+++ /dev/null
-/** @file\r
-*\r
-* Copyright (c) 2011, ARM Limited. All rights reserved.\r
-* \r
-* This program and the accompanying materials \r
-* are licensed and made available under the terms and conditions of the BSD License \r
-* which accompanies this 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 IMPLIED. \r
-*\r
-**/\r
-\r
-//\r
-// The package level header files this module uses\r
-//\r
-#include <PiPei.h>\r
-\r
-//\r
-// The protocols, PPI and GUID defintions for this module\r
-//\r
-#include <Ppi/MasterBootMode.h>\r
-#include <Ppi/BootInRecoveryMode.h>\r
-#include <Guid/MemoryTypeInformation.h>\r
-//\r
-// The Library classes this module consumes\r
-//\r
-#include <Library/DebugLib.h>\r
-#include <Library/PeimEntryPoint.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/HobLib.h>\r
-#include <Library/PeiServicesLib.h>\r
-#include <Library/ArmLib.h>\r
-#include <Library/IoLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/ArmPlatformLib.h>\r
-\r
-VOID\r
-InitMmu (\r
- VOID\r
- )\r
-{\r
- ARM_MEMORY_REGION_DESCRIPTOR *MemoryTable;\r
- VOID *TranslationTableBase;\r
- UINTN TranslationTableSize;\r
-\r
- // Get Virtual Memory Map from the Platform Library\r
- ArmPlatformGetVirtualMemoryMap(&MemoryTable);\r
-\r
- //Note: Because we called PeiServicesInstallPeiMemory() before to call InitMmu() the MMU Page Table resides in\r
- // DRAM (even at the top of DRAM as it is the first permanent memory allocation)\r
- ArmConfigureMmu (MemoryTable, &TranslationTableBase, &TranslationTableSize);\r
-}\r
-\r
-// May want to put this into a library so you only need the PCD settings if you are using the feature?\r
-VOID\r
-BuildMemoryTypeInformationHob (\r
- VOID\r
- )\r
-{\r
- EFI_MEMORY_TYPE_INFORMATION Info[10];\r
-\r
- Info[0].Type = EfiACPIReclaimMemory;\r
- Info[0].NumberOfPages = PcdGet32 (PcdMemoryTypeEfiACPIReclaimMemory);\r
- Info[1].Type = EfiACPIMemoryNVS;\r
- Info[1].NumberOfPages = PcdGet32 (PcdMemoryTypeEfiACPIMemoryNVS);\r
- Info[2].Type = EfiReservedMemoryType;\r
- Info[2].NumberOfPages = PcdGet32 (PcdMemoryTypeEfiReservedMemoryType);\r
- Info[3].Type = EfiRuntimeServicesData;\r
- Info[3].NumberOfPages = PcdGet32 (PcdMemoryTypeEfiRuntimeServicesData);\r
- Info[4].Type = EfiRuntimeServicesCode;\r
- Info[4].NumberOfPages = PcdGet32 (PcdMemoryTypeEfiRuntimeServicesCode);\r
- Info[5].Type = EfiBootServicesCode;\r
- Info[5].NumberOfPages = PcdGet32 (PcdMemoryTypeEfiBootServicesCode);\r
- Info[6].Type = EfiBootServicesData;\r
- Info[6].NumberOfPages = PcdGet32 (PcdMemoryTypeEfiBootServicesData);\r
- Info[7].Type = EfiLoaderCode;\r
- Info[7].NumberOfPages = PcdGet32 (PcdMemoryTypeEfiLoaderCode);\r
- Info[8].Type = EfiLoaderData;\r
- Info[8].NumberOfPages = PcdGet32 (PcdMemoryTypeEfiLoaderData);\r
- \r
- // Terminator for the list\r
- Info[9].Type = EfiMaxMemoryType;\r
- Info[9].NumberOfPages = 0;\r
-\r
- BuildGuidDataHob (&gEfiMemoryTypeInformationGuid, &Info, sizeof (Info));\r
-}\r
-/*++\r
-\r
-Routine Description:\r
-\r
- \r
-\r
-Arguments:\r
-\r
- FileHandle - Handle of the file being invoked.\r
- PeiServices - Describes the list of possible PEI Services.\r
- \r
-Returns:\r
-\r
- Status - EFI_SUCCESS if the boot mode could be set\r
-\r
---*/\r
-EFI_STATUS\r
-EFIAPI\r
-InitializeMemory (\r
- IN EFI_PEI_FILE_HANDLE FileHandle,\r
- IN CONST EFI_PEI_SERVICES **PeiServices\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_RESOURCE_ATTRIBUTE_TYPE Attributes;\r
- ARM_SYSTEM_MEMORY_REGION_DESCRIPTOR* EfiMemoryMap;\r
- UINTN Index;\r
- UINTN SystemMemoryTop;\r
- UINTN UefiMemoryBase;\r
- UINTN UefiMemorySize;\r
-\r
- DEBUG ((EFI_D_ERROR, "Memory Init PEIM Loaded\n"));\r
-\r
- // Ensure PcdSystemMemorySize has been set\r
- ASSERT (FixedPcdGet32 (PcdSystemMemorySize) != 0);\r
-\r
- SystemMemoryTop = (UINTN)FixedPcdGet32 (PcdSystemMemoryBase) + (UINTN)FixedPcdGet32 (PcdSystemMemorySize);\r
-\r
- //\r
- // Initialize the System Memory (DRAM)\r
- //\r
- if (FeaturePcdGet(PcdStandalone)) {\r
- // In case of a standalone version, the DRAM is already initialized\r
- ArmPlatformInitializeSystemMemory();\r
- }\r
-\r
- //\r
- // Declare the UEFI memory to PEI\r
- //\r
- if (FeaturePcdGet(PcdStandalone)) {\r
- // In case of standalone UEFI, we set the UEFI memory region at the top of the DRAM\r
- UefiMemoryBase = SystemMemoryTop - FixedPcdGet32 (PcdSystemMemoryUefiRegionSize);\r
- } else {\r
- // In case of a non standalone UEFI, we set the UEFI memory below the Firmware Volume\r
- UefiMemoryBase = FixedPcdGet32 (PcdNormalFdBaseAddress) - FixedPcdGet32 (PcdSystemMemoryUefiRegionSize);\r
- }\r
- UefiMemorySize = FixedPcdGet32 (PcdSystemMemoryUefiRegionSize);\r
- Status = PeiServicesInstallPeiMemory (UefiMemoryBase,UefiMemorySize);\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- //\r
- // Now, the permanent memory has been installed, we can call AllocatePages()\r
- //\r
- Attributes = (\r
- EFI_RESOURCE_ATTRIBUTE_PRESENT |\r
- EFI_RESOURCE_ATTRIBUTE_INITIALIZED |\r
- EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |\r
- EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |\r
- EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |\r
- EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE |\r
- EFI_RESOURCE_ATTRIBUTE_TESTED\r
- );\r
-\r
- // If it is not a standalone build we must reserved the space above the base address of the firmware volume\r
- if (!FeaturePcdGet(PcdStandalone)) {\r
- // Check if firmware volume has not be copied at the top of DRAM then we must reserve the extra space\r
- // between the firmware and the top\r
- if (SystemMemoryTop != FixedPcdGet32 (PcdNormalFdBaseAddress) + FixedPcdGet32 (PcdNormalFdSize)) {\r
- BuildResourceDescriptorHob (\r
- EFI_RESOURCE_SYSTEM_MEMORY,\r
- Attributes & (~EFI_RESOURCE_ATTRIBUTE_TESTED),\r
- FixedPcdGet32 (PcdNormalFdBaseAddress) + FixedPcdGet32 (PcdNormalFdSize),\r
- SystemMemoryTop - (FixedPcdGet32 (PcdNormalFdBaseAddress) + FixedPcdGet32 (PcdNormalFdSize))\r
- );\r
- }\r
-\r
- // Reserved the memory space occupied by the firmware volume\r
- BuildResourceDescriptorHob (\r
- EFI_RESOURCE_SYSTEM_MEMORY,\r
- Attributes & (~EFI_RESOURCE_ATTRIBUTE_PRESENT),\r
- (UINT32)FixedPcdGet32 (PcdNormalFdBaseAddress),\r
- (UINT32)FixedPcdGet32 (PcdNormalFdSize)\r
- );\r
- }\r
-\r
- // Check there is no overlap between UEFI and Fix Address Regions\r
- ASSERT (FixedPcdGet32 (PcdSystemMemoryBase) + FixedPcdGet32 (PcdSystemMemoryFixRegionSize) <= UefiMemoryBase);\r
-\r
- // Reserved the UEFI Memory Region\r
- BuildResourceDescriptorHob (\r
- EFI_RESOURCE_SYSTEM_MEMORY,\r
- Attributes,\r
- UefiMemoryBase,\r
- UefiMemorySize\r
- );\r
-\r
- // Reserved the Fix Address Region\r
- BuildResourceDescriptorHob (\r
- EFI_RESOURCE_SYSTEM_MEMORY,\r
- Attributes,\r
- FixedPcdGet32 (PcdSystemMemoryBase),\r
- FixedPcdGet32 (PcdSystemMemoryFixRegionSize)\r
- );\r
-\r
- // Reserved the memory between UEFI and Fix Address regions\r
- if (FixedPcdGet32 (PcdSystemMemoryBase) + FixedPcdGet32 (PcdSystemMemoryFixRegionSize) != UefiMemoryBase) {\r
- BuildResourceDescriptorHob (\r
- EFI_RESOURCE_SYSTEM_MEMORY,\r
- Attributes & (~EFI_RESOURCE_ATTRIBUTE_TESTED),\r
- FixedPcdGet32 (PcdSystemMemoryBase) + FixedPcdGet32 (PcdSystemMemoryFixRegionSize),\r
- UefiMemoryBase - (FixedPcdGet32 (PcdSystemMemoryBase) + FixedPcdGet32 (PcdSystemMemoryFixRegionSize))\r
- );\r
- }\r
-\r
- // If a platform has system memory extensions, it can declare those in this function\r
- Status = ArmPlatformGetAdditionalSystemMemory (&EfiMemoryMap);\r
- if (!EFI_ERROR(Status)) {\r
- // Install the EFI Memory Map\r
- for (Index = 0; EfiMemoryMap[Index].ResourceAttribute != 0; Index++) {\r
- BuildResourceDescriptorHob (\r
- EFI_RESOURCE_SYSTEM_MEMORY,\r
- EfiMemoryMap[Index].ResourceAttribute,\r
- EfiMemoryMap[Index].PhysicalStart,\r
- EfiMemoryMap[Index].NumberOfBytes\r
- );\r
- }\r
- FreePool (EfiMemoryMap);\r
- }\r
-\r
- // Build Memory Allocation Hob\r
- InitMmu ();\r
-\r
- if (FeaturePcdGet (PcdPrePiProduceMemoryTypeInformationHob)) {\r
- // Optional feature that helps prevent EFI memory map fragmentation.\r
- BuildMemoryTypeInformationHob ();\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
+++ /dev/null
-#/** @file\r
-# \r
-# Copyright (c) 2011, ARM Ltd. All rights reserved.<BR>\r
-# This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this 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 IMPLIED.\r
-# \r
-#**/\r
-\r
-[Defines]\r
- INF_VERSION = 0x00010005\r
- BASE_NAME = MemoryInit\r
- FILE_GUID = c61ef796-b50d-4f98-9f78-4f6f79d800d5\r
- MODULE_TYPE = PEIM\r
- VERSION_STRING = 1.0\r
-\r
- ENTRY_POINT = InitializeMemory\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources]\r
- MemoryInit.c\r
-\r
-\r
-[Packages]\r
- MdePkg/MdePkg.dec\r
- MdeModulePkg/MdeModulePkg.dec\r
- EmbeddedPkg/EmbeddedPkg.dec\r
- ArmPkg/ArmPkg.dec\r
- ArmPlatformPkg/ArmPlatformPkg.dec\r
- \r
-[LibraryClasses]\r
- PeimEntryPoint\r
- DebugLib\r
- HobLib\r
- ArmLib\r
- ArmPlatformLib\r
-\r
-[Guids]\r
- gEfiMemoryTypeInformationGuid\r
-\r
-[Ppis]\r
-\r
-[FeaturePcd]\r
- gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob\r
- gArmPlatformTokenSpaceGuid.PcdStandalone\r
-\r
-[FixedPcd]\r
- gArmTokenSpaceGuid.PcdNormalFdBaseAddress\r
- gArmTokenSpaceGuid.PcdNormalFdSize\r
-\r
- gArmTokenSpaceGuid.PcdSystemMemoryBase\r
- gArmTokenSpaceGuid.PcdSystemMemorySize\r
- gArmPlatformTokenSpaceGuid.PcdSystemMemoryFixRegionSize\r
- gArmPlatformTokenSpaceGuid.PcdSystemMemoryUefiRegionSize\r
- \r
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory\r
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS\r
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiReservedMemoryType\r
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData\r
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode\r
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesCode\r
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesData\r
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderCode\r
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderData\r
- \r
-[depex]\r
- TRUE\r
--- /dev/null
+/** @file\r
+*\r
+* Copyright (c) 2011, ARM Limited. All rights reserved.\r
+*\r
+* This program and the accompanying materials\r
+* are licensed and made available under the terms and conditions of the BSD License\r
+* which accompanies this 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 IMPLIED.\r
+*\r
+**/\r
+\r
+#include <PiPei.h>\r
+\r
+#include <Library/ArmPlatformLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/HobLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/PcdLib.h>\r
+\r
+#include <Chipset/ArmV7.h>\r
+\r
+VOID\r
+BuildMemoryTypeInformationHob (\r
+ VOID\r
+ );\r
+\r
+VOID\r
+InitMmu (\r
+ VOID\r
+ )\r
+{\r
+ ARM_MEMORY_REGION_DESCRIPTOR *MemoryTable;\r
+ VOID *TranslationTableBase;\r
+ UINTN TranslationTableSize;\r
+\r
+ // Get Virtual Memory Map from the Platform Library\r
+ ArmPlatformGetVirtualMemoryMap(&MemoryTable);\r
+\r
+ //Note: Because we called PeiServicesInstallPeiMemory() before to call InitMmu() the MMU Page Table resides in\r
+ // DRAM (even at the top of DRAM as it is the first permanent memory allocation)\r
+ ArmConfigureMmu (MemoryTable, &TranslationTableBase, &TranslationTableSize);\r
+}\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+\r
+\r
+Arguments:\r
+\r
+ FileHandle - Handle of the file being invoked.\r
+ PeiServices - Describes the list of possible PEI Services.\r
+\r
+Returns:\r
+\r
+ Status - EFI_SUCCESS if the boot mode could be set\r
+\r
+--*/\r
+EFI_STATUS\r
+EFIAPI\r
+MemoryPeim (\r
+ IN EFI_PHYSICAL_ADDRESS UefiMemoryBase,\r
+ IN UINT64 UefiMemorySize\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_RESOURCE_ATTRIBUTE_TYPE Attributes;\r
+ ARM_SYSTEM_MEMORY_REGION_DESCRIPTOR* EfiMemoryMap;\r
+ UINTN Index;\r
+ EFI_PHYSICAL_ADDRESS SystemMemoryTop;\r
+\r
+ // Ensure PcdSystemMemorySize has been set\r
+ ASSERT (PcdGet32 (PcdSystemMemorySize) != 0);\r
+\r
+ SystemMemoryTop = (EFI_PHYSICAL_ADDRESS)((UINT32)PcdGet32 (PcdSystemMemoryBase) + (UINT32)PcdGet32 (PcdSystemMemorySize));\r
+\r
+ //\r
+ // Now, the permanent memory has been installed, we can call AllocatePages()\r
+ //\r
+ Attributes = (\r
+ EFI_RESOURCE_ATTRIBUTE_PRESENT |\r
+ EFI_RESOURCE_ATTRIBUTE_INITIALIZED |\r
+ EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |\r
+ EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |\r
+ EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |\r
+ EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE |\r
+ EFI_RESOURCE_ATTRIBUTE_TESTED\r
+ );\r
+\r
+ // If it is not a standalone build we must reserved the space above the base address of the firmware volume\r
+ if (!PcdGet32(PcdStandalone)) {\r
+ // Check if firmware volume has not be copied at the top of DRAM then we must reserve the extra space\r
+ // between the firmware and the top\r
+ if (SystemMemoryTop != PcdGet32 (PcdNormalFdBaseAddress) + PcdGet32 (PcdNormalFdSize)) {\r
+ BuildResourceDescriptorHob (\r
+ EFI_RESOURCE_SYSTEM_MEMORY,\r
+ Attributes & (~EFI_RESOURCE_ATTRIBUTE_TESTED),\r
+ PcdGet32 (PcdNormalFdBaseAddress) + PcdGet32 (PcdNormalFdSize),\r
+ SystemMemoryTop - (PcdGet32 (PcdNormalFdBaseAddress) + PcdGet32 (PcdNormalFdSize))\r
+ );\r
+ }\r
+\r
+ // Reserved the memory space occupied by the firmware volume\r
+ BuildResourceDescriptorHob (\r
+ EFI_RESOURCE_SYSTEM_MEMORY,\r
+ Attributes & (~EFI_RESOURCE_ATTRIBUTE_PRESENT),\r
+ (UINT32)PcdGet32 (PcdNormalFdBaseAddress),\r
+ (UINT32)PcdGet32 (PcdNormalFdSize)\r
+ );\r
+ }\r
+\r
+ // Check there is no overlap between UEFI and Fix Address Regions\r
+ ASSERT (PcdGet32 (PcdSystemMemoryBase) + PcdGet32 (PcdSystemMemoryFixRegionSize) <= UefiMemoryBase);\r
+\r
+ // Reserved the UEFI Memory Region\r
+ BuildResourceDescriptorHob (\r
+ EFI_RESOURCE_SYSTEM_MEMORY,\r
+ Attributes,\r
+ UefiMemoryBase,\r
+ UefiMemorySize\r
+ );\r
+\r
+ // Reserved the Fix Address Region\r
+ BuildResourceDescriptorHob (\r
+ EFI_RESOURCE_SYSTEM_MEMORY,\r
+ Attributes,\r
+ PcdGet32 (PcdSystemMemoryBase),\r
+ PcdGet32 (PcdSystemMemoryFixRegionSize)\r
+ );\r
+\r
+ // Reserved the memory between UEFI and Fix Address regions\r
+ if (PcdGet32 (PcdSystemMemoryBase) + PcdGet32 (PcdSystemMemoryFixRegionSize) != UefiMemoryBase) {\r
+ BuildResourceDescriptorHob (\r
+ EFI_RESOURCE_SYSTEM_MEMORY,\r
+ Attributes & (~EFI_RESOURCE_ATTRIBUTE_TESTED),\r
+ PcdGet32 (PcdSystemMemoryBase) + PcdGet32 (PcdSystemMemoryFixRegionSize),\r
+ UefiMemoryBase - (PcdGet32 (PcdSystemMemoryBase) + PcdGet32 (PcdSystemMemoryFixRegionSize))\r
+ );\r
+ }\r
+\r
+ // If a platform has system memory extensions, it can declare those in this function\r
+ Status = ArmPlatformGetAdditionalSystemMemory (&EfiMemoryMap);\r
+ if (!EFI_ERROR(Status)) {\r
+ // Install the EFI Memory Map\r
+ for (Index = 0; EfiMemoryMap[Index].ResourceAttribute != 0; Index++) {\r
+ BuildResourceDescriptorHob (\r
+ EFI_RESOURCE_SYSTEM_MEMORY,\r
+ EfiMemoryMap[Index].ResourceAttribute,\r
+ EfiMemoryMap[Index].PhysicalStart,\r
+ EfiMemoryMap[Index].NumberOfBytes\r
+ );\r
+ }\r
+ FreePool (EfiMemoryMap);\r
+ }\r
+\r
+ // Build Memory Allocation Hob\r
+ InitMmu ();\r
+\r
+ if (FeaturePcdGet (PcdPrePiProduceMemoryTypeInformationHob)) {\r
+ // Optional feature that helps prevent EFI memory map fragmentation.\r
+ BuildMemoryTypeInformationHob ();\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
--- /dev/null
+#/** @file
+#
+# Copyright (c) 2011, ARM Ltd. All rights reserved.<BR>
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#**/
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = ArmMemoryInitPeiLib
+ FILE_GUID = 55ddb6e0-70b5-11e0-b33e-0002a5d5c51b
+ MODULE_TYPE = SEC
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = PlatformPeiLib
+
+[Sources]
+ MemoryInitPeiLib.c
+
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ EmbeddedPkg/EmbeddedPkg.dec
+ ArmPkg/ArmPkg.dec
+ ArmPlatformPkg/ArmPlatformPkg.dec
+
+[LibraryClasses]
+ DebugLib
+ HobLib
+ ArmLib
+ ArmPlatformLib
+
+[Guids]
+ gEfiMemoryTypeInformationGuid
+
+[Ppis]
+
+[FeaturePcd]
+ gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob
+
+[FixedPcd]
+ gArmPlatformTokenSpaceGuid.PcdStandalone
+
+ gArmTokenSpaceGuid.PcdNormalFdBaseAddress
+ gArmTokenSpaceGuid.PcdNormalFdSize
+
+ gArmTokenSpaceGuid.PcdSystemMemoryBase
+ gArmTokenSpaceGuid.PcdSystemMemorySize
+ gArmPlatformTokenSpaceGuid.PcdSystemMemoryFixRegionSize
+ gArmPlatformTokenSpaceGuid.PcdSystemMemoryUefiRegionSize
+
+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory
+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS
+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiReservedMemoryType
+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData
+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode
+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesCode
+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesData
+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderCode
+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderData
+
+[depex]
+ TRUE
--- /dev/null
+/** @file\r
+*\r
+* Copyright (c) 2011, ARM Limited. All rights reserved.\r
+* \r
+* This program and the accompanying materials \r
+* are licensed and made available under the terms and conditions of the BSD License \r
+* which accompanies this 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 IMPLIED. \r
+*\r
+**/\r
+\r
+#include <PiPei.h>\r
+\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Ppi/MasterBootMode.h>\r
+#include <Ppi/BootInRecoveryMode.h>\r
+#include <Guid/MemoryTypeInformation.h>\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/ArmPlatformLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/HobLib.h>\r
+#include <Library/PeimEntryPoint.h>\r
+#include <Library/PeiServicesLib.h>\r
+#include <Library/PcdLib.h>\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+MemoryPeim (\r
+ IN EFI_PHYSICAL_ADDRESS UefiMemoryBase,\r
+ IN UINT64 UefiMemorySize\r
+ );\r
+\r
+// May want to put this into a library so you only need the PCD settings if you are using the feature?\r
+VOID\r
+BuildMemoryTypeInformationHob (\r
+ VOID\r
+ )\r
+{\r
+ EFI_MEMORY_TYPE_INFORMATION Info[10];\r
+\r
+ Info[0].Type = EfiACPIReclaimMemory;\r
+ Info[0].NumberOfPages = PcdGet32 (PcdMemoryTypeEfiACPIReclaimMemory);\r
+ Info[1].Type = EfiACPIMemoryNVS;\r
+ Info[1].NumberOfPages = PcdGet32 (PcdMemoryTypeEfiACPIMemoryNVS);\r
+ Info[2].Type = EfiReservedMemoryType;\r
+ Info[2].NumberOfPages = PcdGet32 (PcdMemoryTypeEfiReservedMemoryType);\r
+ Info[3].Type = EfiRuntimeServicesData;\r
+ Info[3].NumberOfPages = PcdGet32 (PcdMemoryTypeEfiRuntimeServicesData);\r
+ Info[4].Type = EfiRuntimeServicesCode;\r
+ Info[4].NumberOfPages = PcdGet32 (PcdMemoryTypeEfiRuntimeServicesCode);\r
+ Info[5].Type = EfiBootServicesCode;\r
+ Info[5].NumberOfPages = PcdGet32 (PcdMemoryTypeEfiBootServicesCode);\r
+ Info[6].Type = EfiBootServicesData;\r
+ Info[6].NumberOfPages = PcdGet32 (PcdMemoryTypeEfiBootServicesData);\r
+ Info[7].Type = EfiLoaderCode;\r
+ Info[7].NumberOfPages = PcdGet32 (PcdMemoryTypeEfiLoaderCode);\r
+ Info[8].Type = EfiLoaderData;\r
+ Info[8].NumberOfPages = PcdGet32 (PcdMemoryTypeEfiLoaderData);\r
+ \r
+ // Terminator for the list\r
+ Info[9].Type = EfiMaxMemoryType;\r
+ Info[9].NumberOfPages = 0;\r
+\r
+ BuildGuidDataHob (&gEfiMemoryTypeInformationGuid, &Info, sizeof (Info));\r
+}\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ \r
+\r
+Arguments:\r
+\r
+ FileHandle - Handle of the file being invoked.\r
+ PeiServices - Describes the list of possible PEI Services.\r
+ \r
+Returns:\r
+\r
+ Status - EFI_SUCCESS if the boot mode could be set\r
+\r
+--*/\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeMemory (\r
+ IN EFI_PEI_FILE_HANDLE FileHandle,\r
+ IN CONST EFI_PEI_SERVICES **PeiServices\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_RESOURCE_ATTRIBUTE_TYPE Attributes;\r
+ ARM_SYSTEM_MEMORY_REGION_DESCRIPTOR* EfiMemoryMap;\r
+ UINTN Index;\r
+ UINTN SystemMemoryTop;\r
+ UINTN UefiMemoryBase;\r
+ UINTN UefiMemorySize;\r
+\r
+ DEBUG ((EFI_D_ERROR, "Memory Init PEIM Loaded\n"));\r
+\r
+ // Ensure PcdSystemMemorySize has been set\r
+ ASSERT (FixedPcdGet32 (PcdSystemMemorySize) != 0);\r
+\r
+ SystemMemoryTop = (UINTN)FixedPcdGet32 (PcdSystemMemoryBase) + (UINTN)FixedPcdGet32 (PcdSystemMemorySize);\r
+\r
+ //\r
+ // Initialize the System Memory (DRAM)\r
+ //\r
+ if (FeaturePcdGet(PcdStandalone)) {\r
+ // In case of a standalone version, the DRAM is already initialized\r
+ ArmPlatformInitializeSystemMemory();\r
+ }\r
+\r
+ //\r
+ // Declare the UEFI memory to PEI\r
+ //\r
+ if (FeaturePcdGet(PcdStandalone)) {\r
+ // In case of standalone UEFI, we set the UEFI memory region at the top of the DRAM\r
+ UefiMemoryBase = SystemMemoryTop - FixedPcdGet32 (PcdSystemMemoryUefiRegionSize);\r
+ } else {\r
+ // In case of a non standalone UEFI, we set the UEFI memory below the Firmware Volume\r
+ UefiMemoryBase = FixedPcdGet32 (PcdNormalFdBaseAddress) - FixedPcdGet32 (PcdSystemMemoryUefiRegionSize);\r
+ }\r
+ Status = PeiServicesInstallPeiMemory (UefiMemoryBase,FixedPcdGet32 (PcdSystemMemoryUefiRegionSize));\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ // Initialize MMU and Memory HOBs (Resource Descriptor HOBs)\r
+ Status = MemoryPeim (UefiMemoryBase, FixedPcdGet32 (PcdSystemMemoryUefiRegionSize));\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return Status;\r
+}\r
--- /dev/null
+#/** @file\r
+# \r
+# Copyright (c) 2011, ARM Ltd. All rights reserved.<BR>\r
+# This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this 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 IMPLIED.\r
+# \r
+#**/\r
+\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = MemoryInit\r
+ FILE_GUID = c61ef796-b50d-4f98-9f78-4f6f79d800d5\r
+ MODULE_TYPE = PEIM\r
+ VERSION_STRING = 1.0\r
+\r
+ ENTRY_POINT = InitializeMemory\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC ARM\r
+#\r
+\r
+[Sources]\r
+ MemoryInitPeim.c\r
+ MemoryInitPeiLib.c\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+ MdeModulePkg/MdeModulePkg.dec\r
+ EmbeddedPkg/EmbeddedPkg.dec\r
+ ArmPkg/ArmPkg.dec\r
+ ArmPlatformPkg/ArmPlatformPkg.dec\r
+ \r
+[LibraryClasses]\r
+ PeimEntryPoint\r
+ DebugLib\r
+ HobLib\r
+ ArmLib\r
+ ArmPlatformLib\r
+\r
+[Guids]\r
+ gEfiMemoryTypeInformationGuid\r
+\r
+[FeaturePcd]\r
+ gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob\r
+ gArmPlatformTokenSpaceGuid.PcdStandalone\r
+\r
+[FixedPcd]\r
+ gArmTokenSpaceGuid.PcdNormalFdBaseAddress\r
+ gArmTokenSpaceGuid.PcdNormalFdSize\r
+\r
+ gArmTokenSpaceGuid.PcdSystemMemoryBase\r
+ gArmTokenSpaceGuid.PcdSystemMemorySize\r
+ gArmPlatformTokenSpaceGuid.PcdSystemMemoryFixRegionSize\r
+ gArmPlatformTokenSpaceGuid.PcdSystemMemoryUefiRegionSize\r
+ \r
+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory\r
+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS\r
+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiReservedMemoryType\r
+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData\r
+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode\r
+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesCode\r
+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesData\r
+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderCode\r
+ gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderData\r
+ \r
+[Depex]\r
+ TRUE\r