5 * AMD AGESA CPU SW C1e feature support code.
7 * Contains code that declares the AGESA CPU C1e 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) $
16 ******************************************************************************
18 * Copyright (C) 2012 Advanced Micro Devices, Inc.
19 * All rights reserved.
21 * 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.
32 * 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.
43 ******************************************************************************
46 /*----------------------------------------------------------------------------------------
47 * M O D U L E S U S E D
48 *----------------------------------------------------------------------------------------
53 #include "cpuRegisters.h"
54 #include "cpuApicUtilities.h"
55 #include "cpuServices.h"
56 #include "GeneralServices.h"
57 #include "cpuFamilyTranslation.h"
59 #include "cpuFeatures.h"
65 #define FILECODE PROC_CPU_FEATURE_CPUSWC1E_FILECODE
66 /*----------------------------------------------------------------------------------------
67 * D E F I N I T I O N S A N D M A C R O S
68 *----------------------------------------------------------------------------------------
71 /*----------------------------------------------------------------------------------------
72 * T Y P E D E F S A N D S T R U C T U R E S
73 *----------------------------------------------------------------------------------------
76 /*----------------------------------------------------------------------------------------
77 * 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
78 *----------------------------------------------------------------------------------------
81 /*----------------------------------------------------------------------------------------
82 * E X P O R T E D F U N C T I O N S
83 *----------------------------------------------------------------------------------------
85 extern CPU_FAMILY_SUPPORT_TABLE SwC1eFamilyServiceTable;
87 /*---------------------------------------------------------------------------------------*/
89 * Should software C1e be enabled
91 * @param[in] PlatformConfig Contains the runtime modifiable feature input data.
92 * @param[in] StdHeader Config Handle for library, services.
94 * @retval TRUE SW C1e is supported.
95 * @retval FALSE SW C1e not supported.
100 IsSwC1eFeatureEnabled (
101 IN PLATFORM_CONFIGURATION *PlatformConfig,
102 IN AMD_CONFIG_PARAMS *StdHeader
106 BOOLEAN IsOtherC1eEnabled;
107 AP_MAILBOXES ApMailboxes;
108 SW_C1E_FAMILY_SERVICES *SwFamilyServices;
110 ASSERT (PlatformConfig->C1eMode < MaxC1eMode);
113 // Check whether software C1e is enabled only if other C1e methods is/are not supported
114 // or if the platform specifically uses C1eModeSoftwareDeprecated.
115 IsOtherC1eEnabled = (IsFeatureEnabled (HardwareC1e, PlatformConfig, StdHeader) ||
116 IsFeatureEnabled (MsgBasedC1e, PlatformConfig, StdHeader));
117 if ((PlatformConfig->C1eMode == C1eModeSoftwareDeprecated) ||
118 ((!IsOtherC1eEnabled) && ((PlatformConfig->C1eMode == C1eModeHardwareSoftwareDeprecated) || (PlatformConfig->C1eMode == C1eModeAuto)))) {
119 ASSERT ((PlatformConfig->C1ePlatformData1 < 0x10000) && (PlatformConfig->C1ePlatformData1 != 0));
120 ASSERT (PlatformConfig->C1ePlatformData2 < 0x100);
121 if ((PlatformConfig->C1ePlatformData1 != 0) && (PlatformConfig->C1ePlatformData1 < 0xFFFE) && (PlatformConfig->C1ePlatformData2 < 0xFF)) {
122 if (!IsNonCoherentHt1 (StdHeader)) {
123 if (GetNumberOfProcessors (StdHeader) == 1) {
124 GetApMailbox (&ApMailboxes.ApMailInfo.Info, StdHeader);
125 if (ApMailboxes.ApMailInfo.Fields.ModuleType == 0) {
126 GetFeatureServicesOfCurrentCore (&SwC1eFamilyServiceTable, (CONST VOID **)&SwFamilyServices, StdHeader);
127 if (SwFamilyServices != NULL) {
128 IsEnabled = SwFamilyServices->IsSwC1eSupported (SwFamilyServices, StdHeader);
138 /*---------------------------------------------------------------------------------------*/
140 * Enable Software C1e
142 * @param[in] EntryPoint Timepoint designator.
143 * @param[in] PlatformConfig Contains the runtime modifiable feature input data.
144 * @param[in] StdHeader Config Handle for library, services.
146 * @return The most severe status of any family specific service.
151 InitializeSwC1eFeature (
152 IN UINT64 EntryPoint,
153 IN PLATFORM_CONFIGURATION *PlatformConfig,
154 IN AMD_CONFIG_PARAMS *StdHeader
157 AGESA_STATUS AgesaStatus;
158 SW_C1E_FAMILY_SERVICES *FamilyServices;
160 AgesaStatus = AGESA_SUCCESS;
162 IDS_HDT_CONSOLE (CPU_TRACE, " SW C1e is enabled\n");
164 if (IsWarmReset (StdHeader)) {
165 GetFeatureServicesOfCurrentCore (&SwC1eFamilyServiceTable, (CONST VOID **)&FamilyServices, StdHeader);
166 AgesaStatus = FamilyServices->InitializeSwC1e (FamilyServices, EntryPoint, PlatformConfig, StdHeader);
172 CONST CPU_FEATURE_DESCRIPTOR ROMDATA CpuFeatureSwC1e =
175 CPU_FEAT_AFTER_PM_INIT,
176 IsSwC1eFeatureEnabled,
177 InitializeSwC1eFeature