]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: scan memory space map and populate FWDT (32-bit fields only)
authorjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 31 Jul 2012 18:18:01 +0000 (18:18 +0000)
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 31 Jul 2012 18:18:01 +0000 (18:18 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
[jordan.l.justen@intel.com: minor cleanup]
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13574 6f19259b-4bc3-4df7-8a09-765794883524

OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf
OvmfPkg/AcpiPlatformDxe/Qemu.c

index b43b8ac403f6a3ecd50a4a2bbefbf539cdf3de0e..04eb495cac8e71020da98b5ad2c75331afc1d7d5 100644 (file)
@@ -48,6 +48,7 @@
   QemuFwCfgLib\r
   MemoryAllocationLib\r
   BaseLib\r
+  DxeServicesTableLib\r
 \r
 [Protocols]\r
   gEfiAcpiTableProtocolGuid                     # PROTOCOL ALWAYS_CONSUMED\r
index 70887339054cdd5688c0e9eb5512b8f0bf9a1fac..051449d72a539bf023a53dde407b27f10b6138e4 100644 (file)
@@ -16,6 +16,7 @@
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/QemuFwCfgLib.h>\r
+#include <Library/DxeServicesTableLib.h>\r
 \r
 \r
 BOOLEAN\r
@@ -121,7 +122,92 @@ PopulateFwData(
   OUT  FIRMWARE_DATA *FwData\r
   )\r
 {\r
-  return EFI_SUCCESS;\r
+  EFI_STATUS                      Status;\r
+  UINTN                           NumDesc;\r
+  EFI_GCD_MEMORY_SPACE_DESCRIPTOR *AllDesc;\r
+\r
+  Status = gDS->GetMemorySpaceMap (&NumDesc, &AllDesc);\r
+  if (Status == EFI_SUCCESS) {\r
+    UINT64 NonMmio32MaxExclTop;\r
+    UINT64 Mmio32MinBase;\r
+    UINT64 Mmio32MaxExclTop;\r
+    UINTN CurDesc;\r
+\r
+    Status = EFI_UNSUPPORTED;\r
+\r
+    NonMmio32MaxExclTop = 0;\r
+    Mmio32MinBase = BASE_4GB;\r
+    Mmio32MaxExclTop = 0;\r
+\r
+    for (CurDesc = 0; CurDesc < NumDesc; ++CurDesc) {\r
+      CONST EFI_GCD_MEMORY_SPACE_DESCRIPTOR *Desc;\r
+      UINT64 ExclTop;\r
+\r
+      Desc = &AllDesc[CurDesc];\r
+      ExclTop = Desc->BaseAddress + Desc->Length;\r
+\r
+      if (ExclTop <= BASE_4GB) {\r
+        switch (Desc->GcdMemoryType) {\r
+          case EfiGcdMemoryTypeNonExistent:\r
+            break;\r
+\r
+          case EfiGcdMemoryTypeReserved:\r
+          case EfiGcdMemoryTypeSystemMemory:\r
+            if (NonMmio32MaxExclTop < ExclTop) {\r
+              NonMmio32MaxExclTop = ExclTop;\r
+            }\r
+            break;\r
+\r
+          case EfiGcdMemoryTypeMemoryMappedIo:\r
+            if (Mmio32MinBase > Desc->BaseAddress) {\r
+              Mmio32MinBase = Desc->BaseAddress;\r
+            }\r
+            if (Mmio32MaxExclTop < ExclTop) {\r
+              Mmio32MaxExclTop = ExclTop;\r
+            }\r
+            break;\r
+\r
+          default:\r
+            ASSERT(0);\r
+        }\r
+      }\r
+    }\r
+\r
+    if (Mmio32MinBase < NonMmio32MaxExclTop) {\r
+      Mmio32MinBase = NonMmio32MaxExclTop;\r
+    }\r
+\r
+    if (Mmio32MinBase < Mmio32MaxExclTop) {\r
+      FwData->PciWindow32.Base   = Mmio32MinBase;\r
+      FwData->PciWindow32.End    = Mmio32MaxExclTop - 1;\r
+      FwData->PciWindow32.Length = Mmio32MaxExclTop - Mmio32MinBase;\r
+\r
+      FwData->PciWindow64.Base   = 0;\r
+      FwData->PciWindow64.End    = 0;\r
+      FwData->PciWindow64.Length = 0;\r
+\r
+      Status = EFI_SUCCESS;\r
+    }\r
+\r
+    FreePool (AllDesc);\r
+  }\r
+\r
+  DEBUG ((\r
+    DEBUG_INFO,\r
+    "ACPI PciWindow32: Base=0x%08lx End=0x%08lx Length=0x%08lx\n",\r
+    FwData->PciWindow32.Base,\r
+    FwData->PciWindow32.End,\r
+    FwData->PciWindow32.Length\r
+    ));\r
+  DEBUG ((\r
+    DEBUG_INFO,\r
+    "ACPI PciWindow64: Base=0x%08lx End=0x%08lx Length=0x%08lx\n",\r
+    FwData->PciWindow64.Base,\r
+    FwData->PciWindow64.End,\r
+    FwData->PciWindow64.Length\r
+    ));\r
+\r
+  return Status;\r
 }\r
 \r
 \r