xref: /netbsd-src/sys/arch/mac68k/mac68k/conf.c (revision 6ea46cb5e46c49111a6ecf3bcbe3c7e2730fe9f6)
1 /*
2  * Copyright (c) 1990 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. All advertising materials mentioning features or use of this software
14  *    must display the following acknowledgement:
15  *	This product includes software developed by the University of
16  *	California, Berkeley and its contributors.
17  * 4. Neither the name of the University nor the names of its contributors
18  *    may be used to endorse or promote products derived from this software
19  *    without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32 */
33 /*-
34  * Copyright (C) 1993	Allen K. Briggs, Chris P. Caputo,
35  *			Michael L. Finch, Bradley A. Grantham, and
36  *			Lawrence A. Kesteloot
37  * All rights reserved.
38  *
39  * Redistribution and use in source and binary forms, with or without
40  * modification, are permitted provided that the following conditions
41  * are met:
42  * 1. Redistributions of source code must retain the above copyright
43  *    notice, this list of conditions and the following disclaimer.
44  * 2. Redistributions in binary form must reproduce the above copyright
45  *    notice, this list of conditions and the following disclaimer in the
46  *    documentation and/or other materials provided with the distribution.
47  * 3. All advertising materials mentioning features or use of this software
48  *    must display the following acknowledgement:
49  *	This product includes software developed by the Alice Group.
50  * 4. The names of the Alice Group or any of its members may not be used
51  *    to endorse or promote products derived from this software without
52  *    specific prior written permission.
53  *
54  * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``AS IS'' AND ANY EXPRESS OR
55  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
56  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
57  * IN NO EVENT SHALL THE ALICE GROUP BE LIABLE FOR ANY DIRECT, INDIRECT,
58  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
59  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
60  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
61  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
62  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
63  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
64  *
65  */
66 /*-
67  *      from: @(#)conf.c	7.9 (Berkeley) 5/28/91
68  *	$Id: conf.c,v 1.11 1994/08/30 11:04:17 briggs Exp $
69  */
70 /*
71    ALICE
72       BG 06/02/92,23:25:54
73          I have modified this file to correspond loosely to our requirements.
74          We need to go back through and check on a few things:
75             1) can we get rid of the _notdef()'s?
76             2) should we keep all the devices I left here?  (e.g. cd...)
77             3) did I put the new devices in the right places?
78  */
79 
80 #include <sys/param.h>
81 #include <sys/systm.h>
82 #include <sys/buf.h>
83 #include <sys/ioctl.h>
84 #include <sys/tty.h>
85 #include <sys/conf.h>
86 #include <sys/vnode.h>
87 #include <dev/cons.h>
88 
89 #include "ite.h"
90 #include "ser.h"
91 
92 int	rawread		__P((dev_t, struct uio *, int));
93 int	rawwrite	__P((dev_t, struct uio *, int));
94 void	swstrategy	__P((struct buf *));
95 int	ttselect	__P((dev_t, int, struct proc *));
96 
97 #define	dev_type_open(n)	int n __P((dev_t, int, int, struct proc *))
98 #define	dev_type_close(n)	int n __P((dev_t, int, int, struct proc *))
99 #define	dev_type_strategy(n)	void n __P((struct buf *))
100 #define	dev_type_ioctl(n) \
101 	int n __P((dev_t, int, caddr_t, int, struct proc *))
102 
103 /* bdevsw-specific types */
104 #define	dev_type_dump(n)	int n ()
105 #define	dev_type_size(n)	int n __P((dev_t))
106 
107 #define	dev_decl(n,t)	__CONCAT(dev_type_,t)(__CONCAT(n,t))
108 
109 #define	dev_init(c,n,t) \
110 	((c > 0) ? __CONCAT(n,t) : (__CONCAT(dev_type_,t)((*))) enxio)
111 
112 /* bdevsw-specific initializations */
113 #define	dev_size_init(c,n)	(c > 0 ? __CONCAT(n,size) : 0)
114 
115 #define	bdev_decl(n) \
116 	dev_decl(n,open); dev_decl(n,close); dev_decl(n,strategy); \
117 	dev_decl(n,ioctl); dev_decl(n,dump); dev_decl(n,size)
118 
119 #define	bdev_disk_init(c,n) { \
120 	dev_init(c,n,open), \
121 	(dev_type_close((*))) nullop, \
122 	dev_init(c,n,strategy), \
123 	dev_init(c,n,ioctl), \
124 	dev_init(c,n,dump), \
125 	dev_size_init(c,n), \
126 	0 }
127 
128 #define	bdev_cd_init(c,n) { \
129 	dev_init(c,n,open), \
130 	(dev_type_close((*))) nullop, \
131 	dev_init(c,n,strategy), \
132 	dev_init(c,n,ioctl), \
133 	(dev_type_dump((*))) enodev, \
134 	dev_size_init(c,n), \
135 	0 }
136 
137 #define	bdev_tape_init(c,n) { \
138 	dev_init(c,n,open), \
139 	dev_init(c,n,close), \
140 	dev_init(c,n,strategy), \
141 	dev_init(c,n,ioctl), \
142 	(dev_type_dump((*))) enodev, \
143 	0, \
144 	B_TAPE }
145 
146 #define	bdev_swap_init() { \
147 	(dev_type_open((*))) enodev, \
148 	(dev_type_close((*))) enodev, \
149 	swstrategy, \
150 	(dev_type_ioctl((*))) enodev, \
151 	(dev_type_dump((*))) enodev, \
152 	0, \
153 	0 }
154 
155 #define	bdev_notdef()	bdev_tape_init(0,no)
156 bdev_decl(no);	/* dummy declarations */
157 
158 #include "st.h"
159 #include "sd.h"
160 #include "cd.h"
161 #include "ch.h"
162 #include "vn.h"
163 
164 bdev_decl(st);
165 bdev_decl(sd);
166 bdev_decl(cd);
167 bdev_decl(vn);
168 
169 #ifdef LKM
170 int	lkmenodev();
171 #else
172 #define lkmenodev	enodev
173 #endif
174 
175 #define LKM_BDEV() { \
176 	(dev_type_open((*))) lkmenodev, (dev_type_close((*))) lkmenodev, \
177 	(dev_type_strategy((*))) lkmenodev, (dev_type_ioctl((*))) lkmenodev, \
178 	(dev_type_dump((*))) lkmenodev, 0, 0 }
179 
180 struct bdevsw	bdevsw[] =
181 {
182 	bdev_notdef(),         	/* 0: */
183 	bdev_notdef(),		/* 1: */
184 	bdev_notdef(),         	/* 2: */
185 	bdev_swap_init(),	/* 3: swap pseudo-device */
186 	bdev_disk_init(NSD,sd),	/* 4: scsi disk */
187 	bdev_tape_init(NST,st),	/* 5: scsi tape */
188 	bdev_cd_init(NCD,cd),	/* 6: scsi CD driver */
189 	bdev_notdef(),         	/* 7: */
190 	bdev_disk_init(NVN,vn),	/* 8: vnode disk driver. */
191 	bdev_notdef(),		/* 9: */
192 	LKM_BDEV(),		/* 10: Empty slot for LKM */
193 	LKM_BDEV(),		/* 11: Empty slot for LKM */
194 	LKM_BDEV(),		/* 12: Empty slot for LKM */
195 	LKM_BDEV(),		/* 13: Empty slot for LKM */
196 	LKM_BDEV(),		/* 14: Empty slot for LKM */
197 	LKM_BDEV(),		/* 15: Empty slot for LKM */
198 };
199 
200 int	nblkdev = sizeof (bdevsw) / sizeof (bdevsw[0]);
201 
202 /* cdevsw-specific types */
203 #define	dev_type_read(n)	int n __P((dev_t, struct uio *, int))
204 #define	dev_type_write(n)	int n __P((dev_t, struct uio *, int))
205 #define	dev_type_stop(n)	int n __P((struct tty *, int))
206 #define	dev_type_reset(n)	int n __P((int))
207 #define	dev_type_select(n)	int n __P((dev_t, int, struct proc *))
208 #define	dev_type_map(n)	int n __P(())
209 
210 #define	cdev_decl(n) \
211 	dev_decl(n,open); dev_decl(n,close); dev_decl(n,read); \
212 	dev_decl(n,write); dev_decl(n,ioctl); dev_decl(n,stop); \
213 	dev_decl(n,reset); dev_decl(n,select); dev_decl(n,map); \
214 	dev_decl(n,strategy); extern struct tty *__CONCAT(n,_tty)[]
215 
216 #define	dev_tty_init(c,n)	(c > 0 ? __CONCAT(n,_tty) : 0)
217 
218 /* open, read, write, ioctl, strategy */
219 #define	cdev_disk_init(c,n) { \
220 	dev_init(c,n,open), \
221 	(dev_type_close((*))) nullop, \
222 	dev_init(c,raw,read), \
223 	dev_init(c,raw,write), \
224 	dev_init(c,n,ioctl), \
225 	(dev_type_stop((*))) enodev, \
226 	(dev_type_reset((*))) nullop, \
227 	0, \
228 	seltrue, \
229 	(dev_type_map((*))) enodev, \
230 	dev_init(c,n,strategy) }
231 
232 /* open, close, read, write, ioctl, strategy */
233 #define	cdev_tape_init(c,n) { \
234 	dev_init(c,n,open), \
235 	dev_init(c,n,close), \
236 	(dev_type_read((*))) enodev, \
237 	(dev_type_write((*))) enodev, \
238 	dev_init(c,n,ioctl), \
239 	(dev_type_stop((*))) enodev, \
240 	(dev_type_reset((*))) nullop, \
241 	0, \
242 	seltrue, \
243 	(dev_type_map((*))) enodev, \
244 	dev_init(c,n,strategy) }
245 
246 /* open, close, read, write, ioctl, stop, tty */
247 #define	cdev_tty_init(c,n) { \
248 	dev_init(c,n,open), \
249 	dev_init(c,n,close), \
250 	dev_init(c,n,read), \
251 	dev_init(c,n,write), \
252 	dev_init(c,n,ioctl), \
253 	dev_init(c,n,stop), \
254 	(dev_type_reset((*))) nullop, \
255 	dev_tty_init(c,n), \
256 	ttselect, \
257 	(dev_type_map((*))) enodev, \
258 	0 }
259 
260 #define	cdev_notdef() { \
261 	(dev_type_open((*))) enodev, \
262 	(dev_type_close((*))) enodev, \
263 	(dev_type_read((*))) enodev, \
264 	(dev_type_write((*))) enodev, \
265 	(dev_type_ioctl((*))) enodev, \
266 	(dev_type_stop((*))) enodev, \
267 	(dev_type_reset((*))) nullop, \
268 	0, \
269 	seltrue, \
270 	(dev_type_map((*))) enodev, 0 }
271 
272 cdev_decl(no);			/* dummy declarations */
273 
274 cdev_decl(cn);
275 #define cdev_cn_init(c,n) { \
276 	dev_init(c,n,open), \
277 	dev_init(c,n,close), \
278 	dev_init(c,n,read), \
279 	dev_init(c,n,write), \
280 	dev_init(c,n,ioctl), \
281 	(dev_type_stop((*))) nullop, \
282 	(dev_type_reset((*))) nullop, \
283 	0, \
284 	dev_init(c,n,select), \
285 	(dev_type_map((*))) enodev, \
286 	0 }
287 
288 cdev_decl(ite);
289 #define cdev_ite_init(c,n) { \
290 	dev_init(c,n,open), \
291 	dev_init(c,n,close), \
292 	dev_init(c,n,read), \
293 	dev_init(c,n,write), \
294 	dev_init(c,n,ioctl), \
295 	(dev_type_stop((*))) enodev, \
296 	(dev_type_reset((*))) nullop, \
297 	dev_tty_init(c,n), \
298 	ttselect, \
299 	(dev_type_map((*))) enodev, \
300 	0 }
301 
302 cdev_decl(ctty);
303 /* open, read, write, ioctl, select -- XXX should be a tty */
304 #define	cdev_ctty_init(c,n) { \
305 	dev_init(c,n,open), \
306 	(dev_type_close((*))) nullop, \
307 	dev_init(c,n,read), \
308 	dev_init(c,n,write), \
309 	dev_init(c,n,ioctl), \
310 	(dev_type_stop((*))) nullop, \
311 	(dev_type_reset((*))) nullop, \
312 	0, \
313 	dev_init(c,n,select), \
314 	(dev_type_map((*))) enodev, \
315 	0 }
316 
317 dev_type_read(mmrw);
318 /* read/write */
319 #define	cdev_mm_init(c,n) { \
320 	(dev_type_open((*))) nullop, \
321 	(dev_type_close((*))) nullop, \
322 	mmrw, \
323 	mmrw, \
324 	(dev_type_ioctl((*))) enodev, \
325 	(dev_type_stop((*))) nullop, \
326 	(dev_type_reset((*))) nullop, \
327 	0, \
328 	seltrue, \
329 	(dev_type_map((*))) enodev, \
330 	0 }
331 
332 /* read, write, strategy */
333 #define	cdev_swap_init(c,n) { \
334 	(dev_type_open((*))) nullop, \
335 	(dev_type_close((*))) nullop, \
336 	rawread, \
337 	rawwrite, \
338 	(dev_type_ioctl((*))) enodev, \
339 	(dev_type_stop((*))) enodev, \
340 	(dev_type_reset((*))) nullop, \
341 	0, \
342 	(dev_type_select((*))) enodev, \
343 	(dev_type_map((*))) enodev, \
344 	dev_init(c,n,strategy) }
345 
346 #include "pty.h"
347 #define	pts_tty		pt_tty
348 #define	ptsioctl	ptyioctl
349 cdev_decl(pts);
350 #define	ptc_tty		pt_tty
351 #define	ptcioctl	ptyioctl
352 cdev_decl(ptc);
353 
354 /* open, close, read, write, ioctl, tty, select */
355 #define	cdev_ptc_init(c,n) { \
356 	dev_init(c,n,open), \
357 	dev_init(c,n,close), \
358 	dev_init(c,n,read), \
359 	dev_init(c,n,write), \
360 	dev_init(c,n,ioctl), \
361 	(dev_type_stop((*))) nullop, \
362 	(dev_type_reset((*))) nullop, \
363 	dev_tty_init(c,n), \
364 	dev_init(c,n,select), \
365 	(dev_type_map((*))) enodev, \
366 	0 }
367 
368 cdev_decl(log);
369 /* open, close, read, ioctl, select -- XXX should be a generic device */
370 #define	cdev_log_init(c,n) { \
371 	dev_init(c,n,open), \
372 	dev_init(c,n,close), \
373 	dev_init(c,n,read), \
374 	(dev_type_write((*))) enodev, \
375 	dev_init(c,n,ioctl), \
376 	(dev_type_stop((*))) enodev, \
377 	(dev_type_reset((*))) nullop, \
378 	0, \
379 	dev_init(c,n,select), \
380 	(dev_type_map((*))) enodev,\
381 	0 }
382 
383 cdev_decl(st);
384 cdev_decl(sd);
385 /* cdev_decl(ch); */
386 
387 cdev_decl(grf);
388 /* open, close, ioctl, select, map -- XXX should be a map device */
389 #define	cdev_grf_init(c,n) { \
390 	dev_init(c,n,open), \
391 	dev_init(c,n,close), \
392 	(dev_type_read((*))) nullop, \
393 	(dev_type_write((*))) nullop, \
394 	dev_init(c,n,ioctl), \
395 	(dev_type_stop((*))) enodev, \
396 	(dev_type_reset((*))) nullop, \
397 	0, \
398 	dev_init(c,n,select), \
399 	dev_init(c,n,map), \
400 	0 }
401 
402 /* ADB driver */
403 cdev_decl(adb);
404 /* open, close, read, ioctl, select, map -- XXX should be a map device */
405 #define	cdev_adb_init(n) { \
406 	dev_init(1,n,open), \
407 	dev_init(1,n,close), \
408 	dev_init(1,n,read), \
409 	(dev_type_write((*))) nullop, \
410 	dev_init(1,n,ioctl), \
411 	(dev_type_stop((*))) enodev, \
412 	(dev_type_reset((*))) nullop, \
413 	0, \
414 	dev_init(1,n,select), \
415 	(dev_type_reset((*))) nullop, \
416 	0 }
417 
418 cdev_decl(ser);
419 
420 cdev_decl(cd);
421 
422 #define NCLOCK 0 /* #include "clock.h" */
423 cdev_decl(clock);
424 /* open, close, ioctl, map -- XXX should be a map device */
425 #define	cdev_clock_init(c,n) { \
426 	dev_init(c,n,open), \
427 	dev_init(c,n,close), \
428 	(dev_type_read((*))) nullop, \
429 	(dev_type_write((*))) nullop, \
430 	dev_init(c,n,ioctl), \
431 	(dev_type_stop((*))) enodev, \
432 	(dev_type_reset((*))) nullop, \
433 	0, \
434 	(dev_type_select((*))) nullop, \
435 	dev_init(c,n,map), \
436 	0 }
437 
438 cdev_decl(vn);
439 /* open, read, write, ioctl -- XXX should be a disk */
440 #define	cdev_vn_init(c,n) { \
441 	dev_init(c,n,open), \
442 	(dev_type_close((*))) nullop, \
443 	dev_init(c,n,read), \
444 	dev_init(c,n,write), \
445 	dev_init(c,n,ioctl), \
446 	(dev_type_stop((*))) enodev, \
447 	(dev_type_reset((*))) nullop, \
448 	0, \
449 	seltrue, \
450 	(dev_type_map((*))) enodev, \
451 	0 }
452 
453 dev_type_open(fdopen);
454 /* open */
455 #define	cdev_fd_init(c,n) { \
456 	dev_init(c,n,open), \
457 	(dev_type_close((*))) enodev, \
458 	(dev_type_read((*))) enodev, \
459 	(dev_type_write((*))) enodev, \
460 	(dev_type_ioctl((*))) enodev, \
461 	(dev_type_stop((*))) enodev, \
462 	(dev_type_reset((*))) enodev, \
463 	0, \
464 	(dev_type_select((*))) enodev, \
465 	(dev_type_map((*))) enodev, \
466 	0 }
467 
468 #include "bpfilter.h"
469 cdev_decl(bpf);
470 /* open, close, read, write, ioctl, select -- XXX should be generic device */
471 #define	cdev_bpf_init(c,n) { \
472 	dev_init(c,n,open), \
473 	dev_init(c,n,close), \
474 	dev_init(c,n,read), \
475 	dev_init(c,n,write), \
476 	dev_init(c,n,ioctl), \
477 	(dev_type_stop((*))) enodev, \
478 	(dev_type_reset((*))) enodev, \
479 	0, \
480 	dev_init(c,n,select), \
481 	(dev_type_map((*))) enodev, \
482 	0 }
483 
484 #ifdef LKM
485 #define NLKM	1
486 #else
487 #define NLKM	0
488 #endif
489 
490 dev_type_open(lkmopen);
491 dev_type_close(lkmclose);
492 dev_type_ioctl(lkmioctl);
493 
494 #define cdev_lkm_init(c) { \
495 	dev_init(c,lkm,open), \
496 	dev_init(c,lkm,close), \
497 	(dev_type_read((*))) enodev, \
498 	(dev_type_write((*))) enodev, \
499 	dev_init(c,lkm,ioctl), \
500 	(dev_type_stop((*))) enodev, \
501 	(dev_type_reset((*))) enodev, \
502 	(struct tty **) NULL, \
503 	(dev_type_select((*))) enodev,\
504 	(dev_type_map((*))) enodev, \
505 	(dev_type_strategy((*))) NULL \
506 }
507 
508 #define LKM_CDEV() { \
509 	(dev_type_open((*))) lkmenodev, \
510 	(dev_type_close((*))) lkmenodev, \
511 	(dev_type_read((*))) lkmenodev, \
512 	(dev_type_write((*))) lkmenodev, \
513 	(dev_type_ioctl((*))) lkmenodev, \
514 	(dev_type_stop((*))) lkmenodev, \
515 	(dev_type_reset((*))) nullop, \
516 	(struct tty **) NULL, \
517 	(dev_type_select((*))) seltrue, \
518 	(dev_type_map((*))) lkmenodev, \
519 	(dev_type_strategy((*))) NULL \
520 }
521 
522 struct cdevsw	cdevsw[] =
523 {
524 	cdev_cn_init(1,cn),		/* 0: virtual console */
525 	cdev_ctty_init(1,ctty),		/* 1: controlling terminal */
526 	cdev_mm_init(1,mm),		/* 2: /dev/{null,mem,kmem,...} */
527 	cdev_swap_init(1,sw),		/* 3: /dev/drum (swap pseudo-device) */
528 	cdev_tty_init(NPTY,pts),	/* 4: pseudo-tty slave */
529 	cdev_ptc_init(NPTY,ptc),	/* 5: pseudo-tty master */
530 	cdev_log_init(1,log),		/* 6: /dev/klog */
531 	cdev_notdef(),			/* 7: */
532 	cdev_notdef(),			/* 8: */
533 	cdev_notdef(),			/* 9: */
534 	cdev_grf_init(1,grf),		/* 10: frame buffer */
535 	cdev_ite_init(NITE,ite),	/* 11: console terminal emulator */
536 	cdev_tty_init(NSER,ser),	/* 12: 2 mac serial ports -- BG*/
537 	cdev_disk_init(NSD,sd),		/* 13: scsi disk */
538 	cdev_tape_init(NST,st),		/* 14: scsi tape */
539 	cdev_tape_init(NCD,cd),		/* 15: scsi compact disc */
540 	cdev_notdef(),			/* 16: */
541 /*	cdev_disk_init(NCH,ch),		 17: scsi changer device */
542 	cdev_notdef(),			/* 17: until we find chstrategy... */
543 	cdev_clock_init(NCLOCK,clock),	/* 18: mapped clock */
544 	cdev_vn_init(NVN,vn),		/* 19: vnode disk */
545 	cdev_tape_init(NST,st),		/* 20: exabyte tape */
546 	cdev_fd_init(1,fd),		/* 21: file descriptor pseudo-dev */
547 	cdev_bpf_init(NBPFILTER,bpf),	/* 22: berkeley packet filter */
548 	cdev_adb_init(adb),		/* 23: ADB event interface */
549 	cdev_notdef(),			/* 24: */
550 	cdev_lkm_init(NLKM),		/* 25: loadable kernel modules pdev */
551 	LKM_CDEV(),			/* 26: Empty slot for LKM */
552 	LKM_CDEV(),			/* 27: Empty slot for LKM */
553 	LKM_CDEV(),			/* 28: Empty slot for LKM */
554 	LKM_CDEV(),			/* 29: Empty slot for LKM */
555 	LKM_CDEV(),			/* 30: Empty slot for LKM */
556 	LKM_CDEV(),			/* 31: Empty slot for LKM */
557 };
558 
559 int	nchrdev = sizeof (cdevsw) / sizeof (cdevsw[0]);
560 
561 int	mem_no = 2; 	/* major device number of memory special file */
562 
563 /*
564  * Swapdev is a fake device implemented
565  * in sw.c used only internally to get to swstrategy.
566  * It cannot be provided to the users, because the
567  * swstrategy routine munches the b_dev and b_blkno entries
568  * before calling the appropriate driver.  This would horribly
569  * confuse, e.g. the hashing routines. Instead, /dev/drum is
570  * provided as a character (raw) device.
571  */
572 dev_t	swapdev = makedev(3, 0);
573 
574 iszerodev(dev)
575 	dev_t	dev;
576 {
577 	return 0;
578 }
579 
580 /*
581  * return true is memory device (kmem or mem)
582  */
583 int
584 iskmemdev(dev)
585 	dev_t	dev;
586 {
587 	if (major(dev) == mem_no && minor(dev) < 2)
588 		return (1);
589 	return (0);
590 }
591 
592 /*
593  * return true is a disk
594  */
595 int
596 isdisk(dev, type)
597 	dev_t	dev;
598 	int	type;
599 {
600 	switch (major(dev)) {
601 		case 4: /* SCSI disk */
602 		case 6: /* SCSI CD-ROM */
603 		/* Floppy blk device will go here */
604 			if (type == VBLK)
605 				return (1);
606 			break;
607 		case 13: /* SCSI disk */
608 		case 15: /* SCSI CD-ROM */
609 		/* Floppy chr device will go here */
610 			if (type == VCHR)
611 				return (1);
612 			break;
613 		default:;
614 	}
615 	return (0);
616 }
617 
618 static int chrtoblktab[] = {
619 	/* CHR*/	/* BLK*/	/* CHR*/	/* BLK*/
620 	/*  0 */	NODEV,		/*  1 */	NODEV,
621 	/*  2 */	NODEV,		/*  3 */	3,
622 	/*  4 */	NODEV,		/*  5 */	NODEV,
623 	/*  6 */	NODEV,		/*  7 */	NODEV,
624 	/*  8 */	NODEV,		/*  9 */	NODEV,
625 	/* 10 */	NODEV,		/* 11 */	NODEV,
626 	/* 12 */	NODEV,		/* 13 */	4,
627 	/* 14 */	5,		/* 15 */	6,
628 	/* 16 */	NODEV,		/* 17 */	NODEV,
629 	/* 18 */	NODEV,		/* 19 */	NODEV,
630 	/* 20 */	NODEV,		/* 21 */	NODEV,
631 	/* 22 */	NODEV,
632 };
633 
634 dev_t
635 chrtoblk(dev)
636 	dev_t	dev;
637 {
638 	int	blkmaj;
639 
640 	if (major(dev) >= nchrdev)
641 		return NODEV;
642 	blkmaj = chrtoblktab[major(dev)];
643 	if (blkmaj == NODEV)
644 		return NODEV;
645 	return (makedev(blkmaj, minor(dev)));
646 }
647 
648 #if NITE > 0
649 int	itecnprobe(), itecninit(), itecngetc(), itecnputc();
650 #endif
651 #if NSER > 0
652 int	sercnprobe(), sercninit(), sercngetc(), sercnputc();
653 #endif
654 
655 struct	consdev constab[] = {
656 #if NITE > 0
657 	{ itecnprobe,	itecninit,	itecngetc,	itecnputc },
658 #endif
659 #if NSER > 0
660 	{ sercnprobe,	sercninit,	sercngetc,	sercnputc },
661 #endif
662 	{ 0 },
663 };
664