]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[uart] Remove ability to use frame formats other than 8n1
authorMichael Brown <mcb30@ipxe.org>
Tue, 17 Jun 2025 14:44:12 +0000 (15:44 +0100)
committerMichael Brown <mcb30@ipxe.org>
Tue, 17 Jun 2025 14:44:12 +0000 (15:44 +0100)
In the context of serial consoles, the use of any frame formats other
than the standard 8 data bits, no parity, and one stop bit is so rare
as to be nonexistent.

Remove the almost certainly unused support for custom frame formats.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/config/serial.h
src/core/gdbserial.c
src/core/serial.c
src/core/uart.c
src/include/ipxe/gdbserial.h
src/include/ipxe/uart.h

index 09068d8e015ee32f7fb7c21a8f2ed0c165bc861e..69d8d8ef33affa6598ee8c5d8e51ed2aba6934c2 100644 (file)
@@ -16,15 +16,12 @@ FILE_LICENCE ( GPL2_OR_LATER );
 #define        COMCONSOLE      COM1            /* I/O port address */
 
 /* Keep settings from a previous user of the serial port (e.g. lilo or
- * LinuxBIOS), ignoring COMSPEED, COMDATA, COMPARITY and COMSTOP.
+ * LinuxBIOS), ignoring COMSPEED.
  */
 #undef COMPRESERVE
 
 #ifndef COMPRESERVE
 #define        COMSPEED        115200          /* Baud rate */
-#define        COMDATA         8               /* Data bits */
-#define        COMPARITY       0               /* Parity: 0=None, 1=Odd, 2=Even */
-#define        COMSTOP         1               /* Stop bits */
 #endif
 
 /* Early UART configuration (for bare metal prefix debugging only) */
index 0983f255743154ebe25cec594d214a7bbeb1f2dd..1edc2810962c9e11bf7fdb05dcb84c09e7ccc6cd 100644 (file)
@@ -46,13 +46,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 #define GDBSERIAL_BAUD COMSPEED
 #endif
 
-/* UART line control register value */
-#ifdef COMPRESERVE
-#define GDBSERIAL_LCR 0
-#else
-#define GDBSERIAL_LCR UART_LCR_WPS ( COMDATA, COMPARITY, COMSTOP )
-#endif
-
 /** GDB serial UART */
 static struct uart gdbserial_uart;
 
@@ -90,7 +83,7 @@ static int gdbserial_init ( int argc, char **argv ) {
                return 1;
        }
 
