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.11 2005/06/14 21:19:18 joerg 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/ioccom.h>
51 #include <sys/kernel.h>
52 #include <sys/systm.h>
54 #include <sys/socket.h>
57 #include <net/i4b/include/machine/i4b_debug.h>
58 #include <net/i4b/include/machine/i4b_ioctl.h>
60 #include "../include/i4b_global.h"
61 #include "../include/i4b_l3l4.h"
62 #include "../layer2/i4b_l2.h"
64 static int openflag = 0;
66 static d_open_t i4bctlopen;
67 static d_close_t i4bctlclose;
68 static d_ioctl_t i4bctlioctl;
70 static d_poll_t i4bctlpoll;
71 #define POLLFIELD i4bctlpoll
75 static struct cdevsw i4bctl_cdevsw = {
82 /* open */ i4bctlopen,
83 /* close */ i4bctlclose,
86 /* ioctl */ i4bctlioctl,
89 /* strategy */ nostrategy,
94 static void i4bctlattach(void *);
95 PSEUDO_SET(i4bctlattach, i4b_i4bctldrv);
97 #define PDEVSTATIC static
99 /*---------------------------------------------------------------------------*
100 * initialization at kernel load time
101 *---------------------------------------------------------------------------*/
103 i4bctlinit(void *unused)
105 cdevsw_add(&i4bctl_cdevsw, 0, 0);
108 SYSINIT(i4bctldev, SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR, &i4bctlinit, NULL);
110 /*---------------------------------------------------------------------------*
111 * interface attach routine
112 *---------------------------------------------------------------------------*/
114 i4bctlattach(void *dummy)
116 #ifndef HACK_NO_PSEUDO_ATTACH_MSG
117 printf("i4bctl: ISDN system control port attached\n");
121 /*---------------------------------------------------------------------------*
122 * i4bctlopen - device driver open routine
123 *---------------------------------------------------------------------------*/
125 i4bctlopen(dev_t dev, int flag, int fmt, struct thread *td)
138 /*---------------------------------------------------------------------------*
139 * i4bctlclose - device driver close routine
140 *---------------------------------------------------------------------------*/
142 i4bctlclose(dev_t dev, int flag, int fmt, struct thread *td)
148 /*---------------------------------------------------------------------------*
149 * i4bctlioctl - device driver ioctl routine
150 *---------------------------------------------------------------------------*/
152 i4bctlioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td)
167 case I4B_CTL_GET_DEBUG:
168 cdbg = (ctl_debug_t *)data;
169 cdbg->l1 = i4b_l1_debug;
170 cdbg->l2 = i4b_l2_debug;
171 cdbg->l3 = i4b_l3_debug;
172 cdbg->l4 = i4b_l4_debug;
175 case I4B_CTL_SET_DEBUG:
176 cdbg = (ctl_debug_t *)data;
177 i4b_l1_debug = cdbg->l1;
178 i4b_l2_debug = cdbg->l2;
179 i4b_l3_debug = cdbg->l3;
180 i4b_l4_debug = cdbg->l4;
183 case I4B_CTL_GET_CHIPSTAT:
185 struct chipstat *cst;
186 cst = (struct chipstat *)data;
187 (*ctrl_desc[cst->driver_unit].N_MGMT_COMMAND)(cst->driver_unit, CMR_GCST, cst);
191 case I4B_CTL_CLR_CHIPSTAT:
193 struct chipstat *cst;
194 cst = (struct chipstat *)data;
195 (*ctrl_desc[cst->driver_unit].N_MGMT_COMMAND)(cst->driver_unit, CMR_CCST, cst);
199 case I4B_CTL_GET_LAPDSTAT:
203 l2s = (l2stat_t *)data;
205 if( l2s->unit < 0 || l2s->unit > MAXL1UNITS)
211 sc = &l2_softc[l2s->unit];
213 bcopy(&sc->stat, &l2s->lapdstat, sizeof(lapdstat_t));
217 case I4B_CTL_CLR_LAPDSTAT:
223 if( *up < 0 || *up > MAXL1UNITS)
231 bzero(&sc->stat, sizeof(lapdstat_t));
240 #endif /* DO_I4B_DEBUG */
243 /*---------------------------------------------------------------------------*
244 * i4bctlpoll - device driver poll routine
245 *---------------------------------------------------------------------------*/
247 i4bctlpoll (dev_t dev, int events, struct thread *td)
252 #endif /* NI4BCTL > 0 */