Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <[email protected]>
---
OvmfPkg/AcpiPlatformDxe/Qemu.c | 107 ++++++++++++++++++++++++++-
OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf | 1 +
2 files changed, 107 insertions(+), 1 deletions(-)
diff --git a/OvmfPkg/AcpiPlatformDxe/Qemu.c b/OvmfPkg/AcpiPlatformDxe/Qemu.c
index 2d3fa0e..0fda85f 100644
--- a/OvmfPkg/AcpiPlatformDxe/Qemu.c
+++ b/OvmfPkg/AcpiPlatformDxe/Qemu.c
@@ -16,6 +16,7 @@
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/QemuFwCfgLib.h>
+#include <Library/DxeServicesTableLib.h>
BOOLEAN
@@ -117,7 +118,111 @@ PopulateBfld(
OUT BFLD *Bfld
)
{
- return EFI_SUCCESS;
+ EFI_STATUS Status;
+ UINTN NumDesc;
+ EFI_GCD_MEMORY_SPACE_DESCRIPTOR *Desc;
+
+ Status = gDS->GetMemorySpaceMap (&NumDesc, &Desc);
+ if (Status == EFI_SUCCESS) {
+ UINT64 NonMmio32MaxExclTop;
+ UINT64 Mmio32MinBase;
+ UINT64 Mmio32MaxExclTop;
+ UINTN CurDesc;
+
+ Status = EFI_UNSUPPORTED;
+
+ NonMmio32MaxExclTop = 0;
+ Mmio32MinBase = BASE_4GB;
+ Mmio32MaxExclTop = 0;
+
+ for (CurDesc = 0; CurDesc < NumDesc; ++CurDesc) {
+ STATIC CONST CHAR8 * CONST MemoryType[EfiGcdMemoryTypeMaximum] = {
+ "nonexistent",
+ "reserved",
+ "system",
+ "mmio"
+ };
+
+ CONST EFI_GCD_MEMORY_SPACE_DESCRIPTOR *D;
+ UINT64 ExclTop;
+
+ D = &Desc[CurDesc];
+ ExclTop = D->BaseAddress + D->Length;
+
+ DEBUG ((
+ DEBUG_INFO,
+ "PopulateBfld(): base=0x%016lx length=0x%016lx top=0x%016lx"
+ " type=%a\n",
+ (UINT64) D->BaseAddress,
+ D->Length,
+ ExclTop,
+ MemoryType[D->GcdMemoryType]
+ ));
+
+ if (ExclTop <= BASE_4GB) {
+ switch (D->GcdMemoryType) {
+ case EfiGcdMemoryTypeNonExistent:
+ break;
+
+ case EfiGcdMemoryTypeReserved:
+ case EfiGcdMemoryTypeSystemMemory:
+ if (NonMmio32MaxExclTop < ExclTop) {
+ NonMmio32MaxExclTop = ExclTop;
+ }
+ break;
+
+ case EfiGcdMemoryTypeMemoryMappedIo:
+ if (Mmio32MinBase > D->BaseAddress) {
+ Mmio32MinBase = D->BaseAddress;
+ }
+ if (Mmio32MaxExclTop < ExclTop) {
+ Mmio32MaxExclTop = ExclTop;
+ }
+ break;
+
+ default:
+ ASSERT(0);
+ }
+ }
+ }
+
+ DEBUG ((
+ DEBUG_INFO,
+ "PopulateBfld(): Mmio32MinBase=0x%08lx Mmio32MaxExclTop=0x%08lx"
+ " NonMmio32MaxExclTop=0x%08lx\n",
+ Mmio32MinBase,
+ Mmio32MaxExclTop,
+ NonMmio32MaxExclTop
+ ));
+
+ if (Mmio32MinBase < NonMmio32MaxExclTop) {
+ Mmio32MinBase = NonMmio32MaxExclTop;
+ }
+
+ if (Mmio32MinBase < Mmio32MaxExclTop) {
+ Bfld->P0S = Mmio32MinBase;
+ Bfld->P0E = Mmio32MaxExclTop - 1;
+ Bfld->P0L = Mmio32MaxExclTop - Mmio32MinBase;
+
+ DEBUG ((
+ DEBUG_INFO,
+ "PopulateBfld(): P0S=0x%08lx P0E=0x%08lx P0L=0x%08lx\n",
+ Bfld->P0S,
+ Bfld->P0E,
+ Bfld->P0L
+ ));
+
+ Bfld->P1S = 0;
+ Bfld->P1E = 0;
+ Bfld->P1L = 0;
+
+ Status = EFI_SUCCESS;
+ }
+
+ FreePool (Desc);
+ }
+
+ return Status;
}
diff --git a/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf
b/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf
index b43b8ac..04eb495 100644
--- a/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf
+++ b/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf
@@ -48,6 +48,7 @@
QemuFwCfgLib
MemoryAllocationLib
BaseLib
+ DxeServicesTableLib
[Protocols]
gEfiAcpiTableProtocolGuid # PROTOCOL ALWAYS_CONSUMED
--
1.7.1
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel