diff options
author | Ulf Jordan <jordan@chalmers.se> | 2008-09-03 19:59:44 +0000 |
---|---|---|
committer | Jordan Crouse <jordan.crouse@amd.com> | 2008-09-03 19:59:44 +0000 |
commit | d57a68063234f56bcf7c315e9a5c16bd069e626f (patch) | |
tree | ef350feaeb0c5681ab0d8a95ab4bc94dba39feff /payloads/libpayload/drivers | |
parent | d21f68bbd588f46c23066eb8d227b51e4823de41 (diff) |
Add support for curses color output over serial.
Note that the sequence \e[m for turning off bold resets all attributes,
including color.
Signed-off-by: Ulf Jordan <jordan@chalmers.se>
Acked-by: Jordan Crouse <jordan.crouse@amd.com>
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3561 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'payloads/libpayload/drivers')
-rw-r--r-- | payloads/libpayload/drivers/serial.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/payloads/libpayload/drivers/serial.c b/payloads/libpayload/drivers/serial.c index 6e46e06581..8d7273c3a5 100644 --- a/payloads/libpayload/drivers/serial.c +++ b/payloads/libpayload/drivers/serial.c @@ -110,6 +110,8 @@ int serial_getchar(void) enacs=\E(B\E)0, smacs=^N, rmacs=^O. */ #define VT100_SMACS "\e(0" #define VT100_RMACS "\e(B" +/* A vt100 doesn't do color, setaf/setab below are from xterm-color. */ +#define VT100_SET_COLOR "\e[3%d;4%dm" static void serial_putcmd(char *str) { @@ -142,6 +144,19 @@ void serial_end_altcharset(void) serial_putcmd(VT100_RMACS); } +/** + * Set the foreground and background colors on the serial console. + * + * @param fg Foreground color number. + * @param bg Background color number. + */ +void serial_set_color(short fg, short bg) +{ + char buffer[32]; + snprintf(buffer, sizeof(buffer), VT100_SET_COLOR, fg, bg); + serial_putcmd(buffer); +} + void serial_set_cursor(int y, int x) { char buffer[32]; |