diff mbox

[edk2,01/12] ArmVirtualizationPkg: VirtFdtDxe: forward FwCfg addresses from DTB to PCDs

Message ID 1417130367-17777-2-git-send-email-lersek@redhat.com
State New
Headers show

Commit Message

Laszlo Ersek Nov. 27, 2014, 11:19 p.m. UTC
Qemu's firmware configuration interface consists of two MMIO registers, a
16-bit selector and an 8-bit data register. Parse their addresses and
verify their sizes from the DTB, and expose them to the rest of DXE by
storing them in dynamic PCDs.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf |  2 ++
 ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c   | 26 ++++++++++++++++++++++++++
 ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec  |  3 +++
 ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc |  3 +++
 4 files changed, 34 insertions(+)

Comments

Laszlo Ersek Dec. 5, 2014, 5:39 p.m. UTC | #1
On 11/28/14 00:19, Laszlo Ersek wrote:
> Qemu's firmware configuration interface consists of two MMIO registers, a
> 16-bit selector and an 8-bit data register. Parse their addresses and
> verify their sizes from the DTB, and expose them to the rest of DXE by
> storing them in dynamic PCDs.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
>  ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf |  2 ++
>  ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c   | 26 ++++++++++++++++++++++++++
>  ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec  |  3 +++
>  ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc |  3 +++
>  4 files changed, 34 insertions(+)
> 
> diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf
> index 1c9dd20..daafe6c 100644
> --- a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf
> +++ b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf
> @@ -47,6 +47,8 @@
>  [Pcd]
>    gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeBaseAddress
>    gArmVirtualizationTokenSpaceGuid.PcdArmPsciMethod
> +  gArmVirtualizationTokenSpaceGuid.PcdFwCfgSelectorAddress
> +  gArmVirtualizationTokenSpaceGuid.PcdFwCfgDataAddress
>    gArmTokenSpaceGuid.PcdGicDistributorBase
>    gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase
>    gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum
> diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c
> index d002e66..f1b5283 100644
> --- a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c
> +++ b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c
> @@ -44,6 +44,7 @@ typedef enum {
>    PropertyTypeUart,
>    PropertyTypeTimer,
>    PropertyTypePsci,
> +  PropertyTypeFwCfg,
>  } PROPERTY_TYPE;
>  
>  typedef struct {
> @@ -59,6 +60,7 @@ STATIC CONST PROPERTY CompatibleProperties[] = {
>    { PropertyTypeTimer,   "arm,armv7-timer"     },
>    { PropertyTypeTimer,   "arm,armv8-timer"     },
>    { PropertyTypePsci,    "arm,psci-0.2"        },
> +  { PropertyTypeFwCfg,   "fw-cfg,mmio"         },

The part of the DTB that exposes this device was slightly changed. Since
there were no review comments thus far, I'll post a v2 of this edk2 series.

Thanks
Laszlo
diff mbox

Patch

diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf
index 1c9dd20..daafe6c 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf
@@ -47,6 +47,8 @@ 
 [Pcd]
   gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeBaseAddress
   gArmVirtualizationTokenSpaceGuid.PcdArmPsciMethod
+  gArmVirtualizationTokenSpaceGuid.PcdFwCfgSelectorAddress
+  gArmVirtualizationTokenSpaceGuid.PcdFwCfgDataAddress
   gArmTokenSpaceGuid.PcdGicDistributorBase
   gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase
   gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum
diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c
index d002e66..f1b5283 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c
@@ -44,6 +44,7 @@  typedef enum {
   PropertyTypeUart,
   PropertyTypeTimer,
   PropertyTypePsci,
+  PropertyTypeFwCfg,
 } PROPERTY_TYPE;
 
 typedef struct {
@@ -59,6 +60,7 @@  STATIC CONST PROPERTY CompatibleProperties[] = {
   { PropertyTypeTimer,   "arm,armv7-timer"     },
   { PropertyTypeTimer,   "arm,armv8-timer"     },
   { PropertyTypePsci,    "arm,psci-0.2"        },
+  { PropertyTypeFwCfg,   "fw-cfg,mmio"         },
   { PropertyTypeUnknown, ""                    }
 };
 
@@ -115,6 +117,10 @@  InitializeVirtFdtDxe (
   CONST INTERRUPT_PROPERTY       *InterruptProp;
   INT32                          SecIntrNum, IntrNum, VirtIntrNum, HypIntrNum;
   CONST CHAR8                    *PsciMethod;
+  UINT64                         FwCfgSelectorAddress;
+  UINT64                         FwCfgSelectorSize;
+  UINT64                         FwCfgDataAddress;
+  UINT64                         FwCfgDataSize;
 
   DeviceTreeBase = (VOID *)(UINTN)PcdGet64 (PcdDeviceTreeBaseAddress);
   ASSERT (DeviceTreeBase != NULL);
@@ -160,6 +166,26 @@  InitializeVirtFdtDxe (
       (PropType == PropertyTypePsci));
 
     switch (PropType) {
+    case PropertyTypeFwCfg:
+      ASSERT (Len == 4 * sizeof (UINT64));
+
+      FwCfgSelectorAddress = fdt64_to_cpu (((UINT64 *)RegProp)[0]);
+      FwCfgSelectorSize    = fdt64_to_cpu (((UINT64 *)RegProp)[1]);
+      FwCfgDataAddress     = fdt64_to_cpu (((UINT64 *)RegProp)[2]);
+      FwCfgDataSize        = fdt64_to_cpu (((UINT64 *)RegProp)[3]);
+
+      ASSERT (FwCfgSelectorSize == 2);
+      ASSERT (FwCfgDataSize     == 1);
+      ASSERT (FwCfgSelectorAddress <= MAX_UINTN - FwCfgSelectorSize + 1);
+      ASSERT (FwCfgDataAddress     <= MAX_UINTN - FwCfgDataSize     + 1);
+
+      PcdSet64 (PcdFwCfgSelectorAddress, FwCfgSelectorAddress);
+      PcdSet64 (PcdFwCfgDataAddress,     FwCfgDataAddress);
+
+      DEBUG ((EFI_D_INFO, "Found FwCfg @ 0x%Lx/0x%Lx\n", FwCfgSelectorAddress,
+        FwCfgDataAddress));
+      break;
+
     case PropertyTypeVirtio:
       ASSERT (Len == 16);
       //
diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec
index b581add..9941154 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec
@@ -53,3 +53,6 @@ 
   # PcdArmPsciMethod == 2 : use SMC
   #
   gArmVirtualizationTokenSpaceGuid.PcdArmPsciMethod|0|UINT32|0x00000003
+
+  gArmVirtualizationTokenSpaceGuid.PcdFwCfgSelectorAddress|0x0|UINT64|0x00000004
+  gArmVirtualizationTokenSpaceGuid.PcdFwCfgDataAddress|0x0|UINT64|0x00000005
diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
index 61689b7..1f3ddea 100644
--- a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
@@ -173,6 +173,9 @@ 
 
   gArmVirtualizationTokenSpaceGuid.PcdArmPsciMethod|0
 
+  gArmVirtualizationTokenSpaceGuid.PcdFwCfgSelectorAddress|0x0
+  gArmVirtualizationTokenSpaceGuid.PcdFwCfgDataAddress|0x0
+
 ################################################################################
 #
 # Components Section - list of all EDK II Modules needed by this Platform