Home | History | Annotate | Line # | Download | only in mvme68k
conf.c revision 1.21
      1  1.21       scw /*	$NetBSD: conf.c,v 1.21 2000/09/06 19:51:44 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.18    kleink #include "opt_compat_svr4.h"
     39  1.18    kleink 
     40   1.1     chuck #include <sys/param.h>
     41   1.1     chuck #include <sys/systm.h>
     42   1.1     chuck #include <sys/buf.h>
     43   1.1     chuck #include <sys/ioctl.h>
     44   1.1     chuck #include <sys/tty.h>
     45   1.1     chuck #include <sys/conf.h>
     46   1.1     chuck #include <sys/vnode.h>
     47   1.1     chuck 
     48   1.1     chuck bdev_decl(sw);
     49   1.1     chuck #include "sd.h"
     50   1.1     chuck bdev_decl(sd);
     51   1.6     chuck #include "ccd.h"
     52   1.6     chuck bdev_decl(ccd);
     53  1.15     oster #include "raid.h"
     54  1.15     oster bdev_decl(raid);
     55   1.6     chuck #include "vnd.h"
     56   1.6     chuck bdev_decl(vnd);
     57   1.6     chuck #include "st.h"
     58   1.6     chuck bdev_decl(st);
     59   1.1     chuck #include "cd.h"
     60   1.1     chuck bdev_decl(cd);
     61  1.10        pk #include "md.h"
     62  1.10        pk bdev_decl(md);
     63   1.1     chuck 
     64   1.1     chuck struct bdevsw	bdevsw[] =
     65   1.1     chuck {
     66   1.1     chuck 	bdev_notdef(),			/* 0 */
     67   1.1     chuck 	bdev_notdef(),			/* 1 */
     68   1.1     chuck 	bdev_notdef(),			/* 2 */
     69   1.1     chuck 	bdev_swap_init(1,sw),		/* 3: swap pseudo-device */
     70   1.1     chuck 	bdev_disk_init(NSD,sd),		/* 4: SCSI disk */
     71   1.6     chuck 	bdev_disk_init(NCCD,ccd),	/* 5: concatenated disk driver */
     72   1.1     chuck 	bdev_disk_init(NVND,vnd),	/* 6: vnode disk driver */
     73   1.6     chuck 	bdev_tape_init(NST,st),		/* 7: SCSI tape */
     74   1.6     chuck 	bdev_disk_init(NCD,cd),		/* 8: SCSI CD-ROM */
     75  1.10        pk 	bdev_disk_init(NMD,md),		/* 9: memory disk - for install tape */
     76   1.1     chuck 	bdev_lkm_dummy(),		/* 10 */
     77   1.1     chuck 	bdev_lkm_dummy(),		/* 11 */
     78   1.1     chuck 	bdev_lkm_dummy(),		/* 12 */
     79   1.1     chuck 	bdev_lkm_dummy(),		/* 13 */
     80   1.1     chuck 	bdev_lkm_dummy(),		/* 14 */
     81   1.6     chuck 	bdev_lkm_dummy(),		/* 15 */
     82  1.15     oster 	bdev_disk_init(NRAID,raid),	/* 16: RAIDframe disk driver */
     83   1.1     chuck };
     84   1.1     chuck 
     85   1.1     chuck int	nblkdev = sizeof (bdevsw) / sizeof (bdevsw[0]);
     86   1.1     chuck 
     87   1.1     chuck cdev_decl(cn);
     88   1.1     chuck cdev_decl(ctty);
     89   1.1     chuck #define mmread  mmrw
     90   1.1     chuck #define mmwrite mmrw
     91   1.1     chuck cdev_decl(mm);
     92   1.1     chuck cdev_decl(sw);
     93   1.1     chuck 
     94   1.1     chuck #include "pty.h"
     95   1.1     chuck #define ptstty		ptytty
     96   1.1     chuck #define	ptsioctl	ptyioctl
     97   1.1     chuck cdev_decl(pts);
     98   1.1     chuck #define ptctty		ptytty
     99   1.1     chuck #define	ptcioctl	ptyioctl
    100   1.1     chuck cdev_decl(ptc);
    101   1.1     chuck 
    102   1.1     chuck cdev_decl(log);
    103   1.1     chuck cdev_decl(fd);
    104   1.1     chuck 
    105   1.5     chuck #include "zstty.h"
    106   1.1     chuck cdev_decl(zs);
    107   1.1     chuck 
    108  1.17       scw #include "clmpcc.h"
    109  1.17       scw cdev_decl(clmpcc);
    110  1.17       scw 
    111   1.8     chuck cdev_decl(cd);
    112   1.8     chuck #include "ch.h"
    113   1.8     chuck cdev_decl(ch);
    114   1.1     chuck cdev_decl(sd);
    115   1.8     chuck #include "ss.h"
    116   1.8     chuck cdev_decl(ss);
    117   1.1     chuck cdev_decl(st);
    118   1.8     chuck #include "uk.h"
    119   1.8     chuck cdev_decl(uk);
    120   1.8     chuck 
    121  1.10        pk cdev_decl(md);
    122   1.1     chuck cdev_decl(vnd);
    123   1.2   thorpej cdev_decl(ccd);
    124  1.15     oster cdev_decl(raid);
    125   1.1     chuck 
    126   1.4     chuck dev_decl(filedesc,open);
    127   1.3  christos 
    128   1.1     chuck #include "bpfilter.h"
    129   1.1     chuck cdev_decl(bpf);
    130   1.1     chuck 
    131   1.1     chuck #include "tun.h"
    132   1.1     chuck cdev_decl(tun);
    133   1.1     chuck 
    134   1.9     chuck #include "lpt.h"
    135   1.9     chuck cdev_decl(lpt);
    136   1.9     chuck /* open, close, write, ioctl */
    137   1.9     chuck #define	cdev_lpt_init(c,n) { \
    138   1.9     chuck 	dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*)))enodev,  \
    139   1.9     chuck 	dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*)))enodev, \
    140   1.9     chuck 	0, seltrue, (dev_type_mmap((*))) enodev, 0}
    141   1.9     chuck 
    142  1.11   thorpej #include "ipfilter.h"
    143  1.12  explorer #include "rnd.h"
    144  1.11   thorpej 
    145  1.14   thorpej #include "scsibus.h"
    146  1.14   thorpej cdev_decl(scsibus);
    147  1.14   thorpej 
    148   1.1     chuck struct cdevsw	cdevsw[] =
    149   1.1     chuck {
    150   1.1     chuck 	cdev_cn_init(1,cn),		/* 0: virtual console */
    151   1.1     chuck 	cdev_ctty_init(1,ctty),		/* 1: controlling terminal */
    152   1.1     chuck 	cdev_mm_init(1,mm),		/* 2: /dev/{null,mem,kmem,...} */
    153   1.1     chuck 	cdev_swap_init(1,sw),		/* 3: /dev/drum (swap pseudo-device) */
    154   1.1     chuck 	cdev_tty_init(NPTY,pts),	/* 4: pseudo-tty slave */
    155   1.1     chuck 	cdev_ptc_init(NPTY,ptc),	/* 5: pseudo-tty master */
    156   1.1     chuck 	cdev_log_init(1,log),		/* 6: /dev/klog */
    157  1.11   thorpej 	cdev_ipf_init(NIPFILTER,ipl),	/* 7: ip-filter device */
    158   1.1     chuck 	cdev_disk_init(NSD,sd),		/* 8: SCSI disk */
    159   1.6     chuck 	cdev_notdef(),			/* 9 */
    160   1.1     chuck 	cdev_notdef(),			/* 10 */
    161   1.9     chuck 	cdev_lpt_init(NLPT,lpt),	/* 11: parallel interface */
    162   1.5     chuck 	cdev_tty_init(NZSTTY,zs),	/* 12: SCC serial ports */
    163  1.17       scw 	cdev_tty_init(NCLMPCC,clmpcc),	/* 13: CD2401 serial ports */
    164   1.1     chuck 	cdev_notdef(),			/* 14 */
    165   1.1     chuck 	cdev_notdef(),			/* 15 */
    166   1.1     chuck 	cdev_notdef(),			/* 16 */
    167   1.2   thorpej 	cdev_disk_init(NCCD,ccd),	/* 17: concatenated disk driver */
    168   1.6     chuck 	cdev_disk_init(NCD,cd),		/* 18: SCSI CD-ROM */
    169   1.1     chuck 	cdev_disk_init(NVND,vnd),	/* 19: vnode disk */
    170   1.1     chuck 	cdev_tape_init(NST,st),		/* 20: SCSI tape */
    171   1.3  christos 	cdev_fd_init(1,filedesc),	/* 21: file descriptor pseudo-dev */
    172   1.1     chuck 	cdev_bpftun_init(NBPFILTER,bpf),/* 22: berkeley packet filter */
    173   1.1     chuck 	cdev_bpftun_init(NTUN,tun),	/* 23: network tunnel */
    174   1.1     chuck 	cdev_lkm_init(NLKM,lkm),	/* 24: loadable module driver */
    175   1.1     chuck 	cdev_lkm_dummy(),		/* 25 */
    176   1.1     chuck 	cdev_lkm_dummy(),		/* 26 */
    177   1.1     chuck 	cdev_lkm_dummy(),		/* 27 */
    178   1.1     chuck 	cdev_lkm_dummy(),		/* 28 */
    179   1.1     chuck 	cdev_lkm_dummy(),		/* 29 */
    180   1.1     chuck 	cdev_lkm_dummy(),		/* 30 */
    181   1.8     chuck 	cdev_ch_init(NCH,ch),		/* 31: SCSI autochanger */
    182  1.10        pk 	cdev_disk_init(NMD,md),		/* 32: memory disk driver */
    183   1.8     chuck 	cdev_scanner_init(NSS,ss),	/* 33: SCSI scanner */
    184   1.8     chuck 	cdev_uk_init(NUK,uk),		/* 34: SCSI unknown */
    185  1.12  explorer 	cdev_rnd_init(NRND,rnd),	/* 35: random source pseudo-device */
    186  1.16       scw 	cdev_scsibus_init(NSCSIBUS,scsibus), /* 36: SCSI bus */
    187  1.19       scw 	cdev_disk_init(NRAID,raid),	/* 37: RAIDframe disk driver */
    188  1.19       scw 	cdev_svr4_net_init(NSVR4_NET,svr4_net) /* 38: svr4 net pseudo-device */
    189   1.1     chuck };
    190   1.1     chuck 
    191   1.1     chuck int	nchrdev = sizeof (cdevsw) / sizeof (cdevsw[0]);
    192   1.1     chuck 
    193   1.1     chuck int	mem_no = 2; 	/* major device number of memory special file */
    194   1.1     chuck 
    195   1.1     chuck /*
    196   1.1     chuck  * Swapdev is a fake device implemented
    197   1.1     chuck  * in sw.c used only internally to get to swstrategy.
    198   1.1     chuck  * It cannot be provided to the users, because the
    199   1.1     chuck  * swstrategy routine munches the b_dev and b_blkno entries
    200   1.1     chuck  * before calling the appropriate driver.  This would horribly
    201   1.1     chuck  * confuse, e.g. the hashing routines. Instead, /dev/drum is
    202   1.1     chuck  * provided as a character (raw) device.
    203   1.1     chuck  */
    204   1.1     chuck dev_t	swapdev = makedev(3, 0);
    205   1.1     chuck 
    206   1.1     chuck /*
    207   1.1     chuck  * Returns true if dev is /dev/mem or /dev/kmem.
    208   1.1     chuck  */
    209  1.20       scw int
    210   1.1     chuck iskmemdev(dev)
    211   1.1     chuck 	dev_t dev;
    212   1.1     chuck {
    213   1.1     chuck 
    214   1.1     chuck 	return (major(dev) == mem_no && minor(dev) < 2);
    215   1.1     chuck }
    216   1.1     chuck 
    217   1.1     chuck /*
    218   1.1     chuck  * Returns true if dev is /dev/zero.
    219   1.1     chuck  */
    220  1.20       scw int
    221   1.1     chuck iszerodev(dev)
    222   1.1     chuck 	dev_t dev;
    223   1.1     chuck {
    224   1.1     chuck 
    225   1.1     chuck 	return (major(dev) == mem_no && minor(dev) == 12);
    226   1.1     chuck }
    227   1.1     chuck 
    228   1.1     chuck static int chrtoblktbl[] = {
    229   1.1     chuck 	/* XXXX This needs to be dynamic for LKMs. */
    230   1.1     chuck 	/*VCHR*/	/*VBLK*/
    231   1.1     chuck 	/*  0 */	NODEV,
    232   1.1     chuck 	/*  1 */	NODEV,
    233   1.1     chuck 	/*  2 */	NODEV,
    234   1.8     chuck 	/*  3 */	3,		/* sw */
    235   1.1     chuck 	/*  4 */	NODEV,
    236   1.1     chuck 	/*  5 */	NODEV,
    237   1.1     chuck 	/*  6 */	NODEV,
    238   1.1     chuck 	/*  7 */	NODEV,
    239   1.8     chuck 	/*  8 */	4,		/* sd */
    240   1.8     chuck 	/*  9 */	NODEV,
    241   1.1     chuck 	/* 10 */	NODEV,
    242   1.1     chuck 	/* 11 */	NODEV,
    243   1.1     chuck 	/* 12 */	NODEV,
    244   1.1     chuck 	/* 13 */	NODEV,
    245   1.1     chuck 	/* 14 */	NODEV,
    246   1.1     chuck 	/* 15 */	NODEV,
    247   1.1     chuck 	/* 16 */	NODEV,
    248   1.8     chuck 	/* 17 */	5,		/* ccd */
    249   1.8     chuck 	/* 18 */	8,		/* cd */
    250   1.8     chuck 	/* 19 */	6,		/* vnd */
    251   1.8     chuck 	/* 20 */	7,		/* st */
    252   1.1     chuck 	/* 21 */	NODEV,
    253   1.1     chuck 	/* 22 */	NODEV,
    254   1.8     chuck 	/* 23 */	NODEV,
    255   1.8     chuck 	/* 24 */	NODEV,
    256   1.8     chuck 	/* 25 */	NODEV,
    257   1.8     chuck 	/* 26 */	NODEV,
    258   1.8     chuck 	/* 27 */	NODEV,
    259   1.8     chuck 	/* 28 */	NODEV,
    260   1.8     chuck 	/* 29 */	NODEV,
    261   1.8     chuck 	/* 30 */	NODEV,
    262   1.8     chuck 	/* 31 */	NODEV,
    263  1.10        pk 	/* 32 */	9,		/* md */
    264  1.12  explorer 	/* 33 */	NODEV,
    265  1.12  explorer 	/* 34 */	NODEV,
    266  1.12  explorer 	/* 35 */	NODEV,
    267  1.14   thorpej 	/* 36 */	NODEV,
    268  1.15     oster 	/* 37 */	16,		/* RAIDframe */
    269   1.1     chuck };
    270   1.1     chuck 
    271   1.1     chuck /*
    272   1.1     chuck  * Convert a character device number to a block device number.
    273   1.1     chuck  */
    274  1.13  christos dev_t
    275   1.1     chuck chrtoblk(dev)
    276   1.1     chuck 	dev_t dev;
    277   1.1     chuck {
    278   1.1     chuck 	int blkmaj;
    279   1.1     chuck 
    280   1.8     chuck 	if (major(dev) >= nchrdev
    281   1.8     chuck 	  || major(dev) >= (sizeof(chrtoblktbl) / sizeof(chrtoblktbl[0])))
    282   1.1     chuck 		return (NODEV);
    283   1.1     chuck 	blkmaj = chrtoblktbl[major(dev)];
    284   1.1     chuck 	if (blkmaj == NODEV)
    285   1.1     chuck 		return (NODEV);
    286   1.1     chuck 	return (makedev(blkmaj, minor(dev)));
    287   1.1     chuck }
    288   1.1     chuck 
    289   1.1     chuck /*
    290   1.1     chuck  * This entire table could be autoconfig()ed but that would mean that
    291   1.1     chuck  * the kernel's idea of the console would be out of sync with that of
    292   1.1     chuck  * the standalone boot.  I think it best that they both use the same
    293   1.1     chuck  * known algorithm unless we see a pressing need otherwise.
    294   1.1     chuck  */
    295   1.1     chuck #include <dev/cons.h>
    296   1.1     chuck 
    297   1.5     chuck #define zsc_pcccnpollc		nullcnpollc
    298   1.5     chuck #include "zsc_pcc.h"
    299   1.5     chuck cons_decl(zsc_pcc);
    300   1.1     chuck 
    301  1.21       scw #define zsc_pcctwocnpollc	nullcnpollc
    302  1.21       scw #define zsc_pcctwocngetc	zsc_pcccngetc
    303  1.21       scw #define zsc_pcctwocnputc	zsc_pcccnputc
    304  1.21       scw #include "zsc_pcctwo.h"
    305  1.21       scw cons_decl(zsc_pcctwo);
    306  1.21       scw 
    307  1.17       scw #define clmpcccnpollc		nullcnpollc
    308  1.17       scw #include "clmpcc_pcctwo.h"
    309  1.17       scw cons_decl(clmpcc);
    310  1.17       scw 
    311  1.17       scw 
    312   1.1     chuck struct	consdev constab[] = {
    313   1.5     chuck #if NZSC_PCC > 0
    314   1.5     chuck 	cons_init(zsc_pcc),
    315  1.21       scw #endif
    316  1.21       scw #if NZSC_PCCTWO > 0
    317  1.21       scw 	cons_init(zsc_pcctwo),
    318  1.17       scw #endif
    319  1.17       scw #if NCLMPCC_PCCTWO > 0
    320  1.17       scw 	cons_init(clmpcc),
    321   1.1     chuck #endif
    322   1.1     chuck 	{ 0 },
    323   1.1     chuck };
    324