2 * Copyright (c) 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the University of
21 * California, Berkeley and its contributors.
22 * 4. Neither the name of the University nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 * @(#)conf.h 8.5 (Berkeley) 1/9/95
39 * $Id: conf.h,v 1.49 1999/01/21 16:15:53 peter Exp $
46 * Definitions of device driver entry switches
56 typedef int d_open_t __P((dev_t dev, int oflags, int devtype, struct proc *p));
57 typedef int d_close_t __P((dev_t dev, int fflag, int devtype, struct proc *p));
58 typedef void d_strategy_t __P((struct buf *bp));
59 typedef int d_parms_t __P((dev_t dev, struct specinfo *sinfo, int ctl));
60 typedef int d_ioctl_t __P((dev_t dev, u_long cmd, caddr_t data,
61 int fflag, struct proc *p));
62 typedef int d_dump_t __P((dev_t dev));
63 typedef int d_psize_t __P((dev_t dev));
65 typedef int d_read_t __P((dev_t dev, struct uio *uio, int ioflag));
66 typedef int d_write_t __P((dev_t dev, struct uio *uio, int ioflag));
67 typedef void d_stop_t __P((struct tty *tp, int rw));
68 typedef int d_reset_t __P((dev_t dev));
69 typedef struct tty *d_devtotty_t __P((dev_t dev));
70 typedef int d_poll_t __P((dev_t dev, int events, struct proc *p));
71 typedef int d_mmap_t __P((dev_t dev, vm_offset_t offset, int nprot));
73 typedef int l_open_t __P((dev_t dev, struct tty *tp));
74 typedef int l_close_t __P((struct tty *tp, int flag));
75 typedef int l_read_t __P((struct tty *tp, struct uio *uio, int flag));
76 typedef int l_write_t __P((struct tty *tp, struct uio *uio, int flag));
77 typedef int l_ioctl_t __P((struct tty *tp, u_long cmd, caddr_t data,
78 int flag, struct proc *p));
79 typedef int l_rint_t __P((int c, struct tty *tp));
80 typedef int l_start_t __P((struct tty *tp));
81 typedef int l_modem_t __P((struct tty *tp, int flag));
90 #define D_TYPEMASK 0xffff
95 #define D_NOCLUSTERR 0x10000 /* disables cluter read */
96 #define D_NOCLUSTERW 0x20000 /* disables cluster write */
97 #define D_NOCLUSTERRW (D_NOCLUSTERR | D_NOCLUSTERW)
98 #define D_CANFREE 0x40000 /* can free blocks */
101 * Control type for d_parms() call.
103 #define DPARM_GET 0 /* ask device to load parms in */
106 * Character device switch table
115 d_reset_t *d_reset; /* XXX not used */
116 d_devtotty_t *d_devtotty;
119 d_strategy_t *d_strategy;
120 char *d_name; /* base device name, e.g. 'vn' */
121 d_parms_t *d_parms; /* populate/override specinfo */
131 extern struct cdevsw *bdevsw[];
132 extern struct cdevsw *cdevsw[];
136 * Line discipline switch table
151 extern struct linesw linesw[];
154 int ldisc_register __P((int , struct linesw *));
155 void ldisc_deregister __P((int));
156 #define LDISC_LOAD -1 /* Loadable line discipline */
168 #define SW_FREED 0x01
169 #define SW_SEQUENTIAL 0x02
170 #define sw_freed sw_flags /* XXX compat */
180 d_devtotty_t nodevtotty;
183 /* Bogus defines for compatibility. */
184 #define noioc noioctl
185 #define nostrat nostrategy
186 #define zerosize nopsize
188 * XXX d_strategy seems to be unused for cdevs that aren't associated with
189 * bdevs and called without checking for it being non-NULL for bdevs.
191 #define nostrategy ((d_strategy_t *)NULL)
196 * nopsize is little used, so not worth having dummy functions for.
198 #define nopsize ((d_psize_t *)NULL)
202 #define nullstop nostop /* one void return is as good as another */
203 #define nullreset noreset /* one unused function is as good as another */
210 struct cdevsw_module_data {
211 int (*chainevh)(struct module *, int, void *); /* next handler */
212 void *chainarg; /* arg for next event handler */
213 dev_t dev; /* device major to use */
214 struct cdevsw *cdevsw; /* device functions */
217 struct bdevsw_module_data {
218 int (*chainevh)(struct module *, int, void *); /* next handler */
219 void *chainarg; /* arg for next event handler */
220 int bdev; /* device major to use */
221 int cdev; /* device major to use */
222 struct cdevsw *cdevsw; /* device functions */
225 #define CDEV_MODULE(name, major, devsw, evh, arg) \
226 static struct cdevsw_module_data name##_cdevsw_mod = { \
227 evh, arg, major == NODEV ? NODEV : makedev(major, 0), &devsw \
230 static moduledata_t name##_mod = { \
232 cdevsw_module_handler, \
235 DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE+major)
237 #define BDEV_MODULE(name, bdev, cdev, devsw, evh, arg) \
238 static struct bdevsw_module_data name##_bdevsw_mod = { \
239 evh, arg, bdev == NODEV ? NODEV : makedev(bdev, 0), \
240 cdev == NODEV ? NODEV : makedev(cdev, 0), &devsw \
243 static moduledata_t name##_mod = { \
245 bdevsw_module_handler, \
248 DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE+cdev)
250 int cdevsw_module_handler __P((struct module *mod, int what, void *arg));
251 int bdevsw_module_handler __P((struct module *mod, int what, void *arg));
253 int cdevsw_add __P((dev_t *descrip,struct cdevsw *new,struct cdevsw **old));
254 void cdevsw_add_generic __P((int bdev, int cdev, struct cdevsw *cdevsw));
255 dev_t chrtoblk __P((dev_t dev));
256 int iskmemdev __P((dev_t dev));
257 int iszerodev __P((dev_t dev));
258 void setconf __P((void));
261 #endif /* !_SYS_CONF_H_ */