3 * modified from original freebios code
4 * by Steve M. Gehlbach <steve@kesa.com>
11 #include <console/console.h>
13 /* The video buffer, should be replaced by symbol in ldscript.ld */
16 int vga_line, vga_col;
18 int vga_inited = 0; // it will be changed in pci_rom.c
20 static int vga_console_inited = 0;
22 #define VIDBUFFER 0xB8000;
24 static void memsetw(void *s, int c, unsigned int n)
29 for (i = 0; i < n; i++) {
34 static void vga_init(void)
39 vidmem = (char *) VIDBUFFER;
41 // mainboard or chip specific init routines
45 // set attributes, char for entire screen
46 // font should be previously loaded in
47 // device specific code (vga_hardware_fixup)
48 memsetw(vidmem, VGA_ATTR_CLR_WHT, 2*1024); //
51 static void vga_scroll(void)
55 memcpy(vidmem, vidmem + COLS * 2, (LINES - 1) * COLS * 2);
56 for (i = (LINES - 1) * COLS * 2; i < LINES * COLS * 2; i += 2)
60 static void vga_tx_byte(unsigned char byte)
66 if(!vga_console_inited) {
68 vga_console_inited = 1;
75 } else if (byte == '\r') {
78 } else if (byte == '\b') {
81 } else if (byte == '\t') {
84 } else if (byte == '\a') {
89 vidmem[((vga_col + (vga_line *COLS)) * 2)] = byte;
90 vidmem[((vga_col + (vga_line *COLS)) * 2) +1] = VGA_ATTR_CLR_WHT;
96 if (vga_col >= COLS) {
100 if (vga_line >= LINES) {
105 write_crtc((vga_col + (vga_line *COLS)) >> 8, CRTC_CURSOR_HI);
106 write_crtc((vga_col + (vga_line *COLS)) & 0x0ff, CRTC_CURSOR_LO);
109 static const struct console_driver vga_console __console ={
111 .tx_byte = vga_tx_byte,