v3: adapted to renames Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <ler...@redhat.com> --- OvmfPkg/AcpiPlatformDxe/Qemu.c | 108 ++++++++++++++++++++++++++- OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf | 1 + 2 files changed, 108 insertions(+), 1 deletions(-) diff --git a/OvmfPkg/AcpiPlatformDxe/Qemu.c b/OvmfPkg/AcpiPlatformDxe/Qemu.c index 7088733..e872dd0 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 @@ -121,7 +122,112 @@ PopulateFwData( OUT FIRMWARE_DATA *FwData ) { - 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, + "PopulateFwData(): 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, + "PopulateFwData(): Mmio32MinBase=0x%08lx Mmio32MaxExclTop=0x%08lx" + " NonMmio32MaxExclTop=0x%08lx\n", + Mmio32MinBase, + Mmio32MaxExclTop, + NonMmio32MaxExclTop + )); + + if (Mmio32MinBase < NonMmio32MaxExclTop) { + Mmio32MinBase = NonMmio32MaxExclTop; + } + + if (Mmio32MinBase < Mmio32MaxExclTop) { + FwData->PciWindow32.Base = Mmio32MinBase; + FwData->PciWindow32.End = Mmio32MaxExclTop - 1; + FwData->PciWindow32.Length = Mmio32MaxExclTop - Mmio32MinBase; + + DEBUG (( + DEBUG_INFO, + "PopulateFwData(): PciWindow32.Base=0x%08lx PciWindow32.End=0x%08lx" + " PciWindow32.Length=0x%08lx\n", + FwData->PciWindow32.Base, + FwData->PciWindow32.End, + FwData->PciWindow32.Length + )); + + FwData->PciWindow64.Base = 0; + FwData->PciWindow64.End = 0; + FwData->PciWindow64.Length = 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 edk2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-devel