/* * VAS_EBOOT -- GRand Unified Bootloader * Copyright (C) 2010,2011 Free Software Foundation, Inc. * * VAS_EBOOT is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * VAS_EBOOT is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with VAS_EBOOT. If not, see . */ #ifndef __mips__ #include #include #endif #include #include #include static struct {VasEBoot_uint8_t r, g, b, a; } colors[] = { // {R, G, B, A} {0x00, 0x00, 0x00, 0xFF}, // 0 = black {0x00, 0x00, 0xA8, 0xFF}, // 1 = blue {0x00, 0xA8, 0x00, 0xFF}, // 2 = green {0x00, 0xA8, 0xA8, 0xFF}, // 3 = cyan {0xA8, 0x00, 0x00, 0xFF}, // 4 = red {0xA8, 0x00, 0xA8, 0xFF}, // 5 = magenta {0xA8, 0x54, 0x00, 0xFF}, // 6 = brown {0xA8, 0xA8, 0xA8, 0xFF}, // 7 = light gray {0x54, 0x54, 0x54, 0xFF}, // 8 = dark gray {0x54, 0x54, 0xFE, 0xFF}, // 9 = bright blue {0x54, 0xFE, 0x54, 0xFF}, // 10 = bright green {0x54, 0xFE, 0xFE, 0xFF}, // 11 = bright cyan {0xFE, 0x54, 0x54, 0xFF}, // 12 = bright red {0xFE, 0x54, 0xFE, 0xFF}, // 13 = bright magenta {0xFE, 0xFE, 0x54, 0xFF}, // 14 = yellow {0xFE, 0xFE, 0xFE, 0xFF} // 15 = white }; #include #ifdef __mips__ #define VGA_ADDR 0xb00a0000 #else #define VGA_ADDR 0xa0000 #endif static void load_font (void) { unsigned i; VasEBoot_vga_gr_write (0 << 2, VAS_EBOOT_VGA_GR_GR6); VasEBoot_vga_sr_write (VAS_EBOOT_VGA_SR_MEMORY_MODE_NORMAL, VAS_EBOOT_VGA_SR_MEMORY_MODE); VasEBoot_vga_sr_write (1 << VAS_EBOOT_VGA_TEXT_FONT_PLANE, VAS_EBOOT_VGA_SR_MAP_MASK_REGISTER); VasEBoot_vga_gr_write (0, VAS_EBOOT_VGA_GR_DATA_ROTATE); VasEBoot_vga_gr_write (0, VAS_EBOOT_VGA_GR_MODE); VasEBoot_vga_gr_write (0xff, VAS_EBOOT_VGA_GR_BITMASK); for (i = 0; i < 128; i++) VasEBoot_memcpy ((void *) (VGA_ADDR + 32 * i), ascii_bitmaps + 16 * i, 16); } static void load_palette (void) { unsigned i; for (i = 0; i < 16; i++) VasEBoot_vga_write_arx (i, i); for (i = 0; i < ARRAY_SIZE (colors); i++) VasEBoot_vga_palette_write (i, colors[i].r, colors[i].g, colors[i].b); } void VasEBoot_qemu_init_cirrus (void) { VasEBoot_outb (VAS_EBOOT_VGA_IO_MISC_COLOR, VAS_EBOOT_MACHINE_PCI_IO_BASE + VAS_EBOOT_VGA_IO_MISC_WRITE); load_font (); VasEBoot_vga_gr_write (VAS_EBOOT_VGA_GR_GR6_MMAP_CGA, VAS_EBOOT_VGA_GR_GR6); VasEBoot_vga_gr_write (VAS_EBOOT_VGA_GR_MODE_ODD_EVEN, VAS_EBOOT_VGA_GR_MODE); VasEBoot_vga_sr_write (VAS_EBOOT_VGA_SR_MEMORY_MODE_NORMAL, VAS_EBOOT_VGA_SR_MEMORY_MODE); VasEBoot_vga_sr_write ((1 << VAS_EBOOT_VGA_TEXT_TEXT_PLANE) | (1 << VAS_EBOOT_VGA_TEXT_ATTR_PLANE), VAS_EBOOT_VGA_SR_MAP_MASK_REGISTER); VasEBoot_vga_cr_write (15, VAS_EBOOT_VGA_CR_CELL_HEIGHT); VasEBoot_vga_cr_write (79, VAS_EBOOT_VGA_CR_HORIZ_END); VasEBoot_vga_cr_write (40, VAS_EBOOT_VGA_CR_PITCH); int vert = 25 * 16; VasEBoot_vga_cr_write (vert & 0xff, VAS_EBOOT_VGA_CR_VDISPLAY_END); VasEBoot_vga_cr_write (((vert >> VAS_EBOOT_VGA_CR_OVERFLOW_HEIGHT1_SHIFT) & VAS_EBOOT_VGA_CR_OVERFLOW_HEIGHT1_MASK) | ((vert >> VAS_EBOOT_VGA_CR_OVERFLOW_HEIGHT2_SHIFT) & VAS_EBOOT_VGA_CR_OVERFLOW_HEIGHT2_MASK), VAS_EBOOT_VGA_CR_OVERFLOW); load_palette (); VasEBoot_vga_write_arx (VAS_EBOOT_VGA_ARX_MODE_TEXT, VAS_EBOOT_VGA_ARX_MODE); VasEBoot_vga_write_arx (0, VAS_EBOOT_VGA_ARX_COLOR_SELECT); VasEBoot_vga_sr_write (VAS_EBOOT_VGA_SR_CLOCKING_MODE_8_DOT_CLOCK, VAS_EBOOT_VGA_SR_CLOCKING_MODE); VasEBoot_vga_cr_write (14, VAS_EBOOT_VGA_CR_CURSOR_START); VasEBoot_vga_cr_write (15, VAS_EBOOT_VGA_CR_CURSOR_END); VasEBoot_outb (0x20, VAS_EBOOT_MACHINE_PCI_IO_BASE + VAS_EBOOT_VGA_IO_ARX); }