[serial] Allow platform to specify mechanism for identifying console

Allow the platform configuration to provide a mechanism for
identifying the serial console UART.  Provide two globally available
mechanisms: "null" (i.e. no serial console), and "fixed" (i.e. use
whatever is specified by COMCONSOLE in config/serial.h).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2025-06-23 16:19:07 +01:00
parent 5d9f20bbd6
commit 2ce1b185b2
7 changed files with 82 additions and 5 deletions

View File

@@ -9,7 +9,61 @@
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;