summaryrefslogtreecommitdiffstats
path: root/src/include/ipxe/serial.h
blob: 04347a89e45c137a2d462c9409ca0e2d4cdc54a5 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef _IPXE_SERIAL_H
#define _IPXE_SERIAL_H

/** @file
 *
 * Serial console
 *
 */

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );

#include <ipxe/api.h>
#include <ipxe/uart.h>
#include <config/serial.h>

#ifdef SERIAL_NULL
#define SERIAL_PREFIX_null
#else
#define SERIAL_PREFIX_null __null_
#endif

/**
 * Calculate static inline serial API function name
 *
 * @v _prefix		Subsystem prefix
 * @v _api_func		API function
 * @ret _subsys_func	Subsystem API function
 */
#define SERIAL_INLINE( _subsys, _api_func ) \
	SINGLE_API_INLINE ( SERIAL_PREFIX_ ## _subsys, _api_func )

/**
 * Provide a serial API implementation
 *
 * @v _prefix		Subsystem prefix
 * @v _api_func		API function
 * @v _func		Implementing function
 */
#define PROVIDE_SERIAL( _subsys, _api_func, _func ) \
	PROVIDE_SINGLE_API ( SERIAL_PREFIX_ ## _subsys, _api_func, _func )

/**
 * Provide a static inline serial API implementation
 *
 * @v _prefix		Subsystem prefix
 * @v _api_func		API function
 */
#define PROVIDE_SERIAL_INLINE( _subsys, _api_func ) \
	PROVIDE_SINGLE_API_INLINE ( SERIAL_PREFIX_ ## _subsys, _api_func )

/**
 * Get null serial console UART
 *
 * @ret uart		Serial console UART, or NULL
 */
static inline __always_inline struct uart *
SERIAL_INLINE ( null, default_serial_console ) ( void ) {
	return NULL;
}

/**
 * Get serial console UART
 *
 * @ret uart		Serial console UART, or NULL
 */
struct uart * default_serial_console ( void );

extern struct uart *serial_console;

extern struct uart * fixed_serial_console ( void );

#endif /* _IPXE_SERIAL_H */