summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Crouse <jordan.crouse@amd.com>2008-04-10 22:49:02 +0000
committerJordan Crouse <jordan.crouse@amd.com>2008-04-10 22:49:02 +0000
commit30939bdffd0435df4aa0830b2da1ef06ceebfba3 (patch)
tree12c08ea67c3c6756c7959813a043f075844d09fa
parentbac89d088cf102851122925b31404b7ae52c21c3 (diff)
downloadcoreboot-30939bdffd0435df4aa0830b2da1ef06ceebfba3.tar.xz
libpayload: Add video console framework
Add a framework for multiple video console drivers. This is to prepare for the Geode driver. Signed-off-by: Jordan Crouse <jordan.crouse@amd.com> Acked-by: Uwe Hermann <uwe@hermann-uwe.de> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3230 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
-rw-r--r--payloads/libpayload/Config.in10
-rw-r--r--payloads/libpayload/curses/local.h2
-rw-r--r--payloads/libpayload/curses/tinycurses.c9
-rw-r--r--payloads/libpayload/drivers/Makefile.inc5
-rw-r--r--payloads/libpayload/drivers/vga.c212
-rw-r--r--payloads/libpayload/drivers/video/vga.c140
-rw-r--r--payloads/libpayload/drivers/video/video.c160
-rw-r--r--payloads/libpayload/include/libpayload.h15
-rw-r--r--payloads/libpayload/include/video_console.h47
-rw-r--r--payloads/libpayload/libc/console.c8
10 files changed, 374 insertions, 234 deletions
diff --git a/payloads/libpayload/Config.in b/payloads/libpayload/Config.in
index fbb477ed7f..f02b366ed2 100644
--- a/payloads/libpayload/Config.in
+++ b/payloads/libpayload/Config.in
@@ -59,13 +59,17 @@ config SERIAL_BAUD_RATE
depends SERIAL_SET_SPEED
default 115200
-config VGA_CONSOLE
- bool "See output on a VGA console"
+config VIDEO_CONSOLE
+ bool "See output on a video console"
+ default y
+
+config VGA_VIDEO_CONSOLE
+ bool "VGA video console driver"
+ depends on VIDEO_CONSOLE
default y
config PC_KEYBOARD
bool "Allow input from a PC keyboard"
- depends VGA_CONSOLE
default y
config NVRAM
diff --git a/payloads/libpayload/curses/local.h b/payloads/libpayload/curses/local.h
index 577fcd4000..7e1fb64b93 100644
--- a/payloads/libpayload/curses/local.h
+++ b/payloads/libpayload/curses/local.h
@@ -69,7 +69,7 @@
/* Flags used to determine what output methods are available */
-#ifdef CONFIG_VGA_CONSOLE
+#ifdef CONFIG_VIDEO_CONSOLE
#define F_ENABLE_CONSOLE 0x01
#else
#define F_ENABLE_CONSOLE 0x00
diff --git a/payloads/libpayload/curses/tinycurses.c b/payloads/libpayload/curses/tinycurses.c
index 9b87ec0828..8fc9bde268 100644
--- a/payloads/libpayload/curses/tinycurses.c
+++ b/payloads/libpayload/curses/tinycurses.c
@@ -219,9 +219,10 @@ WINDOW *initscr(void)
// def_prog_mode();
if (curses_flags & F_ENABLE_CONSOLE) {
- /* Clear the screen and kill the cursor. */
- vga_clear();
- vga_cursor_enable(0);
+ /* Clear the screen and kill the cursor */
+
+ video_console_clear();
+ video_console_cursor_enable(0);
}
// Speaker init?
@@ -586,7 +587,7 @@ int wnoutrefresh(WINDOW *win)
* but this will break wide characters!
*/
c |= (chtype) (win->_line[y].text[x].chars[0] & 0xff);
- vga_putc(y, x, c);
+ video_console_putc(y, x, c);
}
}
}
diff --git a/payloads/libpayload/drivers/Makefile.inc b/payloads/libpayload/drivers/Makefile.inc
index 9f436da79c..746ba45255 100644
--- a/payloads/libpayload/drivers/Makefile.inc
+++ b/payloads/libpayload/drivers/Makefile.inc
@@ -29,6 +29,9 @@
##
TARGETS-$(CONFIG_SERIAL_CONSOLE) += drivers/serial.o
-TARGETS-$(CONFIG_VGA_CONSOLE) += drivers/vga.o
TARGETS-$(CONFIG_PC_KEYBOARD) += drivers/keyboard.o
TARGETS-$(CONFIG_NVRAM) += drivers/nvram.o
+
+# Video console drivers
+TARGETS-$(CONFIG_VIDEO_CONSOLE) += drivers/video/video.o
+TARGETS-$(CONFIG_VGA_VIDEO_CONSOLE) += drivers/video/vga.o
diff --git a/payloads/libpayload/drivers/vga.c b/payloads/libpayload/drivers/vga.c
deleted file mode 100644
index db1cda170b..0000000000
--- a/payloads/libpayload/drivers/vga.c
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * This file is part of the libpayload project.
- *
- * Copyright (C) 2008 Advanced Micro Devices, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <arch/types.h>
-#include <libpayload.h>
-
-#define WIDTH 80
-#define HEIGHT 25
-
-#define VGA_COLOR_WHITE 7
-
-#define CRTC_INDEX 0x3d4
-#define CRTC_DATA 0x3d5
-
-#define VIDEO(_r, _c) \
- ((uint16_t *) (0xB8000 + ((_r) * (WIDTH * 2)) + ((_c) * 2)))
-
-static int cursor_enabled;
-static int cursorx;
-static int cursory;
-
-static void vga_scroll_up(void);
-
-static inline uint8_t crtc_read(uint8_t index)
-{
- outb(index, CRTC_INDEX);
- return inb(CRTC_DATA);
-}
-
-static inline void crtc_write(uint8_t data, uint8_t index)
-{
- outb(index, CRTC_INDEX);
- outb(data, CRTC_DATA);
-}
-
-static void vga_get_cursor_pos(void)
-{
- unsigned int addr;
-
- addr = ((unsigned int)crtc_read(0x0E)) << 8;
- addr += crtc_read(0x0F);
-
- cursorx = addr % WIDTH;
- cursory = addr / WIDTH;
-}
-
-static void vga_fixup_cursor(void)
-{
- unsigned int addr;
-
- if (!cursor_enabled)
- return;
-
- if (cursorx < 0)
- cursorx = 0;
-
- if (cursory < 0)
- cursory = 0;
-
- if (cursorx >= WIDTH) {
- cursorx = 0;
- cursory++;
- }
-
- while (cursory >= HEIGHT)
- vga_scroll_up();
-
- addr = cursorx + (WIDTH * cursory);
- crtc_write(addr >> 8, 0x0E);
- crtc_write(addr, 0x0F);
-}
-
-void vga_cursor_enable(int state)
-{
- unsigned char tmp = crtc_read(0x0a);
-
- if (state == 0) {
- tmp |= (1 << 5);
- cursor_enabled = 0;
- } else {
- tmp &= ~(1 << 5);
- cursor_enabled = 1;
- vga_fixup_cursor();
- }
-
- crtc_write(tmp, 0x0a);
-}
-
-void vga_clear_line(uint8_t row, uint8_t ch, uint8_t attr)
-{
- int col;
- uint16_t *ptr = VIDEO(row, 0);
-
- for (col = 0; col < WIDTH; col++)
- ptr[col] = ((attr & 0xFF) << 8) | (ch & 0xFF);
-}
-
-static void vga_scroll_up(void)
-{
- uint16_t *src = VIDEO(1, 0);
- uint16_t *dst = VIDEO(0, 0);
- int i;
-
- for (i = 0; i < (HEIGHT - 1) * WIDTH; i++)
- *dst++ = *src++;
-
- vga_clear_line(HEIGHT - 1, ' ', VGA_COLOR_WHITE);
- cursory--;
-}
-
-void vga_fill(uint8_t ch, uint8_t attr)
-{
- uint8_t row;
- for (row = 0; row < HEIGHT; row++)
- vga_clear_line(row, ch, attr);
-}
-
-void vga_clear(void)
-{
- vga_fill(' ', VGA_COLOR_WHITE);
- vga_move_cursor(0, 0);
-}
-
-void vga_putc(uint8_t row, uint8_t col, unsigned int c)
-{
- uint16_t *ptr = VIDEO(row, col);
- *ptr = (uint16_t) (c & 0xFFFF);
-}
-
-void vga_putchar(unsigned int ch)
-{
-
- uint16_t *ptr;
-
- switch (ch & 0xFF) {
- case '\r':
- cursorx = 0;
- break;
- case '\n':
- cursory++;
- break;
- case '\b':
- cursorx--;
- ptr = VIDEO(cursory, cursorx);
- *ptr = (*ptr & 0xFF00) | ' ';
- break;
- case '\t':
- cursorx = (cursorx + 8) & ~7;
- break;
-
- default:
- ptr = VIDEO(cursory, cursorx);
- *ptr = (uint16_t) (ch & 0xFFFF);
- cursorx++;
- break;
- }
-
- vga_fixup_cursor();
-}
-
-void vga_move_cursor(int x, int y)
-{
- cursorx = x;
- cursory = y;
-
- vga_fixup_cursor();
-}
-
-void vga_init(void)
-{
- /* Get the position of the cursor. */
- vga_get_cursor_pos();
-
- /* See if it currently enabled or not. */
- cursor_enabled = !(crtc_read(0x0A) & (1 << 5));
-
- /* If the cursor is enabled, get us to a sane point. */
- if (cursor_enabled) {
- /* Go to the next line. */
- if (cursorx) {
- cursorx = 0;
- cursory++;
- }
- vga_fixup_cursor();
- }
-}
diff --git a/payloads/libpayload/drivers/video/vga.c b/payloads/libpayload/drivers/video/vga.c
new file mode 100644
index 0000000000..388c7b1ee7
--- /dev/null
+++ b/payloads/libpayload/drivers/video/vga.c
@@ -0,0 +1,140 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2008 Advanced Micro Devices, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <libpayload.h>
+#include <video_console.h>
+
+#define VGA_COLOR_WHITE 7
+
+#define CRTC_INDEX 0x3d4
+#define CRTC_DATA 0x3d5
+
+#define VIDEO(_r, _c)\
+ ((u16 *) (0xB8000 + ((_r) * (VIDEO_COLS * 2)) + ((_c) * 2)))
+
+static u8 crtc_read(u8 index)
+{
+ outb(index, CRTC_INDEX);
+ return inb(CRTC_DATA);
+}
+
+static void crtc_write(u8 data, u8 index)
+{
+ outb(index, CRTC_INDEX);
+ outb(data, CRTC_DATA);
+}
+
+static void vga_get_cursor(unsigned int *x, unsigned int *y, unsigned int *en)
+{
+ unsigned int addr;
+ addr = ((unsigned int) crtc_read(0x0E)) << 8;
+ addr += crtc_read(0x0E);
+
+ *x = addr % VIDEO_COLS;
+ *y = addr / VIDEO_COLS;
+
+ *en = !(crtc_read(0x0A) & (1 << 5));
+}
+
+static void vga_set_cursor(unsigned int x, unsigned int y)
+{
+ unsigned int addr;
+
+ addr = x + (VIDEO_COLS * y);
+ crtc_write(addr >> 8, 0x0E);
+ crtc_write(addr, 0x0E);
+}
+
+static void vga_enable_cursor(int state)
+{
+ unsigned char tmp = crtc_read(0x0a);
+
+ if (state == 0)
+ tmp |= (1 << 5);
+
+ else
+ tmp &= ~(1 << 5);
+
+ crtc_write(tmp, 0x0a);
+}
+
+static void vga_clear_line(u8 row, u8 ch, u8 attr)
+{
+ int col;
+ u16 *ptr = VIDEO(0, row);
+
+ for(col = 0; col < VIDEO_COLS; col++)
+ ptr[col] = ((attr & 0xFF) << 8) | (ch & 0xFF);
+}
+
+static void vga_scroll_up(void)
+{
+ u16 *src = VIDEO(0,1);
+ u16 *dst = VIDEO(0,0);
+ int i;
+
+ for(i = 0; i < (VIDEO_ROWS - 1) * VIDEO_COLS; i++)
+ *dst++ = *src++;
+
+ vga_clear_line(VIDEO_ROWS - 1, ' ', VGA_COLOR_WHITE);
+}
+
+static void vga_fill(u8 ch, u8 attr)
+{
+ u8 row;
+ for(row = 0; row < VIDEO_ROWS; row++)
+ vga_clear_line(row, ch, attr);
+}
+
+static void vga_clear(void)
+{
+ vga_fill(' ', VGA_COLOR_WHITE);
+}
+
+static void vga_putc(u8 row, u8 col, unsigned int c)
+{
+ u16 *ptr = VIDEO(row, col);
+ *ptr = (u16) (c & 0xFFFF);
+}
+
+static int vga_init(void)
+{
+ return 0;
+}
+
+struct video_console vga_video_console = {
+ .init = vga_init,
+ .putc = vga_putc,
+ .clear = vga_clear,
+ .scroll_up = vga_scroll_up,
+
+ .get_cursor = vga_get_cursor,
+ .set_cursor = vga_set_cursor,
+ .enable_cursor = vga_enable_cursor,
+};
diff --git a/payloads/libpayload/drivers/video/video.c b/payloads/libpayload/drivers/video/video.c
new file mode 100644
index 0000000000..89c146d6ce
--- /dev/null
+++ b/payloads/libpayload/drivers/video/video.c
@@ -0,0 +1,160 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2008 Advanced Micro Devices, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <libpayload.h>
+#include <video_console.h>
+
+#ifdef CONFIG_VGA_VIDEO_CONSOLE
+extern struct video_console vga_video_console;
+#endif
+
+static struct video_console *console_list[] =
+{
+#ifdef CONFIG_VGA_VIDEO_CONSOLE
+ &vga_video_console,
+#endif
+};
+
+static struct video_console *console;
+
+static unsigned int cursorx;
+static unsigned int cursory;
+static unsigned int cursor_enabled = 1;
+
+static void video_console_fixup_cursor(void)
+{
+ if (!cursor_enabled)
+ return;
+
+ if (cursorx < 0)
+ cursorx = 0;
+
+ if (cursory < 0)
+ cursory = 0;
+
+ if (cursorx > VIDEO_COLS) {
+ cursorx = 0;
+ cursory++;
+ }
+
+ while(cursory >= VIDEO_ROWS) {
+ console->scroll_up();
+ cursory--;
+ }
+
+ if (console && console->set_cursor)
+ console->set_cursor(cursorx, cursory);
+}
+
+void video_console_cursor_enable(int state)
+{
+ if (console && console->enable_cursor)
+ console->enable_cursor(state);
+
+ cursor_enabled = state;
+
+ if (cursor_enabled)
+ video_console_fixup_cursor();
+}
+
+void video_console_clear(void)
+{
+ if (console)
+ console->clear();
+
+ cursorx = 0;
+ cursory = 0;
+
+ if (console && console->set_cursor)
+ console->set_cursor(cursorx, cursory);
+}
+
+void video_console_putc(u8 row, u8 col, unsigned int ch)
+{
+ if (console)
+ console->putc(row, col, ch);
+}
+
+void video_console_putchar(unsigned int ch)
+{
+ switch(ch & 0xFF) {
+ case '\r':
+ cursorx = 0;
+ break;
+
+ case '\n':
+ cursory++;
+ break;
+
+ case '\b':
+ cursorx--;
+ break;
+
+ case '\t':
+ while(cursorx % 8 && cursorx < VIDEO_COLS) {
+ if (console)
+ console->putc(cursorx, cursory, (ch & 0xFF00) | ' ');
+
+ cursorx++;
+ }
+ break;
+ default:
+ if (console)
+ console->putc(cursorx++, cursory, ch);
+ break;
+ }
+
+ video_console_fixup_cursor();
+}
+
+int video_console_init(void)
+{
+ int i;
+
+ for(i = 0; i < ARRAY_SIZE(console_list); i++) {
+ if (console_list[i]->init())
+ continue;
+
+ console = console_list[i];
+
+ if (console->get_cursor)
+ console->get_cursor(&cursorx, &cursory, &cursor_enabled);
+
+ if (cursorx) {
+ cursorx = 0;
+ cursory++;
+ }
+
+ video_console_fixup_cursor();
+ return 0;
+ }
+
+ return 0;
+}
+
diff --git a/payloads/libpayload/include/libpayload.h b/payloads/libpayload/include/libpayload.h
index 10e5e8529c..23feedb43f 100644
--- a/payloads/libpayload/include/libpayload.h
+++ b/payloads/libpayload/include/libpayload.h
@@ -78,15 +78,12 @@ void serial_putchar(unsigned char c);
int serial_havechar(void);
int serial_getchar(void);
-/* drivers/serial.c */
-void vga_cursor_enable(int state);
-void vga_clear_line(uint8_t row, uint8_t ch, uint8_t attr);
-void vga_fill(uint8_t ch, uint8_t attr);
-void vga_clear(void);
-void vga_putc(uint8_t row, uint8_t col, unsigned int c);
-void vga_putchar(unsigned int ch);
-void vga_move_cursor(int x, int y);
-void vga_init(void);
+/* video/video.c */
+int video_console_init(void);
+void video_console_putchar(unsigned int ch);
+void video_console_putc(u8 row, u8 col, unsigned int ch);
+void video_console_clear(void);
+void video_console_cursor_enable(int state);
/* libc/console.c */
void console_init(void);
diff --git a/payloads/libpayload/include/video_console.h b/payloads/libpayload/include/video_console.h
new file mode 100644
index 0000000000..55deedf65f
--- /dev/null
+++ b/payloads/libpayload/include/video_console.h
@@ -0,0 +1,47 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright (C) 2008 Advanced Micro Devices, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef VIDEO_CONSOLE_H_
+#define VIDEO_CONSOLE_H_
+
+#define VIDEO_ROWS 25
+#define VIDEO_COLS 80
+
+struct video_console {
+ int (*init)(void);
+ void (*putc)(u8, u8, unsigned int);
+ void (*clear)(void);
+ void (*scroll_up)(void);
+
+ void (*get_cursor)(unsigned int *, unsigned int *, unsigned int *);
+ void (*set_cursor)(unsigned int, unsigned int);
+ void (*enable_cursor)(int);
+};
+
+#endif
diff --git a/payloads/libpayload/libc/console.c b/payloads/libpayload/libc/console.c
index 73e2644cd4..b0bfe241c0 100644
--- a/payloads/libpayload/libc/console.c
+++ b/payloads/libpayload/libc/console.c
@@ -31,8 +31,8 @@
void console_init(void)
{
-#ifdef CONFIG_VGA_CONSOLE
- vga_init();
+#ifdef CONFIG_VIDEO_CONSOLE
+ video_console_init();
#endif
#ifdef CONFIG_SERIAL_CONSOLE
serial_init();
@@ -41,8 +41,8 @@ void console_init(void)
static void device_putchar(unsigned char c)
{
-#ifdef CONFIG_VGA_CONSOLE
- vga_putchar(0x700 | c);
+#ifdef CONFIG_VIDEO_CONSOLE
+ video_console_putchar(0x700| c);
#endif
#ifdef CONFIG_SERIAL_CONSOLE
serial_putchar(c);