2008-08-02 Robert Millan <rmh@aybabtu.com>

* loader/i386/pc/multiboot.c (playground, forward_relocator)
        (backward_relocator): New variables.  Used to allocate and relocate
        the payload, respectively.
        (grub_multiboot_load_elf32): Load into heap instead of requested
        address, install the appropiate relocator code in each bound of
        the payload, and set the entry point such that
        grub_multiboot_real_boot() will jump to one of them.

        * kern/i386/loader.S (grub_multiboot_payload_size)
        (grub_multiboot_payload_orig, grub_multiboot_payload_dest)
        (grub_multiboot_payload_entry_offset): New variables.
        (grub_multiboot_real_boot): Set cpu context to what the relocator
        expects, and jump to the relocator instead of the payload.

        * include/grub/i386/loader.h (grub_multiboot_payload_size)
        (grub_multiboot_payload_orig, grub_multiboot_payload_dest)
        (grub_multiboot_payload_entry_offset): Export.
This commit is contained in:
robertmh 2008-08-02 12:12:14 +00:00
parent b15d8a0cc6
commit a927cc7383
4 changed files with 104 additions and 26 deletions

View file

@ -123,6 +123,15 @@ linux_setup_seg:
* This starts the multiboot kernel.
*/
VARIABLE(grub_multiboot_payload_size)
.long 0
VARIABLE(grub_multiboot_payload_orig)
.long 0
VARIABLE(grub_multiboot_payload_dest)
.long 0
VARIABLE(grub_multiboot_payload_entry_offset)
.long 0
FUNCTION(grub_multiboot_real_boot)
/* Push the entry address on the stack. */
pushl %eax
@ -136,11 +145,16 @@ FUNCTION(grub_multiboot_real_boot)
/* Interrupts should be disabled. */
cli
/* Move the magic value into eax and jump to the kernel. */
movl $MULTIBOOT_MAGIC2,%eax
popl %ecx
jmp *%ecx
/* Where do we copy what from. */
movl EXT_C(grub_multiboot_payload_size), %ecx
movl EXT_C(grub_multiboot_payload_orig), %esi
movl EXT_C(grub_multiboot_payload_dest), %edi
movl EXT_C(grub_multiboot_payload_entry_offset), %eax
/* Jump to the relocator. */
popl %edx
jmp *%edx
/*
* This starts the multiboot 2 kernel.
*/