56 EFI_RESOURCE_SYSTEM_MEMORY,
57 EFI_RESOURCE_ATTRIBUTE_PRESENT |
58 EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
59 EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
60 EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |
61 EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |
62 EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE |
63 EFI_RESOURCE_ATTRIBUTE_TESTED,
95 IN UINT64 SystemMemorySize
100 SystemMemoryBase + SystemMemorySize
124 Prop = fdt_getprop (Fdt, Node, Name, &Len);
129 if (Len !=
sizeof (*Prop)) {
130 return -FDT_ERR_BADNCELLS;
133 Val = fdt32_to_cpu (*Prop);
134 if (Val > FDT_MAX_NCELLS) {
135 return -FDT_ERR_BADNCELLS;
157 CONST INT32 *RegProp;
164 INT32 NumAddrCells, NumSizeCells;
166 NumRsv = fdt_num_mem_rsv (FdtPointer);
169 for (i = 0; i < NumRsv; i++) {
170 if (fdt_get_mem_rsv (FdtPointer, i, &Addr, &Size) != 0) {
182 Node = fdt_subnode_offset (FdtPointer, 0,
"reserved-memory");
184 NumAddrCells =
GetNumCells (FdtPointer, Node,
"#address-cells");
185 if (NumAddrCells <= 0) {
189 NumSizeCells =
GetNumCells (FdtPointer, Node,
"#size-cells");
190 if (NumSizeCells <= 0) {
194 fdt_for_each_subnode (SubNode, FdtPointer, Node) {
195 RegProp = fdt_getprop (FdtPointer, SubNode,
"reg", &Len);
197 if ((RegProp != 0) && (Len == ((NumAddrCells + NumSizeCells) *
sizeof (INT32)))) {
198 Addr = fdt32_to_cpu (RegProp[0]);
200 if (NumAddrCells > 1) {
201 Addr = (Addr << 32) | fdt32_to_cpu (RegProp[1]);
204 RegProp += NumAddrCells;
205 Size = fdt32_to_cpu (RegProp[0]);
207 if (NumSizeCells > 1) {
208 Size = (Size << 32) | fdt32_to_cpu (RegProp[1]);
213 "%a: Adding Reserved Memory Addr = 0x%llx, Size = 0x%llx\n",
219 if (fdt_getprop (FdtPointer, SubNode,
"no-map", &Len)) {
249 CONST UINT64 *RegProp;
251 UINT64 CurBase, CurSize;
256 FirmwareContext =
NULL;
259 if (FirmwareContext ==
NULL) {
260 DEBUG ((DEBUG_ERROR,
"%a: Firmware Context is NULL\n", __func__));
261 return EFI_UNSUPPORTED;
264 FdtPointer = (VOID *)FirmwareContext->FlattenedDeviceTree;
265 if (FdtPointer ==
NULL) {
266 DEBUG ((DEBUG_ERROR,
"%a: Invalid FDT pointer\n", __func__));
267 return EFI_UNSUPPORTED;
271 for (Prev = 0; ; Prev = Node) {
272 Node = fdt_next_node (FdtPointer, Prev,
NULL);
278 Type = fdt_getprop (FdtPointer, Node,
"device_type", &Len);
279 if (Type && (
AsciiStrnCmp (Type,
"memory", Len) == 0)) {
282 RegProp = fdt_getprop (FdtPointer, Node,
"reg", &Len);
283 if ((RegProp != 0) && (Len == (2 *
sizeof (UINT64)))) {
289 "%a: System RAM @ 0x%lx - 0x%lx\n",
292 CurBase + CurSize - 1
302 "%a: Failed to parse FDT memory node\n",
312 ASSERT ((RiscVGetSupervisorAddressTranslationRegister () & SATP64_MODE) == (SATP_MODE_OFF << SATP64_MODE_SHIFT));
VOID EFIAPI BuildResourceDescriptorHob(IN EFI_RESOURCE_TYPE ResourceType, IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute, IN EFI_PHYSICAL_ADDRESS PhysicalStart, IN UINT64 NumberOfBytes)
VOID EFIAPI BuildMemoryAllocationHob(IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN EFI_MEMORY_TYPE MemoryType)
UINT64 EFIAPI ReadUnaligned64(IN CONST UINT64 *Buffer)
INTN EFIAPI AsciiStrnCmp(IN CONST CHAR8 *FirstString, IN CONST CHAR8 *SecondString, IN UINTN Length)
VOID EFIAPI GetFirmwareContextPointer(IN OUT EFI_RISCV_FIRMWARE_CONTEXT **FirmwareContextPtr)
#define DEBUG(Expression)
STATIC VOID AddReservedMemoryMap(IN VOID *FdtPointer)
STATIC INT32 GetNumCells(IN VOID *Fdt, IN INT32 Node, IN CONST CHAR8 *Name)
STATIC VOID AddMemoryRangeHob(IN EFI_PHYSICAL_ADDRESS MemoryBase, IN EFI_PHYSICAL_ADDRESS MemoryLimit)
VOID BuildMemoryTypeInformationHob(VOID)
EFI_STATUS MemoryPeimInitialization(VOID)
STATIC VOID InitializeRamRegions(IN EFI_PHYSICAL_ADDRESS SystemMemoryBase, IN UINT64 SystemMemorySize)
STATIC VOID AddMemoryBaseSizeHob(IN EFI_PHYSICAL_ADDRESS MemoryBase, IN UINT64 MemorySize)
UINT64 EFI_PHYSICAL_ADDRESS