]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[serial] Don't enable serial console without serial support
authorShao Miller <sha0.miller@gmail.com>
Fri, 5 Oct 2012 14:14:12 +0000 (15:14 +0100)
committerMichael Brown <mcb30@ipxe.org>
Fri, 5 Oct 2012 14:18:57 +0000 (15:18 +0100)
serial_console_init() would enable serial console support without
knowing if the serial driver succeeded or not.  As a result, the
serial console would interfere with a normal keyboard on a system
lacking serial support.

Reported-by: Jan ONDREJ (SAL) <ondrejj(at)salstar.sk>
Signed-off-by: Shao Miller <sha0.miller@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/core/serial.c
src/core/serial_console.c
src/include/ipxe/serial.h

index a5551b136f4205c3baeae1927a692fa677d84fd9..8f5a159c44d8a615de2f16652b8c92acf337fde6 100644 (file)
@@ -93,6 +93,9 @@ FILE_LICENCE ( GPL2_OR_LATER );
 #define uart_writeb(val,addr) outb((val),(addr))
 #endif
 
+/* Boolean for the state of serial driver initialization */
+int serial_initialized = 0;
+
 /*
  * void serial_putc(int ch);
  *     Write character `ch' to port UART_BASE.
@@ -207,7 +210,6 @@ static void serial_init ( void ) {
        /* Set clear to send, so flow control works... */
        uart_writeb((1<<1), UART_BASE + UART_MCR);
 
-
        /* Flush the input buffer. */
        do {
                /* rx buffer reg
@@ -217,6 +219,9 @@ static void serial_init ( void ) {
                /* line status reg */
                status = uart_readb(UART_BASE + UART_LSR);
        } while(status & UART_LSR_DR);
+
+       /* Note that serial support has been initialized */
+       serial_initialized = 1;
  out:
        return;
 }
index bbddd6b29a1a21dcd34840163af0521e09ca81ce..3852a308c9b9a3100e1eea1d84176b71e01ae120 100644 (file)
 struct console_driver serial_console __console_driver;
 
 static void serial_console_init ( void ) {
-       /* Serial driver initialization should already be done,
-        * time to enable the serial console. */
-       serial_console.disabled = 0;
+       /*
+        * Check if serial driver initialization is done.
+        * If so, it's time to enable the serial console.
+        */
+       if ( serial_initialized )
+               serial_console.disabled = 0;
 }
 
 struct console_driver serial_console __console_driver = {
index c16e56ae6ab4b4a317fbbe4b5a4b8102f26301e6..b47b1d1252b78aa779409076ee8e44d32fa84fc6 100644 (file)
@@ -12,5 +12,6 @@ FILE_LICENCE ( GPL2_OR_LATER );
 extern void serial_putc ( int ch );
 extern int serial_getc ( void );
 extern int serial_ischar ( void );
+extern int serial_initialized;
 
 #endif /* _IPXE_SERIAL_H */