Initialise VGA video on qemu ourselves.
* boot/i386/qemu/boot.S: Don't call 0xc000. * conf/i386-qemu.rmk (kern/i386/qemu/init.c_DEPENDENCIES): New variable. (kernel_img_SOURCES): Add kern/i386/qemu/init.c and bus/pci.c. (kernel_img_HEADERS): Add pci.h. * conf/i386.rmk (pkglib_MODULES) [qemu]: Remove pci.mod. * configure.ac: Force unifont on qemu and yeeloong. * include/grub/i386/qemu/kernel.h (grub_qemu_init_cirrus): New proto. (grub_vga_palette_write): Use correct register. * kern/i386/coreboot/init.c (grub_machine_init) [GRUB_MACHINE_QEMU]: Call grub_qemu_init_cirrus. * kern/i386/qemu/init.c: New file. * term/i386/pc/vga_text.c (inc_y): Never read outside the screen. * commands/videotest.c (grub_cmd_videotest): Handle double buffering.
This commit is contained in:
commit
97f5cb8c87
11 changed files with 340 additions and 108 deletions
19
ChangeLog
19
ChangeLog
|
@ -1,3 +1,22 @@
|
|||
2010-06-21 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Initialise VGA video on qemu ourselves.
|
||||
|
||||
* boot/i386/qemu/boot.S: Don't call 0xc000.
|
||||
* conf/i386-qemu.rmk (kern/i386/qemu/init.c_DEPENDENCIES): New variable.
|
||||
(kernel_img_SOURCES): Add kern/i386/qemu/init.c and bus/pci.c.
|
||||
(kernel_img_HEADERS): Add pci.h.
|
||||
* conf/i386.rmk (pkglib_MODULES) [qemu]: Remove pci.mod.
|
||||
* configure.ac: Force unifont on qemu and yeeloong.
|
||||
* include/grub/i386/qemu/kernel.h (grub_qemu_init_cirrus): New proto.
|
||||
(grub_vga_palette_write): Use correct register.
|
||||
* kern/i386/coreboot/init.c (grub_machine_init) [GRUB_MACHINE_QEMU]:
|
||||
Call grub_qemu_init_cirrus.
|
||||
* kern/i386/qemu/init.c: New file.
|
||||
* term/i386/pc/vga_text.c (inc_y): Never read outside the screen.
|
||||
|
||||
* commands/videotest.c (grub_cmd_videotest): Handle double buffering.
|
||||
|
||||
2010-06-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Support >3GiB and <16MiB RAM in i386-qemu.
|
||||
|
|
|
@ -36,9 +36,6 @@ VARIABLE(grub_core_entry_addr)
|
|||
.long 0
|
||||
1:
|
||||
|
||||
/* Process VGA rom. */
|
||||
call $0xc000, $0x3
|
||||
|
||||
/* Set up %ds, %ss, and %es. */
|
||||
xorw %ax, %ax
|
||||
movw %ax, %ds
|
||||
|
|
|
@ -38,15 +38,8 @@ grub_cmd_videotest (grub_command_t cmd __attribute__ ((unused)),
|
|||
unsigned int width;
|
||||
unsigned int height;
|
||||
int i;
|
||||
grub_font_t sansbig;
|
||||
grub_font_t sans;
|
||||
grub_font_t sanssmall;
|
||||
grub_font_t fixed;
|
||||
struct grub_font_glyph *glyph;
|
||||
struct grub_video_render_target *text_layer;
|
||||
grub_video_color_t palette[16];
|
||||
const char *str;
|
||||
int texty;
|
||||
|
||||
err = grub_video_set_mode ("auto", GRUB_VIDEO_MODE_TYPE_PURE_TEXT, 0);
|
||||
if (err)
|
||||
|
@ -54,102 +47,115 @@ grub_cmd_videotest (grub_command_t cmd __attribute__ ((unused)),
|
|||
|
||||
grub_video_get_viewport (&x, &y, &width, &height);
|
||||
|
||||
grub_video_create_render_target (&text_layer, width, height,
|
||||
GRUB_VIDEO_MODE_TYPE_RGB
|
||||
| GRUB_VIDEO_MODE_TYPE_ALPHA);
|
||||
{
|
||||
const char *str;
|
||||
int texty;
|
||||
grub_font_t sansbig;
|
||||
grub_font_t sans;
|
||||
grub_font_t sanssmall;
|
||||
grub_font_t fixed;
|
||||
struct grub_font_glyph *glyph;
|
||||
|
||||
grub_video_set_active_render_target (GRUB_VIDEO_RENDER_TARGET_DISPLAY);
|
||||
grub_video_create_render_target (&text_layer, width, height,
|
||||
GRUB_VIDEO_MODE_TYPE_RGB
|
||||
| GRUB_VIDEO_MODE_TYPE_ALPHA);
|
||||
|
||||
color = grub_video_map_rgb (0, 0, 0);
|
||||
grub_video_fill_rect (color, 0, 0, width, height);
|
||||
grub_video_set_active_render_target (text_layer);
|
||||
|
||||
color = grub_video_map_rgb (255, 0, 0);
|
||||
grub_video_fill_rect (color, 0, 0, 100, 100);
|
||||
color = grub_video_map_rgb (0, 255, 255);
|
||||
sansbig = grub_font_get ("Unknown Regular 16");
|
||||
sans = grub_font_get ("Unknown Regular 16");
|
||||
sanssmall = grub_font_get ("Unknown Regular 16");
|
||||
fixed = grub_font_get ("Fixed 20");
|
||||
if (! sansbig || ! sans || ! sanssmall || ! fixed)
|
||||
return grub_error (GRUB_ERR_BAD_FONT, "no font loaded");
|
||||
|
||||
color = grub_video_map_rgb (0, 255, 255);
|
||||
grub_video_fill_rect (color, 100, 100, 100, 100);
|
||||
glyph = grub_font_get_glyph (fixed, '*');
|
||||
grub_font_draw_glyph (glyph, color, 200 ,0);
|
||||
|
||||
sansbig = grub_font_get ("Unknown Regular 16");
|
||||
sans = grub_font_get ("Unknown Regular 16");
|
||||
sanssmall = grub_font_get ("Unknown Regular 16");
|
||||
fixed = grub_font_get ("Fixed 20");
|
||||
if (! sansbig || ! sans || ! sanssmall || ! fixed)
|
||||
return grub_error (GRUB_ERR_BAD_FONT, "no font loaded");
|
||||
color = grub_video_map_rgb (255, 255, 255);
|
||||
|
||||
glyph = grub_font_get_glyph (fixed, '*');
|
||||
grub_font_draw_glyph (glyph, color, 200 ,0);
|
||||
texty = 32;
|
||||
grub_font_draw_string ("The quick brown fox jumped over the lazy dog.",
|
||||
sans, color, 16, texty);
|
||||
texty += grub_font_get_descent (sans) + grub_font_get_leading (sans);
|
||||
|
||||
grub_video_set_viewport (x + 150, y + 150,
|
||||
width - 150 * 2, height - 150 * 2);
|
||||
color = grub_video_map_rgb (77, 33, 77);
|
||||
grub_video_fill_rect (color, 0, 0, width, height);
|
||||
texty += grub_font_get_ascent (fixed);
|
||||
grub_font_draw_string ("The quick brown fox jumped over the lazy dog.",
|
||||
fixed, color, 16, texty);
|
||||
texty += grub_font_get_descent (fixed) + grub_font_get_leading (fixed);
|
||||
|
||||
grub_video_set_active_render_target (text_layer);
|
||||
|
||||
color = grub_video_map_rgb (255, 255, 255);
|
||||
|
||||
texty = 32;
|
||||
grub_font_draw_string ("The quick brown fox jumped over the lazy dog.",
|
||||
sans, color, 16, texty);
|
||||
texty += grub_font_get_descent (sans) + grub_font_get_leading (sans);
|
||||
|
||||
texty += grub_font_get_ascent (fixed);
|
||||
grub_font_draw_string ("The quick brown fox jumped over the lazy dog.",
|
||||
fixed, color, 16, texty);
|
||||
texty += grub_font_get_descent (fixed) + grub_font_get_leading (fixed);
|
||||
|
||||
/* To convert Unicode characters into UTF-8 for this test, the following
|
||||
command is useful:
|
||||
/* To convert Unicode characters into UTF-8 for this test, the following
|
||||
command is useful:
|
||||
echo -ne '\x00\x00\x26\x3A' | iconv -f UTF-32BE -t UTF-8 | od -t x1
|
||||
This converts the Unicode character U+263A to UTF-8. */
|
||||
This converts the Unicode character U+263A to UTF-8. */
|
||||
|
||||
/* Characters used:
|
||||
Code point Description UTF-8 encoding
|
||||
----------- ------------------------------ --------------
|
||||
U+263A unfilled smiley face E2 98 BA
|
||||
U+00A1 inverted exclamation point C2 A1
|
||||
U+00A3 British pound currency symbol C2 A3
|
||||
U+03C4 Greek tau CF 84
|
||||
U+00E4 lowercase letter a with umlaut C3 A4
|
||||
U+2124 set 'Z' symbol (integers) E2 84 A4
|
||||
U+2287 subset symbol E2 8A 87
|
||||
U+211D set 'R' symbol (real numbers) E2 84 9D */
|
||||
/* Characters used:
|
||||
Code point Description UTF-8 encoding
|
||||
----------- ------------------------------ --------------
|
||||
U+263A unfilled smiley face E2 98 BA
|
||||
U+00A1 inverted exclamation point C2 A1
|
||||
U+00A3 British pound currency symbol C2 A3
|
||||
U+03C4 Greek tau CF 84
|
||||
U+00E4 lowercase letter a with umlaut C3 A4
|
||||
U+2124 set 'Z' symbol (integers) E2 84 A4
|
||||
U+2287 subset symbol E2 8A 87
|
||||
U+211D set 'R' symbol (real numbers) E2 84 9D */
|
||||
|
||||
str =
|
||||
"Unicode test: happy\xE2\x98\xBA \xC2\xA3 5.00"
|
||||
" \xC2\xA1\xCF\x84\xC3\xA4u! "
|
||||
" \xE2\x84\xA4\xE2\x8A\x87\xE2\x84\x9D";
|
||||
color = grub_video_map_rgb (128, 128, 255);
|
||||
str =
|
||||
"Unicode test: happy\xE2\x98\xBA \xC2\xA3 5.00"
|
||||
" \xC2\xA1\xCF\x84\xC3\xA4u! "
|
||||
" \xE2\x84\xA4\xE2\x8A\x87\xE2\x84\x9D";
|
||||
color = grub_video_map_rgb (128, 128, 255);
|
||||
|
||||
/* All characters in the string exist in the 'Fixed 20' (10x20) font. */
|
||||
texty += grub_font_get_ascent(fixed);
|
||||
grub_font_draw_string (str, fixed, color, 16, texty);
|
||||
texty += grub_font_get_descent (fixed) + grub_font_get_leading (fixed);
|
||||
/* All characters in the string exist in the 'Fixed 20' (10x20) font. */
|
||||
texty += grub_font_get_ascent(fixed);
|
||||
grub_font_draw_string (str, fixed, color, 16, texty);
|
||||
texty += grub_font_get_descent (fixed) + grub_font_get_leading (fixed);
|
||||
|
||||
texty += grub_font_get_ascent(sansbig);
|
||||
grub_font_draw_string (str, sansbig, color, 16, texty);
|
||||
texty += grub_font_get_descent (sansbig) + grub_font_get_leading (sansbig);
|
||||
texty += grub_font_get_ascent(sansbig);
|
||||
grub_font_draw_string (str, sansbig, color, 16, texty);
|
||||
texty += grub_font_get_descent (sansbig) + grub_font_get_leading (sansbig);
|
||||
|
||||
texty += grub_font_get_ascent(sans);
|
||||
grub_font_draw_string (str, sans, color, 16, texty);
|
||||
texty += grub_font_get_descent (sans) + grub_font_get_leading (sans);
|
||||
texty += grub_font_get_ascent(sans);
|
||||
grub_font_draw_string (str, sans, color, 16, texty);
|
||||
texty += grub_font_get_descent (sans) + grub_font_get_leading (sans);
|
||||
|
||||
texty += grub_font_get_ascent(sanssmall);
|
||||
grub_font_draw_string (str, sanssmall, color, 16, texty);
|
||||
texty += (grub_font_get_descent (sanssmall)
|
||||
+ grub_font_get_leading (sanssmall));
|
||||
texty += grub_font_get_ascent(sanssmall);
|
||||
grub_font_draw_string (str, sanssmall, color, 16, texty);
|
||||
texty += (grub_font_get_descent (sanssmall)
|
||||
+ grub_font_get_leading (sanssmall));
|
||||
|
||||
glyph = grub_font_get_glyph (fixed, '*');
|
||||
glyph = grub_font_get_glyph (fixed, '*');
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
{
|
||||
color = grub_video_map_color (i);
|
||||
palette[i] = color;
|
||||
grub_font_draw_glyph (glyph, color, 16 + i * 16, 220);
|
||||
}
|
||||
for (i = 0; i < 16; i++)
|
||||
{
|
||||
color = grub_video_map_color (i);
|
||||
palette[i] = color;
|
||||
grub_font_draw_glyph (glyph, color, 16 + i * 16, 220);
|
||||
}
|
||||
}
|
||||
|
||||
grub_video_set_active_render_target (GRUB_VIDEO_RENDER_TARGET_DISPLAY);
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
color = grub_video_map_rgb (0, 0, 0);
|
||||
grub_video_fill_rect (color, 0, 0, width, height);
|
||||
|
||||
color = grub_video_map_rgb (255, 0, 0);
|
||||
grub_video_fill_rect (color, 0, 0, 100, 100);
|
||||
|
||||
color = grub_video_map_rgb (0, 255, 255);
|
||||
grub_video_fill_rect (color, 100, 100, 100, 100);
|
||||
|
||||
grub_video_set_viewport (x + 150, y + 150,
|
||||
width - 150 * 2, height - 150 * 2);
|
||||
color = grub_video_map_rgb (77, 33, 77);
|
||||
grub_video_fill_rect (color, 0, 0, width, height);
|
||||
grub_video_swap_buffers ();
|
||||
}
|
||||
|
||||
for (i = 0; i < 5; i++)
|
||||
{
|
||||
color = grub_video_map_rgb (i, 33, 77);
|
||||
|
|
|
@ -13,10 +13,13 @@ boot_img_ASFLAGS = $(COMMON_ASFLAGS) -DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_M
|
|||
boot_img_LDFLAGS = $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)$(GRUB_BOOT_MACHINE_LINK_ADDR)
|
||||
boot_img_FORMAT = binary
|
||||
|
||||
kern/i386/qemu/init.c_DEPENDENCIES = ascii.h
|
||||
|
||||
pkglib_PROGRAMS += kernel.img
|
||||
kernel_img_SOURCES = kern/i386/qemu/startup.S \
|
||||
kern/i386/misc.S \
|
||||
kern/i386/coreboot/init.c \
|
||||
kern/i386/qemu/init.c \
|
||||
kern/i386/qemu/mmap.c \
|
||||
kern/i386/halt.c \
|
||||
kern/main.c kern/device.c \
|
||||
|
@ -29,8 +32,9 @@ kernel_img_SOURCES = kern/i386/qemu/startup.S \
|
|||
kern/generic/rtc_get_time_ms.c \
|
||||
kern/generic/millisleep.c \
|
||||
kern/env.c \
|
||||
term/i386/pc/vga_text.c term/i386/vga_common.c \
|
||||
term/i386/pc/vga_text.c term/i386/vga_common.c bus/pci.c \
|
||||
symlist.c
|
||||
kernel_img_HEADERS += pci.h
|
||||
kernel_img_CFLAGS = $(COMMON_CFLAGS) -DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)
|
||||
kernel_img_ASFLAGS = $(COMMON_ASFLAGS) -DGRUB_KERNEL_MACHINE_LINK_ADDR=$(GRUB_KERNEL_MACHINE_LINK_ADDR)
|
||||
kernel_img_LDFLAGS += $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)$(GRUB_KERNEL_MACHINE_LINK_ADDR)
|
||||
|
|
|
@ -60,11 +60,14 @@ serial_mod_SOURCES = term/serial.c
|
|||
serial_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
serial_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# On qemu it's compiled in
|
||||
ifneq ($(platform), qemu)
|
||||
# For pci.mod
|
||||
pkglib_MODULES += pci.mod
|
||||
pci_mod_SOURCES = bus/pci.c
|
||||
pci_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
pci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
endif
|
||||
|
||||
# For cs5536.mod
|
||||
pkglib_MODULES += cs5536.mod
|
||||
|
|
10
configure.ac
10
configure.ac
|
@ -179,15 +179,23 @@ if test "x$YACC" = x; then
|
|||
AC_MSG_ERROR([bison is not found])
|
||||
fi
|
||||
|
||||
FONT_SOURCE=
|
||||
|
||||
for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
|
||||
for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/unifont; do
|
||||
if test -f "$dir/unifont.$ext"; then
|
||||
AC_SUBST([FONT_SOURCE], [$dir/unifont.$ext])
|
||||
FONT_SOURCE="$dir/unifont.$ext"
|
||||
break 2
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
if test "x$FONT_SOURCE" == x && ( test "x$platform" = xqemu || test "x$platform" = xyeeloong ); then
|
||||
AC_MSG_ERROR([qemu and yeeloong ports need unifont])
|
||||
fi
|
||||
|
||||
AC_SUBST([FONT_SOURCE])
|
||||
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_AWK
|
||||
AC_PROG_LEX
|
||||
|
|
|
@ -34,6 +34,8 @@ extern grub_int32_t grub_kernel_image_size;
|
|||
/* The total size of module images following the kernel. */
|
||||
extern grub_int32_t grub_total_module_size;
|
||||
|
||||
void grub_qemu_init_cirrus (void);
|
||||
|
||||
#endif /* ! ASM_FILE */
|
||||
|
||||
#endif /* ! GRUB_KERNEL_MACHINE_HEADER */
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
enum
|
||||
{
|
||||
GRUB_VGA_IO_ARX = 0x3c0,
|
||||
GRUB_VGA_IO_SR_INDEX = 0x3c4,
|
||||
GRUB_VGA_IO_SR_DATA = 0x3c5,
|
||||
GRUB_VGA_IO_PIXEL_MASK = 0x3c6,
|
||||
|
@ -41,7 +42,8 @@ enum
|
|||
GRUB_VGA_CR_WIDTH = 0x01,
|
||||
GRUB_VGA_CR_OVERFLOW = 0x07,
|
||||
GRUB_VGA_CR_CELL_HEIGHT = 0x09,
|
||||
GRUB_VGA_CR_CURSOR = 0x0a,
|
||||
GRUB_VGA_CR_CURSOR_START = 0x0a,
|
||||
GRUB_VGA_CR_CURSOR_END = 0x0b,
|
||||
GRUB_VGA_CR_START_ADDR_HIGH_REGISTER = 0x0c,
|
||||
GRUB_VGA_CR_START_ADDR_LOW_REGISTER = 0x0d,
|
||||
GRUB_VGA_CR_CURSOR_ADDR_HIGH = 0x0e,
|
||||
|
@ -64,36 +66,68 @@ enum
|
|||
#define GRUB_VGA_CR_CELL_HEIGHT_LINE_COMPARE_MASK 0x40
|
||||
#define GRUB_VGA_CR_CELL_HEIGHT_LINE_COMPARE_SHIFT 3
|
||||
|
||||
#define GRUB_VGA_CR_CURSOR_DISABLE (1 << 5)
|
||||
enum
|
||||
{
|
||||
GRUB_VGA_CR_CURSOR_START_DISABLE = (1 << 5)
|
||||
};
|
||||
|
||||
#define GRUB_VGA_CR_PITCH_DIVISOR 8
|
||||
|
||||
#define GRUB_VGA_CR_MODE_TIMING_ENABLE 0x80
|
||||
#define GRUB_VGA_CR_MODE_BYTE_MODE 0x40
|
||||
#define GRUB_VGA_CR_MODE_NO_HERCULES 0x02
|
||||
#define GRUB_VGA_CR_MODE_NO_CGA 0x01
|
||||
|
||||
enum
|
||||
{
|
||||
GRUB_VGA_SR_MAP_MASK_REGISTER = 0x02,
|
||||
GRUB_VGA_SR_MEMORY_MODE = 0x04,
|
||||
GRUB_VGA_CR_MODE_NO_CGA = 0x01,
|
||||
GRUB_VGA_CR_MODE_NO_HERCULES = 0x02,
|
||||
GRUB_VGA_CR_MODE_BYTE_MODE = 0x40,
|
||||
GRUB_VGA_CR_MODE_TIMING_ENABLE = 0x80
|
||||
};
|
||||
|
||||
#define GRUB_VGA_SR_MEMORY_MODE_CHAIN4 8
|
||||
#define GRUB_VGA_SR_MEMORY_MODE_NORMAL 0
|
||||
enum
|
||||
{
|
||||
GRUB_VGA_SR_CLOCKING_MODE = 1,
|
||||
GRUB_VGA_SR_MAP_MASK_REGISTER = 2,
|
||||
GRUB_VGA_SR_MEMORY_MODE = 4,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
GRUB_VGA_GR_READ_MAP_REGISTER = 0x04,
|
||||
GRUB_VGA_SR_CLOCKING_MODE_8_DOT_CLOCK = 1
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
GRUB_VGA_SR_MEMORY_MODE_NORMAL = 0,
|
||||
GRUB_VGA_SR_MEMORY_MODE_CHAIN4 = 8
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
GRUB_VGA_GR_DATA_ROTATE = 3,
|
||||
GRUB_VGA_GR_READ_MAP_REGISTER = 4,
|
||||
GRUB_VGA_GR_MODE = 5,
|
||||
GRUB_VGA_GR_GR6 = 6,
|
||||
GRUB_VGA_GR_BITMASK = 8,
|
||||
GRUB_VGA_GR_MAX
|
||||
};
|
||||
|
||||
#define GRUB_VGA_GR_GR6_GRAPHICS_MODE 1
|
||||
enum
|
||||
{
|
||||
GRUB_VGA_TEXT_TEXT_PLANE = 0,
|
||||
GRUB_VGA_TEXT_ATTR_PLANE = 1,
|
||||
GRUB_VGA_TEXT_FONT_PLANE = 2
|
||||
};
|
||||
|
||||
#define GRUB_VGA_GR_MODE_256_COLOR 0x40
|
||||
#define GRUB_VGA_GR_MODE_READ_MODE1 0x08
|
||||
enum
|
||||
{
|
||||
GRUB_VGA_GR_GR6_GRAPHICS_MODE = 1,
|
||||
GRUB_VGA_GR_GR6_MMAP_CGA = (3 << 2)
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
GRUB_VGA_GR_MODE_READ_MODE1 = 0x08,
|
||||
GRUB_VGA_GR_MODE_ODD_EVEN = 0x10,
|
||||
GRUB_VGA_GR_MODE_256_COLOR = 0x40
|
||||
};
|
||||
|
||||
static inline void
|
||||
grub_vga_gr_write (grub_uint8_t val, grub_uint8_t addr)
|
||||
|
@ -151,7 +185,7 @@ static inline void
|
|||
grub_vga_palette_write (grub_uint8_t addr, grub_uint8_t r, grub_uint8_t g,
|
||||
grub_uint8_t b)
|
||||
{
|
||||
grub_outb (addr, GRUB_VGA_IO_PALLETTE_READ_INDEX);
|
||||
grub_outb (addr, GRUB_VGA_IO_PALLETTE_WRITE_INDEX);
|
||||
grub_outb (r, GRUB_VGA_IO_PALLETTE_DATA);
|
||||
grub_outb (g, GRUB_VGA_IO_PALLETTE_DATA);
|
||||
grub_outb (b, GRUB_VGA_IO_PALLETTE_DATA);
|
||||
|
|
|
@ -71,6 +71,9 @@ grub_exit (void)
|
|||
void
|
||||
grub_machine_init (void)
|
||||
{
|
||||
#ifdef GRUB_MACHINE_QEMU
|
||||
grub_qemu_init_cirrus ();
|
||||
#endif
|
||||
/* Initialize the console as early as possible. */
|
||||
grub_vga_text_init ();
|
||||
|
||||
|
|
152
kern/i386/qemu/init.c
Normal file
152
kern/i386/qemu/init.c
Normal file
|
@ -0,0 +1,152 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB 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.
|
||||
*
|
||||
* GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/pci.h>
|
||||
#include <grub/machine/kernel.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/vga.h>
|
||||
|
||||
static struct {grub_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 <ascii.h>
|
||||
|
||||
static void
|
||||
load_font (void)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
grub_vga_gr_write (0 << 2, GRUB_VGA_GR_GR6);
|
||||
|
||||
grub_vga_sr_write (GRUB_VGA_SR_MEMORY_MODE_NORMAL, GRUB_VGA_SR_MEMORY_MODE);
|
||||
grub_vga_sr_write (1 << GRUB_VGA_TEXT_FONT_PLANE,
|
||||
GRUB_VGA_SR_MAP_MASK_REGISTER);
|
||||
|
||||
grub_vga_gr_write (0, GRUB_VGA_GR_DATA_ROTATE);
|
||||
grub_vga_gr_write (0, GRUB_VGA_GR_MODE);
|
||||
grub_vga_gr_write (0xff, GRUB_VGA_GR_BITMASK);
|
||||
|
||||
for (i = 0; i < 128; i++)
|
||||
grub_memcpy ((void *) (0xa0000 + 32 * i), ascii_bitmaps + 16 * (0x7f - i), 16);
|
||||
}
|
||||
|
||||
static void
|
||||
load_palette (void)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < 16; i++)
|
||||
{
|
||||
grub_outb (i, GRUB_VGA_IO_ARX);
|
||||
grub_outb (i, GRUB_VGA_IO_ARX);
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE (colors); i++)
|
||||
grub_vga_palette_write (i, colors[i].r, colors[i].g, colors[i].b);
|
||||
}
|
||||
|
||||
void
|
||||
grub_qemu_init_cirrus (void)
|
||||
{
|
||||
auto int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid);
|
||||
int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid __attribute__ ((unused)))
|
||||
{
|
||||
grub_pci_address_t addr;
|
||||
grub_uint32_t class;
|
||||
|
||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
|
||||
class = grub_pci_read (addr);
|
||||
|
||||
if (((class >> 16) & 0xffff) != 0x0300)
|
||||
return 0;
|
||||
|
||||
/* FIXME: chooose addresses dynamically. */
|
||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
|
||||
grub_pci_write (addr, 0xf0000000 | GRUB_PCI_ADDR_MEM_PREFETCH
|
||||
| GRUB_PCI_ADDR_SPACE_MEMORY | GRUB_PCI_ADDR_MEM_TYPE_32);
|
||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG1);
|
||||
grub_pci_write (addr, 0xf2000000
|
||||
| GRUB_PCI_ADDR_SPACE_MEMORY | GRUB_PCI_ADDR_MEM_TYPE_32);
|
||||
|
||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
|
||||
grub_pci_write (addr, GRUB_PCI_COMMAND_MEM_ENABLED
|
||||
| GRUB_PCI_COMMAND_IO_ENABLED);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
grub_pci_iterate (find_card);
|
||||
|
||||
grub_outb (1, 0x3c2);
|
||||
|
||||
load_font ();
|
||||
|
||||
grub_vga_gr_write (GRUB_VGA_GR_GR6_MMAP_CGA, GRUB_VGA_GR_GR6);
|
||||
grub_vga_gr_write (GRUB_VGA_GR_MODE_ODD_EVEN, GRUB_VGA_GR_MODE);
|
||||
|
||||
grub_vga_sr_write (GRUB_VGA_SR_MEMORY_MODE_NORMAL, GRUB_VGA_SR_MEMORY_MODE);
|
||||
|
||||
grub_vga_sr_write ((1 << GRUB_VGA_TEXT_TEXT_PLANE)
|
||||
| (1 << GRUB_VGA_TEXT_ATTR_PLANE),
|
||||
GRUB_VGA_SR_MAP_MASK_REGISTER);
|
||||
|
||||
grub_vga_cr_write (15, GRUB_VGA_CR_CELL_HEIGHT);
|
||||
grub_vga_cr_write (79, GRUB_VGA_CR_WIDTH);
|
||||
grub_vga_cr_write (40, GRUB_VGA_CR_PITCH);
|
||||
|
||||
int vert = 25 * 16;
|
||||
grub_vga_cr_write (vert & 0xff, GRUB_VGA_CR_HEIGHT);
|
||||
grub_vga_cr_write (((vert >> GRUB_VGA_CR_OVERFLOW_HEIGHT1_SHIFT)
|
||||
& GRUB_VGA_CR_OVERFLOW_HEIGHT1_MASK)
|
||||
| ((vert >> GRUB_VGA_CR_OVERFLOW_HEIGHT2_SHIFT)
|
||||
& GRUB_VGA_CR_OVERFLOW_HEIGHT2_MASK),
|
||||
GRUB_VGA_CR_OVERFLOW);
|
||||
|
||||
load_palette ();
|
||||
|
||||
grub_outb (0x10, 0x3c0);
|
||||
grub_outb (0, 0x3c1);
|
||||
grub_outb (0x14, 0x3c0);
|
||||
grub_outb (0, 0x3c1);
|
||||
|
||||
grub_vga_sr_write (GRUB_VGA_SR_CLOCKING_MODE_8_DOT_CLOCK,
|
||||
GRUB_VGA_SR_CLOCKING_MODE);
|
||||
|
||||
grub_vga_cr_write (14, GRUB_VGA_CR_CURSOR_START);
|
||||
grub_vga_cr_write (15, GRUB_VGA_CR_CURSOR_END);
|
||||
|
||||
grub_outb (0x20, 0x3c0);
|
||||
}
|
|
@ -58,9 +58,11 @@ inc_y (void)
|
|||
else
|
||||
{
|
||||
int x, y;
|
||||
for (y = 0; y < ROWS; y++)
|
||||
for (y = 0; y < ROWS - 1; y++)
|
||||
for (x = 0; x < COLS; x++)
|
||||
screen_write_char (x, y, screen_read_char (x, y + 1));
|
||||
for (x = 0; x < COLS; x++)
|
||||
screen_write_char (x, ROWS - 1, ' ' | (grub_console_cur_color << 8));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,11 +126,13 @@ static void
|
|||
grub_vga_text_setcursor (int on)
|
||||
{
|
||||
grub_uint8_t old;
|
||||
old = grub_vga_cr_read (GRUB_VGA_CR_CURSOR);
|
||||
old = grub_vga_cr_read (GRUB_VGA_CR_CURSOR_START);
|
||||
if (on)
|
||||
grub_vga_cr_write (old & ~GRUB_VGA_CR_CURSOR_DISABLE, GRUB_VGA_CR_CURSOR);
|
||||
grub_vga_cr_write (old & ~GRUB_VGA_CR_CURSOR_START_DISABLE,
|
||||
GRUB_VGA_CR_CURSOR_START);
|
||||
else
|
||||
grub_vga_cr_write (old | GRUB_VGA_CR_CURSOR_DISABLE, GRUB_VGA_CR_CURSOR);
|
||||
grub_vga_cr_write (old | GRUB_VGA_CR_CURSOR_START_DISABLE,
|
||||
GRUB_VGA_CR_CURSOR_START);
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
|
|
Loading…
Reference in a new issue