The Device Driver interface provides a unified set of functions for accessing Xinu devices.
More...
Defines |
#define | CONSOLE 0 |
#define | TTY1 1 |
#define | ETH0 2 |
Functions |
devcall | close (int) |
devcall | control (int, int, int, int) |
devcall | getc (int) |
devcall | open (int,...) |
devcall | putc (int, char) |
devcall | read (int, void *, int) |
devcall | write (int, void *, int) |
Detailed Description
The Device Driver interface provides a unified set of functions for accessing Xinu devices.
Define Documentation
CONSOLE is on the first serial port.
ETH0 is the first Ethernet device.
TTY1 is the second serial port.
Function Documentation
devcall close |
( |
int |
descrp | ) |
|
Close a device, which may entail stopping I/O hardware and releasing associated resources.
- Parameters:
-
descrp | Device descriptor is an index into global device array |
- Returns:
- OK on success, else SYSERR
devcall control |
( |
int |
descrp, |
|
|
int |
func, |
|
|
int |
arg1, |
|
|
int |
arg2 |
|
) |
| |
Control functions are a catch-all category for all other device-specific behavior that does not fall under the other device API functions.
- Parameters:
-
descrp | Device descriptor is an index into global device array |
func | Device-specific function code describes the control operation to perform. Each driver recognizes its own set of control functions. |
arg1 | Optional first argument to control function. Usage depends upon the device driver and control function selected. |
arg2 | Optional second argument to control function. Usage depends upon the device driver and control function selected. |
- Returns:
- OK on success, else SYSERR
devcall getc |
( |
int |
descrp | ) |
|
Read a byte from a device.
- Parameters:
-
descrp | Device descriptor is an index into global device array |
- Returns:
- byte of input or SYSERR
devcall open |
( |
int |
descrp, |
|
|
|
... |
|
) |
| |
Open a device, which may entail starting I/O hardware and allocating associated resources.
- Parameters:
-
descrp | Device descriptor is an index into global device array |
... | Optional device-specific arguments, such as the descriptor of a related, underlying device. |
- Returns:
- OK on success, else SYSERR
devcall putc |
( |
int |
descrp, |
|
|
char |
ch |
|
) |
| |
Write a byte to a device.
- Parameters:
-
descrp | Device descriptor is an index into global device array |
ch | byte to write to device |
- Returns:
- OK on success, or SYSERR
devcall read |
( |
int |
descrp, |
|
|
void * |
p, |
|
|
int |
count |
|
) |
| |
Read one or more bytes from a device.
- Parameters:
-
descrp | Device descriptor is an index into global device array |
p | Pointer to data to be read from the device |
count | Number of data elements to be read from device |
- Returns:
- Number of elements read by device, or SYSERR
devcall write |
( |
int |
descrp, |
|
|
void * |
p, |
|
|
int |
count |
|
) |
| |
Write one or more bytes to a device.
- Parameters:
-
descrp | Device descriptor is an index into global device array |
p | Pointer to data to be written to the device |
count | Number of data elements to be written to device |
- Returns:
- Number of elements written device, or SYSERR