iPXE
ns16550.h
Go to the documentation of this file.
1 #ifndef _BITS_NS16550_H
2 #define _BITS_NS16550_H
3 
4 /** @file
5  *
6  * 16550-compatible UART
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 
12 #include <stdint.h>
13 #include <ipxe/io.h>
14 
15 /**
16  * Write to UART register
17  *
18  * @v ns16550 16550 UART
19  * @v address Register address
20  * @v data Data
21  */
22 static inline __attribute__ (( always_inline )) void
23 ns16550_write ( struct ns16550_uart *ns16550, unsigned int address,
25 
26  iowrite8 ( data, ( ns16550->base + address ) );
27 }
28 
29 /**
30  * Read from UART register
31  *
32  * @v ns16550 16550 UART
33  * @v address Register address
34  * @ret data Data
35  */
36 static inline __attribute__ (( always_inline )) uint8_t
37 ns16550_read ( struct ns16550_uart *ns16550, unsigned int address ) {
38 
39  return ioread8 ( ns16550->base + address );
40 }
41 
42 /* Fixed ISA serial port base addresses */
43 #define COM1_BASE 0x3f8
44 #define COM2_BASE 0x2f8
45 #define COM3_BASE 0x3e8
46 #define COM4_BASE 0x2e8
47 
48 /* Fixed ISA serial ports */
49 extern struct uart com1;
50 extern struct uart com2;
51 extern struct uart com3;
52 extern struct uart com4;
53 
54 /* Fixed ISA serial port names */
55 #define COM1 &com1
56 #define COM2 &com2
57 #define COM3 &com3
58 #define COM4 &com4
59 
60 #endif /* _BITS_NS16550_H */
iPXE I/O API
A generic UART.
Definition: uart.h:17
void * base
Register base address.
Definition: ns16550.h:82
uint8_t ioread8(volatile uint8_t *io_addr)
Read byte from I/O-mapped or memory-mapped device.
struct uart com3
static unsigned int address
Definition: ns16550.h:23
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
void iowrite8(uint8_t data, volatile uint8_t *io_addr)
Write byte to I/O-mapped or memory-mapped device.
A 16550-compatible UART.
Definition: ns16550.h:80
unsigned char uint8_t
Definition: stdint.h:10
uint8_t ns16550_read(struct ns16550_uart *ns16550, unsigned int address)
struct uart com4
struct uart com2
static __attribute__((always_inline)) void ns16550_write(struct ns16550_uart *ns16550
Write to UART register.
static unsigned int uint8_t data
Definition: ns16550.h:24
void ns16550_write(struct ns16550_uart *ns16550, unsigned int address, uint8_t data)
Dummy COM1 UART for non-x86 platforms.
struct uart com1