2 CPU Register Table Library functions.
4 Copyright (c) 2017, 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.
17 #include <Library/UefiBootServicesTableLib.h>
19 #include "RegisterCpuFeatures.h"
21 CPU_FEATURES_DATA mCpuFeaturesData
= {0};
22 EFI_MP_SERVICES_PROTOCOL
*mCpuFeaturesMpServices
= NULL
;
25 Worker function to get CPU_FEATURES_DATA pointer.
27 @return Pointer to CPU_FEATURES_DATA.
34 return &mCpuFeaturesData
;
38 Worker function to get EFI_MP_SERVICES_PROTOCOL pointer.
40 @return Pointer to EFI_MP_SERVICES_PROTOCOL.
42 EFI_MP_SERVICES_PROTOCOL
*
49 if (mCpuFeaturesMpServices
== NULL
) {
51 // Get MP Services Protocol
53 Status
= gBS
->LocateProtocol (
54 &gEfiMpServiceProtocolGuid
,
56 (VOID
**)&mCpuFeaturesMpServices
58 ASSERT_EFI_ERROR (Status
);
61 ASSERT (mCpuFeaturesMpServices
!= NULL
);
62 return mCpuFeaturesMpServices
;
66 Worker function to return processor index.
68 @return The processor index.
77 EFI_MP_SERVICES_PROTOCOL
*MpServices
;
79 MpServices
= GetMpProtocol ();
80 Status
= MpServices
->WhoAmI(MpServices
, &ProcessorIndex
);
81 ASSERT_EFI_ERROR (Status
);
82 return ProcessorIndex
;
86 Gets detailed MP-related information on the requested processor at the
87 instant this call is made.
89 @param[in] ProcessorNumber The handle number of processor.
90 @param[out] ProcessorInfoBuffer A pointer to the buffer where information for
91 the requested processor is deposited.
93 @return Status of MpServices->GetProcessorInfo().
96 GetProcessorInformation (
97 IN UINTN ProcessorNumber
,
98 OUT EFI_PROCESSOR_INFORMATION
*ProcessorInfoBuffer
102 EFI_MP_SERVICES_PROTOCOL
*MpServices
;
104 MpServices
= GetMpProtocol ();
105 Status
= MpServices
->GetProcessorInfo (
114 Worker function to execute a caller provided function on all enabled APs.
116 @param[in] Procedure A pointer to the function to be run on
117 enabled APs of the system.
121 IN EFI_AP_PROCEDURE Procedure
125 EFI_MP_SERVICES_PROTOCOL
*MpServices
;
127 MpServices
= GetMpProtocol ();
131 Status
= MpServices
->StartupAllAPs (
140 ASSERT_EFI_ERROR (Status
);
144 Worker function to switch the requested AP to be the BSP from that point onward.
146 @param[in] ProcessorNumber The handle number of AP that is to become the new BSP.
150 IN UINTN ProcessorNumber
154 EFI_MP_SERVICES_PROTOCOL
*MpServices
;
156 MpServices
= GetMpProtocol ();
160 Status
= MpServices
->SwitchBSP (
165 ASSERT_EFI_ERROR (Status
);
169 Worker function to retrieve the number of logical processor in the platform.
171 @param[out] NumberOfCpus Pointer to the total number of logical
172 processors in the system, including the BSP
174 @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical
175 processors that exist in system, including
179 GetNumberOfProcessor (
180 OUT UINTN
*NumberOfCpus
,
181 OUT UINTN
*NumberOfEnabledProcessors
185 EFI_MP_SERVICES_PROTOCOL
*MpServices
;
187 MpServices
= GetMpProtocol ();
190 // Get the number of CPUs
192 Status
= MpServices
->GetNumberOfProcessors (
195 NumberOfEnabledProcessors
197 ASSERT_EFI_ERROR (Status
);