xref: /openbsd/sys/sys/conf.h (revision a74a190b)
1 /*	$OpenBSD: conf.h,v 1.166 2024/10/30 06:16:27 jsg Exp $	*/
2 /*	$NetBSD: conf.h,v 1.33 1996/05/03 20:03:32 christos Exp $	*/
3 
4 /*-
5  * Copyright (c) 1990, 1993
6  *	The Regents of the University of California.  All rights reserved.
7  * (c) UNIX System Laboratories, Inc.
8  * All or some portions of this file are derived from material licensed
9  * to the University of California by American Telephone and Telegraph
10  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
11  * the permission of UNIX System Laboratories, Inc.
12  *
13  * Redistribution and use in source and binary forms, with or without
14  * modification, are permitted provided that the following conditions
15  * are met:
16  * 1. Redistributions of source code must retain the above copyright
17  *    notice, this list of conditions and the following disclaimer.
18  * 2. Redistributions in binary form must reproduce the above copyright
19  *    notice, this list of conditions and the following disclaimer in the
20  *    documentation and/or other materials provided with the distribution.
21  * 3. Neither the name of the University nor the names of its contributors
22  *    may be used to endorse or promote products derived from this software
23  *    without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35  * SUCH DAMAGE.
36  *
37  *	@(#)conf.h	8.3 (Berkeley) 1/21/94
38  */
39 
40 
41 #ifndef _SYS_CONF_H_
42 #define _SYS_CONF_H_
43 
44 /*
45  * Definitions of device driver entry switches
46  */
47 
48 struct buf;
49 struct proc;
50 struct tty;
51 struct uio;
52 struct knote;
53 
54 /*
55  * Types for d_type
56  */
57 #define	D_DISK	1
58 #define	D_TTY	2
59 
60 /*
61  * Flags for d_flags
62  */
63 #define D_CLONE		0x0001		/* clone upon open */
64 
65 #ifdef _KERNEL
66 
67 #define	dev_type_open(n)	int n(dev_t, int, int, struct proc *)
68 #define	dev_type_close(n)	int n(dev_t, int, int, struct proc *)
69 #define	dev_type_strategy(n)	void n(struct buf *)
70 #define	dev_type_ioctl(n) \
71 	int n(dev_t, u_long, caddr_t, int, struct proc *)
72 
73 #define	dev_decl(n,t)	__CONCAT(dev_type_,t)(__CONCAT(n,t))
74 #define	dev_init(c,n,t) \
75 	((c) > 0 ? __CONCAT(n,t) : (__CONCAT(dev_type_,t)((*))) enxio)
76 
77 #endif /* _KERNEL */
78 
79 /*
80  * Block device switch table
81  */
82 struct bdevsw {
83 	int	(*d_open)(dev_t dev, int oflags, int devtype,
84 				     struct proc *p);
85 	int	(*d_close)(dev_t dev, int fflag, int devtype,
86 				     struct proc *p);
87 	void	(*d_strategy)(struct buf *bp);
88 	int	(*d_ioctl)(dev_t dev, u_long cmd, caddr_t data,
89 				     int fflag, struct proc *p);
90 	int	(*d_dump)(dev_t dev, daddr_t blkno, caddr_t va,
91 				    size_t size);
92 	daddr_t (*d_psize)(dev_t dev);
93 	u_int	d_type;
94 	/* u_int	d_flags; */
95 };
96 
97 #ifdef _KERNEL
98 
99 extern struct bdevsw bdevsw[];
100 
101 /* bdevsw-specific types */
102 #define	dev_type_dump(n)	int n(dev_t, daddr_t, caddr_t, size_t)
103 #define	dev_type_size(n)	daddr_t n(dev_t)
104 
105 /* bdevsw-specific initializations */
106 #define	dev_size_init(c,n)	(c > 0 ? __CONCAT(n,size) : 0)
107 
108 #define	bdev_decl(n) \
109 	dev_decl(n,open); dev_decl(n,close); dev_decl(n,strategy); \
110 	dev_decl(n,ioctl); dev_decl(n,dump); dev_decl(n,size)
111 
112 #define	bdev_disk_init(c,n) { \
113 	dev_init(c,n,open), dev_init(c,n,close), \
114 	dev_init(c,n,strategy), dev_init(c,n,ioctl), \
115 	dev_init(c,n,dump), dev_size_init(c,n), D_DISK }
116 
117 #define	bdev_swap_init(c,n) { \
118 	(dev_type_open((*))) enodev, (dev_type_close((*))) enodev, \
119 	dev_init(c,n,strategy), (dev_type_ioctl((*))) enodev, \
120 	(dev_type_dump((*))) enodev, 0 }
121 
122 #define	bdev_notdef() { \
123 	(dev_type_open((*))) enodev, (dev_type_close((*))) enodev, \
124 	(dev_type_strategy((*))) enodev, (dev_type_ioctl((*))) enodev, \
125 	(dev_type_dump((*))) enodev, 0 }
126 
127 #endif
128 
129 /*
130  * Character device switch table
131  */
132 struct cdevsw {
133 	int	(*d_open)(dev_t dev, int oflags, int devtype,
134 				     struct proc *p);
135 	int	(*d_close)(dev_t dev, int fflag, int devtype,
136 				     struct proc *);
137 	int	(*d_read)(dev_t dev, struct uio *uio, int ioflag);
138 	int	(*d_write)(dev_t dev, struct uio *uio, int ioflag);
139 	int	(*d_ioctl)(dev_t dev, u_long cmd, caddr_t data,
140 				     int fflag, struct proc *p);
141 	int	(*d_stop)(struct tty *tp, int rw);
142 	struct tty *
143 		(*d_tty)(dev_t dev);
144 	paddr_t	(*d_mmap)(dev_t, off_t, int);
145 	u_int	d_type;
146 	u_int	d_flags;
147 	int	(*d_kqfilter)(dev_t dev, struct knote *kn);
148 };
149 
150 #ifdef _KERNEL
151 
152 extern struct cdevsw cdevsw[];
153 
154 /* cdevsw-specific types */
155 #define	dev_type_read(n)	int n(dev_t, struct uio *, int)
156 #define	dev_type_write(n)	int n(dev_t, struct uio *, int)
157 #define	dev_type_stop(n)	int n(struct tty *, int)
158 #define	dev_type_tty(n)		struct tty *n(dev_t)
159 #define	dev_type_mmap(n)	paddr_t n(dev_t, off_t, int)
160 #define dev_type_kqfilter(n)	int n(dev_t, struct knote *)
161 
162 #define	cdev_decl(n) \
163 	dev_decl(n,open); dev_decl(n,close); dev_decl(n,read); \
164 	dev_decl(n,write); dev_decl(n,ioctl); dev_decl(n,stop); \
165 	dev_decl(n,tty); dev_decl(n,mmap); \
166 	dev_decl(n,kqfilter)
167 
168 /* open, close, read, write, ioctl */
169 #define	cdev_disk_init(c,n) { \
170 	dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
171 	dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
172 	0, (dev_type_mmap((*))) enodev, \
173 	D_DISK, 0, seltrue_kqfilter }
174 
175 /* open, close, read, write, ioctl */
176 #define	cdev_tape_init(c,n) { \
177 	dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
178 	dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
179 	0, (dev_type_mmap((*))) enodev, \
180 	0, 0, seltrue_kqfilter }
181 
182 /* open, close, read, write, ioctl, stop, tty */
183 #define	cdev_tty_init(c,n) { \
184 	dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
185 	dev_init(c,n,write), dev_init(c,n,ioctl), dev_init(c,n,stop), \
186 	dev_init(c,n,tty), (dev_type_mmap((*))) enodev, \
187 	D_TTY, 0, ttkqfilter }
188 
189 /* open, close, read, ioctl, kqfilter */
190 #define	cdev_mouse_init(c,n) { \
191 	dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
192 	(dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
193 	(dev_type_stop((*))) enodev, 0, \
194 	(dev_type_mmap((*))) enodev , 0, 0, dev_init(c,n,kqfilter) }
195 
196 #define	cdev_notdef() { \
197 	(dev_type_open((*))) enodev, (dev_type_close((*))) enodev, \
198 	(dev_type_read((*))) enodev, (dev_type_write((*))) enodev, \
199 	(dev_type_ioctl((*))) enodev, (dev_type_stop((*))) enodev, \
200 	0, (dev_type_mmap((*))) enodev, 0, 0, seltrue_kqfilter }
201 
202 /* open, close, read, write, ioctl, kqfilter -- XXX should be a tty */
203 #define	cdev_cn_init(c,n) { \
204 	dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
205 	dev_init(c,n,write), dev_init(c,n,ioctl), dev_init(c,n,stop), \
206 	0, (dev_type_mmap((*))) enodev, \
207 	D_TTY, 0, dev_init(c,n,kqfilter) }
208 
209 /* open, read, write, ioctl, kqfilter -- XXX should be a tty */
210 #define cdev_ctty_init(c,n) { \
211 	dev_init(c,n,open), (dev_type_close((*))) nullop, dev_init(c,n,read), \
212 	dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) nullop, \
213 	0, (dev_type_mmap((*))) enodev, \
214 	D_TTY, 0, dev_init(c,n,kqfilter) }
215 
216 /* open, close, read, write, ioctl, mmap */
217 #define cdev_mm_init(c,n) { \
218 	dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
219 	dev_init(c,n,write), dev_init(c,n,ioctl), \
220 	(dev_type_stop((*))) enodev, 0, dev_init(c,n,mmap), \
221 	0, 0, seltrue_kqfilter }
222 
223 /* open, close, read, write, ioctl, tty, kqfilter */
224 #define cdev_ptc_init(c,n) { \
225 	dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
226 	dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) nullop, \
227 	dev_init(c,n,tty), (dev_type_mmap((*))) enodev, \
228 	D_TTY, 0, dev_init(c,n,kqfilter) }
229 
230 /* open, close, read, write, ioctl, mmap */
231 #define cdev_ptm_init(c,n) { \
232 	dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
233 	(dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
234 	(dev_type_stop((*))) enodev, 0, (dev_type_mmap((*))) enodev }
235 
236 /* open, close, read, ioctl, kqfilter XXX should be a generic device */
237 #define cdev_log_init(c,n) { \
238 	dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
239 	(dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
240 	(dev_type_stop((*))) enodev, 0, \
241 	(dev_type_mmap((*))) enodev, 0, 0, dev_init(c,n,kqfilter) }
242 
243 /* open */
244 #define cdev_fd_init(c,n) { \
245 	dev_init(c,n,open), (dev_type_close((*))) enodev, \
246 	(dev_type_read((*))) enodev, (dev_type_write((*))) enodev, \
247 	(dev_type_ioctl((*))) enodev, (dev_type_stop((*))) enodev, \
248 	0, (dev_type_mmap((*))) enodev }
249 
250 /* open, close, read, write, ioctl, kqfilter -- XXX should be generic device */
251 #define cdev_tun_init(c,n) { \
252 	dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
253 	dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
254 	0, (dev_type_mmap((*))) enodev, \
255 	0, 0, dev_init(c,n,kqfilter) }
256 
257 /* open, close, ioctl, kqfilter -- XXX should be generic device */
258 #define cdev_vscsi_init(c,n) { \
259 	dev_init(c,n,open), dev_init(c,n,close), \
260 	(dev_type_read((*))) enodev, (dev_type_write((*))) enodev, \
261 	dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
262 	0, (dev_type_mmap((*))) enodev, \
263 	0, 0, dev_init(c,n,kqfilter) }
264 
265 /* open, close, read, write, ioctl, kqfilter -- XXX should be generic device */
266 #define cdev_pppx_init(c,n) { \
267 	dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
268 	dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
269 	0, (dev_type_mmap((*))) enodev, \
270 	0, 0, dev_init(c,n,kqfilter) }
271 
272 /* open, close, read, write, ioctl, kqfilter, cloning -- XXX should be generic device */
273 #define cdev_bpf_init(c,n) { \
274 	dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
275 	dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
276 	0, (dev_type_mmap((*))) enodev, \
277 	0, D_CLONE, dev_init(c,n,kqfilter) }
278 
279 /* open, close, ioctl */
280 #define	cdev_ch_init(c,n) { \
281 	dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
282 	(dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
283 	(dev_type_stop((*))) enodev, 0, \
284 	(dev_type_mmap((*))) enodev }
285 
286 /* open, close, ioctl */
287 #define       cdev_uk_init(c,n) { \
288 	dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
289 	(dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
290 	(dev_type_stop((*))) enodev, 0, \
291 	(dev_type_mmap((*))) enodev }
292 
293 /* open, close, read, write, ioctl, kqfilter */
294 #define cdev_audio_init(c,n) { \
295 	dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
296 	dev_init(c,n,write), dev_init(c,n,ioctl), \
297 	(dev_type_stop((*))) enodev, 0, \
298 	(dev_type_mmap((*))) enodev, 0, 0, dev_init(c,n,kqfilter) }
299 
300 /* open, close, read, write, ioctl, kqfilter */
301 #define cdev_midi_init(c,n) { \
302 	dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
303 	dev_init(c,n,write), dev_init(c,n,ioctl), \
304 	(dev_type_stop((*))) enodev, 0, \
305 	(dev_type_mmap((*))) enodev, 0, 0, dev_init(c,n,kqfilter) }
306 
307 /* open, close, read */
308 #define cdev_ksyms_init(c,n) { \
309 	dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
310 	(dev_type_write((*))) enodev, (dev_type_ioctl((*))) enodev, \
311 	(dev_type_stop((*))) enodev, 0, \
312 	(dev_type_mmap((*))) enodev, 0, 0, seltrue_kqfilter }
313 
314 /* open, close, ioctl */
315 #define cdev_kstat_init(c,n) { \
316 	dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
317 	(dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
318 	(dev_type_stop((*))) enodev, 0, \
319 	(dev_type_mmap((*))) enodev }
320 
321 /* open, close, read, write, ioctl, stop, tty, mmap, kqfilter */
322 #define	cdev_wsdisplay_init(c,n) { \
323 	dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
324 	dev_init(c,n,write), dev_init(c,n,ioctl), dev_init(c,n,stop), \
325 	dev_init(c,n,tty), dev_init(c,n,mmap), \
326 	D_TTY, 0, dev_init(c,n,kqfilter) }
327 
328 /* open, close, read, write, ioctl, kqfilter */
329 #define	cdev_random_init(c,n) { \
330 	dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
331 	dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
332 	0, (dev_type_mmap((*))) enodev, \
333 	0, 0, dev_init(c,n,kqfilter) }
334 
335 /* open, close, ioctl, nokqfilter */
336 #define	cdev_usb_init(c,n) { \
337 	dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
338 	(dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
339 	(dev_type_stop((*))) enodev, 0, \
340 	(dev_type_mmap((*))) enodev }
341 
342 /* open, close, write */
343 #define cdev_ulpt_init(c,n) { \
344 	dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
345 	dev_init(c,n,write), (dev_type_ioctl((*))) enodev, \
346 	(dev_type_stop((*))) enodev, 0, (dev_type_mmap((*))) enodev }
347 
348 /* open, close, ioctl */
349 #define cdev_pf_init(c,n) { \
350 	dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
351 	(dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
352 	(dev_type_stop((*))) enodev, 0, \
353 	(dev_type_mmap((*))) enodev, 0, D_CLONE }
354 
355 /* open, close, read, write, ioctl, kqfilter */
356 #define	cdev_usbdev_init(c,n) { \
357 	dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
358 	dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
359 	0, (dev_type_mmap((*))) enodev, 0, 0, \
360 	dev_init(c,n,kqfilter) }
361 
362 /* open, close, read, write, ioctl, kqfilter */
363 #define	cdev_fido_init(c,n) { \
364 	dev_init(c,n,open), dev_init(c,uhid,close), dev_init(c,uhid,read), \
365 	dev_init(c,uhid,write), dev_init(c,fido,ioctl), \
366 	(dev_type_stop((*))) enodev, 0, \
367 	(dev_type_mmap((*))) enodev, 0, 0, dev_init(c,uhid,kqfilter) }
368 
369 /* open, close, read, write, ioctl, kqfilter */
370 #define	cdev_ujoy_init(c,n) { \
371 	dev_init(c,n,open), dev_init(c,uhid,close), dev_init(c,uhid,read), \
372 	dev_init(c,uhid,write), dev_init(c,ujoy,ioctl), \
373 	(dev_type_stop((*))) enodev, 0, \
374 	(dev_type_mmap((*))) enodev, 0, 0, dev_init(c,uhid,kqfilter) }
375 
376 /* open, close, init */
377 #define cdev_pci_init(c,n) { \
378 	dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
379 	(dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
380 	(dev_type_stop((*))) enodev, 0, \
381 	(dev_type_mmap((*))) enodev }
382 
383 /* open, close, ioctl */
384 #define cdev_radio_init(c,n) { \
385 	dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
386 	(dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
387 	(dev_type_stop((*))) enodev, 0, \
388 	(dev_type_mmap((*))) enodev }
389 
390 /* open, close, ioctl, read, mmap, kqfilter */
391 #define cdev_video_init(c,n) { \
392 	dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
393 	(dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
394 	(dev_type_stop((*))) enodev, 0, \
395 	dev_init(c,n,mmap), 0, 0, dev_init(c,n,kqfilter) }
396 
397 /* open, close, write, ioctl */
398 #define cdev_spkr_init(c,n) { \
399 	dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
400 	dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
401 	0, (dev_type_mmap((*))) enodev, \
402 	0, 0, seltrue_kqfilter }
403 
404 /* open, close, write */
405 #define cdev_lpt_init(c,n) { \
406 	dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
407 	dev_init(c,n,write), (dev_type_ioctl((*))) enodev, \
408 	(dev_type_stop((*))) enodev, 0, (dev_type_mmap((*))) enodev, \
409 	0, 0, seltrue_kqfilter }
410 
411 /* open, close, read, ioctl, mmap */
412 #define cdev_bktr_init(c, n) { \
413 	dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
414 	(dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
415 	(dev_type_stop((*))) enodev, 0, dev_init(c,n,mmap), \
416 	0, 0, seltrue_kqfilter }
417 
418 /* open, close, read, ioctl, kqfilter */
419 #define cdev_hotplug_init(c,n) { \
420 	dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
421 	(dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
422 	(dev_type_stop((*))) enodev, 0, \
423 	(dev_type_mmap((*))) enodev, 0, 0, dev_init(c,n,kqfilter) }
424 
425 /* open, close, ioctl */
426 #define cdev_gpio_init(c,n) { \
427 	dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
428 	(dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
429 	(dev_type_stop((*))) enodev, 0, \
430 	(dev_type_mmap((*))) enodev }
431 
432 /* open, close, ioctl */
433 #define       cdev_bio_init(c,n) { \
434 	dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
435 	(dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
436 	(dev_type_stop((*))) enodev, 0, \
437 	(dev_type_mmap((*))) enodev }
438 
439 /* open, close, read, ioctl, mmap, nokqfilter */
440 #define      cdev_drm_init(c,n)        { \
441 	dev_init(c,n,open), dev_init(c,n,close), dev_init(c, n, read), \
442 	(dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
443 	(dev_type_stop((*))) enodev, 0, \
444 	dev_init(c,n,mmap), 0, D_CLONE, dev_init(c,n,kqfilter) }
445 
446 /* open, close, ioctl */
447 #define cdev_amdmsr_init(c,n) { \
448 	dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
449 	(dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
450 	(dev_type_stop((*))) enodev, 0, \
451 	(dev_type_mmap((*))) enodev }
452 
453 /* open, close, read, write, ioctl */
454 #define cdev_fuse_init(c,n) { \
455 	dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
456 	dev_init(c,n,write), dev_init(c,n,ioctl), \
457 	(dev_type_stop((*))) enodev, 0, \
458 	(dev_type_mmap((*))) enodev, 0, D_CLONE, dev_init(c,n,kqfilter) }
459 
460 /* open, close, ioctl */
461 #define cdev_pvbus_init(c,n) { \
462 	dev_init(c,n,open), dev_init(c,n,close), \
463 	(dev_type_read((*))) enodev, \
464 	(dev_type_write((*))) enodev, \
465 	 dev_init(c,n,ioctl), \
466 	(dev_type_stop((*))) enodev, 0, \
467 	(dev_type_mmap((*))) enodev }
468 
469 /* open, close, ioctl */
470 #define cdev_ipmi_init(c,n) { \
471 	dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
472 	(dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
473 	(dev_type_stop((*))) enodev, 0, (dev_type_mmap((*))) enodev, \
474 	0, 0, seltrue_kqfilter }
475 
476 /* open, close, ioctl */
477 #define cdev_efi_init(c,n) { \
478 	dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
479 	(dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
480 	(dev_type_stop((*))) enodev, 0, \
481 	(dev_type_mmap((*))) enodev }
482 
483 /* open, close, ioctl, mmap */
484 #define cdev_kcov_init(c,n) { \
485 	dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
486 	(dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
487 	(dev_type_stop((*))) enodev, 0, \
488 	(dev_init(c,n,mmap)), 0, D_CLONE }
489 
490 /* open, close, read, ioctl */
491 #define cdev_dt_init(c,n) { \
492 	dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
493 	(dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
494 	(dev_type_stop((*))) enodev, 0, \
495 	(dev_type_mmap((*))) enodev, 0, D_CLONE }
496 
497 #endif
498 
499 /*
500  * Line discipline switch table
501  */
502 struct linesw {
503 	int	(*l_open)(dev_t dev, struct tty *tp, struct proc *p);
504 	int	(*l_close)(struct tty *tp, int flags, struct proc *p);
505 	int	(*l_read)(struct tty *tp, struct uio *uio,
506 				     int flag);
507 	int	(*l_write)(struct tty *tp, struct uio *uio,
508 				     int flag);
509 	int	(*l_ioctl)(struct tty *tp, u_long cmd, caddr_t data,
510 				     int flag, struct proc *p);
511 	int	(*l_rint)(int c, struct tty *tp);
512 	int	(*l_start)(struct tty *tp);
513 	int	(*l_modem)(struct tty *tp, int flag);
514 };
515 
516 #ifdef _KERNEL
517 extern struct linesw linesw[];
518 extern dev_t swdevt[];		/* Swap device table */
519 extern const int chrtoblktbl[];
520 extern const int nchrtoblktbl;
521 
522 struct bdevsw *bdevsw_lookup(dev_t);
523 struct cdevsw *cdevsw_lookup(dev_t);
524 dev_t	chrtoblk(dev_t);
525 dev_t	blktochr(dev_t);
526 int	iskmemdev(dev_t);
527 int	iszerodev(dev_t);
528 dev_t	getnulldev(void);
529 
530 cdev_decl(filedesc);
531 
532 cdev_decl(log);
533 
534 #define	ptstty		ptytty
535 #define	ptsioctl	ptyioctl
536 cdev_decl(pts);
537 
538 #define	ptctty		ptytty
539 #define	ptcioctl	ptyioctl
540 cdev_decl(ptc);
541 
542 cdev_decl(ptm);
543 
544 cdev_decl(ctty);
545 
546 cdev_decl(audio);
547 cdev_decl(drm);
548 cdev_decl(midi);
549 cdev_decl(radio);
550 cdev_decl(video);
551 cdev_decl(cn);
552 
553 bdev_decl(sw);
554 
555 bdev_decl(vnd);
556 cdev_decl(vnd);
557 
558 cdev_decl(ch);
559 
560 bdev_decl(sd);
561 cdev_decl(sd);
562 
563 cdev_decl(st);
564 
565 bdev_decl(cd);
566 cdev_decl(cd);
567 
568 bdev_decl(rd);
569 cdev_decl(rd);
570 
571 bdev_decl(uk);
572 cdev_decl(uk);
573 
574 cdev_decl(dt);
575 
576 cdev_decl(diskmap);
577 
578 cdev_decl(bpf);
579 
580 cdev_decl(pf);
581 
582 cdev_decl(tun);
583 cdev_decl(tap);
584 cdev_decl(pppx);
585 cdev_decl(pppac);
586 
587 cdev_decl(random);
588 
589 cdev_decl(wsdisplay);
590 cdev_decl(wskbd);
591 cdev_decl(wsmouse);
592 cdev_decl(wsmux);
593 
594 cdev_decl(ksyms);
595 cdev_decl(kstat);
596 
597 cdev_decl(bio);
598 cdev_decl(vscsi);
599 
600 cdev_decl(bktr);
601 
602 cdev_decl(usb);
603 cdev_decl(ugen);
604 cdev_decl(uhid);
605 cdev_decl(fido);
606 cdev_decl(ujoy);
607 cdev_decl(ucom);
608 cdev_decl(ulpt);
609 
610 cdev_decl(hotplug);
611 cdev_decl(gpio);
612 cdev_decl(amdmsr);
613 cdev_decl(fuse);
614 cdev_decl(pvbus);
615 cdev_decl(ipmi);
616 cdev_decl(efi);
617 cdev_decl(kcov);
618 
619 #endif
620 
621 #endif /* _SYS_CONF_H_ */
622