5 * AMD AGESA CPU IO Cstate function declarations.
7 * Contains code that declares the AGESA CPU IO Cstate related APIs
9 * @xrefitem bom "File Content Label" "Release Content"
11 * @e sub-project: CPU/Feature
12 * @e \$Revision: 56279 $ @e \$Date: 2011-07-11 13:11:28 -0600 (Mon, 11 Jul 2011) $
15 ******************************************************************************
17 * Copyright (C) 2012 Advanced Micro Devices, Inc.
18 * All rights reserved.
20 * Redistribution and use in source and binary forms, with or without
21 * modification, are permitted provided that the following conditions are met:
22 * * Redistributions of source code must retain the above copyright
23 * notice, this list of conditions and the following disclaimer.
24 * * Redistributions in binary form must reproduce the above copyright
25 * notice, this list of conditions and the following disclaimer in the
26 * documentation and/or other materials provided with the distribution.
27 * * Neither the name of Advanced Micro Devices, Inc. nor the names of
28 * its contributors may be used to endorse or promote products derived
29 * from this software without specific prior written permission.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
32 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
33 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
34 * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
35 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
36 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
37 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
38 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
40 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 ******************************************************************************
45 /*----------------------------------------------------------------------------------------
46 * M O D U L E S U S E D
47 *----------------------------------------------------------------------------------------
52 #include "cpuFeatures.h"
53 #include "cpuIoCstate.h"
54 #include "cpuServices.h"
55 #include "cpuFamilyTranslation.h"
56 #include "cpuApicUtilities.h"
57 #include "OptionMultiSocket.h"
62 #define FILECODE PROC_CPU_FEATURE_CPUIOCSTATE_FILECODE
64 /*----------------------------------------------------------------------------------------
65 * D E F I N I T I O N S A N D M A C R O S
66 *----------------------------------------------------------------------------------------
69 /*----------------------------------------------------------------------------------------
70 * T Y P E D E F S A N D S T R U C T U R E S
71 *----------------------------------------------------------------------------------------
74 /*----------------------------------------------------------------------------------------
75 * P R O T O T Y P E S O F L O C A L F U N C T I O N S
76 *----------------------------------------------------------------------------------------
81 EnableIoCstateOnSocket (
83 IN AMD_CONFIG_PARAMS *StdHeader,
84 IN AMD_CPU_EARLY_PARAMS *CpuEarlyParams
86 /*----------------------------------------------------------------------------------------
87 * E X P O R T E D F U N C T I O N S
88 *----------------------------------------------------------------------------------------
90 extern CPU_FAMILY_SUPPORT_TABLE IoCstateFamilyServiceTable;
91 extern OPTION_MULTISOCKET_CONFIGURATION OptionMultiSocketConfiguration;
93 /*---------------------------------------------------------------------------------------*/
95 * Should IO Cstate be enabled
96 * If all processors support IO Cstate, return TRUE. Otherwise, return FALSE
98 * @param[in] PlatformConfig Contains the runtime modifiable feature input data.
99 * @param[in] StdHeader Config Handle for library, services.
101 * @retval TRUE IO Cstate is supported.
102 * @retval FALSE IO Cstate cannot be enabled.
107 IsIoCstateFeatureSupported (
108 IN PLATFORM_CONFIGURATION *PlatformConfig,
109 IN AMD_CONFIG_PARAMS *StdHeader
114 IO_CSTATE_FAMILY_SERVICES *IoCstateServices;
117 if ((PlatformConfig->CStateIoBaseAddress != 0) && (PlatformConfig->CStateIoBaseAddress <= 0xFFF8)) {
118 for (Socket = 0; Socket < GetPlatformNumberOfSockets (); Socket++) {
119 if (IsProcessorPresent (Socket, StdHeader)) {
120 GetFeatureServicesOfSocket (&IoCstateFamilyServiceTable, Socket, (CONST VOID **)&IoCstateServices, StdHeader);
121 if (IoCstateServices != NULL) {
122 if (IoCstateServices->IsIoCstateSupported (IoCstateServices, Socket, StdHeader)) {
125 // Stop checking remaining socket(s) once we find one that does not support IO Cstates
130 // Exit the for loop if we found a socket that does not have the IO Cstates feature installed
140 /*---------------------------------------------------------------------------------------*/
142 * Enable IO Cstate feature
144 * @param[in] EntryPoint Timepoint designator.
145 * @param[in] PlatformConfig Contains the runtime modifiable feature input data.
146 * @param[in] StdHeader Config Handle for library, services.
148 * @retval AGESA_SUCCESS Always succeeds.
153 InitializeIoCstateFeature (
154 IN UINT64 EntryPoint,
155 IN PLATFORM_CONFIGURATION *PlatformConfig,
156 IN AMD_CONFIG_PARAMS *StdHeader
160 AMD_CPU_EARLY_PARAMS CpuEarlyParams;
162 IDS_HDT_CONSOLE (CPU_TRACE, " IO C-state is enabled\n");
164 CpuEarlyParams.PlatformConfig = *PlatformConfig;
166 TaskPtr.FuncAddress.PfApTaskIC = EnableIoCstateOnSocket;
167 TaskPtr.DataTransfer.DataSizeInDwords = 2;
168 TaskPtr.DataTransfer.DataPtr = &EntryPoint;
169 TaskPtr.DataTransfer.DataTransferFlags = 0;
170 TaskPtr.ExeFlags = PASS_EARLY_PARAMS;
171 OptionMultiSocketConfiguration.BscRunCodeOnAllSystemCore0s (&TaskPtr, StdHeader, &CpuEarlyParams);
173 return AGESA_SUCCESS;
176 /*---------------------------------------------------------------------------------------*/
178 * 'Local' core 0 task to enable IO Cstate on it's socket.
180 * @param[in] EntryPoint Timepoint designator.
181 * @param[in] StdHeader Config Handle for library, services.
182 * @param[in] CpuEarlyParams Service parameters.
187 EnableIoCstateOnSocket (
189 IN AMD_CONFIG_PARAMS *StdHeader,
190 IN AMD_CPU_EARLY_PARAMS *CpuEarlyParams
193 IO_CSTATE_FAMILY_SERVICES *FamilyServices;
195 GetFeatureServicesOfCurrentCore (&IoCstateFamilyServiceTable, (CONST VOID **)&FamilyServices, StdHeader);
196 FamilyServices->InitializeIoCstate (FamilyServices,
197 *((UINT64 *) EntryPoint),
198 &CpuEarlyParams->PlatformConfig,
202 CONST CPU_FEATURE_DESCRIPTOR ROMDATA CpuFeatureIoCstate =
205 (CPU_FEAT_AFTER_PM_INIT),
206 IsIoCstateFeatureSupported,
207 InitializeIoCstateFeature