]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Drivers/CpuDxe/CpuMpCore.c
ArmPkg: Create MpCoreInfo PPI and HOB to describe CPU Cores on a MPCore platform
[mirror_edk2.git] / ArmPkg / Drivers / CpuDxe / CpuMpCore.c
1 /** @file
2 *
3 * Copyright (c) 2011, ARM Limited. All rights reserved.
4 *
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
9 *
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.
12 *
13 **/
14
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>
20
21 #include <Guid/ArmMpCoreInfo.h>
22
23 ARM_PROCESSOR_TABLE mArmProcessorTableTemplate = {
24 {
25 EFI_ARM_PROCESSOR_TABLE_SIGNATURE,
26 0,
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,
33 0,
34 0
35 }, //ARM Processor table header
36 0, // Number of entries in ARM processor Table
37 NULL // ARM Processor Table
38 };
39
40 /** Publish ARM Processor Data table in UEFI SYSTEM Table.
41 * @param: HobStart Pointer to the beginning of the HOB List from PEI.
42 *
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.
47 **/
48 VOID
49 EFIAPI
50 PublishArmProcessorTable (
51 VOID
52 )
53 {
54 EFI_PEI_HOB_POINTERS Hob;
55
56 Hob.Raw = GetHobList ();
57
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;
65 EFI_STATUS Status;
66
67 // Allocate Runtime memory for ARM processor table
68 ArmProcessorTable = (ARM_PROCESSOR_TABLE*)AllocateRuntimePool(sizeof(ARM_PROCESSOR_TABLE));
69
70 // Check if the memory allocation is succesful or not
71 ASSERT(NULL != ArmProcessorTable);
72
73 // Set ARM processor table to default values
74 CopyMem(ArmProcessorTable,&mArmProcessorTableTemplate,sizeof(ARM_PROCESSOR_TABLE));
75
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);
79
80 // Fill in Identifier(ARM processor table GUID)
81 ArmProcessorTable->Header.Identifier = gArmMpCoreInfoGuid;
82
83 // Set Number of ARM core entries in the Table
84 ArmProcessorTable->NumberOfEntries = GET_GUID_HOB_DATA_SIZE(Hob)/sizeof(ARM_CORE_INFO);
85
86 // Allocate runtime memory for ARM processor Table entries
87 ArmProcessorTable->ArmCpus = (ARM_CORE_INFO*)AllocateRuntimePool (
88 ArmProcessorTable->NumberOfEntries * sizeof(ARM_CORE_INFO));
89
90 // Check if the memory allocation is succesful or not
91 ASSERT(NULL != ArmProcessorTable->ArmCpus);
92
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);
95
96 // Install the ARM Processor table into EFI system configuration table
97 Status = gBS->InstallConfigurationTable (&gArmMpCoreInfoGuid, ArmProcessorTable);
98
99 ASSERT_EFI_ERROR (Status);
100 }
101 }
102 }
103 }