summaryrefslogtreecommitdiffstats
path: root/UefiCpuPkg/CpuMpPei/CpuMpPei.c
diff options
context:
space:
mode:
Diffstat (limited to 'UefiCpuPkg/CpuMpPei/CpuMpPei.c')
-rw-r--r--UefiCpuPkg/CpuMpPei/CpuMpPei.c149
1 files changed, 76 insertions, 73 deletions
diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.c b/UefiCpuPkg/CpuMpPei/CpuMpPei.c
index 3c1bad6470..1e68c91d95 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.c
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.c
@@ -8,12 +8,12 @@
#include "CpuMpPei.h"
-extern EDKII_PEI_MP_SERVICES2_PPI mMpServices2Ppi;
+extern EDKII_PEI_MP_SERVICES2_PPI mMpServices2Ppi;
//
// CPU MP PPI to be installed
//
-EFI_PEI_MP_SERVICES_PPI mMpServicesPpi = {
+EFI_PEI_MP_SERVICES_PPI mMpServicesPpi = {
PeiGetNumberOfProcessors,
PeiGetProcessorInfo,
PeiStartupAllAPs,
@@ -23,7 +23,7 @@ EFI_PEI_MP_SERVICES_PPI mMpServicesPpi = {
PeiWhoAmI,
};
-EFI_PEI_PPI_DESCRIPTOR mPeiCpuMpPpiList[] = {
+EFI_PEI_PPI_DESCRIPTOR mPeiCpuMpPpiList[] = {
{
EFI_PEI_PPI_DESCRIPTOR_PPI,
&gEdkiiPeiMpServices2PpiGuid,
@@ -73,10 +73,10 @@ EFI_PEI_PPI_DESCRIPTOR mPeiCpuMpPpiList[] = {
EFI_STATUS
EFIAPI
PeiGetNumberOfProcessors (
- IN CONST EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_MP_SERVICES_PPI *This,
- OUT UINTN *NumberOfProcessors,
- OUT UINTN *NumberOfEnabledProcessors
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_MP_SERVICES_PPI *This,
+ OUT UINTN *NumberOfProcessors,
+ OUT UINTN *NumberOfEnabledProcessors
)
{
if ((NumberOfProcessors == NULL) || (NumberOfEnabledProcessors == NULL)) {
@@ -193,12 +193,12 @@ PeiGetProcessorInfo (
EFI_STATUS
EFIAPI
PeiStartupAllAPs (
- IN CONST EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_MP_SERVICES_PPI *This,
- IN EFI_AP_PROCEDURE Procedure,
- IN BOOLEAN SingleThread,
- IN UINTN TimeoutInMicroSeconds,
- IN VOID *ProcedureArgument OPTIONAL
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_MP_SERVICES_PPI *This,
+ IN EFI_AP_PROCEDURE Procedure,
+ IN BOOLEAN SingleThread,
+ IN UINTN TimeoutInMicroSeconds,
+ IN VOID *ProcedureArgument OPTIONAL
)
{
return MpInitLibStartupAllAPs (
@@ -260,12 +260,12 @@ PeiStartupAllAPs (
EFI_STATUS
EFIAPI
PeiStartupThisAP (
- IN CONST EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_MP_SERVICES_PPI *This,
- IN EFI_AP_PROCEDURE Procedure,
- IN UINTN ProcessorNumber,
- IN UINTN TimeoutInMicroseconds,
- IN VOID *ProcedureArgument OPTIONAL
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_MP_SERVICES_PPI *This,
+ IN EFI_AP_PROCEDURE Procedure,
+ IN UINTN ProcessorNumber,
+ IN UINTN TimeoutInMicroseconds,
+ IN VOID *ProcedureArgument OPTIONAL
)
{
return MpInitLibStartupThisAP (
@@ -366,11 +366,11 @@ PeiSwitchBSP (
EFI_STATUS
EFIAPI
PeiEnableDisableAP (
- IN CONST EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_MP_SERVICES_PPI *This,
- IN UINTN ProcessorNumber,
- IN BOOLEAN EnableAP,
- IN UINT32 *HealthFlag OPTIONAL
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_MP_SERVICES_PPI *This,
+ IN UINTN ProcessorNumber,
+ IN BOOLEAN EnableAP,
+ IN UINT32 *HealthFlag OPTIONAL
)
{
return MpInitLibEnableDisableAP (ProcessorNumber, EnableAP, HealthFlag);
@@ -423,7 +423,7 @@ PeiWhoAmI (
VOID
EFIAPI
GetGdtr (
- IN OUT VOID *Buffer
+ IN OUT VOID *Buffer
)
{
AsmReadGdtr ((IA32_DESCRIPTOR *)Buffer);
@@ -441,12 +441,12 @@ GetGdtr (
VOID
EFIAPI
InitializeExceptionStackSwitchHandlers (
- IN OUT VOID *Buffer
+ IN OUT VOID *Buffer
)
{
- CPU_EXCEPTION_INIT_DATA *EssData;
- IA32_DESCRIPTOR Idtr;
- EFI_STATUS Status;
+ CPU_EXCEPTION_INIT_DATA *EssData;
+ IA32_DESCRIPTOR Idtr;
+ EFI_STATUS Status;
EssData = Buffer;
//
@@ -454,9 +454,9 @@ InitializeExceptionStackSwitchHandlers (
// the AP's IDT is the same as BSP's IDT either.
//
AsmReadIdtr (&Idtr);
- EssData->Ia32.IdtTable = (VOID *)Idtr.Base;
+ EssData->Ia32.IdtTable = (VOID *)Idtr.Base;
EssData->Ia32.IdtTableSize = Idtr.Limit + 1;
- Status = InitializeCpuExceptionHandlersEx (NULL, EssData);
+ Status = InitializeCpuExceptionHandlersEx (NULL, EssData);
ASSERT_EFI_ERROR (Status);
}
@@ -472,58 +472,59 @@ InitializeMpExceptionStackSwitchHandlers (
VOID
)
{
- EFI_STATUS Status;
- UINTN Index;
- UINTN Bsp;
- UINTN ExceptionNumber;
- UINTN OldGdtSize;
- UINTN NewGdtSize;
- UINTN NewStackSize;
- IA32_DESCRIPTOR Gdtr;
- CPU_EXCEPTION_INIT_DATA EssData;
- UINT8 *GdtBuffer;
- UINT8 *StackTop;
- UINTN NumberOfProcessors;
+ EFI_STATUS Status;
+ UINTN Index;
+ UINTN Bsp;
+ UINTN ExceptionNumber;
+ UINTN OldGdtSize;
+ UINTN NewGdtSize;
+ UINTN NewStackSize;
+ IA32_DESCRIPTOR Gdtr;
+ CPU_EXCEPTION_INIT_DATA EssData;
+ UINT8 *GdtBuffer;
+ UINT8 *StackTop;
+ UINTN NumberOfProcessors;
if (!PcdGetBool (PcdCpuStackGuard)) {
return;
}
- MpInitLibGetNumberOfProcessors(&NumberOfProcessors, NULL);
+ MpInitLibGetNumberOfProcessors (&NumberOfProcessors, NULL);
MpInitLibWhoAmI (&Bsp);
ExceptionNumber = FixedPcdGetSize (PcdCpuStackSwitchExceptionList);
- NewStackSize = FixedPcdGet32 (PcdCpuKnownGoodStackSize) * ExceptionNumber;
+ NewStackSize = FixedPcdGet32 (PcdCpuKnownGoodStackSize) * ExceptionNumber;
StackTop = AllocatePages (EFI_SIZE_TO_PAGES (NewStackSize * NumberOfProcessors));
- ASSERT(StackTop != NULL);
+ ASSERT (StackTop != NULL);
if (StackTop == NULL) {
return;
}
+
StackTop += NewStackSize * NumberOfProcessors;
//
// The default exception handlers must have been initialized. Let's just skip
// it in this method.
//
- EssData.Ia32.Revision = CPU_EXCEPTION_INIT_DATA_REV;
+ EssData.Ia32.Revision = CPU_EXCEPTION_INIT_DATA_REV;
EssData.Ia32.InitDefaultHandlers = FALSE;
- EssData.Ia32.StackSwitchExceptions = FixedPcdGetPtr(PcdCpuStackSwitchExceptionList);
+ EssData.Ia32.StackSwitchExceptions = FixedPcdGetPtr (PcdCpuStackSwitchExceptionList);
EssData.Ia32.StackSwitchExceptionNumber = ExceptionNumber;
- EssData.Ia32.KnownGoodStackSize = FixedPcdGet32(PcdCpuKnownGoodStackSize);
+ EssData.Ia32.KnownGoodStackSize = FixedPcdGet32 (PcdCpuKnownGoodStackSize);
//
// Initialize Gdtr to suppress incorrect compiler/analyzer warnings.
//
- Gdtr.Base = 0;
+ Gdtr.Base = 0;
Gdtr.Limit = 0;
for (Index = 0; Index < NumberOfProcessors; ++Index) {
//
// To support stack switch, we need to re-construct GDT but not IDT.
//
if (Index == Bsp) {
- GetGdtr(&Gdtr);
+ GetGdtr (&Gdtr);
} else {
//
// AP might have different size of GDT from BSP.
@@ -560,7 +561,7 @@ InitializeMpExceptionStackSwitchHandlers (
// | |
// --------------------------------
//
- OldGdtSize = Gdtr.Limit + 1;
+ OldGdtSize = Gdtr.Limit + 1;
EssData.Ia32.ExceptionTssDescSize = sizeof (IA32_TSS_DESCRIPTOR) *
(ExceptionNumber + 1);
EssData.Ia32.ExceptionTssSize = sizeof (IA32_TASK_STATE_SEGMENT) *
@@ -583,19 +584,21 @@ InitializeMpExceptionStackSwitchHandlers (
//
// Make sure GDT table alignment
//
- EssData.Ia32.GdtTable = ALIGN_POINTER(GdtBuffer, sizeof (IA32_TSS_DESCRIPTOR));
- NewGdtSize -= ((UINT8 *)EssData.Ia32.GdtTable - GdtBuffer);
+ EssData.Ia32.GdtTable = ALIGN_POINTER (GdtBuffer, sizeof (IA32_TSS_DESCRIPTOR));
+ NewGdtSize -= ((UINT8 *)EssData.Ia32.GdtTable - GdtBuffer);
EssData.Ia32.GdtTableSize = NewGdtSize;
EssData.Ia32.ExceptionTssDesc = ((UINT8 *)EssData.Ia32.GdtTable + OldGdtSize);
- EssData.Ia32.ExceptionTss = ((UINT8 *)EssData.Ia32.GdtTable + OldGdtSize +
- EssData.Ia32.ExceptionTssDescSize);
+ EssData.Ia32.ExceptionTss = ((UINT8 *)EssData.Ia32.GdtTable + OldGdtSize +
+ EssData.Ia32.ExceptionTssDescSize);
EssData.Ia32.KnownGoodStackTop = (UINTN)StackTop;
- DEBUG ((DEBUG_INFO,
- "Exception stack top[cpu%lu]: 0x%lX\n",
- (UINT64)(UINTN)Index,
- (UINT64)(UINTN)StackTop));
+ DEBUG ((
+ DEBUG_INFO,
+ "Exception stack top[cpu%lu]: 0x%lX\n",
+ (UINT64)(UINTN)Index,
+ (UINT64)(UINTN)StackTop
+ ));
if (Index == Bsp) {
InitializeExceptionStackSwitchHandlers (&EssData);
@@ -610,7 +613,7 @@ InitializeMpExceptionStackSwitchHandlers (
);
}
- StackTop -= NewStackSize;
+ StackTop -= NewStackSize;
}
}
@@ -625,23 +628,23 @@ InitializeMpExceptionStackSwitchHandlers (
**/
EFI_STATUS
InitializeCpuMpWorker (
- IN CONST EFI_PEI_SERVICES **PeiServices
+ IN CONST EFI_PEI_SERVICES **PeiServices
)
{
- EFI_STATUS Status;
- EFI_VECTOR_HANDOFF_INFO *VectorInfo;
- EFI_PEI_VECTOR_HANDOFF_INFO_PPI *VectorHandoffInfoPpi;
+ EFI_STATUS Status;
+ EFI_VECTOR_HANDOFF_INFO *VectorInfo;
+ EFI_PEI_VECTOR_HANDOFF_INFO_PPI *VectorHandoffInfoPpi;
//
// Get Vector Hand-off Info PPI
//
VectorInfo = NULL;
- Status = PeiServicesLocatePpi (
- &gEfiVectorHandoffInfoPpiGuid,
- 0,
- NULL,
- (VOID **)&VectorHandoffInfoPpi
- );
+ Status = PeiServicesLocatePpi (
+ &gEfiVectorHandoffInfoPpiGuid,
+ 0,
+ NULL,
+ (VOID **)&VectorHandoffInfoPpi
+ );
if (Status == EFI_SUCCESS) {
VectorInfo = VectorHandoffInfoPpi->Info;
}
@@ -672,7 +675,7 @@ InitializeCpuMpWorker (
//
// Install CPU MP PPI
//
- Status = PeiServicesInstallPpi(mPeiCpuMpPpiList);
+ Status = PeiServicesInstallPpi (mPeiCpuMpPpiList);
ASSERT_EFI_ERROR (Status);
return Status;
@@ -697,7 +700,7 @@ CpuMpPeimInit (
IN CONST EFI_PEI_SERVICES **PeiServices
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// For the sake of special initialization needing to be done right after