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 #include <sys/queue.h>
46
47 #define SPECNAMELEN 15
48
49 struct tty;
50 struct disk;
51 struct vnode;
52
53 struct specinfo {
54 u_int si_flags;
55 #define SI_STASHED 0x0001 /* created in stashed storage */
56 udev_t si_udev;
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 int si_iosize_max; /* maximum I/O size (for physio &al) */
63 union {
64 struct {
65 struct tty *__sit_tty;
66 } __si_tty;
67 struct {
68 struct disk *__sid_disk;
69 struct mount *__sid_mountpoint;
70 int __sid_bsize_phys; /* min physical block size */
71 int __sid_bsize_best; /* optimal block size */
72 } __si_disk;
73 } __si_u;
74 };
75
76 #define si_tty __si_u.__si_tty.__sit_tty
77 #define si_disk __si_u.__si_disk.__sid_disk
78 #define si_mountpoint __si_u.__si_disk.__sid_mountpoint
79 #define si_bsize_phys __si_u.__si_disk.__sid_bsize_phys
80 #define si_bsize_best __si_u.__si_disk.__sid_bsize_best
81
82 /*
83 * Exported shorthand
84 */
85 #define v_hashchain v_rdev->si_hlist
86 #define v_specmountpoint v_rdev->si_mountpoint
87
88 /*
89 * Special device management
90 */
91 #define SPECHSZ 64
92 #define SPECHASH(rdev) (((unsigned)(minor(rdev)))%SPECHSZ)
93
94 /*
95 * Definitions of device driver entry switches
96 */
97
98 struct buf;
99 struct proc;
100 struct uio;
101 struct knote;
102
103 /*
104 * Note: d_thread_t is provided as a transition aid for those drivers
105 * that treat struct proc/struct thread as an opaque data type and
106 * exist in substantially the same form in both 4.x and 5.x. Writers
107 * of drivers that dips into the d_thread_t structure should use
108 * struct thread or struct proc as appropriate for the version of the
109 * OS they are using. It is provided in lieu of each device driver
110 * inventing its own way of doing this. While it does violate style(9)
111 * in a number of ways, this violation is deemed to be less
112 * important than the benefits that a uniform API between releases
113 * gives.
114 *
115 * Users of struct thread/struct proc that aren't device drivers should
116 * not use d_thread_t.
117 */
118
119 typedef struct proc d_thread_t;
120
121 typedef int d_open_t __P((dev_t dev, int oflags, int devtype, d_thread_t *p));
122 typedef int d_close_t __P((dev_t dev, int fflag, int devtype, d_thread_t *p));
123 typedef void d_strategy_t __P((struct buf *bp));
124 typedef int d_parms_t __P((dev_t dev, struct specinfo *sinfo, int ctl));
125 typedef int d_ioctl_t __P((dev_t dev, u_long cmd, caddr_t data,
126 int fflag, d_thread_t *p));
127 typedef int d_dump_t __P((dev_t dev));
128 typedef int d_psize_t __P((dev_t dev));
129
130 typedef int d_read_t __P((dev_t dev, struct uio *uio, int ioflag));
131 typedef int d_write_t __P((dev_t dev, struct uio *uio, int ioflag));
132 typedef int d_poll_t __P((dev_t dev, int events, d_thread_t *p));
133 typedef int d_kqfilter_t __P((dev_t dev, struct knote *kn));
134 typedef int d_mmap_t __P((dev_t dev, vm_offset_t offset, int nprot));
135
136 typedef int l_open_t __P((dev_t dev, struct tty *tp));
137 typedef int l_close_t __P((struct tty *tp, int flag));
138 typedef int l_read_t __P((struct tty *tp, struct uio *uio, int flag));
139 typedef int l_write_t __P((struct tty *tp, struct uio *uio, int flag));
140 typedef int l_ioctl_t __P((struct tty *tp, u_long cmd, caddr_t data,
141 int flag, d_thread_t *p));
142 typedef int l_rint_t __P((int c, struct tty *tp));
143 typedef int l_start_t __P((struct tty *tp));
144 typedef int l_modem_t __P((struct tty *tp, int flag));
145
146 /*
147 * XXX: The dummy argument can be used to do what strategy1() never
148 * did anywhere: Create a per device flag to lock the device during
149 * label/slice surgery, all calls with a dummy == 0 gets stalled on
150 * a queue somewhere, whereas dummy == 1 are let through. Once out
151 * of surgery, reset the flag and restart all the stuff on the stall
152 * queue.
153 */
154 #define BUF_STRATEGY(bp, dummy) (*devsw((bp)->b_dev)->d_strategy)(bp)
155 /*
156 * Types for d_flags.
157 */
158 #define D_TAPE 0x0001
159 #define D_DISK 0x0002
160 #define D_TTY 0x0004
161 #define D_MEM 0x0008
162
163 #define D_TYPEMASK 0xffff
164
165 /*
166 * Flags for d_flags.
167 */
168 #define D_MEMDISK 0x00010000 /* memory type disk */
169 #define D_NAGGED 0x00020000 /* nagged about missing make_dev() */
170 #define D_CANFREE 0x00040000 /* can free blocks */
171 #define D_TRACKCLOSE 0x00080000 /* track all closes */
172 #define D_KQFILTER 0x00200000 /* has kqfilter entry */
173
174 /*
175 * Character device switch table
176 */
177 struct cdevsw {
178 d_open_t *d_open;
179 d_close_t *d_close;
180 d_read_t *d_read;
181 d_write_t *d_write;
182 d_ioctl_t *d_ioctl;
183 d_poll_t *d_poll;
184 d_mmap_t *d_mmap;
185 d_strategy_t *d_strategy;
186 const char *d_name; /* base device name, e.g. 'vn' */
187 int d_maj;
188 d_dump_t *d_dump;
189 d_psize_t *d_psize;
190 u_int d_flags;
191 int d_bmaj;
192 /* additions below are not binary compatible with 4.2 and below */
193 d_kqfilter_t *d_kqfilter;
194 };
195
196 /*
197 * Line discipline switch table
198 */
199 struct linesw {
200 l_open_t *l_open;
201 l_close_t *l_close;
202 l_read_t *l_read;
203 l_write_t *l_write;
204 l_ioctl_t *l_ioctl;
205 l_rint_t *l_rint;
206 l_start_t *l_start;
207 l_modem_t *l_modem;
208 u_char l_hotchar;
209 };
210
211 #ifdef _KERNEL
212 extern struct linesw linesw[];
213 extern int nlinesw;
214
215 int ldisc_register __P((int , struct linesw *));
216 void ldisc_deregister __P((int));
217 #define LDISC_LOAD -1 /* Loadable line discipline */
218 #endif
219
220 /*
221 * Swap device table
222 */
223 struct swdevt {
224 udev_t sw_dev; /* For quasibogus swapdev reporting */
225 int sw_flags;
226 int sw_nblks;
227 struct vnode *sw_vp;
228 dev_t sw_device;
229 };
230 #define SW_FREED 0x01
231 #define SW_SEQUENTIAL 0x02
232 #define sw_freed sw_flags /* XXX compat */
233
234 #ifdef _KERNEL
235 d_open_t noopen;
236 d_close_t noclose;
237 d_read_t noread;
238 d_write_t nowrite;
239 d_ioctl_t noioctl;
240 d_mmap_t nommap;
241 d_kqfilter_t nokqfilter;
242 #define nostrategy ((d_strategy_t *)NULL)
243 #define nopoll seltrue
244
245 d_dump_t nodump;
246
247 #define NUMCDEVSW 256
248
249 /*
250 * nopsize is little used, so not worth having dummy functions for.
251 */
252 #define nopsize ((d_psize_t *)NULL)
253
254 d_open_t nullopen;
255 d_close_t nullclose;
256
257 l_ioctl_t l_nullioctl;
258 l_read_t l_noread;
259 l_write_t l_nowrite;
260
261 struct module;
262
263 struct devsw_module_data {
264 int (*chainevh)(struct module *, int, void *); /* next handler */
265 void *chainarg; /* arg for next event handler */
266 /* Do not initialize fields hereafter */
267 };
268
269 #define DEV_MODULE(name, evh, arg) \
270 static moduledata_t name##_mod = { \
271 #name, \
272 evh, \
273 arg \
274 }; \
275 DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE)
276
277
278 int cdevsw_add __P((struct cdevsw *new));
279 int cdevsw_remove __P((struct cdevsw *old));
280 int count_dev __P((dev_t dev));
281 void destroy_dev __P((dev_t dev));
282 struct cdevsw *devsw __P((dev_t dev));
283 const char *devtoname __P((dev_t dev));
284 void freedev __P((dev_t dev));
285 int iszerodev __P((dev_t dev));
286 dev_t makebdev __P((int maj, int min));
287 dev_t make_dev __P((struct cdevsw *devsw, int minor, uid_t uid, gid_t gid, int perms, const char *fmt, ...)) __printflike(6, 7);
288 int lminor __P((dev_t dev));
289 void setconf __P((void));
290 dev_t getdiskbyname(char *name);
291
292 /*
293 * XXX: This included for when DEVFS resurfaces
294 */
295
296 #define UID_ROOT 0
297 #define UID_BIN 3
298 #define UID_UUCP 66
299
300 #define GID_WHEEL 0
301 #define GID_KMEM 2
302 #define GID_OPERATOR 5
303 #define GID_BIN 7
304 #define GID_GAMES 13
305 #define GID_DIALER 68
306
307 #endif /* _KERNEL */
308
309 #endif /* !_SYS_CONF_H_ */
Cache object: c0307735a8fd6f09e45fff3929ab5510
|