Embedded Xinu Operating System
An ongoing research project and educational operating system.
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Groups Pages
Functions | Variables
UART Generic Functions

These UART functions are implemented the same way regardless of the exact type of UART. More...

Functions

syscall kprintf (const char *format,...)
 
syscall kvprintf (const char *format, va_list ap)
 
devcall uartControl (device *devptr, int func, long arg1, long arg2)
 
devcall uartGetc (device *devptr)
 
devcall uartInit (device *devptr)
 
devcall uartPutc (device *devptr, char ch)
 
devcall uartRead (device *devptr, void *buf, uint len)
 
void uartStat (ushort uartnum)
 
devcall uartWrite (device *devptr, const void *buf, uint len)
 

Variables

struct uart uarttab [NUART]
 

Detailed Description

These UART functions are implemented the same way regardless of the exact type of UART.

Function Documentation

syscall kprintf ( const char *  format,
  ... 
)

kernel printf: Multicore-safe (by mutex locks), formatted, synchronous output to SERIAL0.

Parameters
formatThe format string. Not all standard format specifiers are supported by this implementation. See _doprnt() for a description of supported conversion specifications.
...Arguments matching those in the format string.
Returns
The number of characters written.
syscall kvprintf ( const char *  format,
va_list  ap 
)

kernel printf: formatted, synchronous output to SERIAL0.

Parameters
formatThe format string. Not all standard format specifiers are supported by this implementation. See _doprnt() for a description of supported conversion specifications.
apArguments matching those in the format string.
Returns
The number of characters written.
devcall uartControl ( device *  devptr,
int  func,
long  arg1,
long  arg2 
)

Control parameters to a UART.

Parameters
devptrpointer to UART device
funcindex of function to run (defined in uart.h)
arg1first argument to called function
arg2second argument to called function
Returns
SYSERR if control function not recognized; otherwise a control-function-dependent value.
devcall uartGetc ( device *  devptr)

Read a single character from a UART.

Parameters
devptrPointer to the device table entry for a UART.
Returns
On success, returns the character read as an unsigned char cast to an int. On read error, invalid device, or end-of file, returns SYSERR.
devcall uartInit ( device *  devptr)

Initialize a UART, including the entry in Xinu's UART table as well as the hardware itself.

Parameters
devptrPointer to the device table entry for the UART.
Returns
OK on success; SYSERR on failure.
devcall uartPutc ( device *  devptr,
char  ch 
)

Write a single character to a UART.

Parameters
devptrPointer to the device table entry for a UART.
chThe character to write.
Returns
On success, returns the character written as an unsigned char cast to an int. On failure, returns SYSERR.
devcall uartRead ( device *  devptr,
void *  buf,
uint  len 
)

Reads data from a UART.

Parameters
devptrPointer to the device table entry for a UART.
bufPointer to a buffer into which to place the read data.
lenMaximum number of bytes of data to read.
Returns
On success, returns the number of bytes read, which normally is len, but may be less than len if the UART has been set to non-blocking mode. Returns SYSERR on other error (currently, only if uartInit() has not yet been called).
void uartStat ( ushort  uartnum)

Prints information about the current status of a UART.

Parameters
uartnumThe minor number of the UART.
devcall uartWrite ( device *  devptr,
const void *  buf,
uint  len 
)

Write a buffer of data to a UART.

Caveat: this operates asynchronously, so the data written may be held in an internal buffer and not yet actually written to the hardware. The UART driver's lower half (interrupt handler; see uartInterrupt()) is responsible for actually writing the data to the hardware. Exception: when the UART transmitter is idle, uartWrite() can directly write one byte to the hardware.

Parameters
devptrPointer to the device table entry for a UART.
bufPointer to the buffer of data to write.
lenNumber of bytes to write.
Returns
On success, returns the number of bytes written, which normally is len, but may be less than len if the UART has been set to non-blocking mode. Returns ::SYSERR on other error (currently, only if uartInit() has not yet been called).

Variable Documentation

struct uart uarttab[NUART]

Global table of UART devices that are available in the current Embedded Xinu configuration.