summaryrefslogtreecommitdiff
path: root/src/console
diff options
context:
space:
mode:
authorLuc Verhaegen <libv@skynet.be>2009-05-29 03:04:16 +0000
committerLuc Verhaegen <libv@skynet.be>2009-05-29 03:04:16 +0000
commit5c5beb765dce9e5ded2ea1332d86d288ba347dce (patch)
tree2ac82209a29b6af718caf0813b83443f1363034a /src/console
parent195f5cd66674433cf06dbfe57e0b9bd98bb3549c (diff)
downloadcoreboot-5c5beb765dce9e5ded2ea1332d86d288ba347dce.tar.xz
Implement native VGA Support.
This code brings a rather complete set of VGA IO routines for whoever wants it. These consist of the by now familiar read/write/mask sets. Due to the crazy nature of VGA, an ancient standard with bits all over the place, it makes no sense to define individual registers. You need a vga register spec at hand if you want to do anything anyway. These IO routines are always exposed. It also provides code to natively set up a 640x400 VGA textmode with an 8x16 font. The native VGA mode code is behind the OPTION_VGA option, as the font really adds to the size of the compiled/compressed rom. The font is the one also present in the linux kernel, but this file is unlicensed. Another copy of this is also present in coreboot in the deprecated console/btext code. The vga console code has been cleaned up, but it still has some TODO's left open, but that's for when i finally have found the remaining issue with the epia-m. Right now, it is important to get parts of my work out already and to make the remainder managable again. Signed-off-by: Luc Verhaegen <libv@skynet.be> Acked-by: Peter Stuge <peter@stuge.se> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@4321 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'src/console')
-rw-r--r--src/console/vga_console.c136
1 files changed, 63 insertions, 73 deletions
diff --git a/src/console/vga_console.c b/src/console/vga_console.c
index 120828a849..0a749f653c 100644
--- a/src/console/vga_console.c
+++ b/src/console/vga_console.c
@@ -5,105 +5,95 @@
*
*/
+/*
+ * TODO:
+ * * make vga_console_init take FB location, columns, lines and starting
+ * column/line.
+ * * track a word offset, and not columns/lines. The offset is needed more
+ * often than columns/lines and the latter two can be calculated easily.
+ * * then implement real vga scrolling, instead of memcpying stuff around.
+ *
+ * -- libv.
+ */
+
#include <arch/io.h>
#include <string.h>
+#include <pc80/vga_io.h>
#include <pc80/vga.h>
#include <console/console.h>
/* The video buffer, should be replaced by symbol in ldscript.ld */
static char *vidmem;
-
-int vga_line, vga_col;
-
-int vga_inited = 0; // it will be changed in pci_rom.c
-
+static int total_lines, total_columns;
+static int current_line, current_column;
static int vga_console_inited = 0;
-#define VIDBUFFER 0xB8000;
-
-static void memsetw(void *s, int c, unsigned int n)
+/*
+ *
+ */
+void vga_console_init(void)
{
- int i;
- u16 *ss = (u16 *) s;
+ vidmem = (char *) VGA_FB;
+ total_columns = VGA_COLUMNS;
+ total_lines = VGA_LINES;
+ current_column = 0;
+ current_line = 0;
- for (i = 0; i < n; i++) {
- ss[i] = ( u16 ) c;
- }
-}
-
-static void vga_init(void)
-{
- // these are globals
- vga_line = 0;
- vga_col = 0;
- vidmem = (char *) VIDBUFFER;
-
- // mainboard or chip specific init routines
- // also loads font
- vga_hardware_fixup();
-
- // set attributes, char for entire screen
- // font should be previously loaded in
- // device specific code (vga_hardware_fixup)
- memsetw(vidmem, VGA_ATTR_CLR_WHT, 2*1024); //
+ vga_console_inited = 1;
}
static void vga_scroll(void)
{
int i;
- memcpy(vidmem, vidmem + COLS * 2, (LINES - 1) * COLS * 2);
- for (i = (LINES - 1) * COLS * 2; i < LINES * COLS * 2; i += 2)
+ memcpy(vidmem, vidmem + total_columns * 2, (total_lines - 1) * total_columns * 2);
+ for (i = (total_lines - 1) * total_columns * 2; i < total_lines * total_columns * 2; i += 2)
vidmem[i] = ' ';
}
-static void vga_tx_byte(unsigned char byte)
+static void
+vga_tx_byte(unsigned char byte)
{
- if (!vga_inited) {
- return;
- }
-
- if(!vga_console_inited) {
- vga_init();
- vga_console_inited = 1;
+ if (!vga_console_inited)
+ return;
+
+ switch (byte) {
+ case '\n':
+ current_line++;
+ current_column = 0;
+ break;
+ case '\r':
+ current_column = 0;
+ break;
+ case '\b':
+ current_column--;
+ break;
+ case '\t':
+ current_column += 4;
+ break;
+ case '\a': /* beep */
+ break;
+ default:
+ vidmem[((current_column + (current_line * total_columns)) * 2)] = byte;
+ vidmem[((current_column + (current_line * total_columns)) * 2) +1] = 0x07;
+ current_column++;
+ break;
}
- if (byte == '\n') {
- vga_line++;
- vga_col = 0;
-
- } else if (byte == '\r') {
- vga_col = 0;
-
- } else if (byte == '\b') {
- vga_col--;
-
- } else if (byte == '\t') {
- vga_col += 4;
-
- } else if (byte == '\a') {
- //beep
-// beep(500);
- ;
- } else {
- vidmem[((vga_col + (vga_line *COLS)) * 2)] = byte;
- vidmem[((vga_col + (vga_line *COLS)) * 2) +1] = VGA_ATTR_CLR_WHT;
- vga_col++;
+ if (current_column < 0)
+ current_column = 0;
+ if (current_column >= total_columns) {
+ current_line++;
+ current_column = 0;
}
- if (vga_col < 0) {
- vga_col = 0;
- }
- if (vga_col >= COLS) {
- vga_line++;
- vga_col = 0;
- }
- if (vga_line >= LINES) {
+ if (current_line >= total_lines) {
vga_scroll();
- vga_line--;
+ current_line--;
}
- // move the cursor
- write_crtc((vga_col + (vga_line *COLS)) >> 8, CRTC_CURSOR_HI);
- write_crtc((vga_col + (vga_line *COLS)) & 0x0ff, CRTC_CURSOR_LO);
+
+ /* move the cursor */
+ vga_cr_write(0x0E, (current_column + (current_line * total_columns)) >> 8);
+ vga_cr_write(0x0F, (current_column + (current_line * total_columns)) & 0x0ff);
}
static const struct console_driver vga_console __console ={