3 Copyright (c) 2011, ARM Limited. All rights reserved.
4 Copyright (c) 2022, Google LLC. All rights reserved.
6 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include <Library/ArmPlatformLib.h>
12 #include <Library/DebugLib.h>
13 #include <Library/HobLib.h>
14 #include <Library/PeimEntryPoint.h>
15 #include <Library/PeiServicesLib.h>
16 #include <Library/PcdLib.h>
17 #include <Guid/MemoryTypeInformation.h>
22 IN EFI_PHYSICAL_ADDRESS UefiMemoryBase
,
23 IN UINT64 UefiMemorySize
27 Build the memory type information HOB that describes how many pages of each
28 type to preallocate when initializing the GCD memory map.
32 BuildMemoryTypeInformationHob (
36 EFI_MEMORY_TYPE_INFORMATION Info
[10];
38 Info
[0].Type
= EfiACPIReclaimMemory
;
39 Info
[0].NumberOfPages
= FixedPcdGet32 (PcdMemoryTypeEfiACPIReclaimMemory
);
40 Info
[1].Type
= EfiACPIMemoryNVS
;
41 Info
[1].NumberOfPages
= FixedPcdGet32 (PcdMemoryTypeEfiACPIMemoryNVS
);
42 Info
[2].Type
= EfiReservedMemoryType
;
43 Info
[2].NumberOfPages
= FixedPcdGet32 (PcdMemoryTypeEfiReservedMemoryType
);
44 Info
[3].Type
= EfiRuntimeServicesData
;
45 Info
[3].NumberOfPages
= FixedPcdGet32 (PcdMemoryTypeEfiRuntimeServicesData
);
46 Info
[4].Type
= EfiRuntimeServicesCode
;
47 Info
[4].NumberOfPages
= FixedPcdGet32 (PcdMemoryTypeEfiRuntimeServicesCode
);
48 Info
[5].Type
= EfiBootServicesCode
;
49 Info
[5].NumberOfPages
= FixedPcdGet32 (PcdMemoryTypeEfiBootServicesCode
);
50 Info
[6].Type
= EfiBootServicesData
;
51 Info
[6].NumberOfPages
= FixedPcdGet32 (PcdMemoryTypeEfiBootServicesData
);
52 Info
[7].Type
= EfiLoaderCode
;
53 Info
[7].NumberOfPages
= FixedPcdGet32 (PcdMemoryTypeEfiLoaderCode
);
54 Info
[8].Type
= EfiLoaderData
;
55 Info
[8].NumberOfPages
= FixedPcdGet32 (PcdMemoryTypeEfiLoaderData
);
57 // Terminator for the list
58 Info
[9].Type
= EfiMaxMemoryType
;
59 Info
[9].NumberOfPages
= 0;
61 BuildGuidDataHob (&gEfiMemoryTypeInformationGuid
, &Info
, sizeof (Info
));
67 @param[in] FileHandle Handle of the file being invoked.
68 @param[in] PeiServices Describes the list of possible PEI Services.
70 @return EFI_SUCCESS unless the operation failed.
75 IN EFI_PEI_FILE_HANDLE FileHandle
,
76 IN CONST EFI_PEI_SERVICES
**PeiServices
82 ASSERT (FixedPcdGet64 (PcdSystemMemoryBase
) < (UINT64
)MAX_ALLOC_ADDRESS
);
85 // Put the permanent PEI memory in the first 128 MiB of DRAM so that
86 // it is covered by the statically configured ID map.
88 UefiMemoryBase
= (UINTN
)FixedPcdGet64 (PcdSystemMemoryBase
) + SIZE_128MB
89 - FixedPcdGet32 (PcdSystemMemoryUefiRegionSize
);
91 Status
= PeiServicesInstallPeiMemory (
93 FixedPcdGet32 (PcdSystemMemoryUefiRegionSize
)
95 ASSERT_EFI_ERROR (Status
);
99 FixedPcdGet32 (PcdSystemMemoryUefiRegionSize
)
101 ASSERT_EFI_ERROR (Status
);