2 * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 *---------------------------------------------------------------------------
27 * i4b_ctl.c - i4b system control port driver
28 * ------------------------------------------
30 * $Id: i4b_ctl.c,v 1.37 2000/05/31 08:04:43 hm Exp $
32 * $FreeBSD: src/sys/i4b/driver/i4b_ctl.c,v 1.10.2.3 2001/08/12 16:22:48 hm Exp $
33 * $DragonFly: src/sys/net/i4b/driver/i4b_ctl.c,v 1.14 2006/12/22 23:44:55 swildner Exp $
35 * last edit-date: [Sat Aug 11 18:06:38 2001]
37 *---------------------------------------------------------------------------*/
39 #include "use_i4bctl.h"
42 #error "only 1 (one) i4bctl device allowed!"
47 #include <sys/param.h>
49 #include <sys/kernel.h>
50 #include <sys/systm.h>
52 #include <sys/device.h>
53 #include <sys/socket.h>
56 #include <net/i4b/include/machine/i4b_debug.h>
57 #include <net/i4b/include/machine/i4b_ioctl.h>
59 #include "../include/i4b_global.h"
60 #include "../include/i4b_l3l4.h"
61 #include "../layer2/i4b_l2.h"
63 static int openflag = 0;
65 static d_open_t i4bctlopen;
66 static d_close_t i4bctlclose;
67 static d_ioctl_t i4bctlioctl;
71 static struct dev_ops i4bctl_ops = {
72 { "i4bctl", CDEV_MAJOR, 0 },
74 .d_close = i4bctlclose,
75 .d_ioctl = i4bctlioctl,
78 static void i4bctlattach(void *);
79 PSEUDO_SET(i4bctlattach, i4b_i4bctldrv);
81 #define PDEVSTATIC static
83 /*---------------------------------------------------------------------------*
84 * interface attach routine
85 *---------------------------------------------------------------------------*/
87 i4bctlattach(void *dummy)
89 #ifndef HACK_NO_PSEUDO_ATTACH_MSG
90 kprintf("i4bctl: ISDN system control port attached\n");
94 /*---------------------------------------------------------------------------*
95 * i4bctlopen - device driver open routine
96 *---------------------------------------------------------------------------*/
98 i4bctlopen(struct dev_open_args *ap)
100 cdev_t dev = ap->a_head.a_dev;
109 /*---------------------------------------------------------------------------*
110 * i4bctlclose - device driver close routine
111 *---------------------------------------------------------------------------*/
113 i4bctlclose(struct dev_close_args *ap)
119 /*---------------------------------------------------------------------------*
120 * i4bctlioctl - device driver ioctl routine
121 *---------------------------------------------------------------------------*/
123 i4bctlioctl(struct dev_ioctl_args *ap)
125 cdev_t dev = ap->a_head.a_dev;
139 case I4B_CTL_GET_DEBUG:
140 cdbg = (ctl_debug_t *)ap->a_data;
141 cdbg->l1 = i4b_l1_debug;
142 cdbg->l2 = i4b_l2_debug;
143 cdbg->l3 = i4b_l3_debug;
144 cdbg->l4 = i4b_l4_debug;
147 case I4B_CTL_SET_DEBUG:
148 cdbg = (ctl_debug_t *)ap->a_data;
149 i4b_l1_debug = cdbg->l1;
150 i4b_l2_debug = cdbg->l2;
151 i4b_l3_debug = cdbg->l3;
152 i4b_l4_debug = cdbg->l4;
155 case I4B_CTL_GET_CHIPSTAT:
157 struct chipstat *cst;
158 cst = (struct chipstat *)ap->a_data;
159 (*ctrl_desc[cst->driver_unit].N_MGMT_COMMAND)(cst->driver_unit, CMR_GCST, cst);
163 case I4B_CTL_CLR_CHIPSTAT:
165 struct chipstat *cst;
166 cst = (struct chipstat *)ap->a_data;
167 (*ctrl_desc[cst->driver_unit].N_MGMT_COMMAND)(cst->driver_unit, CMR_CCST, cst);
171 case I4B_CTL_GET_LAPDSTAT:
175 l2s = (l2stat_t *)ap->a_data;
177 if( l2s->unit < 0 || l2s->unit > MAXL1UNITS)
183 sc = &l2_softc[l2s->unit];
185 bcopy(&sc->stat, &l2s->lapdstat, sizeof(lapdstat_t));
189 case I4B_CTL_CLR_LAPDSTAT:
193 up = (int *)ap->a_data;
195 if( *up < 0 || *up > MAXL1UNITS)
203 bzero(&sc->stat, sizeof(lapdstat_t));
212 #endif /* DO_I4B_DEBUG */
215 #endif /* NI4BCTL > 0 */