aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--payloads/libpayload/drivers/video/video.c21
-rw-r--r--payloads/libpayload/include/libpayload.h5
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, ...);
/** @} */
/**