parent
dc474fc5fe
commit
1c6336eec1
|
@ -1,14 +1,6 @@
|
|||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* Copyright (c) 1991 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* (c) UNIX System Laboratories, Inc.
|
||||
* All or some portions of this file are derived from material licensed
|
||||
* to the University of California by American Telephone and Telegraph
|
||||
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
|
||||
* the permission of UNIX System Laboratories, Inc.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* William Jolitz.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -38,195 +30,251 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)conf.c 5.8 (Berkeley) 5/12/91
|
||||
*
|
||||
* $Id: conf.c,v 1.8 1994/05/25 00:03:06 phil Exp $
|
||||
* from: @(#)conf.c 7.9 (Berkeley) 5/28/91
|
||||
* $Id: conf.c,v 1.9 1994/05/31 21:54:31 phil Exp $
|
||||
*/
|
||||
|
||||
#include "param.h"
|
||||
#include "systm.h"
|
||||
#include "buf.h"
|
||||
#include "ioctl.h"
|
||||
#include "tty.h"
|
||||
#include "conf.h"
|
||||
#include "scn.h"
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/buf.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/tty.h>
|
||||
#include <sys/conf.h>
|
||||
#include <sys/vnode.h>
|
||||
|
||||
int rawread(), rawwrite();
|
||||
int rawread __P((dev_t, struct uio *, int));
|
||||
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 *))
|
||||
|
||||
/* Block devices */
|
||||
/* 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_type_close((*))) nullop, \
|
||||
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"
|
||||
#if NSD > 0
|
||||
int sdopen(), sdclose(), sdioctl();
|
||||
int /*sddump(),*/ sdsize();
|
||||
int sdstrategy();
|
||||
#define sddump enxio
|
||||
#else
|
||||
#define sdopen enxio
|
||||
#define sdclose enxio
|
||||
#define sdstrategy voidop
|
||||
#define sdioctl enxio
|
||||
#define sddump enxio
|
||||
#define sdsize NULL
|
||||
#endif
|
||||
|
||||
#include "st.h"
|
||||
#if NST > 0
|
||||
int stopen(), stclose(), stioctl();
|
||||
/*int stdump(), stsize();*/
|
||||
int ststrategy();
|
||||
#define stdump enxio
|
||||
#define stsize NULL
|
||||
#else
|
||||
#define stopen enxio
|
||||
#define stclose enxio
|
||||
#define ststrategy voidop
|
||||
#define stioctl enxio
|
||||
#define stdump enxio
|
||||
#define stsize NULL
|
||||
#endif
|
||||
|
||||
#include "cd.h"
|
||||
#if NCD > 0
|
||||
int cdopen(), cdclose(), cdioctl();
|
||||
int /*cddump(), */cdsize();
|
||||
int cdstrategy();
|
||||
#define cddump enxio
|
||||
#else
|
||||
#define cdopen enxio
|
||||
#define cdclose enxio
|
||||
#define cdstrategy voidop
|
||||
#define cdioctl enxio
|
||||
#define cddump enxio
|
||||
#define cdsize NULL
|
||||
#endif
|
||||
#include "vn.h"
|
||||
|
||||
#if 0
|
||||
#include "ch.h"
|
||||
#if NCH > 0
|
||||
int chopen(), chclose(), chioctl();
|
||||
#else
|
||||
#define chopen enxio
|
||||
#define chclose enxio
|
||||
#define chioctl enxio
|
||||
#endif
|
||||
#endif
|
||||
bdev_decl(st);
|
||||
bdev_decl(sd);
|
||||
bdev_decl(cd);
|
||||
bdev_decl(vn);
|
||||
|
||||
|
||||
#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);
|
||||
|
||||
#ifdef RAMD_SIZE
|
||||
int rdopen(), rdclose(), rdsize();
|
||||
int rdstrategy();
|
||||
#define NRD 1
|
||||
#else
|
||||
#define NRD 0
|
||||
#endif
|
||||
|
||||
int swread(), swwrite();
|
||||
int swstrategy();
|
||||
|
||||
struct bdevsw bdevsw[] =
|
||||
{
|
||||
{ sdopen, sdclose, sdstrategy, sdioctl, /*0*/
|
||||
sddump, sdsize, NULL }, /* sdX */
|
||||
{ enodev, enodev, swstrategy, enodev, /*1*/
|
||||
enodev, enodev, NULL }, /* swap */
|
||||
{ stopen, stclose, ststrategy, stioctl, /*2*/
|
||||
stdump, stsize, NULL }, /* stX */
|
||||
#ifdef RAMD_SIZE
|
||||
{ rdopen, rdclose, rdstrategy, enodev, /*3*/
|
||||
enodev, rdsize, NULL }, /* rd */
|
||||
#endif
|
||||
bdev_disk_init(NSD,sd), /* 0: scsi disk */
|
||||
bdev_swap_init(), /* 1: swap pseudo-device */
|
||||
bdev_tape_init(NST,st), /* 2: scsi tape */
|
||||
bdev_disk_init(NRD,rd), /* 3: ram disk */
|
||||
bdev_disk_init(NCD,cd), /* 4: concatenated disk driver */
|
||||
bdev_disk_init(NVN,vn), /* 5: vnode disk driver (swap to files) */
|
||||
};
|
||||
|
||||
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(())
|
||||
|
||||
/* Character devices */
|
||||
#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)[]
|
||||
|
||||
int cnopen(), cnclose(), cnread(), cnwrite(), cnioctl(), cnselect();
|
||||
#define dev_tty_init(c,n) (c > 0 ? __CONCAT(n,_tty) : 0)
|
||||
|
||||
int cttyopen(), cttyread(), cttywrite(), cttyioctl(), cttyselect();
|
||||
/* open, read, write, ioctl, strategy */
|
||||
#define cdev_disk_init(c,n) { \
|
||||
dev_init(c,n,open), (dev_type_close((*))) nullop, 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) }
|
||||
|
||||
int mmrw(), mmmmap();
|
||||
#define mmselect seltrue
|
||||
/* 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"
|
||||
#if NPTY > 0
|
||||
int ptsopen(),ptsclose(),ptsread(),ptswrite(),ptsstop();
|
||||
int ptcopen(),ptcclose(),ptcread(),ptcwrite(),ptcselect();
|
||||
int ptyioctl();
|
||||
struct tty *pt_tty[];
|
||||
#else
|
||||
#define ptsopen enxio
|
||||
#define ptsclose enxio
|
||||
#define ptsread enxio
|
||||
#define ptswrite enxio
|
||||
#define ptcopen enxio
|
||||
#define ptcclose enxio
|
||||
#define ptcread enxio
|
||||
#define ptcwrite enxio
|
||||
#define ptyioctl enxio
|
||||
#define pt_tty NULL
|
||||
#define ptcselect enxio
|
||||
#define ptsstop nullop
|
||||
#endif
|
||||
#define pts_tty pt_tty
|
||||
#define ptsioctl ptyioctl
|
||||
cdev_decl(pts);
|
||||
#define ptc_tty pt_tty
|
||||
#define ptcioctl ptyioctl
|
||||
cdev_decl(ptc);
|
||||
|
||||
#include "scn.h"
|
||||
#if NSCN > 0
|
||||
int scnopen(), scnclose(), scnread(), scnwrite(), scnioctl();
|
||||
#define scnreset enxio
|
||||
extern struct tty *scn_tty[];
|
||||
#else
|
||||
#define scnopen enxio
|
||||
#define scnclose enxio
|
||||
#define scnread enxio
|
||||
#define scnwrite enxio
|
||||
#define scnioctl enxio
|
||||
#define scnreset enxio
|
||||
#define scn_tty NULL
|
||||
#endif
|
||||
/* 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 }
|
||||
|
||||
int logopen(),logclose(),logread(),logioctl(),logselect();
|
||||
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 }
|
||||
|
||||
int ttselect(), seltrue();
|
||||
cdev_decl(sd);
|
||||
cdev_decl(st);
|
||||
cdev_decl(cd);
|
||||
cdev_decl(vn);
|
||||
|
||||
int fdopen();
|
||||
#include "scn.h" /* Serial driver. */
|
||||
cdev_decl(scn);
|
||||
|
||||
/* open, read, write, ioctl -- XXX should be a disk */
|
||||
#define cdev_vn_init(c,n) { \
|
||||
dev_init(c,n,open), (dev_type_close((*))) nullop, rawread, rawwrite, \
|
||||
dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
|
||||
(dev_type_reset((*))) nullop, 0, seltrue, (dev_type_map((*))) enodev, \
|
||||
0 }
|
||||
|
||||
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 }
|
||||
|
||||
struct cdevsw cdevsw[] =
|
||||
{
|
||||
{ cnopen, cnclose, cnread, cnwrite, /*0*/
|
||||
cnioctl, nullop, nullop, NULL, /* console */
|
||||
cnselect, enodev, NULL },
|
||||
{ cttyopen, nullop, cttyread, cttywrite, /*1*/
|
||||
cttyioctl, nullop, nullop, NULL, /* tty */
|
||||
cttyselect, enodev, NULL },
|
||||
{ nullop, nullop, mmrw, mmrw, /*2*/
|
||||
enodev, nullop, nullop, NULL, /* memory */
|
||||
mmselect, enodev, NULL },
|
||||
{ sdopen, sdclose, rawread, rawwrite, /*3*/
|
||||
sdioctl, enodev, nullop, NULL, /* rsdX */
|
||||
seltrue, enodev, sdstrategy },
|
||||
{ nullop, nullop, rawread, rawwrite, /*4*/
|
||||
enodev, enodev, nullop, NULL, /* swap */
|
||||
enodev, enodev, swstrategy },
|
||||
{ ptsopen, ptsclose, ptsread, ptswrite, /*5*/
|
||||
ptyioctl, ptsstop, nullop, pt_tty, /* ttyp */
|
||||
ttselect, enodev, NULL },
|
||||
{ ptcopen, ptcclose, ptcread, ptcwrite, /*6*/
|
||||
ptyioctl, nullop, nullop, pt_tty, /* ptyp */
|
||||
ptcselect, enodev, NULL },
|
||||
{ logopen, logclose, logread, enodev, /*7*/
|
||||
logioctl, enodev, nullop, NULL, /* klog */
|
||||
logselect, enodev, NULL },
|
||||
{ scnopen, scnclose, scnread, scnwrite, /*8*/
|
||||
scnioctl, enodev, scnreset, scn_tty, /* ttyXX */
|
||||
ttselect, enodev, NULL },
|
||||
{ enxio, enxio, enxio, enxio, /*9*/
|
||||
enxio, enxio, enxio, NULL, /* nothing */
|
||||
enxio, enxio, enxio },
|
||||
{ stopen, stclose, rawread, rawwrite, /*10*/
|
||||
stioctl, enodev, nullop, NULL, /* rstXX */
|
||||
seltrue, enodev, ststrategy },
|
||||
{ fdopen, enxio, enxio, enxio, /*11*/
|
||||
enxio, enxio, enxio, NULL, /* fd */
|
||||
enxio, enxio, enxio },
|
||||
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_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_vn_init(NVN,vn), /* 13: vnode disk */
|
||||
cdev_bpf_init(NBPFILTER,bpf), /* 14: berkeley packet filter */
|
||||
cdev_notdef(), /* 15 */
|
||||
cdev_notdef(), /* 16 */
|
||||
};
|
||||
|
||||
int nchrdev = sizeof (cdevsw) / sizeof (cdevsw[0]);
|
||||
|
||||
int mem_no = 2; /* major device number of memory special file */
|
||||
|
@ -240,28 +288,17 @@ int mem_no = 2; /* major device number of memory special file */
|
|||
* confuse, e.g. the hashing routines. Instead, /dev/drum is
|
||||
* provided as a character (raw) device.
|
||||
*/
|
||||
dev_t swapdev = makedev(1, 0);
|
||||
|
||||
dev_t swapdev = makedev(3, 0);
|
||||
|
||||
/*
|
||||
* constab is the console configuration for this type of machine.
|
||||
* XXX - it should probably all be configured automatically.
|
||||
* Returns true if dev is /dev/mem or /dev/kmem.
|
||||
*/
|
||||
#include <dev/cons.h>
|
||||
|
||||
/* XXX - all this could be autoconfig()ed */
|
||||
#if NSCN > 0
|
||||
int scncnprobe(), scncninit(), scncngetc(), scncnputc();
|
||||
#endif
|
||||
|
||||
struct consdev constab[] = {
|
||||
#if NSCN > 0
|
||||
{ scncnprobe, scncninit, scncngetc, scncnputc },
|
||||
#endif
|
||||
{ 0 },
|
||||
};
|
||||
/* end XXX */
|
||||
iskmemdev(dev)
|
||||
dev_t dev;
|
||||
{
|
||||
|
||||
return (major(dev) == mem_no && minor(dev) < 2);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns true if dev is /dev/zero.
|
||||
|
@ -272,3 +309,104 @@ 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*/
|
||||
/* 0 */ NODEV,
|
||||
/* 1 */ NODEV,
|
||||
/* 2 */ NODEV,
|
||||
/* 3 */ 0,
|
||||
/* 4 */ 1,
|
||||
/* 5 */ NODEV,
|
||||
/* 6 */ NODEV,
|
||||
/* 7 */ NODEV,
|
||||
/* 8 */ NODEV,
|
||||
/* 9 */ NODEV,
|
||||
/* 10 */ 2,
|
||||
/* 11 */ NODEV,
|
||||
/* 12 */ 4,
|
||||
/* 13 */ 5,
|
||||
/* 14 */ NODEV,
|
||||
/* 15 */ NODEV,
|
||||
/* 16 */ NODEV
|
||||
};
|
||||
|
||||
/*
|
||||
* Convert a character device number to a block device number.
|
||||
*/
|
||||
chrtoblk(dev)
|
||||
dev_t dev;
|
||||
{
|
||||
int blkmaj;
|
||||
|
||||
if (major(dev) >= nchrdev)
|
||||
return (NODEV);
|
||||
blkmaj = chrtoblktbl[major(dev)];
|
||||
if (blkmaj == NODEV)
|
||||
return (NODEV);
|
||||
return (makedev(blkmaj, minor(dev)));
|
||||
}
|
||||
|
||||
/*
|
||||
* This entire table could be autoconfig()ed but that would mean that
|
||||
* the kernel's idea of the console would be out of sync with that of
|
||||
* the standalone boot. I think it best that they both use the same
|
||||
* known algorithm unless we see a pressing need otherwise.
|
||||
*/
|
||||
#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[] = {
|
||||
#if NSCN > 0
|
||||
cons_init(scn),
|
||||
#endif
|
||||
{ 0 },
|
||||
};
|
||||
|
|
|
@ -176,16 +176,20 @@ here_we_go: /* This is the actual start of the locore code! */
|
|||
lprd sp, KERN_INT_SP # use the idle/interrupt stack.
|
||||
lprd fp, KERN_INT_SP # use the idle/interrupt stack.
|
||||
|
||||
/* We are assuming the cfg register is bF7 (IC,DC,DE,M,F,I) */
|
||||
/* Load cfg register is bF7 (IC,DC,DE,M,F,I) or bF5 */
|
||||
sprd cfg, r0
|
||||
tbitb 1, r0 /* Test the F bit! */
|
||||
bfc cfg_no_fpu
|
||||
movqd 1, __have_fpu(pc)
|
||||
|
||||
lprd cfg, 0xbf7
|
||||
br jmphi
|
||||
|
||||
cfg_no_fpu:
|
||||
lprd cfg, 0xbf5
|
||||
|
||||
/* Now jump to high addresses after starting mapping! */
|
||||
|
||||
jmphi:
|
||||
addr here(pc), r0
|
||||
ord KERNBASE, r0
|
||||
jump 0(r0)
|
||||
|
@ -204,22 +208,25 @@ here:
|
|||
lprd usp, USRSTACK /* starting stack for the user. */
|
||||
|
||||
/* Build the "trap" frame to return to address 0 in user space! */
|
||||
movw PSR_I|PSR_S|PSR_U, tos /* psr -- user/user stack/interrupts */
|
||||
movw 0, tos /* mod -- 0! */
|
||||
movd 16, tos /* pc -- 16 after module table */
|
||||
enter [],4 /* Extra space is for USP */
|
||||
movqd 0,tos /* Put fake registers in the pcb. */
|
||||
movqd 1,tos
|
||||
movqd 2,tos
|
||||
movqd 3,tos
|
||||
movqd 4,tos
|
||||
movqd 5,tos
|
||||
movqd 6,tos
|
||||
movqd 7,tos
|
||||
movw PSR_I|PSR_S|PSR_U, tos /* psr - user/user stack/interrupts */
|
||||
movw 0, tos /* mod - 0! */
|
||||
movd 0, tos /* pc - 0 after module table */
|
||||
enter [],8 /* Extra space is for USP */
|
||||
movqd 0, tos /* Zero the registers in the pcb. */
|
||||
movqd 0, tos
|
||||
movqd 0, tos
|
||||
movqd 0, tos
|
||||
movqd 0, tos
|
||||
movqd 0, tos
|
||||
movqd 0, tos
|
||||
movqd 0, tos
|
||||
movqd 0, REGS_SB(sp)
|
||||
|
||||
/* Now things should be ready to start _main! */
|
||||
|
||||
addr 0(sp), tos
|
||||
bsr _main /* Start the kernel! */
|
||||
movd tos, r0 /* Pop addr */
|
||||
|
||||
/* We should only get here in proc 1. */
|
||||
movd _curproc(pc), r1
|
||||
|
@ -228,9 +235,9 @@ here:
|
|||
movd P_PID(r1),r0
|
||||
cmpqd 1, r0
|
||||
bne main_panic
|
||||
lprd usp, USRSTACK
|
||||
lprd usp, REGS_USP(sp)
|
||||
lprd sb, REGS_SB(sp)
|
||||
|
||||
/* Start the user code! */
|
||||
exit [r0,r1,r2,r3,r4,r5,r6,r7]
|
||||
rett 0
|
||||
|
||||
|
@ -307,8 +314,7 @@ ENTRY(low_level_reboot)
|
|||
xxxlow:
|
||||
lmr mcr, 0 /* Turn off mapping. */
|
||||
lprd sp, __save_sp(pc) /* get monitor's sp. */
|
||||
movd 0x10000000, tos /* The ROM Address */
|
||||
ret 0 /* Jump to the ROM! */
|
||||
jump 0x10000000 /* Jump to the ROM! */
|
||||
|
||||
|
||||
/* To get back to the rom monitor .... */
|
||||
|
|
|
@ -672,7 +672,6 @@ boot(arghowto)
|
|||
for(;;);
|
||||
}
|
||||
howto = arghowto;
|
||||
printf ("boot: howto=0x%x\n", howto);
|
||||
if ((howto&RB_NOSYNC) == 0 && waittime < 0) {
|
||||
register struct buf *bp;
|
||||
int iter, nbusy;
|
||||
|
@ -729,16 +728,15 @@ printf ("boot: howto=0x%x\n", howto);
|
|||
|
||||
if (howto & RB_DUMP) {
|
||||
#if 1
|
||||
/* dump the stack! */
|
||||
{ int *fp = (int *)_get_fp();
|
||||
int i=0;
|
||||
while ((u_int)fp < (u_int)UPT_MIN_ADDRESS-40) {
|
||||
printf ("0x%x (@0x%x), ", fp[1], fp);
|
||||
fp = (int *)fp[0];
|
||||
if (++i == 3) { printf ("\n"); i=0; }
|
||||
}
|
||||
for(;;) ; /* Stop here! */
|
||||
}
|
||||
/* dump the stack! */
|
||||
{ int *fp = (int *)_get_fp();
|
||||
int i=0;
|
||||
while ((u_int)fp < (u_int)UPT_MIN_ADDRESS-40) {
|
||||
printf ("0x%x (@0x%x), ", fp[1], fp);
|
||||
fp = (int *)fp[0];
|
||||
if (++i == 3) { printf ("\n"); i=0; }
|
||||
}
|
||||
}
|
||||
#else
|
||||
savectx(&dumppcb, 0);
|
||||
dumppcb.pcb_ptd = _get_ptb0();
|
||||
|
|
|
@ -163,8 +163,8 @@ mmrw(dev, uio, flags)
|
|||
TRUE);
|
||||
o = (int)uio->uio_offset & PGOFSET;
|
||||
c = (u_int)(NBPG - ((int)iov->iov_base & PGOFSET));
|
||||
c = MIN(c, (u_int)(NBPG - o));
|
||||
c = MIN(c, (u_int)iov->iov_len);
|
||||
c = min(c, (u_int)(NBPG - o));
|
||||
c = min(c, (u_int)iov->iov_len);
|
||||
error = uiomove((caddr_t)&vmmap[o], (int)c, uio);
|
||||
pmap_remove(kernel_pmap, vmmap, &vmmap[NBPG]);
|
||||
continue;
|
||||
|
@ -220,7 +220,7 @@ mmrw(dev, uio, flags)
|
|||
malloc(CLBYTES, M_TEMP, M_WAITOK);
|
||||
bzero(zbuf, CLBYTES);
|
||||
}
|
||||
c = MIN(iov->iov_len, CLBYTES);
|
||||
c = min(iov->iov_len, CLBYTES);
|
||||
error = uiomove(zbuf, (int)c, uio);
|
||||
continue;
|
||||
|
||||
|
|
Loading…
Reference in New Issue