+/** @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 <Library/UefiBootServicesTableLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/HobLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+\r
+#include <Guid/ArmMpCoreInfo.h>\r
+\r
+ARM_PROCESSOR_TABLE mArmProcessorTableTemplate = {\r
+ {\r
+ EFI_ARM_PROCESSOR_TABLE_SIGNATURE,\r
+ 0,\r
+ EFI_ARM_PROCESSOR_TABLE_REVISION,\r
+ EFI_ARM_PROCESSOR_TABLE_OEM_ID,\r
+ EFI_ARM_PROCESSOR_TABLE_OEM_TABLE_ID,\r
+ EFI_ARM_PROCESSOR_TABLE_OEM_REVISION,\r
+ EFI_ARM_PROCESSOR_TABLE_CREATOR_ID,\r
+ EFI_ARM_PROCESSOR_TABLE_CREATOR_REVISION,\r
+ 0,\r
+ 0\r
+ }, //ARM Processor table header\r
+ 0, // Number of entries in ARM processor Table\r
+ NULL // ARM Processor Table\r
+};\r
+\r
+/** Publish ARM Processor Data table in UEFI SYSTEM Table.\r
+ * @param: HobStart Pointer to the beginning of the HOB List from PEI.\r
+ *\r
+ * Description : This function iterates through HOB list and finds ARM processor Table Entry HOB.\r
+ * If the ARM processor Table Entry HOB is found, the HOB data is copied to run-time memory\r
+ * and a pointer is assigned to it in ARM processor table. Then the ARM processor table is\r
+ * installed in EFI configuration table.\r
+**/\r
+VOID\r
+EFIAPI\r
+PublishArmProcessorTable (\r
+ VOID\r
+ )\r
+{\r
+ EFI_PEI_HOB_POINTERS Hob;\r
+\r
+ Hob.Raw = GetHobList ();\r
+\r
+ // Iterate through the HOBs and find if there is ARM PROCESSOR ENTRY HOB\r
+ for (; !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) {\r
+ // Check for Correct HOB type\r
+ if ((GET_HOB_TYPE (Hob)) == EFI_HOB_TYPE_GUID_EXTENSION) {\r
+ // Check for correct GUID type\r
+ if (CompareGuid(&(Hob.Guid->Name), &gArmMpCoreInfoGuid)) {\r
+ ARM_PROCESSOR_TABLE *ArmProcessorTable;\r
+ EFI_STATUS Status;\r
+\r
+ // Allocate Runtime memory for ARM processor table\r
+ ArmProcessorTable = (ARM_PROCESSOR_TABLE*)AllocateRuntimePool(sizeof(ARM_PROCESSOR_TABLE));\r
+\r
+ // Check if the memory allocation is succesful or not\r
+ ASSERT(NULL != ArmProcessorTable);\r
+\r
+ // Set ARM processor table to default values\r
+ CopyMem(ArmProcessorTable,&mArmProcessorTableTemplate,sizeof(ARM_PROCESSOR_TABLE));\r
+\r
+ // Fill in Length fields of ARM processor table\r
+ ArmProcessorTable->Header.Length = sizeof(ARM_PROCESSOR_TABLE);\r
+ ArmProcessorTable->Header.DataLen = GET_GUID_HOB_DATA_SIZE(Hob);\r
+\r
+ // Fill in Identifier(ARM processor table GUID)\r
+ ArmProcessorTable->Header.Identifier = gArmMpCoreInfoGuid;\r
+\r
+ // Set Number of ARM core entries in the Table\r
+ ArmProcessorTable->NumberOfEntries = GET_GUID_HOB_DATA_SIZE(Hob)/sizeof(ARM_CORE_INFO);\r
+\r
+ // Allocate runtime memory for ARM processor Table entries\r
+ ArmProcessorTable->ArmCpus = (ARM_CORE_INFO*)AllocateRuntimePool (\r
+ ArmProcessorTable->NumberOfEntries * sizeof(ARM_CORE_INFO));\r
+\r
+ // Check if the memory allocation is succesful or not\r
+ ASSERT(NULL != ArmProcessorTable->ArmCpus);\r
+\r
+ // Copy ARM Processor Table data from HOB list to newly allocated memory\r
+ CopyMem(ArmProcessorTable->ArmCpus,GET_GUID_HOB_DATA(Hob), ArmProcessorTable->Header.DataLen);\r
+\r
+ // Install the ARM Processor table into EFI system configuration table\r
+ Status = gBS->InstallConfigurationTable (&gArmMpCoreInfoGuid, ArmProcessorTable);\r
+\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
+ }\r
+ }\r
+}\r