[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
+3 -4
View File
@@ -115,10 +115,9 @@ static void ns16550_flush ( struct uart *uart ) {
* Initialise UART
*
* @v uart UART
* @v baud Baud rate, or zero to leave unchanged
* @ret rc Return status code
*/
static int ns16550_init ( struct uart *uart, unsigned int baud ) {
static int ns16550_init ( struct uart *uart ) {
struct ns16550_uart *ns16550 = uart->priv;
uint8_t dlm;
uint8_t dll;
@@ -137,8 +136,8 @@ static int ns16550_init ( struct uart *uart, unsigned int baud ) {
/* Configure divisor and line control register, if applicable */
ns16550_write ( ns16550, NS16550_LCR,
( NS16550_LCR_8N1 | NS16550_LCR_DLAB ) );
if ( baud ) {
ns16550->divisor = ( ( ns16550->clock / baud ) /
if ( uart->baud ) {
ns16550->divisor = ( ( ns16550->clock / uart->baud ) /
NS16550_CLK_BIT );
dlm = ( ( ns16550->divisor >> 8 ) & 0xff );
dll = ( ( ns16550->divisor >> 0 ) & 0xff );