Next: 6.8 Buffer Management
Up: 6 OSKit Device Driver
Previous: 6.6 Device Driver Initialization
Device nodes have types
that follow a C++-like single-inheritance subtyping relationship,
where oskit_device_t is the ultimate ancestor or ``supertype''
of all device types.
In general, the host OS must know
what class of device it is talking to
in order to make use of it properly.
On the other hand, it is not strictly necessary
for the host OS to recognize the specific device type,
although it may be able to make better use of the device if it does.
The block device class has the following attributes:
- All input and output is synchronously driven by the host OS,
through calls to the read and write methods of the associated
blkio object;
the driver never calls the asynchronous I/O functions
defined in Section 5.2.
I/O operations always complete ``promptly'':
barring device driver or hardware bugs,
reads and writes are never delayed indefinitely
due to external conditions.
(This contrasts with network devices, for example,
where input is received when another machine sends a message,
not when the host OS asks for input.)
- There may be a minimum read/write granularity, or block size,
which may be obtained through the getblocksize method.
The block size is always a power of two
(e.g., typically 512 for most disks),
and is always less than the processor's minimum page size
(PAGE_SIZE, Section 10.2.1).
The offset and count parameters
of all read/write calls made by the host OS to this device driver
must be an even multiple of this block size.
For block devices with no minimum read/write granularity,
the driver specifies a block size of 1
(i.e., one-byte granularity).
- Block devices may have removable media,
such as floppy drives, CD-ROM drives, or removable hard drives.
The device driver provides an indication to the OS
of whether or not the device supports removable media.
The character device class has the following characteristics:
- Output is synchronous, directed by the host OS,
but input is asynchronous, directed by the external device.
- Incoming and outgoing data consists of a stream of bytes;
there is no larger minimum read/write granularity.
Multiple bytes of data can be sent and received in one operation,
but this is just an optimization;
there is no semantic difference from handling each byte individually.
The network device class has the following characteristics:
- Output is synchronous, directed by the host OS,
but input is asynchronous, directed by the external device.
- Data is handled in units of packets;
one send or receive operation is performed for each packet.
- Packets sent and received typically have
specific size and format restrictions,
depending on the specific network type (e.g., ethernet, myrinet).
Note that it would certainly be possible to decompose these device classes
into a deeper type hierarchy.
For example, in abstract terms it might make sense
to arrange character and network devices
under a single supertype representing ``asynchronous'' devices.
However, since the structure representing this ``abstract supertype''
would contain essentially nothing in terms of actual code or data,
this additional level was not deemed useful for the driver framework.
Of course, the OS is free to use
any type hierarchy (or non-hierarchy) it desires
for its own data structures representing devices, drivers, etc.
Next: 6.8 Buffer Management
Up: 6 OSKit Device Driver
Previous: 6.6 Device Driver Initialization
University of Utah Flux Research Group