Home | History | Annotate | Line # | Download | only in mvme68k
conf.c revision 1.1
      1  1.1  chuck /*	$NetBSD: conf.c,v 1.1 1995/07/25 23:11:56 chuck 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 int	ttselect	__P((dev_t, int, struct proc *));
     47  1.1  chuck 
     48  1.1  chuck #ifdef LKM
     49  1.1  chuck int	lkmenodev();
     50  1.1  chuck #else
     51  1.1  chuck #define	lkmenodev	enodev
     52  1.1  chuck #endif
     53  1.1  chuck 
     54  1.1  chuck #include "vnd.h"
     55  1.1  chuck bdev_decl(vnd);
     56  1.1  chuck bdev_decl(sw);
     57  1.1  chuck #include "sd.h"
     58  1.1  chuck bdev_decl(sd);
     59  1.1  chuck #include "cd.h"
     60  1.1  chuck bdev_decl(cd);
     61  1.1  chuck #include "st.h"
     62  1.1  chuck bdev_decl(st);
     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.1  chuck 	bdev_tape_init(NST,st),		/* 5: SCSI tape */
     72  1.1  chuck 	bdev_disk_init(NVND,vnd),	/* 6: vnode disk driver */
     73  1.1  chuck 	bdev_disk_init(NCD,cd),		/* 7: SCSI CD-ROM */
     74  1.1  chuck 	bdev_notdef(),			/* 8 */
     75  1.1  chuck 	bdev_lkm_dummy(),		/* 9 */
     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.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.1  chuck #include "zs.h"
    104  1.1  chuck cdev_decl(zs);
    105  1.1  chuck 
    106  1.1  chuck cdev_decl(sd);
    107  1.1  chuck cdev_decl(cd);
    108  1.1  chuck cdev_decl(st);
    109  1.1  chuck cdev_decl(vnd);
    110  1.1  chuck 
    111  1.1  chuck #include "bpfilter.h"
    112  1.1  chuck cdev_decl(bpf);
    113  1.1  chuck 
    114  1.1  chuck #include "tun.h"
    115  1.1  chuck cdev_decl(tun);
    116  1.1  chuck #ifdef LKM
    117  1.1  chuck #define NLKM 1
    118  1.1  chuck #else
    119  1.1  chuck #define NLKM 0
    120  1.1  chuck #endif
    121  1.1  chuck cdev_decl(lkm);
    122  1.1  chuck 
    123  1.1  chuck struct cdevsw	cdevsw[] =
    124  1.1  chuck {
    125  1.1  chuck 	cdev_cn_init(1,cn),		/* 0: virtual console */
    126  1.1  chuck 	cdev_ctty_init(1,ctty),		/* 1: controlling terminal */
    127  1.1  chuck 	cdev_mm_init(1,mm),		/* 2: /dev/{null,mem,kmem,...} */
    128  1.1  chuck 	cdev_swap_init(1,sw),		/* 3: /dev/drum (swap pseudo-device) */
    129  1.1  chuck 	cdev_tty_init(NPTY,pts),	/* 4: pseudo-tty slave */
    130  1.1  chuck 	cdev_ptc_init(NPTY,ptc),	/* 5: pseudo-tty master */
    131  1.1  chuck 	cdev_log_init(1,log),		/* 6: /dev/klog */
    132  1.1  chuck 	cdev_notdef(),			/* 7 */
    133  1.1  chuck 	cdev_disk_init(NSD,sd),		/* 8: SCSI disk */
    134  1.1  chuck 	cdev_disk_init(NCD,cd),		/* 9: SCSI CD-ROM */
    135  1.1  chuck 	cdev_notdef(),			/* 10 */
    136  1.1  chuck 	cdev_notdef(),			/* 11: parallel interface */
    137  1.1  chuck 	cdev_tty_init(NZS,zs),		/* 12: SCC serial ports */
    138  1.1  chuck 	cdev_notdef(),			/* 13 */
    139  1.1  chuck 	cdev_notdef(),			/* 14 */
    140  1.1  chuck 	cdev_notdef(),			/* 15 */
    141  1.1  chuck 	cdev_notdef(),			/* 16 */
    142  1.1  chuck 	cdev_notdef(),			/* 17: concatenated disk */
    143  1.1  chuck 	cdev_notdef(),			/* 18 */
    144  1.1  chuck 	cdev_disk_init(NVND,vnd),	/* 19: vnode disk */
    145  1.1  chuck 	cdev_tape_init(NST,st),		/* 20: SCSI tape */
    146  1.1  chuck 	cdev_fd_init(1,fd),		/* 21: file descriptor pseudo-dev */
    147  1.1  chuck 	cdev_bpftun_init(NBPFILTER,bpf),/* 22: berkeley packet filter */
    148  1.1  chuck 	cdev_bpftun_init(NTUN,tun),	/* 23: network tunnel */
    149  1.1  chuck 	cdev_lkm_init(NLKM,lkm),	/* 24: loadable module driver */
    150  1.1  chuck 	cdev_lkm_dummy(),		/* 25 */
    151  1.1  chuck 	cdev_lkm_dummy(),		/* 26 */
    152  1.1  chuck 	cdev_lkm_dummy(),		/* 27 */
    153  1.1  chuck 	cdev_lkm_dummy(),		/* 28 */
    154  1.1  chuck 	cdev_lkm_dummy(),		/* 29 */
    155  1.1  chuck 	cdev_lkm_dummy(),		/* 30 */
    156  1.1  chuck };
    157  1.1  chuck 
    158  1.1  chuck int	nchrdev = sizeof (cdevsw) / sizeof (cdevsw[0]);
    159  1.1  chuck 
    160  1.1  chuck int	mem_no = 2; 	/* major device number of memory special file */
    161  1.1  chuck 
    162  1.1  chuck /*
    163  1.1  chuck  * Swapdev is a fake device implemented
    164  1.1  chuck  * in sw.c used only internally to get to swstrategy.
    165  1.1  chuck  * It cannot be provided to the users, because the
    166  1.1  chuck  * swstrategy routine munches the b_dev and b_blkno entries
    167  1.1  chuck  * before calling the appropriate driver.  This would horribly
    168  1.1  chuck  * confuse, e.g. the hashing routines. Instead, /dev/drum is
    169  1.1  chuck  * provided as a character (raw) device.
    170  1.1  chuck  */
    171  1.1  chuck dev_t	swapdev = makedev(3, 0);
    172  1.1  chuck 
    173  1.1  chuck /*
    174  1.1  chuck  * Returns true if dev is /dev/mem or /dev/kmem.
    175  1.1  chuck  */
    176  1.1  chuck iskmemdev(dev)
    177  1.1  chuck 	dev_t dev;
    178  1.1  chuck {
    179  1.1  chuck 
    180  1.1  chuck 	return (major(dev) == mem_no && minor(dev) < 2);
    181  1.1  chuck }
    182  1.1  chuck 
    183  1.1  chuck /*
    184  1.1  chuck  * Returns true if dev is /dev/zero.
    185  1.1  chuck  */
    186  1.1  chuck iszerodev(dev)
    187  1.1  chuck 	dev_t dev;
    188  1.1  chuck {
    189  1.1  chuck 
    190  1.1  chuck 	return (major(dev) == mem_no && minor(dev) == 12);
    191  1.1  chuck }
    192  1.1  chuck 
    193  1.1  chuck /*
    194  1.1  chuck  * Returns true if dev is a disk device.
    195  1.1  chuck  */
    196  1.1  chuck isdisk(dev, type)
    197  1.1  chuck 	dev_t dev;
    198  1.1  chuck 	int type;
    199  1.1  chuck {
    200  1.1  chuck 
    201  1.1  chuck 	/* XXXX This needs to be dynamic for LKMs. */
    202  1.1  chuck 	switch (major(dev)) {
    203  1.1  chuck 	case 1:
    204  1.1  chuck 	case 2:
    205  1.1  chuck 	case 4:
    206  1.1  chuck 	case 6:
    207  1.1  chuck 		return (type == VBLK);
    208  1.1  chuck 	case 8:
    209  1.1  chuck 	case 9:
    210  1.1  chuck 	case 10:
    211  1.1  chuck 	case 19:
    212  1.1  chuck 		return (type == VCHR);
    213  1.1  chuck 	default:
    214  1.1  chuck 		return (0);
    215  1.1  chuck 	}
    216  1.1  chuck }
    217  1.1  chuck 
    218  1.1  chuck static int chrtoblktbl[] = {
    219  1.1  chuck 	/* XXXX This needs to be dynamic for LKMs. */
    220  1.1  chuck 	/*VCHR*/	/*VBLK*/
    221  1.1  chuck 	/*  0 */	NODEV,
    222  1.1  chuck 	/*  1 */	NODEV,
    223  1.1  chuck 	/*  2 */	NODEV,
    224  1.1  chuck 	/*  3 */	NODEV,
    225  1.1  chuck 	/*  4 */	NODEV,
    226  1.1  chuck 	/*  5 */	NODEV,
    227  1.1  chuck 	/*  6 */	NODEV,
    228  1.1  chuck 	/*  7 */	NODEV,
    229  1.1  chuck 	/*  8 */	4,
    230  1.1  chuck 	/*  9 */	7,
    231  1.1  chuck 	/* 10 */	NODEV,
    232  1.1  chuck 	/* 11 */	NODEV,
    233  1.1  chuck 	/* 12 */	NODEV,
    234  1.1  chuck 	/* 13 */	NODEV,
    235  1.1  chuck 	/* 14 */	NODEV,
    236  1.1  chuck 	/* 15 */	NODEV,
    237  1.1  chuck 	/* 16 */	NODEV,
    238  1.1  chuck 	/* 17 */	NODEV,
    239  1.1  chuck 	/* 18 */	NODEV,
    240  1.1  chuck 	/* 19 */	6,
    241  1.1  chuck 	/* 20 */	NODEV,
    242  1.1  chuck 	/* 21 */	NODEV,
    243  1.1  chuck 	/* 22 */	NODEV,
    244  1.1  chuck };
    245  1.1  chuck 
    246  1.1  chuck /*
    247  1.1  chuck  * Convert a character device number to a block device number.
    248  1.1  chuck  */
    249  1.1  chuck chrtoblk(dev)
    250  1.1  chuck 	dev_t dev;
    251  1.1  chuck {
    252  1.1  chuck 	int blkmaj;
    253  1.1  chuck 
    254  1.1  chuck 	if (major(dev) >= nchrdev)
    255  1.1  chuck 		return (NODEV);
    256  1.1  chuck 	blkmaj = chrtoblktbl[major(dev)];
    257  1.1  chuck 	if (blkmaj == NODEV)
    258  1.1  chuck 		return (NODEV);
    259  1.1  chuck 	return (makedev(blkmaj, minor(dev)));
    260  1.1  chuck }
    261  1.1  chuck 
    262  1.1  chuck /*
    263  1.1  chuck  * This entire table could be autoconfig()ed but that would mean that
    264  1.1  chuck  * the kernel's idea of the console would be out of sync with that of
    265  1.1  chuck  * the standalone boot.  I think it best that they both use the same
    266  1.1  chuck  * known algorithm unless we see a pressing need otherwise.
    267  1.1  chuck  */
    268  1.1  chuck #include <dev/cons.h>
    269  1.1  chuck 
    270  1.1  chuck #define zscnpollc      nullcnpollc
    271  1.1  chuck cons_decl(zs);
    272  1.1  chuck 
    273  1.1  chuck struct	consdev constab[] = {
    274  1.1  chuck #if NZS > 0
    275  1.1  chuck 	cons_init(zs),
    276  1.1  chuck #endif
    277  1.1  chuck 	{ 0 },
    278  1.1  chuck };
    279