This patchs adds support to VirtFdtDxe for the Xen DT node which contains the base address of the Grant Table. This data is communicated to XenBusDxe using a XENIO_PROTOCOL instance.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel ard.biesheuvel@linaro.org --- .../ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c | 33 ++++++++++++++++++++++ .../ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf | 1 + 2 files changed, 34 insertions(+)
diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c index d002e668aa48..c49f726a7f10 100644 --- a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c +++ b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c @@ -27,6 +27,7 @@ #include <libfdt.h>
#include <Guid/Fdt.h> +#include <Protocol/XenIo.h>
#pragma pack (1) typedef struct { @@ -44,6 +45,7 @@ typedef enum { PropertyTypeUart, PropertyTypeTimer, PropertyTypePsci, + PropertyTypeXen, } PROPERTY_TYPE;
typedef struct { @@ -59,6 +61,7 @@ STATIC CONST PROPERTY CompatibleProperties[] = { { PropertyTypeTimer, "arm,armv7-timer" }, { PropertyTypeTimer, "arm,armv8-timer" }, { PropertyTypePsci, "arm,psci-0.2" }, + { PropertyTypeXen, "xen,xen" }, { PropertyTypeUnknown, "" } };
@@ -115,6 +118,7 @@ InitializeVirtFdtDxe ( CONST INTERRUPT_PROPERTY *InterruptProp; INT32 SecIntrNum, IntrNum, VirtIntrNum, HypIntrNum; CONST CHAR8 *PsciMethod; + XENIO_PROTOCOL *XenIo;
DeviceTreeBase = (VOID *)(UINTN)PcdGet64 (PcdDeviceTreeBaseAddress); ASSERT (DeviceTreeBase != NULL); @@ -271,6 +275,35 @@ InitializeVirtFdtDxe ( } break;
+ case PropertyTypeXen: + ASSERT (Len == 16); + + // + // Retrieve the reg base from this node and add it to a + // XENIO_PROTOCOL instance installed on a new handle. + // + XenIo = AllocateZeroPool (sizeof *XenIo); + ASSERT (XenIo != NULL); + XenIo->GrantTableAddress = fdt64_to_cpu (((UINT64 *)RegProp)[0]); + + Handle = NULL; + Status = gBS->InstallProtocolInterface (&Handle, + &gXenIoProtocolGuid, EFI_NATIVE_INTERFACE, + XenIo); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "%a: Failed to install the XENIO_PROTOCOL " + "protocol on a new handle (Status == %r)\n", + __FUNCTION__, Status)); + FreePool (XenIo); + break; + } + Status = gBS->ConnectController (Handle, NULL, NULL, TRUE); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "%a: Failed to invoke ConnectController () on " + "XENIO_PROTOCOL instance (Status == %r)\n", + __FUNCTION__, Status)); + } + default: break; } diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf index 1c9dd20580c4..16b5873d9451 100644 --- a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf +++ b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf @@ -57,6 +57,7 @@
[Protocols] gEfiDevicePathProtocolGuid + gXenIoProtocolGuid
[Depex] TRUE