* conf/i386-coreboot.rmk (sbin_SCRIPTS): Add `grub-install'.
(grub_install_SOURCES): New variable.
* util/i386/pc/grub-install.in: Add a few condition checks to make it
usable on coreboot.
Modularize at_keyboard.mod:
* conf/i386.rmk (pkglib_MODULES): Add `at_keyboard.mod'.
(at_keyboard_mod_SOURCES, at_keyboard_mod_CFLAGS)
(at_keyboard_mod_LDFLAGS): New variables.
Actual terminal split:
* include/grub/term.h (struct grub_term): Split in ...
(struct grub_term_input): ... this, and ...
(struct grub_term_output): ... this. Update all users.
(grub_term_set_current): Split in ...
(grub_term_set_current_input): ... this, and ...
(grub_term_set_current_output): ... this.
(grub_term_get_current): Split in ...
(grub_term_get_current_input): ... this, and ...
(grub_term_get_current_output): ... this.
(grub_term_register): Split in ...
(grub_term_register_input): ... this, and ...
(grub_term_register_output): ... this.
(grub_term_unregister): Split in ...
(grub_term_unregister_input): ... this, and ...
(grub_term_unregister_output): ... this.
(grub_term_iterate): Split in ...
(grub_term_iterate_input): ... this, and ...
(grub_term_iterate_output): ... this.
* kern/term.c (grub_term_list): Split in ...
(grub_term_list_input): ... this, and ...
(grub_term_list_output): ... this. Update all users.
(grub_cur_term): Split in ...
(grub_cur_term_input): ... this, and ...
(grub_cur_term_output): ... this. Update all users.
(grub_term_set_current): Split in ...
(grub_term_set_current_input): ... this, and ...
(grub_term_set_current_output): ... this.
(grub_term_get_current): Split in ...
(grub_term_get_current_input): ... this, and ...
(grub_term_get_current_output): ... this.
(grub_term_register): Split in ...
(grub_term_register_input): ... this, and ...
(grub_term_register_output): ... this.
(grub_term_unregister): Split in ...
(grub_term_unregister_input): ... this, and ...
(grub_term_unregister_output): ... this.
(grub_term_iterate): Split in ...
(grub_term_iterate_input): ... this, and ...
(grub_term_iterate_output): ... this.
* kern/misc.c (grub_abort): Split use of grub_term_get_current() into
a check for input and one for output (and only attempt to get keys
from user when input works).
* util/grub-probe.c (grub_term_get_current): Split in ...
(grub_term_get_current_input): ... this, and ...
(grub_term_get_current_output): ... this.
* util/grub-fstest.c: Likewise.
* util/i386/pc/grub-setup.c: Likewise.
* util/grub-editenv.c: Likewise.
Portability adjustments:
* conf/i386-ieee1275.rmk (kernel_elf_SOURCES): Remove
`term/i386/pc/at_keyboard.c'.
* kern/ieee1275/init.c [__i386__] (grub_machine_init): Remove call to
grub_keyboard_controller_init() (now handled by terminal .init).
* kern/i386/coreboot/init.c (grub_machine_init): Add call to
grub_at_keyboard_init().
* include/grub/i386/ieee1275/console.h (grub_keyboard_controller_init)
(grub_console_checkkey, grub_console_getkey): Remove (now provided by
at_keyboard.mod via input terminal interface).
* include/grub/i386/coreboot/console.h: Convert into a stub for
`<grub/i386/pc/console.h>'.
Migrate full terminals to new API:
* term/efi/console.c (grub_console_term): Split into ...
(grub_console_term_input): ... this, and ...
(grub_console_term_output): ... this. Update all users.
* term/ieee1275/ofconsole.c: Remove __i386__ hack.
(grub_ofconsole_init): Split into ...
(grub_ofconsole_init_input): ... this, and ...
(grub_ofconsole_init_output): ... this.
(grub_ofconsole_term): Split into ...
(grub_ofconsole_term_input): ... this, and ...
(grub_ofconsole_term_output): ... this. Update all users.
* term/i386/pc/serial.c (grub_serial_term): Split into ...
(grub_serial_term_input): ... this, and ...
(grub_serial_term_output): ... this. Update all users.
* term/i386/pc/console.c (grub_console_term): Split into ...
(grub_console_term_input): ... this, and ...
(grub_console_term_output): ... this. Update all users.
(grub_console_term_input): Only enable it on PC/BIOS platform.
(grub_console_init): Remove grub_keyboard_controller_init() call.
Migrate input terminals to new API:
* term/i386/pc/at_keyboard.c: Replace `cpu' and `machine' with
`i386' and `i386/pc' to enable build on x86_64 (this driver is
i386-specific anyway).
(grub_console_checkkey): Rename to ...
(grub_at_keyboard_checkkey): ... this. Static-ize. Update all
users.
(grub_keyboard_controller_orig): New variable.
(grub_console_getkey): Rename to ...
(grub_at_keyboard_getkey): ... this. Static-ize. Update all
users.
(grub_keyboard_controller_init): Static-ize. Save original
controller value so that it can be restored ...
(grub_keyboard_controller_fini): ... here (new function).
(grub_at_keyboard_term): New structure.
(GRUB_MOD_INIT(at_keyboard), GRUB_MOD_FINI(at_keyboard)): New
functions.
Migrate output terminals to new API:
* term/i386/pc/vga.c (grub_vga_term): Change type to
`struct grub_term_output'. Remove `.checkkey' and `.getkey'
members. Update all users.
* term/gfxterm.c (grub_video_term): Change type to
`struct grub_term_output'. Remove `.checkkey' and `.getkey'
members. Update all users.
* include/grub/i386/pc/console.h (grub_console_checkkey)
(grub_console_getkey): Do not export (no longer needed by gfxterm,
etc).
Migrate `terminal' command and userland tools to new API:
* commands/terminal.c (grub_cmd_terminal): Split into ...
(grub_cmd_terminal_input): ... this, and ...
(grub_cmd_terminal_output): ... this.
(GRUB_MOD_INIT(terminal)): Split `terminal' command in two commands:
`terminal_input' and `terminal_output'.
* util/grub.d/00_header.in: Adjust `terminal' calls to new
`terminal_input' / `terminal_output' API.
* util/grub-mkconfig.in: Export ${GRUB_TERMINAL_INPUT} and
${GRUB_TERMINAL_OUTPUT} instead of ${GRUB_TERMINAL} (and if user
provided ${GRUB_TERMINAL}, convert it).
* 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.
* include/grub/i386/pc/kernel.h (GRUB_KERNEL_MACHINE_DATA_END):
Increase from 0x50 to 0x60.
* util/i386/pc/grub-install.in: Detect cross-disk installs, and
use UUIDs to identify the root drive for them. If that's not
possible, abort.
* util/i386/pc/grub-setup.c (setup): Do not special-case, or even
check, for cross-disk installs.
* util/i386/pc/grub-install.in: If `--debug' is specified,
pass `--verbose' to grub-setup.
Abort script if make_system_path_relative_to_its_root() fails.
* util/i386/pc/grub-setup.c (setup): Write install_dos_part and
install_bsd_part immediately before core.img is embedded or
modified on disk. This fixes core.img verification if core.img
cannot be embedded.
* util/i386/pc/grub-install.in: If the drive is LVM or RAID, prepend
it in prefix.
* util/i386/pc/grub-setup.c (main): Don't handle prefix at all. Set
`must_embed' to 1 when root_dev is a RAID device. When dest_dev is
a RAID device, run setup() for all members independently on whether
LVM abstraction is being used.
(setup): Don't handle prefix at all; let grub-mkimage take care of it.
If grub-mkimage has set `*install_dos_part == -2', don't override this
value.
Perform *install_dos_part adjustments independently on whether
we're embedding or not.
Clarify error message when image is too big for embedding.
Remove duplicate *install_dos_part stanza.
* util/i386/pc/grub-mkimage.c (generate_image): If we included a drive
in our prefix, set install_{dos,bsd}_part = -2 to indicate this can be
skipped later.
(main): If a memdisk was requested, add "(memdisk)" drive explicitly to
the beginning of the prefix.
* kern/i386/pc/init.c (make_install_device): Remove memdisk check.
It is assumed that if we have a memdisk, grub-mkimage has set
grub_prefix to include the "(memdisk)" drive in it.
* util/grub-emu.c (grub_machine_init): Move code in this function from
here ...
(main): ... to here (before grub_util_biosdisk_init() call, to prevent
segfault in case grub_printf() is called).
* util/i386/pc/grub-install.in: Append `--device-map=${device_map}' to
grub_probe. Update all users not to explicitly add it again.
(grub_device): New variable; contains corresponding device for grubdir.
(fs_module, partmap_module, devabstraction_module): Pass
`--device ${grub_device}' to grub_probe to avoid traversing /dev
every time.
* util/update-grub_lib.in (make_system_path_relative_to_its_root):
Do not print a trailing slash (therefore, the root directory is an
empty string).
(convert_system_path_to_grub_path): Do not remove trailing slash
from make_system_path_relative_to_its_root() output.
* util/i386/pc/grub-install.in: Add trailing slash to output from
make_system_path_relative_to_its_root().
* util/grub-fstest.c (grub_refresh): Call `fflush (stdout)'. This
ensures that output lines aren't intermangled with those sent to
stderr (via grub_util_info()).
* util/grub-probe.c (grub_refresh): Likewise.
* util/i386/pc/grub-setup.c (grub_refresh): Likewise.
* util/i386/pc/grub-mkrescue.in: Add --emulation=floppy
to create a floppy emulation boot CD when non emulation mode
does not work.
Enable Joliet CD filesystem extension.
Revert grub/machine/init.h addition by Pavel (since it breaks on
i386-ieee1275 and others):
* util/i386/pc/misc.c: Remove grub/machine/init.h.
* util/powerpc/ieee1275/misc.c: Likewise.
* util/biosdisk.c: Include grub/util/biosdisk.h.
* util/grub-fstest.c (execute_command): Make static.
* util/grub-mkdevicemap.c (check_device): Likewise.
* util/i386/pc/misc.c: Include grub/machine/init.h.
* util/powerpc/ieee1275/misc.c: Likewise.
* util/lvm.c: Include grub/util/lvm.h.
* util/misc.c: Include grub/kernel.h, grub/misc.h and
grub/cache.h.
* util/raid.c: Include grub/util/raid.h.
(grub_util_getdiskname): Make static.
* partmap/gpt.c: Include `<grub/gpt_partition.h>'.
(grub_gpt_partition_type_empty): Redefine with macro from
`<grub/gpt_partition.h>'.
(gpt_partition_map_iterate): Adjust partition type comparison.
Export `entry' as partmap-specific `part.data' struct.
(grub_gpt_header, grub_gpt_partentry): Move from here ...
* include/grub/gpt_partition.h (grub_gpt_header)
(grub_gpt_partentry): ... to here (new file).
* util/i386/pc/grub-setup.c: Include `<grub/gpt_partition.h>'.
(grub_gpt_partition_type_bios_boot): New const variable, defined
with macro from `<grub/gpt_partition.h>'.
(setup): Replace `first_start' with `embed_region', which keeps
track of the embed region (and is partmap-agnostic).
Replace find_first_partition_start() with find_usable_region(),
which finds a usable region for embedding using partmap-specific
knowledge (supports PC/MSDOS and GPT).
Fix all assumptions that the embed region start at sector 1, using
`embed_region.start' from now on. Similarly, use `embed_region.end'
rather than `first_start' to calculate available size.
In grub_util_info() message, replace "into after the MBR" with an
indication of the specific sector our embed region starts at.
* util/i386/pc/grub-setup.c (setup): In find_first_partition_start(),
do not assume partition map is PC/MSDOS before performing checks that
are specific to that layout.
* configure.ac: Probe for `help2man'.
* Makefile.in (builddir): New variable.
(HELP2MAN): Likewise. Set to `true' when @HELP2MAN@ doesn't provide it,
or otherwise add a few flags/options to it.
(install-local): For every executable utility or script that is
installed, invoke $(HELP2MAN) to install a manpage based on --help
output.
* util/i386/pc/grub-install.in: Move down `update-grub_lib' sourcing, so
that it doesn't prevent --help from working in build tree.
* util/i386/pc/grub-mkrescue.in (usage): Replace `grub-devel@gnu.org'
with `bug-grub@gnu.org'.
* util/powerpc/ieee1275/grub-mkrescue.in (usage): Likewise.
* util/update-grub.in (usage): New function.
Implement proper argument check, with support for --help and --version
(as well as existing -y).
* util/grub-probe.c (main): When `verbosity > 1', set `debug'
environment variable to 'all' in order to obtain debug output from
non-util/ code.
* util/i386/pc/grub-setup.c (main): Likewise.
Make grub-setup handle a separate root device.
* util/i386/pc/grub-setup.c (setup): Always open the root device,
so that the root device can be compared with the destination
device.
When embedding the core image, if the root and destination devices
are different, set ROOT_DRIVE to ROOT_DEV->DISK->ID. Otherwise, to
0xFF.
When not embedding, set ROOT_DRIVE to 0xFF.
* kern/i386/pc/init.c (make_install_device): When memdisk image is
present, "(memdisk)/boot/grub" becomes the default prefix.
* util/i386/pc/grub-mkrescue.in: Switch to a minimal core.img plus
a memdisk tarball with all the modules. Add --overlay=DIR option that
allows users to overlay additional files into the image.
* conf/i386-pc.rmk (GRUB_MEMORY_MACHINE_LINK_ADDR): New variable.
(kernel_img_LDFLAGS): Use `GRUB_MEMORY_MACHINE_LINK_ADDR' as link
address.
(grub_mkimage_CFLAGS): Propagate `GRUB_MEMORY_MACHINE_LINK_ADDR' as
a C macro.
* include/grub/i386/pc/memory.h (GRUB_MEMORY_MACHINE_UPPER): New macro.
Indicates start of upper memory.
* util/i386/pc/grub-mkimage.c: Include `<grub/machine/memory.h>'.
(generate_image): Abort when image size is big enough to corrupt
upper memory.
* include/grub/i386/pc/vga.h: Include `<grub/machine/memory.h>'.
(GRUB_MEMORY_MACHINE_VGA_ADDR): Alias for `GRUB_MEMORY_MACHINE_UPPER'.
* term/i386/pc/vga.c (VGA_MEM): Use `GRUB_MEMORY_MACHINE_VGA_ADDR'
instead of hardcoding 0xA0000.
* video/i386/pc/vbe.c: Include `<grub/machine/vga.h>'.
(grub_vbe_set_video_mode): Use `GRUB_MEMORY_MACHINE_VGA_ADDR'
instead of hardcoding 0xA0000.
* conf/i386-pc.rmk (kernel_img_HEADERS): Add `machine/kernel.h'.
(pkglib_MODULES): Add `memdisk.mod'.
(memdisk_mod_SOURCES): New variable.
(memdisk_mod_CFLAGS): Likewise.
(memdisk_mod_LDFLAGS): Likewise.
* disk/memdisk.c: New file.
* include/grub/disk.h (grub_disk_dev_id): Add
`GRUB_DISK_DEVICE_MEMDISK_ID'.
* include/grub/i386/pc/kernel.h
(GRUB_KERNEL_MACHINE_MEMDISK_IMAGE_SIZE): New macro.
(GRUB_KERNEL_MACHINE_PREFIX): Increment by 4.
(grub_kernel_image_size): New variable declaration.
(grub_total_module_size): Likewise.
(grub_memdisk_image_size): Likewise.
* include/grub/i386/pc/memory.h
(GRUB_MEMORY_MACHINE_DECOMPRESSION_ADDR): New macro.
* include/grub/kernel.h: Include `<grub/symbol.h>'.
(grub_arch_memdisk_addr): New variable declaration.
(grub_arch_memdisk_size): Likewise.
* kern/i386/pc/init.c (grub_arch_memdisk_addr): New function.
(grub_arch_memdisk_size): Likewise.
* kern/i386/pc/startup.S (grub_memdisk_image_size): New variable.
(codestart): Replace hardcoded `0x100000' with
`GRUB_MEMORY_MACHINE_DECOMPRESSION_ADDR' macro.
* util/i386/pc/grub-mkimage.c: Include `<grub/misc.h>'.
(generate_image): Add `memdisk_path' parameter. When `memdisk_path' is
not NULL, append the contents of the file it refers to, at the end of
the compressed kernel image. Initialize `grub_memdisk_image_size'
variable (at `GRUB_KERNEL_MACHINE_MEMDISK_IMAGE_SIZE' offset).
(options): Add "memdisk"|'m' option.
(main): Parse --memdisk|-m option, and pass user-provided path as
parameter to generate_image().
* include/grub/util/getroot.h (grub_dev_abstraction_types): New enum.
(grub_util_get_dev_abstraction): New function prototype.
* util/getroot.c: Include `<grub/util/getroot.h>'
(grub_util_get_grub_dev): Move detection of abstraction type to ...
(grub_util_get_dev_abstraction): ... here (new function).
* util/grub-probe.c: Convert PRINT_* to an enum. Add
`PRINT_ABSTRACTION'.
(probe): Probe for abstraction type when requested.
(main): Understand `--target=abstraction'.
* util/i386/efi/grub-install.in: Add abstraction module to core
image when it is found to be necessary.
* util/i386/pc/grub-install.in: Likewise.
* util/powerpc/ieee1275/grub-install.in: Likewise.
* util/update-grub_lib.in (font_path): Return system path without
converting to GRUB path.
* util/update-grub.in: Convert system path returned by font_path()
to a GRUB path. Use `grub-probe -t abstraction' to determine what
abstraction module is needed for loading fonts (if any). Export
that as `GRUB_PRELOAD_MODULES'.
* util/grub.d/00_header.in: Process `GRUB_PRELOAD_MODULES' (print
insmod commands).