]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Drivers/CpuDxe/CpuMpCore.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / ArmPkg / Drivers / CpuDxe / CpuMpCore.c
1 /** @file
2 *
3 * Copyright (c) 2011-2021, Arm Limited. All rights reserved.<BR>
4 *
5 * SPDX-License-Identifier: BSD-2-Clause-Patent
6 *
7 **/
8
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>
14
15 #include <Guid/ArmMpCoreInfo.h>
16
17 ARM_PROCESSOR_TABLE mArmProcessorTableTemplate = {
18 {
19 EFI_ARM_PROCESSOR_TABLE_SIGNATURE,
20 0,
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,
27 { 0 },
28 0
29 }, // ARM Processor table header
30 0, // Number of entries in ARM processor Table
31 NULL // ARM Processor Table
32 };
33
34 /** Publish ARM Processor Data table in UEFI SYSTEM Table.
35 * @param HobStart Pointer to the beginning of the HOB List from PEI.
36 *
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.
41 **/
42 VOID
43 EFIAPI
44 PublishArmProcessorTable (
45 VOID
46 )
47 {
48 EFI_PEI_HOB_POINTERS Hob;
49
50 Hob.Raw = GetHobList ();
51
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;
59 EFI_STATUS Status;
60
61 // Allocate Runtime memory for ARM processor table
62 ArmProcessorTable = (ARM_PROCESSOR_TABLE *)AllocateRuntimePool (sizeof (ARM_PROCESSOR_TABLE));
63
64 // Check if the memory allocation is successful or not
65 ASSERT (NULL != ArmProcessorTable);
66
67 // Set ARM processor table to default values
68 CopyMem (ArmProcessorTable, &mArmProcessorTableTemplate, sizeof (ARM_PROCESSOR_TABLE));
69
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);
73
74 // Fill in Identifier(ARM processor table GUID)
75 ArmProcessorTable->Header.Identifier = gArmMpCoreInfoGuid;
76
77 // Set Number of ARM core entries in the Table
78 ArmProcessorTable->NumberOfEntries = GET_GUID_HOB_DATA_SIZE (Hob)/sizeof (ARM_CORE_INFO);
79
80 // Allocate runtime memory for ARM processor Table entries
81 ArmProcessorTable->ArmCpus = (ARM_CORE_INFO *)AllocateRuntimePool (
82 ArmProcessorTable->NumberOfEntries * sizeof (ARM_CORE_INFO)
83 );
84
85 // Check if the memory allocation is successful or not
86 ASSERT (NULL != ArmProcessorTable->ArmCpus);
87
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);
90
91 // Install the ARM Processor table into EFI system configuration table
92 Status = gBS->InstallConfigurationTable (&gArmMpCoreInfoGuid, ArmProcessorTable);
93
94 ASSERT_EFI_ERROR (Status);
95 }
96 }
97 }
98 }