\r
**/\r
\r
+#include <Guid/MemoryTypeInformation.h>\r
#include "UefiPayloadEntry.h"\r
\r
STATIC UINT32 mTopOfLowerUsableDram = 0;\r
\r
+EFI_MEMORY_TYPE_INFORMATION mDefaultMemoryTypeInformation[] = {\r
+ { EfiACPIReclaimMemory, FixedPcdGet32 (PcdMemoryTypeEfiACPIReclaimMemory) },\r
+ { EfiACPIMemoryNVS, FixedPcdGet32 (PcdMemoryTypeEfiACPIMemoryNVS) },\r
+ { EfiReservedMemoryType, FixedPcdGet32 (PcdMemoryTypeEfiReservedMemoryType) },\r
+ { EfiRuntimeServicesData, FixedPcdGet32 (PcdMemoryTypeEfiRuntimeServicesData) },\r
+ { EfiRuntimeServicesCode, FixedPcdGet32 (PcdMemoryTypeEfiRuntimeServicesCode) },\r
+ { EfiMaxMemoryType, 0 }\r
+};\r
+\r
+/**\r
+ Function to reserve memory below 4GB for EDKII Modules.\r
+\r
+ This causes the DXE to dispatch everything under 4GB and allows Operating\r
+ System's that require EFI_LOADED_IMAGE to be under 4GB to start.\r
+ e.g. Xen hypervisor used in Qubes.\r
+**/\r
+VOID\r
+ForceModulesBelow4G (\r
+ VOID\r
+ )\r
+{\r
+ DEBUG ((DEBUG_INFO, "Building hob to restrict memory resorces to below 4G.\n"));\r
+\r
+ //\r
+ // Create Memory Type Information HOB\r
+ //\r
+ BuildGuidDataHob (\r
+ &gEfiMemoryTypeInformationGuid,\r
+ mDefaultMemoryTypeInformation,\r
+ sizeof (mDefaultMemoryTypeInformation)\r
+ );\r
+}\r
+\r
/**\r
Callback function to build resource descriptor HOB\r
\r
// Build other HOBs required by DXE\r
BuildGenericHob ();\r
\r
+ // Create a HOB to make resources for EDKII modules below 4G\r
+ if (!FixedPcdGetBool (PcdDispatchModuleAbove4GMemory)) {\r
+ ForceModulesBelow4G ();\r
+ }\r
+\r
// Load the DXE Core\r
Status = LoadDxeCore (&DxeCoreEntryPoint);\r
ASSERT_EFI_ERROR (Status);\r
gUefiPayloadPkgTokenSpaceGuid.PcdPayloadFdMemSize\r
gUefiPayloadPkgTokenSpaceGuid.PcdBootloaderParameter\r
gUefiPayloadPkgTokenSpaceGuid.PcdSystemMemoryUefiRegionSize\r
+ gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS\r
+ gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory\r
+ gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiReservedMemoryType\r
+ gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData\r
+ gUefiPayloadPkgTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode\r
\r
gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack ## SOMETIMES_CONSUMES\r
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy ## SOMETIMES_CONSUMES\r
gEfiMdeModulePkgTokenSpaceGuid.PcdImageProtectionPolicy ## SOMETIMES_CONSUMES\r
\r
+ gUefiPayloadPkgTokenSpaceGuid.PcdDispatchModuleAbove4GMemory\r
+\r
\r
gUefiPayloadPkgTokenSpaceGuid.PcdPcdDriverFile|{ 0x57, 0x72, 0xcf, 0x80, 0xab, 0x87, 0xf9, 0x47, 0xa3, 0xfe, 0xD5, 0x0B, 0x76, 0xd8, 0x95, 0x41 }|VOID*|0x00000018\r
\r
+# Above 4G Memory\r
+gUefiPayloadPkgTokenSpaceGuid.PcdDispatchModuleAbove4GMemory|TRUE|BOOLEAN|0x00000019\r
+\r
## FFS filename to find the default variable initial data file.\r
# @Prompt FFS Name of variable initial data file\r
gUefiPayloadPkgTokenSpaceGuid.PcdNvsDataFile |{ 0x1a, 0xf1, 0xb1, 0xae, 0x42, 0xcc, 0xcf, 0x4e, 0xac, 0x60, 0xdb, 0xab, 0xf6, 0xca, 0x69, 0xe6 }|VOID*|0x00000025\r
DEFINE UNIVERSAL_PAYLOAD = FALSE\r
DEFINE SECURITY_STUB_ENABLE = TRUE\r
DEFINE SMM_SUPPORT = FALSE\r
+ DEFINE ABOVE_4G_MEMORY = TRUE\r
#\r
# SBL: UEFI payload for Slim Bootloader\r
# COREBOOT: UEFI payload for coreboot\r
gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask | 0x1\r
!endif\r
\r
+ gUefiPayloadPkgTokenSpaceGuid.PcdDispatchModuleAbove4GMemory|$(ABOVE_4G_MEMORY)\r
+\r
[PcdsPatchableInModule.X64]\r
gPcAtChipsetPkgTokenSpaceGuid.PcdRtcIndexRegister|$(RTC_INDEX_REGISTER)\r
gPcAtChipsetPkgTokenSpaceGuid.PcdRtcTargetRegister|$(RTC_TARGET_REGISTER)\r