Annotation of sys/arch/mvme68k/mvme68k/conf.c, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: conf.c,v 1.41 2007/05/28 22:26:03 todd Exp $ */
2:
3: /*-
4: * Copyright (c) 1995 Theo de Raadt
5: *
6: * Redistribution and use in source and binary forms, with or without
7: * modification, are permitted provided that the following conditions
8: * are met:
9: * 1. Redistributions of source code must retain the above copyright
10: * notice, this list of conditions and the following disclaimer.
11: * 2. Redistributions in binary form must reproduce the above copyright
12: * notice, this list of conditions and the following disclaimer in the
13: * documentation and/or other materials provided with the distribution.
14: *
15: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
16: * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18: * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
19: * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25: * SUCH DAMAGE.
26: *
27: * Copyright (c) 1991 The Regents of the University of California.
28: * All rights reserved.
29: *
30: * Redistribution and use in source and binary forms, with or without
31: * modification, are permitted provided that the following conditions
32: * are met:
33: * 1. Redistributions of source code must retain the above copyright
34: * notice, this list of conditions and the following disclaimer.
35: * 2. Redistributions in binary form must reproduce the above copyright
36: * notice, this list of conditions and the following disclaimer in the
37: * documentation and/or other materials provided with the distribution.
38: * 3. Neither the name of the University nor the names of its contributors
39: * may be used to endorse or promote products derived from this software
40: * without specific prior written permission.
41: *
42: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
43: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
45: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
46: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
47: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
48: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
49: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
50: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
51: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
52: * SUCH DAMAGE.
53: *
54: * @(#)conf.c 7.9 (Berkeley) 5/28/91
55: */
56:
57: #include <sys/param.h>
58: #include <sys/systm.h>
59: #include <sys/buf.h>
60: #include <sys/ioctl.h>
61: #include <sys/tty.h>
62: #include <sys/vnode.h>
63:
64: #include <machine/conf.h>
65:
66: #include "st.h"
67: #include "sd.h"
68: #include "cd.h"
69: #include "ch.h"
70: #include "ss.h"
71: #include "uk.h"
72: #ifdef notyet
73: #include "xd.h"
74: bdev_decl(xd);
75: #endif
76: #include "vnd.h"
77: #include "ccd.h"
78: #include "rd.h"
79:
80: struct bdevsw bdevsw[] =
81: {
82: bdev_notdef(), /* 0 */
83: bdev_notdef(), /* 1 */
84: bdev_notdef(), /* 2 */
85: bdev_swap_init(1,sw), /* 3: swap pseudo-device */
86: bdev_disk_init(NSD,sd), /* 4: SCSI disk */
87: bdev_disk_init(NCCD,ccd), /* 5: concatenated disk driver */
88: bdev_disk_init(NVND,vnd), /* 6: vnode disk driver */
89: bdev_tape_init(NST,st), /* 7: SCSI tape */
90: bdev_disk_init(NCD,cd), /* 8: SCSI CD-ROM */
91: bdev_disk_init(NRD,rd), /* 9: RAM disk - for install tape */
92: #ifdef notyet
93: bdev_disk_init(NXD,xd), /* 10: XD disk */
94: #else
95: bdev_notdef(), /* 10 */
96: #endif
97: bdev_notdef(), /* 11 */
98: bdev_notdef(), /* 12 */
99: bdev_lkm_dummy(), /* 13 */
100: bdev_lkm_dummy(), /* 14 */
101: bdev_lkm_dummy(), /* 15 */
102: bdev_lkm_dummy(), /* 16 */
103: bdev_lkm_dummy(), /* 17 */
104: bdev_lkm_dummy(), /* 18 */
105: };
106: int nblkdev = sizeof(bdevsw) / sizeof(bdevsw[0]);
107:
108: #include "sram.h"
109: #include "vmel.h"
110: #include "vmes.h"
111: #include "nvram.h"
112: #include "flash.h"
113:
114: #include "bio.h"
115: #include "pty.h"
116: cdev_decl(fd);
117:
118: #include "zs.h"
119: #include "cl.h"
120: #include "wl.h"
121:
122: /* open, close, write, ioctl */
123: #define cdev_lp_init(c,n) { \
124: dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
125: dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
126: 0, seltrue, (dev_type_mmap((*))) enodev }
127:
128: /* open, close, ioctl, mmap, ioctl */
129: #define cdev_mdev_init(c,n) { \
130: dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
131: dev_init(c,n,write), dev_init(c,n,ioctl), \
132: (dev_type_stop((*))) enodev, 0, (dev_type_poll((*))) enodev, \
133: dev_init(c,n,mmap) }
134:
135: #include "lp.h"
136: #include "lptwo.h"
137: cdev_decl(lptwo);
138: #ifdef XFS
139: #include <xfs/nxfs.h>
140: cdev_decl(xfs_dev);
141: #endif
142: #include "ksyms.h"
143:
144: #ifdef notyet
145: cdev_decl(xd);
146: #endif
147:
148: #include "bpfilter.h"
149: #include "tun.h"
150:
151: #include "pf.h"
152:
153: #include "systrace.h"
154:
155: struct cdevsw cdevsw[] =
156: {
157: cdev_cn_init(1,cn), /* 0: virtual console */
158: cdev_ctty_init(1,ctty), /* 1: controlling terminal */
159: cdev_mm_init(1,mm), /* 2: /dev/{null,mem,kmem,...} */
160: cdev_swap_init(1,sw), /* 3: /dev/drum (swap pseudo-device) */
161: cdev_tty_init(NPTY,pts), /* 4: pseudo-tty slave */
162: cdev_ptc_init(NPTY,ptc), /* 5: pseudo-tty master */
163: cdev_log_init(1,log), /* 6: /dev/klog */
164: cdev_mdev_init(NSRAM,sram), /* 7: /dev/sramX */
165: cdev_disk_init(NSD,sd), /* 8: SCSI disk */
166: cdev_disk_init(NCD,cd), /* 9: SCSI CD-ROM */
167: cdev_mdev_init(NNVRAM,nvram), /* 10: /dev/nvramX */
168: cdev_mdev_init(NFLASH,flash), /* 11: /dev/flashX */
169: cdev_tty_init(NZS,zs), /* 12: SCC serial (tty[a-d]) */
170: cdev_tty_init(NCL,cl), /* 13: CL-CD2400 serial (tty0[0-3]) */
171: cdev_notdef(), /* 14 */
172: cdev_notdef(), /* 15 */
173: cdev_notdef(), /* 16 */
174: cdev_disk_init(NCCD,ccd), /* 17: concatenated disk */
175: cdev_disk_init(NRD,rd), /* 18: ramdisk device */
176: cdev_disk_init(NVND,vnd), /* 19: vnode disk */
177: cdev_tape_init(NST,st), /* 20: SCSI tape */
178: cdev_fd_init(1,filedesc), /* 21: file descriptor pseudo-dev */
179: cdev_bpftun_init(NBPFILTER,bpf),/* 22: berkeley packet filter */
180: cdev_bpftun_init(NTUN,tun), /* 23: network tunnel */
181: cdev_lkm_init(NLKM,lkm), /* 24: loadable module driver */
182: cdev_notdef(), /* 25 */
183: #ifdef notyet
184: cdev_disk_init(NXD,xd), /* 26: XD disk */
185: #else
186: cdev_notdef(), /* 26 */
187: #endif
188: cdev_bio_init(NBIO,bio), /* 27: ioctl tunnel */
189: cdev_lp_init(NLP,lp), /* 28: lp */
190: cdev_lp_init(NLPTWO,lptwo), /* 29: lptwo */
191: cdev_tty_init(NWL,wl), /* 30: WG CL-CD2400 serial (ttywX) */
192: cdev_mdev_init(NVMEL,vmel), /* 31: /dev/vmelX */
193: cdev_mdev_init(NVMES,vmes), /* 32: /dev/vmesX */
194: cdev_lkm_dummy(), /* 33 */
195: cdev_lkm_dummy(), /* 34 */
196: cdev_lkm_dummy(), /* 35 */
197: cdev_lkm_dummy(), /* 36 */
198: cdev_lkm_dummy(), /* 37 */
199: cdev_lkm_dummy(), /* 38 */
200: cdev_pf_init(NPF,pf), /* 39: packet filter */
201: cdev_random_init(1,random), /* 40: random data source */
202: cdev_uk_init(NUK,uk), /* 41: unknown SCSI */
203: cdev_ss_init(NSS,ss), /* 42: SCSI scanner */
204: cdev_ksyms_init(NKSYMS,ksyms), /* 43: Kernel symbols device */
205: cdev_ch_init(NCH,ch), /* 44: SCSI autochanger */
206: cdev_lkm_dummy(), /* 45 */
207: cdev_lkm_dummy(), /* 46 */
208: cdev_lkm_dummy(), /* 47 */
209: cdev_lkm_dummy(), /* 48 */
210: cdev_lkm_dummy(), /* 49 */
211: cdev_systrace_init(NSYSTRACE,systrace), /* 50 system call tracing */
212: #ifdef XFS
213: cdev_xfs_init(NXFS,xfs_dev), /* 51: xfs communication device */
214: #else
215: cdev_lkm_dummy(), /* 51 */
216: #endif
217: cdev_ptm_init(NPTY,ptm), /* 52: pseudo-tty ptm device */
218: };
219: int nchrdev = sizeof(cdevsw) / sizeof(cdevsw[0]);
220:
221: int mem_no = 2; /* major device number of memory special file */
222:
223: /*
224: * Swapdev is a fake device implemented
225: * in sw.c used only internally to get to swstrategy.
226: * It cannot be provided to the users, because the
227: * swstrategy routine munches the b_dev and b_blkno entries
228: * before calling the appropriate driver. This would horribly
229: * confuse, e.g. the hashing routines. Instead, /dev/drum is
230: * provided as a character (raw) device.
231: */
232: dev_t swapdev = makedev(3, 0);
233:
234: /*
235: * Returns true if dev is /dev/mem or /dev/kmem.
236: */
237: int
238: iskmemdev(dev)
239: dev_t dev;
240: {
241:
242: return (major(dev) == mem_no && minor(dev) < 2);
243: }
244:
245: /*
246: * Returns true if dev is /dev/zero.
247: */
248: int
249: iszerodev(dev)
250: dev_t dev;
251: {
252:
253: return (major(dev) == mem_no && minor(dev) == 12);
254: }
255:
256: dev_t
257: getnulldev()
258: {
259: return makedev(mem_no, 2);
260: }
261:
262: int chrtoblktbl[] = {
263: /* XXXX This needs to be dynamic for LKMs. */
264: /*VCHR*/ /*VBLK*/
265: /* 0 */ NODEV,
266: /* 1 */ NODEV,
267: /* 2 */ NODEV,
268: /* 3 */ NODEV,
269: /* 4 */ NODEV,
270: /* 5 */ NODEV,
271: /* 6 */ NODEV,
272: /* 7 */ NODEV,
273: /* 8 */ 4, /* SCSI disk */
274: /* 9 */ 8, /* SCSI CD-ROM */
275: /* 10 */ NODEV,
276: /* 11 */ NODEV,
277: /* 12 */ NODEV,
278: /* 13 */ NODEV,
279: /* 14 */ NODEV,
280: /* 15 */ NODEV,
281: /* 16 */ NODEV,
282: /* 17 */ NODEV,
283: /* 18 */ 9,
284: /* 19 */ 6, /* vnode disk */
285: /* 20 */ NODEV,
286: /* 21 */ NODEV,
287: /* 22 */ NODEV,
288: /* 23 */ NODEV,
289: /* 24 */ NODEV,
290: /* 25 */ NODEV,
291: /* 26 */ 10, /* XD disk */
292: };
293: int nchrtoblktbl = sizeof(chrtoblktbl) / sizeof(chrtoblktbl[0]);
294:
295: /*
296: * This entire table could be autoconfig()ed but that would mean that
297: * the kernel's idea of the console would be out of sync with that of
298: * the standalone boot. I think it best that they both use the same
299: * known algorithm unless we see a pressing need otherwise.
300: */
301: #include <dev/cons.h>
302:
303: #define zscnpollc nullcnpollc
304: cons_decl(zs);
305: #define clcnpollc nullcnpollc
306: cons_decl(cl);
307:
308: struct consdev constab[] = {
309: #if NZS > 0
310: cons_init(zs),
311: #endif
312: #if NCL > 0
313: cons_init(cl),
314: #endif
315: { 0 },
316: };
CVSweb