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
This commit is contained in:
@@ -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
|
||||
//
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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]
|
||||
|
103
ArmPkg/Drivers/CpuDxe/CpuMpCore.c
Normal file
103
ArmPkg/Drivers/CpuDxe/CpuMpCore.c
Normal file
@@ -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 <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/HobLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
|
||||
#include <Guid/ArmMpCoreInfo.h>
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -2,6 +2,8 @@
|
||||
|
||||
Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2011 Hewlett Packard Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2011, ARM Limited. All rights reserved.<BR>
|
||||
|
||||
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
|
||||
@@ -29,12 +31,14 @@ Abstract:
|
||||
//
|
||||
// The protocols, PPI and GUID defintions for this module
|
||||
//
|
||||
#include <Ppi/ArmMpCoreInfo.h>
|
||||
|
||||
//
|
||||
// The Library classes this module consumes
|
||||
//
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/PeimEntryPoint.h>
|
||||
#include <Library/PeiServicesLib.h>
|
||||
#include <Library/PcdLib.h>
|
||||
#include <Library/HobLib.h>
|
||||
#include <Library/ArmLib.h>
|
||||
@@ -54,7 +58,7 @@ FindMainMemory (
|
||||
{
|
||||
EFI_PEI_HOB_POINTERS NextHob;
|
||||
|
||||
// look at the resource descriptor hobs, choose the first system memory one
|
||||
// Look at the resource descriptor hobs, choose the first system memory one
|
||||
NextHob.Raw = GetHobList ();
|
||||
while ((NextHob.Raw = GetNextHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, NextHob.Raw)) != NULL) {
|
||||
if(NextHob.ResourceDescriptor->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY)
|
||||
@@ -75,7 +79,7 @@ ConfigureMmu (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
UINTN Idx;
|
||||
UINT32 CacheAttributes;
|
||||
UINT32 SystemMemoryBase;
|
||||
@@ -99,7 +103,7 @@ ConfigureMmu (
|
||||
|
||||
SystemMemoryLastAddress = SystemMemoryBase + (SystemMemoryLength-1);
|
||||
|
||||
// if system memory does not begin at 0
|
||||
// If system memory does not begin at 0
|
||||
if(SystemMemoryBase > 0) {
|
||||
MemoryTable[Idx].PhysicalBase = 0;
|
||||
MemoryTable[Idx].VirtualBase = 0;
|
||||
@@ -114,7 +118,7 @@ ConfigureMmu (
|
||||
MemoryTable[Idx].Attributes = (ARM_MEMORY_REGION_ATTRIBUTES)CacheAttributes;
|
||||
Idx++;
|
||||
|
||||
// if system memory does not go to the last address (0xFFFFFFFF)
|
||||
// If system memory does not go to the last address (0xFFFFFFFF)
|
||||
if( SystemMemoryLastAddress < MAX_ADDRESS ) {
|
||||
MemoryTable[Idx].PhysicalBase = SystemMemoryLastAddress + 1;
|
||||
MemoryTable[Idx].VirtualBase = MemoryTable[Idx].PhysicalBase;
|
||||
@@ -138,13 +142,6 @@ ConfigureMmu (
|
||||
BuildMemoryAllocationHob((EFI_PHYSICAL_ADDRESS)(UINTN)TranslationTableBase, TranslationTableSize, EfiBootServicesData);
|
||||
}
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
InitializeCpuPeim (
|
||||
IN EFI_PEI_FILE_HANDLE FileHandle,
|
||||
IN CONST EFI_PEI_SERVICES **PeiServices
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
@@ -161,14 +158,37 @@ Returns:
|
||||
Status - EFI_SUCCESS if the boot mode could be set
|
||||
|
||||
--*/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
InitializeCpuPeim (
|
||||
IN EFI_PEI_FILE_HANDLE FileHandle,
|
||||
IN CONST EFI_PEI_SERVICES **PeiServices
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
ARM_MP_CORE_INFO_PPI *ArmMpCoreInfoPpi;
|
||||
UINTN ArmCoreCount;
|
||||
ARM_CORE_INFO *ArmCoreInfoTable;
|
||||
|
||||
// Enable program flow prediction, if supported.
|
||||
ArmEnableBranchPrediction ();
|
||||
|
||||
// publish the CPU memory and io spaces sizes
|
||||
// Publish the CPU memory and io spaces sizes
|
||||
BuildCpuHob (PcdGet8 (PcdPrePiCpuMemorySize), PcdGet8 (PcdPrePiCpuIoSize));
|
||||
|
||||
ConfigureMmu();
|
||||
//ConfigureMmu();
|
||||
|
||||
// Only MP Core platform need to produce gArmMpCoreInfoPpiGuid
|
||||
Status = PeiServicesLocatePpi (&gArmMpCoreInfoPpiGuid, 0, NULL, (VOID**)&ArmMpCoreInfoPpi);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
// Build the MP Core Info Table
|
||||
ArmCoreCount = 0;
|
||||
Status = ArmMpCoreInfoPpi->GetMpCoreInfo (&ArmCoreCount, &ArmCoreInfoTable);
|
||||
if (!EFI_ERROR(Status) && (ArmCoreCount > 0)) {
|
||||
// Build MPCore Info HOB
|
||||
BuildGuidDataHob (&gArmMpCoreInfoGuid, ArmCoreInfoTable, sizeof (ARM_CORE_INFO) * ArmCoreCount);
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
@@ -44,6 +44,10 @@
|
||||
ArmLib
|
||||
|
||||
[Ppis]
|
||||
gArmMpCoreInfoPpiGuid
|
||||
|
||||
[Guids]
|
||||
gArmMpCoreInfoGuid
|
||||
|
||||
[FixedPcd]
|
||||
gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize
|
||||
|
Reference in New Issue
Block a user