* kern/misc.c (grub_vsprintf): Fix size and termination of `format2'
(precision) digit string. Allow `.format2' without `format1' (width).
Limit input chars for `%s' output to `format2' if specified. This is
compatible with standard printf ().
* disk/ata.c (grub_ata_wait_status): Replace by ...
(grub_ata_wait_not_busy): ... this function. Checks only BSY bit,
other status bits may be invalid while BSY is asserted.
(grub_ata_check_ready): New function.
(grub_ata_cmd): Removed.
(grub_ata_wait_drq): New function.
(grub_ata_strncpy): Remove inline.
(grub_ata_pio_read): Reduce to actual block transfer. BSY wait
and error check now done by grub_ata_wait_drq ().
(grub_ata_pio_write): Likewise.
(grub_atapi_identify): Set DEV before check for !BSY. Use
grub_ata_wait_drq () to wait for data.
(grub_ata_device_initialize): Add status register check to
detect missing SATA slave devices. Add debug messages.
(grub_atapi_wait_drq): Use grub_ata_wait_not_busy ().
(grub_atapi_packet): Set DEV before check for !BSY. Replace
transfer loop by grub_ata_pio_write ().
(grub_ata_identify): Set DEV before check for !BSY. Use
grub_ata_wait_drq () to wait for data.
(grub_ata_setaddress): Set DEV before check for !BSY.
(grub_ata_readwrite): Remove duplicate code, handle batch/rest and
read/write in one loop. Fix invalid command on write. Fix incomplete
command on (size % batch) == 0. Add missing error check after write of
last block. Add debug messages.
(grub_atapi_read): Replace transfer loop by grub_ata_pio_read ().
* disk/ata.c (GRUB_ATAPI_REG_*): New defines.
(GRUB_ATAPI_IREASON_*): Likewise.
(grub_ata_pio_write): Fix timeout error return.
(grub_atapi_identify): Add grub_ata_wait () after cmd.
(grub_atapi_wait_drq): New function.
(grub_atapi_packet): New parameter `size'.
Use grub_atapi_wait_drq () and direct write instead of
grub_ata_pio_write ().
(grub_atapi_read): Replace grub_ata_pio_read () by a loop which
reads the number of bytes requested by the device for each DRQ
assertion.
(grub_atapi_write): Remove old implementation, return not
implemented instead.
* disk/scsi.c (grub_scsi_read10): Use scsi->blocksize instead
of 512 to calculate data size.
(grub_scsi_read12): Likewise.
(grub_scsi_write10): Likewise.
(grub_scsi_write12): Likewise.
(grub_scsi_read): Adjust size according to blocksize.
Add checks for invalid blocksize and unaligned transfer.
* disk/ata.c (enum grub_ata_commands): Remove EXEC_DEV_DIAGNOSTICS.
(enum grub_ata_timeout_milliseconds): New enum.
(grub_ata_wait_status): Add parameter milliseconds.
(grub_ata_cmd): Remove variable `err'. Remove wait for !DRQ to allow
recovery from timed-out commands.
(grub_ata_pio_read): Add parameter milliseconds. Fix error return,
return grub_errno instead of REG_ERROR.
(grub_ata_pio_write): Add parameter milliseconds.
(grub_atapi_identify): Fix size of ATAPI IDENTIFY sector.
Pass milliseconds to grub_ata_wait_status () and
grub_ata_pio_read ().
(grub_atapi_packet): Pass milliseconds to grub_ata_pio_write ().
(grub_ata_identify): Remove variable `ataerr'. Pass milliseconds to
grub_ata_wait_status (). Fix IDENTIFY timeout check.
(grub_ata_device_initialize): Remove EXECUTE DEVICE DIAGNOSTICS.
It is not suitable for device detection, because DEV bit is ignored,
the command may run too long, and not all devices set the signature
properly.
(grub_ata_pciinit): Clear grub_errno before grub_ata_device_initialize ().
(grub_ata_setaddress): Pass milliseconds to grub_ata_wait_status ().
Fix device selection, DEV bit must be set first to address the registers
of the correct device.
(grub_ata_readwrite): Pass milliseconds to grub_ata_wait_status () and
grub_ata_pio_read/write ().
(grub_atapi_read): Pass milliseconds to grub_ata_pio_read ().
(grub_atapi_write): Pass milliseconds to grub_ata_pio_write ().
* 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.
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.
* util/grub-fstest.c (grub_term_get_current_input): Change return type
to `grub_term_input_t'.
(grub_term_get_current_output): Change return type to
`grub_term_output_t'.
Fix breakage on coreboot due to declaration missmatch.
* term/i386/pc/vga_text.c (grub_vga_text_init_fini): New function.
(grub_vga_text_term): Use grub_vga_text_init_fini() instead of
grub_vga_text_cls().
grub_machine_mmap_iterate() interface (fixes a recently-introduced
build problem on i386-ieee1275):
* kern/ieee1275/openfw.c (grub_available_iterate): Moved from here ...
* kern/ieee1275/mmap.c (grub_machine_mmap_iterate): ... here. Add third
parameter `type'. Update all users of this function.
* conf/i386-ieee1275.rmk (kernel_elf_SOURCES): Add
`kern/ieee1275/mmap.c'.
* kern/ieee1275/init.c
* include/grub/ieee1275/ieee1275.h (grub_available_iterate): Replace
with ...
(grub_machine_mmap_iterate): ... this.
* include/grub/i386/pc/memory.h (grub_machine_mmap_iterate): Change
return type to `grub_err_t'. Update all implementations of this
function prototype.
* include/grub/i386/coreboot/memory.h (grub_machine_mmap_iterate):
Likewise.
* include/grub/i386/coreboot/memory.h (GRUB_MEMORY_MACHINE_LOWER_SIZE):
Redefine to match with GRUB_MEMORY_MACHINE_UPPER_START (0x100000). We
don't want to mess with lower memory, because it is used in the Linux
loader.
* loader/i386/linux.c (allocate_pages): Allocate `real_mode_mem' in
an appropiate place in lower memory, between 0x10000 and 0x90000,
like loader/i386/efi/linux.c does. Linux often panics if real_mode_mem
is in our heap (probably as a result of it being corrupted during
decompression).
Make loader/i386/linux.c buildable on i386-pc (although disabled).
* include/grub/i386/pc/init.h: Include `<grub/machine/memory.h>'.
(struct grub_machine_mmap_entry, grub_machine_mmap_iterate): Move
from here ...
* include/grub/i386/pc/memory.h: ... to here.
Fix build problems on i386-ieee1275 and *-efi (introduced by vga_text
split).
* include/grub/i386/pc/console.h: Include `<grub/i386/vga_common.h>'.
(grub_console_cur_color, grub_console_real_putchar)
(grub_console_putchar, grub_console_getcharwidth, grub_console_getwh)
(grub_console_setcolorstate, grub_console_setcolor)
(grub_console_getcolor): Move from here ...
* include/grub/i386/vga_common.h: ... to here (new file).
* term/i386/pc/vga_text.c: Replace `<grub/machine/console.h>' with
`<grub/i386/vga_common.h>' and `<grub/cpu/io.h>' with
`<grub/i386/io.h>'.
* term/i386/vga_common.c: Replace `<grub/machine/console.h>' with
`<grub/i386/vga_common.h>'.
* conf/i386-pc.rmk (kernel_img_SOURCES): Add `term/i386/vga_common.c'.
* conf/i386.rmk (pkglib_MODULES): Add `vga_text.mod'.
(vga_text_mod_SOURCES, vga_text_mod_CFLAGS, vga_text_mod_LDFLAGS): New
variables.
* conf/i386-coreboot.rmk (kernel_elf_SOURCES): Replace
`term/i386/pc/console.c' with `term/i386/vga_common.c'.
* kern/i386/coreboot/init.c (grub_machine_init): Replace call to
grub_console_init() with call to grub_vga_text_init().
(grub_machine_fini): Replace call to
grub_console_fini() with call to grub_vga_text_fini() and
grub_at_keyboard_fini().
* include/grub/i386/pc/console.h: Include `<grub/term.h>'.
(grub_console_putchar, grub_console_getcharwidth, grub_console_getwh)
(grub_console_setcolorstate, grub_console_setcolor)
(grub_console_getcolor): New function prototypes.
* term/i386/pc/vga_text.c: Include `<grub/dl.h>'.
(grub_vga_text_getxy, grub_vga_text_gotoxy, grub_vga_text_cls)
(grub_vga_text_setcursor): Static-ize.
(grub_vga_text_term): New structure.
(GRUB_MOD_INIT(vga_text), GRUB_MOD_FINI(vga_text)): New functions.
* term/i386/pc/console.c: Remove `<grub/machine/machine.h>'.
(grub_console_cur_color, grub_console_standard_color)
(grub_console_normal_color, grub_console_highlight_color)
(map_char, grub_console_putchar, grub_console_getcharwidth)
(grub_console_getwh, grub_console_setcolorstate, grub_console_setcolor)
(grub_console_getcolor): Move from here ...
* term/i386/vga_common.c: ... to here (same function names).
Use newly-added Multiboot support in coreboot.
* conf/i386-coreboot.rmk (kernel_elf_SOURCES): Replace
`kern/i386/coreboot/mmap.c' with `kern/i386/multiboot_mmap.c'.
* kern/i386/coreboot/startup.S: Enable Multiboot header, fix its
alignment, set `MULTIBOOT_MEMORY_INFO' flag.
(codestart): Store the MBI in `startup_multiboot_info' when we're
being loaded using Multiboot.
* kern/i386/coreboot/init.c (grub_machine_init): Move
grub_at_keyboard_init() call to beginning of function (useful for
debugging). Call grub_machine_mmap_init() before attempting to use
grub_machine_mmap_iterate().
(grub_lower_mem, grub_upper_mem): Move from here ...
* kern/i386/multiboot_mmap.c (grub_lower_mem, grub_upper_mem): ... to
here (new file).
* include/grub/i386/coreboot/memory.h (grub_machine_mmap_init): New
function prototype.
Fix a regression introduced by the at_keyboard.mod split. Because
some terminals are default on some platforms and non-default on
others, the first terminal being registered determines which is
going to be default.
* kern/term.c (grub_term_register_input): If this is the first
terminal being registered, set it as the current one.
(grub_term_register_output): Likewise.
* term/efi/console.c (grub_console_init): Do not call
grub_term_set_current_output() or grub_term_set_current_input().
* term/ieee1275/ofconsole.c (grub_console_init): Likewise.
* term/i386/pc/console.c (grub_console_init): Likewise.
(grub_console_fini): Do not call grub_term_set_current_input()
(but leave grub_term_set_current_output() to restore text mode).