5.3.3 Device Registration

The following device registration information is defined in 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	*/
	INT	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 desired information. The value 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 .ags 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 .rst 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 setting 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.

  • ID tk_def_dev( UB *devnm, T_DDEV *ddev, T_IDEV *idev )

devnm Physical device name

ddev Device registration information

idev Returns device initialization information

return code Device ID or error

Registers a device with the device name set in devnm.

If a device with device name devnm is already registered, the registration is updated with new

information, in which case the device ID does not change.

When ddev = NULL is specified, device devnm registration is deleted.

The device initialization information is returned in idev.

This includes information set by default when the device driver is started, and can be used as necessary.

When idev = NULL is set, device initialization information is not stored.


	typedef struct t_idev {
	ID evtmbfid; /* event notification message buffer ID */
	/* Implementation-dependent information may be added beyond this point.*/
	} T_IDEV;

evtmbfid specifies the system default message buffer ID for event noti.cation. If there is no system default event noti.cation message buffer, 0 is set.

Noti.cation like the following is made to each subsystem when a device is registered or deleted.

devid is the device ID of the physical device registered or deleted.

Device registration or update: tk_evt_ssy(0, TSEVT_DEVICE_REGIST, 0, devid)

Device deletion: tk_evt_ssy(0, TSEVT_DEVICE_DELETE, 0, devid)

E_LIMIT Number of registrations exceeds the system limit

E_NOEXS The device specified in devnm does not exist (when ddev = NULL)

  • ER tk_ref_idv( T_IDEV *idev )

idev Returns device initialization information

return code Error

Gets device initialization information.

The contents are the same as the information obtained by tk dev def().

Comments