* include/grub/i386/coreboot/memory.h (GRUB_MEMORY_MACHINE_LOWER_SIZE):
Redefine to match with GRUB_MEMORY_MACHINE_UPPER_START (0x100000). We
don't want to mess with lower memory, because it is used in the Linux
loader.
* loader/i386/linux.c (allocate_pages): Allocate `real_mode_mem' in
an appropiate place in lower memory, between 0x10000 and 0x90000,
like loader/i386/efi/linux.c does. Linux often panics if real_mode_mem
is in our heap (probably as a result of it being corrupted during
decompression).
* loader/i386/pc/multiboot.c (grub_multiboot_load_elf32): Skip
segments when their filesz is zero (grub_file_read() interprets
zero-size as "read untill EOF", which results in memory corruption).
Use `lowest_segment' rather than 0 for calculating the current
segment load address.
* loader/i386/pc/multiboot.c (mmap_addr, mmap_length): Remove
variables.
(grub_multiboot): Move `mbi' allocation upwards, so that mmap address
and length can be stored directly in the `mbi->mmap_addr' and
`mbi->mmap_length' struct fields.
* conf/i386-pc.rmk (kernel_img_SOURCES): Add `kern/i386/pc/mmap.c'.
* include/grub/i386/pc/init.h (GRUB_MACHINE_MEMORY_AVAILABLE)
(GRUB_MACHINE_MEMORY_RESERVED): New macros.
(grub_machine_mmap_iterate): New function declaration.
* include/grub/multiboot.h (struct grub_multiboot_mmap_entry): New
structure.
(GRUB_MMAP_MEMORY_AVAILABLE, GRUB_MMAP_MEMORY_RESERVED): New
macros.
* kern/i386/pc/init.c (grub_machine_init): Replace hardcoded region
type check value with `GRUB_MACHINE_MEMORY_AVAILABLE'.
Move e820 parsing from here ...
* kern/i386/pc/mmap.c: New file.
(grub_machine_mmap_iterate): ... to here.
* include/grub/i386/coreboot/memory.h: Remove `<grub/err.h>'.
(GRUB_LINUXBIOS_MEMORY_AVAILABLE): Rename (for consistency) to ...
(GRUB_MACHINE_MEMORY_AVAILABLE): ... this. Update all users.
(grub_available_iterate): Redeclare to return `void', and redeclare
its hook to use grub_uint64_t as addr and size parameters, and rename
to ...
(grub_machine_mmap_iterate): ... this. Update all users.
* kern/i386/coreboot/mmap.c (grub_mmap_iterate): Simplify parser loop
to make it more readable. Rename to ...
(grub_machine_mmap_iterate): ... this.
* loader/i386/pc/multiboot.c (mmap_addr, mmap_length): New variables.
(grub_get_multiboot_mmap_len, grub_fill_multiboot_mmap): New functions.
(grub_multiboot): Allocate an extra region after the payload, and fill
it with a Multiboot memory map. Adjust a.out loader to calculate size
with the extra space.
(grub_multiboot_load_elf32): Adjust elf32 loader to calculate size
with the extra space.
* 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.
* loader/i386/pc/multiboot.c (grub_multiboot_load_elf32): When loading
ELF segments, use a macro for arbitrarily accessing any of them instead
of preparing a pointer that allows access to one at a time.
(grub_multiboot_load_elf64): Likewise.
* Makefile.in (RMKFILES): Add missing arch i386-ieee1275 and
i386-linuxbios.
* commands/hexdump.c (grub_cmd_hexdump): Support dumping of device,
change the buffer size to 4096 for cdrom device.
* conf/i386-ieee1275.rmk (pkglib_MODULES): Add _linux.mod, linux.mod
and nand.mod.
(_linux_mod_SOURCES): New variable.
(_linux_mod_CFLAGS): Likewise.
(_linux_mod_LDFLAGS): Likewise.
(linux_mod_SOURCES): Likewise.
(linux_mod_CFLAGS): Likewise.
(linux_mod_LDFLAGS): Likewise.
(nand_mod_SOURCES): Likewise.
(nand_mod_CFLAGS): Likewise.
(nand_mod_LDFLAGS): Likewise.
* disk/ieee1275/ofdisk.c (grub_ofdisk_open): Return
GRUB_ERR_UNKNOWN_DEVICE instead of GRUB_ERR_BAD_DEVICE if no device
type property. (nand device in olpc don't have this property)
* include/grub/disk.h (grub_disk_dev_id): New macro
GRUB_DISK_DEVICE_NAND_ID.
* include/grub/i386/ieee1275/loader.h (grub_rescue_cmd_linux): New
function prototype.
(grub_rescue_cmd_initrd): Likewise.
* include/grub/i386/linux.h (GRUB_LINUX_OFW_SIGNATURE): New macro.
(linux_kernel_params): Add new member ofw_signature, ofw_num_items,
ofw_cif_handler and ofw_idt, adjust padding number.
* include/grub/i386/pc/memory.h (grub_upper_mem): Export it if
GRUB_MACHINE_IEEE1275 is defined.
* include/grub/ieee1275/ieee1275.h (grub_available_iterate):
Use NESTED_FUNC_ATTR attribute on the hook parameter.
* kern/powerpc/ieee1275/init.c (grub_claim_heap): Use NESTED_FUNC_ATTR
on nested function heap_init.
(grub_upper_mem): New variable for i386-ieee1275.
(grub_get_extended_memory): New function for i386-ieee1275.
(grub_machine_init): Call grub_get_extended_memory for i386-ieee1275.
* kern/powerpc/ieee1275/openfw.c (grub_available_iterate): Use
NESTED_FUNC_ATTR on the hook parameter. Don't quit if no device type
property.
* loader/i386/ieee1275/linux.c: New file.
* loader/i386/ieee1275/linux_normal.c: New file.
* disk/ieee1275/nand.c: New file.
* loader/i386/pc/multiboot.c (grub_multiboot_get_bootdev): New function.
(grub_multiboot): Set boot device.
* boot/i386/pc/lnxboot.S (real_code_2): Set %dh to 0xFF.
* 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.
* loader/i386/pc/multiboot.c (grub_multiboot_load_elf32): Get physical
address of entry.
(grub_multiboot_load_elf64): Likewise.
(grub_multiboot): Initialize mbi structure.
* util/grub-fstest.c: Don't include unused header file script.h.
* conf/common.rmk (grub-fstest.c_DEPENDENCIES): Move to the begginning
of file.
(grub_fstest_SOURCES): Likewise.
* loader/i386/pc/linux.c (grub_rescue_cmd_linux): For
`! grub_linux_is_bzimage', change order of address comparison to make
it more intuitive, and improve "too big zImage" error message.
* loader/i386/pc/multiboot.c (grub_multiboot_load_elf32): Improve error
message when loaded image is out of bounds.
(grub_multiboot_load_elf64): Likewise.
* include/grub/i386/pc/init.h (grub_lower_mem): Moved from here ...
* include/grub/i386/pc/memory.h (grub_lower_mem): ... to here.
* include/grub/i386/pc/init.h (grub_upper_mem): Moved from here ...
* include/grub/i386/pc/memory.h (grub_upper_mem): ... to here.
* include/grub/i386/pc/memory.h: Include `<grub/symbol.h>' and
`<grub/types.h>'.
* loader/i386/pc/multiboot.c: Include `<grub/machine/memory.h>'.
Do not use devices at boot in chainloading.
* loader/i386/pc/chainloader.c (boot_drive): New variable.
(boot_part_addr): Likewise.
(grub_chainloader_boot): Simply call grub_chainloader_real_boot
with BOOT_DRIVE and BOOT_PART_ADDR.
(grub_chainloader_cmd): Set BOOT_DRIVE and BOOT_PART_ADDR.
Reported by Hitoshi Ozeki <h-ozeki@ck2.so-net.ne.jp>.
for powerpc & i386-pc. This patch was more so started by Hollis
Blanchard getting multiboot 2 working for powerpc and I added to it
and cleaned it up.
One of the ideas with this patch is to keep everything under one
command for the user. So instead of having a "multiboot2" & "module2"
command, I created a proxy like mechanism so that you have only one
command for both multiboot 1 & 2 ... "multiboot". This is where
"loader/multiboot_loader.c" comes from. I could have integrated things
more but I figure the current approach will less likely break
anything.
So if your OS is multiboot 2 capable, the user would do the following
to load it up from a grub prompt:
grub> multiboot <location of kernel> <kernel args>
grub> module <some image> <multiboot tag> <image arguments>
grub> module <isome mage> <multiboot tag> <image arguments>
grub .....
The other thing that this patch does is it begins to make the
multiboot 1 code a bit more architecture agnostic so IF someone wanted
to implement it on another architecture they can.
A bit of file moving around and definition renaming is also apart of
this patch. I have also taken the time to make sure that it does not
break multiboot 1 loading on i386-pc. But mulitboot 2 may still need a
little more testing and work for i386-pc. Powerpc multiboot 2 has been
heavily tested and does work.
* loader/i386/pc/linux.c (grub_rescue_cmd_initrd): The conditional
of checking LINUX_MEM_SIZE was reverse. Reported by Jesus
Velazquez <jesus.velazquez@gmail.com>.
Clean up the code to support 64-bit addressing in disks and
files. This change is not enough for filesystems yet.
* util/i386/pc/grub-setup.c (struct boot_blocklist): Change the
type of "start" to grub_uint64_t.
(setup): Change the types of KERNEL_SECTOR and FIRST_SECTOR to
grub_disk_addr_t * and grub_disk_addr_t. Fix the format string in
save_first_sector and save_blocklists. Use grub_le_to_cpu64 to
convert addresses.
* util/i386/pc/biosdisk.c (open_device): Change the type of SECTOR
to grub_disk_addr_t.
* partmap/gpt.c (gpt_partition_map_iterate): Fix the format
string.
* partmap/pc.c (pc_partition_map_iterate): Likewise.
* partmap/amiga.c (amiga_partition_map_iterate): Cast RDSK.MAGIC
to char *.
* normal/script.c (grub_script_parse): Remove unused MEMFREE.
* normal/parser.y (YYLTYPE_IS_TRIVIAL): New macro.
* normal/lexer.c (grub_script_yyerror): Specify unused to LEX.
* loader/i386/pc/multiboot.c (grub_multiboot_load_elf64): Cast -1
to grub_off_t, to detect an error from grub_file_seek.
(grub_multiboot_load_elf32): Likewise.
* kern/misc.c (grub_strtoul): Use grub_strtoull. Return the
maximum unsigned long value when an overflow is detected.
(grub_strtoull): New function.
(grub_divmod64): Likewise.
(grub_lltoa): use grub_divmod64.
* kern/fs.c (struct grub_fs_block): Change the type of "offset" to
grub_disk_addr_t.
(grub_fs_blocklist_open): Increase P if P is not NULL to advance
the pointer to next character. Use grub_strtoull instead of
grub_strtoul.
(grub_fs_blocklist_read): Change the types of SECTOR, OFFSET and
SIZE to grub_disk_addr_t, grub_off_t and grub_size_t,
respectively.
* kern/file.c (grub_file_read): Prevent an oveflow of LEN, as the
return value is signed.
(grub_file_seek): Change the type of OLD to grub_off_t. Do not
test if OFFSET is less than zero, as OFFSET is unsigned now.
* kern/disk.c (struct grub_disk_cache): Change the type of
"sector" to grub_disk_addr_t.
(grub_disk_cache_get_index): Change the type of SECTOR to
grub_disk_addr_t. Calculate the hash with SECTOR casted to
unsigned after shifting.
(grub_disk_cache_invalidate): Change the type of SECTOR to
grub_disk_addr_t.
(grub_disk_cache_unlock): Likewise.
(grub_disk_cache_store): Likewise.
(grub_disk_check_range): Change the types of SECTOR, OFFSET, SIZE,
START and LEN to grub_disk_addr_t *, grub_off_t *, grub_size_t,
grub_disk_addr_t and grub_uint64_t, respectively.
(grub_disk_read): Use an unsigned variable REAL_OFFSET for the
body, as the value of OFFSET is tweaked by
grub_disk_check_range. Change the types of START_SECTOR, LEN and
POS to grub_disk_addr_t, grub_size_t and grub_size_t,
respectively.
(grub_disk_write): Use an unsigned variable REAL_OFFSET for the
body, as the value of OFFSET is tweaked by
grub_disk_check_range. Change the types of LEN and N to
grub_size_t.
* io/gzio.c (struct grub_gzio): Change the types of "data_offset"
and "saved_offset" to grub_off_t.
(test_header): Cast BUF to char *.
(get_byte): Cast GZIO->DATA_OFFSET to grub_off_t. Cast GZIO->INBUF
to char *.
(grub_gzio_read): Change the types of OFFSET and SIZE to
grub_off_t and grub_size_t, respectively.
* include/grub/i386/pc/boot.h (GRUB_BOOT_MACHINE_FORCE_LBA):
Removed.
(GRUB_BOOT_MACHINE_BOOT_DRIVE): Changed to 0x4c.
(GRUB_BOOT_MACHINE_KERNEL_ADDRESS): Changed to 0x40.
(GRUB_BOOT_MACHINE_KERNEL_SEGMENT): Changed to 0x42.
(GRUB_BOOT_MACHINE_DRIVE_CHECK): Changed to 0x4e.
(GRUB_BOOT_MACHINE_LIST_SIZE): Increased to 12.
* include/grub/types.h (grub_off_t): Unconditionally set to
grub_uint64_t.
(grub_disk_addr_t): Changed to grub_uint64_t.
* include/grub/partition.h (struct grub_partition): Change the
types of "start", "len" and "offset" to grub_disk_addr_t,
grub_uint64_t and grub_disk_addr_t, respectively.
(grub_partition_get_start): Return grub_disk_addr_t.
(grub_partition_get_len): Return grub_uint64_t.
* include/grub/misc.h (grub_strtoull): New prototype.
(grub_divmod64): Likewise.
* include/grub/fshelp.h (grub_fshelp_read_file): Change the types
of SECTOR, LEN and FILESIZE to grub_disk_addr_t, grub_size_t and
grub_off_t, respectively.
All callers and references changed.
* include/grub/fs.h (struct grub_fs): Change the type of LEN to
grub_size_t in "read".
All callers and references changed.
* include/grub/file.h (struct grub_file): Change the types of
"offset" and "size" to grub_off_t and grub_off_t,
respectively. Change the type of SECTOR to grub_disk_addr_t in
"read_hook".
(grub_file_read): Change the type of LEN to grub_size_t.
(grub_file_seek): Return grub_off_t. Change the type of OFFSET to
grub_off_t.
(grub_file_size): Return grub_off_t.
(grub_file_tell): Likewise.
All callers and references changed.
* include/grub/disk.h (struct grub_disk_dev): Change the types of
SECTOR and SIZE to grub_disk_addr_t and grub_size_t in "read" and
"write".
(struct grub_disk): Change the type of "total_sectors" to
grub_uint64_t. Change the type of SECTOR to grub_disk_addr_t in
"read_hook".
(grub_disk_read): Change the types of SECTOR, OFFSET and SIZE to
grub_disk_addr_t, grub_off_t and grub_size_t, respectively.
(grub_disk_write): Likewise.
All callers and references changed.
* fs/iso9660.c (grub_iso9660_susp_iterate): Cast parameters to
char * for grub_strncmp to silence gcc.
(grub_iso9660_mount): Likewise.
(grub_iso9660_mount): Likewise.
(grub_iso9660_read_symlink): Likewise. Also, remove the nonsense
return statement.
(grub_iso9660_iterate_dir): Likewise.
(grub_iso9660_label): Cast DATA->VOLDESC.VOLNAME to char *.
* fs/hfs.c (grub_hfs_read_file): Change the types of SECTOR and
LEN to grub_disk_addr_t and grub_size_t, respectively.
* fs/hfsplus.c (grub_hfsplus_read_file): Likewise.
* fs/jfs.c (grub_jfs_read_file): Likewise.
* fs/minix.c (grub_jfs_read_file): Likewise.
* fs/sfs.c (grub_jfs_read_file): Likewise.
* fs/ufs.c (grub_jfs_read_file): Likewise.
* fs/xfs.c (grub_jfs_read_file): Likewise.
* fs/fat.c (grub_fat_read_data): Change the types of SECTOR, LEN
and SIZE to grub_disk_addr_t, grub_size_t and grub_size_t,
respectively.
* fs/ext2.c (grub_ext2_read_block): When an error happens, set
BLKNR to -1 instead of returning GRUB_ERRNO.
(grub_ext2_read_file): Change the types of SECTOR and
LEN to grub_disk_addr_t and grub_size_t, respectively.
* fs/affs.c (grub_affs_read_file): Change the types of SECTOR and
LEN to grub_disk_addr_t and grub_size_t, respectively.
* font/manager.c (grub_font_get_glyph): Cast BITMAP to char * for
grub_file_read.
* disk/ieee1275/ofdisk.c (grub_ofdisk_read): Fix the format
string. Do not cast SECTOR explicitly.
* disk/i386/pc/biosdisk.c (grub_biosdisk_open): Change the type of
TOTAL_SECTORS to grub_uint64_t. Do not mask DRP->TOTAL_SECTORS.
(grub_biosdisk_rw): Change the types of SECTOR and SIZE to
grub_disk_addr_t and grub_size_t, respectively. If the sector is
over 2TB and LBA mode is not supported, raise an error.
(get_safe_sectors): New function.
(grub_biosdisk_read): Use get_safe_sectors.
(grub_biosdisk_write): Likewise.
* disk/efi/efidisk.c (grub_efidisk_read): Fix the format string.
(grub_efidisk_write): Likewise.
* disk/loopback.c (delete_loopback): Cosmetic changes.
(grub_cmd_loopback): Likewise. Also, test NEWDEV->FILENAME
correctly.
(grub_loopback_open): Likewise.
(grub_loopback_read): Likewise. Also, change the type of POS to
grub_off_t, and fix the usage of grub_memset.
* commands/i386/pc/play.c: Include grub/machine/time.h.
* commands/ls.c (grub_ls_list_files): Use "llu" instead of "d" to
print FILE->SIZE.
* commands/configfile.c: Include grub/env.h.
* commands/cmp.c (grub_cmd_cmp): Do not use ERR, but use
GRUB_ERRNO directly instead. Change the type of POS to
grub_off_t. Follow the coding standard.
* commands/blocklist.c: Include grub/partition.h.
(grub_cmd_blocklist): Return an error if the underlying device is
not a disk. Take the starting sector of a partition into account,
if a partition is used.
* boot/i386/pc/diskboot.S (bootloop): Adapted to the new offset of
a length field.
(lba_mode): Support 64-bit addresses.
(chs_mode): Likewise.
(copy_buffer): Adapted to the new offsets of a length field and a
segment field.
(blocklist_default_start): Allocate 64-bit space.
* boot/i386/pc/boot.S (force_lba): Removed.
(boot_drive): Moved to under KERNEL_SECTOR.
(kernel_sector): Moved to under KENREL_SEGMENT. Allocate 64-bit
space.
(real_start): Set %si earlier. Remove code for FORCE_LBA, since it
is useless.
(lba_mode): Refactored to support a 64-bit address. More size
optimization.
(setup_sectors): Likewise.
* fs/hfsplus.c (grub_hfsplus_btree_recoffset): Moved to near the
top.
(grub_hfsplus_btree_recptr): Likewise.
(grub_hfsplus_find_block): Do not take RETRY any longer. Use
FILEBLOCK both to pass a block number and store next block
number.
(grub_hfsplus_read_block): Rewritten heavily to support an extent
overflow file correctly. Specify errors appropriately, because
fshelp expects that GRUB_ERRNO is set when fails. Reuse
grub_hfsplus_btree_recptr to get the pointer to a found key.
(grub_hfsplus_btree_search): Return 1 instead of 0 when no match
is found.
* conf/i386-efi.rmk (pkgdata_MODULES): Added _linux.mod and
linux.mod.
(_linux_mod_SOURCES): New variable.
(_linux_mod_CFLAGS): Likewise.
(_linux_mod_LDFLAGS): Likewise.
(linux_mod_SOURCES): Likewise.
(linux_mod_CFLAGS): Likewise.
(linux_mod_LDFLAGS): Likewise.
* DISTLIST: Added loader/i386/efi/linux.c,
loader/i386/efi/linux_normal.c and
include/grub/i386/efi/loader.h.
* loader/i386/efi/linux.c: New file.
* loader/i386/efi/linux_normal.c: Likewise.
* include/grub/i386/efi/loader.h: Likewise.
* kern/i386/pc/startup.S: Include grub/cpu/linux.h instead of
grub/machine/linux.h
* loader/i386/pc/linux.c: Likewise.
* include/grub/i386/pc/linux.h: Moved to ...
* include/grub/i386/linux.h: ... here.
* include/grub/i386/linux.h (struct linux_kernel_params): New
struct.
Extend the loader so that GRUB can accept a loader which comes
back to GRUB when a loaded image exits. Also, this change adds
support for a chainloader on EFI.
* term/efi/console.c: Include grub/misc.h.
(grub_console_checkkey): Display a scan code on the top for
debugging. This will be removed once the EFI port gets stable.
Correct the scan code mapping.
* kern/efi/mm.c (sort_memory_map): Sort in a descending order to
allocate memory from larger regions, in order to reduce the number
of allocated regions. Otherwise, the MacOSX loader panics.
(filter_memory_map): Avoid less than 1MB for compatibility with
other loaders.
(add_memory_regions): Allocate from the tail of a region, if
possible, to avoid allocating a region near to 1MB, for the MacOSX
loader.
* kern/efi/init.c (grub_efi_set_prefix): Specify
GRUB_EFI_IMAGE_HANDLE to grub_efi_get_loaded_image.
* kern/efi/efi.c (grub_efi_get_loaded_image): Accept a new
argument IMAGE_HANDLE and specify it to get a loaded image.
(grub_arch_modules_addr): Specify GRUB_EFI_IMAGE_HANDLE to
grub_efi_get_loaded_image.
(grub_efi_get_filename): Divide the legnth by the size of
grub_efi_char16_t.
(grub_efi_get_device_path): New function.
(grub_efi_print_device_path): Print End Device Path nodes. Divide
the length by the size of grub_efi_char16_t for a file path device
path node.
* kern/loader.c (grub_loader_noreturn): New variable.
(grub_loader_set): Accept a new argument NORETURN. Set
GRUB_LOADER_NORETURN to NORETURN.
All callers changed.
(grub_loader_boot): If GRUB_LOADER_NORETURN is false, do not call
grub_machine_fini.
* include/grub/efi/efi.h (grub_efi_get_device_path): New
prototype.
(grub_efi_get_loaded_image): Take an argument to specify an image
handle.
* include/grub/loader.h (grub_loader_set): Added one more argument
NORETURN.
* disk/efi/efidisk.c (make_devices): Use grub_efi_get_device_path
instead of grub_efi_open_protocol.
(grub_efidisk_get_device_name): Likewise.
(grub_efidisk_close): Print a newline.
(grub_efidisk_get_device_handle): Fixed to use
GRUB_EFI_DEVICE_PATH_SUBTYPE instead of
GRUB_EFI_DEVICE_PATH_TYPE.
* disk/efi/efidisk.c (device_path_guid): Moved to ...
* kern/efi/efi.c (device_path_guid): ... here.
* conf/i386-efi.rmk (pkgdata_MODULES): Added _chain.mod and
chain.mod.
(kernel_mod_HEADERS): Added efi/disk.h.
(_chain_mod_SOURCES): New variable.
(_chain_mod_CFLAGS): Likewise.
(_chain_mod_LDFLAGS): Likewise.
(chain_mod_SOURCES): Likewise.
(chain_mod_CFLAGS): Likewise.
(chain_mod_LDFLAGS): Likewise.
* DISTLIST: Added include/grub/efi/chainloader.h,
loader/efi/chainloader.c and loader/efi/chainloader_normal.c.
* include/grub/efi/chainloader.h: New file.
* loader/efi/chainloader.c: Likewise.
* loader/efi/chainloader_normal.c: Likewise.
* loader/i386/pc/linux.c (grub_rescue_cmd_linux): Compare the file
size with GRUB_OS_AREA_SIZE as grub_size_t instead of
grub_ssize_t. Reported by Jeff Chua <jeff84@silk.corp.fedex.com>.
* loader/powerpc/ieee1275/linux.c (grub_rescue_cmd_linux): Specify
the boot file by the option BOOT_IMAGE. Use grub_stpcpy instead of
grub_strcat.
* loader/i386/pc/linux.c (grub_rescue_cmd_linux): Specify the boot
file by the option BOOT_IMAGE. Use grub_stpcpy instead of
grub_strcpy and grub_strlen. Take it into account that a space
character is inserted as a delimiter.
* loader/i386/pc/multiboot.c (grub_multiboot_is_elf32): New
function.
(grub_multiboot_load_elf32): Likewise.
(grub_multiboot_is_elf64): Likewise.
(grub_multiboot_load_elf64): Likewise.
(grub_multiboot_load_elf): Likewise.
(grub_rescue_cmd_multiboot): Call grub_multiboot_load_elf to load
an ELF32 or ELF64 file.
This is based on a patch from Ruslan Nikolaev <nruslan@mail.com>.
From Serbinenko Vladimir <serbinenko.vova@list.ru>:
* kern/disk.c (grub_print_partinfo): Check if FS->LABEL is not
NULL before calling FS->LABEL.
* fs/fat.c (grub_fat_dir): Initialize DIRNAME to NULL.
* commands/ls.c (grub_ls_list_files): Show labels, if possible.
(grub_ls_list_disks): Check if FS and FS->LABEL are not NULL
before calling FS->LABEL.