-       if ( ! gdbserial_configure ( port, GDBSERIAL_BAUD, GDBSERIAL_LCR ) ) {
+       if ( ! gdbserial_configure ( port, GDBSERIAL_BAUD ) ) {
                printf ( "serial: unable to configure\n" );
                return 1;
        }
@@ -106,13 +99,13 @@ struct gdb_transport serial_gdb_transport __gdb_transport = {
 };
 
 struct gdb_transport * gdbserial_configure ( unsigned int port,
-                                            unsigned int baud, uint8_t lcr ) {
+                                            unsigned int baud ) {
        int rc;
 
        if ( ( rc = uart_select ( &gdbserial_uart, port ) ) != 0 )
                return NULL;
 
-       if ( ( rc = uart_init ( &gdbserial_uart, baud, lcr ) ) != 0 )
+       if ( ( rc = uart_init ( &gdbserial_uart, baud ) ) != 0 )
                return NULL;
 
        return &serial_gdb_transport;
index bef9ccbab232af349fd6139a3922fd0a27ca0722..2866681a8d0df1ecd1df5c3f4635754601939bc3 100644 (file)
@@ -58,13 +58,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 #define CONSOLE_BAUD COMSPEED
 #endif
 
-/* UART line control register value */
-#ifdef COMPRESERVE
-#define CONSOLE_LCR 0
-#else
-#define CONSOLE_LCR UART_LCR_WPS ( COMDATA, COMPARITY, COMSTOP )
-#endif
-
 /** Serial console UART */
 struct uart serial_console;
 
@@ -149,10 +142,9 @@ static void serial_init ( void ) {
        }
 
        /* Initialise UART */
-       if ( ( rc = uart_init ( &serial_console, CONSOLE_BAUD,
-                               CONSOLE_LCR ) ) != 0 ) {
-               DBG ( "Could not initialise UART %d baud %d LCR %#02x: %s\n",
-                     CONSOLE_PORT, CONSOLE_BAUD, CONSOLE_LCR, strerror ( rc ));
+       if ( ( rc = uart_init ( &serial_console, CONSOLE_BAUD ) ) != 0 ) {
+               DBG ( "Could not initialise UART %d baud %d: %s\n",
+                     CONSOLE_PORT, CONSOLE_BAUD, strerror ( rc ) );
                return;
        }
 }
index b85fe0767c1a792806cac38d5b157a28ddc0bd48..4dc307fce9db32a66d8537f50360a50ef722ce25 100644 (file)
@@ -107,10 +107,9 @@ int uart_exists ( struct uart *uart ) {
  *
  * @v uart             UART
  * @v baud             Baud rate, or zero to leave unchanged
- * @v lcr              Line control register value, or zero to leave unchanged
  * @ret rc             Return status code
  */
-int uart_init ( struct uart *uart, unsigned int baud, uint8_t lcr ) {
+int uart_init ( struct uart *uart, unsigned int baud ) {
        uint8_t dlm;
        uint8_t dll;
        int rc;
@@ -120,10 +119,7 @@ int uart_init ( struct uart *uart, unsigned int baud, uint8_t lcr ) {
                return rc;
 
        /* Configure divisor and line control register, if applicable */
-       if ( ! lcr )
-               lcr = uart_read ( uart, UART_LCR );
-       uart->lcr = lcr;
-       uart_write ( uart, UART_LCR, ( lcr | UART_LCR_DLAB ) );
+       uart_write ( uart, UART_LCR, ( UART_LCR_8N1 | UART_LCR_DLAB ) );
        if ( baud ) {
                uart->divisor = ( UART_MAX_BAUD / baud );
                dlm = ( ( uart->divisor >> 8 ) & 0xff );
@@ -135,7 +131,7 @@ int uart_init ( struct uart *uart, unsigned int baud, uint8_t lcr ) {
                dll = uart_read ( uart, UART_DLL );
                uart->divisor = ( ( dlm << 8 ) | dll );
        }
-       uart_write ( uart, UART_LCR, ( lcr & ~UART_LCR_DLAB ) );
+       uart_write ( uart, UART_LCR, UART_LCR_8N1 );
 
        /* Disable interrupts */
        uart_write ( uart, UART_IER, 0 );
index e1040c94e62013378f1c5baa5a23c9ea12b208ca..166eb4f0da1018ad72a1fe035487151201565497 100644 (file)
@@ -9,12 +9,9 @@
 
 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 
-#include <stdint.h>
-
 struct gdb_transport;
 
 extern struct gdb_transport * gdbserial_configure ( unsigned int port,
-                                                   unsigned int baud,
-                                                   uint8_t lcr );
+                                                   unsigned int baud );
 
 #endif /* _IPXE_GDBSERIAL_H */
index c63eae61549ef072b64f33daf6e2f8e9d9a34427..86583ee2fe16e3af28cdfc80ca2cd7a9ab1a170d 100644 (file)
@@ -82,8 +82,6 @@ struct uart {
        void *base;
        /** Baud rate divisor */
        uint16_t divisor;
-       /** Line control register */
-       uint8_t lcr;
 };
 
 /** Symbolic names for port indexes */
@@ -127,6 +125,6 @@ static inline uint8_t uart_receive ( struct uart *uart ) {
 extern void uart_transmit ( struct uart *uart, uint8_t data );
 extern void uart_flush ( struct uart *uart );
 extern int uart_exists ( struct uart *uart );
-extern int uart_init ( struct uart *uart, unsigned int baud, uint8_t lcr );
+extern int uart_init ( struct uart *uart, unsigned int baud );
 
 #endif /* _IPXE_UART_H */