2 CPU PEI Module installs CPU Multiple Processor PPI.
4 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
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
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.
18 // Global Descriptor Table (GDT)
20 GLOBAL_REMOVE_IF_UNREFERENCED IA32_GDT mGdtEntries
[] = {
21 /* selector { Global Segment Descriptor } */
22 /* 0x00 */ {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, //null descriptor
23 /* 0x08 */ {{0xffff, 0, 0, 0x2, 1, 0, 1, 0xf, 0, 0, 1, 1, 0}}, //linear data segment descriptor
24 /* 0x10 */ {{0xffff, 0, 0, 0xf, 1, 0, 1, 0xf, 0, 0, 1, 1, 0}}, //linear code segment descriptor
25 /* 0x18 */ {{0xffff, 0, 0, 0x3, 1, 0, 1, 0xf, 0, 0, 1, 1, 0}}, //system data segment descriptor
26 /* 0x20 */ {{0xffff, 0, 0, 0xa, 1, 0, 1, 0xf, 0, 0, 1, 1, 0}}, //system code segment descriptor
27 /* 0x28 */ {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, //spare segment descriptor
28 /* 0x30 */ {{0xffff, 0, 0, 0x2, 1, 0, 1, 0xf, 0, 0, 1, 1, 0}}, //system data segment descriptor
29 /* 0x38 */ {{0xffff, 0, 0, 0xa, 1, 0, 1, 0xf, 0, 1, 0, 1, 0}}, //system code segment descriptor
30 /* 0x40 */ {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, //spare segment descriptor
36 GLOBAL_REMOVE_IF_UNREFERENCED IA32_DESCRIPTOR mGdt
= {
37 sizeof (mGdtEntries
) - 1,
41 GLOBAL_REMOVE_IF_UNREFERENCED EFI_PEI_NOTIFY_DESCRIPTOR mNotifyList
= {
42 (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
43 &gEfiEndOfPeiSignalPpiGuid
,
48 Sort the APIC ID of all processors.
50 This function sorts the APIC ID of all processors so that processor number is
51 assigned in the ascending order of APIC ID which eases MP debugging.
53 @param PeiCpuMpData Pointer to PEI CPU MP Data
57 IN PEI_CPU_MP_DATA
*PeiCpuMpData
67 ApCount
= PeiCpuMpData
->CpuCount
- 1;
70 for (Index1
= 0; Index1
< ApCount
; Index1
++) {
73 // Sort key is the hardware default APIC ID
75 ApicId
= PeiCpuMpData
->CpuData
[Index1
].ApicId
;
76 for (Index2
= Index1
+ 1; Index2
<= ApCount
; Index2
++) {
77 if (ApicId
> PeiCpuMpData
->CpuData
[Index2
].ApicId
) {
79 ApicId
= PeiCpuMpData
->CpuData
[Index2
].ApicId
;
82 if (Index3
!= Index1
) {
83 CopyMem (&CpuData
, &PeiCpuMpData
->CpuData
[Index3
], sizeof (PEI_CPU_DATA
));
85 &PeiCpuMpData
->CpuData
[Index3
],
86 &PeiCpuMpData
->CpuData
[Index1
],
89 CopyMem (&PeiCpuMpData
->CpuData
[Index1
], &CpuData
, sizeof (PEI_CPU_DATA
));
94 // Get the processor number for the BSP
96 ApicId
= GetInitialApicId ();
97 for (Index1
= 0; Index1
< PeiCpuMpData
->CpuCount
; Index1
++) {
98 if (PeiCpuMpData
->CpuData
[Index1
].ApicId
== ApicId
) {
99 PeiCpuMpData
->BspNumber
= (UINT32
) Index1
;
107 Enable x2APIC mode on APs.
109 @param Buffer Pointer to private data buffer.
117 SetApicMode (LOCAL_APIC_MODE_X2APIC
);
121 Get CPU MP Data pointer from the Guided HOB.
123 @return Pointer to Pointer to PEI CPU MP Data
130 EFI_HOB_GUID_TYPE
*GuidHob
;
132 PEI_CPU_MP_DATA
*CpuMpData
;
135 GuidHob
= GetFirstGuidHob (&gEfiCallerIdGuid
);
136 if (GuidHob
!= NULL
) {
137 DataInHob
= GET_GUID_HOB_DATA (GuidHob
);
138 CpuMpData
= (PEI_CPU_MP_DATA
*)(*(UINTN
*)DataInHob
);
140 ASSERT (CpuMpData
!= NULL
);
145 Save the volatile registers required to be restored following INIT IPI
147 @param VolatileRegisters Returns buffer saved the volatile resisters
150 SaveVolatileRegisters (
151 OUT CPU_VOLATILE_REGISTERS
*VolatileRegisters
156 VolatileRegisters
->Cr0
= AsmReadCr0 ();
157 VolatileRegisters
->Cr3
= AsmReadCr3 ();
158 VolatileRegisters
->Cr4
= AsmReadCr4 ();
160 AsmCpuid (CPUID_VERSION_INFO
, NULL
, NULL
, NULL
, &RegEdx
);
161 if ((RegEdx
& BIT2
) != 0) {
163 // If processor supports Debugging Extensions feature
164 // by CPUID.[EAX=01H]:EDX.BIT2
166 VolatileRegisters
->Dr0
= AsmReadDr0 ();
167 VolatileRegisters
->Dr1
= AsmReadDr1 ();
168 VolatileRegisters
->Dr2
= AsmReadDr2 ();
169 VolatileRegisters
->Dr3
= AsmReadDr3 ();
170 VolatileRegisters
->Dr6
= AsmReadDr6 ();
171 VolatileRegisters
->Dr7
= AsmReadDr7 ();
176 Restore the volatile registers following INIT IPI
178 @param VolatileRegisters Pointer to volatile resisters
179 @param IsRestoreDr TRUE: Restore DRx if supported
180 FALSE: Do not restore DRx
183 RestoreVolatileRegisters (
184 IN CPU_VOLATILE_REGISTERS
*VolatileRegisters
,
185 IN BOOLEAN IsRestoreDr
190 AsmWriteCr0 (VolatileRegisters
->Cr0
);
191 AsmWriteCr3 (VolatileRegisters
->Cr3
);
192 AsmWriteCr4 (VolatileRegisters
->Cr4
);
195 AsmCpuid (CPUID_VERSION_INFO
, NULL
, NULL
, NULL
, &RegEdx
);
196 if ((RegEdx
& BIT2
) != 0) {
198 // If processor supports Debugging Extensions feature
199 // by CPUID.[EAX=01H]:EDX.BIT2
201 AsmWriteDr0 (VolatileRegisters
->Dr0
);
202 AsmWriteDr1 (VolatileRegisters
->Dr1
);
203 AsmWriteDr2 (VolatileRegisters
->Dr2
);
204 AsmWriteDr3 (VolatileRegisters
->Dr3
);
205 AsmWriteDr6 (VolatileRegisters
->Dr6
);
206 AsmWriteDr7 (VolatileRegisters
->Dr7
);
212 This function will be called from AP reset code if BSP uses WakeUpAP.
214 @param ExchangeInfo Pointer to the MP exchange info buffer
215 @param NumApsExecuting Number of curret executing AP
220 IN MP_CPU_EXCHANGE_INFO
*ExchangeInfo
,
221 IN UINTN NumApsExecuting
224 PEI_CPU_MP_DATA
*PeiCpuMpData
;
225 UINTN ProcessorNumber
;
226 EFI_AP_PROCEDURE Procedure
;
229 PeiCpuMpData
= ExchangeInfo
->PeiCpuMpData
;
230 if (PeiCpuMpData
->InitFlag
) {
231 ProcessorNumber
= NumApsExecuting
;
233 // Sync BSP's Control registers to APs
235 RestoreVolatileRegisters (&PeiCpuMpData
->CpuData
[0].VolatileRegisters
, FALSE
);
237 // This is first time AP wakeup, get BIST information from AP stack
239 BistData
= *(UINTN
*) (PeiCpuMpData
->Buffer
+ ProcessorNumber
* PeiCpuMpData
->CpuApStackSize
- sizeof (UINTN
));
240 PeiCpuMpData
->CpuData
[ProcessorNumber
].Health
.Uint32
= (UINT32
) BistData
;
241 PeiCpuMpData
->CpuData
[ProcessorNumber
].ApicId
= GetInitialApicId ();
242 if (PeiCpuMpData
->CpuData
[ProcessorNumber
].ApicId
>= 0xFF) {
244 // Set x2APIC mode if there are any logical processor reporting
245 // an APIC ID of 255 or greater.
247 AcquireSpinLock(&PeiCpuMpData
->MpLock
);
248 PeiCpuMpData
->X2ApicEnable
= TRUE
;
249 ReleaseSpinLock(&PeiCpuMpData
->MpLock
);
252 // Sync BSP's Mtrr table to all wakeup APs and load microcode on APs.
254 MtrrSetAllMtrrs (&PeiCpuMpData
->MtrrTable
);
256 PeiCpuMpData
->CpuData
[ProcessorNumber
].State
= CpuStateIdle
;
259 // Execute AP function if AP is not disabled
261 GetProcessorNumber (PeiCpuMpData
, &ProcessorNumber
);
263 // Restore AP's volatile registers saved
265 RestoreVolatileRegisters (&PeiCpuMpData
->CpuData
[ProcessorNumber
].VolatileRegisters
, TRUE
);
267 if ((PeiCpuMpData
->CpuData
[ProcessorNumber
].State
!= CpuStateDisabled
) &&
268 (PeiCpuMpData
->ApFunction
!= 0)) {
269 PeiCpuMpData
->CpuData
[ProcessorNumber
].State
= CpuStateBusy
;
270 Procedure
= (EFI_AP_PROCEDURE
)(UINTN
)PeiCpuMpData
->ApFunction
;
271 Procedure ((VOID
*)(UINTN
)PeiCpuMpData
->ApFunctionArgument
);
272 PeiCpuMpData
->CpuData
[ProcessorNumber
].State
= CpuStateIdle
;
277 // AP finished executing C code
279 InterlockedIncrement ((UINT32
*)&PeiCpuMpData
->FinishedCount
);
282 // Save AP volatile registers
284 SaveVolatileRegisters (&PeiCpuMpData
->CpuData
[ProcessorNumber
].VolatileRegisters
);
290 This function will be called by BSP to wakeup AP.
292 @param PeiCpuMpData Pointer to PEI CPU MP Data
293 @param Broadcast TRUE: Send broadcast IPI to all APs
294 FALSE: Send IPI to AP by ApicId
295 @param ApicId Apic ID for the processor to be waked
296 @param Procedure The function to be invoked by AP
297 @param ProcedureArgument The argument to be passed into AP function
301 IN PEI_CPU_MP_DATA
*PeiCpuMpData
,
302 IN BOOLEAN Broadcast
,
304 IN EFI_AP_PROCEDURE Procedure
, OPTIONAL
305 IN VOID
*ProcedureArgument OPTIONAL
308 volatile MP_CPU_EXCHANGE_INFO
*ExchangeInfo
;
310 PeiCpuMpData
->ApFunction
= (UINTN
) Procedure
;
311 PeiCpuMpData
->ApFunctionArgument
= (UINTN
) ProcedureArgument
;
312 PeiCpuMpData
->FinishedCount
= 0;
314 ExchangeInfo
= PeiCpuMpData
->MpCpuExchangeInfo
;
315 ExchangeInfo
->Lock
= 0;
316 ExchangeInfo
->StackStart
= PeiCpuMpData
->Buffer
;
317 ExchangeInfo
->StackSize
= PeiCpuMpData
->CpuApStackSize
;
318 ExchangeInfo
->BufferStart
= PeiCpuMpData
->WakeupBuffer
;
319 ExchangeInfo
->PmodeOffset
= PeiCpuMpData
->AddressMap
.PModeEntryOffset
;
320 ExchangeInfo
->LmodeOffset
= PeiCpuMpData
->AddressMap
.LModeEntryOffset
;
321 ExchangeInfo
->Cr3
= AsmReadCr3 ();
322 ExchangeInfo
->CFunction
= (UINTN
) ApCFunction
;
323 ExchangeInfo
->NumApsExecuting
= 0;
324 ExchangeInfo
->PeiCpuMpData
= PeiCpuMpData
;
327 // Get the BSP's data of GDT and IDT
329 CopyMem ((VOID
*)&ExchangeInfo
->GdtrProfile
, &mGdt
, sizeof(mGdt
));
330 AsmReadIdtr ((IA32_DESCRIPTOR
*) &ExchangeInfo
->IdtrProfile
);
333 SendInitSipiSipiAllExcludingSelf ((UINT32
) ExchangeInfo
->BufferStart
);
335 SendInitSipiSipi (ApicId
, (UINT32
) ExchangeInfo
->BufferStart
);
342 Get available system memory below 1MB by specified size.
344 @param WakeupBufferSize Wakeup buffer size required
346 @retval other Return wakeup buffer address below 1MB.
347 @retval -1 Cannot find free memory below 1MB.
351 IN UINTN WakeupBufferSize
354 EFI_PEI_HOB_POINTERS Hob
;
355 UINTN WakeupBufferStart
;
356 UINTN WakeupBufferEnd
;
359 // Get the HOB list for processing
361 Hob
.Raw
= GetHobList ();
364 // Collect memory ranges
366 while (!END_OF_HOB_LIST (Hob
)) {
367 if (Hob
.Header
->HobType
== EFI_HOB_TYPE_RESOURCE_DESCRIPTOR
) {
368 if ((Hob
.ResourceDescriptor
->PhysicalStart
< BASE_1MB
) &&
369 (Hob
.ResourceDescriptor
->ResourceType
== EFI_RESOURCE_SYSTEM_MEMORY
) &&
370 ((Hob
.ResourceDescriptor
->ResourceAttribute
&
371 (EFI_RESOURCE_ATTRIBUTE_READ_PROTECTED
|
372 EFI_RESOURCE_ATTRIBUTE_WRITE_PROTECTED
|
373 EFI_RESOURCE_ATTRIBUTE_EXECUTION_PROTECTED
377 // Need memory under 1MB to be collected here
379 WakeupBufferEnd
= (UINTN
) (Hob
.ResourceDescriptor
->PhysicalStart
+ Hob
.ResourceDescriptor
->ResourceLength
);
380 if (WakeupBufferEnd
> BASE_1MB
) {
382 // Wakeup buffer should be under 1MB
384 WakeupBufferEnd
= BASE_1MB
;
387 // Wakeup buffer should be aligned on 4KB
389 WakeupBufferStart
= (WakeupBufferEnd
- WakeupBufferSize
) & ~(SIZE_4KB
- 1);
390 if (WakeupBufferStart
< Hob
.ResourceDescriptor
->PhysicalStart
) {
394 // Create a memory allocation HOB.
396 BuildMemoryAllocationHob (
401 return WakeupBufferStart
;
407 Hob
.Raw
= GET_NEXT_HOB (Hob
);
414 Get available system memory below 1MB by specified size.
416 @param PeiCpuMpData Pointer to PEI CPU MP Data
419 BackupAndPrepareWakeupBuffer(
420 IN PEI_CPU_MP_DATA
*PeiCpuMpData
424 (VOID
*) PeiCpuMpData
->BackupBuffer
,
425 (VOID
*) PeiCpuMpData
->WakeupBuffer
,
426 PeiCpuMpData
->BackupBufferSize
429 (VOID
*) PeiCpuMpData
->WakeupBuffer
,
430 (VOID
*) PeiCpuMpData
->AddressMap
.RendezvousFunnelAddress
,
431 PeiCpuMpData
->AddressMap
.RendezvousFunnelSize
436 Restore wakeup buffer data.
438 @param PeiCpuMpData Pointer to PEI CPU MP Data
442 IN PEI_CPU_MP_DATA
*PeiCpuMpData
445 CopyMem ((VOID
*) PeiCpuMpData
->WakeupBuffer
, (VOID
*) PeiCpuMpData
->BackupBuffer
, PeiCpuMpData
->BackupBufferSize
);
449 This function will get CPU count in the system.
451 @param PeiCpuMpData Pointer to PEI CPU MP Data
453 @return AP processor count
456 CountProcessorNumber (
457 IN PEI_CPU_MP_DATA
*PeiCpuMpData
461 // Load Microcode on BSP
465 // Store BSP's MTRR setting
467 MtrrGetAllMtrrs (&PeiCpuMpData
->MtrrTable
);
470 // Only perform AP detection if PcdCpuMaxLogicalProcessorNumber is greater than 1
472 if (PcdGet32 (PcdCpuMaxLogicalProcessorNumber
) > 1) {
474 // Send 1st broadcast IPI to APs to wakeup APs
476 PeiCpuMpData
->InitFlag
= TRUE
;
477 PeiCpuMpData
->X2ApicEnable
= FALSE
;
478 WakeUpAP (PeiCpuMpData
, TRUE
, 0, NULL
, NULL
);
480 // Wait for AP task to complete and then exit.
482 MicroSecondDelay (PcdGet32 (PcdCpuApInitTimeOutInMicroSeconds
));
483 PeiCpuMpData
->InitFlag
= FALSE
;
484 PeiCpuMpData
->CpuCount
+= (UINT32
)PeiCpuMpData
->MpCpuExchangeInfo
->NumApsExecuting
;
485 ASSERT (PeiCpuMpData
->CpuCount
<= PcdGet32 (PcdCpuMaxLogicalProcessorNumber
));
487 // Wait for all APs finished the initialization
489 while (PeiCpuMpData
->FinishedCount
< (PeiCpuMpData
->CpuCount
- 1)) {
493 if (PeiCpuMpData
->X2ApicEnable
) {
494 DEBUG ((EFI_D_INFO
, "Force x2APIC mode!\n"));
496 // Send 2nd broadcast IPI to all APs to enable x2APIC mode
498 WakeUpAP (PeiCpuMpData
, TRUE
, 0, ApFuncEnableX2Apic
, NULL
);
500 // Wait for all known APs finished
502 while (PeiCpuMpData
->FinishedCount
< (PeiCpuMpData
->CpuCount
- 1)) {
506 // Enable x2APIC on BSP
508 SetApicMode (LOCAL_APIC_MODE_X2APIC
);
510 DEBUG ((EFI_D_INFO
, "APIC MODE is %d\n", GetApicMode ()));
512 // Sort BSP/Aps by CPU APIC ID in ascending order
514 SortApicId (PeiCpuMpData
);
517 DEBUG ((EFI_D_INFO
, "CpuMpPei: Find %d processors in system.\n", PeiCpuMpData
->CpuCount
));
518 return PeiCpuMpData
->CpuCount
;
522 Prepare for AP wakeup buffer and copy AP reset code into it.
524 Get wakeup buffer below 1MB. Allocate memory for CPU MP Data and APs Stack.
526 @return Pointer to PEI CPU MP Data
529 PrepareAPStartupVector (
535 PEI_CPU_MP_DATA
*PeiCpuMpData
;
536 EFI_PHYSICAL_ADDRESS Buffer
;
539 UINTN WakeupBufferSize
;
540 MP_ASSEMBLY_ADDRESS_MAP AddressMap
;
542 AsmGetAddressMap (&AddressMap
);
543 WakeupBufferSize
= AddressMap
.RendezvousFunnelSize
+ sizeof (MP_CPU_EXCHANGE_INFO
);
544 WakeupBuffer
= GetWakeupBuffer ((WakeupBufferSize
+ SIZE_4KB
- 1) & ~(SIZE_4KB
- 1));
545 ASSERT (WakeupBuffer
!= (UINTN
) -1);
546 DEBUG ((EFI_D_INFO
, "CpuMpPei: WakeupBuffer = 0x%x\n", WakeupBuffer
));
549 // Allocate Pages for APs stack, CPU MP Data and backup buffer for wakeup buffer
551 MaxCpuCount
= PcdGet32(PcdCpuMaxLogicalProcessorNumber
);
552 BufferSize
= PcdGet32 (PcdCpuApStackSize
) * MaxCpuCount
+ sizeof (PEI_CPU_MP_DATA
)
553 + WakeupBufferSize
+ sizeof (PEI_CPU_DATA
) * MaxCpuCount
;
554 Status
= PeiServicesAllocatePages (
556 EFI_SIZE_TO_PAGES (BufferSize
),
559 ASSERT_EFI_ERROR (Status
);
561 PeiCpuMpData
= (PEI_CPU_MP_DATA
*) (UINTN
) (Buffer
+ PcdGet32 (PcdCpuApStackSize
) * MaxCpuCount
);
562 PeiCpuMpData
->Buffer
= (UINTN
) Buffer
;
563 PeiCpuMpData
->CpuApStackSize
= PcdGet32 (PcdCpuApStackSize
);
564 PeiCpuMpData
->WakeupBuffer
= WakeupBuffer
;
565 PeiCpuMpData
->BackupBuffer
= (UINTN
)PeiCpuMpData
+ sizeof (PEI_CPU_MP_DATA
);
566 PeiCpuMpData
->BackupBufferSize
= WakeupBufferSize
;
567 PeiCpuMpData
->MpCpuExchangeInfo
= (MP_CPU_EXCHANGE_INFO
*) (UINTN
) (WakeupBuffer
+ AddressMap
.RendezvousFunnelSize
);
569 PeiCpuMpData
->CpuCount
= 1;
570 PeiCpuMpData
->BspNumber
= 0;
571 PeiCpuMpData
->CpuData
= (PEI_CPU_DATA
*) (PeiCpuMpData
->BackupBuffer
+
572 PeiCpuMpData
->BackupBufferSize
);
573 PeiCpuMpData
->CpuData
[0].ApicId
= GetInitialApicId ();
574 PeiCpuMpData
->CpuData
[0].Health
.Uint32
= 0;
575 PeiCpuMpData
->EndOfPeiFlag
= FALSE
;
576 InitializeSpinLock(&PeiCpuMpData
->MpLock
);
577 SaveVolatileRegisters (&PeiCpuMpData
->CpuData
[0].VolatileRegisters
);
578 CopyMem (&PeiCpuMpData
->AddressMap
, &AddressMap
, sizeof (MP_ASSEMBLY_ADDRESS_MAP
));
581 // Backup original data and copy AP reset code in it
583 BackupAndPrepareWakeupBuffer(PeiCpuMpData
);
589 Notify function on End Of Pei PPI.
591 On S3 boot, this function will restore wakeup buffer data.
592 On normal boot, this function will flag wakeup buffer to be un-used type.
594 @param PeiServices The pointer to the PEI Services Table.
595 @param NotifyDescriptor Address of the notification descriptor data structure.
596 @param Ppi Address of the PPI that was installed.
598 @retval EFI_SUCCESS When everything is OK.
603 CpuMpEndOfPeiCallback (
604 IN EFI_PEI_SERVICES
**PeiServices
,
605 IN EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyDescriptor
,
610 EFI_BOOT_MODE BootMode
;
611 PEI_CPU_MP_DATA
*PeiCpuMpData
;
612 EFI_PEI_HOB_POINTERS Hob
;
613 EFI_HOB_MEMORY_ALLOCATION
*MemoryHob
;
615 DEBUG ((EFI_D_INFO
, "CpuMpPei: CpuMpEndOfPeiCallback () invokded\n"));
617 Status
= PeiServicesGetBootMode (&BootMode
);
618 ASSERT_EFI_ERROR (Status
);
620 PeiCpuMpData
= GetMpHobData ();
621 ASSERT (PeiCpuMpData
!= NULL
);
623 if (BootMode
!= BOOT_ON_S3_RESUME
) {
625 // Get the HOB list for processing
627 Hob
.Raw
= GetHobList ();
629 // Collect memory ranges
631 while (!END_OF_HOB_LIST (Hob
)) {
632 if (Hob
.Header
->HobType
== EFI_HOB_TYPE_MEMORY_ALLOCATION
) {
633 MemoryHob
= Hob
.MemoryAllocation
;
634 if(MemoryHob
->AllocDescriptor
.MemoryBaseAddress
== PeiCpuMpData
->WakeupBuffer
) {
636 // Flag this HOB type to un-used
638 GET_HOB_TYPE (Hob
) = EFI_HOB_TYPE_UNUSED
;
642 Hob
.Raw
= GET_NEXT_HOB (Hob
);
645 RestoreWakeupBuffer (PeiCpuMpData
);
646 PeiCpuMpData
->EndOfPeiFlag
= TRUE
;
652 The Entry point of the MP CPU PEIM.
654 This function will wakeup APs and collect CPU AP count and install the
657 @param FileHandle Handle of the file being invoked.
658 @param PeiServices Describes the list of possible PEI Services.
660 @retval EFI_SUCCESS MpServicePpi is installed successfully.
666 IN EFI_PEI_FILE_HANDLE FileHandle
,
667 IN CONST EFI_PEI_SERVICES
**PeiServices
671 PEI_CPU_MP_DATA
*PeiCpuMpData
;
672 UINT32 ProcessorCount
;
675 // Load new GDT table on BSP
677 AsmInitializeGdt (&mGdt
);
679 // Get wakeup buffer and copy AP reset code in it
681 PeiCpuMpData
= PrepareAPStartupVector ();
683 // Count processor number and collect processor information
685 ProcessorCount
= CountProcessorNumber (PeiCpuMpData
);
687 // Build location of PEI CPU MP DATA buffer in HOB
691 (VOID
*)&PeiCpuMpData
,
695 // Update and publish CPU BIST information
697 CollectBistDataFromPpi (PeiServices
, PeiCpuMpData
);
699 // register an event for EndOfPei
701 Status
= PeiServicesNotifyPpi (&mNotifyList
);
702 ASSERT_EFI_ERROR (Status
);
704 // Install CPU MP PPI
706 Status
= PeiServicesInstallPpi(&mPeiCpuMpPpiDesc
);
707 ASSERT_EFI_ERROR (Status
);