3 * Copyright (c) 2011-2014, ARM Limited. All rights reserved.
5 * This program and the accompanying materials
6 * are licensed and made available under the terms and conditions of the BSD License
7 * which accompanies this distribution. The full text of the license may be found at
8 * http://opensource.org/licenses/bsd-license.php
10 * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include <Library/UefiBootServicesTableLib.h>
16 #include <Library/BaseMemoryLib.h>
17 #include <Library/HobLib.h>
18 #include <Library/DebugLib.h>
19 #include <Library/MemoryAllocationLib.h>
21 #include <Guid/ArmMpCoreInfo.h>
23 ARM_PROCESSOR_TABLE mArmProcessorTableTemplate
= {
25 EFI_ARM_PROCESSOR_TABLE_SIGNATURE
,
27 EFI_ARM_PROCESSOR_TABLE_REVISION
,
28 EFI_ARM_PROCESSOR_TABLE_OEM_ID
,
29 EFI_ARM_PROCESSOR_TABLE_OEM_TABLE_ID
,
30 EFI_ARM_PROCESSOR_TABLE_OEM_REVISION
,
31 EFI_ARM_PROCESSOR_TABLE_CREATOR_ID
,
32 EFI_ARM_PROCESSOR_TABLE_CREATOR_REVISION
,
35 }, //ARM Processor table header
36 0, // Number of entries in ARM processor Table
37 NULL
// ARM Processor Table
40 /** Publish ARM Processor Data table in UEFI SYSTEM Table.
41 * @param: HobStart Pointer to the beginning of the HOB List from PEI.
43 * Description : This function iterates through HOB list and finds ARM processor Table Entry HOB.
44 * If the ARM processor Table Entry HOB is found, the HOB data is copied to run-time memory
45 * and a pointer is assigned to it in ARM processor table. Then the ARM processor table is
46 * installed in EFI configuration table.
50 PublishArmProcessorTable (
54 EFI_PEI_HOB_POINTERS Hob
;
56 Hob
.Raw
= GetHobList ();
58 // Iterate through the HOBs and find if there is ARM PROCESSOR ENTRY HOB
59 for (; !END_OF_HOB_LIST(Hob
); Hob
.Raw
= GET_NEXT_HOB(Hob
)) {
60 // Check for Correct HOB type
61 if ((GET_HOB_TYPE (Hob
)) == EFI_HOB_TYPE_GUID_EXTENSION
) {
62 // Check for correct GUID type
63 if (CompareGuid(&(Hob
.Guid
->Name
), &gArmMpCoreInfoGuid
)) {
64 ARM_PROCESSOR_TABLE
*ArmProcessorTable
;
67 // Allocate Runtime memory for ARM processor table
68 ArmProcessorTable
= (ARM_PROCESSOR_TABLE
*)AllocateRuntimePool(sizeof(ARM_PROCESSOR_TABLE
));
70 // Check if the memory allocation is succesful or not
71 ASSERT(NULL
!= ArmProcessorTable
);
73 // Set ARM processor table to default values
74 CopyMem(ArmProcessorTable
,&mArmProcessorTableTemplate
,sizeof(ARM_PROCESSOR_TABLE
));
76 // Fill in Length fields of ARM processor table
77 ArmProcessorTable
->Header
.Length
= sizeof(ARM_PROCESSOR_TABLE
);
78 ArmProcessorTable
->Header
.DataLen
= GET_GUID_HOB_DATA_SIZE(Hob
);
80 // Fill in Identifier(ARM processor table GUID)
81 ArmProcessorTable
->Header
.Identifier
= gArmMpCoreInfoGuid
;
83 // Set Number of ARM core entries in the Table
84 ArmProcessorTable
->NumberOfEntries
= GET_GUID_HOB_DATA_SIZE(Hob
)/sizeof(ARM_CORE_INFO
);
86 // Allocate runtime memory for ARM processor Table entries
87 ArmProcessorTable
->ArmCpus
= (ARM_CORE_INFO
*)AllocateRuntimePool (
88 ArmProcessorTable
->NumberOfEntries
* sizeof(ARM_CORE_INFO
));
90 // Check if the memory allocation is succesful or not
91 ASSERT(NULL
!= ArmProcessorTable
->ArmCpus
);
93 // Copy ARM Processor Table data from HOB list to newly allocated memory
94 CopyMem(ArmProcessorTable
->ArmCpus
,GET_GUID_HOB_DATA(Hob
), ArmProcessorTable
->Header
.DataLen
);
96 // Install the ARM Processor table into EFI system configuration table
97 Status
= gBS
->InstallConfigurationTable (&gArmMpCoreInfoGuid
, ArmProcessorTable
);
99 ASSERT_EFI_ERROR (Status
);