xref: /netbsd-src/sys/arch/mac68k/mac68k/conf.c (revision 2a399c6883d870daece976daec6ffa7bb7f934ce)
1 /*	$NetBSD: conf.c,v 1.44 1997/10/13 03:59:18 scottr 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  * Derived a long time ago from
37  *      @(#)conf.c	7.9 (Berkeley) 5/28/91
38  */
39 
40 #include <sys/param.h>
41 #include <sys/systm.h>
42 #include <sys/buf.h>
43 #include <sys/ioctl.h>
44 #include <sys/tty.h>
45 #include <sys/conf.h>
46 #include <sys/vnode.h>
47 #include <dev/cons.h>
48 
49 #include "ccd.h"
50 #include "cd.h"
51 #include "ch.h"
52 #include "md.h"
53 #include "sd.h"
54 #include "st.h"
55 #include "vnd.h"
56 /* No cdev for md */
57 
58 bdev_decl(ccd);
59 bdev_decl(cd);
60 bdev_decl(ch);
61 bdev_decl(md);
62 bdev_decl(sd);
63 bdev_decl(st);
64 bdev_decl(sw);
65 bdev_decl(vnd);
66 
67 struct bdevsw	bdevsw[] =
68 {
69 	bdev_notdef(),         		/* 0 */
70 	bdev_notdef(),			/* 1 */
71 	bdev_notdef(),         		/* 2 */
72 	bdev_swap_init(1,sw),		/* 3: swap pseudo-device */
73 	bdev_disk_init(NSD,sd),		/* 4: SCSI disk */
74 	bdev_tape_init(NST,st),		/* 5: SCSI tape */
75 	bdev_disk_init(NCD,cd),		/* 6: SCSI CD-ROM */
76 	bdev_notdef(),        	 	/* 7 */
77 	bdev_disk_init(NVND,vnd),	/* 8: vnode disk driver */
78 	bdev_disk_init(NCCD,ccd),	/* 9: concatenated disk driver */
79 	bdev_notdef(),        	 	/* 10 */
80 	bdev_notdef(),        	 	/* 11 */
81 	bdev_notdef(),        	 	/* 12 */
82 	bdev_disk_init(NMD,md),	 	/* 13: memory disk -- for install */
83 	bdev_lkm_dummy(),		/* 14 */
84 	bdev_lkm_dummy(),		/* 15 */
85 	bdev_lkm_dummy(),		/* 16 */
86 	bdev_lkm_dummy(),		/* 17 */
87 	bdev_lkm_dummy(),		/* 18 */
88 	bdev_lkm_dummy(),		/* 19 */
89 };
90 int	nblkdev = sizeof(bdevsw) / sizeof(bdevsw[0]);
91 
92 #define NADB 1 /* #include "adb.h" */
93 #include "asc.h"
94 #include "bpfilter.h"
95 #include "ch.h"
96 #include "grf.h"
97 #include "ipfilter.h"
98 #include "ite.h"
99 #include "pty.h"
100 #include "rnd.h"
101 #include "se.h"
102 #include "ss.h"
103 #include "tun.h"
104 #include "uk.h"
105 #include "zsc.h"
106 #include "zstty.h"
107 
108 cdev_decl(adb);
109 cdev_decl(asc);
110 cdev_decl(bpf);
111 cdev_decl(ccd);
112 cdev_decl(ch);
113 cdev_decl(cn);
114 cdev_decl(ctty);
115 cdev_decl(fd);
116 cdev_decl(grf);
117 cdev_decl(ipl);
118 cdev_decl(ite);
119 cdev_decl(log);
120 cdev_decl(md);
121 #define mmread	mmrw
122 #define mmwrite	mmrw
123 cdev_decl(mm);
124 #define	ptcioctl	ptyioctl
125 #define	ptctty		ptytty
126 cdev_decl(ptc);
127 #define	ptsioctl	ptyioctl
128 #define	ptstty		ptytty
129 cdev_decl(pts);
130 cdev_decl(sd);
131 cdev_decl(se);
132 cdev_decl(ss);
133 cdev_decl(st);
134 cdev_decl(sw);
135 cdev_decl(tun);
136 cdev_decl(uk);
137 cdev_decl(vnd);
138 cdev_decl(zs);
139 cdev_decl(zsc);
140 
141 dev_decl(filedesc,open);
142 
143 struct cdevsw	cdevsw[] =
144 {
145 	cdev_cn_init(1,cn),		/* 0: virtual console */
146 	cdev_ctty_init(1,ctty),		/* 1: controlling terminal */
147 	cdev_mm_init(1,mm),		/* 2: /dev/{null,mem,kmem,...} */
148 	cdev_swap_init(1,sw),		/* 3: /dev/drum (swap pseudo-device) */
149 	cdev_tty_init(NPTY,pts),	/* 4: pseudo-tty slave */
150 	cdev_ptc_init(NPTY,ptc),	/* 5: pseudo-tty master */
151 	cdev_log_init(1,log),		/* 6: /dev/klog */
152 	cdev_notdef(),			/* 7 */
153 	cdev_notdef(),			/* 8 */
154 	cdev_notdef(),			/* 9 */
155 	cdev_fb_init(NGRF,grf),		/* 10: frame buffer */
156 	cdev_tty_init(NITE,ite),	/* 11: console terminal emulator */
157 	cdev_tty_init(NZSTTY,zs),	/* 12: 2 mac serial ports -- BG*/
158 	cdev_disk_init(NSD,sd),		/* 13: SCSI disk */
159 	cdev_tape_init(NST,st),		/* 14: SCSI tape */
160 	cdev_disk_init(NCD,cd),		/* 15: SCSI CD-ROM */
161 	cdev_notdef(),			/* 16 */
162 	cdev_ch_init(NCH,ch),		/* 17: SCSI autochanger */
163 	cdev_notdef(),			/* 18 */
164 	cdev_disk_init(NVND,vnd),	/* 19: vnode disk driver */
165 	cdev_disk_init(NCCD,ccd),	/* 20: concatenated disk driver */
166 	cdev_fd_init(1,filedesc),	/* 21: file descriptor pseudo-device */
167 	cdev_bpftun_init(NBPFILTER,bpf),/* 22: Berkeley packet filter */
168 	cdev_mouse_init(NADB,adb),	/* 23: ADB event interface */
169 	cdev_bpftun_init(NTUN,tun),	/* 24: network tunnel */
170 	cdev_lkm_init(NLKM,lkm),	/* 25: loadable module driver */
171 	cdev_lkm_dummy(),		/* 26 */
172 	cdev_lkm_dummy(),		/* 27 */
173 	cdev_lkm_dummy(),		/* 28 */
174 	cdev_lkm_dummy(),		/* 29 */
175 	cdev_lkm_dummy(),		/* 30 */
176 	cdev_lkm_dummy(),		/* 31 */
177 	cdev_disk_init(NMD,md),		/* 32: memory disk driver */
178 	cdev_scanner_init(NSS,ss),	/* 33: SCSI scanner */
179 	cdev_uk_init(NUK,uk),		/* 34: SCSI unknown */
180 	cdev_ipf_init(NIPFILTER,ipl),	/* 35: ip-filter device */
181 	cdev_audio_init(NASC,asc),	/* 36: ASC audio device */
182 	cdev_se_init(NSE, se),		/* 37: SCSI ethernet */
183 	cdev_rnd_init(NRND, rnd),	/* 38: random source pseudo-device */
184 };
185 int	nchrdev = sizeof(cdevsw) / sizeof(cdevsw[0]);
186 
187 int	mem_no = 2; 	/* major device number of memory special file */
188 
189 /*
190  * Swapdev is a fake device implemented
191  * in sw.c used only internally to get to swstrategy.
192  * It cannot be provided to the users, because the
193  * swstrategy routine munches the b_dev and b_blkno entries
194  * before calling the appropriate driver.  This would horribly
195  * confuse, e.g. the hashing routines. Instead, /dev/drum is
196  * provided as a character (raw) device.
197  */
198 dev_t	swapdev = makedev(3, 0);
199 
200 /*
201  * Returns true if dev is /dev/mem or /dev/kmem.
202  */
203 int
204 iskmemdev(dev)
205 	dev_t	dev;
206 {
207 
208 	return (major(dev) == mem_no && minor(dev) < 2);
209 }
210 
211 /*
212  * Returns true if dev is /dev/zero.
213  */
214 int
215 iszerodev(dev)
216 	dev_t	dev;
217 {
218 
219 	return (major(dev) == mem_no && minor(dev) == 12);
220 }
221 
222 static int chrtoblktab[] = {
223 	/* XXXX This needs to be dynamic for LKMs. */
224 	/*VCHR*/	/*VBLK*/
225 	/*  0 */	NODEV,
226 	/*  1 */	NODEV,
227 	/*  2 */	NODEV,
228 	/*  3 */	3,
229 	/*  4 */	NODEV,
230 	/*  5 */	NODEV,
231 	/*  6 */	NODEV,
232 	/*  7 */	NODEV,
233 	/*  8 */	NODEV,
234 	/*  9 */	NODEV,
235 	/* 10 */	NODEV,
236 	/* 11 */	NODEV,
237 	/* 12 */	NODEV,
238 	/* 13 */	4,
239 	/* 14 */	5,
240 	/* 15 */	6,
241 	/* 16 */	NODEV,
242 	/* 17 */	NODEV,
243 	/* 18 */	NODEV,
244 	/* 19 */	8,
245 	/* 20 */	9,
246 	/* 21 */	NODEV,
247 	/* 22 */	NODEV,
248 	/* 23 */	NODEV,
249 	/* 24 */	NODEV,
250 	/* 25 */	NODEV,
251 	/* 26 */	NODEV,
252 	/* 27 */	NODEV,
253 	/* 28 */	NODEV,
254 	/* 29 */	NODEV,
255 	/* 30 */	NODEV,
256 	/* 31 */	NODEV,
257 	/* 32 */	32,
258 	/* 33 */	NODEV,
259 	/* 34 */	NODEV,
260 	/* 35 */	NODEV,
261 	/* 36 */	NODEV,
262 	/* 37 */	NODEV,
263 	/* 38 */	NODEV,
264 };
265 
266 dev_t
267 chrtoblk(dev)
268 	dev_t	dev;
269 {
270 	int	blkmaj;
271 
272 	if (major(dev) >= nchrdev)
273 		return NODEV;
274 	blkmaj = chrtoblktab[major(dev)];
275 	if (blkmaj == NODEV)
276 		return NODEV;
277 	return (makedev(blkmaj, minor(dev)));
278 }
279 
280 #define itecnpollc	nullcnpollc
281 cons_decl(ite);
282 #define zscnpollc	nullcnpollc
283 cons_decl(zs);
284 
285 struct	consdev constab[] = {
286 #if NITE > 0
287 	cons_init(ite),
288 #endif
289 #if NZSTTY > 0
290 	cons_init(zs),
291 #endif
292 	{ 0 },
293 };
294