xref: /openbsd-src/sys/arch/sparc64/sparc64/conf.c (revision fb264aa6f008773d0e2d5c2f03e255f48e03e756)
1 /*	$OpenBSD: conf.c,v 1.90 2024/06/11 09:21:32 jsg Exp $	*/
2 /*	$NetBSD: conf.c,v 1.17 2001/03/26 12:33:26 lukem Exp $ */
3 
4 /*
5  * Copyright (c) 1992, 1993
6  *	The Regents of the University of California.  All rights reserved.
7  *
8  * This software was developed by the Computer Systems Engineering group
9  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
10  * contributed to Berkeley.
11  *
12  * All advertising materials mentioning features or use of this software
13  * must display the following acknowledgement:
14  *	This product includes software developed by the University of
15  *	California, Lawrence Berkeley Laboratory.
16  *
17  * Redistribution and use in source and binary forms, with or without
18  * modification, are permitted provided that the following conditions
19  * are met:
20  * 1. Redistributions of source code must retain the above copyright
21  *    notice, this list of conditions and the following disclaimer.
22  * 2. Redistributions in binary form must reproduce the above copyright
23  *    notice, this list of conditions and the following disclaimer in the
24  *    documentation and/or other materials provided with the distribution.
25  * 3. Neither the name of the University nor the names of its contributors
26  *    may be used to endorse or promote products derived from this software
27  *    without specific prior written permission.
28  *
29  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
30  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
33  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39  * SUCH DAMAGE.
40  *
41  *	@(#)conf.c	8.3 (Berkeley) 11/14/93
42  */
43 
44 #include <sys/param.h>
45 #include <sys/systm.h>
46 #include <sys/buf.h>
47 #include <sys/ioctl.h>
48 #include <sys/vnode.h>
49 #include <sys/tty.h>
50 #include <sys/conf.h>
51 
52 #include <machine/conf.h>
53 
54 #include "bio.h"
55 #include "pty.h"
56 #include "bpfilter.h"
57 #include "tun.h"
58 #include "midi.h"
59 #include "audio.h"
60 #include "video.h"
61 #include "vnd.h"
62 #include "ch.h"
63 #include "sd.h"
64 #include "st.h"
65 #include "cd.h"
66 #include "uk.h"
67 #include "wd.h"
68 
69 #include "zstty.h"
70 #include "sab.h"
71 #include "pcons.h"
72 #include "vcons.h"
73 #include "vcctty.h"
74 #include "sbbc.h"
75 #include "com.h"
76 #include "lpt.h"
77 #include "bpp.h"
78 #include "magma.h"		/* has NMTTY and NMBPP */
79 #include "spif.h"		/* has NSTTY and NSBPP */
80 #include "uperf.h"
81 #include "vldcp.h"
82 #include "vdsp.h"
83 
84 #include "fdc.h"		/* has NFDC and NFD; see files.sparc64 */
85 
86 #include "drm.h"
87 
88 #include "wsdisplay.h"
89 #include "wskbd.h"
90 #include "wsmouse.h"
91 #include "wsmux.h"
92 
93 #ifdef USER_PCICONF
94 #include "pci.h"
95 cdev_decl(pci);
96 #endif
97 
98 #include "rd.h"
99 
100 #include "usb.h"
101 #include "uhid.h"
102 #include "fido.h"
103 #include "ujoy.h"
104 #include "ugen.h"
105 #include "ulpt.h"
106 #include "ucom.h"
107 
108 #include "dt.h"
109 #include "pf.h"
110 
111 #include "ksyms.h"
112 #include "kstat.h"
113 
114 #include "hotplug.h"
115 #include "vscsi.h"
116 #include "pppx.h"
117 #include "fuse.h"
118 
119 struct bdevsw	bdevsw[] =
120 {
121 	bdev_notdef(),			/* 0 */
122 	bdev_notdef(),			/* 1 */
123 	bdev_notdef(),			/* 2 */
124 	bdev_notdef(),			/* 3 */
125 	bdev_swap_init(1,sw),		/* 4 swap pseudo-device */
126 	bdev_disk_init(NRD,rd),		/* 5: ram disk */
127 	bdev_notdef(),			/* 6 */
128 	bdev_disk_init(NSD,sd),		/* 7: SCSI disk */
129 	bdev_disk_init(NVND,vnd),	/* 8: vnode disk driver */
130 	bdev_notdef(),			/* 9: was: concatenated disk driver */
131 	bdev_notdef(),			/* 10 */
132 	bdev_notdef(),			/* 11: was: SCSI tape */
133 	bdev_disk_init(NWD,wd),		/* 12: IDE disk */
134 	bdev_notdef(),			/* 13 */
135 	bdev_notdef(),			/* 14 */
136 	bdev_notdef(),			/* 15 */
137 	bdev_disk_init(NFD,fd),		/* 16: floppy disk */
138 	bdev_notdef(),			/* 17 */
139 	bdev_disk_init(NCD,cd),		/* 18: SCSI CD-ROM */
140 	bdev_notdef(),			/* 19 */
141 	bdev_notdef(),			/* 20 */
142 	bdev_notdef(),			/* 21 */
143 	bdev_notdef(),			/* 22 */
144 	bdev_notdef(),			/* 23 */
145 	bdev_notdef(),			/* 24 */
146 	bdev_notdef(),			/* 25 was: RAIDframe disk driver */
147 };
148 int	nblkdev = nitems(bdevsw);
149 
150 struct cdevsw	cdevsw[] =
151 {
152 	cdev_cn_init(1,cn),		/* 0: virtual console */
153 	cdev_notdef(),			/* 1 */
154 	cdev_ctty_init(1,ctty),		/* 2: controlling terminal */
155 	cdev_mm_init(1,mm),		/* 3: /dev/{null,mem,kmem,...} */
156 	cdev_notdef(),			/* 4 */
157 	cdev_notdef(),			/* 5 */
158 	cdev_notdef(),			/* 6 */
159 	cdev_notdef(),			/* 7 was /dev/drum */
160 	cdev_notdef(),			/* 8 */
161 	cdev_notdef(),			/* 9 */
162 	cdev_notdef(),			/* 10 */
163 	cdev_notdef(),			/* 11 */
164 	cdev_tty_init(NZSTTY,zs),	/* 12: Zilog 8530 serial port */
165 	cdev_notdef(),			/* 13 */
166 	cdev_notdef(),			/* 14 */
167 	cdev_notdef(),			/* 15 */
168 	cdev_log_init(1,log),		/* 16: /dev/klog */
169 	cdev_disk_init(NSD,sd),		/* 17: SCSI disk */
170 	cdev_tape_init(NST,st),		/* 18: SCSI tape */
171 	cdev_ch_init(NCH,ch),		/* 19: SCSI autochanger */
172 	cdev_tty_init(NPTY,pts),	/* 20: pseudo-tty slave */
173 	cdev_ptc_init(NPTY,ptc),	/* 21: pseudo-tty master */
174 	cdev_notdef(),			/* 22 */
175 	cdev_notdef(),			/* 23: was: concatenated disk driver */
176 	cdev_fd_init(1,filedesc),	/* 24: file descriptor pseudo-device */
177 	cdev_uperf_init(NUPERF,uperf),	/* 25: performance counters */
178 	cdev_disk_init(NWD,wd),		/* 26: IDE disk */
179 	cdev_notdef(),			/* 27 */
180 	cdev_notdef(),			/* 28 */
181 	cdev_notdef(),			/* 29 */
182 	cdev_dt_init(NDT,dt),		/* 30: dynamic tracer */
183 	cdev_notdef(),			/* 31 */
184 	cdev_notdef(),			/* 32 */
185 	cdev_notdef(),			/* 33 */
186 	cdev_notdef(),			/* 34 */
187 	cdev_notdef(),			/* 35 */
188 	cdev_tty_init(NCOM,com),	/* 36: NS16x50 compatible ports */
189 	cdev_lpt_init(NLPT,lpt),	/* 37: parallel printer */
190 	cdev_notdef(),			/* 38 */
191 	cdev_notdef(),			/* 39 */
192 	cdev_notdef(),			/* 40 */
193 	cdev_notdef(),			/* 41 */
194 	cdev_notdef(),			/* 42 */
195 	cdev_notdef(),			/* 43 */
196 	cdev_video_init(NVIDEO,video),	/* 44: generic video I/O */
197 	cdev_notdef(),			/* 45 */
198 	cdev_notdef(),			/* 46 */
199 	cdev_notdef(),			/* 47 */
200 	cdev_notdef(),			/* 48 */
201 	cdev_notdef(),			/* 49 */
202 	cdev_notdef(),			/* 50 */
203 	cdev_kstat_init(NKSTAT,kstat),	/* 51: kernel statistics */
204 #ifdef USER_PCICONF
205 	cdev_pci_init(NPCI,pci),	/* 52: PCI user */
206 #else
207 	cdev_notdef(),			/* 52 */
208 #endif
209 	cdev_notdef(),			/* 53 */
210 	cdev_disk_init(NFD,fd),		/* 54: floppy disk */
211 	cdev_notdef(),			/* 55 */
212 	cdev_notdef(),			/* 56 */
213 	cdev_notdef(),			/* 57 */
214 	cdev_disk_init(NCD,cd),		/* 58: SCSI CD-ROM */
215 	cdev_notdef(),			/* 59 */
216 	cdev_uk_init(NUK,uk),		/* 60: SCSI unknown */
217 	cdev_disk_init(NRD,rd),		/* 61: memory disk */
218 	cdev_notdef(),			/* 62 */
219 	cdev_notdef(),			/* 63 */
220 	cdev_notdef(),			/* 64 */
221 	cdev_notdef(),			/* 65 */
222 	cdev_notdef(),			/* 66 */
223 	cdev_notdef(),			/* 67 */
224 	cdev_midi_init(NMIDI,midi),	/* 68: /dev/rmidi */
225 	cdev_audio_init(NAUDIO,audio),	/* 69: /dev/audio */
226 	cdev_openprom_init(1,openprom),	/* 70: /dev/openprom */
227 	cdev_tty_init(NMTTY,mtty),	/* 71: magma serial ports */
228 	cdev_gen_init(NMBPP,mbpp),	/* 72: magma parallel ports */
229 	cdev_pf_init(NPF,pf),		/* 73: packet filter */
230 	cdev_notdef(),			/* 74: ALTQ (deprecated) */
231 	cdev_notdef(),			/* 75: was: /dev/crypto */
232 	cdev_ksyms_init(NKSYMS,ksyms),	/* 76 *: Kernel symbols device */
233 	cdev_tty_init(NSABTTY,sabtty),	/* 77: sab82532 serial ports */
234 	cdev_wsdisplay_init(NWSDISPLAY,	/* 78: frame buffers, etc. */
235 	    wsdisplay),
236 	cdev_mouse_init(NWSKBD, wskbd),	/* 79: keyboards */
237 	cdev_mouse_init(NWSMOUSE, wsmouse), /* 80: mice */
238 	cdev_mouse_init(NWSMUX, wsmux),	/* 81: ws multiplexor */
239 	cdev_notdef(),			/* 82 */
240 	cdev_notdef(),			/* 83 */
241 	cdev_notdef(),			/* 84 */
242 	cdev_notdef(),			/* 85 */
243 	cdev_notdef(),			/* 86 */
244 	cdev_drm_init(NDRM,drm),	/* 87: drm */
245 	cdev_notdef(),			/* 88 */
246 	cdev_notdef(),			/* 89 */
247 	cdev_usb_init(NUSB,usb),	/* 90: USB controller */
248 	cdev_usbdev_init(NUHID,uhid),	/* 91: USB generic HID */
249 	cdev_usbdev_init(NUGEN,ugen),	/* 92: USB generic driver */
250 	cdev_ulpt_init(NULPT,ulpt),	/* 93: USB printers */
251 	cdev_notdef(),			/* 94 */
252 	cdev_tty_init(NUCOM,ucom),	/* 95: USB tty */
253 	cdev_notdef(),			/* 96: was USB scanners */
254 	cdev_notdef(),			/* 97 */
255 	cdev_notdef(),			/* 98 */
256 	cdev_notdef(),			/* 99 */
257 	cdev_notdef(),			/* 100 */
258 	cdev_notdef(),			/* 101 */
259 	cdev_notdef(),			/* 102 */
260 	cdev_notdef(),			/* 103 */
261 	cdev_notdef(),			/* 104 */
262 	cdev_bpf_init(NBPFILTER,bpf),	/* 105: packet filter */
263 	cdev_notdef(),			/* 106 */
264 	cdev_bpp_init(NBPP,bpp),	/* 107: on-board parallel port */
265 	cdev_tty_init(NSTTY,stty),	/* 108: spif serial ports */
266 	cdev_gen_init(NSBPP,sbpp),	/* 109: spif parallel ports */
267 	cdev_disk_init(NVND,vnd),	/* 110: vnode disk driver */
268 	cdev_tun_init(NTUN,tun),	/* 111: network tunnel */
269 	cdev_notdef(),			/* 112 was LKM */
270 	cdev_notdef(),			/* 113 */
271 	cdev_notdef(),			/* 114 */
272 	cdev_notdef(),			/* 115 */
273 	cdev_notdef(),			/* 116 */
274 	cdev_notdef(),			/* 117 */
275 	cdev_notdef(),			/* 118 */
276 	cdev_random_init(1,random),	/* 119: random data source */
277 	cdev_bio_init(NBIO,bio),	/* 120: ioctl tunnel */
278 	cdev_notdef(),			/* 121 was: RAIDframe disk driver */
279 	cdev_tty_init(NPCONS,pcons),	/* 122: PROM console */
280 	cdev_ptm_init(NPTY,ptm),	/* 123: pseudo-tty ptm device */
281 	cdev_hotplug_init(NHOTPLUG,hotplug), /* 124: devices hot plugging */
282 	cdev_tty_init(NVCONS,vcons),	/* 125: virtual console */
283 	cdev_tty_init(NSBBC,sbbc),	/* 126: SBBC console */
284 	cdev_tty_init(NVCCTTY,vcctty),	/* 127: virtual console concentrator */
285 	cdev_vscsi_init(NVSCSI,vscsi),	/* 128: vscsi */
286 	cdev_notdef(),
287 	cdev_disk_init(1,diskmap),	/* 130: disk mapper */
288 	cdev_pppx_init(NPPPX,pppx),	/* 131: pppx */
289 	cdev_gen_init(NVLDCP,vldcp),	/* 132: vldcp */
290 	cdev_vdsp_init(NVDSP,vdsp),	/* 133: vdsp */
291 	cdev_fuse_init(NFUSE,fuse),	/* 134: fuse */
292 	cdev_tun_init(NTUN,tap),	/* 135: Ethernet network tunnel */
293 	cdev_notdef(),			/* 136: was switch(4) */
294 	cdev_fido_init(NFIDO,fido),	/* 137: FIDO/U2F security key */
295 	cdev_pppx_init(NPPPX,pppac),	/* 138: PPP Access Concentrator */
296 	cdev_ujoy_init(NUJOY,ujoy),	/* 139: USB joystick/gamecontroller */
297 };
298 int	nchrdev = nitems(cdevsw);
299 
300 int	mem_no = 3; 	/* major device number of memory special file */
301 
302 /*
303  * Swapdev is a fake device implemented
304  * in sw.c used only internally to get to swstrategy.
305  * It cannot be provided to the users, because the
306  * swstrategy routine munches the b_dev and b_blkno entries
307  * before calling the appropriate driver.  This would horribly
308  * confuse, e.g. the hashing routines.
309  */
310 dev_t	swapdev = makedev(4, 0);
311 
312 /*
313  * Routine that identifies /dev/mem and /dev/kmem.
314  */
315 int
iskmemdev(dev_t dev)316 iskmemdev(dev_t dev)
317 {
318 	return (major(dev) == mem_no && minor(dev) < 2);
319 }
320 
321 int
iszerodev(dev_t dev)322 iszerodev(dev_t dev)
323 {
324 	return (major(dev) == mem_no && minor(dev) == 12);
325 }
326 
327 dev_t
getnulldev(void)328 getnulldev(void)
329 {
330 	return makedev(mem_no, 2);
331 }
332 
333 const int chrtoblktbl[] = {
334 	/*VCHR*/	/*VBLK*/
335 	/*  0 */	NODEV,
336 	/*  1 */	NODEV,
337 	/*  2 */	NODEV,
338 	/*  3 */	NODEV,
339 	/*  4 */	NODEV,
340 	/*  5 */	NODEV,
341 	/*  6 */	NODEV,
342 	/*  7 */	NODEV,
343 	/*  8 */	NODEV,
344 	/*  9 */	NODEV,
345 	/* 10 */	NODEV,
346 	/* 11 */	NODEV,
347 	/* 12 */	NODEV,
348 	/* 13 */	NODEV,
349 	/* 14 */	NODEV,
350 	/* 15 */	NODEV,
351 	/* 16 */	NODEV,
352 	/* 17 */	7,		/* sd */
353 	/* 18 */	NODEV,
354 	/* 19 */	NODEV,
355 	/* 20 */	NODEV,
356 	/* 21 */	NODEV,
357 	/* 22 */	NODEV,
358 	/* 23 */	NODEV,
359 	/* 24 */	NODEV,
360 	/* 25 */	NODEV,
361 	/* 26 */	12,		/* wd */
362 	/* 27 */	NODEV,
363 	/* 28 */	NODEV,
364 	/* 29 */	NODEV,
365 	/* 30 */	NODEV,
366 	/* 31 */	NODEV,
367 	/* 32 */	NODEV,
368 	/* 33 */	NODEV,
369 	/* 34 */	NODEV,
370 	/* 35 */	NODEV,
371 	/* 36 */	NODEV,
372 	/* 37 */	NODEV,
373 	/* 38 */	NODEV,
374 	/* 39 */	NODEV,
375 	/* 40 */	NODEV,
376 	/* 41 */	NODEV,
377 	/* 42 */	NODEV,
378 	/* 43 */	NODEV,
379 	/* 44 */	NODEV,
380 	/* 45 */	NODEV,
381 	/* 46 */	NODEV,
382 	/* 47 */	NODEV,
383 	/* 48 */	NODEV,
384 	/* 49 */	NODEV,
385 	/* 50 */	NODEV,
386 	/* 51 */	NODEV,
387 	/* 52 */	NODEV,
388 	/* 53 */	NODEV,
389 	/* 54 */	16,		/* fd */
390 	/* 55 */	NODEV,
391 	/* 56 */	NODEV,
392 	/* 57 */	NODEV,
393 	/* 58 */	18,		/* cd */
394 	/* 59 */	NODEV,
395 	/* 60 */	NODEV,
396 	/* 61 */	5,		/* rd */
397 	/* 62 */	NODEV,
398 	/* 63 */	NODEV,
399 	/* 64 */	NODEV,
400 	/* 65 */	NODEV,
401 	/* 66 */	NODEV,
402 	/* 67 */	NODEV,
403 	/* 68 */	NODEV,
404 	/* 69 */	NODEV,
405 	/* 70 */	NODEV,
406 	/* 71 */	NODEV,
407 	/* 72 */	NODEV,
408 	/* 73 */	NODEV,
409 	/* 74 */	NODEV,
410 	/* 75 */	NODEV,
411 	/* 76 */	NODEV,
412 	/* 77 */	NODEV,
413 	/* 78 */	NODEV,
414 	/* 79 */	NODEV,
415 	/* 80 */	NODEV,
416 	/* 81 */	NODEV,
417 	/* 82 */	NODEV,
418 	/* 83 */	NODEV,
419 	/* 84 */	NODEV,
420 	/* 85 */	NODEV,
421 	/* 86 */	NODEV,
422 	/* 87 */	NODEV,
423 	/* 88 */	NODEV,
424 	/* 89 */	NODEV,
425 	/* 90 */	NODEV,
426 	/* 91 */	NODEV,
427 	/* 92 */	NODEV,
428 	/* 93 */	NODEV,
429 	/* 94 */	NODEV,
430 	/* 95 */	NODEV,
431 	/* 96 */	NODEV,
432 	/* 97 */	NODEV,
433 	/* 98 */	NODEV,
434 	/* 99 */	NODEV,
435 	/*100 */	NODEV,
436 	/*101 */	NODEV,
437 	/*102 */	NODEV,
438 	/*103 */	NODEV,
439 	/*104 */	NODEV,
440 	/*105 */	NODEV,
441 	/*106 */	NODEV,
442 	/*107 */	NODEV,
443 	/*108 */	NODEV,
444 	/*109 */	NODEV,
445 	/*110 */	8,		/* vnd */
446 };
447 const int nchrtoblktbl = nitems(chrtoblktbl);
448