3 * Copyright (c) 2011-2021, Arm Limited. All rights reserved.<BR>
5 * SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include <Library/UefiBootServicesTableLib.h>
10 #include <Library/BaseMemoryLib.h>
11 #include <Library/HobLib.h>
12 #include <Library/DebugLib.h>
13 #include <Library/MemoryAllocationLib.h>
15 #include <Guid/ArmMpCoreInfo.h>
17 ARM_PROCESSOR_TABLE mArmProcessorTableTemplate
= {
19 EFI_ARM_PROCESSOR_TABLE_SIGNATURE
,
21 EFI_ARM_PROCESSOR_TABLE_REVISION
,
22 EFI_ARM_PROCESSOR_TABLE_OEM_ID
,
23 EFI_ARM_PROCESSOR_TABLE_OEM_TABLE_ID
,
24 EFI_ARM_PROCESSOR_TABLE_OEM_REVISION
,
25 EFI_ARM_PROCESSOR_TABLE_CREATOR_ID
,
26 EFI_ARM_PROCESSOR_TABLE_CREATOR_REVISION
,
29 }, // ARM Processor table header
30 0, // Number of entries in ARM processor Table
31 NULL
// ARM Processor Table
34 /** Publish ARM Processor Data table in UEFI SYSTEM Table.
35 * @param HobStart Pointer to the beginning of the HOB List from PEI.
37 * Description : This function iterates through HOB list and finds ARM processor Table Entry HOB.
38 * If the ARM processor Table Entry HOB is found, the HOB data is copied to run-time memory
39 * and a pointer is assigned to it in ARM processor table. Then the ARM processor table is
40 * installed in EFI configuration table.
44 PublishArmProcessorTable (
48 EFI_PEI_HOB_POINTERS Hob
;
50 Hob
.Raw
= GetHobList ();
52 // Iterate through the HOBs and find if there is ARM PROCESSOR ENTRY HOB
53 for ( ; !END_OF_HOB_LIST (Hob
); Hob
.Raw
= GET_NEXT_HOB (Hob
)) {
54 // Check for Correct HOB type
55 if ((GET_HOB_TYPE (Hob
)) == EFI_HOB_TYPE_GUID_EXTENSION
) {
56 // Check for correct GUID type
57 if (CompareGuid (&(Hob
.Guid
->Name
), &gArmMpCoreInfoGuid
)) {
58 ARM_PROCESSOR_TABLE
*ArmProcessorTable
;
61 // Allocate Runtime memory for ARM processor table
62 ArmProcessorTable
= (ARM_PROCESSOR_TABLE
*)AllocateRuntimePool (sizeof (ARM_PROCESSOR_TABLE
));
64 // Check if the memory allocation is successful or not
65 ASSERT (NULL
!= ArmProcessorTable
);
67 // Set ARM processor table to default values
68 CopyMem (ArmProcessorTable
, &mArmProcessorTableTemplate
, sizeof (ARM_PROCESSOR_TABLE
));
70 // Fill in Length fields of ARM processor table
71 ArmProcessorTable
->Header
.Length
= sizeof (ARM_PROCESSOR_TABLE
);
72 ArmProcessorTable
->Header
.DataLen
= GET_GUID_HOB_DATA_SIZE (Hob
);
74 // Fill in Identifier(ARM processor table GUID)
75 ArmProcessorTable
->Header
.Identifier
= gArmMpCoreInfoGuid
;
77 // Set Number of ARM core entries in the Table
78 ArmProcessorTable
->NumberOfEntries
= GET_GUID_HOB_DATA_SIZE (Hob
)/sizeof (ARM_CORE_INFO
);
80 // Allocate runtime memory for ARM processor Table entries
81 ArmProcessorTable
->ArmCpus
= (ARM_CORE_INFO
*)AllocateRuntimePool (
82 ArmProcessorTable
->NumberOfEntries
* sizeof (ARM_CORE_INFO
)
85 // Check if the memory allocation is successful or not
86 ASSERT (NULL
!= ArmProcessorTable
->ArmCpus
);
88 // Copy ARM Processor Table data from HOB list to newly allocated memory
89 CopyMem (ArmProcessorTable
->ArmCpus
, GET_GUID_HOB_DATA (Hob
), ArmProcessorTable
->Header
.DataLen
);
91 // Install the ARM Processor table into EFI system configuration table
92 Status
= gBS
->InstallConfigurationTable (&gArmMpCoreInfoGuid
, ArmProcessorTable
);
94 ASSERT_EFI_ERROR (Status
);