iPXE
Functions | Variables
x86_uart.c File Reference

16550-compatible UART More...

#include <errno.h>
#include <ipxe/uart.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
int uart_select (struct uart *uart, unsigned int port)
 Select UART port. More...
 

Variables

static uint16_t uart_base []
 UART port bases. More...
 

Detailed Description

16550-compatible UART

Definition in file x86_uart.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ uart_select()

int uart_select ( struct uart uart,
unsigned int  port 
)

Select UART port.

Parameters
uartUART
portPort number, or 0 to disable
Return values
rcReturn status code

Definition at line 50 of file x86_uart.c.

50  {
51  int rc;
52 
53  /* Set new UART base */
54  if ( port >= ( sizeof ( uart_base ) / sizeof ( uart_base[0] ) ) ) {
55  rc = -ENODEV;
56  goto err;
57  }
58  uart->base = ( ( void * ) ( intptr_t ) uart_base[port] );
59 
60  /* Check that UART exists */
61  if ( ( rc = uart_exists ( uart ) ) != 0 )
62  goto err;
63 
64  return 0;
65 
66  err:
67  uart->base = NULL;
68  return rc;
69 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int uart_exists(struct uart *uart)
Check for existence of UART.
Definition: uart.c:88
A 16550-compatible UART.
Definition: uart.h:80
void * base
I/O port base address.
Definition: uart.h:82
unsigned long intptr_t
Definition: stdint.h:21
u8 port
Port number.
Definition: CIB_PRM.h:31
#define ENODEV
No such device.
Definition: errno.h:509
static uint16_t uart_base[]
UART port bases.
Definition: x86_uart.c:36
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References uart::base, ENODEV, NULL, port, rc, uart_base, and uart_exists().

Referenced by gdbserial_configure(), and serial_init().

Variable Documentation

◆ uart_base

uint16_t uart_base[]
static
Initial value:
= {
[COM1] = 0x3f8,
[COM2] = 0x2f8,
[COM3] = 0x3e8,
[COM4] = 0x2e8,
}
Definition: uart.h:92
Definition: uart.h:91
Definition: uart.h:94
Definition: uart.h:93

UART port bases.

Definition at line 36 of file x86_uart.c.

Referenced by uart_select().