xref: /openbsd-src/sys/arch/octeon/octeon/conf.c (revision 68cc39830aa48a2182a4a2976238be1f40888669)
1 /*	$OpenBSD: conf.c,v 1.30 2023/04/13 02:19:05 jsg Exp $ */
2 
3 /*
4  * Copyright (c) 1992, 1993
5  *	The Regents of the University of California.  All rights reserved.
6  *
7  * This code is derived from software contributed to Berkeley by
8  * Ralph Campbell.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *	This product includes software developed by the University of
21  *	California, Berkeley and its contributors.
22  * 4. Neither the name of the University nor the names of its contributors
23  *    may be used to endorse or promote products derived from this software
24  *    without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36  * SUCH DAMAGE.
37  */
38 
39 #include <sys/param.h>
40 #include <sys/systm.h>
41 #include <sys/buf.h>
42 #include <sys/ioctl.h>
43 #include <sys/proc.h>
44 #include <sys/vnode.h>
45 #include <sys/tty.h>
46 
47 #include <machine/conf.h>
48 
49 /*
50  *	Block devices.
51  */
52 
53 #include "vnd.h"
54 #include "sd.h"
55 #include "cd.h"
56 #include "wd.h"
57 bdev_decl(wd);
58 #include "rd.h"
59 #include "hotplug.h"
60 
61 #define NOCTCF 1
62 bdev_decl(octcf);
63 
64 #define NAMDCF 1
65 bdev_decl(amdcf);
66 
67 struct bdevsw	bdevsw[] =
68 {
69 	bdev_disk_init(NSD,sd),		/* 0: SCSI disk */
70 	bdev_swap_init(1,sw),		/* 1: should be here swap pseudo-dev */
71 	bdev_disk_init(NVND,vnd),	/* 2: vnode disk driver */
72 	bdev_disk_init(NCD,cd),		/* 3: SCSI CD-ROM */
73 	bdev_disk_init(NWD,wd),		/* 4: ST506/ESDI/IDE disk */
74 	bdev_notdef(),			/* 5:  */
75 	bdev_notdef(),			/* 6: was: concatenated disk driver */
76 	bdev_notdef(),			/* 7:  */
77 	bdev_disk_init(NRD,rd),		/* 8: RAM disk (for install) */
78 	bdev_notdef(),			/* 9:  */
79 	bdev_notdef(),			/* 10: was: SCSI tape */
80 	bdev_notdef(),			/* 11:  */
81 	bdev_notdef(),			/* 12:  */
82 	bdev_notdef(),			/* 13:  */
83 	bdev_notdef(),			/* 14:  */
84 	bdev_disk_init(NOCTCF,octcf),	/* 15: CF disk */
85 	bdev_notdef(),			/* 16:  */
86 	bdev_notdef(),			/* 17:  */
87 	bdev_notdef(),			/* 18:  */
88 	bdev_disk_init(NAMDCF,amdcf),	/* 19: CF disk */
89 };
90 
91 int	nblkdev = nitems(bdevsw);
92 
93 /*
94  *	Character devices.
95  */
96 
97 #define mmread mmrw
98 #define mmwrite mmrw
99 dev_type_read(mmrw);
100 cdev_decl(mm);
101 #include "bio.h"
102 #include "pty.h"
103 cdev_decl(fd);
104 #include "st.h"
105 #include "bpfilter.h"
106 #include "tun.h"
107 #if 0
108 #include "apm.h"
109 #endif
110 #include "com.h"
111 cdev_decl(com);
112 #include "lpt.h"
113 cdev_decl(lpt);
114 #include "ch.h"
115 #include "uk.h"
116 cdev_decl(wd);
117 #include "audio.h"
118 #include "video.h"
119 cdev_decl(octcf);
120 cdev_decl(amdcf);
121 
122 #include "ksyms.h"
123 #include "kstat.h"
124 
125 #include "wsdisplay.h"
126 #include "wskbd.h"
127 #include "wsmouse.h"
128 #include "wsmux.h"
129 #include "pci.h"
130 cdev_decl(pci);
131 
132 #include "dt.h"
133 #include "pf.h"
134 
135 #include "usb.h"
136 #include "uhid.h"
137 #include "fido.h"
138 #include "ujoy.h"
139 #include "ugen.h"
140 #include "ulpt.h"
141 #include "ucom.h"
142 
143 #include "vscsi.h"
144 #include "pppx.h"
145 #include "fuse.h"
146 #include "octboot.h"
147 #include "openprom.h"
148 
149 struct cdevsw	cdevsw[] =
150 {
151 	cdev_cn_init(1,cn),		/* 0: virtual console */
152 	cdev_notdef(),			/* 1: was /dev/drum */
153 	cdev_ctty_init(1,ctty),		/* 2: controlling terminal */
154 	cdev_mm_init(1,mm),		/* 3: /dev/{null,mem,kmem,...} */
155 	cdev_tty_init(NPTY,pts),	/* 4: pseudo-tty slave */
156 	cdev_ptc_init(NPTY,ptc),	/* 5: pseudo-tty master */
157 	cdev_log_init(1,log),		/* 6: /dev/klog */
158 	cdev_fd_init(1,filedesc),	/* 7: file descriptor pseudo-dev */
159 	cdev_disk_init(NCD,cd),		/* 8: SCSI CD */
160 	cdev_disk_init(NSD,sd),		/* 9: SCSI disk */
161 	cdev_tape_init(NST,st),		/* 10: SCSI tape */
162 	cdev_disk_init(NVND,vnd),	/* 11: vnode disk */
163 	cdev_bpf_init(NBPFILTER,bpf),	/* 12: berkeley packet filter */
164 	cdev_tun_init(NTUN,tun),	/* 13: network tunnel */
165 #if 0
166 	cdev_apm_init(NAPM,apm),	/* 14: apm */
167 #else
168 	cdev_notdef(),			/* 14: */
169 #endif
170 	cdev_disk_init(NOCTCF,octcf),	/* 15: CF disk */
171 	cdev_lpt_init(NLPT,lpt),	/* 16: Parallel printer interface */
172 	cdev_tty_init(NCOM,com),	/* 17: 16C450 serial interface */
173 	cdev_disk_init(NWD,wd),		/* 18: ST506/ESDI/IDE disk */
174 	cdev_disk_init(NAMDCF,amdcf),	/* 19: CF disk */
175 	cdev_openprom_init(NOPENPROM,openprom),	/* 20: /dev/openprom */
176 	cdev_octboot_init(NOCTBOOT,octboot),	/* 21: /dev/octboot */
177 	cdev_disk_init(NRD,rd),		/* 22: ramdisk device */
178 	cdev_notdef(),			/* 23: was: concatenated disk driver */
179 	cdev_notdef(),			/* 24: */
180 	cdev_wsdisplay_init(NWSDISPLAY, wsdisplay),	/* 25: */
181 	cdev_mouse_init(NWSKBD, wskbd),	/* 26: */
182 	cdev_mouse_init(NWSMOUSE, wsmouse),	/* 27: */
183 	cdev_mouse_init(NWSMUX, wsmux),	/* 28: */
184 #ifdef USER_PCICONF
185 	cdev_pci_init(NPCI,pci),	/* 29: PCI user */
186 #else
187 	cdev_notdef(),			/* 29 */
188 #endif
189 	cdev_dt_init(NDT,dt),		/* 30: dynamic tracer */
190 	cdev_pf_init(NPF,pf),		/* 31: packet filter */
191 	cdev_uk_init(NUK,uk),		/* 32: unknown SCSI */
192 	cdev_random_init(1,random),	/* 33: random data source */
193 	cdev_notdef(),			/* 34: */
194 	cdev_ksyms_init(NKSYMS,ksyms),	/* 35: Kernel symbols device */
195 	cdev_ch_init(NCH,ch),		/* 36: SCSI autochanger */
196 	cdev_notdef(),			/* 37: */
197 	cdev_notdef(),			/* 38: */
198 	cdev_notdef(),			/* 39: */
199 	cdev_notdef(),			/* 40: */
200 	cdev_notdef(),			/* 41: */
201 	cdev_notdef(),			/* 42: */
202 	cdev_notdef(),			/* 43: */
203 	cdev_audio_init(NAUDIO,audio),	/* 44: /dev/audio */
204 	cdev_video_init(NVIDEO,video),	/* 45: generic video I/O */
205 	cdev_notdef(),			/* 46: */
206 	cdev_notdef(),			/* 47: was: /dev/crypto */
207 	cdev_notdef(),			/* 48: */
208 	cdev_bio_init(NBIO,bio),	/* 49: ioctl tunnel */
209 	cdev_notdef(),			/* 50: */
210 	cdev_kstat_init(NKSTAT,kstat),	/* 51: kernel statistics */
211 	cdev_ptm_init(NPTY,ptm),	/* 52: pseudo-tty ptm device */
212 	cdev_fuse_init(NFUSE,fuse),	/* 53: fuse */
213 	cdev_notdef(),			/* 54: */
214 	cdev_notdef(),			/* 55: */
215 	cdev_notdef(),			/* 56: */
216 	cdev_notdef(),			/* 57: */
217 	cdev_notdef(),			/* 58: */
218 	cdev_notdef(),			/* 59: */
219 	cdev_notdef(),			/* 60: */
220 	cdev_usb_init(NUSB,usb),	/* 61: USB controller */
221 	cdev_usbdev_init(NUHID,uhid),	/* 62: USB generic HID */
222 	cdev_usbdev_init(NUGEN,ugen),	/* 63: USB generic driver */
223 	cdev_ulpt_init(NULPT,ulpt),	/* 64: USB printers */
224 	cdev_notdef(),			/* 65: */
225 	cdev_tty_init(NUCOM,ucom),	/* 66: USB tty */
226 	cdev_hotplug_init(NHOTPLUG,hotplug), /* 67: devices hotplugging */
227 	cdev_notdef(),			/* 68: */
228 	cdev_vscsi_init(NVSCSI,vscsi),	/* 69: vscsi */
229 	cdev_disk_init(1,diskmap),	/* 70: disk mapper */
230 	cdev_pppx_init(NPPPX,pppx),	/* 71: pppx */
231 	cdev_notdef(),			/* 72: was USB scanners */
232 	cdev_notdef(),			/* 73: fuse on other mips64 */
233 	cdev_tun_init(NTUN,tap),	/* 74: Ethernet network tunnel */
234 	cdev_notdef(),			/* 75: was switch(4) */
235 	cdev_fido_init(NFIDO,fido),	/* 76: FIDO/U2F security key */
236 	cdev_pppx_init(NPPPX,pppac),	/* 77: PPP Access Concentrator */
237 	cdev_ujoy_init(NUJOY,ujoy),	/* 78: USB joystick/gamecontroller */
238 };
239 
240 int	nchrdev = nitems(cdevsw);
241 
242 /*
243  * Swapdev is a fake device implemented
244  * in sw.c used only internally to get to swstrategy.
245  * It cannot be provided to the users, because the
246  * swstrategy routine munches the b_dev and b_blkno entries
247  * before calling the appropriate driver.  This would horribly
248  * confuse, e.g. the hashing routines. Instead, /dev/drum is
249  * provided as a character (raw) device.
250  */
251 dev_t	swapdev = makedev(1, 0);
252 
253 /*
254  * Routine that identifies /dev/mem and /dev/kmem.
255  *
256  * A minimal stub routine can always return 0.
257  */
258 int
iskmemdev(dev_t dev)259 iskmemdev(dev_t dev)
260 {
261 
262 	if (major(dev) == 3 && (minor(dev) == 0 || minor(dev) == 1))
263 		return (1);
264 	return (0);
265 }
266 
267 /*
268  * Returns true if def is /dev/zero
269  */
270 int
iszerodev(dev_t dev)271 iszerodev(dev_t dev)
272 {
273 	return (major(dev) == 3 && minor(dev) == 12);
274 }
275 
276 dev_t
getnulldev(void)277 getnulldev(void)
278 {
279 	return(makedev(3, 2));
280 }
281 
282 
283 const int chrtoblktbl[] =  {
284 	/* VCHR         VBLK */
285 	/* 0 */		NODEV,
286 	/* 1 */		NODEV,
287 	/* 2 */		NODEV,
288 	/* 3 */		NODEV,
289 	/* 4 */		NODEV,
290 	/* 5 */		NODEV,
291 	/* 6 */		NODEV,
292 	/* 7 */		NODEV,
293 	/* 8 */		3,		/* cd */
294 	/* 9 */		0,		/* sd */
295 	/* 10 */	NODEV,
296 	/* 11 */	2,		/* vnd */
297 	/* 12 */	NODEV,
298 	/* 13 */	NODEV,
299 	/* 14 */	NODEV,
300 	/* 15 */	15,		/* octcf */
301 	/* 16 */	NODEV,
302 	/* 17 */	NODEV,
303 	/* 18 */	4,		/* wd */
304 	/* 19 */	19,		/* amdcf */
305 	/* 20 */	NODEV,
306 	/* 21 */	NODEV,
307 	/* 22 */	8		/* rd */
308 };
309 
310 const int nchrtoblktbl = nitems(chrtoblktbl);
311 
312 #include <dev/cons.h>
313 
314 cons_decl(ws);
315 cons_decl(com);
316 
317 struct	consdev constab[] = {
318 #if NWSDISPLAY > 0
319 	cons_init(ws),
320 #endif
321 #if NCOM > 0
322 	cons_init(com),
323 #endif
324 	{ 0 },
325 };
326