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