Update for conf.h.

This commit is contained in:
mycroft 1995-04-10 07:43:49 +00:00
parent c126c9401f
commit 14241df959

View File

@ -1,4 +1,4 @@
/* $NetBSD: conf.c,v 1.19 1995/02/08 17:45:09 phil Exp $ */
/* $NetBSD: conf.c,v 1.20 1995/04/10 07:43:49 mycroft Exp $ */
/*-
* Copyright (c) 1991 The Regents of the University of California.
@ -48,208 +48,37 @@ int rawwrite __P((dev_t, struct uio *, int));
void swstrategy __P((struct buf *));
int ttselect __P((dev_t, int, struct proc *));
#define dev_type_open(n) int n __P((dev_t, int, int, struct proc *))
#define dev_type_close(n) int n __P((dev_t, int, int, struct proc *))
#define dev_type_strategy(n) void n __P((struct buf *))
#define dev_type_ioctl(n) \
int n __P((dev_t, int, caddr_t, int, struct proc *))
/* bdevsw-specific types */
#define dev_type_dump(n) int n()
#define dev_type_size(n) int n __P((dev_t))
#define dev_decl(n,t) __CONCAT(dev_type_,t)(__CONCAT(n,t))
#define dev_init(c,n,t) \
(c > 0 ? __CONCAT(n,t) : (__CONCAT(dev_type_,t)((*))) enxio)
/* bdevsw-specific initializations */
#define dev_size_init(c,n) (c > 0 ? __CONCAT(n,size) : 0)
#define bdev_decl(n) \
dev_decl(n,open); dev_decl(n,close); dev_decl(n,strategy); \
dev_decl(n,ioctl); dev_decl(n,dump); dev_decl(n,size)
#define bdev_disk_init(c,n) { \
dev_init(c,n,open), dev_init(c,n,close), \
dev_init(c,n,strategy), dev_init(c,n,ioctl), \
dev_init(c,n,dump), dev_size_init(c,n), 0 }
#define bdev_tape_init(c,n) { \
dev_init(c,n,open), dev_init(c,n,close), \
dev_init(c,n,strategy), dev_init(c,n,ioctl), \
(dev_type_dump((*))) enodev, 0, B_TAPE }
#define bdev_swap_init() { \
(dev_type_open((*))) enodev, (dev_type_close((*))) enodev, \
swstrategy, (dev_type_ioctl((*))) enodev, \
(dev_type_dump((*))) enodev, 0, 0 }
#define bdev_notdef() bdev_tape_init(0,no)
bdev_decl(no); /* dummy declarations */
#include "sd.h"
#include "st.h"
#include "cd.h"
#include "vnd.h"
bdev_decl(st);
bdev_decl(sd);
bdev_decl(cd);
bdev_decl(vnd);
#define bdev_rd_init(c,n) { \
dev_init(c,n,open), (dev_type_close((*))) nullop, \
dev_init(c,n,strategy), (dev_type_ioctl((*))) enodev, \
(dev_type_dump((*))) enodev, 0, 0 }
bdev_decl(rd);
(dev_type_dump((*))) enodev, 0 }
#include "sd.h"
bdev_decl(sd);
#include "st.h"
bdev_decl(st);
#ifdef RAMD_SIZE
#define NRD 1
#else
#define NRD 0
#endif
bdev_decl(rd);
#include "cd.h"
bdev_decl(cd);
#include "vnd.h"
bdev_decl(vnd);
struct bdevsw bdevsw[] =
{
bdev_disk_init(NSD,sd), /* 0: scsi disk */
bdev_disk_init(NSD,sd), /* 0: SCSI disk */
bdev_swap_init(), /* 1: swap pseudo-device */
bdev_tape_init(NST,st), /* 2: scsi tape */
bdev_tape_init(NST,st), /* 2: SCSI tape */
bdev_rd_init(NRD,rd), /* 3: ram disk */
bdev_disk_init(NCD,cd), /* 4: scsi cdrom */
bdev_disk_init(NCD,cd), /* 4: SCSI CD-ROM */
bdev_disk_init(NVND,vnd), /* 5: vnode disk driver */
};
int nblkdev = sizeof(bdevsw) / sizeof(bdevsw[0]);
int nblkdev = sizeof (bdevsw) / sizeof (bdevsw[0]);
/* cdevsw-specific types */
#define dev_type_read(n) int n __P((dev_t, struct uio *, int))
#define dev_type_write(n) int n __P((dev_t, struct uio *, int))
#define dev_type_stop(n) int n __P((struct tty *, int))
#define dev_type_reset(n) int n __P((int))
#define dev_type_select(n) int n __P((dev_t, int, struct proc *))
#define dev_type_map(n) int n __P(())
#define cdev_decl(n) \
dev_decl(n,open); dev_decl(n,close); dev_decl(n,read); \
dev_decl(n,write); dev_decl(n,ioctl); dev_decl(n,stop); \
dev_decl(n,reset); dev_decl(n,select); dev_decl(n,map); \
dev_decl(n,strategy); extern struct tty *__CONCAT(n,_tty)[]
#define dev_tty_init(c,n) (c > 0 ? __CONCAT(n,_tty) : 0)
/* open, read, write, ioctl, strategy */
#define cdev_disk_init(c,n) { \
dev_init(c,n,open), dev_init(c,n,close), rawread, rawwrite, \
dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
(dev_type_reset((*))) nullop, 0, seltrue, (dev_type_map((*))) enodev, \
dev_init(c,n,strategy) }
/* open, close, read, write, ioctl, strategy */
#define cdev_tape_init(c,n) { \
dev_init(c,n,open), dev_init(c,n,close), rawread, rawwrite, \
dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
(dev_type_reset((*))) nullop, 0, seltrue, (dev_type_map((*))) enodev, \
dev_init(c,n,strategy) }
/* open, close, read, write, ioctl, stop, tty */
#define cdev_tty_init(c,n) { \
dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
dev_init(c,n,write), dev_init(c,n,ioctl), dev_init(c,n,stop), \
(dev_type_reset((*))) nullop, dev_tty_init(c,n), ttselect, \
(dev_type_map((*))) enodev, 0 }
#define cdev_notdef() { \
(dev_type_open((*))) enodev, (dev_type_close((*))) enodev, \
(dev_type_read((*))) enodev, (dev_type_write((*))) enodev, \
(dev_type_ioctl((*))) enodev, (dev_type_stop((*))) enodev, \
(dev_type_reset((*))) nullop, 0, seltrue, \
(dev_type_map((*))) enodev, 0 }
cdev_decl(no); /* dummy declarations */
cdev_decl(cn);
/* open, close, read, write, ioctl, select -- XXX should be a tty */
#define cdev_cn_init(c,n) { \
dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) nullop, \
(dev_type_reset((*))) nullop, 0, dev_init(c,n,select), \
(dev_type_map((*))) enodev, 0 }
cdev_decl(ctty);
/* open, read, write, ioctl, select -- XXX should be a tty */
#define cdev_ctty_init(c,n) { \
dev_init(c,n,open), (dev_type_close((*))) nullop, dev_init(c,n,read), \
dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) nullop, \
(dev_type_reset((*))) nullop, 0, dev_init(c,n,select), \
(dev_type_map((*))) enodev, 0 }
dev_type_read(mmrw);
/* read/write */
#define cdev_mm_init(c,n) { \
(dev_type_open((*))) nullop, (dev_type_close((*))) nullop, mmrw, \
mmrw, (dev_type_ioctl((*))) enodev, (dev_type_stop((*))) nullop, \
(dev_type_reset((*))) nullop, 0, seltrue, (dev_type_map((*))) enodev, 0 }
/* read, write, strategy */
#define cdev_swap_init(c,n) { \
(dev_type_open((*))) nullop, (dev_type_close((*))) nullop, rawread, \
rawwrite, (dev_type_ioctl((*))) enodev, (dev_type_stop((*))) enodev, \
(dev_type_reset((*))) nullop, 0, (dev_type_select((*))) enodev, \
(dev_type_map((*))) enodev, dev_init(c,n,strategy) }
#include "pty.h"
#define pts_tty pt_tty
#define ptsioctl ptyioctl
cdev_decl(pts);
#define ptc_tty pt_tty
#define ptcioctl ptyioctl
cdev_decl(ptc);
/* open, close, read, write, ioctl, tty, select */
#define cdev_ptc_init(c,n) { \
dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) nullop, \
(dev_type_reset((*))) nullop, dev_tty_init(c,n), dev_init(c,n,select), \
(dev_type_map((*))) enodev, 0 }
cdev_decl(log);
/* open, close, read, ioctl, select -- XXX should be a generic device */
#define cdev_log_init(c,n) { \
dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
(dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
(dev_type_stop((*))) enodev, (dev_type_reset((*))) nullop, 0, \
dev_init(c,n,select), (dev_type_map((*))) enodev, 0 }
cdev_decl(sd);
cdev_decl(st);
cdev_decl(cd);
cdev_decl(vnd);
#include "scn.h" /* Serial driver. */
cdev_decl(scn);
dev_type_open(fdopen);
/* open */
#define cdev_fd_init(c,n) { \
dev_init(c,n,open), (dev_type_close((*))) enodev, \
(dev_type_read((*))) enodev, (dev_type_write((*))) enodev, \
(dev_type_ioctl((*))) enodev, (dev_type_stop((*))) enodev, \
(dev_type_reset((*))) enodev, 0, (dev_type_select((*))) enodev, \
(dev_type_map((*))) enodev, 0 }
#include "bpfilter.h"
cdev_decl(bpf);
/* open, close, read, write, ioctl, select -- XXX should be generic device */
#define cdev_bpf_init(c,n) { \
dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
(dev_type_reset((*))) enodev, 0, dev_init(c,n,select), \
(dev_type_map((*))) enodev, 0 }
#include "lpt.h"
cdev_decl(lpt);
/* open, close, write, ioctl */
#define cdev_lpt_init(c,n) { \
dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
@ -257,39 +86,55 @@ cdev_decl(lpt);
(dev_type_reset((*))) nullop, 0, seltrue, \
(dev_type_map((*))) enodev, 0 }
cdev_decl(cn);
cdev_decl(ctty);
#define mmread mmrw
#define mmwrite mmrw
cdev_decl(mm);
cdev_decl(sd);
#include "pty.h"
#define pts_tty pt_tty
#define ptsioctl ptyioctl
cdev_decl(pts);
#define ptc_tty pt_tty
#define ptcioctl ptyioctl
cdev_decl(ptc);
cdev_decl(log);
#include "scn.h"
cdev_decl(scn);
cdev_decl(st);
cdev_decl(fd);
cdev_decl(cd);
cdev_decl(vnd);
#include "bpfilter.h"
cdev_decl(bpf);
#include "tun.h"
cdev_decl(tun);
/* open, close, read, write, ioctl, select -- XXX should be generic device */
#define cdev_tun_init(c,n) { \
dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
(dev_type_reset((*))) nullop, 0, dev_init(c,n,select), \
(dev_type_map((*))) enodev, 0 }
#include "lpt.h"
cdev_decl(lpt);
struct cdevsw cdevsw[] =
{
cdev_cn_init(1,cn), /* 0: virtual console */
cdev_ctty_init(1,ctty), /* 1: controlling terminal */
cdev_mm_init(1,mm), /* 2: /dev/{null,mem,kmem,...} */
cdev_disk_init(NSD,sd), /* 3: scsi disk */
cdev_disk_init(NSD,sd), /* 3: SCSI disk */
cdev_swap_init(1,sw), /* 4: /dev/drum (swap device) */
cdev_tty_init(NPTY,pts), /* 5: pseudo-tty slave */
cdev_ptc_init(NPTY,ptc), /* 6: pseudo-tty master */
cdev_log_init(1,log), /* 7: /dev/klog */
cdev_tty_init(NSCN,scn), /* 8: serial ports */
cdev_notdef(), /* 9: */
cdev_tape_init(NST,st), /* 10: scsi tape */
cdev_fd_init(1,fd), /* 11: file descriptor pseudo-dev */
cdev_disk_init(NCD,cd), /* 12: concatenated disk */
cdev_disk_init(NVND,vnd), /* 13: vnode disk */
cdev_bpf_init(NBPFILTER,bpf), /* 14: berkeley packet filter */
cdev_tun_init(NTUN,tun), /* 15: network tunnel */
cdev_tape_init(NST,st), /* 10: SCSI tape */
cdev_fd_init(1,fd), /* 11: file descriptor pseudo-device */
cdev_disk_init(NCD,cd), /* 12: SCSI CD-ROM */
cdev_disk_init(NVND,vnd), /* 13: vnode disk driver */
cdev_bpftun_init(NBPFILTER,bpf),/* 14: Berkeley packet filter */
cdev_bpftun_init(NTUN,tun), /* 15: network tunnel */
cdev_notdef(), /* 16: */
cdev_lpt_init(NLPT, lpt), /* 17: Centronix */
};
int nchrdev = sizeof (cdevsw) / sizeof (cdevsw[0]);
int nchrdev = sizeof(cdevsw) / sizeof(cdevsw[0]);
int mem_no = 2; /* major device number of memory special file */
@ -324,31 +169,6 @@ iszerodev(dev)
return (major(dev) == mem_no && minor(dev) == 12);
}
/*
* Returns true if dev is a disk device.
*/
isdisk(dev, type)
dev_t dev;
int type;
{
/* XXXX This needs to be dynamic for LKMs. */
switch (major(dev)) {
case 2:
case 4:
case 5:
case 6:
return (type == VBLK);
case 8:
case 9:
case 17:
case 19:
return (type == VCHR);
default:
return (0);
}
}
static int chrtoblktbl[] = {
/* XXXX This needs to be dynamic for LKMs. */
/*VCHR*/ /*VBLK*/
@ -356,7 +176,7 @@ static int chrtoblktbl[] = {
/* 1 */ NODEV,
/* 2 */ NODEV,
/* 3 */ 0,
/* 4 */ 1,
/* 4 */ NODEV,
/* 5 */ NODEV,
/* 6 */ NODEV,
/* 7 */ NODEV,
@ -396,27 +216,6 @@ chrtoblk(dev)
*/
#include <dev/cons.h>
/* console-specific types */
#if 0 /* XXX */
#define dev_type_cnprobe(n) void n __P((struct consdev *))
#define dev_type_cninit(n) void n __P((struct consdev *))
#define dev_type_cngetc(n) int n __P((dev_t))
#define dev_type_cnputc(n) void n __P((dev_t, int))
#else
#define dev_type_cnprobe(n) int n()
#define dev_type_cninit(n) int n()
#define dev_type_cngetc(n) int n()
#define dev_type_cnputc(n) int n()
#endif
#define cons_decl(n) \
dev_decl(n,cnprobe); dev_decl(n,cninit); dev_decl(n,cngetc); \
dev_decl(n,cnputc)
#define cons_init(n) { \
dev_init(1,n,cnprobe), dev_init(1,n,cninit), dev_init(1,n,cngetc), \
dev_init(1,n,cnputc) }
cons_decl(scn);
struct consdev constab[] = {