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.

Variables

static uint16_t uart_base []
 UART port bases.

Detailed Description

16550-compatible UART

Definition in file x86_uart.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
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.

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

Referenced by gdbserial_configure(), and serial_init().

                                                         {
        int rc;

        /* Set new UART base */
        if ( port >= ( sizeof ( uart_base ) / sizeof ( uart_base[0] ) ) ) {
                rc = -ENODEV;
                goto err;
        }
        uart->base = ( ( void * ) ( intptr_t ) uart_base[port] );

        /* Check that UART exists */
        if ( ( rc = uart_exists ( uart ) ) != 0 )
                goto err;

        return 0;

 err:
        uart->base = NULL;
        return rc;
}

Variable Documentation

uint16_t uart_base[] [static]
Initial value:
 {
        [COM1] = 0x3f8,
        [COM2] = 0x2f8,
        [COM3] = 0x3e8,
        [COM4] = 0x2e8,
}

UART port bases.

Definition at line 36 of file x86_uart.c.

Referenced by uart_select().