+++ /dev/null
-/** @file\r
-* High memory node enumeration DXE driver for ARM Virtual Machines\r
-*\r
-* Copyright (c) 2015-2016, Linaro Ltd. All rights reserved.\r
-*\r
-* This program and the accompanying materials are licensed and made available\r
-* under the terms and conditions of the BSD License which accompanies this\r
-* distribution. The full text of the license may be found at\r
-* http://opensource.org/licenses/bsd-license.php\r
-*\r
-* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR\r
-* IMPLIED.\r
-*\r
-**/\r
-\r
-#include <Library/BaseLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/DxeServicesTableLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-\r
-#include <Protocol/FdtClient.h>\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-InitializeHighMemDxe (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
- )\r
-{\r
- FDT_CLIENT_PROTOCOL *FdtClient;\r
- EFI_STATUS Status, FindNodeStatus;\r
- INT32 Node;\r
- CONST UINT32 *Reg;\r
- UINT32 RegSize;\r
- UINTN AddressCells, SizeCells;\r
- UINT64 CurBase;\r
- UINT64 CurSize;\r
-\r
- Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL,\r
- (VOID **)&FdtClient);\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- //\r
- // Check for memory node and add the memory spaces except the lowest one\r
- //\r
- for (FindNodeStatus = FdtClient->FindMemoryNodeReg (FdtClient, &Node,\r
- (CONST VOID **) &Reg, &AddressCells,\r
- &SizeCells, &RegSize);\r
- !EFI_ERROR (FindNodeStatus);\r
- FindNodeStatus = FdtClient->FindNextMemoryNodeReg (FdtClient, Node,\r
- &Node, (CONST VOID **) &Reg, &AddressCells,\r
- &SizeCells, &RegSize)) {\r
- ASSERT (AddressCells <= 2);\r
- ASSERT (SizeCells <= 2);\r
-\r
- while (RegSize > 0) {\r
- CurBase = SwapBytes32 (*Reg++);\r
- if (AddressCells > 1) {\r
- CurBase = (CurBase << 32) | SwapBytes32 (*Reg++);\r
- }\r
- CurSize = SwapBytes32 (*Reg++);\r
- if (SizeCells > 1) {\r
- CurSize = (CurSize << 32) | SwapBytes32 (*Reg++);\r
- }\r
- RegSize -= (AddressCells + SizeCells) * sizeof (UINT32);\r
-\r
- if (PcdGet64 (PcdSystemMemoryBase) != CurBase) {\r
- Status = gDS->AddMemorySpace (EfiGcdMemoryTypeSystemMemory, CurBase,\r
- CurSize, EFI_MEMORY_WB);\r
-\r
- if (EFI_ERROR (Status)) {\r
- DEBUG ((EFI_D_ERROR,\r
- "%a: Failed to add System RAM @ 0x%lx - 0x%lx (%r)\n",\r
- __FUNCTION__, CurBase, CurBase + CurSize - 1, Status));\r
- continue;\r
- }\r
-\r
- Status = gDS->SetMemorySpaceAttributes (CurBase, CurSize,\r
- EFI_MEMORY_WB);\r
-\r
- if (EFI_ERROR (Status)) {\r
- DEBUG ((EFI_D_ERROR,\r
- "%a: Failed to set System RAM @ 0x%lx - 0x%lx attribute (%r)\n",\r
- __FUNCTION__, CurBase, CurBase + CurSize - 1, Status));\r
- } else {\r
- DEBUG ((EFI_D_INFO, "%a: Add System RAM @ 0x%lx - 0x%lx\n",\r
- __FUNCTION__, CurBase, CurBase + CurSize - 1));\r
- }\r
- }\r
- }\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r