Device Registration
The following device registration information is defined when registering a device.
Device registration is performed for each physical device.
typedef struct t_ddev {
VP exinf; /* extended information */
ATR drvatr; /* driver attributes */
ATR devatr; /* device attributes */
INT nsub; /* subunits */
W blksz; /* block size of device-specific data (-1: unknown) */
FP openfn; /* open count */
FP closefn; /* close count */
FP execfn; /* processing start function */
FP waitfn; /* completion wait function */
FP abortfn; /* abort processing function */
FP eventfn; /* event function */
/* Implementation-dependent information may be added beyond this point. */
} T_DDEV;
exinf is used to store any other desired information. The value of exinf is passed to the processing functions. Device management pays no attention to the contents. drvatr sets device driver attribute information. The low bits indicate system attributes and the high bits are used for implementation-dependent attributes. The implementation-dependent attribute portion is used, for example, to indicate validity flags when implementation-dependent data is added to T_DDEV.
drvatr := [TDA_OPENREQ]
#define TDA_OPENREQ 0x0001 /* open/close each time */
TDA_OPENREQ
When a device is opened multiple times, normally openfn is called the first time it is opened and closefn the last time it is closed.
If TDA_OPENREQ is specified, then openfn/ closefn will be called for all open/ close operations even in case of multiple openings.
Device attributes are specified in devatr. The details of device attribute settings are as noted above. The number of subunits is set in nsub. If there are no subunits, 0 is specified.
blksz sets the block size of device-specific data in bytes. In the case of a disk device, this is the physical block size. It is set to 1 byte for a serial port, etc. For a device with no device-specific data it is set to 0. For an unformatted disk or other device whose block size is unknown, -1 is set.
If blksz ( 0, device-specific data cannot be accessed. When device-specific data is accessed by tk_rea_dev or tk_wri_dev, size × blksz must be the size of the area being accessed, that is, the size of buf.
openfn, closefn, execfn, waitfn, abortfn, and eventfn set the entry address of processing functions.
Details of the processing functions are discussed later.
blksz, the member of T_DDEV, is of W type instead of INT type.

Comments
Click here to Post a Comment