iPXE
|
16550-compatible UART More...
Go to the source code of this file.
Data Structures | |
struct | uart |
A 16550-compatible UART. More... | |
Macros | |
#define | UART_THR 0x00 |
Transmitter holding register. More... | |
#define | UART_RBR 0x00 |
Receiver buffer register. More... | |
#define | UART_IER 0x01 |
Interrupt enable register. More... | |
#define | UART_FCR 0x02 |
FIFO control register. More... | |
#define | UART_FCR_FE 0x01 |
FIFO enable. More... | |
#define | UART_LCR 0x03 |
Line control register. More... | |
#define | UART_LCR_WLS0 0x01 |
Word length select bit 0. More... | |
#define | UART_LCR_WLS1 0x02 |
Word length select bit 1. More... | |
#define | UART_LCR_STB 0x04 |
Number of stop bits. More... | |
#define | UART_LCR_PEN 0x08 |
Parity enable. More... | |
#define | UART_LCR_EPS 0x10 |
Even parity select. More... | |
#define | UART_LCR_DLAB 0x80 |
Divisor latch access bit. More... | |
#define | UART_LCR_WORD_LEN(x) ( ( (x) - 5 ) << 0 ) |
Word length. More... | |
#define | UART_LCR_STOP_BITS(x) ( ( (x) - 1 ) << 2 ) |
Stop bits. More... | |
#define | UART_LCR_PARITY(x) ( ( (x) - 0 ) << 3 ) |
Parity. More... | |
#define | UART_LCR_WPS(word_len, parity, stop_bits) |
Calculate line control register value. More... | |
#define | UART_LCR_8N1 UART_LCR_WPS ( 8, 0, 1 ) |
Default LCR value: 8 data bits, no parity, one stop bit. More... | |
#define | UART_MCR 0x04 |
Modem control register. More... | |
#define | UART_MCR_DTR 0x01 |
Data terminal ready. More... | |
#define | UART_MCR_RTS 0x02 |
Request to send. More... | |
#define | UART_LSR 0x05 |
Line status register. More... | |
#define | UART_LSR_DR 0x01 |
Data ready. More... | |
#define | UART_LSR_THRE 0x20 |
Transmitter holding register empty. More... | |
#define | UART_LSR_TEMT 0x40 |
Transmitter empty. More... | |
#define | UART_SCR 0x07 |
Scratch register. More... | |
#define | UART_DLL 0x00 |
Divisor latch (least significant byte) More... | |
#define | UART_DLM 0x01 |
Divisor latch (most significant byte) More... | |
#define | UART_MAX_BAUD 115200 |
Maximum baud rate. More... | |
Enumerations | |
enum | uart_port { COM1 = 1, COM2 = 2, COM3 = 3, COM4 = 4 } |
Symbolic names for port indexes. More... | |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
void | uart_write (struct uart *uart, unsigned int addr, uint8_t data) |
uint8_t | uart_read (struct uart *uart, unsigned int addr) |
int | uart_select (struct uart *uart, unsigned int port) |
Select UART port. More... | |
static int | uart_data_ready (struct uart *uart) |
Check if received data is ready. More... | |
static uint8_t | uart_receive (struct uart *uart) |
Receive data. More... | |
void | uart_transmit (struct uart *uart, uint8_t data) |
Transmit data. More... | |
void | uart_flush (struct uart *uart) |
Flush data. More... | |
int | uart_exists (struct uart *uart) |
Check for existence of UART. More... | |
int | uart_init (struct uart *uart, unsigned int baud, uint8_t lcr) |
Initialise UART. More... | |
16550-compatible UART
Definition in file uart.h.
#define UART_LCR_WORD_LEN | ( | x | ) | ( ( (x) - 5 ) << 0 ) |
#define UART_LCR_STOP_BITS | ( | x | ) | ( ( (x) - 1 ) << 2 ) |
#define UART_LCR_WPS | ( | word_len, | |
parity, | |||
stop_bits | |||
) |
Calculate line control register value.
word_len | Word length (5-8) |
parity | Parity (0=none, 1=odd, 3=even) |
stop_bits | Stop bits (1-2) |
lcr | Line control register value |
#define UART_LCR_8N1 UART_LCR_WPS ( 8, 0, 1 ) |
#define UART_LSR_THRE 0x20 |
enum uart_port |
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
Referenced by uart_exists(), uart_init(), and uart_transmit().
Referenced by uart_data_ready(), uart_exists(), uart_flush(), uart_init(), uart_receive(), and uart_transmit().
int uart_select | ( | struct uart * | uart, |
unsigned int | port | ||
) |
Select UART port.
uart | UART |
port | Port number, or 0 to disable |
rc | Return status code |
Definition at line 50 of file x86_uart.c.
References uart::base, ENODEV, NULL, port, rc, uart_base, and uart_exists().
Referenced by gdbserial_configure(), and serial_init().
|
inlinestatic |
Check if received data is ready.
uart | UART |
ready | Data is ready |
Definition at line 109 of file uart.h.
References UART_LSR, UART_LSR_DR, and uart_read().
Referenced by gdbserial_recv(), serial_getchar(), and serial_iskey().
Receive data.
uart | UART |
data | Data |
Definition at line 122 of file uart.h.
References UART_RBR, and uart_read().
Referenced by gdbserial_recv(), and serial_getchar().
Transmit data.
uart | UART |
data | Data |
Definition at line 48 of file uart.c.
References data, mdelay(), UART_LSR, UART_LSR_THRE, uart_read(), UART_THR, UART_THRE_TIMEOUT_MS, and uart_write().
Referenced by gdbserial_send(), int21(), and serial_putchar().
void uart_flush | ( | struct uart * | uart | ) |
Flush data.
uart | UART |
Definition at line 69 of file uart.c.
References UART_LSR, UART_LSR_DR, UART_LSR_TEMT, UART_RBR, uart_read(), and UART_TEMT_TIMEOUT_MS.
Referenced by serial_shutdown(), and uart_init().
int uart_exists | ( | struct uart * | uart | ) |
Check for existence of UART.
uart | UART |
rc | Return status code |
Definition at line 88 of file uart.c.
References uart::base, ENODEV, uart_read(), UART_SCR, and uart_write().
Referenced by uart_init(), and uart_select().
Initialise UART.
uart | UART |
baud | Baud rate, or zero to leave unchanged |
lcr | Line control register value, or zero to leave unchanged |
rc | Return status code |
Definition at line 113 of file uart.c.
References uart::divisor, uart::lcr, rc, UART_DLL, UART_DLM, uart_exists(), UART_FCR, UART_FCR_FE, uart_flush(), UART_IER, UART_LCR, UART_LCR_DLAB, UART_MAX_BAUD, UART_MCR, UART_MCR_DTR, UART_MCR_RTS, uart_read(), and uart_write().
Referenced by gdbserial_configure(), and serial_init().