added rx support
authorGreg Watson <jarrah@users.sourceforge.net>
Sat, 13 Mar 2004 03:40:51 +0000 (03:40 +0000)
committerGreg Watson <jarrah@users.sourceforge.net>
Sat, 13 Mar 2004 03:40:51 +0000 (03:40 +0000)
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@1410 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1

src/console/console.c
src/console/logbuf_console.c
src/console/uart8250_console.c
src/console/vga_console.c
src/include/console/console.h
src/include/uart8250.h
src/lib/uart8250.c

index 5ec936d8ab22488fead77613c52649d24cdb6cce..b97ee8e1d57fa770fa09b358fb4c7e5481302f56 100644 (file)
@@ -52,6 +52,31 @@ void console_tx_byte(unsigned char byte)
        __console_tx_byte(byte);
 }
 
+unsigned char console_rx_byte(void)
+{
+       struct console_driver *driver;
+       if (!initialized)
+               return 0;
+       for(driver = console_drivers; driver < econsole_drivers; driver++)
+               if (driver->tst_byte)
+                       break;
+       if (driver == econsole_drivers)
+               return 0;
+       while (!driver->tst_byte());
+       return driver->rx_byte();
+}
+
+int console_tst_byte(void)
+{
+       struct console_driver *driver;
+       if (!initialized)
+               return 0;
+       for(driver = console_drivers; driver < econsole_drivers; driver++)
+               if (driver->tst_byte)
+                       return driver->tst_byte();
+       return 0;
+}
+
 /*
  *    Write POST information
  */
index e605ae5c23de0327e1a4e0e6d1108e846a61bc4d..00185d383cca3d5866e4b50298d43e627125d9b8 100644 (file)
@@ -16,4 +16,6 @@ static void logbuf_tx_byte(unsigned char byte)
 static struct console_driver __console = {
        .init    = 0,
        .tx_byte = logbuf_tx_byte,
+       .rx_byte = 0,
+       .tst_byte = 0,
 };}
index bb51d0f363386842c22d9f11db25d6ecc710b3f5..333693befbc42998d3e9ca19aba187c32ec748a0 100644 (file)
@@ -43,8 +43,20 @@ void ttyS0_tx_byte(unsigned char data)
        uart8250_tx_byte(TTYS0_BASE, data);
 }
 
+unsigned char ttyS0_rx_byte(void) 
+{
+       return uart8250_rx_byte(TTYS0_BASE);
+}
+
+int ttyS0_tst_byte(unsigned char data) 
+{
+       return uart8250_can_rx_byte(TTYS0_BASE);
+}
+
 static struct console_driver uart8250_console __console = {
        .init    = ttyS0_init,
        .tx_byte = ttyS0_tx_byte,
+       .rx_byte = ttyS0_rx_byte,
+       .tst_byte = ttyS0_tst_byte,
 };
 
index ffd6699529ac2d72b3d0415e85106383e694654a..8dcbe07db198fd1e22858494183bba59ba5a01c1 100644 (file)
@@ -97,4 +97,6 @@ static void vga_tx_byte(unsigned char byte)
 struct console_driver {
        .init    = vga_init,
        .tx_byte = vga_tx_byte,
+       .rx_byte = 0,
+       .tst_byte = 0,
 };
index ffb17d4c9b420dd5b2bedff4cbd4e41daac2ea2e..aeb5895587c99d0c761662ea822da1daa46e7af0 100644 (file)
@@ -7,6 +7,8 @@
 void console_init(void);
 void console_tx_byte(unsigned char byte);
 void console_tx_flush(void);
+unsigned char console_rx_byte(void);
+int console_tst_byte(void);
 void post_code(uint8_t value);
 void die(char *msg);
 
@@ -14,6 +16,8 @@ struct console_driver {
        void (*init)(void);
        void (*tx_byte)(unsigned char byte);
        void (*tx_flush)(void);
+       unsigned char (*rx_byte)(void);
+       int (*tst_byte)(void);
 };
 
 #define __console      __attribute__((unused, __section__ (".rodata.console_drivers")))
index f6100266145b77957753b0d15ccdf535818934d7..dc09315dea0f7b1645262566bb47fb25a1bb97fc 100644 (file)
@@ -6,6 +6,8 @@ struct uart8250 {
        /* Do I need an lcs parameter here? */
 };
 
+unsigned char uart8250_rx_byte(unsigned base_port);
+int uart8250_can_rx_byte(unsigned base_port);
 void uart8250_tx_byte(unsigned base_port, unsigned char data);
 void uart8250_init(unsigned base_port, unsigned divisor, unsigned lcs);
 void init_uart8250(unsigned base_port, struct uart8250 *uart);
index 67b0a95cfb30f81a669a3733b3cce8fee5637f18..e3a1255dc6f6f2277db4f76fc119e9db87280369 100644 (file)
@@ -20,7 +20,7 @@
 #define UART_MSR 0x06
 #define UART_SCR 0x07
 
-static inline int uart8250_can_tx_byte(unsigned base_port)
+static int uart8250_can_tx_byte(unsigned base_port)
 {
        return inb(base_port + UART_LSR) & 0x20;
 }
@@ -45,6 +45,18 @@ void uart8250_tx_byte(unsigned base_port, unsigned char data)
        uart8250_wait_until_sent(base_port);
 }
 
+int uart8250_can_rx_byte(unsigned base_port)
+{
+       return inb(base_port + UART_LSR) & 0x01;
+}
+
+unsigned char uart8250_rx_byte(unsigned base_port)
+{
+       while(!uart8250_can_rx_byte(base_port))
+               ;
+       return inb(base_port + UART_RBR);
+}
+
 void uart8250_init(unsigned base_port, unsigned divisor, unsigned lcs)
 {
        lcs &= 0x7f;