I/o Subsystems
I/o Subsystems
Embedded Systems
ISBN: 1-57820-124-1
CMPBooks
Chapter 12
I/O Subsystem
Outline
12.1 Introduction
12.2 Basic I/O Concepts
12.3 The I/O Subsystem
12.1 Introduction
All embedded systems include some form of input
and output (I/O) operations
Examples of embedded systems built explicitly to
deal with I/O devices:
Cell phone, pager, and a handheld MP3 player
I/O operations are interpreted differently depending
on the viewpoint taken and place different
requirements on the level of understanding of the
hardware details
Introduction (Cont.)
From the perspective of a system software developer
I/O operations imply communicating with the device
Programming the device to initiate an I/O request
Performing actual data transfer between the device and the system
Notifying the requestor when the operation completes
Must understand
the physical properties (e.g. register definitions, access methods) of the
device
locating the correct instance of the device
how the device is integrated with rest of the system
how to handle any errors that can occur during the I/O operations
Introduction (Cont.)
From the perspective of the RTOS
Locating the right device for the I/O request
Locating the right device driver for the device
Issuing the request to the device driver
Ensure synchronized access to the device
Facilitate an abstraction that hides both the device
characteristics and specifics from the application
developers
Introduction (Cont.)
From the perspective of an application
developer
The goal is to find a simple, uniform, and elegant
way to communicate with all types of devices
present in the system
The application developer is most concerned with
presenting the data to the end user in a useful way
Introduction (Cont.)
This chapter focuses on
basic hardware I/O concepts,
the structure of the I/O subsystem, and
a specific implementation of an I/O subsystem
12.2 Basic I/O Concepts
The combination of I/O devices, device drivers, and
the I/O subsystem comprises the overall I/O system
in an embedded environment
UNIFORM_IO_DRV ttyIOdrv;
ttyIOdrv.Create = tty_Create;
ttyIOdrv.Open = tty_Open;
ttyIOdrv.Read = tty_Read;
ttyIOdrv.Write = tty_Write;
ttyIOdrv.Close = tty_Close;
ttyIOdrv.Ioctl = tty_Ioctl;
ttyIOdrv.Destroy = tty_Destroy;
Driver Table
An I/O subsystem usually maintains a
uniform I/O driver table
Associate uniform I/O calls with driver-specific
I/O routines
A new driver can be installed to or removed from
this driver table
Uniform I/O Driver Table
Associating Devices with Device
Drivers
The create() function is used to create a
virtual instance of a device
The I/O subsystem tracks these virtual
instances using the device table
Each entry in the device table holds generic
information, as well as instance-specific
information
Associating Devices with Device
Drivers (Cont.)
The generic part can include the unique name
of the device instance and a reference to the
device driver
A device instance name is constructed using the
generic device name and the instance number
For example, the device named tty0 implies that
This I/O device is a serial terminal device
The first instance created in the system
Associating Devices with Device
Drivers (Cont.)
The driver-dependent part is a block of memory
Hold instance-specific data.
The content of this information is dependent on the driver
implementation.
The driver is the only entity that accesses and interprets
this data.
A reference to the newly created device entry is
returned to the caller of the create function.
Subsequent calls to the open and destroy functions use
this reference.
Associating Devices with Drivers
Points to Remember
Interfaces between a device and the main processor
occur in two ways: port mapped and memory
mapped
DMA controllers allows data transfer bypassing the
main processor
I/O subsystems must be flexible enough to handle a
wide range of I/O devices.
Uniform I/O hides device peculiarities from
applications.
Points to Remember (Cont.)
The I/O subsystem maintains a driver table
that associates uniform I/O calls with driver-
specific I/O routines.
The I/O subsystem maintains a device table
and forms an association between this table
and the driver table