[uart] Make baud rate a property of the UART

Make the current baud rate (if specified) a property of the UART, to
allow the default_serial_console() function to specify the default
baud rate as well as the default UART device.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2025-11-05 12:16:22 +00:00
parent a786c8d231
commit 08d4d7fe9d
5 changed files with 23 additions and 16 deletions

View File

@@ -95,7 +95,9 @@ struct gdb_transport * gdbserial_configure ( const char *name,
return NULL;
uart_get ( gdbserial_uart );
if ( ( rc = uart_init ( gdbserial_uart, baud ) ) != 0 )
gdbserial_uart->baud = baud;
if ( ( rc = uart_init ( gdbserial_uart ) ) != 0 )
return NULL;
return &serial_gdb_transport;

View File

@@ -74,8 +74,14 @@ struct uart *serial_console = NULL;
* @ret uart Serial console UART, or NULL
*/
static struct uart * serial_comconsole ( void ) {
struct uart *uart = COMCONSOLE;
unsigned int baud = COMSPEED;
return COMCONSOLE;
/* Set default baud rate, if applicable */
if ( uart && baud )
uart->baud = baud;
return uart;
}
/**
@@ -154,9 +160,9 @@ static void serial_init ( void ) {
return;
/* Initialise UART */
if ( ( rc = uart_init ( uart, COMSPEED ) ) != 0 ) {
DBGC ( uart, "SERIAL could not initialise %s baud %d: %s\n",
uart->name, COMSPEED, strerror ( rc ) );
if ( ( rc = uart_init ( uart ) ) != 0 ) {
DBGC ( uart, "SERIAL could not initialise %s: %s\n",
uart->name, strerror ( rc ) );
return;
}

View File

@@ -49,8 +49,7 @@ static uint8_t null_uart_receive ( struct uart *uart __unused ) {
return 0;
}
static int null_uart_init ( struct uart *uart __unused,
unsigned int baud __unused ) {
static int null_uart_init ( struct uart *uart __unused ) {
return 0;
}