libgcc for boot environment isn't always present and compatible.
libgcc is often absent if endianness or bit-size at boot is different
from running OS.
libgcc may use optimised opcodes that aren't available on boot time.
So instead of relying on libgcc shipped with the compiler, supply
the functions in GRUB directly.
Tests are present to ensure that those replacement functions behave the
way compiler expects them to.
* Makefile.am (build-grub-mkfont): Don't include gnulib.
(build-grub-gen-asciih): Likewise.
(build-grub-gen-widthspec): Likewise.
* Makefile.util.def (grub-pe2elf): Remove.
* config.h.in [GRUB_BUILD]: Use build rather than host constants.
* configure.ac: Separate tests for build.
Move ./build-grub-pe2elf to grub-core.
Fix typo.
* grub-core/Makefile.am (build-grub-pe2elf): New target.
* grub-core/kern/emu/misc.c (xasprintf): Don't compile if GRUB_BUILD is
defined.
* include/grub/types.h [GRUB_BUILD]: Use build rather than host
constants.
* util/grub-mkfont.c [GRUB_BUILD]: Simplify not to rely on argp.
* util/grub-pe2elf.c: Simplify not to rely on getopt.
* util/misc.c (program_name) [GRUB_BUILD]: Define to static string.
* config.h.in (RE_ENABLE_I18N) [!GRUB_UTIL]: New define.
* grub-core/lib/posix_wrap/ctype.h (islower): Use grub_islower.
(isupper): Use grub_isupper.
(isascii): New inline function.
* grub-core/lib/posix_wrap/wchar.h: Replace dummy with real contents.
* grub-core/lib/posix_wrap/wctype.h: Likewise.
* grub-core/normal/charset.c (grub_utf8_process): New function.
(grub_utf8_to_utf16): Use grub_utf8_process.
(grub_encode_utf8_character): New function.
(grub_ucs4_to_utf8): Use grub_encode_utf8_character.
* include/grub/charset.h (grub_utf8_process): New declaration.
(grub_encode_utf8_character): Likewise.
* include/grub/misc.h (grub_islower): New inline function.
(grub_isupper): Likewise.
(grub_strchrsub): Moved down to fix the definitions.
* configure.ac: --enable-cache-stats added.
* config.h.in (DISK_CACHE_STATS): New define.
* grub-core/Makefile.core.def (cacheinfo): New command.
* include/grub/disk.h(grub_disk_cache_get_performance): New function.
* grub-core/commands/cacheinfo.c: New file.
* grub-core/commands/minicmd.c (grub_rescue_cmd_info): Updated and
moved to cacheinfo.c.
* grub-core/kern/disk.c: Use DISK_CACHE_STATS to disable disk cache
debug code.
* include/grub/disk.h: Likewise.
* util/hostdisk.c [__FreeBSD__]: Include sys/disk.h.
(grub_util_biosdisk_open) [__FreeBSD__]: Add support for
FreeBSD. Check if a device is a character device. Use
DIOCGMEDIASIZE to get the size.
(convert_system_partition_to_system_disk) [__FreeBSD__]: Add
support for FreeBSD.
(grub_util_biosdisk_get_grub_dev) [__FreeBSD__]: Check if OS_DEV
is a character device instead of a block device. Add support for
FreeBSD device names.
* util/getroot.c (find_root_device) [__FreeBSD__]: Check if ENT is
a character device instead of a block device.
(grub_util_check_char_device): New function.
* util/grub-probe.c (probe) [__FreeBSD__]: Check if DEVICE_NAME is
a character device instead of a block device.
* include/grub/util/getroot.h (grub_util_check_char_device): New
prototype.
Make the format of Environment Block plain text. The boot loader
part is not tested well yet.
* util/grub-editenv.c (DEFAULT_ENVBLK_SIZE): New macro.
(buffer): Removed.
(envblk): Likewise.
(usage): Remove "info" and "clear". Add "unset". Update the
description of "set", as this does not delete variables any
longer.
(create_envblk_file): Complete rewrite.
(open_envblk_file): Likewise.
(cmd_info): Removed.
(cmd_list): Likewise.
(cmd_set): Likewise.
(cmd_clear): Likewise.
(list_variables): New function.
(write_envblk): Likewise.
(set_variables): Likewise.
(unset_variables): Likewise.
(main): Complete rewrite.
* commands/loadenv.c (buffer): Removed.
(envblk): Likewise.
(open_envblk_file): New function.
(read_envblk_file): Complete rewrite.
(grub_cmd_load_env): Likewise.
(grub_cmd_list_env): Likewise.
(struct blocklist): New struct.
(free_blocklists): New function.
(check_blocklists): Likewise.
(write_blocklists): Likewise.
(grub_cmd_save_env): Complete rewrite.
* include/grub/lib/envblk.h (GRUB_ENVBLK_SIGNATURE): Replaced with
a plain text signature.
(GRUB_ENVBLK_MAXLEN): Removed.
(struct grub_envblk): Complete rewrite.
(grub_envblk_find): Removed.
(grub_envblk_insert): Likewise.
(grub_envblk_open): New prototype.
(grub_envblk_set): Likewise.
(grub_envblk_delete): Put const to VALUE.
(grub_envblk_iterate): Put const to NAME and VALUE.
(grub_envblk_close): New prototype.
(grub_envblk_buffer): New inline function.
(grub_envblk_size): Likewise.
* lib/envblk.c: Include grub/mm.h.
(grub_env_find): Removed.
(grub_envblk_open): New function.
(grub_envblk_close): Likewise.
(escaped_value_len): Likewise.
(find_next_line): Likewise.
(grub_envblk_insert): Removed.
(grub_envblk_set): New function.
(grub_envblk_delete): Complete rewrite.
(grub_envblk_iterate): Likewise.
* configure.ac: Change host_os to cygwin for mingw.
(asprintf): New check for function.
* include/grub/symbol.h: Replace #ifndef __CYGWIN__ with
#if ! defined (__CYGWIN__) && ! defined (__MINGW32__).
* include/grub/util/misc.h: #include <config.h> and <grub/types.h>,
declear asprintf if HAVE_ASPRINTF is not set, declear fseeko, ftello,
sync, sleep and grub_util_get_disk_size for mingw.
* util/biosdisk.c (grub_util_biosdisk_open): Use grub_util_get_disk_size
to get size in mingw.
(open_device): Use flag O_BINARY if it's defined.
(find_root_device): Add dummy code for mingw.
* util/grub-mkdevicemap.c (get_floppy_disk_name): Return 0 for mingw.
(get_ide_disk_name): Return //./PHYSICALDRIVE%d for mingw.
(get_scsi_disk_name): Return 0 for mingw.
* util/hostfs.c: #include <grub/util/misc.h>.
(grub_hostfs_open): Use "rb" flag to open file, use
grub_util_get_disk_size to get disk size for mingw.
* util/misc.c: #include <windows.h> and <winioctl.h> in mingw.
(asprintf): New function if HAVE_ASPRINTF is not set.
(sync): New function for mingw.
(sleep): Likewise.
(grub_util_get_disk_size): Likewise.
* include/grub/term.h (GRUB_TERM_LEFT, GRUB_TERM_RIGHT)
(GRUB_TERM_UP, GRUB_TERM_DOWN, GRUB_TERM_HOME, GRUB_TERM_END)
(GRUB_TERM_DC, GRUB_TERM_PPAGE, GRUB_TERM_NPAGE, GRUB_TERM_ESC)
(GRUB_TERM_TAB, GRUB_TERM_BACKSPACE): New macros.
* kern/i386/pc/startup.S: Include `<grub/term.h>'.
(translation_table): Replace hardcoded values with macros
provided by `<grub/term.h>'.
* term/i386/pc/at_keyboard.c: Include `<grub/term.h>'.
(keyboard_map): Correct/add a few values, with macros provided
by `<grub/term.h>'.
(keyboard_map_shift): Zero values that don't differ from their
`keyboard_map' equivalents.
(grub_console_checkkey): Optimize KEYBOARD_STATUS_CAPS_LOCK toggling.
Discard the second scan code that is always sent by Caps lock.
Only use `keyboard_map_shift' when it provides a non-zero value,
otherwise fallback to `keyboard_map'.
* 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.
* fs/ext2.c (grub_ext2_read_inode): Use the inode size in a
superblock instead of the structure size to compute an
offset. This fixes the problem that GRUB could not read a
filesystem when inode size is different from 128-byte.
* util/misc.c: Include config.h.
[!HAVE_MEMALIGN]: Do not include malloc.h.
(grub_memalign): Use posix_memalign, if present. Then, use
memalign, if present. Otherwise, emit an error.
* util/grub-emu.c: Do not include malloc.h.
* include/grub/util/misc.h: Include unistd.h. This is required for
FreeBSD, because off_t is defined in unistd.h. Reported by Harley
D. Eades III <hde@foobar-qux.org>.
* configure.ac (AC_GNU_SOURCE): Added.
(AC_CHECK_FUNCS): Check posix_memalign and memalign for the host
type.
* configure.ac: Don't set host_m32 for x86_64. Also reset LIBS
for the target-specific tests. Make sure that we also have the
up-to-date target variables for those tests.
A new machine-specific function "grub_machine_set_prefix" is
defined. This is called after loading modules, so that a prefix
initialization can use modules. Also, this change adds an
intensive debugging feature for the memory manager via the
configure option "--enable-mm-debug".
* partmap/gpt.c (gpt_partition_map_iterate): Add one more into
PART.LEN.
* kern/sparc64/ieee1275/init.c (abort): Removed.
(grub_stop): Likewise.
(grub_exit): New function.
(grub_set_prefix): Renamed to ...
(grub_machine_set_prefix): ... this.
(grub_machine_init): Do not call grub_set_prefix.
* kern/powerpc/ieee1275/init.c (grub_set_prefix): Renamed to ...
(grub_machine_set_prefix): ... this.
(grub_machine_init): Do not call grub_set_prefix.
* kern/i386/pc/init.c (grub_machine_set_prefix): New function.
(grub_machine_init): Do not set the prefix here.
* kern/i386/efi/init.c (grub_machine_set_prefix): New function.
* kern/efi/init.c: Include grub/mm.h.
(grub_efi_set_prefix): New function.
* kern/efi/efi.c (grub_exit): Call grub_efi_fini.
(grub_efi_get_filename): New function.
(grub_print_device_path): Renamed to ...
(grub_efi_print_device_path): ... this.
* kern/mm.c [MM_DEBUG] (grub_malloc): Undefined.
[MM_DEBUG] (grub_realloc): Likewise.
[MM_DEBUG] (grub_free): Likewise.
[MM_DEBUG] (grub_memalign): Likewise.
[MM_DEBUG] (grub_mm_debug): New variable.
[MM_DEBUG] (grub_debug_malloc): New function.
[MM_DEBUG] (grub_debug_free): New function.
[MM_DEBUG] (grub_debug_realloc): New function.
[MM_DEBUG] (grub_debug_memalign): New function.
* kern/misc.c (grub_abort): Print a newline to distinguish
the message.
* kern/main.c (grub_main): Call grub_machine_set_prefix and
grub_set_root_dev after loading modules. This is necessary when
setting a prefix depends on modules.
* include/grub/efi/efi.h (grub_print_device_path): Renamed to ...
(grub_efi_print_device_path): ... this.
(grub_efi_get_filename): New prototype.
(grub_efi_set_prefix): Likewise.
* include/grub/efi/disk.h: Include grub/efi/api.h, grub/symbol.h
and grub/disk.h.
(grub_efidisk_get_device_handle): New prototype.
(grub_efidisk_get_device_name): Likewise.
* include/grub/mm.h: Include config.h.
(MM_DEBUG): Removed.
[MM_DEBUG && !GRUB_UTIL] (grub_mm_debug): New prototype.
[MM_DEBUG && !GRUB_UTIL] (grub_malloc): New macro.
[MM_DEBUG && !GRUB_UTIL] (grub_realloc): Likewise.
[MM_DEBUG && !GRUB_UTIL] (grub_memalign): Likewise.
[MM_DEBUG && !GRUB_UTIL] (grub_free): Likewise.
[MM_DEBUG && !GRUB_UTIL] (grub_debug_malloc): New prototype.
[MM_DEBUG && !GRUB_UTIL] (grub_debug_realloc): New prototype.
[MM_DEBUG && !GRUB_UTIL] (grub_debug_memalign): New prototype.
[MM_DEBUG && !GRUB_UTIL] (grub_debug_free): New prototype.
* include/grub/kernel.h (grub_machine_set_prefix): New prototype.
* disk/efi/efidisk.c: Include grub/partition.h.
(iterate_child_devices): New function.
(add_device): First, compare only last device path nodes, so that
devices are sorted by the types.
(grub_efidisk_get_device_handle): New function.
(grub_efidisk_get_device_name): Likewise.
* configure.ac (--enable-mm-debug): New option to enable the
memory manager debugging feature. This makes the binary much
bigger, so is disabled by default.