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
45 #include <sys/queue.h>
47 #define SPECNAMELEN 15
55 #define SI_STASHED 0x0001 /* created in stashed storage */
57 LIST_ENTRY(specinfo) si_hash;
58 SLIST_HEAD(, vnode) si_hlist;
59 char si_name[SPECNAMELEN + 1];
60 void *si_drv1, *si_drv2;
61 struct cdevsw *si_devsw;
62 void *si_devfs; /* save cookie for devfs operations */
63 void *si_bdevfs; /* XXX block device (should go away) */
64 int si_iosize_max; /* maximum I/O size (for physio &al) */
67 struct tty *__sit_tty;
70 struct disk *__sid_disk;
71 struct mount *__sid_mountpoint;
72 int __sid_bsize_phys; /* min physical block size */
73 int __sid_bsize_best; /* optimal block size */
78 #define si_tty __si_u.__si_tty.__sit_tty
79 #define si_disk __si_u.__si_disk.__sid_disk
80 #define si_mountpoint __si_u.__si_disk.__sid_mountpoint
81 #define si_bsize_phys __si_u.__si_disk.__sid_bsize_phys
82 #define si_bsize_best __si_u.__si_disk.__sid_bsize_best
87 #define v_hashchain v_rdev->si_hlist
88 #define v_specmountpoint v_rdev->si_mountpoint
91 * Special device management
94 #define SPECHASH(rdev) (((unsigned)(minor(rdev)))%SPECHSZ)
97 * Definitions of device driver entry switches
104 typedef int d_open_t __P((dev_t dev, int oflags, int devtype, struct proc *p));
105 typedef int d_close_t __P((dev_t dev, int fflag, int devtype, struct proc *p));
106 typedef void d_strategy_t __P((struct buf *bp));
107 typedef int d_parms_t __P((dev_t dev, struct specinfo *sinfo, int ctl));
108 typedef int d_ioctl_t __P((dev_t dev, u_long cmd, caddr_t data,
109 int fflag, struct proc *p));
110 typedef int d_dump_t __P((dev_t dev));
111 typedef int d_psize_t __P((dev_t dev));
113 typedef int d_read_t __P((dev_t dev, struct uio *uio, int ioflag));
114 typedef int d_write_t __P((dev_t dev, struct uio *uio, int ioflag));
115 typedef int d_poll_t __P((dev_t dev, int events, struct proc *p));
116 typedef int d_mmap_t __P((dev_t dev, vm_offset_t offset, int nprot));
118 typedef int l_open_t __P((dev_t dev, struct tty *tp));
119 typedef int l_close_t __P((struct tty *tp, int flag));
120 typedef int l_read_t __P((struct tty *tp, struct uio *uio, int flag));
121 typedef int l_write_t __P((struct tty *tp, struct uio *uio, int flag));
122 typedef int l_ioctl_t __P((struct tty *tp, u_long cmd, caddr_t data,
123 int flag, struct proc *p));
124 typedef int l_rint_t __P((int c, struct tty *tp));
125 typedef int l_start_t __P((struct tty *tp));
126 typedef int l_modem_t __P((struct tty *tp, int flag));
128 /* This is type of the function DEVFS uses to hook into the kernel with */
129 typedef void devfs_create_t __P((dev_t dev, uid_t uid, gid_t gid, int perms));
130 typedef void devfs_remove_t __P((dev_t dev));
133 * XXX: The dummy argument can be used to do what strategy1() never
134 * did anywhere: Create a per device flag to lock the device during
135 * label/slice surgery, all calls with a dummy == 0 gets stalled on
136 * a queue somewhere, whereas dummy == 1 are let through. Once out
137 * of surgery, reset the flag and restart all the stuff on the stall
140 #define DEV_STRATEGY(bp, dummy) \
142 if ((!(bp)->b_iocmd) || ((bp)->b_iocmd & ((bp)->b_iocmd - 1))) \
143 Debugger("d_iocmd botch"); \
144 (*devsw((bp)->b_dev)->d_strategy)(bp); \
150 #define D_TAPE 0x0001
151 #define D_DISK 0x0002
155 #define D_TYPEMASK 0xffff
160 #define D_MEMDISK 0x10000 /* memory type disk */
161 #define D_NAGGED 0x20000 /* nagged about missing make_dev() */
162 #define D_CANFREE 0x40000 /* can free blocks */
163 #define D_TRACKCLOSE 0x80000 /* track all closes */
166 * Character device switch table
176 d_strategy_t *d_strategy;
177 const char *d_name; /* base device name, e.g. 'vn' */
186 * Line discipline switch table
201 extern struct linesw linesw[];
204 int ldisc_register __P((int , struct linesw *));
205 void ldisc_deregister __P((int));
206 #define LDISC_LOAD -1 /* Loadable line discipline */
213 udev_t sw_dev; /* For quasibogus swapdev reporting */
219 #define SW_FREED 0x01
220 #define SW_SEQUENTIAL 0x02
221 #define sw_freed sw_flags /* XXX compat */
230 #define nostrategy ((d_strategy_t *)NULL)
231 #define nopoll seltrue
235 #define NUMCDEVSW 256
238 * nopsize is little used, so not worth having dummy functions for.
240 #define nopsize ((d_psize_t *)NULL)
250 struct devsw_module_data {
251 int (*chainevh)(struct module *, int, void *); /* next handler */
252 void *chainarg; /* arg for next event handler */
253 /* Do not initialize fields hereafter */
256 #define DEV_MODULE(name, evh, arg) \
257 static moduledata_t name##_mod = { \
262 DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE)
265 int cdevsw_add __P((struct cdevsw *new));
266 int cdevsw_remove __P((struct cdevsw *old));
267 int count_dev __P((dev_t dev));
268 void destroy_dev __P((dev_t dev));
269 struct cdevsw *devsw __P((dev_t dev));
270 const char *devtoname __P((dev_t dev));
271 void freedev __P((dev_t dev));
272 int iszerodev __P((dev_t dev));
273 dev_t makebdev __P((int maj, int min));
274 dev_t make_dev __P((struct cdevsw *devsw, int minor, uid_t uid, gid_t gid, int perms, char *fmt, ...)) __printflike(6, 7);
275 int lminor __P((dev_t dev));
276 void setconf __P((void));
277 dev_t getdiskbyname(char *name);
279 extern devfs_create_t *devfs_create_hook;
282 * XXX: This included for when DEVFS resurfaces
291 #define GID_OPERATOR 5
294 #define GID_DIALER 68
298 #endif /* !_SYS_CONF_H_ */