Embedded Xinu Network Playground COSC3300Fall2012
Device driver API

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

#define CONSOLE   0

CONSOLE is on the first serial port.

#define ETH0   2

ETH0 is the first Ethernet device.

#define TTY1   1

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:
descrpDevice 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:
descrpDevice descriptor is an index into global device array
funcDevice-specific function code describes the control operation to perform. Each driver recognizes its own set of control functions.
arg1Optional first argument to control function. Usage depends upon the device driver and control function selected.
arg2Optional 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:
descrpDevice 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:
descrpDevice 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:
descrpDevice descriptor is an index into global device array
chbyte 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:
descrpDevice descriptor is an index into global device array
pPointer to data to be read from the device
countNumber 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:
descrpDevice descriptor is an index into global device array
pPointer to data to be written to the device
countNumber of data elements to be written to device
Returns:
Number of elements written device, or SYSERR