From patchwork Thu Sep 25 01:42:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roy Franz X-Patchwork-Id: 37870 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8CF6E20063 for ; Thu, 25 Sep 2014 01:44:10 +0000 (UTC) Received: by mail-wg0-f72.google.com with SMTP id k14sf2329545wgh.11 for ; Wed, 24 Sep 2014 18:44:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe:list-post :list-help:list-subscribe:mime-version:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :list-archive:content-type:content-transfer-encoding; bh=fPWirrq8garp2X/tVg3ryeqodZTcZLmws21qNMON+5Q=; b=YDk1IN4HH8Ru61KROzM5lKVks7QKnzbY2ow1UQyyG1T0EWCKnjbrzpJVvpzFNTn7na tNzqy+K+V5FjYzetvyyNcYh3yLtauMUm/1EW5Vb4M8UA0XwKChgODhoJQEOqW/dBxRCf 7FOF10IhrLC//J+ecfl0oGCU/M6c350NQmQIhF10Fqp3PMJYNtozNzXOwyBT6Um9TbgJ 8te35qAVVn2rUsbnl3v4xDaCeknVMLZQ5E/jiK1hnqsb6jURWWZ8j0VlyMpXrp8BYy1I UgxtaYA+bsVPox+8ANajU3xrmL07pHLVofU6dCLc4oAFiYO01BtpwVm8qf3W0cn/Ktio U1tw== X-Gm-Message-State: ALoCoQkf9Mt6pgNqfsQKd15bal2K9reLWRD4Aaf+iXRdHcyIkTLkpYHm/E3Q/Tn9Sew3t7y4iblt X-Received: by 10.112.132.37 with SMTP id or5mr1583190lbb.2.1411609449727; Wed, 24 Sep 2014 18:44:09 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.28.73 with SMTP id z9ls209831lag.55.gmail; Wed, 24 Sep 2014 18:44:09 -0700 (PDT) X-Received: by 10.152.88.97 with SMTP id bf1mr9909966lab.58.1411609449582; Wed, 24 Sep 2014 18:44:09 -0700 (PDT) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com [209.85.215.43]) by mx.google.com with ESMTPS id d2si871026lbw.125.2014.09.24.18.44.09 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 24 Sep 2014 18:44:09 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by mail-la0-f43.google.com with SMTP id gb8so2169086lab.2 for ; Wed, 24 Sep 2014 18:44:09 -0700 (PDT) X-Received: by 10.112.161.70 with SMTP id xq6mr9490419lbb.49.1411609449219; Wed, 24 Sep 2014 18:44:09 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.130.169 with SMTP id of9csp678171lbb; Wed, 24 Sep 2014 18:44:08 -0700 (PDT) X-Received: by 10.221.64.2 with SMTP id xg2mr6622194vcb.18.1411609447867; Wed, 24 Sep 2014 18:44:07 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id h6si425075vdc.96.2014.09.24.18.44.07 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 24 Sep 2014 18:44:07 -0700 (PDT) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XWy5D-00015D-26; Thu, 25 Sep 2014 01:42:59 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XWy5B-00013C-PN for xen-devel@lists.xen.org; Thu, 25 Sep 2014 01:42:57 +0000 Received: from [193.109.254.147:26753] by server-6.bemta-14.messagelabs.com id E8/DA-01867-12373245; Thu, 25 Sep 2014 01:42:57 +0000 X-Env-Sender: roy.franz@linaro.org X-Msg-Ref: server-9.tower-27.messagelabs.com!1411609374!12840675!1 X-Originating-IP: [209.85.223.176] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.12.2; banners=-,-,- X-VirusChecked: Checked Received: (qmail 14511 invoked from network); 25 Sep 2014 01:42:55 -0000 Received: from mail-ie0-f176.google.com (HELO mail-ie0-f176.google.com) (209.85.223.176) by server-9.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 25 Sep 2014 01:42:55 -0000 Received: by mail-ie0-f176.google.com with SMTP id ar1so12244070iec.7 for ; Wed, 24 Sep 2014 18:42:53 -0700 (PDT) X-Received: by 10.42.180.5 with SMTP id bs5mr15431533icb.70.1411609373753; Wed, 24 Sep 2014 18:42:53 -0700 (PDT) Received: from rfranz-v430.caveonetworks.com (64.2.3.195.ptr.us.xo.net. [64.2.3.195]) by mx.google.com with ESMTPSA id x9sm5829238igl.10.2014.09.24.18.42.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Sep 2014 18:42:53 -0700 (PDT) From: Roy Franz To: xen-devel@lists.xen.org, ian.campbell@citrix.com, stefano.stabellini@citrix.com, tim@xen.org, jbeulich@suse.com, keir@xen.org Date: Wed, 24 Sep 2014 18:42:26 -0700 Message-Id: <1411609352-24549-9-git-send-email-roy.franz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1411609352-24549-1-git-send-email-roy.franz@linaro.org> References: <1411609352-24549-1-git-send-email-roy.franz@linaro.org> Cc: Roy Franz , fu.wei@linaro.org Subject: [Xen-devel] [PATCH for-4.5 V7 08/14] Move x86 specific disk probing code X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: roy.franz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: 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 Acked-by: Jan Beulich --- 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 07e9fc7..786d5cd 100644 --- a/xen/arch/x86/efi/efi-boot.h +++ b/xen/arch/x86/efi/efi-boot.h @@ -302,3 +302,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 24dba9b..9a3ae61 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -660,8 +660,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; @@ -948,147 +946,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. */