Skip to content

Commit

Permalink
[serial] Don't enable serial console without serial support
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Shao Miller authored and mcb30 committed Oct 5, 2012
1 parent fcdfe81 commit a712dae
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/core/serial.c
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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;
}
Expand Down
9 changes: 6 additions & 3 deletions src/core/serial_console.c
Expand Up @@ -18,9 +18,12 @@
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 = {
Expand Down
1 change: 1 addition & 0 deletions src/include/ipxe/serial.h
Expand Up @@ -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 */

0 comments on commit a712dae

Please sign in to comment.