Index: OvmfPkg/PlatformPei/Platform.c =================================================================== --- OvmfPkg/PlatformPei/Platform.c (revision 9332) +++ OvmfPkg/PlatformPei/Platform.c (working copy) @@ -67,6 +67,34 @@ VOID +AddRomMemoryBaseSizeHob ( + EFI_PHYSICAL_ADDRESS MemoryBase, + UINT64 MemorySize + ) +{ + STATIC EFI_RESOURCE_ATTRIBUTE_TYPE Attributes = + ( + EFI_RESOURCE_ATTRIBUTE_PRESENT | + EFI_RESOURCE_ATTRIBUTE_WRITE_PROTECTED | + EFI_RESOURCE_ATTRIBUTE_INITIALIZED | + EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE + ); + + BuildResourceDescriptorHob ( + EFI_RESOURCE_FIRMWARE_DEVICE, + Attributes, + MemoryBase, + MemorySize + ); + + DEBUG ( + (EFI_D_ERROR, "ROM HOB: at 0x%llx size 0x%llx\n", MemoryBase, MemorySize) + ); + +} + + +VOID AddIoMemoryRangeHob ( EFI_PHYSICAL_ADDRESS MemoryBase, EFI_PHYSICAL_ADDRESS MemoryLimit @@ -111,11 +139,33 @@ AddMemoryBaseSizeHob (MemoryBase, (UINT64)(MemoryLimit - MemoryBase)); } +#define ACPI_RSD_PTR SIGNATURE_64('R', 'S', 'D', ' ', 'P', 'T', 'R', ' ') +VOID * +FindAcpiRsdPtr ( + VOID + ) +{ + UINTN Address; + // + // First Search 0x0e0000 - 0x0fffff for RSD Ptr + // + for (Address = 0xe0000; Address < 0xfffff; Address += 0x10) { + if (*(UINT64 *)(Address) == ACPI_RSD_PTR) { + return (VOID *)Address; + } + } + return NULL; +} + + VOID MemMapInitialization ( ) { + EFI_PHYSICAL_ADDRESS RsdPtr; + EFI_PHYSICAL_ADDRESS AcpiTables; + // // Create Memory Type Information HOB // @@ -139,6 +189,20 @@ // Video memory + Legacy BIOS region // AddIoMemoryRangeHob (0x0A0000, 0x100000); + + + // + // Add ACPI memory, provided by VBox + // + RsdPtr = (EFI_PHYSICAL_ADDRESS)(UINTN)FindAcpiRsdPtr(); + ASSERT(RsdPtr != 0); + AcpiTables = (EFI_PHYSICAL_ADDRESS)*(UINT32*)((UINTN)RsdPtr + 16) & ~0xfff; + ASSERT(AcpiTables != 0); + + // Floating pointer page + AddRomMemoryBaseSizeHob(RsdPtr, 0x1000); + // ACPI tables 64 K + AddRomMemoryBaseSizeHob(AcpiTables, 0x10000); } @@ -214,4 +278,3 @@ return EFI_SUCCESS; } -