📄 sources.htm
字号:
* that MAX_NNONE is the maximum number of *
* controllers that the /dev/none driver can *
* support. This is a small number of instances *
* of the driver and the data structures *
* themselves are not large, so it is acceptable *
* to allocate for the maximum configuration. *
* *
* Note that MAX_NNONE is used in the *
* none_attributes table, specifically as the *
* maximum value for the numunit attribute field. *
* The NNONE variable is the data value address *
* for the numunit attribute field. *
***************************************************/
</p><p>
</p><p>
</p><p>
#define MAX_NNONE 8
</p></pre>
<p>
</p><p>
</p><pre>/***************************************************
* Declarations Section *
***************************************************/
<p>
</p><p>
</p><p>
</p><p>
/***************************************************
* Bits used in read/write operations *
***************************************************/
</p><p>
</p><p>
</p><p>
</p><p>
#define DN_RESET 0001 /* Device ready for data transfer */
#define DN_ERROR 0002 /* Indicate error */
/***************************************************
* Defines for softc structure *
***************************************************/
</p><p>
</p><p>
</p><p>
#define DN_OPEN 1 /* Device open bit */
#define DN_CLOSE 0 /* Device close bit */
/***************************************************
* Forward declarations of driver interfaces *
***************************************************/
int noneprobe(), nonecattach(), noneintr();
int noneopen(), noneclose(), noneread(), nonewrite();
int noneioctl(), none_ctlr_unattach();
</p><p>
/***************************************************
* controller and driver Structures *
***************************************************/
/***************************************************
* Declare an array of pointers to controller *
* structures *
***************************************************/
struct controller *noneinfo[MAX_NNONE];
/***************************************************
* Declare and initialize driver structure *
***************************************************/
struct driver nonedriver = {
noneprobe, /* probe */
0, /* slave */
nonecattach, /* cattach */
0, /* dattach */
0, /* go */
0, /* addr_list */
0, /* dev_name */
0, /* dev_list */
"none", /* ctlr_name */
noneinfo, /* ctlr_list */
0, /* xclu */
0, /* addr1_size */
0, /* addr1_atype */
0, /* addr2_size */
0, /* addr2_atype */
none_ctlr_unattach, /* ctlr_unattach */
0 /* dev_unattach */
};
/***************************************************
* Declare softc structure *
***************************************************/
struct none_softc {
int sc_openf; /* Open flag */
int sc_count; /* Count of characters written to device */
int sc_state; /* Device state, not currently used */
} none_softc[MAX_NNONE];
int none_config = FALSE; /* State flags indicating driver configured */
int none_devno = NO_DEV; /* No major number assigned yet. */
int NNONE = 1; /* One controller supported by default */
</p><p>
</p><p>
</p><p>
/***************************************************
* The handler_add interface is used to register *
* the interrupt handler for the /dev/none driver. *
* The none_id_t array contains IDs that are used *
* to enable, disable, and deregister the *
* interrupt handlers. *
***************************************************/
</p><p>
</p><p>
</p><p>
ihandler_id_t *none_id_t[MAX_NNONE];
</p><p>
</p><p>
</p><p>
</p><p>
/***************************************************
* The following list describes the use of the *
* none_is_dynamic, callback_return_status, and *
* num_none variables: *
* *
* o none_is_dynamic *
* *
* The none_is_dynamic variable will be used to *
* control any differences in tasks performed *
* by the statically or dynamically configured *
* /dev/none driver. Implementing a device *
* driver to handle a static or dynamic *
* configuration request gives customers *
* maximum flexibility in how they configure *
* the driver into the kernel. *
* *
* o callback_return_status *
* *
* The callback_return_status variable is used *
* by the callback_register_major_number *
* interface to determine if a previous failure *
* has occurred in statically configuring the *
* /dev/none driver. *
* *
* o num_none *
* *
* The num_none variable is used to count the *
* number of controllers probed. The noneprobe *
* interface increments this variable each time *
* it probes a NONE controller. *
***************************************************/
</p><p>
</p><p>
</p><p>
</p><p>
int none_is_dynamic = 0;
int num_none = 0;
int callback_return_status = ESUCCESS;
</p><p>
</p><p>
</p><p>
/***************************************************
* External function references. These are needed *
* for the devsw declaration. *
***************************************************/
</p><p>
</p><p>
</p><p>
extern int nodev(), nulldev();
</p><p>
</p><p>
</p><p>
</p><p>
/**************************************************
* !!* BUS SPECIFIC CHANGE *!! *
***************************************************
* Bus-Specific Option Data *
***************************************************
* You specify bus-specific option data for the *
* EISA, ISA, PCI, TURBOchannel, and VME buses *
* in the sysconfigtab database. You supply the *
* bus-specific option data for each bus that *
* your driver operates on. *
* *
* Typically, third-party driver writers specify *
* the bus-specific option data in a *
* sysconfigtab file fragment. See *
* Writing Device Drivers: Tutorial and the *
* bus-specific books for information on the *
* syntax associated with the following *
* bus-specific option data attribute fields: *
* *
* o EISA_Option *
* o ISA_Option *
* o PCI_Option *
* o TC_Option *
* o VBA_Option *
***************************************************/
</p><p>
</p><p>
</p><p>
/**************************************************
* The following code sets the members of the *
* the dsent structure to appropriate values *
* for the /dev/none driver. The address of this *
* structure is passed to the devsw_add *
* interface, which registers the I/O services *
* interfaces in the dsent table and reserves a *
* major number for the /dev/none driver. *
**************************************************/
</p><p>
</p><p>
</p><p>
</p><p>
struct dsent none_devsw_entry = {
noneopen, /* d_open */
noneclose, /* d_close */
nodev, /* d_strategy */
noneread, /* d_read */
nonewrite, /* d_write */
noneioctl, /* d_ioctl */
nodev, /* d_dump */
nodev, /* d_psize */
nodev, /* d_stop */
nodev, /* d_reset */
nodev, /* d_select */
0, /* d_mmap */
0, /* d_segmap */
NULL, /* d_ttys */
DEV_FUNNEL, /* d_funnel */
0, /* d_bflags */
0, /* d_cflags */
};
</p></pre>
<p>
</p><p>
</p><pre>/***************************************************
* !!* BUS-SPECIFIC CHANGE *!! *
***************************************************
* Your goal should be to write one device driver *
* that can operate on multiple buses. If your *
* driver operates on Digital-implemented buses *
* (EISA, ISA, PCI, and TURBOchannel), then you *
* define something similar to the following: *
* *
* #define DN_BUSNAME1 "tc" TURBOchannel *
* #define DN_BUSNAME2 "isa" eisa bus *
* #define DN_BUSNAME3 "eisa" isa bus *
* #define DN_BUSNAME4 "pci" pci bus *
* *
* These constants are passed to the *
* configure_driver interface, which the /dev/none *
* driver's none_configure interface calls. *
* *
* Another way to define a constant to handle *
* multiple buses is to use the asterisk (*), *
* which signifies a wildcard character to the *
* configure_driver interface. In other words, *
* the asterisk (*) tells the configure_driver *
* interface that the driver can operate on any of *
* the Digital-supported buses. The /dev/none *
* driver uses the asterisk (*) to define the bus *
* name. *
***************************************************/
#define DN_BUSNAME1 "DRIVER_WILDNAME /* This can be any */
/* Digital-supported bus */
<p>
</p></pre>
<p>
</p><p>
</p><pre><p>
</p><p>
</p><p>
/***************************************************
* The following code declares variables that are *
* required by the cfgmgr framework. You use *
* these variables as fields in the driver's *
* attribute table. The attribute table for the *
* /dev/none driver is called none_attributes. *
***************************************************/
static int majnum = NO_DEV;
static int noneversion = 0;
static int none_developer_debug = 0;
static unsigned char mcfgname[CFG_ATTR_NAME_SZ] = ;
static unsigned char unused[300] = ;
static unsigned char cma_dd[120] = ;
static unsigned char tc_optiondata[300] = ;
</p><p>
</p><p>
</p><p>
/***************************************************
* The cfgmgr framework uses the driver's *
* attribute table (a structure of type *
* cfg_subsys_attr_t) during static and dynamic *
* configuration of a device driver into the *
* kernel. The cfgmgr framework initializes the *
* attributes table early in the kernel boot *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -