summaryrefslogtreecommitdiffstats
path: root/src/include/bits/ns16550.h
blob: 45e3e978fc50956bd00e776b358cf2dd17c3214e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef _BITS_NS16550_H
#define _BITS_NS16550_H

/** @file
 *
 * 16550-compatible UART
 *
 */

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );

#include <stdint.h>
#include <ipxe/io.h>

/**
 * Write to UART register
 *
 * @v ns16550		16550 UART
 * @v address		Register address
 * @v data		Data
 */
static inline __attribute__ (( always_inline )) void
ns16550_write ( struct ns16550_uart *ns16550, unsigned int address,
		uint8_t data ) {

	iowrite8 ( data, ( ns16550->base + ( address << ns16550->shift ) ) );
}

/**
 * Read from UART register
 *
 * @v ns16550		16550 UART
 * @v address		Register address
 * @ret data		Data
 */
static inline __attribute__ (( always_inline )) uint8_t
ns16550_read ( struct ns16550_uart *ns16550, unsigned int address ) {

	return ioread8 ( ns16550->base + ( address << ns16550->shift ) );
}

#endif /* _BITS_NS16550_H */