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