From 57b3102955693be2d3e44575b1d98c13a8a535e7 Mon Sep 17 00:00:00 2001 From: mdkinney Date: Mon, 14 Jun 2010 23:29:06 +0000 Subject: [PATCH] Update NT32 to produce the gEfiMemoryTypeInformation HOB git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10582 6f19259b-4bc3-4df7-8a09-765794883524 --- Nt32Pkg/WinNtAutoScanPei/WinNtAutoScan.c | 58 ++++++++++++++++++- Nt32Pkg/WinNtAutoScanPei/WinNtAutoScanPei.inf | 8 ++- 2 files changed, 63 insertions(+), 3 deletions(-) diff --git a/Nt32Pkg/WinNtAutoScanPei/WinNtAutoScan.c b/Nt32Pkg/WinNtAutoScanPei/WinNtAutoScan.c index cba5d936bd..90a97b9767 100644 --- a/Nt32Pkg/WinNtAutoScanPei/WinNtAutoScan.c +++ b/Nt32Pkg/WinNtAutoScanPei/WinNtAutoScan.c @@ -28,6 +28,10 @@ Revision History // The protocols, PPI and GUID defintions for this module // #include +#include + +#include + // // The Library classes this module consumes // @@ -36,6 +40,15 @@ Revision History #include #include +EFI_MEMORY_TYPE_INFORMATION mDefaultMemoryTypeInformation[] = { + { EfiReservedMemoryType, 0x0004 }, + { EfiRuntimeServicesCode, 0x0040 }, + { EfiRuntimeServicesData, 0x0040 }, + { EfiBootServicesCode, 0x0300 }, + { EfiBootServicesData, 0x1000 }, + { EfiMaxMemoryType, 0 } +}; + EFI_STATUS EFIAPI PeimInitializeWinNtAutoScan ( @@ -63,6 +76,9 @@ Returns: EFI_PHYSICAL_ADDRESS MemoryBase; UINTN Index; EFI_RESOURCE_ATTRIBUTE_TYPE Attributes; + EFI_PEI_READ_ONLY_VARIABLE2_PPI *Variable; + UINTN DataSize; + EFI_MEMORY_TYPE_INFORMATION MemoryData [EfiMaxMemoryType + 1]; DEBUG ((EFI_D_ERROR, "NT 32 Autoscan PEIM Loaded\n")); @@ -116,6 +132,46 @@ Returns: // Build the CPU hob with 36-bit addressing and 16-bits of IO space. // BuildCpuHob (36, 16); - + + // + // Build GUIDed Hob that contains the Memory Type Information array + // + Status = PeiServicesLocatePpi ( + &gEfiPeiReadOnlyVariable2PpiGuid, + 0, + NULL, + (VOID **)&Variable + ); + ASSERT_EFI_ERROR (Status); + + DataSize = sizeof (MemoryData); + Status = Variable->GetVariable ( + Variable, + EFI_MEMORY_TYPE_INFORMATION_VARIABLE_NAME, + &gEfiMemoryTypeInformationGuid, + NULL, + &DataSize, + &MemoryData + ); + if (EFI_ERROR (Status)) { + // + // Create Memory Type Information HOB + // + BuildGuidDataHob ( + &gEfiMemoryTypeInformationGuid, + mDefaultMemoryTypeInformation, + sizeof(mDefaultMemoryTypeInformation) + ); + } else { + // + // Create Memory Type Information HOB + // + BuildGuidDataHob ( + &gEfiMemoryTypeInformationGuid, + MemoryData, + DataSize + ); + } + return Status; } diff --git a/Nt32Pkg/WinNtAutoScanPei/WinNtAutoScanPei.inf b/Nt32Pkg/WinNtAutoScanPei/WinNtAutoScanPei.inf index a639c6c1aa..0971c0ea29 100644 --- a/Nt32Pkg/WinNtAutoScanPei/WinNtAutoScanPei.inf +++ b/Nt32Pkg/WinNtAutoScanPei/WinNtAutoScanPei.inf @@ -46,6 +46,10 @@ [Ppis] gPeiNtAutoScanPpiGuid # PPI ALWAYS_CONSUMED + gEfiPeiReadOnlyVariable2PpiGuid # PPI ALWAYS_CONSUMED -[depex] - gPeiNtAutoScanPpiGuid AND gEfiPeiMasterBootModePpiGuid +[Guids] + gEfiMemoryTypeInformationGuid + +[Depex] + gPeiNtAutoScanPpiGuid AND gEfiPeiMasterBootModePpiGuid AND gEfiPeiReadOnlyVariable2PpiGuid -- 2.39.2