multiboot: disentangle multiboot and multiboot2.

Previously we had multiboot and multiboot2 declaring the same symbols.
This can potentially lead to aliasing and strange behaviours when e.g.
module instead of module2 is used with multiboot2.

Bug: #51137
This commit is contained in:
Vladimir Serbinenko 2017-08-14 12:51:26 +02:00 committed by Vincent Batts
parent aa34f69d5d
commit ec4630c2b5
8 changed files with 95 additions and 85 deletions

View file

@ -19,6 +19,13 @@
#ifndef GRUB_MULTIBOOT_CPU_HEADER
#define GRUB_MULTIBOOT_CPU_HEADER 1
#define MULTIBOOT2_INITIAL_STATE { .eax = MULTIBOOT2_BOOTLOADER_MAGIC, \
.ecx = 0, \
.edx = 0, \
/* Set esp to some random location in low memory to avoid breaking */ \
/* non-compliant kernels. */ \
.esp = 0x7ff00 \
}
#define MULTIBOOT_INITIAL_STATE { .eax = MULTIBOOT_BOOTLOADER_MAGIC, \
.ecx = 0, \
.edx = 0, \
@ -28,7 +35,7 @@
}
#define MULTIBOOT_ENTRY_REGISTER eip
#define MULTIBOOT_MBI_REGISTER ebx
#define MULTIBOOT_ARCHITECTURE_CURRENT MULTIBOOT_ARCHITECTURE_I386
#define MULTIBOOT2_ARCHITECTURE_CURRENT MULTIBOOT2_ARCHITECTURE_I386
#ifdef GRUB_MACHINE_EFI
#ifdef __x86_64__

View file

@ -19,11 +19,11 @@
#ifndef GRUB_MULTIBOOT_CPU_HEADER
#define GRUB_MULTIBOOT_CPU_HEADER 1
#define MULTIBOOT_INITIAL_STATE { .gpr[4] = MULTIBOOT_BOOTLOADER_MAGIC, \
#define MULTIBOOT2_INITIAL_STATE { .gpr[4] = MULTIBOOT2_BOOTLOADER_MAGIC, \
.jumpreg = 1 }
#define MULTIBOOT_ENTRY_REGISTER gpr[1]
#define MULTIBOOT_MBI_REGISTER gpr[5]
#define MULTIBOOT_ARCHITECTURE_CURRENT MULTIBOOT_ARCHITECTURE_MIPS32
#define MULTIBOOT2_ARCHITECTURE_CURRENT MULTIBOOT_ARCHITECTURE_MIPS32
#define MULTIBOOT_ELF32_MACHINE EM_MIPS
#define MULTIBOOT_ELF64_MACHINE EM_MIPS

View file

@ -22,19 +22,11 @@
#include <grub/file.h>
#ifdef GRUB_USE_MULTIBOOT2
#include <multiboot2.h>
/* Same thing as far as our loader is concerned. */
#define MULTIBOOT_BOOTLOADER_MAGIC MULTIBOOT2_BOOTLOADER_MAGIC
#define MULTIBOOT_HEADER_MAGIC MULTIBOOT2_HEADER_MAGIC
#else
#include <multiboot.h>
#endif
#include <grub/types.h>
#include <grub/err.h>
#ifndef GRUB_USE_MULTIBOOT2
typedef enum
{
GRUB_MULTIBOOT_QUIRKS_NONE = 0,
@ -42,7 +34,6 @@ typedef enum
GRUB_MULTIBOOT_QUIRK_MODULES_AFTER_KERNEL = 2
} grub_multiboot_quirks_t;
extern grub_multiboot_quirks_t grub_multiboot_quirks;
#endif
extern struct grub_relocator *grub_multiboot_relocator;
@ -60,7 +51,7 @@ void
grub_multiboot_add_elfsyms (grub_size_t num, grub_size_t entsize,
unsigned shndx, void *data);
grub_uint32_t grub_get_multiboot_mmap_count (void);
grub_uint32_t grub_multiboot_get_mmap_count (void);
grub_err_t grub_multiboot_set_video_mode (void);
/* FIXME: support coreboot as well. */

View file

@ -75,8 +75,8 @@
#define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64 9
#define MULTIBOOT_HEADER_TAG_RELOCATABLE 10
#define MULTIBOOT_ARCHITECTURE_I386 0
#define MULTIBOOT_ARCHITECTURE_MIPS32 4
#define MULTIBOOT2_ARCHITECTURE_I386 0
#define MULTIBOOT2_ARCHITECTURE_MIPS32 4
#define MULTIBOOT_HEADER_TAG_OPTIONAL 1
#define MULTIBOOT_LOAD_PREFERENCE_NONE 0