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
diff --git a/Nt32Pkg/WinNtAutoScanPei/WinNtAutoScan.c b/Nt32Pkg/WinNtAutoScanPei/WinNtAutoScan.c
index cba5d93..90a97b9 100644
--- a/Nt32Pkg/WinNtAutoScanPei/WinNtAutoScan.c
+++ b/Nt32Pkg/WinNtAutoScanPei/WinNtAutoScan.c
@@ -28,6 +28,10 @@
// The protocols, PPI and GUID defintions for this module
//
#include <Ppi/NtAutoscan.h>
+#include <Ppi/ReadOnlyVariable2.h>
+
+#include <Guid/MemoryTypeInformation.h>
+
//
// The Library classes this module consumes
//
@@ -36,6 +40,15 @@
#include <Library/HobLib.h>
#include <Library/PeiServicesLib.h>
+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 @@
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 @@
// 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 a639c6c..0971c0e 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