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;
* @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;
}
/**
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;
}
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;
}
* 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;
/* 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 );
/** List of registered UARTs */
struct list_head list;
+ /** Baud rate (if specified) */
+ unsigned int baud;
+
/** UART operations */
struct uart_operations *op;
/** Driver-private data */
* Initialise UART
*
* @v uart UART
- * @v baud Baud rate, or zero to leave unchanged
* @ret rc Return status code
*/
- int ( * init ) ( struct uart *uart, unsigned int baud );
+ int ( * init ) ( struct uart *uart );
/**
* Flush transmitted data
*
* Initialise UART
*
* @v uart UART
- * @v baud Baud rate, or zero to leave unchanged
* @ret rc Return status code
*/
static inline __attribute__ (( always_inline )) int
-uart_init ( struct uart *uart, unsigned int baud ) {
+uart_init ( struct uart *uart ) {
- return uart->op->init ( uart, baud );
+ return uart->op->init ( uart );
}
/**