5.3.1 Basic Concepts



Figure 5.1: Device Management Functions

(1) Device Name (UB* type)

A device name is a string of up to 8 characters consisting of the following elements.


#define	L_DEVNM 8	 /* Device name length */

Type Name indicating the device type

Characters a to z and A to Z can be used.

Unit One letter indicating a physical device

Each unit is assigned a letter from a to z in order starting from a.

Subunit One to three digits indicating a logical device

Each subunit is assigned a number from 0 to 254 in order starting from 0.

Device names take the format type + unit + subunit. Some devices may not have a unit or subunit, in

which case the corresponding .eld is omitted.

A name consisting of type + unit is called a physical device name. A name consisting of type + unit + subunit may be called a logical device name to distinguish it from a physical device name. If there is no subunit, the physical device name and logical device name arE_IDentical. The term “device name” by itself means the logical device name.

A subunit generally refers to a partition on a hard disk, but can be used to mean other logical devices as well.

Examples:

Had Hard disk (entire disk)

hda0 Hard disk (1st partition)

fda Floppy disk

rsa Serial port

kbpd Keyboard/pointing device

(2) Device ID (ID type)

By registering a device (device driver) with T-Kernel/SM, a device ID (> 0) is assigned to the device (physical device name). Device IDs are assigned to each physical device. The device ID of a logical device consists of the device ID assigned to the physical device to which is appended the subunit number + 1 (1 to 255).

devid: The device ID assigned at device registration

devid Physical device

devid + n + 1 The nth subunit (logical device)

Examples:

Had devid Entire hard disk

hda0 devid + 1 1st partition of hard disk

hda1 devid + 2 2nd partition of hard disk

(3) Device Attribute (ATR type)

Device attributes are defined as follows, in order to classify devices by their properties.


IIII IIII IIII IIII PRxx xxxx KKKK KKKK

The high 16 bits are device-dependent attributes defined for each device.

The low 16 bits are standard attributes defined as follows.


#define	TD_PROTECT	0x8000	/* P: write protection	*/
#define TD_REMOVABLE	0x4000	/* R: removable media	*/
#define	TD_DEVKIND	0x00ff	/* K: device/media kind	*/
#define	TD_DEVTYPE	0x00f0	/* device type	*/
			/* device type	*/
#define	TDK_UNDEF	0x0000	/* undefined/unknown	*/
#define	TDK_DISK	0x0010	/* disk device	*/
			/* disk kind	*/
#define	TDK_DISK_UNDEF	0x0010	/* miscellaneous disk	*/
#define	TDK_DISK_RAM	0x0011	/* RAM disk (used as main memory)	*/
#define	TDK_DISK_ROM	0x0012	/* ROM disk (used as main memory)	*/
#define	TDK_DISK_FLA	0x0013	/* Flash ROM or other silicon disk	*/
#define	TDK_DISK_FD	0x0014	/* floppy disk	*/
#define	TDK_DISK_HD	0x0015	/* hard disk	*/
#define	TDK_DISK_CDROM	0x0016	/* CD-ROM	*/

Currently no device types other than disks are defined. Other devices are assigned to undefined type (TDK UNDEF). Note that device types are defined for the sake of distinguishing devices from the standpoint of the user as necessary, such as when applications must change their processing based on the type of device or media. Devices for which no such distinctions are necessary do not have to have a device type assigned. See the individual device driver specifications regarding device-dependent attributes.

(4) Device Descriptor (ID type)

A device descriptor (> 0) is an identifier used for accessing a device, assigned by T-Kernel/SM when a device is opened.

A device descriptor belongs to a resource group. Operations using a device descriptor can be performed only by tasks belonging to the same resource group as the device descriptor. Error code (E_OACV) is returned for requests from tasks belonging to a di.erent resource group.

(5) Request ID (ID type)

When an IO request is made to a device, a request ID (> 0) is assigned identifying the request. This ID can be used to wait for IO completion.

(6) Data Number (INT type)

Device data is specified by a data number. Data is classi.ed into device-specific data and attribute data as follows.

Device-specific data: Data number > 0

As device-specific data, the data numbers are defined separately for each device.

Examples

Disk Data number = physical block number

Serial port Data number = 0 only

Attribute data: Data number < 0

Attribute data specifies driver or device state acquisition and setting modes, and special functions, etc.

Data numbers common to devices are defined, but device-dependent attribute data can also be defined. Details are given later.

Comments