RTEMS
Files | Classes | Typedefs | Functions
I/O Manager

The Input/Output (I/O) Manager provides a well-defined mechanism for accessing device drivers and a structured methodology for organizing device drivers. More...

Files

file  io.h
 This header file defines the IO Manager API.
 

Classes

struct  rtems_driver_address_table
 This structure contains the device driver entries. More...
 

Typedefs

typedef uint32_t rtems_device_minor_number
 This integer type represents the minor number of devices. More...
 
typedef uint32_t rtems_device_major_number
 This integer type represents the major number of devices. More...
 
typedef rtems_status_code rtems_device_driver
 This type shall be used in device driver entry declarations and definitions. More...
 
typedef rtems_device_driver(* rtems_device_driver_entry) (rtems_device_major_number, rtems_device_minor_number, void *)
 Device driver entries shall have this type.
 

Functions

rtems_status_code rtems_io_close (rtems_device_major_number major, rtems_device_minor_number minor, void *argument)
 Closes the device specified by the device major and minor numbers. More...
 
rtems_status_code rtems_io_control (rtems_device_major_number major, rtems_device_minor_number minor, void *argument)
 Controls the device specified by the device major and minor numbers. More...
 
rtems_status_code rtems_io_initialize (rtems_device_major_number major, rtems_device_minor_number minor, void *argument)
 Initializes the device specified by the device major and minor numbers. More...
 
rtems_status_code rtems_io_open (rtems_device_major_number major, rtems_device_minor_number minor, void *argument)
 Opens the device specified by the device major and minor numbers. More...
 
rtems_status_code rtems_io_read (rtems_device_major_number major, rtems_device_minor_number minor, void *argument)
 Reads from the device specified by the device major and minor numbers. More...
 
rtems_status_code rtems_io_register_driver (rtems_device_major_number major, const rtems_driver_address_table *driver_table, rtems_device_major_number *registered_major)
 Registers and initializes the device with the specified device driver address table and device major number in the Device Driver Table. More...
 
rtems_status_code rtems_io_register_name (const char *device_name, rtems_device_major_number major, rtems_device_minor_number minor)
 Registers the device specified by the device major and minor numbers in the file system under the specified name. More...
 
rtems_status_code rtems_io_unregister_driver (rtems_device_major_number major)
 Removes a device driver specified by the device major number from the Device Driver Table. More...
 
rtems_status_code rtems_io_write (rtems_device_major_number major, rtems_device_minor_number minor, void *argument)
 Writes to the device specified by the device major and minor numbers. More...
 

Detailed Description

The Input/Output (I/O) Manager provides a well-defined mechanism for accessing device drivers and a structured methodology for organizing device drivers.

Typedef Documentation

◆ rtems_device_driver

This type shall be used in device driver entry declarations and definitions.

Device driver entries return an rtems_status_code status code. This type definition helps to document device driver entries in the source code.

Definition at line 109 of file io.h.

◆ rtems_device_major_number

typedef uint32_t rtems_device_major_number

This integer type represents the major number of devices.

The major number of a device is determined by rtems_io_register_driver() and the application configuration (see CONFIGURE_MAXIMUM_DRIVERS) .

Definition at line 96 of file io.h.

◆ rtems_device_minor_number

typedef uint32_t rtems_device_minor_number

This integer type represents the minor number of devices.

The minor number of devices is managed by the device driver.

Definition at line 84 of file io.h.

Function Documentation

◆ rtems_io_close()

rtems_status_code rtems_io_close ( rtems_device_major_number  major,
rtems_device_minor_number  minor,
void *  argument 
)

Closes the device specified by the device major and minor numbers.

This directive calls the device driver close entry registered in the Device Driver Table for the specified device major number.

The close entry point is commonly used by device drivers to relinquish exclusive access to a device.

Parameters
majoris the major number of the device.
minoris the minor number of the device.
argumentis the argument passed to the device driver close entry.
Return values
RTEMS_SUCCESSFULThe requested operation was successful.
RTEMS_INVALID_NUMBERThe device major number was invalid.
Returns
Other status codes may be returned by the device driver close entry.

◆ rtems_io_control()

rtems_status_code rtems_io_control ( rtems_device_major_number  major,
rtems_device_minor_number  minor,
void *  argument 
)

Controls the device specified by the device major and minor numbers.

This directive calls the device driver I/O control entry registered in the Device Driver Table for the specified device major number.

The exact functionality of the driver entry called by this directive is driver dependent. It should not be assumed that the control entries of two device drivers are compatible. For example, an RS-232 driver I/O control operation may change the baud of a serial line, while an I/O control operation for a floppy disk driver may cause a seek operation.

Parameters
majoris the major number of the device.
minoris the minor number of the device.
argumentis the argument passed to the device driver I/O control entry.
Return values
RTEMS_SUCCESSFULThe requested operation was successful.
RTEMS_INVALID_NUMBERThe device major number was invalid.
Returns
Other status codes may be returned by the device driver I/O control entry.

◆ rtems_io_initialize()

rtems_status_code rtems_io_initialize ( rtems_device_major_number  major,
rtems_device_minor_number  minor,
void *  argument 
)

