5 * AMD AGESA CPU HW 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_CPUHWC1E_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 HwC1eFamilyServiceTable;
87 /*---------------------------------------------------------------------------------------*/
89 * Should hardware 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 HW C1e is supported.
95 * @retval FALSE HW C1e cannot be enabled.
100 IsHwC1eFeatureEnabled (
101 IN PLATFORM_CONFIGURATION *PlatformConfig,
102 IN AMD_CONFIG_PARAMS *StdHeader
107 AP_MAILBOXES ApMailboxes;
108 HW_C1E_FAMILY_SERVICES *FamilyServices;
110 ASSERT (PlatformConfig->C1eMode < MaxC1eMode);
112 C1eData = PlatformConfig->C1ePlatformData;
113 if ((PlatformConfig->C1eMode == C1eModeHardware) || (PlatformConfig->C1eMode == C1eModeHardwareSoftwareDeprecated) ||
114 (PlatformConfig->C1eMode == C1eModeAuto)) {
115 // If C1eMode is Auto, C1ePlatformData3 specifies the P_LVL3 I/O port of the platform for HW C1e
116 if (PlatformConfig->C1eMode == C1eModeAuto) {
117 C1eData = PlatformConfig->C1ePlatformData3;
119 ASSERT (C1eData < 0x10000);
120 ASSERT (C1eData != 0);
121 if ((C1eData != 0) && (C1eData < 0xFFFE)) {
122 if (!IsNonCoherentHt1 (StdHeader)) {
123 if (GetNumberOfProcessors (StdHeader) == 1) {
124 GetApMailbox (&ApMailboxes.ApMailInfo.Info, StdHeader);
125 if (ApMailboxes.ApMailInfo.Fields.ModuleType == 0) {
126 GetFeatureServicesOfCurrentCore (&HwC1eFamilyServiceTable, (CONST VOID **)&FamilyServices, StdHeader);
127 if (FamilyServices != NULL) {
128 IsEnabled = FamilyServices->IsHwC1eSupported (FamilyServices, StdHeader);
138 /*---------------------------------------------------------------------------------------*/
140 * Enable Hardware 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 InitializeHwC1eFeature (
152 IN UINT64 EntryPoint,
153 IN PLATFORM_CONFIGURATION *PlatformConfig,
154 IN AMD_CONFIG_PARAMS *StdHeader
157 AGESA_STATUS CalledStatus;
158 AGESA_STATUS AgesaStatus;
159 HW_C1E_FAMILY_SERVICES *FamilyServices;
161 AgesaStatus = AGESA_SUCCESS;
163 IDS_HDT_CONSOLE (CPU_TRACE, " HW C1e is enabled\n");
165 if (IsWarmReset (StdHeader)) {
166 GetFeatureServicesOfCurrentCore (&HwC1eFamilyServiceTable, (CONST VOID **)&FamilyServices, StdHeader);
167 CalledStatus = FamilyServices->InitializeHwC1e (FamilyServices, EntryPoint, PlatformConfig, StdHeader);
168 if (CalledStatus > AgesaStatus) {
169 AgesaStatus = CalledStatus;
175 CONST CPU_FEATURE_DESCRIPTOR ROMDATA CpuFeatureHwC1e =
178 CPU_FEAT_AFTER_PM_INIT,
179 IsHwC1eFeatureEnabled,
180 InitializeHwC1eFeature