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 * $FreeBSD: src/sys/sys/conf.h,v 1.103.2.6 2002/03/11 01:14:55 dd Exp $
40 * $DragonFly: src/sys/sys/conf.h,v 1.9 2005/02/21 18:56:02 dillon Exp $
46 #include <sys/queue.h>
49 #define SPECNAMELEN 15
59 LIST_ENTRY(specinfo) si_hash;
60 SLIST_HEAD(, vnode) si_hlist;
61 char si_name[SPECNAMELEN + 1];
64 struct cdevsw *si_devsw; /* direct device switch */
65 struct lwkt_port *si_port; /* direct port dispatch */
66 int si_iosize_max; /* maximum I/O size (for physio &al) */
70 struct tty *__sit_tty;
73 struct disk *__sid_disk;
74 struct mount *__sid_mountpoint;
75 int __sid_bsize_phys; /* min physical block size */
76 int __sid_bsize_best; /* optimal block size */
79 time_t si_lastread; /* time_second */
80 time_t si_lastwrite; /* time_second */
83 #define SI_STASHED 0x0001 /* created in stashed storage */
84 #define SI_HASHED 0x0002 /* in (maj,min) hash table */
85 #define SI_ADHOC 0x0004 /* created via make_adhoc_dev() or udev2dev() */
87 #define si_tty __si_u.__si_tty.__sit_tty
88 #define si_disk __si_u.__si_disk.__sid_disk
89 #define si_mountpoint __si_u.__si_disk.__sid_mountpoint
90 #define si_bsize_phys __si_u.__si_disk.__sid_bsize_phys
91 #define si_bsize_best __si_u.__si_disk.__sid_bsize_best
93 #define CDEVSW_ALL_MINORS 0 /* mask of 0 always matches 0 */
96 * Special device management
99 #define SPECHASH(rdev) (((unsigned)(minor(rdev)))%SPECHSZ)
102 * Definitions of device driver entry switches
111 * Note: d_thread_t is provided as a transition aid for those drivers
112 * that treat struct proc/struct thread as an opaque data type and
113 * exist in substantially the same form in both 4.x and 5.x. Writers
114 * of drivers that dips into the d_thread_t structure should use
115 * struct thread or struct proc as appropriate for the version of the
116 * OS they are using. It is provided in lieu of each device driver
117 * inventing its own way of doing this. While it does violate style(9)
118 * in a number of ways, this violation is deemed to be less
119 * important than the benefits that a uniform API between releases
122 * Users of struct thread/struct proc that aren't device drivers should
123 * not use d_thread_t.
129 typedef struct thread d_thread_t;
130 typedef int d_clone_t (dev_t dev);
131 typedef int d_open_t (dev_t dev, int oflags, int devtype, d_thread_t *td);
132 typedef int d_close_t (dev_t dev, int fflag, int devtype, d_thread_t *td);
133 typedef void d_strategy_t (struct buf *bp);
134 typedef int d_ioctl_t (dev_t dev, u_long cmd, caddr_t data,
135 int fflag, d_thread_t *td);
136 typedef int d_dump_t (dev_t dev, u_int count, u_int blkno, u_int secsize);
137 typedef int d_psize_t (dev_t dev);
139 typedef int d_read_t (dev_t dev, struct uio *uio, int ioflag);
140 typedef int d_write_t (dev_t dev, struct uio *uio, int ioflag);
141 typedef int d_poll_t (dev_t dev, int events, d_thread_t *td);
142 typedef int d_kqfilter_t (dev_t dev, struct knote *kn);
143 typedef int d_mmap_t (dev_t dev, vm_offset_t offset, int nprot);
145 typedef int l_open_t (dev_t dev, struct tty *tp);
146 typedef int l_close_t (struct tty *tp, int flag);
147 typedef int l_read_t (struct tty *tp, struct uio *uio, int flag);
148 typedef int l_write_t (struct tty *tp, struct uio *uio, int flag);
149 typedef int l_ioctl_t (struct tty *tp, u_long cmd, caddr_t data,
150 int flag, d_thread_t *td);
151 typedef int l_rint_t (int c, struct tty *tp);
152 typedef int l_start_t (struct tty *tp);
153 typedef int l_modem_t (struct tty *tp, int flag);
156 * XXX: The dummy argument can be used to do what strategy1() never
157 * did anywhere: Create a per device flag to lock the device during
158 * label/slice surgery, all calls with a dummy == 0 gets stalled on
159 * a queue somewhere, whereas dummy == 1 are let through. Once out
160 * of surgery, reset the flag and restart all the stuff on the stall
163 #define BUF_STRATEGY(bp, dummy) dev_dstrategy((bp)->b_dev, bp)
167 #define D_TAPE 0x0001
168 #define D_DISK 0x0002
172 #define D_TYPEMASK 0xffff
177 #define D_MEMDISK 0x00010000 /* memory type disk */
178 #define D_NAGGED 0x00020000 /* nagged about missing make_dev() */
179 #define D_CANFREE 0x00040000 /* can free blocks */
180 #define D_TRACKCLOSE 0x00080000 /* track all closes */
181 #define D_MASTER 0x00100000 /* used by pty/tty code */
182 #define D_KQFILTER 0x00200000 /* has kqfilter entry */
185 * Character device switch table.
187 * NOTE: positions are hard coded for static structure initialization.
190 const char *d_name; /* base device name, e.g. 'vn' */
191 int d_maj; /* major (char) device number */
192 u_int d_flags; /* D_ flags */
193 struct lwkt_port *d_port; /* port (template only) */
194 d_clone_t *d_clone; /* clone from base cdevsw */
197 * Old style vectors are used only if d_port is NULL when the cdevsw
198 * is added to the system. They have been renamed to prevent misuse.
201 d_close_t *old_close;
203 d_write_t *old_write;
204 d_ioctl_t *old_ioctl;
207 d_strategy_t *old_strategy;
209 d_psize_t *old_psize;
210 d_kqfilter_t *old_kqfilter;
211 void (*old_dummy1)(void); /* expansion space */
212 void (*old_dummy2)(void);
213 void (*old_dummy3)(void);
214 void (*old_dummy4)(void);
215 int d_refs; /* ref count */
216 void *d_data; /* custom driver data */
220 struct cdevlink *next;
223 struct cdevsw *devsw;
227 * Line discipline switch table
242 extern struct linesw linesw[];
245 int ldisc_register (int , struct linesw *);
246 void ldisc_deregister (int);
247 #define LDISC_LOAD -1 /* Loadable line discipline */
254 udev_t sw_dev; /* For quasibogus swapdev reporting */
260 #define SW_FREED 0x01
261 #define SW_SEQUENTIAL 0x02
262 #define sw_freed sw_flags /* XXX compat */
272 d_kqfilter_t nokqfilter;
273 d_strategy_t nostrategy;
278 #define NUMCDEVSW 256
283 l_ioctl_t l_nullioctl;
289 struct devsw_module_data {
290 int (*chainevh)(struct module *, int, void *); /* next handler */
291 void *chainarg; /* arg for next event handler */
292 /* Do not initialize fields hereafter */
295 #define DEV_MODULE(name, evh, arg) \
296 static moduledata_t name##_mod = { \
301 DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE)
303 extern struct cdevsw dead_cdevsw;
305 void compile_devsw(struct cdevsw *);
306 int cdevsw_add (struct cdevsw *, u_int mask, u_int match);
307 struct cdevsw *cdevsw_add_override (dev_t, u_int mask, u_int match);
308 struct lwkt_port *cdevsw_dev_override(dev_t dev, struct lwkt_port *port);
310 int cdevsw_remove (struct cdevsw *, u_int mask, u_int match);
311 struct cdevsw *cdevsw_get (int x, int y);
312 void cdevsw_release (struct cdevsw *);
313 int count_dev (dev_t dev);
314 int count_udev (udev_t dev);
315 void destroy_dev (dev_t dev);
316 void destroy_all_dev (struct cdevsw *, u_int mask, u_int match);
317 void release_dev (dev_t dev);
318 dev_t reference_dev (dev_t dev);
319 struct cdevsw *devsw (dev_t dev);
320 const char *devtoname (dev_t dev);
321 void freedev (dev_t dev);
322 int iszerodev (dev_t dev);
323 dev_t make_dev (struct cdevsw *devsw, int minor, uid_t uid, gid_t gid, int perms, const char *fmt, ...) __printflike(6, 7);
324 dev_t make_adhoc_dev (struct cdevsw *devsw, int minor);
325 dev_t make_sub_dev (dev_t dev, int minor);
326 int lminor (dev_t dev);
328 dev_t getdiskbyname(const char *name);
329 int dev_is_good(dev_t dev);
332 * XXX: This included for when DEVFS resurfaces
341 #define GID_OPERATOR 5
344 #define GID_DIALER 68
348 #endif /* !_SYS_CONF_H_ */