Fix memory corruption issue (spotted by Colin Watson).
* kern/i386/pc/startup.S (grub_vbe_bios_getset_dac_palette): Fix bug
causing returned size to be stored in an incorrect memory location.
Fix use of uninitialized value when storing the returned size.
Save space by inlining misc.c functions.
* kern/misc.c (grub_iswordseparator): Made static.
* kern/misc.c (grub_strcat): Moved from here ...
* include/grub/misc.h (grub_strcat): ... here. Inlined.
* kern/misc.c (grub_strncat): Moved from here ...
* include/grub/misc.h (grub_strncat): ... here. Inlined.
* kern/misc.c (grub_strcasecmp): Moved from here ...
* include/grub/misc.h (grub_strcasecmp): ... here. Inlined.
* kern/misc.c (grub_strncasecmp): Moved from here ...
* include/grub/misc.h (grub_strncasecmp): ... here. Inlined.
* kern/misc.c (grub_isalpha): Moved from here ...
* include/grub/misc.h (grub_isalpha): ... here. Inlined.
* kern/misc.c (grub_isdigit): Moved from here ...
* include/grub/misc.h (grub_isdigit): ... here. Inlined.
* kern/misc.c (grub_isgraph): Moved from here ...
* include/grub/misc.h (grub_isgraph): ... here. Inlined.
* kern/misc.c (grub_tolower): Moved from here ...
* include/grub/misc.h (grub_tolower): ... here. Inlined.
Fix a bug resulting in black screen when loading Linux using a
packed video mode.
* kern/i386/pc/startup.S (grub_vbe_bios_getset_dac_palette_width): New
function.
* include/grub/i386/pc/vbe.h (GRUB_VBE_CAPABILITY_DACWIDTH): New macro.
(grub_vbe_bios_getset_dac_palette_width): New function.
(grub_vbe_bios_get_dac_palette_width)
(grub_vbe_bios_set_dac_palette_width): New macros (act as wrappers for
grub_vbe_bios_getset_dac_palette_width()).
* video/i386/pc/vbe.c (grub_vbe_probe): Use `GRUB_VBE_STATUS_OK' to
check for return status.
(grub_vbe_get_video_mode_info): When getting information for a packed
mode (<= 8 bpp), obtain DAC palette width using
grub_vbe_bios_getset_dac_palette_width(), and use that for initializing
{red,green,blue}_mark_size.
* kern/device.c (grub_device_iterate): Change struct part_ent to
hold the name, not a pointer to it. Use one grub_malloc() per
partition, not two. Free partition_name if grub_malloc() fails.
Set ents to NULL only before grub_partition_iterate() is called.
2009-07-10 Robert Millan <rmh.grub@aybabtu.com>
* kern/ieee1275/openfw.c (grub_children_iterate)
(grub_devalias_iterate): Fix size evaluation for property or path
strings, which was broken since r2132.
* kern/i386/pc/startup.S (real_to_prot): Access `gdtdesc' using
segment 0x0 unconditionally, because the reference generated by
GAS is an absolute address.
Load BSD ELF modules
* conf/i386-pc.rmk (bsd_mod_SOURCES): Add loader/i386/bsd32.c
and loader/i386/bsd64.c
* include/grub/i386/bsd.h (FREEBSD_MODTYPE_MODULE): Remove
(FREEBSD_MODTYPE_ELF_MODULE): New definition
(FREEBSD_MODTYPE_ELF_MODULE_OBJ): Likewise
(grub_freebsd_load_elfmodule32): New declaration
(grub_freebsd_load_elfmoduleobj64): Likewise
(grub_freebsd_load_elf_meta32): Likewise
(grub_freebsd_load_elf_meta64): Likewise
(grub_freebsd_add_meta): Likewise
(grub_freebsd_add_meta_module): Likewise
* loader/i386/bsd.c (grub_freebsd_add_meta): Make global
(grub_freebsd_add_meta_module): Likewise and move module-specific
parts to grub_cmd_freebsd and grub_cmd_freebsd_module
(grub_cmd_freebsd): Add elf-kernel specific parts
based on grub_freebsd_add_meta_module
(grub_cmd_freebsd_module): Add type parsing moved from
grub_freebsd_add_meta_module
(grub_cmd_freebsd_module_elf): New function
(cmd_freebsd_module_elf): New variable
(GRUB_MOD_INIT): Register freebsd_module_elf
* loader/i386/bsd32.c: New file
* loader/i386/bsd64.c: Likewise
* loader/i386/bsdXX.c: Likewise
* kern/elf.c (grub_elf32_load): Let hook decide which pheaders to load
(grub_elf64_load): Likewise
* include/grub/elfload.h (grub_elf32_load_hook_t): New parameter do_load
All users updated
(grub_elf64_load_hook_t): Likewise
* conf/i386-coreboot.rmk (kernel_elf_SOURCES): Remove
term/i386/pc/at_keyboard.c, it doesn't need to be compiled into
the kernel.
* kern/i386/coreboot/init.c: Don't call grub_at_keyboard_init()
and grub_at_keyboard_fini(), it's done on module load and
unload.
* boot/i386/pc/boot.S: Remove root_drive. Assert offset of
boot_drive_check by using GRUB_BOOT_MACHINE_DRIVE_CHECK. Don't
save %dx, we only need %dl and we never change it.
* boot/i386/pc/cdboot.S: Don't set the root drive.
* boot/i386/pc/pxeboot.S: Likewise.
* include/grub/i386/pc/boot.h: Remove
GRUB_BOOT_MACHINE_ROOT_DRIVE, adjust
GRUB_BOOT_MACHINE_DRIVE_CHECK.
* include/grub/i386/pc/kernel.h: Remove grub_root_drive.
* kern/i386/pc/init.c (make_install_device): Remove references
to grub_root_drive.
* kern/i386/pc/startup.S: Likewise.
* util/i386/pc/grub-setup.c (setup): Don't set root_drive.
Avoid aliases when compiling with Apple's CC for PCBIOS machine
* kern/misc.c [APPLE_CC] (memcpy): new function
[APPLE_CC] (memmove): likewise
[APPLE_CC && !GRUB_UTIL] (grub_err_printf): likewise
(memcpy): define alias conditionaly on !APPLE_CC
(memset): likewise
(abort): likewise
* include/grub/misc.h (memove): don't define when both GRUB_UTIL and
APPLE_CC are defined
* include/grub/list.h [APPLE_CC] (grub_assert_fail): new function
(grub_assert_fail): make prototype conditional
Use grub-macho2img when compiling with Apple's CC for PCBIOS machine
* conf/common.rmk (bin_UTILITIES): add (on false on condition)
grub-macho2img
(CLEANFILES): add grub-macho2img
(grub_macho2img_SOURCES): new variable
* kern/i386/pc/startup.S (bss_start): new variable
(bss_end): likewise
* genmk.rb: use grub-macho2img for *.img when compiled with Apple's CC
* util/grub-macho2img.c: new file
Allow a compilation without -mcmodel=large
* kern/efi/mm.c (grub_efi_allocate_pages): don't allocate >4GiB
when compiled without -mcmodel=large
(filter_memory_map): remove memory post 4 GiB when compiled
without -mcmodel=large
* configure.ac: fail gracefully and add -DMCMODEL_SMALL=1 to
TARGET_CFLAGS when -mcmodel=large isn't supported
Absolute addressing through constant with Apple's cc
* kern/i386/pc/startup.S: Define necessary constants
and address through it when using ABS with Apple's CC
* boot/i386/pc/diskboot.S: likewise
* boot/i386/pc/boot.S: likewise
* boot/i386/pc/lnxboot.S: likewise
* boot/i386/pc/cdboot.S: likewise
* mmap/i386/pc/mmap_helper.S: likewise
* commands/i386/pc/drivemap_int13h.S: likewise
Script fixes
* include/grub/script_sh.h (grub_script_cmdline): remove cmdline
(grub_lexer_param): add tokenonhold
(grub_script_create_cmdline): remove cmdline. All callers updated
(grub_script_function_create): make functionname
grub_script_arg. All callers updated
(grub_script_execute_argument_to_string): new prototype
* kern/parser.c (state_transitions): reorder
(grub_parser_cmdline_state): fix a bug and make more compact
* script/sh/execute.c (grub_script_execute_argument_to_string):
make global
(grub_script_execute_cmdline): use new format
* script/sh/function.c (grub_script_function_create): make functionname
grub_script_arg. All callers updated
* script/sh/lexer.c (grub_script_lexer_init): initilaize tokenonhold
(grub_script_yylex): remove
(grub_script_yylex2): renamed to ...
(grub_script_yylex): ...renamed
parse the expressions like a${b}c
* script/sh/parser.y (GRUB_PARSER_TOKEN_ARG): new typed terminal
(GRUB_PARSER_TOKEN_VAR): remove
(GRUB_PARSER_TOKEN_NAME): likewise
("if"): declare as typeless
("while"): likewise
("function"): likewise
("else"): likewise
("then"): likewise
("fi"): likewise
(text): remove
(argument): likewise
(script): accept empty scripts and make exit on error
(arguments): use GRUB_PARSER_TOKEN_ARG
(function): likewise
(command): move error handling to script
(menuentry): move grub_script_lexer_ref before
* script/sh/script.c (grub_script_create_cmdline): remove cmdline
argument. All callers updated
trampoline for linux on 64-bit platform
* conf/x86_64-efi.rmk (linux_mod_SOURCES): added
loader/i386/efi/linux_trampoline.S
* include/grub/x86_64/efi/loader.h (grub_linux_real_boot): removed
declration
* kern/x86_64/efi/startup.S (grub_linux_real_boot): moved from here
* loader/i386/linux_trampoline.S: moved here
* loader/i386/efi/linux.c (allocate_pages): reserve space for trampoline
(jumpvector): removed
(grub_linux_trampoline_start): new declaration
(grub_linux_trampoline_end): likewise
(grub_linux_boot): use trampoline when on 64-bit platform
* loader/i386/linux.c: likewise
* include/grub/kernel.h (grub_module_header_types): Add type
OBJ_TYPE_CONFIG.
* kern/main.c (grub_load_config): New function.
(grub_main): Call grub_load_config to read boot config.
* grub-mkimage (generate_image): New parameter config_path.
(options): New option --config.
(main): Parse --config option, and pass it to generate_image.
* kernel/disk.c (grub_disk_read): Use void pointer for the
buffer.
(grub_disk_write): Use const void pointer for the buffer.
Adjust all callers. Remove unnecessary casts.
(grub_ofdisk_open): Use it to un-escape "," characters.
* kern/disk.c (find_part_sep): New.
(grub_disk_open): Use it to find the first non-escaped ','
character in the disk name.
* util/ieee1275/devicemap.c (escape_of_path): New.
(grub_util_emit_devicemap_entry): Use it.
* util/sparc64/ieee1275/grub-install.in: Update script to
strip partition specifiers properly by not triggering on
'\' escaped ',' characters.
FreeBSD 64-bit support
* conf/i386-pc.rmk (bsd_mod_SOURCES): add loader/i386/bsd_helper.S
and loader/i386/bsd_trampoline.S
(bsd_mod_ASFLAGS): new variable
* include/grub/i386/bsd.h (FREEBSD_MODINFOMD_SMAP): new definition
(FREEBSD_MODTYPE_KERNEL64): likewise
(grub_bsd64_trampoline_start): likewise
(grub_bsd64_trampoline_end): likewise
(grub_bsd64_trampoline_selfjump): likewise
(grub_bsd64_trampoline_gdt): likewise
* include/grub/i386/loader.h (grub_unix_real_boot): moved from here ...
* include/grub/i386/bsd.h (grub_unix_real_boot): ... moved here
* kern/i386/loader.S (grub_unix_real_boot): moved from here ...
* loader/i386/bsd_helper.S (grub_unix_real_boot): moved here
* include/grub/gpt_partition.h (grub_gpt_partentry): Corrected the type
of "attrib" member
* loader/i386/bsd_pagetable.c: new file
* loader/i386/bsd_trampoline.S: likewise
* loader/i386/bsd.c (ALIGN_QWORD): new macro
(ALIGN_VAR): likewise
(entry_hi): new variable
(kern_end_mdofs): likewise
(is_64bit): likewise
(grub_freebsd_add_meta): use ALIGN_VAR
(grub_e820_mmap): new declaration
(grub_freebsd_add_mmap): new function
(grub_freebsd_add_meta_module): support 64 bit kernels
(grub_freebsd_list_modules): use ALIGN_VAR
(gdt_descriptor): new declaration
(grub_freebsd_boot): support 64 bit kernels
(grub_bsd_elf64_hook): new function
(grub_bsd_load_elf): support elf64
* conf/common.rmk (grub_script.tab.c): Change normal/parser.y to
script/sh/parser.y.
(pkglib_MODULES): Add normal.mod and sh.mod.
(normal_SOURCES): New variable.
(normal_mod_CFLAGS): Likewise.
(normal_mod_LDFLAGS): Likewise.
(sh_mod_SOURCES): Likewise.
(sh_mod_CFLAGS): Likewise.
(sh_mod_LDFLAGS): Likewise.
* conf/i386-pc.rmk (normal/lexer.c_DEPENDENCIES): Changed to
script/sh/lexer.c_DEPENDENCIES.
(kernel_img_SOURCES): Remove kern/rescue.c, and kern/reader.c,
kern/rescue_reader.c and kern/rescue_parser.c.
(kernel_img_HEADERS): Remove rescue.h, add reader.h.
(grub_emu_SOURCES): Change source files.
(pkglib_MODULES): Remove normal.mod.
(normal_SOURCES): Removed.
(normal_mod_CFLAGS): Likewise.
(normal_mod_LDFLAGS): Likewise.
* conf/i386-coreboot.rmk: Likewise.
* conf/i386-efi.rmk: Likewise.
* conf/i386-ieee1276.rmk: Likewise.
* conf/powerpc-ieee1275.rmk: Likewise.
* conf/sparc64-ieee1275.rmk: Likewise.
* conf/x86_64-efi.rmk: Likewise.
* include/grub/command.h (grub_command_execute): New inline function.
* include/grub/menu.h (grub_menu_entry): Removed commands field.
* include/grub/normal.h: Remove <grub/setjmp.h>.
(grub_fs_module_list): Moved to normal/autofs.c.
(grub_exit_env): Removed.
(grub_command_execute): Likewise.
(grub_normal_menu_addentry): Renamed to grub_menu_addentry, removed
parameter script.
(read_command_list): New function declaration.
(read_fs_list): Likewise.
* include/parser.h: Include <grub/reader.h>.
(grub_parser_split_cmdline): Change type of getline parameter.
(grub_parser): New structure.
(grub_parser_class): New variable.
(grub_parser_execute): New function declaration.
(grub_register_rescue_parser): Likewise.
(grub_parser_register): New inline function.
(grub_parser_unregister): Likewise.
(grub_parser_get_current): Likewise.
(grub_parser_set_current): Likewise.
* include/grub/reader.h: New file.
* kern/reader.c: Likewise.
* kern/rescue_parser.c: Likewise.
* kern/rescue_reader.c: Likewise.
* normal/autofs.c: Likewise.
* normal/dyncmd.c: Likewise.
* include/grub/rescue.h: Removed.
* normal/command.h: Likewise.
* include/grub/script.h: Moved to ...
* include/grub/script_sh.h: ... Moved here.
* normal/execute.c: Moved to ...
* script/sh/execute.c: ... Moved here.
* normal/function.c: Moved to ...
* script/sh/function.c: ... Moved here.
* normal/lexer.c: Moved to ...
* script/sh/lexer.c: ... Moved here.
* normal/parser.y: Moved to ...
* script/sh/parser.y: ... Moved here.
* normal/script.c: Moved to ...
* script/sh/script.c: ... Moved here.
* normal/main.c: Remove <grub/rescue.h> and <grub/script.h>, include
<grub/reader.h>.
(grub_exit_env): Removed.
(fs_module_list): Moved to normal/autofs.c.
(grub_file_getline): Don't handle comment here.
(free_menu): Skip removed field entry->commands.
(grub_normal_menu_addentry): Removed as grub_menu_entry, removed
script parameter.
(read_config_file): Removed nested parameter, change getline function.
(grub_enter_normal_mode): Removed.
(grub_dyncmd_dispatcher): Moved to normal/dyncmd.c.
(read_command_list): Likewise.
(autoload_fs_module): Moved to normal/autofs.c.
(read_fs_list): Likewise.
(reader_nested): New variable.
(grub_normal_execute): Run parser.sh to switch to sh parser.
(grub_cmd_rescue): Removed.
(cmd_normal): Removed.
(grub_cmd_normal): Unregister itself at the beginning. Don't register
rescue command.
(grub_cmdline_run): New function.
(grub_normal_reader_init): Likewise.
(grub_normal_read_line): Likewise.
(grub_env_write_pager): Likewise.
(cmdline): New variable.
(grub_normal_reader): Likewise.
(GRUB_MOD_INIT): Register normal reader and set as current, register
pager hook, register normal command with grub_register_command_prio,
so that it won't show up in command.lst.
(GRUB_MOD_FINI): Unregister normal reader, unhook pager, clear
grub_fs_autoload_hook.
* normal/menu.c: Remove <grub/script.h>, add <grub/command.h>.
(grub_menu_execute_entry): Replace grub_script_execute with
grub_parser_execute, change parameter to grub_command_execute.
* normal/menu_text.c: Remove <grub/script.h>.
* normal/menu_entry.c: Remove <grub/script.h>, add <grub/command.h>
and <grub/parser.h>.
(run): Change editor_getline to use new parser interface. Change
parameter to grub_command_execute.
* kern/main.c: Remove <grub/rescue.h>, include <grub/command.h>,
<grub/reader.h> and <grub/parser.h>.
(grub_load_normal_mode): Execute normal command.
(grub_main): Call grub_register_core_commands,
grub_register_rescue_parser and grub_register_rescue_reader, use
grub_reader_loop to enter input loop.
* kern/parser.c (grub_parser_spli_cmdline): Change type of getline
parameter.
(grub_parser_class): New variable.
(grub_parser_execute): New function.
* loader/i386/multiboot.c: Remove <grub/rescue.h>.
* loader/multiboot2.c: Likewise.
* loader/sparc64/ieee1275/linux.c: Likewise.
* util/grub-emu.c (read_command_list): New dummy function.
warnings.
* kern/ieee1275/openfw.c (grub_claimmap): Likewise.
* disk/ieee1275/ofdisk.c (grub_ofdisk_open, grub_ofdisk_close,
grub_ofdisk_read): Likewise, and deal similarly with the fact that
ihandles have a 32-bit type but need to be stored in a "void *".
grub_devalias_iterate() result instead of unconditional 0.
* disk/ieee1275/ofdisk.c (grub_ofdisk_iterate): Likewise.
Also, capture hook return value, either directly or via
grub_children_iterate(), and propagate to caller.
* include/grub/ieee1275/ieee1275.h (grub_devalias_iterate,
grub_children_iterate): Return value is now 'int' instead of
'grub_err_t'.
* kern/ieee1275/openfw.c (grub_children_iterate): Fix to behave
like a proper iterator, stopping when hooks return non-zero.
(grub_devalias_iterate): Likewise.
* util/sparc64/ieee1275/grub-setup.c: New file.
* util/sparc64/ieee1275/grub-ofpathname.c: New file.
* util/sparc64/ieee1275/grub-mkimage.c: New file.
* util/sparc64/ieee1275/grub-install.in: New file.
* util/ieee1275/ofpath.c: New file.
* util/ieee1275/devicemap.c: New file.
* util/devicemap.c: New file.
* util/deviceiter.c: New file.
* kern/sparc64/ieee1275/init.c: New file.
* include/grub/util/ofpath.h: New file.
* include/grub/util/deviceiter.h: New file.
* util/grub-mkdevicemap.c: Include deviceiter.h.
Implement using grub_util_emit_devicemap_entry and
grub_util_iterate_devices.
* conf/i386-corebook.rmk: Build util/deviceiter.c and
util/devicemap.c into grub-mkdevicemap
* conf/i386-efi.rmk: Likewise.
* conf/i386-ieee1275.rmk: Likewise.
* conf/i386-pc.rmk: Likewise.
* conf/powerpc-ieee1275.rmk: Likewise.
* conf/sparc64-ieee1275.rmk: Add rules to build boot block
images and installation utilities. Build kernel as image
instead of as elf binary. Use common rules as much as possible.
* include/grub/types.h: Rename ULONG_MAX to GRUB_ULONG_MAX and
LONG_MAX to GRUB_LONG_MAX. Introduce GRUB_LONG_MIN. Update all
users of ULONG_MAX, LONG_MAX and LONG_MIN to use the new
definitions.
use grub_lltoa instead of grub_itoa and grub_ltoa for all purposes
* kern/misc.c (grub_itoa): Removed function
(grub_ltoa): likewise
(grub_vsprintf): use grub_lltoa