mirror of
https://github.com/ipxe/ipxe
synced 2025-12-12 14:32:49 +03:00
[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:
@@ -28,6 +28,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#define FDT_EFI
|
||||
#define MPAPI_EFI
|
||||
#define NAP_EFI
|
||||
#define SERIAL_FIXED
|
||||
|
||||
#define NET_PROTO_IPV6 /* IPv6 protocol */
|
||||
#define NET_PROTO_LLDP /* Link Layer Discovery protocol */
|
||||
|
||||
@@ -24,6 +24,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
||||
#define DMAAPI_FLAT
|
||||
#define ACPI_LINUX
|
||||
#define MPAPI_NULL
|
||||
#define SERIAL_NULL
|
||||
|
||||
#define DRIVERS_LINUX
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#define REBOOT_PCBIOS
|
||||
#define ACPI_RSDP
|
||||
#define MPAPI_PCBIOS
|
||||
#define SERIAL_FIXED
|
||||
|
||||
#ifdef __x86_64__
|
||||
#define IOMAP_PAGES
|
||||
|
||||
@@ -25,6 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#define REBOOT_SBI
|
||||
#define UMALLOC_UHEAP
|
||||
#define MEMMAP_FDT
|
||||
#define SERIAL_NULL
|
||||
|
||||
#define ACPI_NULL
|
||||
#define MPAPI_NULL
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER );
|
||||
|
||||
#include <config/defaults.h>
|
||||
|
||||
#define COMCONSOLE COM1 /* I/O port address */
|
||||
|
||||
/* Keep settings from a previous user of the serial port (e.g. lilo or
|
||||
|
||||
@@ -45,6 +45,12 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#define CONSOLE_SERIAL ( CONSOLE_USAGE_ALL & ~CONSOLE_USAGE_LOG )
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_FIXED
|
||||
#define SERIAL_PREFIX_fixed
|
||||
#else
|
||||
#define SERIAL_PREFIX_fixed __fixed_
|
||||
#endif
|
||||
|
||||
/* Serial console UART */
|
||||
#ifndef COMCONSOLE
|
||||
#define COMCONSOLE NULL
|
||||
@@ -55,12 +61,19 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#define COMSPEED 0
|
||||
#endif
|
||||
|
||||
/** Default serial console UART */
|
||||
static struct uart * const default_serial_console = COMCONSOLE;
|
||||
|
||||
/** Active serial console UART */
|
||||
struct uart *serial_console;
|
||||
|
||||
/**
|
||||
* Get fixed serial console UART
|
||||
*
|
||||
* @ret uart Serial console UART, or NULL
|
||||
*/
|
||||
static struct uart * serial_comconsole ( void ) {
|
||||
|
||||
return COMCONSOLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a character to serial console
|
||||
*
|
||||
@@ -128,10 +141,11 @@ struct console_driver serial_console_driver __console_driver = {
|
||||
|
||||
/** Initialise serial console */
|
||||
static void serial_init ( void ) {
|
||||
struct uart *uart = default_serial_console;
|
||||
struct uart *uart;
|
||||
int rc;
|
||||
|
||||
/* Do nothing if we have no default port */
|
||||
/* Get default serial console, if any */
|
||||
uart = default_serial_console();
|
||||
if ( ! uart )
|
||||
return;
|
||||
|
||||
@@ -174,3 +188,6 @@ struct startup_fn serial_startup_fn __startup_fn ( STARTUP_EARLY ) = {
|
||||
.name = "serial",
|
||||
.shutdown = serial_shutdown,
|
||||
};
|
||||
|
||||
PROVIDE_SERIAL_INLINE ( null, default_serial_console );
|
||||
PROVIDE_SERIAL ( fixed, default_serial_console, serial_comconsole );
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user