conf.c revision 1.16 1 1.16 scw /* $NetBSD: conf.c,v 1.16 1998/11/21 20:37:06 scw Exp $ */
2 1.1 chuck
3 1.1 chuck /*-
4 1.1 chuck * Copyright (c) 1991 The Regents of the University of California.
5 1.1 chuck * All rights reserved.
6 1.1 chuck *
7 1.1 chuck * Redistribution and use in source and binary forms, with or without
8 1.1 chuck * modification, are permitted provided that the following conditions
9 1.1 chuck * are met:
10 1.1 chuck * 1. Redistributions of source code must retain the above copyright
11 1.1 chuck * notice, this list of conditions and the following disclaimer.
12 1.1 chuck * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 chuck * notice, this list of conditions and the following disclaimer in the
14 1.1 chuck * documentation and/or other materials provided with the distribution.
15 1.1 chuck * 3. All advertising materials mentioning features or use of this software
16 1.1 chuck * must display the following acknowledgement:
17 1.1 chuck * This product includes software developed by the University of
18 1.1 chuck * California, Berkeley and its contributors.
19 1.1 chuck * 4. Neither the name of the University nor the names of its contributors
20 1.1 chuck * may be used to endorse or promote products derived from this software
21 1.1 chuck * without specific prior written permission.
22 1.1 chuck *
23 1.1 chuck * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 1.1 chuck * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 1.1 chuck * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 1.1 chuck * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 1.1 chuck * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 1.1 chuck * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 1.1 chuck * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 1.1 chuck * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 1.1 chuck * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 1.1 chuck * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 1.1 chuck * SUCH DAMAGE.
34 1.1 chuck *
35 1.1 chuck * @(#)conf.c 7.9 (Berkeley) 5/28/91
36 1.1 chuck */
37 1.1 chuck
38 1.1 chuck #include <sys/param.h>
39 1.1 chuck #include <sys/systm.h>
40 1.1 chuck #include <sys/buf.h>
41 1.1 chuck #include <sys/ioctl.h>
42 1.1 chuck #include <sys/tty.h>
43 1.1 chuck #include <sys/conf.h>
44 1.1 chuck #include <sys/vnode.h>
45 1.1 chuck
46 1.1 chuck bdev_decl(sw);
47 1.1 chuck #include "sd.h"
48 1.1 chuck bdev_decl(sd);
49 1.6 chuck #include "ccd.h"
50 1.6 chuck bdev_decl(ccd);
51 1.15 oster #include "raid.h"
52 1.15 oster bdev_decl(raid);
53 1.6 chuck #include "vnd.h"
54 1.6 chuck bdev_decl(vnd);
55 1.6 chuck #include "st.h"
56 1.6 chuck bdev_decl(st);
57 1.1 chuck #include "cd.h"
58 1.1 chuck bdev_decl(cd);
59 1.10 pk #include "md.h"
60 1.10 pk bdev_decl(md);
61 1.1 chuck
62 1.1 chuck struct bdevsw bdevsw[] =
63 1.1 chuck {
64 1.1 chuck bdev_notdef(), /* 0 */
65 1.1 chuck bdev_notdef(), /* 1 */
66 1.1 chuck bdev_notdef(), /* 2 */
67 1.1 chuck bdev_swap_init(1,sw), /* 3: swap pseudo-device */
68 1.1 chuck bdev_disk_init(NSD,sd), /* 4: SCSI disk */
69 1.6 chuck bdev_disk_init(NCCD,ccd), /* 5: concatenated disk driver */
70 1.1 chuck bdev_disk_init(NVND,vnd), /* 6: vnode disk driver */
71 1.6 chuck bdev_tape_init(NST,st), /* 7: SCSI tape */
72 1.6 chuck bdev_disk_init(NCD,cd), /* 8: SCSI CD-ROM */
73 1.10 pk bdev_disk_init(NMD,md), /* 9: memory disk - for install tape */
74 1.1 chuck bdev_lkm_dummy(), /* 10 */
75 1.1 chuck bdev_lkm_dummy(), /* 11 */
76 1.1 chuck bdev_lkm_dummy(), /* 12 */
77 1.1 chuck bdev_lkm_dummy(), /* 13 */
78 1.1 chuck bdev_lkm_dummy(), /* 14 */
79 1.6 chuck bdev_lkm_dummy(), /* 15 */
80 1.15 oster bdev_disk_init(NRAID,raid), /* 16: RAIDframe disk driver */
81 1.1 chuck };
82 1.1 chuck
83 1.1 chuck int nblkdev = sizeof (bdevsw) / sizeof (bdevsw[0]);
84 1.1 chuck
85 1.1 chuck cdev_decl(cn);
86 1.1 chuck cdev_decl(ctty);
87 1.1 chuck #define mmread mmrw
88 1.1 chuck #define mmwrite mmrw
89 1.1 chuck cdev_decl(mm);
90 1.1 chuck cdev_decl(sw);
91 1.1 chuck
92 1.1 chuck #include "pty.h"
93 1.1 chuck #define ptstty ptytty
94 1.1 chuck #define ptsioctl ptyioctl
95 1.1 chuck cdev_decl(pts);
96 1.1 chuck #define ptctty ptytty
97 1.1 chuck #define ptcioctl ptyioctl
98 1.1 chuck cdev_decl(ptc);
99 1.1 chuck
100 1.1 chuck cdev_decl(log);
101 1.1 chuck cdev_decl(fd);
102 1.1 chuck
103 1.5 chuck #include "zstty.h"
104 1.1 chuck cdev_decl(zs);
105 1.1 chuck
106 1.8 chuck cdev_decl(cd);
107 1.8 chuck #include "ch.h"
108 1.8 chuck cdev_decl(ch);
109 1.1 chuck cdev_decl(sd);
110 1.8 chuck #include "ss.h"
111 1.8 chuck cdev_decl(ss);
112 1.1 chuck cdev_decl(st);
113 1.8 chuck #include "uk.h"
114 1.8 chuck cdev_decl(uk);
115 1.8 chuck
116 1.10 pk cdev_decl(md);
117 1.1 chuck cdev_decl(vnd);
118 1.2 thorpej cdev_decl(ccd);
119 1.15 oster cdev_decl(raid);
120 1.1 chuck
121 1.4 chuck dev_decl(filedesc,open);
122 1.3 christos
123 1.1 chuck #include "bpfilter.h"
124 1.1 chuck cdev_decl(bpf);
125 1.1 chuck
126 1.1 chuck #include "tun.h"
127 1.1 chuck cdev_decl(tun);
128 1.1 chuck
129 1.9 chuck #include "lpt.h"
130 1.9 chuck cdev_decl(lpt);
131 1.9 chuck /* open, close, write, ioctl */
132 1.9 chuck #define cdev_lpt_init(c,n) { \
133 1.9 chuck dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*)))enodev, \
134 1.9 chuck dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*)))enodev, \
135 1.9 chuck 0, seltrue, (dev_type_mmap((*))) enodev, 0}
136 1.9 chuck
137 1.11 thorpej #include "ipfilter.h"
138 1.12 explorer #include "rnd.h"
139 1.11 thorpej
140 1.14 thorpej #include "scsibus.h"
141 1.14 thorpej cdev_decl(scsibus);
142 1.14 thorpej
143 1.1 chuck struct cdevsw cdevsw[] =
144 1.1 chuck {
145 1.1 chuck cdev_cn_init(1,cn), /* 0: virtual console */
146 1.1 chuck cdev_ctty_init(1,ctty), /* 1: controlling terminal */
147 1.1 chuck cdev_mm_init(1,mm), /* 2: /dev/{null,mem,kmem,...} */
148 1.1 chuck cdev_swap_init(1,sw), /* 3: /dev/drum (swap pseudo-device) */
149 1.1 chuck cdev_tty_init(NPTY,pts), /* 4: pseudo-tty slave */
150 1.1 chuck cdev_ptc_init(NPTY,ptc), /* 5: pseudo-tty master */
151 1.1 chuck cdev_log_init(1,log), /* 6: /dev/klog */
152 1.11 thorpej cdev_ipf_init(NIPFILTER,ipl), /* 7: ip-filter device */
153 1.1 chuck cdev_disk_init(NSD,sd), /* 8: SCSI disk */
154 1.6 chuck cdev_notdef(), /* 9 */
155 1.1 chuck cdev_notdef(), /* 10 */
156 1.9 chuck cdev_lpt_init(NLPT,lpt), /* 11: parallel interface */
157 1.5 chuck cdev_tty_init(NZSTTY,zs), /* 12: SCC serial ports */
158 1.1 chuck cdev_notdef(), /* 13 */
159 1.1 chuck cdev_notdef(), /* 14 */
160 1.1 chuck cdev_notdef(), /* 15 */
161 1.1 chuck cdev_notdef(), /* 16 */
162 1.2 thorpej cdev_disk_init(NCCD,ccd), /* 17: concatenated disk driver */
163 1.6 chuck cdev_disk_init(NCD,cd), /* 18: SCSI CD-ROM */
164 1.1 chuck cdev_disk_init(NVND,vnd), /* 19: vnode disk */
165 1.1 chuck cdev_tape_init(NST,st), /* 20: SCSI tape */
166 1.3 christos cdev_fd_init(1,filedesc), /* 21: file descriptor pseudo-dev */
167 1.1 chuck cdev_bpftun_init(NBPFILTER,bpf),/* 22: berkeley packet filter */
168 1.1 chuck cdev_bpftun_init(NTUN,tun), /* 23: network tunnel */
169 1.1 chuck cdev_lkm_init(NLKM,lkm), /* 24: loadable module driver */
170 1.1 chuck cdev_lkm_dummy(), /* 25 */
171 1.1 chuck cdev_lkm_dummy(), /* 26 */
172 1.1 chuck cdev_lkm_dummy(), /* 27 */
173 1.1 chuck cdev_lkm_dummy(), /* 28 */
174 1.1 chuck cdev_lkm_dummy(), /* 29 */
175 1.1 chuck cdev_lkm_dummy(), /* 30 */
176 1.8 chuck cdev_ch_init(NCH,ch), /* 31: SCSI autochanger */
177 1.10 pk cdev_disk_init(NMD,md), /* 32: memory disk driver */
178 1.8 chuck cdev_scanner_init(NSS,ss), /* 33: SCSI scanner */
179 1.8 chuck cdev_uk_init(NUK,uk), /* 34: SCSI unknown */
180 1.12 explorer cdev_rnd_init(NRND,rnd), /* 35: random source pseudo-device */
181 1.16 scw cdev_scsibus_init(NSCSIBUS,scsibus), /* 36: SCSI bus */
182 1.16 scw cdev_disk_init(NRAID,raid) /* 37: RAIDframe disk driver */
183 1.1 chuck };
184 1.1 chuck
185 1.1 chuck int nchrdev = sizeof (cdevsw) / sizeof (cdevsw[0]);
186 1.1 chuck
187 1.1 chuck int mem_no = 2; /* major device number of memory special file */
188 1.1 chuck
189 1.1 chuck /*
190 1.1 chuck * Swapdev is a fake device implemented
191 1.1 chuck * in sw.c used only internally to get to swstrategy.
192 1.1 chuck * It cannot be provided to the users, because the
193 1.1 chuck * swstrategy routine munches the b_dev and b_blkno entries
194 1.1 chuck * before calling the appropriate driver. This would horribly
195 1.1 chuck * confuse, e.g. the hashing routines. Instead, /dev/drum is
196 1.1 chuck * provided as a character (raw) device.
197 1.1 chuck */
198 1.1 chuck dev_t swapdev = makedev(3, 0);
199 1.1 chuck
200 1.1 chuck /*
201 1.1 chuck * Returns true if dev is /dev/mem or /dev/kmem.
202 1.1 chuck */
203 1.1 chuck iskmemdev(dev)
204 1.1 chuck dev_t dev;
205 1.1 chuck {
206 1.1 chuck
207 1.1 chuck return (major(dev) == mem_no && minor(dev) < 2);
208 1.1 chuck }
209 1.1 chuck
210 1.1 chuck /*
211 1.1 chuck * Returns true if dev is /dev/zero.
212 1.1 chuck */
213 1.1 chuck iszerodev(dev)
214 1.1 chuck dev_t dev;
215 1.1 chuck {
216 1.1 chuck
217 1.1 chuck return (major(dev) == mem_no && minor(dev) == 12);
218 1.1 chuck }
219 1.1 chuck
220 1.1 chuck static int chrtoblktbl[] = {
221 1.1 chuck /* XXXX This needs to be dynamic for LKMs. */
222 1.1 chuck /*VCHR*/ /*VBLK*/
223 1.1 chuck /* 0 */ NODEV,
224 1.1 chuck /* 1 */ NODEV,
225 1.1 chuck /* 2 */ NODEV,
226 1.8 chuck /* 3 */ 3, /* sw */
227 1.1 chuck /* 4 */ NODEV,
228 1.1 chuck /* 5 */ NODEV,
229 1.1 chuck /* 6 */ NODEV,
230 1.1 chuck /* 7 */ NODEV,
231 1.8 chuck /* 8 */ 4, /* sd */
232 1.8 chuck /* 9 */ NODEV,
233 1.1 chuck /* 10 */ NODEV,
234 1.1 chuck /* 11 */ NODEV,
235 1.1 chuck /* 12 */ NODEV,
236 1.1 chuck /* 13 */ NODEV,
237 1.1 chuck /* 14 */ NODEV,
238 1.1 chuck /* 15 */ NODEV,
239 1.1 chuck /* 16 */ NODEV,
240 1.8 chuck /* 17 */ 5, /* ccd */
241 1.8 chuck /* 18 */ 8, /* cd */
242 1.8 chuck /* 19 */ 6, /* vnd */
243 1.8 chuck /* 20 */ 7, /* st */
244 1.1 chuck /* 21 */ NODEV,
245 1.1 chuck /* 22 */ NODEV,
246 1.8 chuck /* 23 */ NODEV,
247 1.8 chuck /* 24 */ NODEV,
248 1.8 chuck /* 25 */ NODEV,
249 1.8 chuck /* 26 */ NODEV,
250 1.8 chuck /* 27 */ NODEV,
251 1.8 chuck /* 28 */ NODEV,
252 1.8 chuck /* 29 */ NODEV,
253 1.8 chuck /* 30 */ NODEV,
254 1.8 chuck /* 31 */ NODEV,
255 1.10 pk /* 32 */ 9, /* md */
256 1.12 explorer /* 33 */ NODEV,
257 1.12 explorer /* 34 */ NODEV,
258 1.12 explorer /* 35 */ NODEV,
259 1.14 thorpej /* 36 */ NODEV,
260 1.15 oster /* 37 */ 16, /* RAIDframe */
261 1.1 chuck };
262 1.1 chuck
263 1.1 chuck /*
264 1.1 chuck * Convert a character device number to a block device number.
265 1.1 chuck */
266 1.13 christos dev_t
267 1.1 chuck chrtoblk(dev)
268 1.1 chuck dev_t dev;
269 1.1 chuck {
270 1.1 chuck int blkmaj;
271 1.1 chuck
272 1.8 chuck if (major(dev) >= nchrdev
273 1.8 chuck || major(dev) >= (sizeof(chrtoblktbl) / sizeof(chrtoblktbl[0])))
274 1.1 chuck return (NODEV);
275 1.1 chuck blkmaj = chrtoblktbl[major(dev)];
276 1.1 chuck if (blkmaj == NODEV)
277 1.1 chuck return (NODEV);
278 1.1 chuck return (makedev(blkmaj, minor(dev)));
279 1.1 chuck }
280 1.1 chuck
281 1.1 chuck /*
282 1.1 chuck * This entire table could be autoconfig()ed but that would mean that
283 1.1 chuck * the kernel's idea of the console would be out of sync with that of
284 1.1 chuck * the standalone boot. I think it best that they both use the same
285 1.1 chuck * known algorithm unless we see a pressing need otherwise.
286 1.1 chuck */
287 1.1 chuck #include <dev/cons.h>
288 1.1 chuck
289 1.5 chuck #define zsc_pcccngetc zscngetc
290 1.5 chuck #define zsc_pcccnputc zscnputc
291 1.5 chuck #define zsc_pcccnpollc nullcnpollc
292 1.5 chuck #include "zsc_pcc.h"
293 1.5 chuck cons_decl(zsc_pcc);
294 1.1 chuck
295 1.1 chuck struct consdev constab[] = {
296 1.5 chuck #if NZSC_PCC > 0
297 1.5 chuck cons_init(zsc_pcc),
298 1.1 chuck #endif
299 1.1 chuck { 0 },
300 1.1 chuck };
301