summaryrefslogtreecommitdiff
path: root/payloads/libpayload/drivers
diff options
context:
space:
mode:
authorJordan Crouse <jordan.crouse@amd.com>2008-06-20 00:01:42 +0000
committerJordan Crouse <jordan.crouse@amd.com>2008-06-20 00:01:42 +0000
commit3b4706591ce3d31628fad8953beba10a97529642 (patch)
tree76d6b65373790bb131ddf2e129d30a5a35048f8a /payloads/libpayload/drivers
parent4e48408059cb07cf1fbf8f74e61cc9dc7b7cd0bf (diff)
libpayload: Support curses for serial
Support the curses interface over serial by supporting a minimal vt100 terminal. Signed-off-by: Jordan Crouse <jordan.crouse@amd.com> Acked-by: Ronald G. Minnich <rminnich@gmail.com> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3370 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'payloads/libpayload/drivers')
-rw-r--r--payloads/libpayload/drivers/serial.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/payloads/libpayload/drivers/serial.c b/payloads/libpayload/drivers/serial.c
index a97e7dd808..f7b12eb561 100644
--- a/payloads/libpayload/drivers/serial.c
+++ b/payloads/libpayload/drivers/serial.c
@@ -35,6 +35,25 @@
#define DIVISOR (115200 / CONFIG_SERIAL_BAUD_RATE)
#endif
+/* This is a hack - we convert the drawing characters to ASCII */
+
+static unsigned char translate_special_chars(unsigned char c)
+{
+ switch(c) {
+ case 196:
+ return '-';
+ case 179:
+ return '|';
+ case 218:
+ case 191:
+ case 192:
+ case 217:
+ return '+';
+ default:
+ return ' ';
+ }
+}
+
void serial_init(void)
{
#ifdef CONFIG_SERIAL_SET_SPEED
@@ -61,6 +80,9 @@ void serial_init(void)
void serial_putchar(unsigned char c)
{
+ if (c > 127)
+ c = translate_special_chars(c);
+
while ((inb(IOBASE + 0x05) & 0x20) == 0) ;
outb(c, IOBASE);
}
@@ -75,3 +97,38 @@ int serial_getchar(void)
while (!serial_havechar()) ;
return (int)inb(IOBASE);
}
+
+/* These are thinly veiled vt100 functions used by curses */
+
+#define VT100_CLEAR "\e[H\e[J"
+#define VT100_SBOLD "\e[7m"
+#define VT100_EBOLD "\e[m"
+#define VT100_CURSOR_ADDR "\e[%d;%dH"
+
+static void serial_putcmd(char *str)
+{
+ while(*str)
+ serial_putchar(*(str++));
+}
+
+void serial_clear(void)
+{
+ serial_putcmd(VT100_CLEAR);
+}
+
+void serial_start_bold(void)
+{
+ serial_putcmd(VT100_SBOLD);
+}
+
+void serial_end_bold(void)
+{
+ serial_putcmd(VT100_EBOLD);
+}
+
+void serial_set_cursor(int y, int x)
+{
+ char buffer[32];
+ snprintf(buffer, sizeof(buffer), VT100_CURSOR_ADDR, y, x);
+ serial_putcmd(buffer);
+}