* boot/i386/pc/boot.S (boot_drive_check): New label.
* include/grub/i386/pc/boot.h (GRUB_BOOT_MACHINE_DRIVE_CHECK): New
macro.
* util/i386/pc/grub-setup.c (setup): Added a workaround for BIOSes
which do not pass a boot drive correctly. Copied from GRUB Legacy.
* kern/i386/pc/startup.S (gate_a20_try_system_control_port_a):
When turning off Gate A20, skip the check and return immediately,
because this is not fatal usually.
* conf/i386-pc.rmk (pxeboot_img_LDFLAGS): The text address should
be 0x7C00 instead of 0x8000.
* boot/i386/pc/pxeboot.S: Rewritten.
* kern/i386/pc/startup.S (gate_a20_try_bios): No need to specify
EXT_C.
(gate_a20_check_state): Read a byte from 0x108000. Invert the
result.
* kern/i386/pc/startup.S (grub_gate_a20): Rewritten for
robustness. This routine now supports a BIOS call and System
Control Port A to modify the gate A20.
* include/grub/i386/pc/kernel.h (GRUB_KERNEL_MACHINE_RAW_SIZE):
Increased to 0x440.
* disk/powerpc/ieee1275/ofdisk.c (grub_ofdisk_open): dprintf the
device path and resulting ihandle.
(grub_ofdisk_close): dprintf the ihandle being closed.
(grub_ofdisk_read): dprintf function parameters.
* kern/mm.c (grub_mm_init_region): Likewise.
* loader/powerpc/ieee1275/linux.c: Remove extra whitespace.
(grub_linux_boot): dprintf the Linux entry point, initrd address and
size, and boot arguments.
(grub_rescue_cmd_linux): dprintf each ELF segment's address and size
before loading into memory.
(grub_rescue_cmd_initrd): dprintf the initrd's address and size
before loading into memory.
* commands/cmp.c (BUFFER_SIZE): New macro.
(grub_cmd_cmp): Close the right file at the right time. Compare
only data just read. Don't report files of different size as
identical. Dynamically allocate buffers. Move variable
declarations at the beginning of function.
* DISTLIST: Added genfslist.sh.
* normal/main.c (fs_module_list): New variable.
(autoload_fs_module): New function.
(read_fs_list): Likewise.
(grub_normal_execute): Call read_fs_list.
* kern/fs.c (grub_fs_autoload_hook): New variable.
(grub_fs_probe): Added support for auto-loading.
* include/grub/normal.h (struct grub_fs_module_list): New struct.
(grub_fs_module_list_t): New type.
* include/grub/fs.h (grub_fs_autoload_hook_t): New type.
(grub_fs_autoload_hook): New prototype.
* genfslist.sh: New file.
* genmk.rb: Added a rule to generate a filesystem list.
* configure.ac: Fix the test for cross-compiling.
* genmk.rb (Program): Use `$(CC)' instead of `$(BUILD_CC)'. Don't
define GRUB_UTIL anymore.
* util/powerpc/ieee1275/grub-mkimage.c (load_note): Endian fixes
so this function works on other systems than just big endian.
(load_modules): Likewise.
(add_segments): Likewise.
* kern/mm.c (grub_free): If the next free block which is being
merged is the first free block, set the first block to the block
being freed.
Reported by Vincent Guffens <guffens@inma.ucl.ac.be>.
* boot/powerpc/ieee1275/cmain.c (module_info): Remove definition.
(grub_ieee1275_chosen): New variable.
(cmain): Initialize and use `grub_ieee1275_chosen' instead of
`chosen'.
* boot/powerpc/ieee1275/crt0.S (init_stack): Remove stack space.
* boot/powerpc/ieee1275/ieee1275.c (grub_ieee1275_get_property):
Rename first argument to `phandle' for consistency.
(grub_ieee1275_get_property_length): Likewise.
(grub_ieee1275_next_property): Likewise. Change type of first argument
to grub_ieee1275_phandle_t.
* include/grub/powerpc/ieee1275/ieee1275.h (grub_ieee1275_entry_fn):
Move export next to declaration.
(grub_ieee1275_chosen): New variable.
* include/grub/powerpc/ieee1275/kernel.h (GRUB_IEEE1275_MODULE_BASE):
Correct cosmetic typo.
* kern/powerpc/ieee1275/init.c (grub_set_prefix): Use
`grub_ieee1275_chosen'.
* kern/powerpc/ieee1275/openfw.c (grub_map): Likewise.
* loader/powerpc/ieee1275/linux.c (grub_linux_boot): Likewise.
(grub_rescue_cmd_linux): Set `initrd_addr' to 0.
* term/powerpc/ieee1275/ofconsole.c (grub_ofconsole_refresh): Use
`grub_ieee1275_chosen'.
* DISTLIST: New file.
* gendistlist.sh: Likewise.
* Makefile.in (COMMON_DISTFILES): Removed.
(BOOT_DISTFILES): Likewise.
(CONF_DISTFILES): Likewise.
(DISK_DISTFILES): Likewise.
(FS_DISTFILES): Likewise.
(INCLUDE_DISTFILES): Likewise.
(KERN_DISTFILES): Likewise.
(LOADER_DISTFILES): Likewise.
(TERM_DISTFILES): Likewise.
(UTIL_DISTFILES): Likewise.
(DISTFILES): Likewise.
(uninstall): Uninstall files in $(pkgdata_DATA).
(DISTLIST): New target.
(distdir): Use the contents of the file DISTLIST to get a list of
distributed files.
* fs/fat.c (grub_fat_mount): Ignore the 3rd bit of a media
descriptor. This is ported from GRUB Legacy.
* gencmdlist.sh: Added an extra semicolon to make it work with
old sed versions. Reported by Robert Bihlmeyer
<robbe@orcus.priv.at>.
Automatic loading of commands is supported.
* normal/main.c (read_command_list): New function.
(grub_normal_execute): Call read_command_list.
* normal/command.c (grub_register_command): Return zero or CMD.
Allocate CMD->NAME from the heap.
Initialize CMD->MODULE_NAME to zero.
Find the same name as well. If the same command is found and it is
a dummy command, overwrite members. If it is not a dummy command,
return zero.
(grub_unregister_command): Free Q->NAME and Q->MODULE_NAME.
(grub_command_find): If a dummy command is found, load a module
and retry to find a command only once.
* normal/cmdline.c (grub_tab_complete): Call grub_command_find to
make sure that each command is loaded.
* include/grub/normal.h (GRUB_COMMAND_FLAG_NOT_LOADED): New
macro.
(struct grub_command): Remove const from the member `name'.
Add a new member `module_name'.
(grub_register_command): Return grub_command_t.
* commands/help.c (grub_cmd_help): Call grub_command_find to make
sure that each command is loaded.
* genmk.rb (PModule::rule): Specify a module name without the
suffix ".mod" to gencmdlist.sh.
* normal/arg.c (grub_arg_show_help): Do not show the bug report
address.
* commands/help.c (grub_cmd_help): Do not print newlines after
the last command in print_command_help.
* commands/default.h: New file.
* commands/timeout.h: Likewise.
* normal/context.c: Likewise.
* util/misc.c: Do not include sys/times.h.
Include sys/time.h and grub/machine/time.h.
(grub_get_rtc): Rewritten with gettimeofday.
* util/grub-emu.c (main): Call grub_default_init and
grub_timeout_init before grub_normal_init, and call
grub_timeout_fini and grub_default_fini after grub_main.
* util/console.c (grub_ncurses_checkkey): Return the read
character or -1.
* normal/menu.c (run_menu): Set MENU->TIMEOUT to -1 once it
timeouts.
* normal/main.c (read_config_file): Push MENU. If this fails,
print an error and wait for a user input.
Print an error only if GRUB_ERRNO is not GRUB_ERR_NONE.
If a menu is empty or an error occurs, pop MENU.
(grub_normal_execute): Pop and free MENU after grub_menu_run
returns.
* kern/loader.c (grub_loader_boot): Call grub_machine_fini.
* include/grub/powerpc/ieee1275/time.h [GRUB_UTIL]: Do not
include time.h.
[GRUB_UTIL] (GRUB_TICKS_PER_SECOND): Use the same definition as
without GRUB_UTIL.
* include/grub/i386/pc/time.h [GRUB_UTIL]: Do not include
time.h.
[GRUB_UTIL] (GRUB_TICKS_PER_SECOND): Use the same definition as
without GRUB_UTIL.
* include/grub/normal.h (struct grub_menu_list): New struct.
(grub_menu_list_t): New type.
(struct grub_context): New struct.
(grub_context_t): New type.
(grub_register_command): Got rid of EXPORT_FUNC.
(grub_unregister_command): Likewise.
(grub_context_get): New prototype.
(grub_context_get_current_menu): Likewise.
(grub_context_push_menu): Likewise.
(grub_context_pop_menu): Likewise.
[GRUB_UTIL] (grub_default_init): Likewise.
[GRUB_UTIL] (grub_default_fini): Likewise.
[GRUB_UTIL] (grub_timeout_init): Likewise.
[GRUB_UTIL] (grub_timeout_fini): Likewise.
* conf/i386-pc.rmk (grub_emu_SOURCES): Added commands/default.c,
commands/timeout.c and normal/context.c.
(pkgdata_MODULES): Added default.mod and timeout.mod.
(normal_mod_SOURCES): Added normal/context.c.
(default_mod_SOURCES): New variable.
(default_mod_CFLAGS): Likewise.
(timeout_mod_SOURCES): Likewise.
(timeout_mod_CFLAGS): Likewise.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Copied from
conf/i386-pc.rmk.
(pkgdata_MODULES): Added default.mod and timeout.mod.
(normal_mod_SOURCES): Added normal/context.c.
(default_mod_SOURCES): New variable.
(default_mod_CFLAGS): Likewise.
(timeout_mod_SOURCES): Likewise.
(timeout_mod_CFLAGS): Likewise.
* Makefile.in (all-local): Added $(MKFILES).
* include/grub/normal.h (grub_halt_init): New prototype.
(grub_halt_fini): Likewise.
(grub_reboot_init): Likewise.
(grub_reboot_fini): Likewise.
* util/grub-emu.c: Include signal.h.
(main_env): New global variable.
(grub_machine_init): Ignore SIGINT. Otherwise grub-emu cannot
catch C-c.
(grub_machine_fini): New function.
(main): Call grub_halt_init and grub_reboot_init before
grub_main, and grub_reboot_fini and grub_halt_fini after it.
Call setjmp with MAIN_ENV to go back afterwards.
Call grub_machine_fini right before return.
* include/grub/util/misc.h: Include setjmp.h.
(main_env): New prototype.
* include/grub/kernel.h (grub_machine_fini): New prototype.
* include/grub/i386/pc/biosdisk.h (grub_biosdisk_fini): Likewise.
* include/grub/i386/pc/console.h (grub_console_fini): Likewise.
* disk/i386/pc/biosdisk.c (grub_biosdisk_fini): New function.
* kern/i386/pc/init.c (grub_machine_fini): Likewise.
* term/i386/pc/console.c (grub_console_fini): Likewise.
* util/i386/pc/misc.c: New file.
* conf/i386-pc.rmk (grub_emu_SOURCES): Added
util/i386/pc/misc.c, commands/i386/pc/halt.c and
commands/i386/pc/reboot.c.
* include/grub/dl.h (grub_dl_check_header): New prototype.
(grub_arch_dl_check_header): Change return type to grub_err_t,
remove size parameter and export function. Update all callers.
* kern/dl.c (grub_dl_check_header): New function.
(grub_dl_load_core): Use `grub_dl_check_header' instead of
`grub_arch_dl_check_header'. Check ELF type. Check if sections
are inside the core.
* kern/i386/dl.c (grub_arch_dl_check_header): Remove arch
independent ELF header checks.
* kern/powerpc/dl.c (grub_arch_dl_check_header): Likewise.
* loader/i386/pc/multiboot.c (grub_rescue_cmd_multiboot): Use
`grub_dl_check_header' instead of explicit checks. Check for the
ELF type.
* loader/powerpc/ieee1275/linux.c (grub_rescue_cmd_linux): Use
`grub_dl_check_header' instead of explicit checks. Remove arch
specific ELF header checks.
* kern/partition.c (grub_partition_probe): Clear `grub_errno' and
return 0 if `grub_errno' is GRUB_ERR_BAD_PART_TABLE.
(part_map_iterate): Clear `grub_errno' and return 0 if
`partmap->iterate' returns GRUB_ERR_BAD_PART_TABLE.
* partmap/amiga.c (amiga_partition_map_iterate): Return
GRUB_ERR_BAD_PART_TABLE if no partition map magic is found.
* partmap/apple.c (apple_partition_map_iterate): Likewise.
* include/grub/powerpc/ieee1275/loader.h (grub_load_linux):
Removed prototype.
(grub_rescue_cmd_linux): New prototype.
(grub_rescue_cmd_initrd): Likewise.
* powerpc/ieee1275/linux.c (grub_linux_boot): Remove struct
`bi_rec'.
(grub_linux_release_mem): Release the memory for the initrd.
(grub_load_linux): Renamed from this...
(grub_rescue_cmd_linux): ...To this. Changed all callers.
Changed `entry' not to be static. Loop over memory regions to
find another one when the default fails.
(grub_rescue_cmd_initrd): New function.
(grub_linux_init): Remove function.
(grub_linux_fini): Likewise.
(GRUB_MOD_INIT): Register `initrd'.
(GRUB_MOD_FINI): Unregister `initrd'.
* powerpc/ieee1275/linux_normal.c (grub_linux_normal_init):
Function removed.
(grub_linux_normal_fini): Likewise.
(GRUB_MOD_INIT): Register `initrd'.
(GRUB_MOD_FINI): Unregister `initrd'.
* normal/menu.c (TERM_WIDTH): Macro redefined.
(TERM_TOP_BORDER_Y): Likewise.
(draw_border): Replaced while-loop by a for-loop. Make the number
of lines consistent with the number of lines displayed in
print_entries. Added a margin below the rectangle.
(print_entry): Make the entry fit in the rectangle.
(print_entries): Display the scroll arrows next to the right
border.
* fs/minix.c (grub_minix_find_file): Reserve more space for
`fpath' so the \0 can be stored. Use `grub_strcpy' instead of
`grub_strncpy' to copy `path' into it.
Add the loopback device, a device via which files can be accessed
as devices.
* conf/i386-pc.rmk (grub_emu_SOURCES): Add `disk/loopback.c'.
(pkgdata_MODULES): Add loopback.mod.
(loopback_mod_SOURCES): New variable.
(loopback_mod_CFLAGS): Likewise.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Add
`disk/loopback.c'.
(pkgdata_MODULES): Add loopback.mod.
(loopback_mod_SOURCES): New variable.
(loopback_mod_CFLAGS): Likewise.
* disk/loopback.c: new file.
* include/grub/normal.h (grub_loop_init): New prototype.
(grub_loop_fini): New prototype.
* util/grub-emu.c (main): Initialize and de-initialize loopback
support.
* include/grub/disk.h (grub_disk_dev_id): Add
`GRUB_DISK_DEVICE_LOOPBACK_ID'.