summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/XenBusDxe/XenBusDxe.c
diff options
context:
space:
mode:
authorSteven Smith <sos22@cam.ac.uk>2014-10-29 06:50:14 +0000
committerjljusten <jljusten@Edk2>2014-10-29 06:50:14 +0000
commit0fd142464fc5b0fcb8b7fdfac379c1054ec81654 (patch)
tree5976cdb6b46225cc1c57b6bf264e55f067e2fc51 /OvmfPkg/XenBusDxe/XenBusDxe.c
parentbba9d16231fe9f7d67e0530e720530d91a88ad73 (diff)
downloadedk2-0fd142464fc5b0fcb8b7fdfac379c1054ec81654.tar.gz
edk2-0fd142464fc5b0fcb8b7fdfac379c1054ec81654.tar.bz2
edk2-0fd142464fc5b0fcb8b7fdfac379c1054ec81654.zip
OvmfPkg/XenBusDxe: Add Grant Table functions.
There are used to grant access of pages to other Xen domains. This code originaly comes from the Xen Project, and more precisely from MiniOS. Change in V4: - Add license to GrantTable.h Change in V3: - Add a comment about the use of the BAR of the device. Change in V2: - Adding locks - Redo the file header - Add functions comment - Add license Signed-off-by: Steven Smith <sos22@cam.ac.uk> Signed-off-by: Grzegorz Milos <gm281@cam.ac.uk> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Acked-by: Jordan Justen <jordan.l.justen@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16264 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'OvmfPkg/XenBusDxe/XenBusDxe.c')
-rw-r--r--OvmfPkg/XenBusDxe/XenBusDxe.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/OvmfPkg/XenBusDxe/XenBusDxe.c b/OvmfPkg/XenBusDxe/XenBusDxe.c
index 776d896368..edeb20ef38 100644
--- a/OvmfPkg/XenBusDxe/XenBusDxe.c
+++ b/OvmfPkg/XenBusDxe/XenBusDxe.c
@@ -30,6 +30,7 @@
#include "XenBusDxe.h"
#include "XenHypercall.h"
+#include "GrantTable.h"
///
@@ -282,6 +283,8 @@ XenBusDxeDriverBindingStart (
EFI_STATUS Status;
XENBUS_DEVICE *Dev;
EFI_PCI_IO_PROTOCOL *PciIo;
+ EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *BarDesc;
+ UINT64 MmioAddr;
Status = gBS->OpenProtocol (
ControllerHandle,
@@ -313,6 +316,20 @@ 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 = XenHyperpageInit (Dev);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "XenBus: Unable to retrieve the hyperpage.\n"));
@@ -327,6 +344,8 @@ XenBusDxeDriverBindingStart (
goto ErrorAllocated;
}
+ XenGrantTableInit (Dev, MmioAddr);
+
Status = gBS->CreateEvent (EVT_SIGNAL_EXIT_BOOT_SERVICES, TPL_CALLBACK,
NotifyExitBoot,
(VOID*) Dev,
@@ -380,6 +399,7 @@ XenBusDxeDriverBindingStop (
XENBUS_DEVICE *Dev = mMyDevice;
gBS->CloseEvent (Dev->ExitBootEvent);
+ XenGrantTableDeinit (Dev);
gBS->CloseProtocol (ControllerHandle, &gEfiPciIoProtocolGuid,
This->DriverBindingHandle, ControllerHandle);