Initializes the device specified by the device major and minor numbers.

This directive calls the device driver initialization entry registered in the Device Driver Table for the specified device major number.

This directive is automatically invoked for each device driver defined by the application configuration during the system initialization and via the rtems_io_register_driver() directive.

A device driver initialization entry is responsible for initializing all hardware and data structures associated with a device. If necessary, it can allocate memory to be used during other operations.

Parameters
majoris the major number of the device.
minoris the minor number of the device.
argumentis the argument passed to the device driver initialization entry.
Return values
RTEMS_SUCCESSFULThe requested operation was successful.
RTEMS_INVALID_NUMBERThe device major number was invalid.
Returns
Other status codes may be returned by the device driver initialization entry.

◆ rtems_io_open()

rtems_status_code rtems_io_open ( rtems_device_major_number  major,
rtems_device_minor_number  minor,
void *  argument 
)

Opens the device specified by the device major and minor numbers.

This directive calls the device driver open entry registered in the Device Driver Table for the specified device major number.

The open entry point is commonly used by device drivers to provide exclusive access to a device.

Parameters
majoris the major number of the device.
minoris the minor number of the device.
argumentis the argument passed to the device driver close entry.
Return values
RTEMS_SUCCESSFULThe requested operation was successful.
RTEMS_INVALID_NUMBERThe device major number was invalid.
Returns
Other status codes may be returned by the device driver open entry.

◆ rtems_io_read()

rtems_status_code rtems_io_read ( rtems_device_major_number  major,
rtems_device_minor_number  minor,
void *  argument 
)

Reads from the device specified by the device major and minor numbers.

This directive calls the device driver read entry registered in the Device Driver Table for the specified device major number.

Read operations typically require a buffer address as part of the argument parameter block. The contents of this buffer will be replaced with data from the device.

Parameters
majoris the major number of the device.
minoris the minor number of the device.
argumentis the argument passed to the device driver read entry.
Return values
RTEMS_SUCCESSFULThe requested operation was successful.
RTEMS_INVALID_NUMBERThe device major number was invalid.
Returns
Other status codes may be returned by the device driver read entry.

◆ rtems_io_register_driver()

rtems_status_code rtems_io_register_driver ( rtems_device_major_number  major,
const rtems_driver_address_table driver_table,
rtems_device_major_number registered_major 
)

Registers and initializes the device with the specified device driver address table and device major number in the Device Driver Table.

If the device major number equals zero a device major number will be obtained. The device major number of the registered driver will be returned.

After a successful registration, the rtems_io_initialize() directive will be called to initialize the device.

Parameters
majoris the device major number. Use a value of zero to let the system obtain a device major number automatically.
driver_tableis the device driver address table.
[out]registered_majoris the pointer to a device major number variable. The device major number of the registered device will be stored in this variable, in case of a successful operation.
Return values
RTEMS_SUCCESSFULThe requested operation was successful.
RTEMS_INVALID_ADDRESSThe device major number of the device was NULL.
RTEMS_INVALID_ADDRESSThe device driver address table was empty.
RTEMS_INVALID_NUMBERThe device major number of the device was out of range, see CONFIGURE_MAXIMUM_DRIVERS.
RTEMS_TOO_MANYThe system was unable to obtain a device major number.
RTEMS_RESOURCE_IN_USEThe device major number was already in use.
RTEMS_CALLED_FROM_ISRThe directive was called from interrupt context.
Returns
Other status codes may be returned by rtems_io_initialize().

◆ rtems_io_register_name()

rtems_status_code rtems_io_register_name ( const char *  device_name,
rtems_device_major_number  major,
rtems_device_minor_number  minor 
)

Registers the device specified by the device major and minor numbers in the file system under the specified name.

The device is registered as a character device.

Parameters
device_nameis the device name in the file system.
majoris the device major number.
minoris the device minor number.
Return values
RTEMS_SUCCESSFULThe requested operation was successful.
RTEMS_TOO_MANYThe name was already in use or other errors occurred.

◆ rtems_io_unregister_driver()

rtems_status_code rtems_io_unregister_driver ( rtems_device_major_number  major)

Removes a device driver specified by the device major number from the Device Driver Table.

Currently no specific checks are made and the driver is not closed.

Parameters
majoris the major number of the device.
Return values
RTEMS_SUCCESSFULThe requested operation was successful.
RTEMS_UNSATISFIEDThe device major number was invalid.
RTEMS_CALLED_FROM_ISRThe directive was called from interrupt context.

◆ rtems_io_write()

rtems_status_code rtems_io_write ( rtems_device_major_number  major,
rtems_device_minor_number  minor,
void *  argument 
)

Writes to the device specified by the device major and minor numbers.

This directive calls the device driver write entry registered in the Device Driver Table for the specified device major number.

Write operations typically require a buffer address as part of the argument parameter block. The contents of this buffer will be sent to the device.

Parameters
majoris the major number of the device.
minoris the minor number of the device.
argumentis the argument passed to the device driver write entry.
Return values
RTEMS_SUCCESSFULThe requested operation was successful.
RTEMS_INVALID_NUMBERThe device major number was invalid.
Returns
Other status codes may be returned by the device driver write entry.