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
This commit is contained in:
Patrick Georgi
2008-10-21 15:08:18 +00:00
parent 97f56a4b7e
commit 657a6dc390
6 changed files with 89 additions and 32 deletions

View File

@@ -326,6 +326,11 @@ int keyboard_add_reset_handler(void (*new_handler)(void))
return 0;
}
static struct console_input_driver cons = {
.havekey = keyboard_havechar,
.getchar = keyboard_getchar
};
void keyboard_init(void)
{
u8 mode;
@@ -350,5 +355,7 @@ void keyboard_init(void)
/* Write the new mode */
keyboard_set_mode(mode);
console_add_input_driver(&cons);
}

View File

@@ -58,15 +58,27 @@ void serial_hardware_init(int port, int speed, int word_bits, int parity, int st
outb(reg &= ~0x80, port + 0x03);
}
static struct console_input_driver consin = {
.havekey = serial_havechar,
.getchar = serial_getchar
};
static struct console_output_driver consout = {
.putchar = serial_putchar
};
void serial_init(void)
{
#ifdef CONFIG_SERIAL_SET_SPEED
serial_hardware_init(IOBASE, CONFIG_SERIAL_BAUD_RATE, 8, 0, 1);
#endif
console_add_input_driver(&consin);
console_add_output_driver(&consout);
}
void serial_putchar(unsigned char c)
void serial_putchar(unsigned int c)
{
c &= 0xff;
while ((inb(IOBASE + 0x05) & 0x20) == 0) ;
outb(c, IOBASE);
}

View File

@@ -145,10 +145,21 @@ usb_hid_set_protocol (usbdev_t *dev, interface_descriptor_t *interface, hid_prot
dev->controller->control (dev, OUT, sizeof (dev_req_t), &dr, 0, 0);
}
static struct console_input_driver cons = {
.havekey = usbhid_havechar,
.getchar = usbhid_getchar
};
void
usb_hid_init (usbdev_t *dev)
{
static int installed = 0;
if (!installed) {
installed = 1;
console_add_input_driver (&cons);
}
configuration_descriptor_t *cd = (configuration_descriptor_t*)dev->configuration;
interface_descriptor_t *interface = (interface_descriptor_t*)(((char *) cd) + cd->bLength);

View File

@@ -111,6 +111,11 @@ void video_console_putc(u8 row, u8 col, unsigned int ch)
void video_console_putchar(unsigned int ch)
{
/* replace black-on-black with light-gray-on-black.
do it here, instead of in libc/console.c */
if ((ch & 0xFF00) == 0) {
ch |= 0x0700;
}
switch(ch & 0xFF) {
case '\r':
cursorx = 0;
@@ -165,6 +170,10 @@ void video_console_set_cursor(unsigned int x, unsigned int y)
video_console_fixup_cursor();
}
static struct console_output_driver cons = {
.putchar = video_console_putchar
};
int video_console_init(void)
{
int i;
@@ -187,6 +196,8 @@ int video_console_init(void)
return 0;
}
console_add_output_driver(&cons);
return 0;
}