]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPkg/Drivers/CpuDxe/CpuMpCore.c
ArmPkg: Apply uncrustify changes
[mirror_edk2.git] / ArmPkg / Drivers / CpuDxe / CpuMpCore.c
CommitLineData
44788bae 1/** @file\r
2*\r
ea61e597 3* Copyright (c) 2011-2021, Arm Limited. All rights reserved.<BR>\r
44788bae 4*\r
4059386c 5* SPDX-License-Identifier: BSD-2-Clause-Patent\r
44788bae 6*\r
7**/\r
8\r
9#include <Library/UefiBootServicesTableLib.h>\r
10#include <Library/BaseMemoryLib.h>\r
11#include <Library/HobLib.h>\r
12#include <Library/DebugLib.h>\r
13#include <Library/MemoryAllocationLib.h>\r
14\r
15#include <Guid/ArmMpCoreInfo.h>\r
16\r
429309e0 17ARM_PROCESSOR_TABLE mArmProcessorTableTemplate = {\r
44788bae 18 {\r
19 EFI_ARM_PROCESSOR_TABLE_SIGNATURE,\r
20 0,\r
21 EFI_ARM_PROCESSOR_TABLE_REVISION,\r
22 EFI_ARM_PROCESSOR_TABLE_OEM_ID,\r
23 EFI_ARM_PROCESSOR_TABLE_OEM_TABLE_ID,\r
24 EFI_ARM_PROCESSOR_TABLE_OEM_REVISION,\r
25 EFI_ARM_PROCESSOR_TABLE_CREATOR_ID,\r
26 EFI_ARM_PROCESSOR_TABLE_CREATOR_REVISION,\r
b0fdce95 27 { 0 },\r
44788bae 28 0\r
429309e0 29 }, // ARM Processor table header\r
44788bae 30 0, // Number of entries in ARM processor Table\r
31 NULL // ARM Processor Table\r
32};\r
33\r
34/** Publish ARM Processor Data table in UEFI SYSTEM Table.\r
ea61e597 35 * @param HobStart Pointer to the beginning of the HOB List from PEI.\r
44788bae 36 *\r
37 * Description : This function iterates through HOB list and finds ARM processor Table Entry HOB.\r
38 * If the ARM processor Table Entry HOB is found, the HOB data is copied to run-time memory\r
39 * and a pointer is assigned to it in ARM processor table. Then the ARM processor table is\r
40 * installed in EFI configuration table.\r
41**/\r
42VOID\r
43EFIAPI\r
44PublishArmProcessorTable (\r
45 VOID\r
46 )\r
47{\r
429309e0 48 EFI_PEI_HOB_POINTERS Hob;\r
44788bae 49\r
50 Hob.Raw = GetHobList ();\r
51\r
52 // Iterate through the HOBs and find if there is ARM PROCESSOR ENTRY HOB\r
429309e0 53 for ( ; !END_OF_HOB_LIST (Hob); Hob.Raw = GET_NEXT_HOB (Hob)) {\r
44788bae 54 // Check for Correct HOB type\r
55 if ((GET_HOB_TYPE (Hob)) == EFI_HOB_TYPE_GUID_EXTENSION) {\r
56 // Check for correct GUID type\r
429309e0
MK
57 if (CompareGuid (&(Hob.Guid->Name), &gArmMpCoreInfoGuid)) {\r
58 ARM_PROCESSOR_TABLE *ArmProcessorTable;\r
59 EFI_STATUS Status;\r
44788bae 60\r
61 // Allocate Runtime memory for ARM processor table\r
429309e0 62 ArmProcessorTable = (ARM_PROCESSOR_TABLE *)AllocateRuntimePool (sizeof (ARM_PROCESSOR_TABLE));\r
44788bae 63\r
ff5fef14 64 // Check if the memory allocation is successful or not\r
429309e0 65 ASSERT (NULL != ArmProcessorTable);\r
44788bae 66\r
67 // Set ARM processor table to default values\r
429309e0 68 CopyMem (ArmProcessorTable, &mArmProcessorTableTemplate, sizeof (ARM_PROCESSOR_TABLE));\r
44788bae 69\r
70 // Fill in Length fields of ARM processor table\r
429309e0
MK
71 ArmProcessorTable->Header.Length = sizeof (ARM_PROCESSOR_TABLE);\r
72 ArmProcessorTable->Header.DataLen = GET_GUID_HOB_DATA_SIZE (Hob);\r
44788bae 73\r
74 // Fill in Identifier(ARM processor table GUID)\r
75 ArmProcessorTable->Header.Identifier = gArmMpCoreInfoGuid;\r
76\r
77 // Set Number of ARM core entries in the Table\r
429309e0 78 ArmProcessorTable->NumberOfEntries = GET_GUID_HOB_DATA_SIZE (Hob)/sizeof (ARM_CORE_INFO);\r
44788bae 79\r
80 // Allocate runtime memory for ARM processor Table entries\r
429309e0
MK
81 ArmProcessorTable->ArmCpus = (ARM_CORE_INFO *)AllocateRuntimePool (\r
82 ArmProcessorTable->NumberOfEntries * sizeof (ARM_CORE_INFO)\r
83 );\r
44788bae 84\r
ff5fef14 85 // Check if the memory allocation is successful or not\r
429309e0 86 ASSERT (NULL != ArmProcessorTable->ArmCpus);\r
44788bae 87\r
88 // Copy ARM Processor Table data from HOB list to newly allocated memory\r
429309e0 89 CopyMem (ArmProcessorTable->ArmCpus, GET_GUID_HOB_DATA (Hob), ArmProcessorTable->Header.DataLen);\r
44788bae 90\r
91 // Install the ARM Processor table into EFI system configuration table\r
92 Status = gBS->InstallConfigurationTable (&gArmMpCoreInfoGuid, ArmProcessorTable);\r
93\r
94 ASSERT_EFI_ERROR (Status);\r
95 }\r
96 }\r
97 }\r
98}\r