diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2015-07-31 15:22:58 -0700 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2015-09-08 11:51:26 +0000 |
commit | abe03d25e2890eec96df5b8e8372a9b5a1ffd1d0 (patch) | |
tree | 5964ace587015e7a67e303c8521042859033f014 /payloads/libpayload | |
parent | 4bd65e1c0cd53802abd3598c03d28b82a11be46d (diff) | |
download | coreboot-abe03d25e2890eec96df5b8e8372a9b5a1ffd1d0.tar.xz |
video: add video_printf
video_printf prints strings on the screen with specified foreground and
background color.
BUG=none
BRANCH=smaug
TEST=verified messages printed on Smaug
Change-Id: I619625f7d4c5bc19cd9de64a0ba07899cf9ba289
Signed-off-by: Patrick Georgi <patrick@georgi-clan.de>
Original-Commit-Id: e0ac4cb4c0d43b40f5c8f8f5a90eac45b0263b77
Original-Reviewed-on: https://chromium-review.googlesource.com/290130
Original-Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Original-(cherry picked from commit 75ea2c025d629c8fabc0cb859c4e8ab8ba6ce6e3)
Original-Change-Id: Ief6d1fc820330b54f37ad9260cf3119853460b70
Original-Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/290373
Reviewed-on: http://review.coreboot.org/11407
Tested-by: build bot (Jenkins)
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'payloads/libpayload')
-rw-r--r-- | payloads/libpayload/drivers/video/video.c | 21 | ||||
-rw-r--r-- | payloads/libpayload/include/libpayload.h | 5 |
2 files changed, 26 insertions, 0 deletions
diff --git a/payloads/libpayload/drivers/video/video.c b/payloads/libpayload/drivers/video/video.c index 834a121e19..f183517881 100644 --- a/payloads/libpayload/drivers/video/video.c +++ b/payloads/libpayload/drivers/video/video.c @@ -162,6 +162,27 @@ void video_console_putchar(unsigned int ch) video_console_fixup_cursor(); } +void video_printf(int foreground, int background, const char *fmt, ...) +{ + int i = 0, len; + char str[200]; + + va_list ap; + va_start(ap, fmt); + len = vsnprintf(str, ARRAY_SIZE(str), fmt, ap); + va_end(ap); + if (len <= 0) + return; + + foreground &= 0xf; + foreground <<= 8; + background &= 0xf; + background <<= 12; + + while (str[i]) + video_console_putchar(str[i++] | foreground | background); +} + void video_console_get_cursor(unsigned int *x, unsigned int *y, unsigned int *en) { *x=0; diff --git a/payloads/libpayload/include/libpayload.h b/payloads/libpayload/include/libpayload.h index 5e787e1ff7..3ae3590558 100644 --- a/payloads/libpayload/include/libpayload.h +++ b/payloads/libpayload/include/libpayload.h @@ -206,6 +206,11 @@ void video_console_clear(void); void video_console_cursor_enable(int state); void video_console_get_cursor(unsigned int *x, unsigned int *y, unsigned int *en); void video_console_set_cursor(unsigned int cursorx, unsigned int cursory); +/* + * print characters on video console with colors. note that there is a size + * restriction for the internal buffer. so, output string can be truncated. + */ +void video_printf(int foreground, int background, const char *fmt, ...); /** @} */ /** |