[coreboot] New patch to review for coreboot: fdf790b libpayload: Check if serial console h/w is present before using
Dave Frodin (dave.frodin@se-eng.com)
gerrit at coreboot.org
Mon Dec 17 23:32:54 CET 2012
Dave Frodin (dave.frodin at se-eng.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2040
-gerrit
commit fdf790b187d668bb25a88c23919846c70371f08f
Author: Dave Frodin <dave.frodin at se-eng.com>
Date: Sat Dec 15 13:24:02 2012 -0700
libpayload: Check if serial console h/w is present before using
The serial_io_havechar() and serial_io_getchar() functions will
always see keystrokes available if the serial hardware isn't
actually there. We will still output chars to non-existant
hardware to allow virtual hardware to capture them.
Change-Id: I04e85157b6b7a185448abab352b5417a798a397a
Signed-off-by: Dave Frodin <dave.frodin at se-eng.com>
---
payloads/libpayload/drivers/serial.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/payloads/libpayload/drivers/serial.c b/payloads/libpayload/drivers/serial.c
index c0200af..cd00a13 100644
--- a/payloads/libpayload/drivers/serial.c
+++ b/payloads/libpayload/drivers/serial.c
@@ -35,6 +35,8 @@
#define MEMBASE (phys_to_virt(lib_sysinfo.serial->baseaddr))
#define DIVISOR(x) (115200 / x)
+static int serial_io_hardware_is_present = 1;
+
#ifdef CONFIG_SERIAL_SET_SPEED
static void serial_io_hardware_init(int port, int speed, int word_bits, int parity, int stop_bits)
{
@@ -107,6 +109,12 @@ void serial_init(void)
#endif
console_add_input_driver(&consin);
console_add_output_driver(&consout);
+
+ /* check to see if there's actually serial port h/w */
+ if (lib_sysinfo.ser_ioport) {
+ if( (inb(IOBASE + 0x05)==0xFF) && (inb(IOBASE + 0x06)==0xFF) )
+ serial_io_hardware_is_present = 0;
+ }
}
static void serial_io_putchar(unsigned int c)
@@ -118,11 +126,15 @@ static void serial_io_putchar(unsigned int c)
static int serial_io_havechar(void)
{
+ if ( !serial_io_hardware_is_present )
+ return 0;
return inb(IOBASE + 0x05) & 0x01;
}
static int serial_io_getchar(void)
{
+ if ( !serial_io_hardware_is_present )
+ return -1;
while (!serial_io_havechar()) ;
return (int)inb(IOBASE);
}
More information about the coreboot
mailing list