16022e28cf744a885c278dad256d50670741ea123Jordan Justen/** @file 27fadaacd50d716e8e054a94c20db56cca98e961eJeff Fan CPU DXE Module to produce CPU MP Protocol. 36022e28cf744a885c278dad256d50670741ea123Jordan Justen 47fadaacd50d716e8e054a94c20db56cca98e961eJeff Fan Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.<BR> 56022e28cf744a885c278dad256d50670741ea123Jordan Justen This program and the accompanying materials 66022e28cf744a885c278dad256d50670741ea123Jordan Justen are licensed and made available under the terms and conditions of the BSD License 76022e28cf744a885c278dad256d50670741ea123Jordan Justen which accompanies this distribution. The full text of the license may be found at 86022e28cf744a885c278dad256d50670741ea123Jordan Justen http://opensource.org/licenses/bsd-license.php 96022e28cf744a885c278dad256d50670741ea123Jordan Justen 106022e28cf744a885c278dad256d50670741ea123Jordan Justen THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 116022e28cf744a885c278dad256d50670741ea123Jordan Justen WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 126022e28cf744a885c278dad256d50670741ea123Jordan Justen 136022e28cf744a885c278dad256d50670741ea123Jordan Justen**/ 146022e28cf744a885c278dad256d50670741ea123Jordan Justen 156022e28cf744a885c278dad256d50670741ea123Jordan Justen#include "CpuDxe.h" 166022e28cf744a885c278dad256d50670741ea123Jordan Justen#include "CpuMp.h" 176022e28cf744a885c278dad256d50670741ea123Jordan Justen 189840b1299de78458a42d35b8d1d6cbadd1f6da72Chen FanEFI_HANDLE mMpServiceHandle = NULL; 197fadaacd50d716e8e054a94c20db56cca98e961eJeff FanUINTN mNumberOfProcessors = 1; 20acb2172d15ed793c8ae0484700d42dcc105f2ea1Chen Fan 21003973d98cf1ef84ab810cb4f3870acd3a7f40a6Chen FanEFI_MP_SERVICES_PROTOCOL mMpServicesTemplate = { 22d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan GetNumberOfProcessors, 23e7938b5a869fc42df7f026752f39ea85090eb3f9Chen Fan GetProcessorInfo, 245fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan StartupAllAPs, 253f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan StartupThisAP, 26b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan SwitchBSP, 27fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan EnableDisableAP, 28cfa2fac1f667b227a29a2219321b651c7a143071Chen Fan WhoAmI 29003973d98cf1ef84ab810cb4f3870acd3a7f40a6Chen Fan}; 30003973d98cf1ef84ab810cb4f3870acd3a7f40a6Chen Fan 316022e28cf744a885c278dad256d50670741ea123Jordan Justen/** 32d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan This service retrieves the number of logical processor in the platform 33d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan and the number of those logical processors that are enabled on this boot. 34d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan This service may only be called from the BSP. 35d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan 36d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan This function is used to retrieve the following information: 37d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan - The number of logical processors that are present in the system. 38d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan - The number of enabled logical processors in the system at the instant 39d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan this call is made. 40d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan 41d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan Because MP Service Protocol provides services to enable and disable processors 42d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan dynamically, the number of enabled logical processors may vary during the 43d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan course of a boot session. 44d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan 45d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan If this service is called from an AP, then EFI_DEVICE_ERROR is returned. 46d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan If NumberOfProcessors or NumberOfEnabledProcessors is NULL, then 47d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan EFI_INVALID_PARAMETER is returned. Otherwise, the total number of processors 48d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan is returned in NumberOfProcessors, the number of currently enabled processor 49d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan is returned in NumberOfEnabledProcessors, and EFI_SUCCESS is returned. 50d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan 51d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL 52d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan instance. 53d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan @param[out] NumberOfProcessors Pointer to the total number of logical 54d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan processors in the system, including the BSP 55d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan and disabled APs. 56d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical 57d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan processors that exist in system, including 58d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan the BSP. 59d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan 60d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan @retval EFI_SUCCESS The number of logical processors and enabled 61d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan logical processors was retrieved. 62d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan @retval EFI_DEVICE_ERROR The calling processor is an AP. 63d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL. 64d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan @retval EFI_INVALID_PARAMETER NumberOfEnabledProcessors is NULL. 65d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan 66d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan**/ 67d894d8b704324da8ed902677703ed9d4f7c85076Chen FanEFI_STATUS 68d894d8b704324da8ed902677703ed9d4f7c85076Chen FanEFIAPI 69d894d8b704324da8ed902677703ed9d4f7c85076Chen FanGetNumberOfProcessors ( 70d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan IN EFI_MP_SERVICES_PROTOCOL *This, 71d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan OUT UINTN *NumberOfProcessors, 72d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan OUT UINTN *NumberOfEnabledProcessors 73d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan ) 74d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan{ 75d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan if ((NumberOfProcessors == NULL) || (NumberOfEnabledProcessors == NULL)) { 76d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan return EFI_INVALID_PARAMETER; 77d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan } 78d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan 797fadaacd50d716e8e054a94c20db56cca98e961eJeff Fan return MpInitLibGetNumberOfProcessors ( 807fadaacd50d716e8e054a94c20db56cca98e961eJeff Fan NumberOfProcessors, 817fadaacd50d716e8e054a94c20db56cca98e961eJeff Fan NumberOfEnabledProcessors 827fadaacd50d716e8e054a94c20db56cca98e961eJeff Fan ); 83d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan} 84d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan 85d894d8b704324da8ed902677703ed9d4f7c85076Chen Fan/** 86e7938b5a869fc42df7f026752f39ea85090eb3f9Chen Fan Gets detailed MP-related information on the requested processor at the 87e7938b5a869fc42df7f026752f39ea85090eb3f9Chen Fan instant this call is made. This service may only be called from the BSP. 88e7938b5a869fc42df7f026752f39ea85090eb3f9Chen Fan 89e7938b5a869fc42df7f026752f39ea85090eb3f9Chen Fan This service retrieves detailed MP-related information about any processor 90e7938b5a869fc42df7f026752f39ea85090eb3f9Chen Fan on the platform. Note the following: 91e7938b5a869fc42df7f026752f39ea85090eb3f9Chen Fan - The processor information may change during the course of a boot session. 92e7938b5a869fc42df7f026752f39ea85090eb3f9Chen Fan - The information presented here is entirely MP related. 93e7938b5a869fc42df7f026752f39ea85090eb3f9Chen Fan 94e7938b5a869fc42df7f026752f39ea85090eb3f9Chen Fan Information regarding the number of caches and their sizes, frequency of operation, 95e7938b5a869fc42df7f026752f39ea85090eb3f9Chen Fan slot numbers is all considered platform-related information and is not provided 96e7938b5a869fc42df7f026752f39ea85090eb3f9Chen Fan by this service. 97e7938b5a869fc42df7f026752f39ea85090eb3f9Chen Fan 98e7938b5a869fc42df7f026752f39ea85090eb3f9Chen Fan @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL 99e7938b5a869fc42df7f026752f39ea85090eb3f9Chen Fan instance. 100e7938b5a869fc42df7f026752f39ea85090eb3f9Chen Fan @param[in] ProcessorNumber The handle number of processor. 101e7938b5a869fc42df7f026752f39ea85090eb3f9Chen Fan @param[out] ProcessorInfoBuffer A pointer to the buffer where information for 102e7938b5a869fc42df7f026752f39ea85090eb3f9Chen Fan the requested processor is deposited. 103e7938b5a869fc42df7f026752f39ea85090eb3f9Chen Fan 104e7938b5a869fc42df7f026752f39ea85090eb3f9Chen Fan @retval EFI_SUCCESS Processor information was returned. 105e7938b5a869fc42df7f026752f39ea85090eb3f9Chen Fan @retval EFI_DEVICE_ERROR The calling processor is an AP. 106e7938b5a869fc42df7f026752f39ea85090eb3f9Chen Fan @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL. 107e7938b5a869fc42df7f026752f39ea85090eb3f9Chen Fan @retval EFI_NOT_FOUND The processor with the handle specified by 108e7938b5a869fc42df7f026752f39ea85090eb3f9Chen Fan ProcessorNumber does not exist in the platform. 109e7938b5a869fc42df7f026752f39ea85090eb3f9Chen Fan 110e7938b5a869fc42df7f026752f39ea85090eb3f9Chen Fan**/ 111e7938b5a869fc42df7f026752f39ea85090eb3f9Chen FanEFI_STATUS 112e7938b5a869fc42df7f026752f39ea85090eb3f9Chen FanEFIAPI 113e7938b5a869fc42df7f026752f39ea85090eb3f9Chen FanGetProcessorInfo ( 114e7938b5a869fc42df7f026752f39ea85090eb3f9Chen Fan IN EFI_MP_SERVICES_PROTOCOL *This, 115e7938b5a869fc42df7f026752f39ea85090eb3f9Chen Fan IN UINTN ProcessorNumber, 116e7938b5a869fc42df7f026752f39ea85090eb3f9Chen Fan OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer 117e7938b5a869fc42df7f026752f39ea85090eb3f9Chen Fan ) 118e7938b5a869fc42df7f026752f39ea85090eb3f9Chen Fan{ 1197fadaacd50d716e8e054a94c20db56cca98e961eJeff Fan return MpInitLibGetProcessorInfo (ProcessorNumber, ProcessorInfoBuffer, NULL); 120e7938b5a869fc42df7f026752f39ea85090eb3f9Chen Fan} 121e7938b5a869fc42df7f026752f39ea85090eb3f9Chen Fan 122e7938b5a869fc42df7f026752f39ea85090eb3f9Chen Fan/** 1235fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan This service executes a caller provided function on all enabled APs. APs can 1245fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan run either simultaneously or one at a time in sequence. This service supports 1255fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan both blocking and non-blocking requests. The non-blocking requests use EFI 1265fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan events so the BSP can detect when the APs have finished. This service may only 1275fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan be called from the BSP. 1285fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan 1295fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan This function is used to dispatch all the enabled APs to the function specified 1305fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan by Procedure. If any enabled AP is busy, then EFI_NOT_READY is returned 1315fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan immediately and Procedure is not started on any AP. 1325fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan 1335fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan If SingleThread is TRUE, all the enabled APs execute the function specified by 1345fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan Procedure one by one, in ascending order of processor handle number. Otherwise, 1355fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan all the enabled APs execute the function specified by Procedure simultaneously. 1365fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan 1375fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan If WaitEvent is NULL, execution is in blocking mode. The BSP waits until all 1385fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan APs finish or TimeoutInMicroseconds expires. Otherwise, execution is in non-blocking 1395fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan mode, and the BSP returns from this service without waiting for APs. If a 1405fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan non-blocking mode is requested after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT 1415fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan is signaled, then EFI_UNSUPPORTED must be returned. 1425fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan 1435fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan If the timeout specified by TimeoutInMicroseconds expires before all APs return 1445fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan from Procedure, then Procedure on the failed APs is terminated. All enabled APs 1455fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan are always available for further calls to EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() 1465fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan and EFI_MP_SERVICES_PROTOCOL.StartupThisAP(). If FailedCpuList is not NULL, its 1475fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan content points to the list of processor handle numbers in which Procedure was 1485fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan terminated. 1495fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan 1505fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan Note: It is the responsibility of the consumer of the EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() 1515fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan to make sure that the nature of the code that is executed on the BSP and the 1525fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan dispatched APs is well controlled. The MP Services Protocol does not guarantee 1535fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan that the Procedure function is MP-safe. Hence, the tasks that can be run in 1545fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan parallel are limited to certain independent tasks and well-controlled exclusive 1555fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan code. EFI services and protocols may not be called by APs unless otherwise 1565fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan specified. 1575fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan 1585fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan In blocking execution mode, BSP waits until all APs finish or 1595fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan TimeoutInMicroseconds expires. 1605fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan 1615fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan In non-blocking execution mode, BSP is freed to return to the caller and then 1625fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan proceed to the next task without having to wait for APs. The following 1635fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan sequence needs to occur in a non-blocking execution mode: 1645fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan 1655fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan -# The caller that intends to use this MP Services Protocol in non-blocking 1665fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan mode creates WaitEvent by calling the EFI CreateEvent() service. The caller 1675fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan invokes EFI_MP_SERVICES_PROTOCOL.StartupAllAPs(). If the parameter WaitEvent 1685fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan is not NULL, then StartupAllAPs() executes in non-blocking mode. It requests 1695fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan the function specified by Procedure to be started on all the enabled APs, 1705fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan and releases the BSP to continue with other tasks. 1715fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan -# The caller can use the CheckEvent() and WaitForEvent() services to check 1725fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan the state of the WaitEvent created in step 1. 1735fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan -# When the APs complete their task or TimeoutInMicroSecondss expires, the MP 1745fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan Service signals WaitEvent by calling the EFI SignalEvent() function. If 1755fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan FailedCpuList is not NULL, its content is available when WaitEvent is 1765fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan signaled. If all APs returned from Procedure prior to the timeout, then 1775fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan FailedCpuList is set to NULL. If not all APs return from Procedure before 1785fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan the timeout, then FailedCpuList is filled in with the list of the failed 1795fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan APs. The buffer is allocated by MP Service Protocol using AllocatePool(). 1805fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan It is the caller's responsibility to free the buffer with FreePool() service. 1815fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan -# This invocation of SignalEvent() function informs the caller that invoked 1825fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() that either all the APs completed 1835fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan the specified task or a timeout occurred. The contents of FailedCpuList 1845fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan can be examined to determine which APs did not complete the specified task 1855fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan prior to the timeout. 1865fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan 1875fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL 1885fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan instance. 1895fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan @param[in] Procedure A pointer to the function to be run on 1905fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan enabled APs of the system. See type 1915fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan EFI_AP_PROCEDURE. 1925fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan @param[in] SingleThread If TRUE, then all the enabled APs execute 1935fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan the function specified by Procedure one by 1945fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan one, in ascending order of processor handle 1955fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan number. If FALSE, then all the enabled APs 1965fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan execute the function specified by Procedure 1975fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan simultaneously. 1985fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan @param[in] WaitEvent The event created by the caller with CreateEvent() 1995fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan service. If it is NULL, then execute in 2005fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan blocking mode. BSP waits until all APs finish 2015fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan or TimeoutInMicroseconds expires. If it's 2025fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan not NULL, then execute in non-blocking mode. 2035fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan BSP requests the function specified by 2045fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan Procedure to be started on all the enabled 2055fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan APs, and go on executing immediately. If 2065fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan all return from Procedure, or TimeoutInMicroseconds 2075fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan expires, this event is signaled. The BSP 2085fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan can use the CheckEvent() or WaitForEvent() 2095fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan services to check the state of event. Type 2105fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan EFI_EVENT is defined in CreateEvent() in 2115fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan the Unified Extensible Firmware Interface 2125fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan Specification. 2135fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for 2145fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan APs to return from Procedure, either for 2155fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan blocking or non-blocking mode. Zero means 2165fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan infinity. If the timeout expires before 2175fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan all APs return from Procedure, then Procedure 2185fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan on the failed APs is terminated. All enabled 2195fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan APs are available for next function assigned 2205fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan by EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() 2215fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan or EFI_MP_SERVICES_PROTOCOL.StartupThisAP(). 2225fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan If the timeout expires in blocking mode, 2235fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan BSP returns EFI_TIMEOUT. If the timeout 2245fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan expires in non-blocking mode, WaitEvent 2255fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan is signaled with SignalEvent(). 2265fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan @param[in] ProcedureArgument The parameter passed into Procedure for 2275fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan all APs. 2285fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan @param[out] FailedCpuList If NULL, this parameter is ignored. Otherwise, 2295fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan if all APs finish successfully, then its 2305fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan content is set to NULL. If not all APs 2315fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan finish before timeout expires, then its 2325fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan content is set to address of the buffer 2335fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan holding handle numbers of the failed APs. 2345fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan The buffer is allocated by MP Service Protocol, 2355fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan and it's the caller's responsibility to 2365fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan free the buffer with FreePool() service. 2375fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan In blocking mode, it is ready for consumption 2385fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan when the call returns. In non-blocking mode, 2395fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan it is ready when WaitEvent is signaled. The 2405fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan list of failed CPU is terminated by 2415fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan END_OF_CPU_LIST. 2425fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan 2435fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan @retval EFI_SUCCESS In blocking mode, all APs have finished before 2445fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan the timeout expired. 2455fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan @retval EFI_SUCCESS In non-blocking mode, function has been dispatched 2465fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan to all enabled APs. 2475fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan @retval EFI_UNSUPPORTED A non-blocking mode request was made after the 2485fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was 2495fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan signaled. 2505fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan @retval EFI_DEVICE_ERROR Caller processor is AP. 2515fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan @retval EFI_NOT_STARTED No enabled APs exist in the system. 2525fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan @retval EFI_NOT_READY Any enabled APs are busy. 2535fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan @retval EFI_TIMEOUT In blocking mode, the timeout expired before 2545fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan all enabled APs have finished. 2555fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan @retval EFI_INVALID_PARAMETER Procedure is NULL. 2565fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan 2575fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan**/ 2585fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen FanEFI_STATUS 2595fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen FanEFIAPI 2605fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen FanStartupAllAPs ( 2615fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan IN EFI_MP_SERVICES_PROTOCOL *This, 2625fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan IN EFI_AP_PROCEDURE Procedure, 2635fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan IN BOOLEAN SingleThread, 2645fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan IN EFI_EVENT WaitEvent OPTIONAL, 2655fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan IN UINTN TimeoutInMicroseconds, 2665fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan IN VOID *ProcedureArgument OPTIONAL, 2675fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan OUT UINTN **FailedCpuList OPTIONAL 2685fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan ) 2695fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan{ 2707fadaacd50d716e8e054a94c20db56cca98e961eJeff Fan return MpInitLibStartupAllAPs ( 2717fadaacd50d716e8e054a94c20db56cca98e961eJeff Fan Procedure, 2727fadaacd50d716e8e054a94c20db56cca98e961eJeff Fan SingleThread, 2737fadaacd50d716e8e054a94c20db56cca98e961eJeff Fan WaitEvent, 2747fadaacd50d716e8e054a94c20db56cca98e961eJeff Fan TimeoutInMicroseconds, 2757fadaacd50d716e8e054a94c20db56cca98e961eJeff Fan ProcedureArgument, 2767fadaacd50d716e8e054a94c20db56cca98e961eJeff Fan FailedCpuList 2777fadaacd50d716e8e054a94c20db56cca98e961eJeff Fan ); 2785fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan} 2795fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan 2805fee172fb75ba07df4638abfd0cfc0ce83fc1073Chen Fan/** 2813f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan This service lets the caller get one enabled AP to execute a caller-provided 2823f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan function. The caller can request the BSP to either wait for the completion 2833f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan of the AP or just proceed with the next task by using the EFI event mechanism. 2843f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan See EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() for more details on non-blocking 2853f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan execution support. This service may only be called from the BSP. 2863f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan 2873f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan This function is used to dispatch one enabled AP to the function specified by 2883f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan Procedure passing in the argument specified by ProcedureArgument. If WaitEvent 2893f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan is NULL, execution is in blocking mode. The BSP waits until the AP finishes or 2903f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan TimeoutInMicroSecondss expires. Otherwise, execution is in non-blocking mode. 2913f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan BSP proceeds to the next task without waiting for the AP. If a non-blocking mode 2923f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan is requested after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT is signaled, 2933f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan then EFI_UNSUPPORTED must be returned. 2943f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan 2953f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan If the timeout specified by TimeoutInMicroseconds expires before the AP returns 2963f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan from Procedure, then execution of Procedure by the AP is terminated. The AP is 2973f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan available for subsequent calls to EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() and 2983f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan EFI_MP_SERVICES_PROTOCOL.StartupThisAP(). 2993f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan 3003f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL 3013f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan instance. 302f3b91fa04adea2389c5a6d0fbd9a584d149bae09Jeff Fan @param[in] Procedure A pointer to the function to be run on the 303f3b91fa04adea2389c5a6d0fbd9a584d149bae09Jeff Fan designated AP of the system. See type 3043f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan EFI_AP_PROCEDURE. 3053f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan @param[in] ProcessorNumber The handle number of the AP. The range is 3063f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan from 0 to the total number of logical 3073f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan processors minus 1. The total number of 3083f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan logical processors can be retrieved by 3093f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). 3103f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan @param[in] WaitEvent The event created by the caller with CreateEvent() 3113f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan service. If it is NULL, then execute in 312f3b91fa04adea2389c5a6d0fbd9a584d149bae09Jeff Fan blocking mode. BSP waits until this AP finish 313f3b91fa04adea2389c5a6d0fbd9a584d149bae09Jeff Fan or TimeoutInMicroSeconds expires. If it's 3143f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan not NULL, then execute in non-blocking mode. 3153f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan BSP requests the function specified by 316f3b91fa04adea2389c5a6d0fbd9a584d149bae09Jeff Fan Procedure to be started on this AP, 317f3b91fa04adea2389c5a6d0fbd9a584d149bae09Jeff Fan and go on executing immediately. If this AP 318f3b91fa04adea2389c5a6d0fbd9a584d149bae09Jeff Fan return from Procedure or TimeoutInMicroSeconds 3193f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan expires, this event is signaled. The BSP 3203f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan can use the CheckEvent() or WaitForEvent() 3213f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan services to check the state of event. Type 3223f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan EFI_EVENT is defined in CreateEvent() in 3233f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan the Unified Extensible Firmware Interface 3243f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan Specification. 325367284e7735478b0c4ad37d8f6bf17d3c4a473d0Dandan Bi @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for 326f3b91fa04adea2389c5a6d0fbd9a584d149bae09Jeff Fan this AP to finish this Procedure, either for 3273f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan blocking or non-blocking mode. Zero means 3283f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan infinity. If the timeout expires before 329f3b91fa04adea2389c5a6d0fbd9a584d149bae09Jeff Fan this AP returns from Procedure, then Procedure 330f3b91fa04adea2389c5a6d0fbd9a584d149bae09Jeff Fan on the AP is terminated. The 331f3b91fa04adea2389c5a6d0fbd9a584d149bae09Jeff Fan AP is available for next function assigned 3323f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan by EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() 3333f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan or EFI_MP_SERVICES_PROTOCOL.StartupThisAP(). 3343f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan If the timeout expires in blocking mode, 3353f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan BSP returns EFI_TIMEOUT. If the timeout 3363f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan expires in non-blocking mode, WaitEvent 3373f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan is signaled with SignalEvent(). 338f3b91fa04adea2389c5a6d0fbd9a584d149bae09Jeff Fan @param[in] ProcedureArgument The parameter passed into Procedure on the 339f3b91fa04adea2389c5a6d0fbd9a584d149bae09Jeff Fan specified AP. 3403f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan @param[out] Finished If NULL, this parameter is ignored. In 3413f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan blocking mode, this parameter is ignored. 3423f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan In non-blocking mode, if AP returns from 3433f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan Procedure before the timeout expires, its 3443f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan content is set to TRUE. Otherwise, the 3453f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan value is set to FALSE. The caller can 3463f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan determine if the AP returned from Procedure 3473f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan by evaluating this value. 3483f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan 3493f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan @retval EFI_SUCCESS In blocking mode, specified AP finished before 3503f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan the timeout expires. 3513f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan @retval EFI_SUCCESS In non-blocking mode, the function has been 3523f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan dispatched to specified AP. 3533f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan @retval EFI_UNSUPPORTED A non-blocking mode request was made after the 3543f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was 3553f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan signaled. 3563f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan @retval EFI_DEVICE_ERROR The calling processor is an AP. 3573f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan @retval EFI_TIMEOUT In blocking mode, the timeout expired before 3583f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan the specified AP has finished. 3593f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan @retval EFI_NOT_READY The specified AP is busy. 3603f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan @retval EFI_NOT_FOUND The processor with the handle specified by 3613f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan ProcessorNumber does not exist. 3623f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or disabled AP. 3633f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan @retval EFI_INVALID_PARAMETER Procedure is NULL. 3643f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan 3653f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan**/ 3663f4f0af8724c56ed6fac052b5086e33511aa9a80Chen FanEFI_STATUS 3673f4f0af8724c56ed6fac052b5086e33511aa9a80Chen FanEFIAPI 3683f4f0af8724c56ed6fac052b5086e33511aa9a80Chen FanStartupThisAP ( 3693f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan IN EFI_MP_SERVICES_PROTOCOL *This, 3703f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan IN EFI_AP_PROCEDURE Procedure, 3713f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan IN UINTN ProcessorNumber, 3723f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan IN EFI_EVENT WaitEvent OPTIONAL, 3733f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan IN UINTN TimeoutInMicroseconds, 3743f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan IN VOID *ProcedureArgument OPTIONAL, 3753f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan OUT BOOLEAN *Finished OPTIONAL 3763f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan ) 3773f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan{ 3787fadaacd50d716e8e054a94c20db56cca98e961eJeff Fan return MpInitLibStartupThisAP ( 3797fadaacd50d716e8e054a94c20db56cca98e961eJeff Fan Procedure, 3807fadaacd50d716e8e054a94c20db56cca98e961eJeff Fan ProcessorNumber, 3817fadaacd50d716e8e054a94c20db56cca98e961eJeff Fan WaitEvent, 3827fadaacd50d716e8e054a94c20db56cca98e961eJeff Fan TimeoutInMicroseconds, 3837fadaacd50d716e8e054a94c20db56cca98e961eJeff Fan ProcedureArgument, 3847fadaacd50d716e8e054a94c20db56cca98e961eJeff Fan Finished 3857fadaacd50d716e8e054a94c20db56cca98e961eJeff Fan ); 3863f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan} 3873f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan 3883f4f0af8724c56ed6fac052b5086e33511aa9a80Chen Fan/** 389b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan This service switches the requested AP to be the BSP from that point onward. 390b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan This service changes the BSP for all purposes. This call can only be performed 391b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan by the current BSP. 392b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan 393b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan This service switches the requested AP to be the BSP from that point onward. 394b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan This service changes the BSP for all purposes. The new BSP can take over the 395b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan execution of the old BSP and continue seamlessly from where the old one left 396b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan off. This service may not be supported after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT 397b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan is signaled. 398b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan 399b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan If the BSP cannot be switched prior to the return from this service, then 400b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan EFI_UNSUPPORTED must be returned. 401b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan 402b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance. 403b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan @param[in] ProcessorNumber The handle number of AP that is to become the new 404b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan BSP. The range is from 0 to the total number of 405b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan logical processors minus 1. The total number of 406b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan logical processors can be retrieved by 407b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). 408b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an 409b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan enabled AP. Otherwise, it will be disabled. 410b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan 411b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan @retval EFI_SUCCESS BSP successfully switched. 412b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan @retval EFI_UNSUPPORTED Switching the BSP cannot be completed prior to 413b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan this service returning. 414b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan @retval EFI_UNSUPPORTED Switching the BSP is not supported. 415b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan @retval EFI_SUCCESS The calling processor is an AP. 416b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan @retval EFI_NOT_FOUND The processor with the handle specified by 417b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan ProcessorNumber does not exist. 418b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BSP or 419b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan a disabled AP. 420b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan @retval EFI_NOT_READY The specified AP is busy. 421b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan 422b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan**/ 423b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen FanEFI_STATUS 424b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen FanEFIAPI 425b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen FanSwitchBSP ( 426b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan IN EFI_MP_SERVICES_PROTOCOL *This, 427b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan IN UINTN ProcessorNumber, 428b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan IN BOOLEAN EnableOldBSP 429b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan ) 430b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan{ 4317fadaacd50d716e8e054a94c20db56cca98e961eJeff Fan return MpInitLibSwitchBSP (ProcessorNumber, EnableOldBSP); 432b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan} 433b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan 434b7c05ba5173f4ae8ccfc901755aa79dcc97ebde2Chen Fan/** 435fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan This service lets the caller enable or disable an AP from this point onward. 436fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan This service may only be called from the BSP. 437fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan 438fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan This service allows the caller enable or disable an AP from this point onward. 439fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan The caller can optionally specify the health status of the AP by Health. If 440fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan an AP is being disabled, then the state of the disabled AP is implementation 441fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan dependent. If an AP is enabled, then the implementation must guarantee that a 442fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan complete initialization sequence is performed on the AP, so the AP is in a state 443fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan that is compatible with an MP operating system. This service may not be supported 444fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT is signaled. 445fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan 446fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan If the enable or disable AP operation cannot be completed prior to the return 447fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan from this service, then EFI_UNSUPPORTED must be returned. 448fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan 449fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance. 450f3b91fa04adea2389c5a6d0fbd9a584d149bae09Jeff Fan @param[in] ProcessorNumber The handle number of AP. 451f3b91fa04adea2389c5a6d0fbd9a584d149bae09Jeff Fan The range is from 0 to the total number of 452fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan logical processors minus 1. The total number of 453fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan logical processors can be retrieved by 454fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). 455fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan @param[in] EnableAP Specifies the new state for the processor for 456fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan enabled, FALSE for disabled. 457fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan @param[in] HealthFlag If not NULL, a pointer to a value that specifies 458fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan the new health status of the AP. This flag 459fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan corresponds to StatusFlag defined in 460fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan EFI_MP_SERVICES_PROTOCOL.GetProcessorInfo(). Only 461fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan the PROCESSOR_HEALTH_STATUS_BIT is used. All other 462fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan bits are ignored. If it is NULL, this parameter 463fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan is ignored. 464fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan 465fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan @retval EFI_SUCCESS The specified AP was enabled or disabled successfully. 466fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be completed 467fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan prior to this service returning. 468fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan @retval EFI_UNSUPPORTED Enabling or disabling an AP is not supported. 469fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan @retval EFI_DEVICE_ERROR The calling processor is an AP. 470fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan @retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber 471fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan does not exist. 472fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP. 473fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan 474fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan**/ 475fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen FanEFI_STATUS 476fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen FanEFIAPI 477fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen FanEnableDisableAP ( 478fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan IN EFI_MP_SERVICES_PROTOCOL *This, 479fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan IN UINTN ProcessorNumber, 480fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan IN BOOLEAN EnableAP, 481fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan IN UINT32 *HealthFlag OPTIONAL 482fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan ) 483fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan{ 4847fadaacd50d716e8e054a94c20db56cca98e961eJeff Fan return MpInitLibEnableDisableAP (ProcessorNumber, EnableAP, HealthFlag); 485fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan} 486fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan 487fa7ce675b991bca6e18fcda8446737717ae3c1f6Chen Fan/** 488cfa2fac1f667b227a29a2219321b651c7a143071Chen Fan This return the handle number for the calling processor. This service may be 489cfa2fac1f667b227a29a2219321b651c7a143071Chen Fan called from the BSP and APs. 490cfa2fac1f667b227a29a2219321b651c7a143071Chen Fan 491cfa2fac1f667b227a29a2219321b651c7a143071Chen Fan This service returns the processor handle number for the calling processor. 492cfa2fac1f667b227a29a2219321b651c7a143071Chen Fan The returned value is in the range from 0 to the total number of logical 493cfa2fac1f667b227a29a2219321b651c7a143071Chen Fan processors minus 1. The total number of logical processors can be retrieved 494cfa2fac1f667b227a29a2219321b651c7a143071Chen Fan with EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). This service may be 495cfa2fac1f667b227a29a2219321b651c7a143071Chen Fan called from the BSP and APs. If ProcessorNumber is NULL, then EFI_INVALID_PARAMETER 496cfa2fac1f667b227a29a2219321b651c7a143071Chen Fan is returned. Otherwise, the current processors handle number is returned in 497cfa2fac1f667b227a29a2219321b651c7a143071Chen Fan ProcessorNumber, and EFI_SUCCESS is returned. 498cfa2fac1f667b227a29a2219321b651c7a143071Chen Fan 499cfa2fac1f667b227a29a2219321b651c7a143071Chen Fan @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance. 500f3b91fa04adea2389c5a6d0fbd9a584d149bae09Jeff Fan @param[out] ProcessorNumber Pointer to the handle number of AP. 501f3b91fa04adea2389c5a6d0fbd9a584d149bae09Jeff Fan The range is from 0 to the total number of 502cfa2fac1f667b227a29a2219321b651c7a143071Chen Fan logical processors minus 1. The total number of 503cfa2fac1f667b227a29a2219321b651c7a143071Chen Fan logical processors can be retrieved by 504cfa2fac1f667b227a29a2219321b651c7a143071Chen Fan EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). 505cfa2fac1f667b227a29a2219321b651c7a143071Chen Fan 506cfa2fac1f667b227a29a2219321b651c7a143071Chen Fan @retval EFI_SUCCESS The current processor handle number was returned 507cfa2fac1f667b227a29a2219321b651c7a143071Chen Fan in ProcessorNumber. 508cfa2fac1f667b227a29a2219321b651c7a143071Chen Fan @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL. 509cfa2fac1f667b227a29a2219321b651c7a143071Chen Fan 510cfa2fac1f667b227a29a2219321b651c7a143071Chen Fan**/ 511cfa2fac1f667b227a29a2219321b651c7a143071Chen FanEFI_STATUS 512cfa2fac1f667b227a29a2219321b651c7a143071Chen FanEFIAPI 513cfa2fac1f667b227a29a2219321b651c7a143071Chen FanWhoAmI ( 514cfa2fac1f667b227a29a2219321b651c7a143071Chen Fan IN EFI_MP_SERVICES_PROTOCOL *This, 515cfa2fac1f667b227a29a2219321b651c7a143071Chen Fan OUT UINTN *ProcessorNumber 516cfa2fac1f667b227a29a2219321b651c7a143071Chen Fan ) 517cfa2fac1f667b227a29a2219321b651c7a143071Chen Fan{ 5187fadaacd50d716e8e054a94c20db56cca98e961eJeff Fan return MpInitLibWhoAmI (ProcessorNumber);; 51903673ae11e255b9467e8f317175495b1ff79f965Chen Fan} 5201535c888c6f06bb35881e83cd7ee49fb8554942bJordan Justen 5211535c888c6f06bb35881e83cd7ee49fb8554942bJordan Justen/** 522db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan Collects BIST data from HOB. 523db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan 524db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan This function collects BIST data from HOB built from Sec Platform Information 525db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan PPI or SEC Platform Information2 PPI. 526db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan 527db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan**/ 528db61e1630870069f9a3691cacd5cbd15928ec453Jeff FanVOID 529db61e1630870069f9a3691cacd5cbd15928ec453Jeff FanCollectBistDataFromHob ( 530db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan VOID 531db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan ) 532db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan{ 533db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan EFI_HOB_GUID_TYPE *GuidHob; 534db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan EFI_SEC_PLATFORM_INFORMATION_RECORD2 *SecPlatformInformation2; 535db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan EFI_SEC_PLATFORM_INFORMATION_RECORD *SecPlatformInformation; 536db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan UINTN NumberOfData; 537db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan EFI_SEC_PLATFORM_INFORMATION_CPU *CpuInstance; 538db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan EFI_SEC_PLATFORM_INFORMATION_CPU BspCpuInstance; 539db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan UINTN ProcessorNumber; 5407fadaacd50d716e8e054a94c20db56cca98e961eJeff Fan EFI_PROCESSOR_INFORMATION ProcessorInfo; 5417fadaacd50d716e8e054a94c20db56cca98e961eJeff Fan EFI_HEALTH_FLAGS BistData; 5427d17ab47d1d81c8012d8095c1e17412168c1cfc9Jeff Fan UINTN CpuInstanceNumber; 543db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan 544db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan SecPlatformInformation2 = NULL; 545db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan SecPlatformInformation = NULL; 546db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan 547db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan // 548db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan // Get gEfiSecPlatformInformation2PpiGuid Guided HOB firstly 549db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan // 550db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan GuidHob = GetFirstGuidHob (&gEfiSecPlatformInformation2PpiGuid); 551db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan if (GuidHob != NULL) { 552db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan // 553db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan // Sec Platform Information2 PPI includes BSP/APs' BIST information 554db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan // 555db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan SecPlatformInformation2 = GET_GUID_HOB_DATA (GuidHob); 556db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan NumberOfData = SecPlatformInformation2->NumberOfCpus; 557db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan CpuInstance = SecPlatformInformation2->CpuInstance; 558db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan } else { 559db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan // 560db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan // Otherwise, get gEfiSecPlatformInformationPpiGuid Guided HOB 561db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan // 562db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan GuidHob = GetFirstGuidHob (&gEfiSecPlatformInformationPpiGuid); 563db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan if (GuidHob != NULL) { 564db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan SecPlatformInformation = GET_GUID_HOB_DATA (GuidHob); 565db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan NumberOfData = 1; 566db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan // 567db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan // SEC Platform Information only includes BSP's BIST information 568db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan // does not have BSP's APIC ID 569db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan // 570db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan BspCpuInstance.CpuLocation = GetApicId (); 571db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan BspCpuInstance.InfoRecord.IA32HealthFlags.Uint32 = SecPlatformInformation->IA32HealthFlags.Uint32; 572db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan CpuInstance = &BspCpuInstance; 573db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan } else { 574db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan DEBUG ((EFI_D_INFO, "Does not find any HOB stored CPU BIST information!\n")); 575db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan // 576db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan // Does not find any HOB stored BIST information 577db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan // 578db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan return; 579db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan } 580db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan } 581db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan 5827d17ab47d1d81c8012d8095c1e17412168c1cfc9Jeff Fan for (ProcessorNumber = 0; ProcessorNumber < mNumberOfProcessors; ProcessorNumber++) { 5837d17ab47d1d81c8012d8095c1e17412168c1cfc9Jeff Fan MpInitLibGetProcessorInfo (ProcessorNumber, &ProcessorInfo, &BistData); 5847d17ab47d1d81c8012d8095c1e17412168c1cfc9Jeff Fan for (CpuInstanceNumber = 0; CpuInstanceNumber < NumberOfData; CpuInstanceNumber++) { 5857d17ab47d1d81c8012d8095c1e17412168c1cfc9Jeff Fan if (ProcessorInfo.ProcessorId == CpuInstance[CpuInstanceNumber].CpuLocation) { 586db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan // 587db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan // Update CPU health status for MP Services Protocol according to BIST data. 588db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan // 5897d17ab47d1d81c8012d8095c1e17412168c1cfc9Jeff Fan BistData = CpuInstance[CpuInstanceNumber].InfoRecord.IA32HealthFlags; 590db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan } 591db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan } 5927d17ab47d1d81c8012d8095c1e17412168c1cfc9Jeff Fan if (BistData.Uint32 != 0) { 5937d17ab47d1d81c8012d8095c1e17412168c1cfc9Jeff Fan // 5947d17ab47d1d81c8012d8095c1e17412168c1cfc9Jeff Fan // Report Status Code that self test is failed 5957d17ab47d1d81c8012d8095c1e17412168c1cfc9Jeff Fan // 5967d17ab47d1d81c8012d8095c1e17412168c1cfc9Jeff Fan REPORT_STATUS_CODE ( 5977d17ab47d1d81c8012d8095c1e17412168c1cfc9Jeff Fan EFI_ERROR_CODE | EFI_ERROR_MAJOR, 5987d17ab47d1d81c8012d8095c1e17412168c1cfc9Jeff Fan (EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_HP_EC_SELF_TEST) 5997d17ab47d1d81c8012d8095c1e17412168c1cfc9Jeff Fan ); 6007d17ab47d1d81c8012d8095c1e17412168c1cfc9Jeff Fan } 601db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan } 602db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan} 603db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan 604db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan/** 6056022e28cf744a885c278dad256d50670741ea123Jordan Justen Initialize Multi-processor support. 6066022e28cf744a885c278dad256d50670741ea123Jordan Justen 6076022e28cf744a885c278dad256d50670741ea123Jordan Justen**/ 6086022e28cf744a885c278dad256d50670741ea123Jordan JustenVOID 6096022e28cf744a885c278dad256d50670741ea123Jordan JustenInitializeMpSupport ( 6106022e28cf744a885c278dad256d50670741ea123Jordan Justen VOID 6116022e28cf744a885c278dad256d50670741ea123Jordan Justen ) 6126022e28cf744a885c278dad256d50670741ea123Jordan Justen{ 6131aa6bf528926f8f012a0f2a77bdf53374551a9ecMichael Kinney EFI_STATUS Status; 6147fadaacd50d716e8e054a94c20db56cca98e961eJeff Fan UINTN NumberOfProcessors; 6157fadaacd50d716e8e054a94c20db56cca98e961eJeff Fan UINTN NumberOfEnabledProcessors; 6164a50c2728540b9c487c9eccf19548f5322851212Chen Fan 6176a26a597a38d36c670a5c1ce0bf54c8a413a1868Chen Fan // 6180a55f3bd65783b4a8142719e257d1d49048318ceJeff Fan // Wakeup APs to do initialization 6196a26a597a38d36c670a5c1ce0bf54c8a413a1868Chen Fan // 6200a55f3bd65783b4a8142719e257d1d49048318ceJeff Fan Status = MpInitLibInitialize (); 6210a55f3bd65783b4a8142719e257d1d49048318ceJeff Fan ASSERT_EFI_ERROR (Status); 622fe078dd57f5e935c28eac7348b758ca6fb5e696fChen Fan 6230a55f3bd65783b4a8142719e257d1d49048318ceJeff Fan MpInitLibGetNumberOfProcessors (&NumberOfProcessors, &NumberOfEnabledProcessors); 6240a55f3bd65783b4a8142719e257d1d49048318ceJeff Fan mNumberOfProcessors = NumberOfProcessors; 6257fadaacd50d716e8e054a94c20db56cca98e961eJeff Fan DEBUG ((EFI_D_ERROR, "Detect CPU count: %d\n", mNumberOfProcessors)); 6261aa6bf528926f8f012a0f2a77bdf53374551a9ecMichael Kinney 6271aa6bf528926f8f012a0f2a77bdf53374551a9ecMichael Kinney // 628db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan // Update CPU healthy information from Guided HOB 629db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan // 630db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan CollectBistDataFromHob (); 631db61e1630870069f9a3691cacd5cbd15928ec453Jeff Fan 6324a50c2728540b9c487c9eccf19548f5322851212Chen Fan Status = gBS->InstallMultipleProtocolInterfaces ( 6334a50c2728540b9c487c9eccf19548f5322851212Chen Fan &mMpServiceHandle, 6344a50c2728540b9c487c9eccf19548f5322851212Chen Fan &gEfiMpServiceProtocolGuid, &mMpServicesTemplate, 6354a50c2728540b9c487c9eccf19548f5322851212Chen Fan NULL 6364a50c2728540b9c487c9eccf19548f5322851212Chen Fan ); 6374a50c2728540b9c487c9eccf19548f5322851212Chen Fan ASSERT_EFI_ERROR (Status); 6386a26a597a38d36c670a5c1ce0bf54c8a413a1868Chen Fan} 6397fadaacd50d716e8e054a94c20db56cca98e961eJeff Fan 640