1 /* $OpenBSD: conf.c,v 1.19 2014/12/11 19:44:17 tedu 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 "st.h" 57 #include "wd.h" 58 bdev_decl(wd); 59 #include "rd.h" 60 #include "hotplug.h" 61 62 struct bdevsw bdevsw[] = 63 { 64 bdev_disk_init(NSD,sd), /* 0: SCSI disk */ 65 bdev_swap_init(1,sw), /* 1: should be here swap pseudo-dev */ 66 bdev_disk_init(NVND,vnd), /* 2: vnode disk driver */ 67 bdev_disk_init(NCD,cd), /* 3: SCSI CD-ROM */ 68 bdev_disk_init(NWD,wd), /* 4: ST506/ESDI/IDE disk */ 69 bdev_notdef(), /* 5: */ 70 bdev_notdef(), /* 6: was: concatenated disk driver */ 71 bdev_notdef(), /* 7: */ 72 bdev_disk_init(NRD,rd), /* 8: RAM disk (for install) */ 73 bdev_notdef(), /* 9: */ 74 bdev_tape_init(NST,st), /* 10: SCSI tape */ 75 bdev_notdef(), /* 11: */ 76 bdev_notdef(), /* 12: */ 77 bdev_notdef(), /* 13: */ 78 bdev_notdef(), /* 14: */ 79 bdev_notdef(), /* 15: */ 80 }; 81 82 int nblkdev = nitems(bdevsw); 83 84 /* 85 * Character devices. 86 */ 87 88 #define mmread mmrw 89 #define mmwrite mmrw 90 dev_type_read(mmrw); 91 cdev_decl(mm); 92 #include "bio.h" 93 #include "pty.h" 94 cdev_decl(fd); 95 #include "st.h" 96 #include "bpfilter.h" 97 #include "tun.h" 98 #include "apm.h" 99 #include "com.h" 100 cdev_decl(com); 101 #include "lpt.h" 102 cdev_decl(lpt); 103 #include "ch.h" 104 #include "uk.h" 105 cdev_decl(wd); 106 #include "audio.h" 107 #include "video.h" 108 #include "ksyms.h" 109 110 #include "wsdisplay.h" 111 #include "wskbd.h" 112 #include "wsmouse.h" 113 #include "wsmux.h" 114 #include "pci.h" 115 cdev_decl(pci); 116 117 #include "pf.h" 118 #include "systrace.h" 119 120 #include "usb.h" 121 #include "uhid.h" 122 #include "ugen.h" 123 #include "ulpt.h" 124 #include "ucom.h" 125 126 #include "vscsi.h" 127 #include "pppx.h" 128 #include "fuse.h" 129 130 struct cdevsw cdevsw[] = 131 { 132 cdev_cn_init(1,cn), /* 0: virtual console */ 133 cdev_notdef(), /* 1: was /dev/drum */ 134 cdev_ctty_init(1,ctty), /* 2: controlling terminal */ 135 cdev_mm_init(1,mm), /* 3: /dev/{null,mem,kmem,...} */ 136 cdev_tty_init(NPTY,pts), /* 4: pseudo-tty slave */ 137 cdev_ptc_init(NPTY,ptc), /* 5: pseudo-tty master */ 138 cdev_log_init(1,log), /* 6: /dev/klog */ 139 cdev_fd_init(1,filedesc), /* 7: file descriptor pseudo-dev */ 140 cdev_disk_init(NCD,cd), /* 8: SCSI CD */ 141 cdev_disk_init(NSD,sd), /* 9: SCSI disk */ 142 cdev_tape_init(NST,st), /* 10: SCSI tape */ 143 cdev_disk_init(NVND,vnd), /* 11: vnode disk */ 144 cdev_bpf_init(NBPFILTER,bpf), /* 12: berkeley packet filter */ 145 cdev_tun_init(NTUN,tun), /* 13: network tunnel */ 146 cdev_apm_init(NAPM,apm), /* 14: apm */ 147 cdev_notdef(), /* 15: */ 148 cdev_lpt_init(NLPT,lpt), /* 16: Parallel printer interface */ 149 cdev_tty_init(NCOM,com), /* 17: 16C450 serial interface */ 150 cdev_disk_init(NWD,wd), /* 18: ST506/ESDI/IDE disk */ 151 cdev_notdef(), /* 19: */ 152 cdev_notdef(), /* 20: */ 153 cdev_notdef(), /* 21: */ 154 cdev_disk_init(NRD,rd), /* 22: ramdisk device */ 155 cdev_notdef(), /* 23: was: concatenated disk driver */ 156 cdev_notdef(), /* 24: */ 157 cdev_wsdisplay_init(NWSDISPLAY, wsdisplay), /* 25: */ 158 cdev_mouse_init(NWSKBD, wskbd), /* 26: */ 159 cdev_mouse_init(NWSMOUSE, wsmouse), /* 27: */ 160 cdev_mouse_init(NWSMUX, wsmux), /* 28: */ 161 #ifdef USER_PCICONF 162 cdev_pci_init(NPCI,pci), /* 29: PCI user */ 163 #else 164 cdev_notdef(), /* 29 */ 165 #endif 166 cdev_notdef(), /* 30: */ 167 cdev_pf_init(NPF,pf), /* 31: packet filter */ 168 cdev_uk_init(NUK,uk), /* 32: unknown SCSI */ 169 cdev_random_init(1,random), /* 33: random data source */ 170 cdev_notdef(), /* 34: */ 171 cdev_ksyms_init(NKSYMS,ksyms), /* 35: Kernel symbols device */ 172 cdev_ch_init(NCH,ch), /* 36: SCSI autochanger */ 173 cdev_notdef(), /* 37: */ 174 cdev_notdef(), /* 38: */ 175 cdev_notdef(), /* 39: */ 176 cdev_notdef(), /* 40: */ 177 cdev_notdef(), /* 41: */ 178 cdev_notdef(), /* 42: */ 179 cdev_notdef(), /* 33: */ 180 cdev_audio_init(NAUDIO,audio), /* 44: /dev/audio */ 181 cdev_video_init(NVIDEO,video), /* 45: generic video I/O */ 182 cdev_notdef(), /* 46: */ 183 cdev_notdef(), /* 47: was: /dev/crypto */ 184 cdev_notdef(), /* 48: */ 185 cdev_bio_init(NBIO,bio), /* 49: ioctl tunnel */ 186 cdev_systrace_init(NSYSTRACE,systrace), /* 50: system call tracing */ 187 cdev_notdef(), /* 51: */ 188 cdev_ptm_init(NPTY,ptm), /* 52: pseudo-tty ptm device */ 189 cdev_notdef(), /* 53: */ 190 cdev_notdef(), /* 54: */ 191 cdev_notdef(), /* 55: */ 192 cdev_notdef(), /* 56: */ 193 cdev_notdef(), /* 57: */ 194 cdev_notdef(), /* 58: */ 195 cdev_notdef(), /* 59: */ 196 cdev_notdef(), /* 60: */ 197 cdev_usb_init(NUSB,usb), /* 61: USB controller */ 198 cdev_usbdev_init(NUHID,uhid), /* 62: USB generic HID */ 199 cdev_usbdev_init(NUGEN,ugen), /* 63: USB generic driver */ 200 cdev_ulpt_init(NULPT,ulpt), /* 64: USB printers */ 201 cdev_notdef(), /* 65: */ 202 cdev_tty_init(NUCOM,ucom), /* 66: USB tty */ 203 cdev_hotplug_init(NHOTPLUG,hotplug), /* 67: devices hotplugging */ 204 cdev_notdef(), 205 cdev_vscsi_init(NVSCSI,vscsi), /* 69: vscsi */ 206 cdev_disk_init(1,diskmap), /* 70: disk mapper */ 207 cdev_pppx_init(NPPPX,pppx), /* 71: pppx */ 208 cdev_notdef(), /* 72: was USB scanners */ 209 cdev_fuse_init(NFUSE,fuse), /* 73: fuse */ 210 }; 211 212 int nchrdev = nitems(cdevsw); 213 214 /* 215 * Swapdev is a fake device implemented 216 * in sw.c used only internally to get to swstrategy. 217 * It cannot be provided to the users, because the 218 * swstrategy routine munches the b_dev and b_blkno entries 219 * before calling the appropriate driver. This would horribly 220 * confuse, e.g. the hashing routines. Instead, /dev/drum is 221 * provided as a character (raw) device. 222 */ 223 dev_t swapdev = makedev(1, 0); 224 225 /* 226 * Routine that identifies /dev/mem and /dev/kmem. 227 * 228 * A minimal stub routine can always return 0. 229 */ 230 int 231 iskmemdev(dev) 232 dev_t dev; 233 { 234 235 if (major(dev) == 3 && (minor(dev) == 0 || minor(dev) == 1)) 236 return (1); 237 return (0); 238 } 239 240 /* 241 * Returns true if def is /dev/zero 242 */ 243 int 244 iszerodev(dev) 245 dev_t dev; 246 { 247 return (major(dev) == 3 && minor(dev) == 12); 248 } 249 250 dev_t 251 getnulldev() 252 { 253 return(makedev(3, 2)); 254 } 255 256 257 int chrtoblktbl[] = { 258 /* VCHR VBLK */ 259 /* 0 */ NODEV, 260 /* 1 */ NODEV, 261 /* 2 */ NODEV, 262 /* 3 */ NODEV, 263 /* 4 */ NODEV, 264 /* 5 */ NODEV, 265 /* 6 */ NODEV, 266 /* 7 */ NODEV, 267 /* 8 */ 3, /* cd */ 268 /* 9 */ 0, /* sd */ 269 /* 10 */ 10, /* st */ 270 /* 11 */ 2, /* vnd */ 271 /* 12 */ NODEV, 272 /* 13 */ NODEV, 273 /* 14 */ NODEV, 274 /* 15 */ NODEV, 275 /* 16 */ NODEV, 276 /* 17 */ NODEV, 277 /* 18 */ 4, /* wd */ 278 /* 19 */ NODEV, 279 /* 20 */ NODEV, 280 /* 21 */ NODEV, 281 /* 22 */ 8 /* rd */ 282 }; 283 284 int nchrtoblktbl = nitems(chrtoblktbl); 285 286 #include <dev/cons.h> 287 288 cons_decl(ws); 289 cons_decl(com); 290 291 struct consdev constab[] = { 292 #if NWSDISPLAY > 0 293 cons_init(ws), 294 #endif 295 #if NCOM > 0 296 cons_init(com), 297 #endif 298 { 0 }, 299 }; 300