FreeBSD/Linux Kernel Cross Reference
sys/sys/conf.h
1 /*-
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.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
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.
25 *
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
36 * SUCH DAMAGE.
37 *
38 * @(#)conf.h 8.5 (Berkeley) 1/9/95
39 * $FreeBSD$
40 */
41
42 #ifndef _SYS_CONF_H_
43 #define _SYS_CONF_H_
44
45 /*
46 * Definitions of device driver entry switches
47 */
48
49 struct buf;
50 struct proc;
51 struct tty;
52 struct uio;
53 struct vnode;
54
55 typedef int d_open_t __P((dev_t dev, int oflags, int devtype, struct proc *p));
56 typedef int d_close_t __P((dev_t dev, int fflag, int devtype, struct proc *p));
57 typedef void d_strategy_t __P((struct buf *bp));
58 typedef int d_ioctl_t __P((dev_t dev, u_long cmd, caddr_t data,
59 int fflag, struct proc *p));
60 typedef int d_dump_t __P((dev_t dev));
61 typedef int d_psize_t __P((dev_t dev));
62
63 typedef int d_read_t __P((dev_t dev, struct uio *uio, int ioflag));
64 typedef int d_write_t __P((dev_t dev, struct uio *uio, int ioflag));
65 typedef void d_stop_t __P((struct tty *tp, int rw));
66 typedef int d_reset_t __P((dev_t dev));
67 typedef struct tty *d_devtotty_t __P((dev_t dev));
68 typedef int d_poll_t __P((dev_t dev, int events, struct proc *p));
69 typedef int d_mmap_t __P((dev_t dev, vm_offset_t offset, int nprot));
70
71 typedef int l_open_t __P((dev_t dev, struct tty *tp));
72 typedef int l_close_t __P((struct tty *tp, int flag));
73 typedef int l_read_t __P((struct tty *tp, struct uio *uio, int flag));
74 typedef int l_write_t __P((struct tty *tp, struct uio *uio, int flag));
75 typedef int l_ioctl_t __P((struct tty *tp, u_long cmd, caddr_t data,
76 int flag, struct proc *p));
77 typedef int l_rint_t __P((int c, struct tty *tp));
78 typedef int l_start_t __P((struct tty *tp));
79 typedef int l_modem_t __P((struct tty *tp, int flag));
80
81 /*
82 * Types for d_type.
83 */
84 #define D_TAPE 1
85 #define D_DISK 2
86 #define D_TTY 3
87
88 #define D_TYPEMASK 0xffff
89
90 /*
91 * Flags for d_flags.
92 */
93 #define D_NOCLUSTERR 0x10000 /* disables cluter read */
94 #define D_NOCLUSTERW 0x20000 /* disables cluster write */
95 #define D_NOCLUSTERRW (D_NOCLUSTERR | D_NOCLUSTERW)
96 #define D_CANFREE 0x40000 /* can free blocks */
97
98
99 /*
100 * Character device switch table
101 */
102 struct cdevsw {
103 d_open_t *d_open;
104 d_close_t *d_close;
105 d_read_t *d_read;
106 d_write_t *d_write;
107 d_ioctl_t *d_ioctl;
108 d_stop_t *d_stop;
109 d_reset_t *d_reset; /* XXX not used */
110 d_devtotty_t *d_devtotty;
111 d_poll_t *d_poll;
112 d_mmap_t *d_mmap;
113 d_strategy_t *d_strategy;
114 char *d_name; /* see above */
115 void *d_spare;
116 int d_maj;
117 d_dump_t *d_dump;
118 d_psize_t *d_psize;
119 u_int d_flags;
120 int d_maxio;
121 int d_bmaj;
122 };
123
124 #ifdef KERNEL
125 extern struct cdevsw *bdevsw[];
126 extern struct cdevsw *cdevsw[];
127 #endif
128
129 /*
130 * Line discipline switch table
131 */
132 struct linesw {
133 l_open_t *l_open;
134 l_close_t *l_close;
135 l_read_t *l_read;
136 l_write_t *l_write;
137 l_ioctl_t *l_ioctl;
138 l_rint_t *l_rint;
139 l_start_t *l_start;
140 l_modem_t *l_modem;
141 u_char l_hotchar;
142 };
143
144 #ifdef KERNEL
145 extern struct linesw linesw[];
146 extern int nlinesw;
147
148 int ldisc_register __P((int , struct linesw *));
149 void ldisc_deregister __P((int));
150 #define LDISC_LOAD -1 /* Loadable line discipline */
151 #endif
152
153 /*
154 * Swap device table
155 */
156 struct swdevt {
157 dev_t sw_dev;
158 int sw_flags;
159 int sw_nblks;
160 struct vnode *sw_vp;
161 };
162 #define SW_FREED 0x01
163 #define SW_SEQUENTIAL 0x02
164 #define sw_freed sw_flags /* XXX compat */
165
166 #ifdef KERNEL
167 d_open_t noopen;
168 d_close_t noclose;
169 d_read_t noread;
170 d_write_t nowrite;
171 d_ioctl_t noioctl;
172 d_stop_t nostop;
173 d_reset_t noreset;
174 d_devtotty_t nodevtotty;
175 d_mmap_t nommap;
176
177 /* Bogus defines for compatibility. */
178 #define noioc noioctl
179 #define nostrat nostrategy
180 #define zerosize nopsize
181 /*
182 * XXX d_strategy seems to be unused for cdevs that aren't associated with
183 * bdevs and called without checking for it being non-NULL for bdevs.
184 */
185 #define nostrategy ((d_strategy_t *)NULL)
186
187 d_dump_t nodump;
188
189 /*
190 * nopsize is little used, so not worth having dummy functions for.
191 */
192 #define nopsize ((d_psize_t *)NULL)
193
194 d_open_t nullopen;
195 d_close_t nullclose;
196 #define nullstop nostop /* one void return is as good as another */
197 #define nullreset noreset /* one unused function is as good as another */
198
199 l_read_t l_noread;
200 l_write_t l_nowrite;
201
202 struct module;
203
204 struct cdevsw_module_data {
205 int (*chainevh)(struct module *, int, void *); /* next handler */
206 void *chainarg; /* arg for next event handler */
207 dev_t dev; /* device major to use */
208 struct cdevsw *cdevsw; /* device functions */
209 };
210
211 struct bdevsw_module_data {
212 int (*chainevh)(struct module *, int, void *); /* next handler */
213 void *chainarg; /* arg for next event handler */
214 int bdev; /* device major to use */
215 int cdev; /* device major to use */
216 struct cdevsw *cdevsw; /* device functions */
217 };
218
219 #define CDEV_MODULE(name, major, devsw, evh, arg) \
220 static struct cdevsw_module_data name##_cdevsw_mod = { \
221 evh, arg, major == NODEV ? NODEV : makedev(major, 0), &devsw \
222 }; \
223 \
224 static moduledata_t name##_mod = { \
225 #name, \
226 cdevsw_module_handler, \
227 &name##_cdevsw_mod \
228 }; \
229 DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE+major)
230
231 #define BDEV_MODULE(name, bdev, cdev, devsw, evh, arg) \
232 static struct bdevsw_module_data name##_bdevsw_mod = { \
233 evh, arg, bdev == NODEV ? NODEV : makedev(bdev, 0), \
234 cdev == NODEV ? NODEV : makedev(cdev, 0), &devsw \
235 }; \
236 \
237 static moduledata_t name##_mod = { \
238 #name, \
239 bdevsw_module_handler, \
240 &name##_bdevsw_mod \
241 }; \
242 DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE+cdev)
243
244 int cdevsw_module_handler __P((struct module *mod, int what, void *arg));
245 int bdevsw_module_handler __P((struct module *mod, int what, void *arg));
246
247 int cdevsw_add __P((dev_t *descrip,struct cdevsw *new,struct cdevsw **old));
248 void cdevsw_add_generic __P((int bdev, int cdev, struct cdevsw *cdevsw));
249 dev_t chrtoblk __P((dev_t dev));
250 int iskmemdev __P((dev_t dev));
251 int iszerodev __P((dev_t dev));
252 void setconf __P((void));
253
254 /*
255 * XXX: This included for when DEVFS resurfaces
256 */
257
258 #define UID_ROOT 0
259 #define UID_BIN 3
260 #define UID_UUCP 66
261
262 #define GID_WHEEL 0
263 #define GID_KMEM 2
264 #define GID_OPERATOR 5
265 #define GID_BIN 7
266 #define GID_GAMES 13
267 #define GID_DIALER 68
268
269 #endif /* KERNEL */
270
271 #endif /* !_SYS_CONF_H_ */
Cache object: addb1de2f93da00258802f197eaf951d
|