blob: 24cb8f41ac19c71f8e634dfb39c67d3ab0dded66 [file] [log] [blame]
zbao7d94cf92012-07-02 14:19:14 +08001/* $NoKeywords:$ */
2/**
3 * @file
4 *
5 * AMD AGESA CPU Message-based C1e feature support code.
6 *
7 * Contains code that declares the AGESA CPU C1e related APIs
8 *
9 * @xrefitem bom "File Content Label" "Release Content"
10 * @e project: AGESA
11 * @e sub-project: CPU/Feature
12 * @e \$Revision: 63425 $ @e \$Date: 2011-12-22 11:24:10 -0600 (Thu, 22 Dec 2011) $
13 *
14 */
15/*
16 ******************************************************************************
17 *
Siyuan Wang641f00c2013-06-08 11:50:55 +080018 * Copyright (c) 2008 - 2012, Advanced Micro Devices, Inc.
19 * All rights reserved.
zbao7d94cf92012-07-02 14:19:14 +080020 *
Siyuan Wang641f00c2013-06-08 11:50:55 +080021 * Redistribution and use in source and binary forms, with or without
22 * modification, are permitted provided that the following conditions are met:
23 * * Redistributions of source code must retain the above copyright
24 * notice, this list of conditions and the following disclaimer.
25 * * Redistributions in binary form must reproduce the above copyright
26 * notice, this list of conditions and the following disclaimer in the
27 * documentation and/or other materials provided with the distribution.
28 * * Neither the name of Advanced Micro Devices, Inc. nor the names of
29 * its contributors may be used to endorse or promote products derived
30 * from this software without specific prior written permission.
zbao7d94cf92012-07-02 14:19:14 +080031 *
Siyuan Wang641f00c2013-06-08 11:50:55 +080032 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
33 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
35 * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
36 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
37 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
38 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
39 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
41 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
zbao7d94cf92012-07-02 14:19:14 +080042 ******************************************************************************
43 */
44
45/*----------------------------------------------------------------------------------------
46 * M O D U L E S U S E D
47 *----------------------------------------------------------------------------------------
48 */
49#include "AGESA.h"
50#include "amdlib.h"
51#include "Ids.h"
52#include "OptionMultiSocket.h"
53#include "cpuRegisters.h"
54#include "cpuApicUtilities.h"
55#include "cpuServices.h"
56#include "cpuFamilyTranslation.h"
57#include "cpuFeatures.h"
58#include "cpuMsgBasedC1e.h"
59#include "Filecode.h"
60CODE_GROUP (G1_PEICC)
61RDATA_GROUP (G1_PEICC)
62
63#define FILECODE PROC_CPU_FEATURE_CPUMSGBASEDC1E_FILECODE
64/*----------------------------------------------------------------------------------------
65 * D E F I N I T I O N S A N D M A C R O S
66 *----------------------------------------------------------------------------------------
67 */
68
69/*----------------------------------------------------------------------------------------
70 * T Y P E D E F S A N D S T R U C T U R E S
71 *----------------------------------------------------------------------------------------
72 */
73
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 *----------------------------------------------------------------------------------------
77 */
78VOID
79STATIC
80EnableMsgC1eOnSocket (
81 IN VOID *EntryPoint,
82 IN AMD_CONFIG_PARAMS *StdHeader,
83 IN AMD_CPU_EARLY_PARAMS *CpuEarlyParams
84 );
85
86/*----------------------------------------------------------------------------------------
87 * E X P O R T E D F U N C T I O N S
88 *----------------------------------------------------------------------------------------
89 */
90extern CPU_FAMILY_SUPPORT_TABLE MsgBasedC1eFamilyServiceTable;
91extern OPTION_MULTISOCKET_CONFIGURATION OptionMultiSocketConfiguration;
92
93/*---------------------------------------------------------------------------------------*/
94/**
95 * Should message-based C1e be enabled
96 *
97 * @param[in] PlatformConfig Contains the runtime modifiable feature input data.
98 * @param[in] StdHeader Config Handle for library, services.
99 *
100 * @retval TRUE Message-based C1e is supported.
101 * @retval FALSE Message-based C1e cannot be enabled.
102 *
103 */
104BOOLEAN
105STATIC
106IsMsgBasedC1eFeatureEnabled (
107 IN PLATFORM_CONFIGURATION *PlatformConfig,
108 IN AMD_CONFIG_PARAMS *StdHeader
109 )
110{
111 BOOLEAN IsEnabled;
112 UINT32 Socket;
113 MSG_BASED_C1E_FAMILY_SERVICES *FamilyServices;
114
115 ASSERT (PlatformConfig->C1eMode < MaxC1eMode);
116
117 IsEnabled = FALSE;
118 if ((PlatformConfig->C1eMode == C1eModeMsgBased) || (PlatformConfig->C1eMode == C1eModeAuto)) {
119 ASSERT (PlatformConfig->C1ePlatformData < 0x10000);
120 ASSERT (PlatformConfig->C1ePlatformData != 0);
121 if ((PlatformConfig->C1ePlatformData != 0) && (PlatformConfig->C1ePlatformData < 0xFFFE)) {
122 IsEnabled = TRUE;
123 if (IsNonCoherentHt1 (StdHeader)) {
124 IsEnabled = FALSE;
125 } else {
126 for (Socket = 0; Socket < GetPlatformNumberOfSockets (); Socket++) {
127 if (IsProcessorPresent (Socket, StdHeader)) {
128 GetFeatureServicesOfSocket (&MsgBasedC1eFamilyServiceTable, Socket, (CONST VOID **)&FamilyServices, StdHeader);
129 if ((FamilyServices == NULL) || !FamilyServices->IsMsgBasedC1eSupported (FamilyServices, Socket, StdHeader)) {
130 IsEnabled = FALSE;
131 break;
132 }
133 }
134 }
135 }
136 }
137 }
138 return IsEnabled;
139}
140
141/*---------------------------------------------------------------------------------------*/
142/**
143 * Enable Message-based C1e
144 *
145 * @param[in] EntryPoint Timepoint designator.
146 * @param[in] PlatformConfig Contains the runtime modifiable feature input data.
147 * @param[in] StdHeader Config Handle for library, services.
148 *
149 * @return AGESA_SUCCESS Always succeeds.
150 *
151 */
152AGESA_STATUS
153STATIC
154InitializeMsgBasedC1eFeature (
155 IN UINT64 EntryPoint,
156 IN PLATFORM_CONFIGURATION *PlatformConfig,
157 IN AMD_CONFIG_PARAMS *StdHeader
158 )
159{
160 AP_TASK TaskPtr;
161 AMD_CPU_EARLY_PARAMS CpuEarlyParams;
162
163 IDS_HDT_CONSOLE (CPU_TRACE, " MT C1e is enabled\n");
164
165 if ((EntryPoint != CPU_FEAT_AFTER_PM_INIT) || (IsWarmReset (StdHeader))) {
166 CpuEarlyParams.PlatformConfig = *PlatformConfig;
167
168 TaskPtr.FuncAddress.PfApTaskIC = EnableMsgC1eOnSocket;
169 TaskPtr.DataTransfer.DataSizeInDwords = 2;
170 TaskPtr.DataTransfer.DataPtr = &EntryPoint;
171 TaskPtr.DataTransfer.DataTransferFlags = 0;
172 TaskPtr.ExeFlags = PASS_EARLY_PARAMS;
173 OptionMultiSocketConfiguration.BscRunCodeOnAllSystemCore0s (&TaskPtr, StdHeader, &CpuEarlyParams);
174 }
175 return AGESA_SUCCESS;
176}
177
178
179/*---------------------------------------------------------------------------------------*/
180/**
181 * 'Local' core 0 task to enable message-based C1e on it's socket.
182 *
183 * @param[in] EntryPoint Timepoint designator.
184 * @param[in] StdHeader Config Handle for library, services.
185 * @param[in] CpuEarlyParams Service parameters.
186 *
187 */
188VOID
189STATIC
190EnableMsgC1eOnSocket (
191 IN VOID *EntryPoint,
192 IN AMD_CONFIG_PARAMS *StdHeader,
193 IN AMD_CPU_EARLY_PARAMS *CpuEarlyParams
194 )
195{
196 MSG_BASED_C1E_FAMILY_SERVICES *FamilyServices;
197
198 GetFeatureServicesOfCurrentCore (&MsgBasedC1eFamilyServiceTable, (CONST VOID **)&FamilyServices, StdHeader);
199 FamilyServices->InitializeMsgBasedC1e (FamilyServices,
200 *((UINT64 *) EntryPoint),
201 &CpuEarlyParams->PlatformConfig,
202 StdHeader);
203}
204
205CONST CPU_FEATURE_DESCRIPTOR ROMDATA CpuFeatureMsgBasedC1e =
206{
207 MsgBasedC1e,
208 (CPU_FEAT_AFTER_PM_INIT | CPU_FEAT_AFTER_POST_MTRR_SYNC | CPU_FEAT_AFTER_RESUME_MTRR_SYNC),
209 IsMsgBasedC1eFeatureEnabled,
210 InitializeMsgBasedC1eFeature
211};