Support multiple fallback entries, and provide an API to support
executing default+fallback menu entries. Renamed the `terminal' menu
viewer to `text'.
* include/grub/normal.h (grub_normal_text_menu_viewer): New global
variable declaration.
(grub_menu_execute_callback): New structure declaration.
(grub_menu_execute_callback_t): New typedef.
(grub_menu_execute_with_fallback): New function declaration.
(grub_menu_get_entry): Likewise.
(grub_menu_get_timeout): Likewise.
(grub_menu_set_timeout): Likewise.
* normal/main.c (GRUB_MOD_INIT(normal)): Refer to new variable name.
* normal/menu.c (grub_wait_after_message): Moved to
`normal/menu_text.c'.
(draw_border): Likewise.
(print_message): Likewise.
(print_entry): Likewise.
(print_entries): Likewise.
(grub_menu_init_page): Likewise.
(get_entry_number): Likewise.
(print_timeout): Likewise.
(run_menu): Likewise.
(grub_menu_execute_entry): Likewise.
(show_text_menu): Likewise.
(get_and_remove_first_entry_number): New function.
(grub_menu_execute_with_fallback): Likewise.
(get_entry): Renamed to ...
(grub_menu_get_entry): .. this and made it global.
(get_timeout): Renamed to ...
(grub_menu_get_timeout): ... this and made it global.
(set_timeout): Renamed to ...
(grub_menu_set_timeout): ... this and made it global.
(grub_normal_terminal_menu_viewer): Renamed to ...
(grub_normal_text_menu_viewer): ... this.
* normal/menu_text.c: New file. Extracted text-menu-specific code
from normal/menu.c.
* conf/i386-coreboot.rmk (grub_emu_SOURCES): Add `normal/menu_text.c'.
(normal_mod_SOURCES): Likewise.
* conf/i386-efi.rmk (grub_emu_SOURCES): Likewise.
(normal_mod_SOURCES): Likewise.
* conf/i386-ieee1275.rmk (grub_emu_SOURCES): Likewise.
(normal_mod_SOURCES): Likewise.
* conf/i386-pc.rmk, (grub_emu_SOURCES): Likewise.
(normal_mod_SOURCES): Likewise.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise.
(normal_mod_SOURCES): Likewise.
* conf/sparc64-ieee1275.rmk (grub_emu_SOURCES): Likewise.
(normal_mod_SOURCES): Likewise.
* conf/x86_64-efi.rmk (grub_emu_SOURCES): Likewise.
(normal_mod_SOURCES): Likewise.
* normal/main.c: Add include to grub/menu_viewer.h.
(free_menu_entry_classes): Added.
(grub_normal_menu_addentry): Added class property handling.
(grub_normal_execute): Changed to use new menu viewer for menu viewing.
(GRUB_MOD_INIT(normal)): Added register for text based menu viewer.
* normal/menu_viewer.c: New file.
* normal/menu.c (run_menu_entry): Renamed to ...
(grub_menu_execute_entry): ... this and made it as global.
(grub_menu_run): Renamed to ...
(show_text_menu): ... this and made it local.
(show_text_menu): Adapt to new function names.
(grub_normal_terminal_menu_viewer): New global variable.
* include/grub/menu.h: New file.
* include/grub/menu_viewer.h: New file.
* include/grub/normal.h: Added include to grub/menu.h.
(grub_menu_entry): Moved to include/grub/menu.h.
(grub_menu_entry_t): Likewise.
(grub_menu): Likewise.
(grub_menu_t): Likewise.
(grub_normal_terminal_menu_viewer): Added.
(grub_menu_execute_entry): Likewise.
(grub_menu_run): Removed.
* DISTLIST: Added include/grub/menu.h.
Added include/grub/menu_viewer.h.
Added normal/menu_viewer.c.
2009-01-31 Vesa Jääskeläinen <chaac@nic.fi>
* normal/execute.c (grub_script_execute_menuentry): Changed to use
arglist for menutitle arguments.
* normal/main.c (grub_normal_menu_addentry): Likewise.
* normal/parser.y (menuentry): Likewise.
* normal/script.c (grub_script_create_cmdmenu): Likewise.
* include/grub/script.h (grub_script_cmd_menuentry): Likewise.
(grub_script_create_cmdmenu): Likewise.
* include/grub/normal.h (grub_normal_menu_addentry): Likewise.
* conf/i386-pc.rmk (normal_mod_SOURCES): Adapt Colin D Bennett's
changes.
* conf/x86_64-efi.rmk (normal_mod_SOURCES): Likewise.
* conf/i386-coreboot.rmk (normal_mod_SOURCES): Likewise.
* conf/i386-efi.rmk (normal_mod_SOURCES): Likewise.
* conf/i386-ieee1275.rmk (normal_mod_SOURCES): Likewise.
* conf/powerpc-ieee1275.rmk (normal_mod_SOURCES): Likewise.
* conf/sparc64-ieee1275.rmk (normal_mod_SOURCES): Likewise.
Fix build on powerpc-ieee1275. Based on patch created by
Manoel Abranches <mrabran@linux.vnet.ibm.com>.
* conf/powerpc-ieee1275.rmk (kernel_elf_SOURCES): Add
`kern/ieee1275/mmap.c'.
* include/grub/powerpc/ieee1275/memory.h: New file.
* conf/common.rmk (grub_probe_SOURCES): Add disk/mdraid_linux.c.
(grub_fstest_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c,
disk/mdraid_linux.c and disk/dmraid_nvidia.c and lib/crc.c.
(pkglib_MODULES): Add raid5rec.mod, raid6rec.mod, mdraid.mod and
dm_nv.mod.
(raid5rec_mod_SOURCES): New macro.
(raid5rec_mod_CFLAGS): Likewise.
(raid5rec_mod_LDFLAGS): Likewise.
(raid6rec_mod_SOURCES): Likewise.
(raid6rec_mod_CFLAGS): Likewise.
(raid6rec_mod_LDFLAGS): Likewise.
(mdraid_mod_SOURCES): Likewise.
(mdraid_mod_CFLAGS): Likewise.
(mdraid_mod_LDFLAGS): Likewise.
(dm_nv_mod_SOURCES): Likewise.
(dm_nv_mod_CFLAGS): Likewise.
(dm_nv_mod_LDFLAGS): Likewise.
* conf/i386-pc.rmk (grub_setup_SOURCES): Add disk/mdraid_linux.c.
(grub_emu_SOURCES): Add disk/raid5_recover.c, disk/raid6_recover.c,
disk/mdraid_linux.c and disk/dmraid_nvidia.c.
* conf/i386-coreboot.rmk (grub_emu_SOURCES): Add disk/raid5_recover.c,
disk/raid6_recover.c, disk/mdraid_linux.c and disk/dmraid_nvidia.c.
* conf/i386-efi.rmk (grub_emu_SOURCES): Likewise.
* conf/x86_64-efi.rmk (grub_emu_SOURCES): Likewise.
* conf/i386-ieee1275.rmk (grub_emu_SOURCES): Likewise.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise.
* disk/raid5_recover.c: New file.
* disk/raid6_recover.c: Likewise.
* disk/mdraid_linux.c: Likewise.
* disk/dmraid_nvidia.c: Likewise.
* disk/i386/pc/biosdisk.c: Set total_sectors of cdrom device to
ULONG_MAX.
* disk/raid.c (grub_raid_open): Use the size of the smallest disk to
calculate the size of raid device.
(grub_raid_read): Simplify raid0 code. Support raid4, raid6 and four
different layout of raid5.
(grub_raid_scan_device): Remove code specific to mdraid.
(grub_raid_list): New variable.
(free_array): New function.
(grub_raid_register): Likewise.
(grub_raid_unregister): Likewise.
(grub_raid_rescan): Likewise.
(GRUB_MOD_INIT): Don't iterate device here.
(GRUB_MOD_FINI): Use free_array to release resource.
* include/grub/raid.h: Remove macro and structure specific to mdraid.
(grub_raid5_recover_func_t): New function variable type.
(grub_raid6_recover_func_t): Likewise.
(grub_raid5_recover_func): New variable.
(grub_raid6_recover_func): Likewise.
(grub_raid_register): New function.
(grub_raid_unregister): Likewise.
(grub_raid_rescan): Likewise.
(grub_raid_block_xor): Likewise.
* util/grub-fstest.c: Add #include <grub/raid.h> and <grub/lib/crc.h>.
(CMD_CRC): New macro.
(part): Removed.
(read_file): Handle device as well as file.
(cmd_crc): New function.
(fstest): Handle multiple disks.
(options): Remove part, raw and long, add root and diskcount.
(usage): Add crc, remove -p, -r, -l, add -r and -c.
(main): Find the first non option entry and ignore subsequence options,
add handling for the new options, support multiple disks.
* util/grub-probe.c (probe): Add mdraid to abstraction_name.
High resolution timer support. Implemented for x86 CPUs using TSC.
Extracted generic grub_millisleep() so it's linked in only as needed.
This requires a Pentium compatible CPU; if the RDTSC instruction is
not supported, then it falls back on the generic grub_get_time_ms()
implementation that uses the machine's RTC.
* conf/i386-pc.rmk (kernel_img_SOURCES): Add `kern/time.c',
`kern/i386/tsc.c', `kern/generic/rtc_get_time_ms.c' and
`kern/generic/millisleep.c'.
* conf/i386-efi.rmk (kernel_mod_SOURCES): Add `kern/i386/tsc.c',
`kern/generic/rtc_get_time_ms.c' and `kern/generic/millisleep.c'.
* conf/x86_64-efi.rml (kernel_mod_SOURCES): Add
`kern/generic/millisleep.c' and `kern/generic/rtc_get_time_ms.c'.
* conf/sparc64-ieee1275.rmk (kernel_elf_SOURCES): Likewise.
* conf/powerpc-ieee1275.rmk (kernel_elf_SOURCES): Add
`kern/generic/millisleep.c'.
* conf/i386-ieee1275.rmk (kernel_elf_SOURCES): Likewise.
* conf/i386-coreboot.rmk (kernel_elf_SOURCES): Add `kern/time.c'.
* kern/generic/rtc_get_time_ms.c: New file.
* kern/generic/millisleep.c: New file.
* kern/misc.c: Don't include
<kern/time.h> anymore.
(grub_millisleep_generic): Removed.
* commands/sleep.c (grub_interruptible_millisleep): Uses
grub_get_time_ms() instead of grub_get_rtc().
* include/grub/i386/tsc.h (grub_get_tsc): New file. New inline
function.
(grub_cpu_is_cpuid_supported): New inline function.
(grub_cpu_is_tsc_supported): New inline function.
(grub_tsc_init): New function prototype.
(grub_tsc_get_time_ms): New function prototype.
* kern/i386/tsc.c (grub_get_time_ms): New file.
* include/grub/time.h: Include <grub/types.h.
(grub_millisleep_generic): Removed.
(grub_get_time_ms): New prototype.
(grub_install_get_time_ms): New prototype.
(grub_rtc_get_time_ms): New prototype.
* kern/time.c (grub_get_time_ms): New function.
(grub_install_get_time_ms): New function.
* kern/i386/efi/init.c: Include <grub/cpu/tsc.h>. Don't include
<grub/time.h> anymore.
(grub_millisleep): Removed.
(grub_machine_init): Call grub_tsc_init.
* kern/i386/linuxbios/init.c (grub_machine_init): Install the RTC
get_time_ms() implementation.
* kern/sparc64/ieee1275/init.c (grub_millisleep): Removed.
(ieee1275_get_time_ms): New function.
(grub_machine_init): Install get_time_ms() implementation.
* kern/i386/pc/init.c: Include <grub/cpu/tsc.h>.
(grub_machine_init): Call grub_tsc_init().
(grub_millisleep): Removed.
* kern/ieee1275/init.c (grub_millisleep): Removed.
(grub_machine_init): Install ieee1275_get_time_ms()
implementation.
(ieee1275_get_time_ms): New function.
(grub_get_rtc): Now calls ieee1275_get_time_ms(), which does the
real work.
* disk/memdisk.c (memdisk_size): Don't initialize.
(GRUB_MOD_INIT(memdisk)): Find memdisk using grub_module_iterate().
* include/grub/i386/pc/kernel.h
(GRUB_KERNEL_MACHINE_MEMDISK_IMAGE_SIZE): Remove macro.
(GRUB_KERNEL_MACHINE_PREFIX, GRUB_KERNEL_MACHINE_DATA_END): Shift.
(grub_memdisk_image_size, grub_arch_memdisk_addr)
(grub_arch_memdisk_size): Remove.
* include/grub/kernel.h (struct grub_module_header): Remove `offset'
field (was only used to transfer a constant). Add `type' field to
support multiple module types.
(grub_module_iterate): New function.
* kern/device.c (grub_device_open): Do not hide error messages
when grub_disk_open() fails. Use grub_print_error() instead.
* kern/i386/pc/init.c (grub_arch_modules_addr)
(grub_arch_memdisk_size): Remove functions.
(grub_arch_modules_addr): Return the module address in high memory
(now that it isn't copied anymore).
* kern/i386/pc/startup.S (grub_memdisk_image_size): Remove variable.
(codestart): Don't add grub_memdisk_image_size to %ecx in LZMA
decompression routine (grub_total_module_size already includes that
now). Don't copy modules back to low memory.
* kern/main.c: Include `<grub/mm.h>'.
(grub_load_modules): Split out (and use) ...
(grub_module_iterate): ... this function, which iterates through
module objects and runs a hook.
Comment out grub_mm_init_region() call, as it would cause non-ELF
modules to be overwritten.
* util/i386/pc/grub-mkimage.c (generate_image): Instead of appending
the memdisk image in its own region, make it part of the module list.
* util/elf/grub-mkimage.c (options): Add "memdisk"|'m' option.
(main): Parse --memdisk|-m option, and pass user-provided path as
parameter to generate_image().
(add_segments): Pass `memdisk_path' down to load_modules().
(load_modules): Embed memdisk image in module section when requested.
* util/i386/efi/grub-mkimage.c (make_mods_section): Initialize
`header.type' instead of `header.offset'.
* conf/powerpc-ieee1275.rmk (pkglib_MODULES): Add `memdisk.mod'.
(memdisk_mod_SOURCES, memdisk_mod_CFLAGS)
(memdisk_mod_LDFLAGS): New variables.
* conf/i386-coreboot.rmk: Likewise.
* conf/i386-ieee1275.rmk: Likewise.
* conf/i386-efi.rmk: Recompile grub-mkimage.c if Makefile has
changed. This is needed in case GRUB_LIBDIR changes.
* conf/i386-ieee1275.rmk: Likewise.
* conf/i386-linuxbios.rmk: Likewise.
* conf/i386-pc.rmk: Likewise.
* conf/powerpc-ieee1275.rmk: Likewise.
* conf/powerpc-ieee1275.rmk (kernel_elf_SOURCES): Rename
kernel_elf_symlist.c to symlist.c for consistency with other
architectures. Update all users.
* conf/sparc64-ieee1275.rmk (kernel_elf_SOURCES): Likewise.
* kern/powerpc/ieee1275/init.c: Move from here ...
* kern/ieee1275/init.c: ... to here. Update all users.
* kern/powerpc/ieee1275/cmain.c: Move from here ...
* kern/ieee1275/cmain.c: ... to here. Update all users.
* kern/powerpc/ieee1275/openfw.c: Move from here ...
* kern/ieee1275/openfw.c: ... to here. Update all users.
* loader/powerpc/ieee1275/multiboot2.c: Move from here ...
* loader/ieee1275/multiboot2.c: ... to here. Update all users.
* util/powerpc/ieee1275/grub-mkrescue.in: New file.
* conf/powerpc-ieee1275.rmk: Add grub-mkrescue support for
PowerPC.
* DISTLIST: Add util/powerpc/ieee1275/grub-mkrescue.in.
* include/grub/normal.h (grub_env_write_color_normal): New prototype.
(grub_env_write_color_highlight): Likewise.
(grub_wait_after_message): Likewise.
* normal/color.c: New file.
* conf/i386-pc.rmk (grub_emu_SOURCES): Add `normal/color.c'.
(normal_mod_DEPENDENCIES): Likewise.
* conf/i386-efi.rmk (grub_emu_SOURCES): Add `normal/color.c'.
(normal_mod_DEPENDENCIES): Likewise.
* conf/i386-linuxbios.rmk (grub_emu_SOURCES): Add `normal/color.c'.
(normal_mod_DEPENDENCIES): Likewise.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Add `normal/color.c'.
(normal_mod_DEPENDENCIES): Likewise.
* normal/menu_entry.c (run): Rely on grub_wait_after_message()
for waiting after a message is printed.
* normal/main.c (read_config_file): Likewise.
(grub_normal_init): Register grub_env_write_color_normal() and
grub_env_write_color_highlight() hooks. Mark `color_normal' and
`color_highlight' variables as global.
* normal/menu.c (grub_wait_after_message): New function.
(grub_color_menu_normal): New variable. Replaces ...
(GRUB_COLOR_MENU_NORMAL): ... this macro.
(grub_color_menu_highlight): New variable. Replaces ...
(GRUB_COLOR_MENU_HIGHLIGHT): ... this macro.
(draw_border): Set color state to `GRUB_TERM_COLOR_NORMAL' instead of
`GRUB_TERM_COLOR_STANDARD'.
(print_message): Use `grub_setcolorstate' to reload colors. Rename
`normal_code' and `highlight_code' to `old_color_normal' and
`old_color_highlight', respectively.
(grub_menu_init_page): Update colors when drawing the menu, based on
`menu_color_normal' and `menu_color_highlight' variables.
(grub_menu_run): Rely on grub_wait_after_message() for waiting after
a message is printed.
* configure.ac: Search for possible unifont.hex locations, and
define UNIFONT_HEX if found.
* Makefile.in (UNIFONT_HEX): Define variable.
(DATA): Rename to ...
(PKGLIB): ... this. Update all users.
(PKGDATA): New variable.
(pkgdata_IMAGES): Rename to ...
(pkglib_IMAGES): ... this. Update all users.
(pkgdata_MODULES): Rename to ...
(pkglib_MODULES): ... this. Update all users.
(pkgdata_PROGRAMS): Rename to ...
(pkglib_PROGRAMS): ... this. Update all users.
(pkgdata_DATA): Rename to ...
(pkglib_DATA): ... this. Update all users.
(CLEANFILES): Redefine to `$(pkglib_DATA) $(pkgdata_DATA)'.
(unicode.pff, ascii.pff): New rules.
(all-local): Add `$(PKGDATA)' dependency.
(install-local): Process `$(PKGDATA)'.
* util/update-grub_lib.in (font_path): Search for *.pff files in
a few more locations, including `${pkgdata}'.
Patch from Simon Peter <dn.tlp@gmx.net>:
* genmk.rb (Utility): Append $(#{src}_DEPENDENCIES) to #{obj} targets.
* conf/i386-pc.rmk: Replace grub-probe_DEPENDENCIES with
util/grub-probe.c_DEPENDENCIES. Replace grub-setup_DEPENDENCIES with
util/i386/pc/grub-setup.c_DEPENDENCIES.
* conf/i386-efi.rmk: Replace grub-probe_DEPENDENCIES with
util/grub-probe.c_DEPENDENCIES.
* conf/powerpc-ieee1275.rmk: Likewise.
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.
* geninitheader.sh: Process file specified in first parameter rather
than hardcoding grub_modules_init.lst.
* geninit.sh: Likewise. Also, construct header name dynamicaly rather
than hardcoding grub_modules_init.h.
* conf/common.rmk: Rename grub_modules_init.[ch] files associated with
grub-emu to grub_emu_init.[ch]. Add rules to build analogous
grub_probe_init.[ch] and grub_setup_init.[ch].
* conf/powerpc-ieee1275.rmk (grub_emu_DEPENDENCIES): Replace
grub_modules_init.h with grub_emu_init.h.
(grub_probe_DEPENDENCIES, grub_probe_SOURCES): Add new
grub_probe_init.[ch] files.
* conf/i386-efi.rmk: Likewise.
* conf/i386-pc.rmk: Likewise.
(grub_setup_DEPENDENCIES, grub_setup_SOURCES): Add new
grub_setup_init.[ch] files.
* util/grub-emu.c: Replace grub_modules_init.h with grub_emu_init.h.
* util/grub-probe.c: Include grub_probe_init.h. Use grub_init_all()
to initialize modules rather than a list of hardcoded functions.
* util/i386/pc/grub-setup.c: Include grub_setup_init.h. Use
grub_init_all() to initialize modules rather than a list of hardcoded
functions.
* conf/powerpc-ieee1275.rmk: Enable grub-mkdevicemap and grub-probe.
* include/grub/partition.h: Declare grub_apple_partition_map_init and
grub_apple_partition_map_fini.
* util/biosdisk.c
(grub_util_biosdisk_open): Replace BLKGETSIZE with BLKGETSIZE64 (needed
to access >2 TiB disks).
Print disk->total_sectors with %llu instead of %lu, since this
variable is always 64-bit (prevents wrong disk size from being displayed
on either >2 TiB disk or big-endian CPU).
(grub_util_biosdisk_get_grub_dev): Convert gpt_partition_map handling
into a generic case that supports all (sane) partition maps.
Stop using grub_cpu_to_le32() on dos_part / bsd_part since it actually
breaks big-endian.
* util/grub-probe.c: Call grub_apple_partition_map_init() before probe()
and grub_apple_partition_map_fini() after that.