These UART functions are implemented the same way regardless of the exact type of UART.
More...
|
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) |
|
These UART functions are implemented the same way regardless of the exact type of UART.
syscall kprintf |
( |
const char * |
format, |
|
|
|
... |
|
) |
| |
kernel printf: Multicore-safe (by mutex locks), formatted, synchronous output to SERIAL0.
- Parameters
-
format | The 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
-
format | The format string. Not all standard format specifiers are supported by this implementation. See _doprnt() for a description of supported conversion specifications. |
ap | Arguments 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
-
devptr | pointer to UART device |
func | index of function to run (defined in uart.h) |
arg1 | first argument to called function |
arg2 | second 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
-
devptr | Pointer 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
-
devptr | Pointer 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
-
devptr | Pointer to the device table entry for a UART. |
ch | The 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
-
devptr | Pointer to the device table entry for a UART. |
buf | Pointer to a buffer into which to place the read data. |
len | Maximum 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
-
uartnum | The 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
-
devptr | Pointer to the device table entry for a UART. |
buf | Pointer to the buffer of data to write. |
len | Number 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).
struct uart uarttab[NUART] |
Global table of UART devices that are available in the current Embedded Xinu configuration.