iPXE
x86_uart.c File Reference

16550-compatible UART More...

#include <string.h>
#include <ipxe/serial.h>
#include <ipxe/ns16550.h>

Go to the source code of this file.

Macros

#define ISA_UART(NAME, BASE)
 Define a fixed ISA UART.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 ISA_UART (com1, COM1_BASE)
 ISA_UART (com2, COM2_BASE)
 ISA_UART (com3, COM3_BASE)
 ISA_UART (com4, COM4_BASE)
int uart_register_fixed (void)
 Register fixed ISA UARTs.

Detailed Description

16550-compatible UART

Definition in file x86_uart.c.

Macro Definition Documentation

◆ ISA_UART

#define ISA_UART ( NAME,
BASE )
Value:
static struct ns16550_uart ns16550_ ## NAME = { \
.base = ( ( void * ) (BASE) ), \
.clock = NS16550_CLK_DEFAULT, \
}; \
struct uart NAME = { \
.refcnt = REF_INIT ( ref_no_free ), \
.name = #NAME, \
.priv = &ns16550_ ## NAME, \
}
#define BASE
Definition 3c595.h:69
#define NS16550_CLK_DEFAULT
Default input clock rate (1.8432 MHz)
Definition ns16550.h:95
struct uart_operations ns16550_operations
16550 UART operations
Definition ns16550.c:171
void ref_no_free(struct refcnt *refcnt __unused)
Do not free reference-counted object.
Definition refcnt.c:102
#define REF_INIT(free_fn)
Initialise a static reference counter.
Definition refcnt.h:78
A 16550-compatible UART.
Definition ns16550.h:80
A generic UART.
Definition uart.h:17
struct uart_operations * op
UART operations.
Definition uart.h:29

Define a fixed ISA UART.

Definition at line 37 of file x86_uart.c.

37#define ISA_UART( NAME, BASE ) \
38 static struct ns16550_uart ns16550_ ## NAME = { \
39 .base = ( ( void * ) (BASE) ), \
40 .clock = NS16550_CLK_DEFAULT, \
41 }; \
42 struct uart NAME = { \
43 .refcnt = REF_INIT ( ref_no_free ), \
44 .name = #NAME, \
45 .op = &ns16550_operations, \
46 .priv = &ns16550_ ## NAME, \
47 }

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ ISA_UART() [1/4]

ISA_UART ( com1 ,
COM1_BASE  )

References com1, and COM1_BASE.

◆ ISA_UART() [2/4]

ISA_UART ( com2 ,
COM2_BASE  )

References com2, and COM2_BASE.

◆ ISA_UART() [3/4]

ISA_UART ( com3 ,
COM3_BASE  )

References com3, and COM3_BASE.

◆ ISA_UART() [4/4]

ISA_UART ( com4 ,
COM4_BASE  )

References com4, and COM4_BASE.

◆ uart_register_fixed()

int uart_register_fixed ( void )

Register fixed ISA UARTs.

Register fixed UARTs (when not provided by platform)

Return values
rcReturn status code

Definition at line 60 of file x86_uart.c.

60 {
61 static struct uart *ports[] = { COM1, COM2, COM3, COM4 };
62 unsigned int i;
63 int rc;
64
65 /* Register all fixed ISA UARTs */
66 for ( i = 0 ; i < ( sizeof ( ports ) / sizeof ( ports[0] ) ) ; i++ ) {
67 if ( ( rc = uart_register ( ports[i] ) ) != 0 ) {
68 DBGC ( ports[i], "UART could not register %s: %s\n",
69 ports[i]->name, strerror ( rc ) );
70 return rc;
71 }
72 }
73
74 return 0;
75}
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
#define COM1
Definition ns16550.h:55
#define COM2
Definition ns16550.h:56
#define COM4
Definition ns16550.h:58
#define COM3
Definition ns16550.h:57
const char * name
Definition ath9k_hw.c:1986
#define DBGC(...)
Definition compiler.h:505
char * strerror(int errno)
Retrieve string representation of error number.
Definition strerror.c:79
int uart_register(struct uart *uart)
Register UART.
Definition uart.c:102

References COM1, COM2, COM3, COM4, DBGC, name, rc, strerror(), and uart_register().