From 44788bae6f0ac5519764651d732a7c12b1f398c4 Mon Sep 17 00:00:00 2001 From: oliviermartin Date: Thu, 22 Sep 2011 23:14:01 +0000 Subject: ArmPkg: Create MpCoreInfo PPI and HOB to describe CPU Cores on a MPCore platform These info are: - ClusterId, CoreId - MailBox Set/Get/Clear address git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12423 6f19259b-4bc3-4df7-8a09-765794883524 --- ArmPkg/Drivers/CpuDxe/CpuDxe.c | 6 +++ ArmPkg/Drivers/CpuDxe/CpuDxe.h | 14 ++++++ ArmPkg/Drivers/CpuDxe/CpuDxe.inf | 7 ++- ArmPkg/Drivers/CpuDxe/CpuMpCore.c | 103 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 ArmPkg/Drivers/CpuDxe/CpuMpCore.c (limited to 'ArmPkg/Drivers/CpuDxe') diff --git a/ArmPkg/Drivers/CpuDxe/CpuDxe.c b/ArmPkg/Drivers/CpuDxe/CpuDxe.c index cea333f91d..f14a676383 100644 --- a/ArmPkg/Drivers/CpuDxe/CpuDxe.c +++ b/ArmPkg/Drivers/CpuDxe/CpuDxe.c @@ -257,6 +257,12 @@ CpuDxeInitialize ( // SyncCacheConfig (&mCpu); + // If the platform is a MPCore system then install the Configuration Table describing the + // secondary core states + if (ArmIsMPCore()) { + PublishArmProcessorTable(); + } + // // Setup a callback for idle events // diff --git a/ArmPkg/Drivers/CpuDxe/CpuDxe.h b/ArmPkg/Drivers/CpuDxe/CpuDxe.h index 70f77ca059..6349d8087f 100644 --- a/ArmPkg/Drivers/CpuDxe/CpuDxe.h +++ b/ArmPkg/Drivers/CpuDxe/CpuDxe.h @@ -124,6 +124,20 @@ ConvertSectionToPages ( IN EFI_PHYSICAL_ADDRESS BaseAddress ); +/** + * Publish ARM Processor Data table in UEFI SYSTEM Table. + * @param HobStart Pointer to the beginning of the HOB List from PEI. + * + * Description : This function iterates through HOB list and finds ARM processor Table Entry HOB. + * If the ARM processor Table Entry HOB is found, the HOB data is copied to run-time memory + * and a pointer is assigned to it in ARM processor table. Then the ARM processor table is + * installed in EFI configuration table. +**/ +VOID +EFIAPI +PublishArmProcessorTable( + VOID + ); extern VIRTUAL_UNCACHED_PAGES_PROTOCOL gVirtualUncachedPages; diff --git a/ArmPkg/Drivers/CpuDxe/CpuDxe.inf b/ArmPkg/Drivers/CpuDxe/CpuDxe.inf index 231257cc1a..e5709a63d0 100644 --- a/ArmPkg/Drivers/CpuDxe/CpuDxe.inf +++ b/ArmPkg/Drivers/CpuDxe/CpuDxe.inf @@ -27,6 +27,7 @@ [Sources.ARM] CpuDxe.c CpuDxe.h + CpuMpCore.c Exception.c # @@ -40,7 +41,7 @@ # ExceptionSupport.ARMv6.asm | RVCT ExceptionSupport.ARMv6.S | GCC - Mmu.c + Mmu.c [Packages] @@ -50,13 +51,16 @@ MdeModulePkg/MdeModulePkg.dec [LibraryClasses] + ArmLib BaseMemoryLib CacheMaintenanceLib CpuLib DebugLib DefaultExceptionHandlerLib DxeServicesTableLib + HobLib PeCoffGetEntryPointLib + UefiDriverEntryPoint UefiLib [Protocols] @@ -66,6 +70,7 @@ [Guids] gEfiDebugImageInfoTableGuid + gArmMpCoreInfoGuid gIdleLoopEventGuid [Pcd.common] diff --git a/ArmPkg/Drivers/CpuDxe/CpuMpCore.c b/ArmPkg/Drivers/CpuDxe/CpuMpCore.c new file mode 100644 index 0000000000..49bc25c8c5 --- /dev/null +++ b/ArmPkg/Drivers/CpuDxe/CpuMpCore.c @@ -0,0 +1,103 @@ +/** @file +* +* Copyright (c) 2011, ARM Limited. All rights reserved. +* +* This program and the accompanying materials +* are licensed and made available under the terms and conditions of the BSD License +* which accompanies this distribution. The full text of the license may be found at +* http://opensource.org/licenses/bsd-license.php +* +* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +* +**/ + +#include +#include +#include +#include +#include + +#include + +ARM_PROCESSOR_TABLE mArmProcessorTableTemplate = { + { + EFI_ARM_PROCESSOR_TABLE_SIGNATURE, + 0, + EFI_ARM_PROCESSOR_TABLE_REVISION, + EFI_ARM_PROCESSOR_TABLE_OEM_ID, + EFI_ARM_PROCESSOR_TABLE_OEM_TABLE_ID, + EFI_ARM_PROCESSOR_TABLE_OEM_REVISION, + EFI_ARM_PROCESSOR_TABLE_CREATOR_ID, + EFI_ARM_PROCESSOR_TABLE_CREATOR_REVISION, + 0, + 0 + }, //ARM Processor table header + 0, // Number of entries in ARM processor Table + NULL // ARM Processor Table +}; + +/** Publish ARM Processor Data table in UEFI SYSTEM Table. + * @param: HobStart Pointer to the beginning of the HOB List from PEI. + * + * Description : This function iterates through HOB list and finds ARM processor Table Entry HOB. + * If the ARM processor Table Entry HOB is found, the HOB data is copied to run-time memory + * and a pointer is assigned to it in ARM processor table. Then the ARM processor table is + * installed in EFI configuration table. +**/ +VOID +EFIAPI +PublishArmProcessorTable ( + VOID + ) +{ + EFI_PEI_HOB_POINTERS Hob; + + Hob.Raw = GetHobList (); + + // Iterate through the HOBs and find if there is ARM PROCESSOR ENTRY HOB + for (; !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) { + // Check for Correct HOB type + if ((GET_HOB_TYPE (Hob)) == EFI_HOB_TYPE_GUID_EXTENSION) { + // Check for correct GUID type + if (CompareGuid(&(Hob.Guid->Name), &gArmMpCoreInfoGuid)) { + ARM_PROCESSOR_TABLE *ArmProcessorTable; + EFI_STATUS Status; + + // Allocate Runtime memory for ARM processor table + ArmProcessorTable = (ARM_PROCESSOR_TABLE*)AllocateRuntimePool(sizeof(ARM_PROCESSOR_TABLE)); + + // Check if the memory allocation is succesful or not + ASSERT(NULL != ArmProcessorTable); + + // Set ARM processor table to default values + CopyMem(ArmProcessorTable,&mArmProcessorTableTemplate,sizeof(ARM_PROCESSOR_TABLE)); + + // Fill in Length fields of ARM processor table + ArmProcessorTable->Header.Length = sizeof(ARM_PROCESSOR_TABLE); + ArmProcessorTable->Header.DataLen = GET_GUID_HOB_DATA_SIZE(Hob); + + // Fill in Identifier(ARM processor table GUID) + ArmProcessorTable->Header.Identifier = gArmMpCoreInfoGuid; + + // Set Number of ARM core entries in the Table + ArmProcessorTable->NumberOfEntries = GET_GUID_HOB_DATA_SIZE(Hob)/sizeof(ARM_CORE_INFO); + + // Allocate runtime memory for ARM processor Table entries + ArmProcessorTable->ArmCpus = (ARM_CORE_INFO*)AllocateRuntimePool ( + ArmProcessorTable->NumberOfEntries * sizeof(ARM_CORE_INFO)); + + // Check if the memory allocation is succesful or not + ASSERT(NULL != ArmProcessorTable->ArmCpus); + + // Copy ARM Processor Table data from HOB list to newly allocated memory + CopyMem(ArmProcessorTable->ArmCpus,GET_GUID_HOB_DATA(Hob), ArmProcessorTable->Header.DataLen); + + // Install the ARM Processor table into EFI system configuration table + Status = gBS->InstallConfigurationTable (&gArmMpCoreInfoGuid, ArmProcessorTable); + + ASSERT_EFI_ERROR (Status); + } + } + } +} -- cgit v1.2.3