conf.c
来自「基于组件方式开发操作系统的OSKIT源代码」· C语言 代码 · 共 1,574 行 · 第 1/3 页
C
1,574 行
#if NITY > 0d_open_t ityopen;d_close_t ityclose;d_read_t ityread;d_write_t itywrite;d_ioctl_t ityioctl;d_ttycv_t itydevtotty;#define ityreset nxreset#else#define ityopen nxopen#define ityclose nxclose#define ityread nxread#define itywrite nxwrite#define ityioctl nxioctl#define ityreset nxreset#define itydevtotty nxdevtotty#endif#include "nic.h"#if NNIC > 0d_open_t nicopen;d_close_t nicclose;d_ioctl_t nicioctl;#else#define nicopen nxopen#define nicclose nxclose#define nicioctl nxioctl#endif#include "nnic.h"#if NNNIC > 0d_open_t nnicopen;d_close_t nnicclose;d_ioctl_t nnicioctl;#else#define nnicopen nxopen#define nnicclose nxclose#define nnicioctl nxioctl#endif#include "isdn.h"#if NISDN > 0d_open_t isdnopen;d_close_t isdnclose;d_read_t isdnread;d_ioctl_t isdnioctl;#else#define isdnopen nxopen#define isdnclose nxclose#define isdnread nxread#define isdnioctl nxioctl#endif#include "itel.h"#if NITEL > 0d_open_t itelopen;d_close_t itelclose;d_read_t itelread;d_write_t itelwrite;d_ioctl_t itelioctl;#else#define itelopen nxopen#define itelclose nxclose#define itelread nxread#define itelwrite nxwrite#define itelioctl nxioctl#endif#include "ispy.h"#if NISPY > 0d_open_t ispyopen;d_close_t ispyclose;d_read_t ispyread;d_write_t ispywrite;d_ioctl_t ispyioctl;#else#define ispyopen nxopen#define ispyclose nxclose#define ispyread nxread#define ispywrite nxwrite#define ispyioctl nxioctl#endif#include "rc.h"#if NRC > 0d_open_t rcopen;d_close_t rcclose;d_rdwr_t rcread, rcwrite;d_ioctl_t rcioctl;d_stop_t rcstop;d_ttycv_t rcdevtotty;#define rcreset nxreset#else#define rcopen nxopen#define rcclose nxclose#define rcread nxread#define rcwrite nxwrite#define rcioctl nxioctl#define rcstop nxstop#define rcreset nxreset#define rcdevtotty nxdevtotty#endif#include "labpc.h"#if NLABPC > 0d_open_t labpcopen;d_close_t labpcclose;d_strategy_t labpcstrategy;d_ioctl_t labpcioctl;#else#define labpcopen nxopen#define labpcclose nxclose#define labpcstrategy nxstrategy#define labpcioctl nxioctl#endif/* Stallion Multiport Serial Driver (cd1400 based) */#include "stl.h"#if NSTL > 0d_open_t stlopen;d_close_t stlclose;d_read_t stlread;d_write_t stlwrite;d_ioctl_t stlioctl;d_stop_t stlstop;d_ttycv_t stldevtotty;#define stlreset nxreset#define stlmmap nxmmap#define stlstrategy nxstrategy#else#define stlopen nxopen#define stlclose nxclose#define stlread nxread#define stlwrite nxwrite#define stlioctl nxioctl#define stlstop nxstop#define stlreset nxreset#define stlmmap nxmmap#define stlstrategy nxstrategy#define stldevtotty nxdevtotty#endif/* Stallion Intelligent Multiport Serial Driver */#include "stli.h"#if NSTLI > 0d_open_t stliopen;d_close_t stliclose;d_read_t stliread;d_write_t stliwrite;d_ioctl_t stliioctl;d_stop_t stlistop;d_ttycv_t stlidevtotty;#define stlireset nxreset#define stlimmap nxmmap#define stlistrategy nxstrategy#else#define stliopen nxopen#define stliclose nxclose#define stliread nxread#define stliwrite nxwrite#define stliioctl nxioctl#define stlistop nxstop#define stlireset nxreset#define stlimmap nxmmap#define stlistrategy nxstrategy#define stlidevtotty nxdevtotty#endif/* open, close, read, write, ioctl, stop, reset, ttys, select, mmap, strat */struct cdevsw cdevsw[] ={ { cnopen, cnclose, cnread, cnwrite, /*0*/ cnioctl, nullstop, nullreset, nodevtotty,/* console */ cnselect, nommap, NULL }, { cttyopen, nullclose, cttyread, cttywrite, /*1*/ cttyioctl, nullstop, nullreset, nodevtotty,/* tty */ cttyselect, nommap, NULL }, { mmopen, mmclose, mmrw, mmrw, /*2*/ mmioctl, nullstop, nullreset, nodevtotty,/* memory */ mmselect, memmmap, NULL }, { wdopen, wdclose, rawread, rawwrite, /*3*/ wdioctl, nostop, nullreset, nodevtotty,/* wd */ seltrue, nommap, wdstrategy }, { nullopen, nullclose, rawread, rawwrite, /*4*/ noioc, nostop, noreset, nodevtotty,/* swap */ noselect, nommap, swstrategy }, { ptsopen, ptsclose, ptsread, ptswrite, /*5*/ ptyioctl, ptsstop, nullreset, ptydevtotty,/* ttyp */ ttselect, nommap, NULL }, { ptcopen, ptcclose, ptcread, ptcwrite, /*6*/ ptyioctl, nullstop, nullreset, ptydevtotty,/* ptyp */ ptcselect, nommap, NULL }, { logopen, logclose, logread, nowrite, /*7*/ logioctl, nostop, nullreset, nodevtotty,/* klog */ logselect, nommap, NULL }, { bquopen, bquclose, bquread, bquwrite, /*8*/ bquioctl, nostop, nullreset, nodevtotty,/* tputer */ bquselect, nommap, NULL }, { Fdopen, fdclose, rawread, rawwrite, /*9*/ fdioctl, nostop, nullreset, nodevtotty,/* Fd (!=fd) */ seltrue, nommap, fdstrategy }, { wtopen, wtclose, rawread, rawwrite, /*10*/ wtioctl, nostop, nullreset, nodevtotty,/* wt */ seltrue, nommap, wtstrategy }, { spigot_open, spigot_close, spigot_read, spigot_write, /*11*/ spigot_ioctl, nostop, nullreset, nodevtotty,/* Spigot */ spigot_select, spigot_mmap, NULL }, { scopen, scclose, scread, scwrite, /*12*/ scioctl, nullstop, nullreset, scdevtotty,/* sc */ ttselect, scmmap, NULL }, { sdopen, sdclose, rawread, rawwrite, /*13*/ sdioctl, nostop, nullreset, nodevtotty,/* sd */ seltrue, nommap, sdstrategy }, { stopen, stclose, rawread, rawwrite, /*14*/ stioctl, nostop, nullreset, nodevtotty,/* st */ seltrue, nommap, ststrategy }, { cdopen, cdclose, rawread, nowrite, /*15*/ cdioctl, nostop, nullreset, nodevtotty,/* cd */ seltrue, nommap, cdstrategy }, { lptopen, lptclose, noread, lptwrite, /*16*/ lptioctl, nullstop, nullreset, nodevtotty,/* lpt */ seltrue, nommap, nostrat}, { chopen, chclose, noread, nowrite, /*17*/ chioctl, nostop, nullreset, nodevtotty,/* ch */ noselect, nommap, nostrat }, { suopen, suclose, suread, suwrite, /*18*/ suioctl, nostop, nullreset, nodevtotty,/* scsi */ suselect, summap, sustrategy }, /* 'generic' */ { twopen, twclose, twread, twwrite, /*19*/ noioc, nullstop, nullreset, nodevtotty,/* tw */ twselect, nommap, nostrat },/* * If you need a cdev major number for a driver that you intend to donate * back to the group or release publically, please contact the FreeBSD team * by sending mail to "hackers@freebsd.org". * If you assign one yourself it may conflict with someone else. * Otherwise, simply use the one reserved for local use. */ /* character device 20 is reserved for local use */ { nxopen, nxclose, nxread, nxwrite, /*20*/ nxioctl, nxstop, nxreset, nxdevtotty,/* reserved */ nxselect, nxmmap, NULL }, { psmopen, psmclose, psmread, nowrite, /*21*/ psmioctl, nostop, nullreset, nodevtotty,/* psm mice */ psmselect, nommap, NULL }, { fdopen, noclose, noread, nowrite, /*22*/ noioc, nostop, nullreset, nodevtotty,/* fd (!=Fd) */ noselect, nommap, nostrat }, { bpfopen, bpfclose, bpfread, bpfwrite, /*23*/ bpfioctl, nostop, nullreset, nodevtotty,/* bpf */ bpfselect, nommap, NULL }, { pcaopen, pcaclose, noread, pcawrite, /*24*/ pcaioctl, nostop, nullreset, nodevtotty,/* pcaudio */ pcaselect, nommap, NULL }, { nxopen, nxclose, nxread, nxwrite, /*25*/ nxioctl, nxstop, nxreset, nxdevtotty,/* was vat */ nxselect, nxmmap, NULL }, { spkropen, spkrclose, noread, spkrwrite, /*26*/ spkrioctl, nostop, nullreset, nodevtotty,/* spkr */ seltrue, nommap, NULL }, { mseopen, mseclose, mseread, nowrite, /*27*/ noioc, nostop, nullreset, nodevtotty,/* mse */ mseselect, nommap, NULL }, { sioopen, sioclose, sioread, siowrite, /*28*/ sioioctl, siostop, sioreset, siodevtotty,/* sio */ ttselect, nommap, NULL }, { mcdopen, mcdclose, rawread, nowrite, /*29*/ mcdioctl, nostop, nullreset, nodevtotty,/* mitsumi cd */ seltrue, nommap, mcdstrategy }, { sndopen, sndclose, sndread, sndwrite, /*30*/ sndioctl, nostop, nullreset, nodevtotty,/* sound */ sndselect, nommap, NULL }, { ukopen, ukclose, noread, nowrite, /*31*/ ukioctl, nostop, nullreset, nodevtotty,/* unknown */ seltrue, nommap, NULL }, /* scsi */ { lkmcopen, lkmcclose, noread, nowrite, /*32*/ lkmcioctl, nostop, nullreset, nodevtotty, noselect, nommap, NULL }, { lkmopen, lkmclose, lkmread, lkmwrite, /*33*/ lkmioctl, lkmstop, lkmreset, nodevtotty, lkmselect, lkmmmap, NULL }, { lkmopen, lkmclose, lkmread, lkmwrite, /*34*/ lkmioctl, lkmstop, lkmreset, nodevtotty, lkmselect, lkmmmap, NULL }, { lkmopen, lkmclose, lkmread, lkmwrite, /*35*/ lkmioctl, lkmstop, lkmreset, nodevtotty, lkmselect, lkmmmap, NULL }, { lkmopen, lkmclose, lkmread, lkmwrite, /*36*/ lkmioctl, lkmstop, lkmreset, nodevtotty, lkmselect, lkmmmap, NULL }, { lkmopen, lkmclose, lkmread, lkmwrite, /*37*/ lkmioctl, lkmstop, lkmreset, nodevtotty, lkmselect, lkmmmap, NULL }, { lkmopen, lkmclose, lkmread, lkmwrite, /*38*/ lkmioctl, lkmstop, lkmreset, nodevtotty, lkmselect, lkmmmap, NULL }, { apmopen, apmclose, noread, nowrite, /*39*/ apmioctl, nostop, nullreset, nodevtotty,/* APM */ seltrue, nommap, NULL }, { ctxopen, ctxclose, ctxread, ctxwrite, /*40*/ ctxioctl, nostop, nullreset, nodevtotty,/* cortex */ seltrue, nommap, NULL }, { sockopen, sockclose, noread, nowrite, /*41*/ sockioctl, nostop, nullreset, nodevtotty,/* socksys */ seltrue, nommap, NULL }, { cxopen, cxclose, cxread, cxwrite, /*42*/ cxioctl, cxstop, nullreset, cxdevtotty,/* cronyx */ cxselect, nommap, NULL }, { vnopen, vnclose, rawread, rawwrite, /*43*/ vnioctl, nostop, nullreset, nodevtotty,/* vn */ seltrue, nommap, vnstrategy }, { gpopen, gpclose, noread, gpwrite, /*44*/ gpioctl, nostop, nullreset, nodevtotty,/* GPIB */ seltrue, nommap, NULL }, { scdopen, scdclose, rawread, nowrite, /*45*/ scdioctl, nostop, nullreset, nodevtotty,/* sony cd */ seltrue, nommap, scdstrategy }, { matcdopen, matcdclose, rawread, nowrite, /*46*/ matcdioctl, nostop, nullreset, nodevtotty,/* SB cd */ seltrue, nommap, matcdstrategy }, { gscopen, gscclose, gscread, nowrite, /*47*/ gscioctl, nostop, nullreset, nodevtotty,/* gsc */ seltrue, nommap, NULL }, { cyopen, cyclose, cyread, cywrite, /*48*/ cyioctl, cystop, cyreset, cydevtotty,/*cyclades*/ ttselect, cymmap, cystrategy }, { sscopen, sscclose, sscread, sscwrite, /*49*/ sscioctl, nostop, nullreset, nodevtotty,/* scsi super */ sscselect, sscmmap, sscstrategy }, { crdopen, crdclose, crdread, crdwrite, /*50*/ crdioctl, nostop, nullreset, nodevtotty,/* pcmcia */ crdselect, nommap, NULL }, { joyopen, joyclose, joyread, nowrite, /*51*/ joyioctl, nostop, nullreset, nodevtotty,/*joystick */ seltrue, nommap, NULL}, { tunopen, tunclose, tunread, tunwrite, /*52*/ tunioctl, nostop, nullreset, nodevtotty,/* tunnel */ tunselect, nommap, NULL }, { snpopen, snpclose, snpread, snpwrite, /*53*/ snpioctl, nostop, nullreset, nodevtotty,/* snoop */ snpselect, nommap, NULL }, { nicopen, nicclose, noread, nowrite, /*54*/ nicioctl, nostop, nullreset, nodevtotty,/* nic */ seltrue, nommap, NULL }, { isdnopen, isdnclose, isdnread, nowrite, /*55*/ isdnioctl, nostop, nullreset, nodevtotty,/* isdn */ seltrue, nommap, NULL }, { ityopen, ityclose, ityread, itywrite, /*56*/ ityioctl, nostop, ityreset, itydevtotty,/* ity */ ttselect, nommap, NULL }, { itelopen, itelclose, itelread, itelwrite, /*57*/ itelioctl, nostop, nullreset, nodevtotty,/* itel */ seltrue, nommap, NULL }, { dgbopen, dgbclose, dgbread, dgbwrite, /*58*/ dgbioctl, dgbstop, dgbreset, dgbdevtotty, /* dgb */ ttselect, nommap, NULL }, { ispyopen, ispyclose, ispyread, nowrite, /*59*/ ispyioctl, nostop, nullreset, nodevtotty,/* ispy */ seltrue, nommap, NULL }, { nnicopen, nnicclose, noread, nowrite, /*60*/ nnicioctl, nostop, nullreset, nodevtotty,/* nnic */ seltrue, nommap, NULL }, { ptopen, ptclose, rawread, rawwrite, /*61*/ ptioctl, nostop, nullreset, nodevtotty,/* pt */ seltrue, nommap, ptstrategy }, { wormopen, wormclose, rawread, rawwrite, /*62*/ wormioctl, nostop, nullreset, nodevtotty,/* worm */ seltrue, nommap, wormstrategy }, { rcopen, rcclose, rcread, rcwrite, /*63*/ rcioctl, rcstop, rcreset, rcdevtotty,/* rc */ ttselect, nommap, NULL }, { nxopen, nxclose, nxread, nxwrite, /*64*/ nxioctl, nxstop, nxreset, nxdevtotty,/* Talisman */ nxselect, nxmmap, NULL }, { sctargopen, sctargclose, rawread, rawwrite, /*65*/ sctargioctl, nostop, nullreset, nodevtotty,/* sctarg */ seltrue, nommap, sctargstrategy }, { labpcopen, labpcclose, rawread, rawwrite, /*66*/ labpcioctl, nostop, nullreset, nodevtotty,/* labpc */ seltrue, nommap, labpcstrategy }, { meteor_open, meteor_close, meteor_read, meteor_write, /*67*/ meteor_ioctl, nostop, nullreset, nodevtotty,/* Meteor */ seltrue, meteor_mmap, NULL }, { siopen, siclose, siread, siwrite, /*68*/ siioctl, sistop, sireset, sidevtotty,/* slxos */ ttselect, nxmmap, NULL }, { wcdopen, wcdclose, rawread, nowrite, /*69*/ wcdioctl, nostop, nullreset, nodevtotty,/* atapi */ seltrue, nommap, wcdstrategy }, { odopen, odclose, rawread, rawwrite, /*70*/ odioctl, nostop, nullreset, nodevtotty,/* od */ seltrue, nommap, odstrategy }, { ascopen, ascclose, ascread, nowrite, /*71*/ ascioctl, nostop, nullreset, nodevtotty, /* asc */ ascselect, nommap, NULL }, { stlopen, stlclose, stlread, stlwrite, /*72*/ stlioctl, stlstop, stlreset, stldevtotty, /*stli*/ ttselect, stlmmap, stlstrategy }, { qcam_open, qcam_close, qcam_read, nowrite, /*73*/ qcam_ioctl, nostop, nullreset, nodevtotty, /* qcam */ noselect, nommap, NULL }, { ccdopen, ccdclose, ccdread, ccdwrite, /*74*/ ccdioctl, nostop, nullreset, nodevtotty, /* ccd */ seltrue, nommap, ccdstrategy }, { stliopen, stliclose, stliread, stliwrite, /*75*/ stliioctl, stlistop, stlireset, stlidevtotty, /*stli*/ ttselect, stlimmap, stlistrategy },};int nchrdev = sizeof (cdevsw) / sizeof (cdevsw[0]);/* * Swapdev is a fake device implemented * in sw.c used only internally to get to swstrategy. * It cannot be provided to the users, because the * swstrategy routine munches the b_dev and b_blkno entries * before calling the appropriate driver. This would horribly * confuse, e.g. the hashing routines. Instead, /dev/drum is * provided as a character (raw) device. */dev_t swapdev = makedev(1, 0);/* * The tunnel device's LKM wants to know where to install itself in the * cdevsw table. Sigh. */dev_t tuncdev = makedev(52, 0);/* * Routine that identifies /dev/mem and /dev/kmem. * * A minimal stub routine can always return 0. */intiskmemdev(dev) dev_t dev;{ return (major(dev) == 2 && (minor(dev) == 0 || minor(dev) == 1));}intiszerodev(dev) dev_t dev;{ return (major(dev) == 2 && minor(dev) == 12);}/* * Routine to determine if a device is a disk. * * A minimal stub routine can always return 0. */intisdisk(dev, type) dev_t dev; int type;{ switch (major(dev)) { case 15: /* VBLK: vn, VCHR: cd */ return (1); case 0: /* wd */ case 2: /* fd */ case 4: /* sd */ case 6: /* cd */ case 7: /* mcd */ case 16: /* scd */ case 17: /* matcd */ case 18: /* ata */ case 19: /* wcd */ case 20: /* od */ if (type == VBLK) return (1); return (0); case 3: /* wd */ case 9: /* fd */ case 13: /* sd */ case 29: /* mcd */ case 43: /* vn */ case 45: /* scd */ case 46: /* matcd */ case 69: /* wcd */ case 70: /* od */ if (type == VCHR) return (1); /* fall through */ default: return (0); } /* NOTREACHED */}/* * Routine to convert from character to block device number. * * A minimal stub routine can always return NODEV. */dev_tchrtoblk(dev) dev_t dev;{ int blkmaj; switch (major(dev)) { case 3: blkmaj = 0; break; /* wd */ case 9: blkmaj = 2; break; /* fd */ case 10: blkmaj = 3; break; /* wt */ case 13: blkmaj = 4; break; /* sd */ case 14: blkmaj = 5; break; /* st */ case 15: blkmaj = 6; break; /* cd */ case 29: blkmaj = 7; break; /* mcd */ case 43: blkmaj = 15; break; /* vn */ case 45: blkmaj = 16; break; /* scd */ case 46: blkmaj = 17; break; /* matcd */ case 69: blkmaj = 19; break; /* wcd */ case 70: blkmaj = 20; break; /* od */ default: return (NODEV); } return (makedev(blkmaj, minor(dev)));}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?