blob: 903ad0e316ec677692c82c24b1a06e79b462a247 [file] [log] [blame]
Frank Vibrans2b4c8312011-02-14 18:30:54 +00001/* $NoKeywords:$ */
2/**
3 * @file
4 *
5 * AMD AGESA CPU SW 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: 37157 $ @e \$Date: 2010-09-01 03:24:07 +0800 (Wed, 01 Sep 2010) $
13 *
14 */
15/*
16 *****************************************************************************
17 *
18 * Copyright (c) 2011, Advanced Micro Devices, Inc.
19 * All rights reserved.
Edward O'Callaghan1542a6f2014-07-06 19:24:06 +100020 *
Frank Vibrans2b4c8312011-02-14 18:30:54 +000021 * 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.
Edward O'Callaghan1542a6f2014-07-06 19:24:06 +100028 * * Neither the name of Advanced Micro Devices, Inc. nor the names of
29 * its contributors may be used to endorse or promote products derived
Frank Vibrans2b4c8312011-02-14 18:30:54 +000030 * from this software without specific prior written permission.
Edward O'Callaghan1542a6f2014-07-06 19:24:06 +100031 *
Frank Vibrans2b4c8312011-02-14 18:30:54 +000032 * 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.
Edward O'Callaghan1542a6f2014-07-06 19:24:06 +100042 *
Frank Vibrans2b4c8312011-02-14 18:30:54 +000043 * ***************************************************************************
44 *
45 */
46
47/*----------------------------------------------------------------------------------------
48 * M O D U L E S U S E D
49 *----------------------------------------------------------------------------------------
50 */
51#include "AGESA.h"
52#include "amdlib.h"
53#include "Ids.h"
54#include "cpuRegisters.h"
55#include "cpuApicUtilities.h"
56#include "cpuServices.h"
57#include "GeneralServices.h"
58#include "cpuFamilyTranslation.h"
59#include "Topology.h"
60#include "cpuFeatures.h"
61#include "cpuSwC1e.h"
62#include "cpuHwC1e.h"
63#include "Filecode.h"
64CODE_GROUP (G1_PEICC)
65RDATA_GROUP (G1_PEICC)
66
67#define FILECODE PROC_CPU_FEATURE_CPUSWC1E_FILECODE
68/*----------------------------------------------------------------------------------------
69 * D E F I N I T I O N S A N D M A C R O S
70 *----------------------------------------------------------------------------------------
71 */
72
73/*----------------------------------------------------------------------------------------
74 * T Y P E D E F S A N D S T R U C T U R E S
75 *----------------------------------------------------------------------------------------
76 */
77
78/*----------------------------------------------------------------------------------------
79 * 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
80 *----------------------------------------------------------------------------------------
81 */
82
83/*----------------------------------------------------------------------------------------
84 * E X P O R T E D F U N C T I O N S
85 *----------------------------------------------------------------------------------------
86 */
87extern CPU_FAMILY_SUPPORT_TABLE SwC1eFamilyServiceTable;
88
89/*---------------------------------------------------------------------------------------*/
90/**
91 * Should software C1e be enabled
92 *
93 * @param[in] PlatformConfig Contains the runtime modifiable feature input data.
94 * @param[in] StdHeader Config Handle for library, services.
95 *
96 * @retval TRUE SW C1e is supported.
97 * @retval FALSE SW C1e not supported.
98 *
99 */
100BOOLEAN
101STATIC
102IsSwC1eFeatureEnabled (
103 IN PLATFORM_CONFIGURATION *PlatformConfig,
104 IN AMD_CONFIG_PARAMS *StdHeader
105 )
106{
107 BOOLEAN IsEnabled;
108 AP_MAILBOXES ApMailboxes;
109 SW_C1E_FAMILY_SERVICES *SwFamilyServices;
110
111 ASSERT (PlatformConfig->C1eMode < MaxC1eMode);
112 IsEnabled = FALSE;
113 // Check whether software C1e is enabled only if hardware C1e is not supported or if the platform specifically
114 // uses C1eModeSoftwareDeprecated.
115 if ((PlatformConfig->C1eMode == C1eModeSoftwareDeprecated) ||
116 ((PlatformConfig->C1eMode == C1eModeHardwareSoftwareDeprecated) && (!IsFeatureEnabled (HardwareC1e, PlatformConfig, StdHeader)))) {
117 ASSERT ((PlatformConfig->C1ePlatformData1 < 0x10000) && (PlatformConfig->C1ePlatformData1 != 0));
118 ASSERT (PlatformConfig->C1ePlatformData2 < 0x100);
119 if ((PlatformConfig->C1ePlatformData1 != 0) && (PlatformConfig->C1ePlatformData1 < 0xFFFE) && (PlatformConfig->C1ePlatformData2 < 0xFF)) {
120 if (!IsNonCoherentHt1 (StdHeader)) {
121 if (GetNumberOfProcessors (StdHeader) == 1) {
122 GetApMailbox (&ApMailboxes.ApMailInfo.Info, StdHeader);
123 if (ApMailboxes.ApMailInfo.Fields.ModuleType == 0) {
efdesign9884cbce22011-08-04 12:09:17 -0600124 GetFeatureServicesOfCurrentCore (&SwC1eFamilyServiceTable, (const VOID **)&SwFamilyServices, StdHeader);
Frank Vibrans2b4c8312011-02-14 18:30:54 +0000125 if (SwFamilyServices != NULL) {
126 IsEnabled = SwFamilyServices->IsSwC1eSupported (SwFamilyServices, StdHeader);
127 }
128 }
129 }
130 }
131 }
132 }
133 return IsEnabled;
134}
135
136/*---------------------------------------------------------------------------------------*/
137/**
138 * Enable Software C1e
139 *
140 * @param[in] EntryPoint Timepoint designator.
141 * @param[in] PlatformConfig Contains the runtime modifiable feature input data.
142 * @param[in] StdHeader Config Handle for library, services.
143 *
144 * @return The most severe status of any family specific service.
145 *
146 */
147AGESA_STATUS
148STATIC
149InitializeSwC1eFeature (
150 IN UINT64 EntryPoint,
151 IN PLATFORM_CONFIGURATION *PlatformConfig,
152 IN AMD_CONFIG_PARAMS *StdHeader
153 )
154{
155 AGESA_STATUS AgesaStatus;
156 SW_C1E_FAMILY_SERVICES *FamilyServices;
157
158 AgesaStatus = AGESA_SUCCESS;
159
160 IDS_HDT_CONSOLE (CPU_TRACE, " SW C1e is enabled\n");
161
162 if (IsWarmReset (StdHeader)) {
efdesign9884cbce22011-08-04 12:09:17 -0600163 GetFeatureServicesOfCurrentCore (&SwC1eFamilyServiceTable, (const VOID **)&FamilyServices, StdHeader);
Frank Vibrans2b4c8312011-02-14 18:30:54 +0000164 AgesaStatus = FamilyServices->InitializeSwC1e (FamilyServices, EntryPoint, PlatformConfig, StdHeader);
165 }
166
167 return AgesaStatus;
168}
169
170CONST CPU_FEATURE_DESCRIPTOR ROMDATA CpuFeatureSwC1e =
171{
172 SoftwareC1e,
173 CPU_FEAT_AFTER_PM_INIT,
174 IsSwC1eFeatureEnabled,
175 InitializeSwC1eFeature
176};