From: robertmh Date: Mon, 29 Jun 2009 17:19:35 +0000 (+0000) Subject: 2009-06-29 Robert Millan X-Git-Tag: 1.98~748 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b09db61dddd7de15b7354513051ae2e8730119c9;p=thirdparty%2Fgrub.git 2009-06-29 Robert Millan * include/grub/i386/linux.h (GRUB_VIDEO_TYPE_TEXT): New macro. * loader/i386/linux.c [__i386__] (grub_linux_boot): Simplify inline assembly in final jump, using register constraints. (grub_linux_boot): For text mode, initialize `have_vga' using GRUB_VIDEO_TYPE_TEXT rather than 0 (this changes its value to 1). Initialize `video_cursor_x' and `video_cursor_y' as late as possible, right before the final jump. Set `video_mode' to 0x3. Document initialization of `video_page', `video_mode' and `video_ega_bx'. --- diff --git a/ChangeLog b/ChangeLog index ab44fb5d9..844f603b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,21 @@ 2009-06-29 Robert Millan + * include/grub/i386/linux.h (GRUB_VIDEO_TYPE_TEXT): New macro. + * loader/i386/linux.c [__i386__] (grub_linux_boot): Simplify inline assembly in final jump, using register constraints. + (grub_linux_boot): For text mode, initialize `have_vga' using + GRUB_VIDEO_TYPE_TEXT rather than 0 (this changes its value to 1). + + Initialize `video_cursor_x' and `video_cursor_y' as late as possible, + right before the final jump. + + Set `video_mode' to 0x3. + + Document initialization of `video_page', `video_mode' and + `video_ega_bx'. + 2009-06-29 Robert Millan * include/grub/i386/linux.h (GRUB_LINUX_FLAG_QUIET): New macro. diff --git a/include/grub/i386/linux.h b/include/grub/i386/linux.h index dc6c02e1b..641c09016 100644 --- a/include/grub/i386/linux.h +++ b/include/grub/i386/linux.h @@ -79,6 +79,7 @@ struct grub_e820_mmap grub_uint32_t type; } __attribute__((packed)); +#define GRUB_VIDEO_TYPE_TEXT 0x01 #define GRUB_VIDEO_TYPE_VLFB 0x23 /* VESA VGA in graphic mode */ #define GRUB_VIDEO_TYPE_EFI 0x70 diff --git a/loader/i386/linux.c b/loader/i386/linux.c index da2e34c4f..78fa84822 100644 --- a/loader/i386/linux.c +++ b/loader/i386/linux.c @@ -479,9 +479,7 @@ grub_linux_boot (void) params->have_vga = GRUB_VIDEO_TYPE_VLFB; else { - params->have_vga = 0; - params->video_cursor_x = grub_getxy () >> 8; - params->video_cursor_y = grub_getxy () & 0xff; + params->have_vga = GRUB_VIDEO_TYPE_TEXT; params->video_width = 80; params->video_height = 25; } @@ -536,6 +534,13 @@ grub_linux_boot (void) grub_mmap_iterate (hook); params->mmap_size = e820_num; + /* Initialize these last, because terminal position could be affected by printfs above. */ + if (params->have_vga == GRUB_VIDEO_TYPE_TEXT) + { + params->video_cursor_x = grub_getxy () >> 8; + params->video_cursor_y = grub_getxy () & 0xff; + } + #ifdef __x86_64__ grub_memcpy ((char *) prot_mode_mem + (prot_mode_pages << 12), @@ -664,8 +669,11 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), params->type_of_loader = (LINUX_LOADER_ID_GRUB << 4); + /* These two are used (instead of cmd_line_ptr) by older versions of Linux, + and otherwise ignored. */ params->cl_magic = GRUB_LINUX_CL_MAGIC; params->cl_offset = 0x1000; + params->cmd_line_ptr = (unsigned long) real_mode_mem + 0x1000; params->ramdisk_image = 0; params->ramdisk_size = 0; @@ -679,9 +687,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), params->ext_mem = ((32 * 0x100000) >> 10); params->alt_mem = ((32 * 0x100000) >> 10); - params->video_page = 0; /* ??? */ - params->video_mode = 0; + /* Ignored by Linux. */ + params->video_page = 0; + + /* Must be non-zero even in text mode, or Linux will think there's no VGA. */ + params->video_mode = 0x3; + + /* Only used when `video_mode == 0x7', otherwise ignored. */ params->video_ega_bx = 0; + params->font_size = 16; /* XXX */ /* The other parameters are filled when booting. */