From 579940128bcd6feeffed7e261b21d6a75c010226 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 29 Sep 2010 23:51:12 +0200 Subject: [PATCH] Fix coreboot compilation. * grub-core/loader/i386/multiboot_mbi.c (grub_multiboot_get_mbi_size): Take VBE info into account even if only text is supported. (fill_vbe_info): Take into account the case when only VGA text is supported. * include/grub/multiboot.h (GRUB_MACHINE_HAS_VBE): Set to zero on coreboot, multiboot and qemu. --- ChangeLog | 11 ++++++++++ grub-core/loader/i386/multiboot_mbi.c | 29 +++++++++++++++++++++------ include/grub/multiboot.h | 12 +++++++---- 3 files changed, 42 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 63c6e83ee..4614a1cac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2010-09-29 Vladimir Serbinenko + + Fix coreboot compilation. + + * grub-core/loader/i386/multiboot_mbi.c (grub_multiboot_get_mbi_size): + Take VBE info into account even if only text is supported. + (fill_vbe_info): Take into account the case when only VGA text + is supported. + * include/grub/multiboot.h (GRUB_MACHINE_HAS_VBE): Set to zero + on coreboot, multiboot and qemu. + 2010-09-29 Vladimir Serbinenko * grub-core/lib/relocator.c (malloc_in_range): Trim too verbose diff --git a/grub-core/loader/i386/multiboot_mbi.c b/grub-core/loader/i386/multiboot_mbi.c index 283b84c5a..79f72ee0f 100644 --- a/grub-core/loader/i386/multiboot_mbi.c +++ b/grub-core/loader/i386/multiboot_mbi.c @@ -187,6 +187,10 @@ grub_multiboot_load (grub_file_t file) return err; } +#if GRUB_MACHINE_HAS_VBE || GRUB_MACHINE_HAS_VGA_TEXT +#include +#endif + static grub_size_t grub_multiboot_get_mbi_size (void) { @@ -196,7 +200,7 @@ grub_multiboot_get_mbi_size (void) + grub_get_multiboot_mmap_count () * sizeof (struct multiboot_mmap_entry) + elf_sec_entsize * elf_sec_num + 256 * sizeof (struct multiboot_color) -#if GRUB_MACHINE_HAS_VBE +#if GRUB_MACHINE_HAS_VBE || GRUB_MACHINE_HAS_VGA_TEXT + sizeof (struct grub_vbe_info_block) + sizeof (struct grub_vbe_mode_info_block) #endif @@ -247,15 +251,17 @@ grub_fill_multiboot_mmap (struct multiboot_mmap_entry *first_entry) grub_mmap_iterate (hook); } -#if GRUB_MACHINE_HAS_VBE +#if GRUB_MACHINE_HAS_VBE || GRUB_MACHINE_HAS_VGA_TEXT + static grub_err_t fill_vbe_info (struct multiboot_info *mbi, grub_uint8_t *ptrorig, grub_uint32_t ptrdest, int fill_generic) { - grub_vbe_status_t status; grub_uint32_t vbe_mode; - void *scratch = (void *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR; struct grub_vbe_mode_info_block *mode_info; +#if GRUB_MACHINE_HAS_VBE + grub_vbe_status_t status; + void *scratch = (void *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR; status = grub_vbe_bios_get_controller_info (scratch); if (status != GRUB_VBE_STATUS_OK) @@ -265,11 +271,18 @@ fill_vbe_info (struct multiboot_info *mbi, grub_uint8_t *ptrorig, grub_memcpy (ptrorig, scratch, sizeof (struct grub_vbe_info_block)); ptrorig += sizeof (struct grub_vbe_info_block); ptrdest += sizeof (struct grub_vbe_info_block); - +#else + mbi->vbe_control_info = 0; +#endif + +#if GRUB_MACHINE_HAS_VBE status = grub_vbe_bios_get_mode (scratch); vbe_mode = *(grub_uint32_t *) scratch; if (status != GRUB_VBE_STATUS_OK) return grub_error (GRUB_ERR_IO, "can't get VBE mode"); +#else + vbe_mode = 3; +#endif mbi->vbe_mode = vbe_mode; mode_info = (struct grub_vbe_mode_info_block *) ptrorig; @@ -284,18 +297,22 @@ fill_vbe_info (struct multiboot_info *mbi, grub_uint8_t *ptrorig, } else { +#if GRUB_MACHINE_HAS_VBE status = grub_vbe_bios_get_mode_info (vbe_mode, scratch); if (status != GRUB_VBE_STATUS_OK) return grub_error (GRUB_ERR_IO, "can't get mode info"); grub_memcpy (mode_info, scratch, sizeof (struct grub_vbe_mode_info_block)); +#endif } ptrorig += sizeof (struct grub_vbe_mode_info_block); ptrdest += sizeof (struct grub_vbe_mode_info_block); - + +#if GRUB_MACHINE_HAS_VBE grub_vbe_bios_get_pm_interface (&mbi->vbe_interface_seg, &mbi->vbe_interface_off, &mbi->vbe_interface_len); +#endif mbi->flags |= MULTIBOOT_INFO_VBE_INFO; diff --git a/include/grub/multiboot.h b/include/grub/multiboot.h index 364dc3ca6..9a0b57359 100644 --- a/include/grub/multiboot.h +++ b/include/grub/multiboot.h @@ -53,15 +53,19 @@ grub_multiboot_add_elfsyms (grub_size_t num, grub_size_t entsize, grub_uint32_t grub_get_multiboot_mmap_count (void); grub_err_t grub_multiboot_set_video_mode (void); -#if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_MULTIBOOT) || defined (GRUB_MACHINE_QEMU) -#include -#define GRUB_MACHINE_HAS_VGA_TEXT 1 +/* FIXME: support coreboot as well. */ +#if defined (GRUB_MACHINE_PCBIOS) #define GRUB_MACHINE_HAS_VBE 1 #else -#define GRUB_MACHINE_HAS_VGA_TEXT 0 #define GRUB_MACHINE_HAS_VBE 0 #endif +#if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_MULTIBOOT) || defined (GRUB_MACHINE_QEMU) +#define GRUB_MACHINE_HAS_VGA_TEXT 1 +#else +#define GRUB_MACHINE_HAS_VGA_TEXT 0 +#endif + #if defined (GRUB_MACHINE_EFI) || defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_MULTIBOOT) #define GRUB_MACHINE_HAS_ACPI 1 #else