xref: /netbsd-src/sys/arch/mac68k/mac68k/conf.c (revision ae9172d6cd9432a6a1a56760d86b32c57a66c39c)
1 /*	$NetBSD: conf.c,v 1.16 1994/12/22 05:50:26 briggs 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 #include "tun.h"
486 cdev_decl(tun);
487 /* open, close, read, write, ioctl, select -- XXX should be generic device */
488 #define cdev_tun_init(c,n) { \
489 	dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
490 	dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
491 	(dev_type_reset((*))) enodev, 0, dev_init(c,n,select), \
492 	(dev_type_map((*))) enodev, 0 }
493 
494 #ifdef LKM
495 #define NLKM	1
496 #else
497 #define NLKM	0
498 #endif
499 
500 dev_type_open(lkmopen);
501 dev_type_close(lkmclose);
502 dev_type_ioctl(lkmioctl);
503 
504 #define cdev_lkm_init(c) { \
505 	dev_init(c,lkm,open), \
506 	dev_init(c,lkm,close), \
507 	(dev_type_read((*))) enodev, \
508 	(dev_type_write((*))) enodev, \
509 	dev_init(c,lkm,ioctl), \
510 	(dev_type_stop((*))) enodev, \
511 	(dev_type_reset((*))) enodev, \
512 	(struct tty **) NULL, \
513 	(dev_type_select((*))) enodev,\
514 	(dev_type_map((*))) enodev, \
515 	(dev_type_strategy((*))) NULL \
516 }
517 
518 #define LKM_CDEV() { \
519 	(dev_type_open((*))) lkmenodev, \
520 	(dev_type_close((*))) lkmenodev, \
521 	(dev_type_read((*))) lkmenodev, \
522 	(dev_type_write((*))) lkmenodev, \
523 	(dev_type_ioctl((*))) lkmenodev, \
524 	(dev_type_stop((*))) lkmenodev, \
525 	(dev_type_reset((*))) nullop, \
526 	(struct tty **) NULL, \
527 	(dev_type_select((*))) seltrue, \
528 	(dev_type_map((*))) lkmenodev, \
529 	(dev_type_strategy((*))) NULL \
530 }
531 
532 struct cdevsw	cdevsw[] =
533 {
534 	cdev_cn_init(1,cn),		/* 0: virtual console */
535 	cdev_ctty_init(1,ctty),		/* 1: controlling terminal */
536 	cdev_mm_init(1,mm),		/* 2: /dev/{null,mem,kmem,...} */
537 	cdev_swap_init(1,sw),		/* 3: /dev/drum (swap pseudo-device) */
538 	cdev_tty_init(NPTY,pts),	/* 4: pseudo-tty slave */
539 	cdev_ptc_init(NPTY,ptc),	/* 5: pseudo-tty master */
540 	cdev_log_init(1,log),		/* 6: /dev/klog */
541 	cdev_notdef(),			/* 7: */
542 	cdev_notdef(),			/* 8: */
543 	cdev_notdef(),			/* 9: */
544 	cdev_grf_init(1,grf),		/* 10: frame buffer */
545 	cdev_ite_init(NITE,ite),	/* 11: console terminal emulator */
546 	cdev_tty_init(NSER,ser),	/* 12: 2 mac serial ports -- BG*/
547 	cdev_disk_init(NSD,sd),		/* 13: scsi disk */
548 	cdev_tape_init(NST,st),		/* 14: scsi tape */
549 	cdev_tape_init(NCD,cd),		/* 15: scsi compact disc */
550 	cdev_notdef(),			/* 16: */
551 /*	cdev_disk_init(NCH,ch),		 17: scsi changer device */
552 	cdev_notdef(),			/* 17: until we find chstrategy... */
553 	cdev_clock_init(NCLOCK,clock),	/* 18: mapped clock */
554 	cdev_vn_init(NVN,vn),		/* 19: vnode disk */
555 	cdev_tape_init(NST,st),		/* 20: exabyte tape */
556 	cdev_fd_init(1,fd),		/* 21: file descriptor pseudo-dev */
557 	cdev_bpf_init(NBPFILTER,bpf),	/* 22: berkeley packet filter */
558 	cdev_adb_init(adb),		/* 23: ADB event interface */
559 	cdev_tun_init(NTUN,tun),	/* 24: network tunnel */
560 	cdev_lkm_init(NLKM),		/* 25: loadable kernel modules pdev */
561 	LKM_CDEV(),			/* 26: Empty slot for LKM */
562 	LKM_CDEV(),			/* 27: Empty slot for LKM */
563 	LKM_CDEV(),			/* 28: Empty slot for LKM */
564 	LKM_CDEV(),			/* 29: Empty slot for LKM */
565 	LKM_CDEV(),			/* 30: Empty slot for LKM */
566 	LKM_CDEV(),			/* 31: Empty slot for LKM */
567 };
568 
569 int	nchrdev = sizeof (cdevsw) / sizeof (cdevsw[0]);
570 
571 int	mem_no = 2; 	/* major device number of memory special file */
572 
573 /*
574  * Swapdev is a fake device implemented
575  * in sw.c used only internally to get to swstrategy.
576  * It cannot be provided to the users, because the
577  * swstrategy routine munches the b_dev and b_blkno entries
578  * before calling the appropriate driver.  This would horribly
579  * confuse, e.g. the hashing routines. Instead, /dev/drum is
580  * provided as a character (raw) device.
581  */
582 dev_t	swapdev = makedev(3, 0);
583 
584 iszerodev(dev)
585 	dev_t	dev;
586 {
587 	return 0;
588 }
589 
590 /*
591  * return true is memory device (kmem or mem)
592  */
593 int
594 iskmemdev(dev)
595 	dev_t	dev;
596 {
597 	if (major(dev) == mem_no && minor(dev) < 2)
598 		return (1);
599 	return (0);
600 }
601 
602 /*
603  * return true is a disk
604  */
605 int
606 isdisk(dev, type)
607 	dev_t	dev;
608 	int	type;
609 {
610 	switch (major(dev)) {
611 		case 4: /* SCSI disk */
612 		case 6: /* SCSI CD-ROM */
613 		/* Floppy blk device will go here */
614 			if (type == VBLK)
615 				return (1);
616 			break;
617 		case 13: /* SCSI disk */
618 		case 15: /* SCSI CD-ROM */
619 		/* Floppy chr device will go here */
620 			if (type == VCHR)
621 				return (1);
622 			break;
623 		default:;
624 	}
625 	return (0);
626 }
627 
628 static int chrtoblktab[] = {
629 	/* CHR*/	/* BLK*/	/* CHR*/	/* BLK*/
630 	/*  0 */	NODEV,		/*  1 */	NODEV,
631 	/*  2 */	NODEV,		/*  3 */	3,
632 	/*  4 */	NODEV,		/*  5 */	NODEV,
633 	/*  6 */	NODEV,		/*  7 */	NODEV,
634 	/*  8 */	NODEV,		/*  9 */	NODEV,
635 	/* 10 */	NODEV,		/* 11 */	NODEV,
636 	/* 12 */	NODEV,		/* 13 */	4,
637 	/* 14 */	5,		/* 15 */	6,
638 	/* 16 */	NODEV,		/* 17 */	NODEV,
639 	/* 18 */	NODEV,		/* 19 */	NODEV,
640 	/* 20 */	NODEV,		/* 21 */	NODEV,
641 	/* 22 */	NODEV,
642 };
643 
644 dev_t
645 chrtoblk(dev)
646 	dev_t	dev;
647 {
648 	int	blkmaj;
649 
650 	if (major(dev) >= nchrdev)
651 		return NODEV;
652 	blkmaj = chrtoblktab[major(dev)];
653 	if (blkmaj == NODEV)
654 		return NODEV;
655 	return (makedev(blkmaj, minor(dev)));
656 }
657 
658 #if NITE > 0
659 int	itecnprobe(), itecninit(), itecngetc(), itecnputc();
660 #endif
661 #if NSER > 0
662 int	sercnprobe(), sercninit(), sercngetc(), sercnputc();
663 #endif
664 
665 struct	consdev constab[] = {
666 #if NITE > 0
667 	{ itecnprobe,	itecninit,	itecngetc,	itecnputc },
668 #endif
669 #if NSER > 0
670 	{ sercnprobe,	sercninit,	sercngetc,	sercnputc },
671 #endif
672 	{ 0 },
673 };
674