2 CPU MP Initialize Library common functions.
4 Copyright (c) 2016, 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.
19 Detect whether Mwait-monitor feature is supported.
21 @retval TRUE Mwait-monitor feature is supported.
22 @retval FALSE Mwait-monitor feature is not supported.
29 CPUID_VERSION_INFO_ECX VersionInfoEcx
;
31 AsmCpuid (CPUID_VERSION_INFO
, NULL
, NULL
, &VersionInfoEcx
.Uint32
, NULL
);
32 return (VersionInfoEcx
.Bits
.MONITOR
== 1) ? TRUE
: FALSE
;
38 @param[out] MonitorFilterSize Returns the largest monitor-line size in bytes.
40 @return The AP loop mode.
44 OUT UINT32
*MonitorFilterSize
48 CPUID_MONITOR_MWAIT_EBX MonitorMwaitEbx
;
50 ASSERT (MonitorFilterSize
!= NULL
);
52 ApLoopMode
= PcdGet8 (PcdCpuApLoopMode
);
53 ASSERT (ApLoopMode
>= ApInHltLoop
&& ApLoopMode
<= ApInRunLoop
);
54 if (ApLoopMode
== ApInMwaitLoop
) {
55 if (!IsMwaitSupport ()) {
57 // If processor does not support MONITOR/MWAIT feature,
58 // force AP in Hlt-loop mode
60 ApLoopMode
= ApInHltLoop
;
64 if (ApLoopMode
!= ApInMwaitLoop
) {
65 *MonitorFilterSize
= sizeof (UINT32
);
68 // CPUID.[EAX=05H]:EBX.BIT0-15: Largest monitor-line size in bytes
69 // CPUID.[EAX=05H].EDX: C-states supported using MWAIT
71 AsmCpuid (CPUID_MONITOR_MWAIT
, NULL
, &MonitorMwaitEbx
.Uint32
, NULL
, NULL
);
72 *MonitorFilterSize
= MonitorMwaitEbx
.Bits
.LargestMonitorLineSize
;
78 MP Initialize Library initialization.
80 This service will allocate AP reset vector and wakeup all APs to do APs
83 This service must be invoked before all other MP Initialize Library
86 @retval EFI_SUCCESS MP initialization succeeds.
87 @retval Others MP initialization fails.
96 MP_ASSEMBLY_ADDRESS_MAP AddressMap
;
97 UINT32 MonitorFilterSize
;
99 UINTN ApResetVectorSize
;
101 AsmGetAddressMap (&AddressMap
);
102 ApResetVectorSize
= AddressMap
.RendezvousFunnelSize
+ sizeof (MP_CPU_EXCHANGE_INFO
);
103 ApLoopMode
= GetApLoopMode (&MonitorFilterSize
);
109 Gets detailed MP-related information on the requested processor at the
110 instant this call is made. This service may only be called from the BSP.
112 @param[in] ProcessorNumber The handle number of processor.
113 @param[out] ProcessorInfoBuffer A pointer to the buffer where information for
114 the requested processor is deposited.
115 @param[out] HealthData Return processor health data.
117 @retval EFI_SUCCESS Processor information was returned.
118 @retval EFI_DEVICE_ERROR The calling processor is an AP.
119 @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL.
120 @retval EFI_NOT_FOUND The processor with the handle specified by
121 ProcessorNumber does not exist in the platform.
122 @retval EFI_NOT_READY MP Initialize Library is not initialized.
127 MpInitLibGetProcessorInfo (
128 IN UINTN ProcessorNumber
,
129 OUT EFI_PROCESSOR_INFORMATION
*ProcessorInfoBuffer
,
130 OUT EFI_HEALTH_FLAGS
*HealthData OPTIONAL
133 return EFI_UNSUPPORTED
;
136 This return the handle number for the calling processor. This service may be
137 called from the BSP and APs.
139 @param[out] ProcessorNumber Pointer to the handle number of AP.
140 The range is from 0 to the total number of
141 logical processors minus 1. The total number of
142 logical processors can be retrieved by
143 MpInitLibGetNumberOfProcessors().
145 @retval EFI_SUCCESS The current processor handle number was returned
147 @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL.
148 @retval EFI_NOT_READY MP Initialize Library is not initialized.
154 OUT UINTN
*ProcessorNumber
157 return EFI_UNSUPPORTED
;
160 Retrieves the number of logical processor in the platform and the number of
161 those logical processors that are enabled on this boot. This service may only
162 be called from the BSP.
164 @param[out] NumberOfProcessors Pointer to the total number of logical
165 processors in the system, including the BSP
167 @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical
168 processors that exist in system, including
171 @retval EFI_SUCCESS The number of logical processors and enabled
172 logical processors was retrieved.
173 @retval EFI_DEVICE_ERROR The calling processor is an AP.
174 @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL and NumberOfEnabledProcessors
176 @retval EFI_NOT_READY MP Initialize Library is not initialized.
181 MpInitLibGetNumberOfProcessors (
182 OUT UINTN
*NumberOfProcessors
, OPTIONAL
183 OUT UINTN
*NumberOfEnabledProcessors OPTIONAL
186 return EFI_UNSUPPORTED
;