aboutsummaryrefslogtreecommitdiff
path: root/payloads/libpayload/libc
diff options
context:
space:
mode:
authorPatrick Georgi <patrick.georgi@coresystems.de>2008-10-21 15:08:18 +0000
committerPatrick Georgi <patrick.georgi@coresystems.de>2008-10-21 15:08:18 +0000
commit657a6dc390871721711c2becc8501d05095891e5 (patch)
tree145b4de959fa8b76f5585ea85b1c5960e76d37c9 /payloads/libpayload/libc
parent97f56a4b7e36a49f8d7d24dcf741df1c181f13cb (diff)
This patch removes most of the #ifdefs in libc/console.c, and
replaces it with two queues (input, output) where drivers (serial, keyboard, video, usb) can attach. The only things left with #ifdefs are initialization (at some point the drivers must get a chance to register) Signed-off-by: Patrick Georgi <patrick.georgi@coresystems.de> Acked-by: Jordan Crouse <jordan.crouse@amd.com> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3679 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'payloads/libpayload/libc')
-rw-r--r--payloads/libpayload/libc/console.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/payloads/libpayload/libc/console.c b/payloads/libpayload/libc/console.c
index ff6fc13e8e..8b09c44d51 100644
--- a/payloads/libpayload/libc/console.c
+++ b/payloads/libpayload/libc/console.c
@@ -31,6 +31,21 @@
#include <libpayload.h>
#include <usb/usb.h>
+struct console_output_driver *console_out;
+struct console_input_driver *console_in;
+
+void console_add_output_driver(struct console_output_driver *out)
+{
+ out->next = console_out;
+ console_out = out;
+}
+
+void console_add_input_driver(struct console_input_driver *in)
+{
+ in->next = console_in;
+ console_in = in;
+}
+
void console_init(void)
{
#ifdef CONFIG_VIDEO_CONSOLE
@@ -46,15 +61,12 @@ void console_init(void)
static void device_putchar(unsigned char c)
{
-#ifdef CONFIG_VIDEO_CONSOLE
- video_console_putchar(0x700| c);
-#endif
-#ifdef CONFIG_SERIAL_CONSOLE
- serial_putchar(c);
-#endif
+ struct console_output_driver *out;
+ for (out = console_out; out != 0; out = out->next)
+ out->putchar(c);
}
-int putchar(int c)
+int putchar(unsigned int c)
{
c &= 0xff;
if (c == '\n')
@@ -78,19 +90,13 @@ int puts(const char *s)
int havekey(void)
{
-#ifdef CONFIG_USB_HID
+#ifdef CONFIG_USB
usb_poll();
- if (usbhid_havechar())
- return 1;
-#endif
-#ifdef CONFIG_SERIAL_CONSOLE
- if (serial_havechar())
- return 1;
-#endif
-#ifdef CONFIG_PC_KEYBOARD
- if (keyboard_havechar())
- return 1;
#endif
+ struct console_input_driver *in;
+ for (in = console_in; in != 0; in = in->next)
+ if (in->havekey())
+ return 1;
return 0;
}
@@ -101,19 +107,13 @@ int havekey(void)
int getchar(void)
{
while (1) {
-#ifdef CONFIG_USB_HID
+#ifdef CONFIG_USB
usb_poll();
- if (usbhid_havechar())
- return usbhid_getchar();
-#endif
-#ifdef CONFIG_SERIAL_CONSOLE
- if (serial_havechar())
- return serial_getchar();
-#endif
-#ifdef CONFIG_PC_KEYBOARD
- if (keyboard_havechar())
- return keyboard_getchar();
#endif
+ struct console_input_driver *in = console_in;
+ for (in = console_in; in != 0; in = in->next)
+ if (in->havechar())
+ return in->getchar();
}
}