From patchwork Fri Jan 2 10:45:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 42690 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f72.google.com (mail-ee0-f72.google.com [74.125.83.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2929D26CD1 for ; Fri, 2 Jan 2015 10:45:53 +0000 (UTC) Received: by mail-ee0-f72.google.com with SMTP id e53sf10494457eek.11 for ; Fri, 02 Jan 2015 02:45:52 -0800 (PST) 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:subject:precedence:reply-to:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :content-type:content-transfer-encoding:errors-to:x-original-sender :x-original-authentication-results:mailing-list; bh=gRkUNA57y9GnVJcnpQrF53L20Rdmxurq/OFwd/4G2jE=; b=ffdQ4NQKmFw0qTZOIhhqT7UBY+0jgKenM/gPM7rvgPYQysygiVEUYuAlSV9jqV1JYR Ls8UnWCu6wKwd8IFxY/ke5PtZT1sjBmy/LIGP/CPjp38XNaPNgkiCPG7FxFopQp+yW6Z L1n/Gt5LghbJy8fHcGrGFjUReQji1yTcqlaEs4/ml8Oy7Yhd17/2WGZ2Sx7rh6fPWa3v 9/GQAe6V18gYRXyMMloIuL4X9Jsrt2dy92chSmey6OujLWsACmUgM6PN3qzSBz5ovjBF bKZhfQlHaAdf+zLDJvV+z/iZOad6r7TTbh6zEn21XXWHeBTra5Gv4E9u5lcVE9uMmz7N wA0g== X-Gm-Message-State: ALoCoQm5bWEOzCXtTYQ5vjpy20fipSfKhhHA+ZrcZEF2O+jJ2oj8Y5Zdl70+sjU2I3sAgPTfqgTv X-Received: by 10.112.141.98 with SMTP id rn2mr5897585lbb.2.1420195552334; Fri, 02 Jan 2015 02:45:52 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.43.165 with SMTP id x5ls2387439lal.34.gmail; Fri, 02 Jan 2015 02:45:52 -0800 (PST) X-Received: by 10.112.89.232 with SMTP id br8mr36535580lbb.69.1420195552178; Fri, 02 Jan 2015 02:45:52 -0800 (PST) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id yi9si50940317lab.58.2015.01.02.02.45.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 02 Jan 2015 02:45:51 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by mail-la0-f47.google.com with SMTP id hz20so14935136lab.20 for ; Fri, 02 Jan 2015 02:45:51 -0800 (PST) X-Received: by 10.152.26.201 with SMTP id n9mr76416088lag.50.1420195551824; Fri, 02 Jan 2015 02:45:51 -0800 (PST) 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.9.200 with SMTP id c8csp164475lbb; Fri, 2 Jan 2015 02:45:50 -0800 (PST) X-Received: by 10.50.109.164 with SMTP id ht4mr63390203igb.4.1420195549760; Fri, 02 Jan 2015 02:45:49 -0800 (PST) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id aa4si6668234igd.60.2015.01.02.02.45.49 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 02 Jan 2015 02:45:49 -0800 (PST) Received-SPF: pass (google.com: domain of edk2-devel-bounces@lists.sourceforge.net designates 216.34.181.88 as permitted sender) client-ip=216.34.181.88; Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1Y6zjc-0007Ry-T6; Fri, 02 Jan 2015 10:45:36 +0000 Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1Y6zjY-0007Rm-M6 for edk2-devel@lists.sourceforge.net; Fri, 02 Jan 2015 10:45:32 +0000 Received-SPF: pass (sog-mx-2.v43.ch3.sourceforge.com: domain of linaro.org designates 74.125.82.47 as permitted sender) client-ip=74.125.82.47; envelope-from=ard.biesheuvel@linaro.org; helo=mail-wg0-f47.google.com; Received: from mail-wg0-f47.google.com ([74.125.82.47]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1Y6zjW-0000cE-Di for edk2-devel@lists.sourceforge.net; Fri, 02 Jan 2015 10:45:32 +0000 Received: by mail-wg0-f47.google.com with SMTP id n12so23739474wgh.6 for ; Fri, 02 Jan 2015 02:45:24 -0800 (PST) X-Received: by 10.194.82.97 with SMTP id h1mr151389969wjy.116.1420195524419; Fri, 02 Jan 2015 02:45:24 -0800 (PST) Received: from ards-macbook-pro.local ([197.131.3.201]) by mx.google.com with ESMTPSA id c10sm64201270wjy.4.2015.01.02.02.45.22 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 02 Jan 2015 02:45:23 -0800 (PST) From: Ard Biesheuvel To: anthony.perard@citrix.com, christoffer.dall@linaro.org, ijc@hellion.org.uk, stefano.stabellini@eu.citrix.com, lersek@redhat.com, linaro-uefi@lists.linaro.org, edk2-devel@lists.sourceforge.net Date: Fri, 2 Jan 2015 10:45:07 +0000 Message-Id: <1420195510-22100-3-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1420195510-22100-1-git-send-email-ard.biesheuvel@linaro.org> References: <1420195510-22100-1-git-send-email-ard.biesheuvel@linaro.org> X-Spam-Score: -1.5 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_PASS SPF: sender matches SPF record X-Headers-End: 1Y6zjW-0000cE-Di Subject: [edk2] [RFC PATCH 2/5] Ovmf/Xen: allow non-PCI usage of XenBusDxe X-BeenThere: edk2-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list Reply-To: edk2-devel@lists.sourceforge.net List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.sourceforge.net X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@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.47 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 While Xen on Intel uses a virtual PCI device to communicate the base address of the grant table, the ARM implementation uses a DT node, which is fundamentally incompatible with the way XenBusDxe is implemented, i.e., as a UEFI Driver Model implementation for a PCI device. To allow the non-PCI implementations to use this driver anyway, this patch introduces an abstract XENIO_PROTOCOL protocol, which contains just the grant table base address. The Intel implementation is adapted to allocate such a protocol on the fly based on the PCI config space metadata, so it operates as before. Other users can invoke the driver by installing a XENIO_PROTOCOL instance on a handle, and invoking ConnectController() Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- OvmfPkg/Include/Protocol/XenIo.h | 48 ++++++++++ OvmfPkg/OvmfPkg.dec | 1 + OvmfPkg/XenBusDxe/ComponentName.c | 2 +- OvmfPkg/XenBusDxe/GrantTable.c | 5 +- OvmfPkg/XenBusDxe/GrantTable.h | 3 +- OvmfPkg/XenBusDxe/XenBus.c | 6 +- OvmfPkg/XenBusDxe/XenBusDxe.c | 185 ++++++++++++++++++++++++++++++++------ OvmfPkg/XenBusDxe/XenBusDxe.h | 2 + OvmfPkg/XenBusDxe/XenBusDxe.inf | 1 + 9 files changed, 215 insertions(+), 38 deletions(-) create mode 100644 OvmfPkg/Include/Protocol/XenIo.h diff --git a/OvmfPkg/Include/Protocol/XenIo.h b/OvmfPkg/Include/Protocol/XenIo.h new file mode 100644 index 000000000000..510391f3b3e8 --- /dev/null +++ b/OvmfPkg/Include/Protocol/XenIo.h @@ -0,0 +1,48 @@ +/** @file + XenIo protocol to abstract arch specific details + + The Xen implementations for the Intel and ARM archictures differ in the way + the base address of the grant table is communicated to the guest. The former + uses a virtual PCI device, while the latter uses a device tree node. + In order to allow the XenBusDxe UEFI driver to be reused for the non-PCI + Xen implementation, this abstract protocol can be installed on a handle + with the appropriate base address. + + Copyright (C) 2014, Linaro Ltd. + + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef __PROTOCOL_XENIO_H__ +#define __PROTOCOL_XENIO_H__ + +#include + +#define XENIO_PROTOCOL_GUID \ + {0x6efac84f, 0x0ab0, 0x4747, {0x81, 0xbe, 0x85, 0x55, 0x62, 0x59, 0x04, 0x49}} + +/// +/// Forward declaration +/// +typedef struct _XENIO_PROTOCOL XENIO_PROTOCOL; + +/// +/// Protocol structure +/// +struct _XENIO_PROTOCOL { + // + // Protocol data fields + // + EFI_PHYSICAL_ADDRESS GrantTableAddress; +}; + +extern EFI_GUID gXenIoProtocolGuid; + +#endif diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec index 314d97c258b3..0233ae4ca754 100644 --- a/OvmfPkg/OvmfPkg.dec +++ b/OvmfPkg/OvmfPkg.dec @@ -52,6 +52,7 @@ gVirtioDeviceProtocolGuid = {0xfa920010, 0x6785, 0x4941, {0xb6, 0xec, 0x49, 0x8c, 0x57, 0x9f, 0x16, 0x0a}} gBlockMmioProtocolGuid = {0x6b558ce3, 0x69e5, 0x4c67, {0xa6, 0x34, 0xf7, 0xfe, 0x72, 0xad, 0xbe, 0x84}} gXenBusProtocolGuid = {0x3d3ca290, 0xb9a5, 0x11e3, {0xb7, 0x5d, 0xb8, 0xac, 0x6f, 0x7d, 0x65, 0xe6}} + gXenIoProtocolGuid = {0x6efac84f, 0x0ab0, 0x4747, {0x81, 0xbe, 0x85, 0x55, 0x62, 0x59, 0x04, 0x49}} [PcdsFixedAtBuild] gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase|0x0|UINT32|0 diff --git a/OvmfPkg/XenBusDxe/ComponentName.c b/OvmfPkg/XenBusDxe/ComponentName.c index 4530509e65dc..3f2dd406c77d 100644 --- a/OvmfPkg/XenBusDxe/ComponentName.c +++ b/OvmfPkg/XenBusDxe/ComponentName.c @@ -155,7 +155,7 @@ XenBusDxeComponentNameGetControllerName ( Status = EfiTestManagedDevice ( ControllerHandle, gXenBusDxeDriverBinding.DriverBindingHandle, - &gEfiPciIoProtocolGuid + &gXenIoProtocolGuid ); if (EFI_ERROR (Status)) { return Status; diff --git a/OvmfPkg/XenBusDxe/GrantTable.c b/OvmfPkg/XenBusDxe/GrantTable.c index 37d3bf786c64..ae9059c146f1 100644 --- a/OvmfPkg/XenBusDxe/GrantTable.c +++ b/OvmfPkg/XenBusDxe/GrantTable.c @@ -139,8 +139,7 @@ XenGrantTableEndAccess ( VOID XenGrantTableInit ( - IN XENBUS_DEVICE *Dev, - IN UINT64 MmioAddr + IN XENBUS_DEVICE *Dev ) { xen_add_to_physmap_t Parameters; @@ -155,7 +154,7 @@ XenGrantTableInit ( XenGrantTablePutFreeEntry ((grant_ref_t)Index); } - GrantTable = (VOID*)(UINTN) MmioAddr; + GrantTable = (VOID*)(UINTN) Dev->XenIo->GrantTableAddress; for (Index = 0; Index < NR_GRANT_FRAMES; Index++) { Parameters.domid = DOMID_SELF; Parameters.idx = Index; diff --git a/OvmfPkg/XenBusDxe/GrantTable.h b/OvmfPkg/XenBusDxe/GrantTable.h index 5772c56662df..194275ba7ed5 100644 --- a/OvmfPkg/XenBusDxe/GrantTable.h +++ b/OvmfPkg/XenBusDxe/GrantTable.h @@ -29,8 +29,7 @@ **/ VOID XenGrantTableInit ( - IN XENBUS_DEVICE *Dev, - IN UINT64 MmioAddr + IN XENBUS_DEVICE *Dev ); /** diff --git a/OvmfPkg/XenBusDxe/XenBus.c b/OvmfPkg/XenBusDxe/XenBus.c index f69c27dd184a..ee9526c33252 100644 --- a/OvmfPkg/XenBusDxe/XenBus.c +++ b/OvmfPkg/XenBusDxe/XenBus.c @@ -138,7 +138,7 @@ XenBusAddDevice ( XENBUS_PRIVATE_DATA *Private; EFI_STATUS Status; XENBUS_DEVICE_PATH *TempXenBusPath; - VOID *ChildPciIo; + VOID *ChildXenIo; AsciiSPrint (DevicePath, sizeof (DevicePath), "device/%a/%a", Type, Id); @@ -208,8 +208,8 @@ XenBusAddDevice ( } Status = gBS->OpenProtocol (Dev->ControllerHandle, - &gEfiPciIoProtocolGuid, - &ChildPciIo, Dev->This->DriverBindingHandle, + &gXenIoProtocolGuid, + &ChildXenIo, Dev->This->DriverBindingHandle, Private->Handle, EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER); if (EFI_ERROR (Status)) { diff --git a/OvmfPkg/XenBusDxe/XenBusDxe.c b/OvmfPkg/XenBusDxe/XenBusDxe.c index 07336ff15bba..a03f7cb6d8b9 100644 --- a/OvmfPkg/XenBusDxe/XenBusDxe.c +++ b/OvmfPkg/XenBusDxe/XenBusDxe.c @@ -194,6 +194,22 @@ XenBusDxeDriverBindingSupported ( EFI_PCI_IO_PROTOCOL *PciIo; PCI_TYPE00 Pci; + // + // If the ControllerHandle supports the XENIO_PROTOCOL, we can use + // it directly without having to bother with the PCI representation. + // + Status = gBS->OpenProtocol ( + ControllerHandle, + &gXenIoProtocolGuid, + NULL, + This->DriverBindingHandle, + ControllerHandle, + EFI_OPEN_PROTOCOL_TEST_PROTOCOL + ); + if (!EFI_ERROR (Status)) { + return Status; + } + Status = gBS->OpenProtocol ( ControllerHandle, &gEfiPciIoProtocolGuid, @@ -238,6 +254,137 @@ NotifyExitBoot ( } /** + Opens the XENIO_PROTOCOL on ControllerHandle. + + If the protocol is not available, but the EFI_PCI_IO_PROTOCOL is, create + the XENIO_PROTOCOL protocol instance on the fly based on the PCI metadata + and install it on ControllerHandle. + + @param ControllerHandle The controller handle + @param DriverBindingHandle The driver binding handle + @param XenIo The XENIO_PROTOCOL return value + @param PciIo The EFI_PCI_IO_PROTOCOL return value, or NULL if + the XENIO_PROTOCOL already existed on Handle +**/ +STATIC +EFI_STATUS +OpenOrInstallXenIoProtocolOnHandle ( + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE DriverBindingHandle, + OUT XENIO_PROTOCOL **XenIo, + OUT EFI_PCI_IO_PROTOCOL **PciIo + ) +{ + EFI_STATUS Status; + EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *BarDesc; + + // + // We support both EFI_PCI_IO_PROTOCOL and XENIO_PROTOCOL, the former only + // if the vendor and product IDs match up (as verified in .Supported()). + // The latter has precedence, and we install it on the fly if it is not + // supported. + // + *PciIo = NULL; + Status = gBS->OpenProtocol ( + ControllerHandle, + &gXenIoProtocolGuid, + (VOID**)XenIo, + DriverBindingHandle, + ControllerHandle, + EFI_OPEN_PROTOCOL_BY_DRIVER + ); + if (EFI_ERROR (Status)) { + // + // This handle does not support XENIO_PROTOCOL yet, which implies that it + // does support the EFI_PCI_IO_PROTOCOL, or we wouldn't have been invoked. + // Get the grant table base address from the PCI config space, and allocate + // and install the XENIO_PROTOCOL instance on the fly. + // + Status = gBS->OpenProtocol ( + ControllerHandle, + &gEfiPciIoProtocolGuid, + (VOID**)PciIo, + DriverBindingHandle, + ControllerHandle, + EFI_OPEN_PROTOCOL_BY_DRIVER + ); + ASSERT_EFI_ERROR (Status); + + *XenIo = AllocateZeroPool (sizeof(XENIO_PROTOCOL)); + ASSERT (*XenIo != NULL); + + // + // The BAR1 of this PCI device is used for shared memory and is supposed to + // look like MMIO. The address space of the BAR1 will be used to map the + // Grant Table. + // + Status = (*PciIo)->GetBarAttributes (*PciIo, PCI_BAR_IDX1, NULL, (VOID**) &BarDesc); + ASSERT_EFI_ERROR (Status); + ASSERT (BarDesc->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM); + + /* Get a Memory address for mapping the Grant Table. */ + DEBUG ((EFI_D_INFO, "XenBus: BAR at %LX\n", BarDesc->AddrRangeMin)); + (*XenIo)->GrantTableAddress = BarDesc->AddrRangeMin; + FreePool (BarDesc); + + // + // Now install the XENIO_PROTOCOL protocol instance on Handle. + // This should only fail in extraordinary cases, as we have already + // established that the protocol does not exist yet on the handle. + // + Status = gBS->InstallProtocolInterface (ControllerHandle, + &gXenIoProtocolGuid, EFI_NATIVE_INTERFACE, *XenIo); + ASSERT_EFI_ERROR (Status); + + Status = gBS->OpenProtocol ( + ControllerHandle, + &gXenIoProtocolGuid, + (VOID**)XenIo, + DriverBindingHandle, + ControllerHandle, + EFI_OPEN_PROTOCOL_BY_DRIVER + ); + if (EFI_ERROR (Status)) { + gBS->CloseProtocol (ControllerHandle, &gEfiPciIoProtocolGuid, + DriverBindingHandle, ControllerHandle); + } + } + return Status; +} + +/** + Close or uninstall the XENIO_PROTOCOL instance on ControllerHandle + + Close the XENIO_PROTOCOL protocol instance on ControllerHandle, and + in case PciIo != NULL, uninstall and deallocate it as well. + + @param ControllerHandle The controller handle + @param DriverBindingHandle The driver binding handle + @param XenIo The XENIO_PROTOCOL protocol instance + @param PciIo The EFI_PCI_IO_PROTOCOL protocol instance, or NULL + if the XENIO_PROTOCOL already existed on + ControllerHandle +**/ +STATIC +VOID +CloseOrUninstallXenIoProtocolOnHandle ( + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE DriverBindingHandle, + IN XENIO_PROTOCOL *XenIo, + IN EFI_PCI_IO_PROTOCOL *PciIo + ) +{ + gBS->CloseProtocol (ControllerHandle, &gXenIoProtocolGuid, + DriverBindingHandle, ControllerHandle); + if (PciIo != NULL) { + gBS->UninstallProtocolInterface (ControllerHandle, &gXenIoProtocolGuid, XenIo); + FreePool (XenIo); + gBS->CloseProtocol (ControllerHandle, &gEfiPciIoProtocolGuid, + DriverBindingHandle, ControllerHandle); + } +} + +/** Starts a bus controller. The Start() function is designed to be invoked from the EFI boot service ConnectController(). @@ -284,19 +431,12 @@ XenBusDxeDriverBindingStart ( { EFI_STATUS Status; XENBUS_DEVICE *Dev; + XENIO_PROTOCOL *XenIo; EFI_PCI_IO_PROTOCOL *PciIo; - EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *BarDesc; - UINT64 MmioAddr; EFI_DEVICE_PATH_PROTOCOL *DevicePath; - Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiPciIoProtocolGuid, - (VOID **) &PciIo, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); + Status = OpenOrInstallXenIoProtocolOnHandle (ControllerHandle, + This->DriverBindingHandle, &XenIo, &PciIo); if (EFI_ERROR (Status)) { return Status; } @@ -319,6 +459,7 @@ XenBusDxeDriverBindingStart ( Dev->This = This; Dev->ControllerHandle = ControllerHandle; Dev->PciIo = PciIo; + Dev->XenIo = XenIo; Dev->DevicePath = DevicePath; InitializeListHead (&Dev->ChildList); @@ -334,20 +475,6 @@ XenBusDxeDriverBindingStart ( mMyDevice = Dev; EfiReleaseLock (&mMyDeviceLock); - // - // The BAR1 of this PCI device is used for shared memory and is supposed to - // look like MMIO. The address space of the BAR1 will be used to map the - // Grant Table. - // - Status = PciIo->GetBarAttributes (PciIo, PCI_BAR_IDX1, NULL, (VOID**) &BarDesc); - ASSERT_EFI_ERROR (Status); - ASSERT (BarDesc->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM); - - /* Get a Memory address for mapping the Grant Table. */ - DEBUG ((EFI_D_INFO, "XenBus: BAR at %LX\n", BarDesc->AddrRangeMin)); - MmioAddr = BarDesc->AddrRangeMin; - FreePool (BarDesc); - Status = XenGetSharedInfoPage (Dev); if (EFI_ERROR (Status)) { DEBUG ((EFI_D_ERROR, "XenBus: Unable to get the shared info page.\n")); @@ -355,7 +482,7 @@ XenBusDxeDriverBindingStart ( goto ErrorAllocated; } - XenGrantTableInit (Dev, MmioAddr); + XenGrantTableInit (Dev); Status = XenStoreInit (Dev); ASSERT_EFI_ERROR (Status); @@ -375,8 +502,8 @@ ErrorAllocated: gBS->CloseProtocol (ControllerHandle, &gEfiDevicePathProtocolGuid, This->DriverBindingHandle, ControllerHandle); ErrorOpenningProtocol: - gBS->CloseProtocol (ControllerHandle, &gEfiPciIoProtocolGuid, - This->DriverBindingHandle, ControllerHandle); + CloseOrUninstallXenIoProtocolOnHandle (ControllerHandle, + This->DriverBindingHandle, XenIo, PciIo); return Status; } @@ -465,8 +592,8 @@ XenBusDxeDriverBindingStop ( gBS->CloseProtocol (ControllerHandle, &gEfiDevicePathProtocolGuid, This->DriverBindingHandle, ControllerHandle); - gBS->CloseProtocol (ControllerHandle, &gEfiPciIoProtocolGuid, - This->DriverBindingHandle, ControllerHandle); + CloseOrUninstallXenIoProtocolOnHandle (ControllerHandle, + This->DriverBindingHandle, Dev->XenIo, Dev->PciIo); mMyDevice = NULL; FreePool (Dev); diff --git a/OvmfPkg/XenBusDxe/XenBusDxe.h b/OvmfPkg/XenBusDxe/XenBusDxe.h index 0879e9cd194f..81b73f8f1e0b 100644 --- a/OvmfPkg/XenBusDxe/XenBusDxe.h +++ b/OvmfPkg/XenBusDxe/XenBusDxe.h @@ -45,6 +45,7 @@ // Consumed Protocols // #include +#include // @@ -92,6 +93,7 @@ struct _XENBUS_DEVICE { EFI_DRIVER_BINDING_PROTOCOL *This; EFI_HANDLE ControllerHandle; EFI_PCI_IO_PROTOCOL *PciIo; + XENIO_PROTOCOL *XenIo; EFI_EVENT ExitBootEvent; EFI_DEVICE_PATH_PROTOCOL *DevicePath; LIST_ENTRY ChildList; diff --git a/OvmfPkg/XenBusDxe/XenBusDxe.inf b/OvmfPkg/XenBusDxe/XenBusDxe.inf index 2645267a1c6f..1429a85e1d12 100644 --- a/OvmfPkg/XenBusDxe/XenBusDxe.inf +++ b/OvmfPkg/XenBusDxe/XenBusDxe.inf @@ -73,4 +73,5 @@ gEfiComponentName2ProtocolGuid gEfiComponentNameProtocolGuid gXenBusProtocolGuid + gXenIoProtocolGuid