* include/grub/i386/loader.h (grub_linux16_boot): Renamed to ...
(grub_linux16_real_boot): ... this.
* kern/i386/loader.S: Likewise.
* loader/i386/pc/linux.c: Include `<grub/video.h>' and `<grub/mm.h>'.
(grub_linux16_boot): New function. Switches to text mode and calls
grub_linux16_real_boot().
* loader/i386/bsd.c: Include `<grub/video.h>'.
(grub_freebsd_boot, grub_openbsd_boot, grub_netbsd_boot): Switch to
text mode before calling grub_unix_real_boot().
* loader/i386/multiboot.c: Include `<grub/video.h>'.
(grub_multiboot_boot): Switch to text mode before calling
grub_relocator32_boot().
* loader/i386/pc/chainloader.c: Include `<grub/video.h>'.
(grub_chainloader_boot): Switch to text mode before calling
grub_chainloader_real_boot().
FreeBSD 64-bit support
* conf/i386-pc.rmk (bsd_mod_SOURCES): add loader/i386/bsd_helper.S
and loader/i386/bsd_trampoline.S
(bsd_mod_ASFLAGS): new variable
* include/grub/i386/bsd.h (FREEBSD_MODINFOMD_SMAP): new definition
(FREEBSD_MODTYPE_KERNEL64): likewise
(grub_bsd64_trampoline_start): likewise
(grub_bsd64_trampoline_end): likewise
(grub_bsd64_trampoline_selfjump): likewise
(grub_bsd64_trampoline_gdt): likewise
* include/grub/i386/loader.h (grub_unix_real_boot): moved from here ...
* include/grub/i386/bsd.h (grub_unix_real_boot): ... moved here
* kern/i386/loader.S (grub_unix_real_boot): moved from here ...
* loader/i386/bsd_helper.S (grub_unix_real_boot): moved here
* include/grub/gpt_partition.h (grub_gpt_partentry): Corrected the type
of "attrib" member
* loader/i386/bsd_pagetable.c: new file
* loader/i386/bsd_trampoline.S: likewise
* loader/i386/bsd.c (ALIGN_QWORD): new macro
(ALIGN_VAR): likewise
(entry_hi): new variable
(kern_end_mdofs): likewise
(is_64bit): likewise
(grub_freebsd_add_meta): use ALIGN_VAR
(grub_e820_mmap): new declaration
(grub_freebsd_add_mmap): new function
(grub_freebsd_add_meta_module): support 64 bit kernels
(grub_freebsd_list_modules): use ALIGN_VAR
(gdt_descriptor): new declaration
(grub_freebsd_boot): support 64 bit kernels
(grub_bsd_elf64_hook): new function
(grub_bsd_load_elf): support elf64
* loader/i386/pc/multiboot.c (grub_multiboot_load_elf32): Move part
of the relocation code from here ...
(grub_multiboot): ... to here.
(forward_relocator, backward_relocator): Move from here ...
* kern/i386/loader.S (grub_multiboot_forward_relocator)
(grub_multiboot_backward_relocator): ... to here.
(grub_multiboot_real_boot): Use %edx for entry offset. Put Multiboot
magic in %eax. Use %ebp for jumping (so %edx is not trashed).
* include/grub/i386/loader.h (grub_multiboot_forward_relocator)
(grub_multiboot_forward_relocator_end)
(grub_multiboot_backward_relocator)
(grub_multiboot_backward_relocator_end): New variables.
* 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.
* conf/i386-pc.rmk (pkglib_MODULES): Add aout.mod _bsd.mod and bsd.mod.
(aout_mod_SOURCES): New variable.
(aout_mod_CFLAGS): Likewise.
(aout_mod_LDFLAGS): Likewise.
(_bsd_mod_SOURCES): New variable.
(_bsd_mod_CFLAGS): Likewise.
(_bsd_mod_LDFLAGS): Likewise.
(bsd_mod_SOURCES): New variable.
(bsd_mod_CFLAGS): Likewise.
(bsd_mod_LDFLAGS): Likewise.
* include/grub/aout.h: New file.
* include/grub/i386/loader.h (grub_unix_real_boot): New function.
* include/grub/i386/bsd.h: New file.
* include/grub/i386/pc/init.h (grub_get_mmap_entry): Use EXPORT_FUNC
to make it public.
* kern/elf.c (grub_elf32_load): Get the physical address after the hook
function is called, so that it's possible to change it inside the hook.
(grub_elf64_load): Likewise.
(grub_elf_file): Don't close the file if elf header is not found.
(grub_elf_close): Close the file if grub_elf_file fails (The new
grub_elf_file won't close it).
(grub_elf32_size): Use NESTED_FUNC_ATTR for nested function calcsize.
(grub_elf64_size): Likewise.
* kern/i386/loader.S (grub_unix_real_boot): New function.
* loader/aout.c: New file.
* loader/i386/bsd.c: New file.
* loader/i386/bsd_normal.c: New file.
* loader/i386/pc/multiboot.c (grub_multiboot): Handle a.out format.
* loader/multiboot2.c (grub_multiboot2): Reset grub_errno so that it
can test othe formats.