From: Roy Franz <roy.franz@linaro.org>
To: xen-devel@lists.xen.org, ian.campbell@citrix.com,
stefano.stabellini@citrix.com, tim@xen.org, jbeulich@suse.com,
keir@xen.org
Cc: Roy Franz <roy.franz@linaro.org>, fu.wei@linaro.org
Subject: [PATCH for-4.5 V6 07/14] Move x86 specific disk probing code
Date: Tue, 23 Sep 2014 22:03:05 -0700 [thread overview]
Message-ID: <1411534992-27443-8-git-send-email-roy.franz@linaro.org> (raw)
In-Reply-To: <1411534992-27443-1-git-send-email-roy.franz@linaro.org>
Move x86 specific disk (EDD) probing to arch specific file. This code is x86
only and relates to legacy BIOS handling of disk drives.
Signed-off-by: Roy Franz <roy.franz@linaro.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
---
xen/arch/x86/efi/efi-boot.h | 152 ++++++++++++++++++++++++++++++++++++++++++++
xen/common/efi/boot.c | 144 +----------------------------------------
2 files changed, 153 insertions(+), 143 deletions(-)
diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h
index 633a498..d7e2faf 100644
--- a/xen/arch/x86/efi/efi-boot.h
+++ b/xen/arch/x86/efi/efi-boot.h
@@ -305,3 +305,155 @@ static void __init efi_arch_handle_cmdline(CHAR16 *image_name,
mbi.boot_loader_name = (long)"EFI";
mbi.mods_addr = (long)mb_modules;
}
+
+static void __init efi_arch_edd(void)
+{
+ static EFI_GUID __initdata bio_guid = BLOCK_IO_PROTOCOL;
+ static EFI_GUID __initdata devp_guid = DEVICE_PATH_PROTOCOL;
+ EFI_HANDLE *handles = NULL;
+ unsigned int i;
+ UINTN size;
+ EFI_STATUS status;
+
+ /* Collect EDD info. */
+ BUILD_BUG_ON(offsetof(struct edd_info, edd_device_params) != EDDEXTSIZE);
+ BUILD_BUG_ON(sizeof(struct edd_device_params) != EDDPARMSIZE);
+ size = 0;
+ status = efi_bs->LocateHandle(ByProtocol, &bio_guid, NULL, &size, NULL);
+ if ( status == EFI_BUFFER_TOO_SMALL )
+ status = efi_bs->AllocatePool(EfiLoaderData, size, (void **)&handles);
+ if ( !EFI_ERROR(status) )
+ status = efi_bs->LocateHandle(ByProtocol, &bio_guid, NULL, &size,
+ handles);
+ if ( EFI_ERROR(status) )
+ size = 0;
+ for ( i = 0; i < size / sizeof(*handles); ++i )
+ {
+ EFI_BLOCK_IO *bio;
+ EFI_DEV_PATH_PTR devp;
+ struct edd_info *info = boot_edd_info + boot_edd_info_nr;
+ struct edd_device_params *params = &info->edd_device_params;
+ enum { root, acpi, pci, ctrlr } state = root;
+
+ status = efi_bs->HandleProtocol(handles[i], &bio_guid, (void **)&bio);
+ if ( EFI_ERROR(status) ||
+ bio->Media->RemovableMedia ||
+ bio->Media->LogicalPartition )
+ continue;
+ if ( boot_edd_info_nr < EDD_INFO_MAX )
+ {
+ info->device = 0x80 + boot_edd_info_nr; /* fake */
+ info->version = 0x11;
+ params->length = offsetof(struct edd_device_params, dpte_ptr);
+ params->number_of_sectors = bio->Media->LastBlock + 1;
+ params->bytes_per_sector = bio->Media->BlockSize;
+ params->dpte_ptr = ~0;
+ }
+ ++boot_edd_info_nr;
+ status = efi_bs->HandleProtocol(handles[i], &devp_guid,
+ (void **)&devp);
+ if ( EFI_ERROR(status) )
+ continue;
+ for ( ; !IsDevicePathEnd(devp.DevPath);
+ devp.DevPath = NextDevicePathNode(devp.DevPath) )
+ {
+ switch ( DevicePathType(devp.DevPath) )
+ {
+ const u8 *p;
+
+ case ACPI_DEVICE_PATH:
+ if ( state != root || boot_edd_info_nr > EDD_INFO_MAX )
+ break;
+ switch ( DevicePathSubType(devp.DevPath) )
+ {
+ case ACPI_DP:
+ if ( devp.Acpi->HID != EISA_PNP_ID(0xA03) &&
+ devp.Acpi->HID != EISA_PNP_ID(0xA08) )
+ break;
+ params->interface_path.pci.bus = devp.Acpi->UID;
+ state = acpi;
+ break;
+ case EXPANDED_ACPI_DP:
+ /* XXX */
+ break;
+ }
+ break;
+ case HARDWARE_DEVICE_PATH:
+ if ( state != acpi ||
+ DevicePathSubType(devp.DevPath) != HW_PCI_DP ||
+ boot_edd_info_nr > EDD_INFO_MAX )
+ break;
+ state = pci;
+ edd_put_string(params->host_bus_type, "PCI");
+ params->interface_path.pci.slot = devp.Pci->Device;
+ params->interface_path.pci.function = devp.Pci->Function;
+ break;
+ case MESSAGING_DEVICE_PATH:
+ if ( state != pci || boot_edd_info_nr > EDD_INFO_MAX )
+ break;
+ state = ctrlr;
+ switch ( DevicePathSubType(devp.DevPath) )
+ {
+ case MSG_ATAPI_DP:
+ edd_put_string(params->interface_type, "ATAPI");
+ params->interface_path.pci.channel =
+ devp.Atapi->PrimarySecondary;
+ params->device_path.atapi.device = devp.Atapi->SlaveMaster;
+ params->device_path.atapi.lun = devp.Atapi->Lun;
+ break;
+ case MSG_SCSI_DP:
+ edd_put_string(params->interface_type, "SCSI");
+ params->device_path.scsi.id = devp.Scsi->Pun;
+ params->device_path.scsi.lun = devp.Scsi->Lun;
+ break;
+ case MSG_FIBRECHANNEL_DP:
+ edd_put_string(params->interface_type, "FIBRE");
+ params->device_path.fibre.wwid = devp.FibreChannel->WWN;
+ params->device_path.fibre.lun = devp.FibreChannel->Lun;
+ break;
+ case MSG_1394_DP:
+ edd_put_string(params->interface_type, "1394");
+ params->device_path.i1394.eui = devp.F1394->Guid;
+ break;
+ case MSG_USB_DP:
+ case MSG_USB_CLASS_DP:
+ edd_put_string(params->interface_type, "USB");
+ break;
+ case MSG_I2O_DP:
+ edd_put_string(params->interface_type, "I2O");
+ params->device_path.i2o.identity_tag = devp.I2O->Tid;
+ break;
+ default:
+ continue;
+ }
+ info->version = 0x30;
+ params->length = sizeof(struct edd_device_params);
+ params->key = 0xbedd;
+ params->device_path_info_length =
+ sizeof(struct edd_device_params) -
+ offsetof(struct edd_device_params, key);
+ for ( p = (const u8 *)¶ms->key; p < ¶ms->checksum; ++p )
+ params->checksum -= *p;
+ break;
+ case MEDIA_DEVICE_PATH:
+ if ( DevicePathSubType(devp.DevPath) == MEDIA_HARDDRIVE_DP &&
+ devp.HardDrive->MBRType == MBR_TYPE_PCAT &&
+ boot_mbr_signature_nr < EDD_MBR_SIG_MAX )
+ {
+ struct mbr_signature *sig = boot_mbr_signature +
+ boot_mbr_signature_nr;
+
+ sig->device = 0x80 + boot_edd_info_nr; /* fake */
+ memcpy(&sig->signature, devp.HardDrive->Signature,
+ sizeof(sig->signature));
+ ++boot_mbr_signature_nr;
+ }
+ break;
+ }
+ }
+ }
+ if ( handles )
+ efi_bs->FreePool(handles);
+ if ( boot_edd_info_nr > EDD_INFO_MAX )
+ boot_edd_info_nr = EDD_INFO_MAX;
+}
diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
index 639280b..4566cf0 100644
--- a/xen/common/efi/boot.c
+++ b/xen/common/efi/boot.c
@@ -656,8 +656,6 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
static EFI_GUID __initdata loaded_image_guid = LOADED_IMAGE_PROTOCOL;
static EFI_GUID __initdata gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
- static EFI_GUID __initdata bio_guid = BLOCK_IO_PROTOCOL;
- static EFI_GUID __initdata devp_guid = DEVICE_PATH_PROTOCOL;
static EFI_GUID __initdata shim_lock_guid = SHIM_LOCK_PROTOCOL_GUID;
EFI_LOADED_IMAGE *loaded_image;
EFI_STATUS status;
@@ -944,147 +942,7 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
}
}
- /* Collect EDD info. */
- BUILD_BUG_ON(offsetof(struct edd_info, edd_device_params) != EDDEXTSIZE);
- BUILD_BUG_ON(sizeof(struct edd_device_params) != EDDPARMSIZE);
- size = 0;
- status = efi_bs->LocateHandle(ByProtocol, &bio_guid, NULL, &size, NULL);
- if ( status == EFI_BUFFER_TOO_SMALL )
- status = efi_bs->AllocatePool(EfiLoaderData, size, (void **)&handles);
- if ( !EFI_ERROR(status) )
- status = efi_bs->LocateHandle(ByProtocol, &bio_guid, NULL, &size,
- handles);
- if ( EFI_ERROR(status) )
- size = 0;
- for ( i = 0; i < size / sizeof(*handles); ++i )
- {
- EFI_BLOCK_IO *bio;
- EFI_DEV_PATH_PTR devp;
- struct edd_info *info = boot_edd_info + boot_edd_info_nr;
- struct edd_device_params *params = &info->edd_device_params;
- enum { root, acpi, pci, ctrlr } state = root;
-
- status = efi_bs->HandleProtocol(handles[i], &bio_guid, (void **)&bio);
- if ( EFI_ERROR(status) ||
- bio->Media->RemovableMedia ||
- bio->Media->LogicalPartition )
- continue;
- if ( boot_edd_info_nr < EDD_INFO_MAX )
- {
- info->device = 0x80 + boot_edd_info_nr; /* fake */
- info->version = 0x11;
- params->length = offsetof(struct edd_device_params, dpte_ptr);
- params->number_of_sectors = bio->Media->LastBlock + 1;
- params->bytes_per_sector = bio->Media->BlockSize;
- params->dpte_ptr = ~0;
- }
- ++boot_edd_info_nr;
- status = efi_bs->HandleProtocol(handles[i], &devp_guid,
- (void **)&devp);
- if ( EFI_ERROR(status) )
- continue;
- for ( ; !IsDevicePathEnd(devp.DevPath);
- devp.DevPath = NextDevicePathNode(devp.DevPath) )
- {
- switch ( DevicePathType(devp.DevPath) )
- {
- const u8 *p;
-
- case ACPI_DEVICE_PATH:
- if ( state != root || boot_edd_info_nr > EDD_INFO_MAX )
- break;
- switch ( DevicePathSubType(devp.DevPath) )
- {
- case ACPI_DP:
- if ( devp.Acpi->HID != EISA_PNP_ID(0xA03) &&
- devp.Acpi->HID != EISA_PNP_ID(0xA08) )
- break;
- params->interface_path.pci.bus = devp.Acpi->UID;
- state = acpi;
- break;
- case EXPANDED_ACPI_DP:
- /* XXX */
- break;
- }
- break;
- case HARDWARE_DEVICE_PATH:
- if ( state != acpi ||
- DevicePathSubType(devp.DevPath) != HW_PCI_DP ||
- boot_edd_info_nr > EDD_INFO_MAX )
- break;
- state = pci;
- edd_put_string(params->host_bus_type, "PCI");
- params->interface_path.pci.slot = devp.Pci->Device;
- params->interface_path.pci.function = devp.Pci->Function;
- break;
- case MESSAGING_DEVICE_PATH:
- if ( state != pci || boot_edd_info_nr > EDD_INFO_MAX )
- break;
- state = ctrlr;
- switch ( DevicePathSubType(devp.DevPath) )
- {
- case MSG_ATAPI_DP:
- edd_put_string(params->interface_type, "ATAPI");
- params->interface_path.pci.channel =
- devp.Atapi->PrimarySecondary;
- params->device_path.atapi.device = devp.Atapi->SlaveMaster;
- params->device_path.atapi.lun = devp.Atapi->Lun;
- break;
- case MSG_SCSI_DP:
- edd_put_string(params->interface_type, "SCSI");
- params->device_path.scsi.id = devp.Scsi->Pun;
- params->device_path.scsi.lun = devp.Scsi->Lun;
- break;
- case MSG_FIBRECHANNEL_DP:
- edd_put_string(params->interface_type, "FIBRE");
- params->device_path.fibre.wwid = devp.FibreChannel->WWN;
- params->device_path.fibre.lun = devp.FibreChannel->Lun;
- break;
- case MSG_1394_DP:
- edd_put_string(params->interface_type, "1394");
- params->device_path.i1394.eui = devp.F1394->Guid;
- break;
- case MSG_USB_DP:
- case MSG_USB_CLASS_DP:
- edd_put_string(params->interface_type, "USB");
- break;
- case MSG_I2O_DP:
- edd_put_string(params->interface_type, "I2O");
- params->device_path.i2o.identity_tag = devp.I2O->Tid;
- break;
- default:
- continue;
- }
- info->version = 0x30;
- params->length = sizeof(struct edd_device_params);
- params->key = 0xbedd;
- params->device_path_info_length =
- sizeof(struct edd_device_params) -
- offsetof(struct edd_device_params, key);
- for ( p = (const u8 *)¶ms->key; p < ¶ms->checksum; ++p )
- params->checksum -= *p;
- break;
- case MEDIA_DEVICE_PATH:
- if ( DevicePathSubType(devp.DevPath) == MEDIA_HARDDRIVE_DP &&
- devp.HardDrive->MBRType == MBR_TYPE_PCAT &&
- boot_mbr_signature_nr < EDD_MBR_SIG_MAX )
- {
- struct mbr_signature *sig = boot_mbr_signature +
- boot_mbr_signature_nr;
-
- sig->device = 0x80 + boot_edd_info_nr; /* fake */
- memcpy(&sig->signature, devp.HardDrive->Signature,
- sizeof(sig->signature));
- ++boot_mbr_signature_nr;
- }
- break;
- }
- }
- }
- if ( handles )
- efi_bs->FreePool(handles);
- if ( boot_edd_info_nr > EDD_INFO_MAX )
- boot_edd_info_nr = EDD_INFO_MAX;
+ efi_arch_edd();
/* XXX Collect EDID info. */
--
2.1.0
next prev parent reply other threads:[~2014-09-24 5:03 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-24 5:02 [PATCH for-4.5 V6 00/14] arm64 EFI stub Roy Franz
2014-09-24 5:02 ` [PATCH for-4.5 V6 01/14] move x86 EFI boot/runtime code to common/efi Roy Franz
2014-09-24 15:50 ` Jan Beulich
2014-09-24 19:41 ` Roy Franz
2014-09-24 5:03 ` [PATCH for-4.5 V6 02/14] Move x86 specific funtions/variables to arch header Roy Franz
2014-09-24 15:56 ` Jan Beulich
2014-09-24 19:45 ` Roy Franz
2014-09-25 8:12 ` Jan Beulich
2014-09-24 5:03 ` [PATCH for-4.5 V6 03/14] create arch functions to allocate memory for and process EFI memory map Roy Franz
2014-09-24 15:57 ` Jan Beulich
2014-09-24 5:03 ` [PATCH for-4.5 V6 04/14] Add architecture functions for pre/post ExitBootServices Roy Franz
2014-09-24 5:03 ` [PATCH for-4.5 V6 05/14] Add efi_arch_cfg_file_early/late() to handle arch specific cfg file fields Roy Franz
2014-09-24 5:03 ` [PATCH for-4.5 V6 06/14] Add efi_arch_handle_cmdline() for processing commandline Roy Franz
2014-09-24 5:03 ` Roy Franz [this message]
2014-09-24 5:03 ` [PATCH for-4.5 V6 08/14] Create arch functions for console and video init Roy Franz
2014-09-24 5:03 ` [PATCH for-4.5 V6 09/14] Add efi_arch_memory() for arch specific memory setup Roy Franz
2014-09-24 5:03 ` [PATCH for-4.5 V6 10/14] Add arch specific module handling to read_file() Roy Franz
2014-09-24 16:02 ` Jan Beulich
2014-09-24 5:03 ` [PATCH for-4.5 V6 11/14] Add several misc. arch functions for EFI boot code Roy Franz
2014-09-24 5:03 ` [PATCH for-4.5 V6 12/14] Add efi_arch_use_config_file() function to control use of config file Roy Franz
2014-09-24 5:03 ` [PATCH for-4.5 V6 13/14] Fix freeing of uninitialized pointer Roy Franz
2014-09-24 9:07 ` Jan Beulich
2014-09-24 19:22 ` Roy Franz
2014-09-25 8:13 ` Jan Beulich
2014-09-25 15:46 ` Roy Franz
2014-09-24 5:03 ` [PATCH for-4.5 V6 14/14] Add ARM EFI boot support Roy Franz
2014-09-24 16:11 ` Julien Grall
2014-09-24 19:53 ` Roy Franz
2014-09-24 8:55 ` [PATCH for-4.5 V6 00/14] arm64 EFI stub Jan Beulich
2014-09-24 19:37 ` Roy Franz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1411534992-27443-8-git-send-email-roy.franz@linaro.org \
--to=roy.franz@linaro.org \
--cc=fu.wei@linaro.org \
--cc=ian.campbell@citrix.com \
--cc=jbeulich@suse.com \
--cc=keir@xen.org \
--cc=stefano.stabellini@citrix.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).