2006-04-30 Yoshinori K. Okuji <okuji@enbug.org>
Extend the loader so that GRUB can accept a loader which comes back to GRUB when a loaded image exits. Also, this change adds support for a chainloader on EFI. * term/efi/console.c: Include grub/misc.h. (grub_console_checkkey): Display a scan code on the top for debugging. This will be removed once the EFI port gets stable. Correct the scan code mapping. * kern/efi/mm.c (sort_memory_map): Sort in a descending order to allocate memory from larger regions, in order to reduce the number of allocated regions. Otherwise, the MacOSX loader panics. (filter_memory_map): Avoid less than 1MB for compatibility with other loaders. (add_memory_regions): Allocate from the tail of a region, if possible, to avoid allocating a region near to 1MB, for the MacOSX loader. * kern/efi/init.c (grub_efi_set_prefix): Specify GRUB_EFI_IMAGE_HANDLE to grub_efi_get_loaded_image. * kern/efi/efi.c (grub_efi_get_loaded_image): Accept a new argument IMAGE_HANDLE and specify it to get a loaded image. (grub_arch_modules_addr): Specify GRUB_EFI_IMAGE_HANDLE to grub_efi_get_loaded_image. (grub_efi_get_filename): Divide the legnth by the size of grub_efi_char16_t. (grub_efi_get_device_path): New function. (grub_efi_print_device_path): Print End Device Path nodes. Divide the length by the size of grub_efi_char16_t for a file path device path node. * kern/loader.c (grub_loader_noreturn): New variable. (grub_loader_set): Accept a new argument NORETURN. Set GRUB_LOADER_NORETURN to NORETURN. All callers changed. (grub_loader_boot): If GRUB_LOADER_NORETURN is false, do not call grub_machine_fini. * include/grub/efi/efi.h (grub_efi_get_device_path): New prototype. (grub_efi_get_loaded_image): Take an argument to specify an image handle. * include/grub/loader.h (grub_loader_set): Added one more argument NORETURN. * disk/efi/efidisk.c (make_devices): Use grub_efi_get_device_path instead of grub_efi_open_protocol. (grub_efidisk_get_device_name): Likewise. (grub_efidisk_close): Print a newline. (grub_efidisk_get_device_handle): Fixed to use GRUB_EFI_DEVICE_PATH_SUBTYPE instead of GRUB_EFI_DEVICE_PATH_TYPE. * disk/efi/efidisk.c (device_path_guid): Moved to ... * kern/efi/efi.c (device_path_guid): ... here. * conf/i386-efi.rmk (pkgdata_MODULES): Added _chain.mod and chain.mod. (kernel_mod_HEADERS): Added efi/disk.h. (_chain_mod_SOURCES): New variable. (_chain_mod_CFLAGS): Likewise. (_chain_mod_LDFLAGS): Likewise. (chain_mod_SOURCES): Likewise. (chain_mod_CFLAGS): Likewise. (chain_mod_LDFLAGS): Likewise. * DISTLIST: Added include/grub/efi/chainloader.h, loader/efi/chainloader.c and loader/efi/chainloader_normal.c. * include/grub/efi/chainloader.h: New file. * loader/efi/chainloader.c: Likewise. * loader/efi/chainloader_normal.c: Likewise.
This commit is contained in:
parent
c0111d6e92
commit
7f362539b7
19 changed files with 743 additions and 64 deletions
|
@ -41,7 +41,6 @@ struct grub_efidisk_data
|
|||
/* GUIDs. */
|
||||
static grub_efi_guid_t disk_io_guid = GRUB_EFI_DISK_IO_GUID;
|
||||
static grub_efi_guid_t block_io_guid = GRUB_EFI_BLOCK_IO_GUID;
|
||||
static grub_efi_guid_t device_path_guid = GRUB_EFI_DEVICE_PATH_GUID;
|
||||
|
||||
static struct grub_efidisk_data *fd_devices;
|
||||
static struct grub_efidisk_data *hd_devices;
|
||||
|
@ -159,8 +158,7 @@ make_devices (void)
|
|||
grub_efi_block_io_t *bio;
|
||||
grub_efi_disk_io_t *dio;
|
||||
|
||||
dp = grub_efi_open_protocol (*handle, &device_path_guid,
|
||||
GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL);
|
||||
dp = grub_efi_get_device_path (*handle);
|
||||
if (! dp)
|
||||
continue;
|
||||
|
||||
|
@ -556,7 +554,7 @@ static void
|
|||
grub_efidisk_close (struct grub_disk *disk __attribute__ ((unused)))
|
||||
{
|
||||
/* EFI disks do not allocate extra memory, so nothing to do here. */
|
||||
grub_dprintf ("efidisk", "closing %s", disk->name);
|
||||
grub_dprintf ("efidisk", "closing %s\n", disk->name);
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
|
@ -683,7 +681,7 @@ grub_efidisk_get_device_handle (grub_disk_t disk)
|
|||
|
||||
if ((GRUB_EFI_DEVICE_PATH_TYPE (c->last_device_path)
|
||||
== GRUB_EFI_MEDIA_DEVICE_PATH_TYPE)
|
||||
&& (GRUB_EFI_DEVICE_PATH_TYPE (c->last_device_path)
|
||||
&& (GRUB_EFI_DEVICE_PATH_SUBTYPE (c->last_device_path)
|
||||
== GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE)
|
||||
&& (grub_partition_get_start (disk->partition)
|
||||
== hd.partition_start)
|
||||
|
@ -718,8 +716,7 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
|
|||
{
|
||||
grub_efi_device_path_t *dp, *ldp;
|
||||
|
||||
dp = grub_efi_open_protocol (handle, &device_path_guid,
|
||||
GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL);
|
||||
dp = grub_efi_get_device_path (handle);
|
||||
if (! dp)
|
||||
return 0;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue