source: grub-pc/trunk/fuentes/grub-core/kern/vga_init.c @ 22

Last change on this file since 22 was 22, checked in by mabarracus, 4 years ago

updated version and apply net.ifnames=0 into debian/rules

File size: 3.8 KB
Line 
1/*
2 *  GRUB  --  GRand Unified Bootloader
3 *  Copyright (C) 2010,2011  Free Software Foundation, Inc.
4 *
5 *  GRUB is free software: you can redistribute it and/or modify
6 *  it under the terms of the GNU General Public License as published by
7 *  the Free Software Foundation, either version 3 of the License, or
8 *  (at your option) any later version.
9 *
10 *  GRUB is distributed in the hope that it will be useful,
11 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 *  GNU General Public License for more details.
14 *
15 *  You should have received a copy of the GNU General Public License
16 *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef __mips__
20#include <grub/pci.h>
21#include <grub/mm.h>
22#endif
23#include <grub/machine/kernel.h>
24#include <grub/misc.h>
25#include <grub/vga.h>
26
27static struct {grub_uint8_t r, g, b, a; } colors[] =
28  {
29    // {R, G, B, A}
30    {0x00, 0x00, 0x00, 0xFF}, // 0 = black
31    {0x00, 0x00, 0xA8, 0xFF}, // 1 = blue
32    {0x00, 0xA8, 0x00, 0xFF}, // 2 = green
33    {0x00, 0xA8, 0xA8, 0xFF}, // 3 = cyan
34    {0xA8, 0x00, 0x00, 0xFF}, // 4 = red
35    {0xA8, 0x00, 0xA8, 0xFF}, // 5 = magenta
36    {0xA8, 0x54, 0x00, 0xFF}, // 6 = brown
37    {0xA8, 0xA8, 0xA8, 0xFF}, // 7 = light gray
38
39    {0x54, 0x54, 0x54, 0xFF}, // 8 = dark gray
40    {0x54, 0x54, 0xFE, 0xFF}, // 9 = bright blue
41    {0x54, 0xFE, 0x54, 0xFF}, // 10 = bright green
42    {0x54, 0xFE, 0xFE, 0xFF}, // 11 = bright cyan
43    {0xFE, 0x54, 0x54, 0xFF}, // 12 = bright red
44    {0xFE, 0x54, 0xFE, 0xFF}, // 13 = bright magenta
45    {0xFE, 0xFE, 0x54, 0xFF}, // 14 = yellow
46    {0xFE, 0xFE, 0xFE, 0xFF}  // 15 = white
47  };
48
49#include <ascii.h>
50
51#ifdef __mips__
52#define VGA_ADDR 0xb00a0000
53#else
54#define VGA_ADDR 0xa0000
55#endif
56
57static void
58load_font (void)
59{
60  unsigned i;
61
62  grub_vga_gr_write (0 << 2, GRUB_VGA_GR_GR6);
63
64  grub_vga_sr_write (GRUB_VGA_SR_MEMORY_MODE_NORMAL, GRUB_VGA_SR_MEMORY_MODE);
65  grub_vga_sr_write (1 << GRUB_VGA_TEXT_FONT_PLANE,
66                     GRUB_VGA_SR_MAP_MASK_REGISTER);
67
68  grub_vga_gr_write (0, GRUB_VGA_GR_DATA_ROTATE);
69  grub_vga_gr_write (0, GRUB_VGA_GR_MODE);
70  grub_vga_gr_write (0xff, GRUB_VGA_GR_BITMASK);
71
72  for (i = 0; i < 128; i++)
73    grub_memcpy ((void *) (VGA_ADDR + 32 * i), ascii_bitmaps + 16 * i, 16);
74}
75
76static void
77load_palette (void)
78{
79  unsigned i;
80  for (i = 0; i < 16; i++)
81    grub_vga_write_arx (i, i);
82
83  for (i = 0; i < ARRAY_SIZE (colors); i++)
84    grub_vga_palette_write (i, colors[i].r, colors[i].g, colors[i].b);
85}
86
87void
88grub_qemu_init_cirrus (void)
89{
90  grub_outb (GRUB_VGA_IO_MISC_COLOR,
91             GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_MISC_WRITE);
92
93  load_font ();
94
95  grub_vga_gr_write (GRUB_VGA_GR_GR6_MMAP_CGA, GRUB_VGA_GR_GR6);
96  grub_vga_gr_write (GRUB_VGA_GR_MODE_ODD_EVEN, GRUB_VGA_GR_MODE);
97
98  grub_vga_sr_write (GRUB_VGA_SR_MEMORY_MODE_NORMAL, GRUB_VGA_SR_MEMORY_MODE);
99
100  grub_vga_sr_write ((1 << GRUB_VGA_TEXT_TEXT_PLANE)
101                     | (1 << GRUB_VGA_TEXT_ATTR_PLANE),
102                     GRUB_VGA_SR_MAP_MASK_REGISTER);
103
104  grub_vga_cr_write (15, GRUB_VGA_CR_CELL_HEIGHT);
105  grub_vga_cr_write (79, GRUB_VGA_CR_HORIZ_END);
106  grub_vga_cr_write (40, GRUB_VGA_CR_PITCH);
107
108  int vert = 25 * 16;
109  grub_vga_cr_write (vert & 0xff, GRUB_VGA_CR_VDISPLAY_END);
110  grub_vga_cr_write (((vert >> GRUB_VGA_CR_OVERFLOW_HEIGHT1_SHIFT)
111                      & GRUB_VGA_CR_OVERFLOW_HEIGHT1_MASK)
112                     | ((vert >> GRUB_VGA_CR_OVERFLOW_HEIGHT2_SHIFT)
113                        & GRUB_VGA_CR_OVERFLOW_HEIGHT2_MASK),
114                     GRUB_VGA_CR_OVERFLOW);
115
116  load_palette ();
117
118  grub_vga_write_arx (GRUB_VGA_ARX_MODE_TEXT, GRUB_VGA_ARX_MODE);
119  grub_vga_write_arx (0, GRUB_VGA_ARX_COLOR_SELECT);
120
121  grub_vga_sr_write (GRUB_VGA_SR_CLOCKING_MODE_8_DOT_CLOCK,
122                     GRUB_VGA_SR_CLOCKING_MODE);
123
124  grub_vga_cr_write (14, GRUB_VGA_CR_CURSOR_START);
125  grub_vga_cr_write (15, GRUB_VGA_CR_CURSOR_END);
126
127  grub_outb (0x20, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_ARX);
128}
Note: See TracBrowser for help on using the repository browser.