5 * Implement general feature dispatcher.
7 * @xrefitem bom "File Content Label" "Release Content"
10 * @e \$Revision: 56279 $ @e \$Date: 2011-07-11 13:11:28 -0600 (Mon, 11 Jul 2011) $
14 ******************************************************************************
16 * Copyright (C) 2012 Advanced Micro Devices, Inc.
17 * All rights reserved.
19 * Redistribution and use in source and binary forms, with or without
20 * modification, are permitted provided that the following conditions are met:
21 * * Redistributions of source code must retain the above copyright
22 * notice, this list of conditions and the following disclaimer.
23 * * Redistributions in binary form must reproduce the above copyright
24 * notice, this list of conditions and the following disclaimer in the
25 * documentation and/or other materials provided with the distribution.
26 * * Neither the name of Advanced Micro Devices, Inc. nor the names of
27 * its contributors may be used to endorse or promote products derived
28 * from this software without specific prior written permission.
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
31 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
32 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
33 * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
34 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
35 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
37 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
39 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 ******************************************************************************
44 /*----------------------------------------------------------------------------------------
45 * M O D U L E S U S E D
46 *----------------------------------------------------------------------------------------
50 #include "GeneralServices.h"
51 #include "cpuFeatures.h"
52 #include "cpuFamilyTranslation.h"
56 #define FILECODE PROC_CPU_FEATURE_CPUFEATURES_FILECODE
57 /*----------------------------------------------------------------------------------------
58 * D E F I N I T I O N S A N D M A C R O S
59 *----------------------------------------------------------------------------------------
62 /*----------------------------------------------------------------------------------------
63 * T Y P E D E F S A N D S T R U C T U R E S
64 *----------------------------------------------------------------------------------------
67 /*----------------------------------------------------------------------------------------
68 * 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
69 *----------------------------------------------------------------------------------------
72 /*----------------------------------------------------------------------------------------
73 * E X P O R T E D F U N C T I O N S - External General Services API
74 *----------------------------------------------------------------------------------------
76 extern CONST CPU_FEATURE_DESCRIPTOR* ROMDATA SupportedCpuFeatureList[];
79 * Determines if a specific feature is or will be enabled.
81 * This code traverses the feature list until a match is
82 * found, then invokes the 'IsEnabled' function of the
85 * @param[in] Feature Indicates the desired feature.
86 * @param[in] PlatformConfig Contains the runtime modifiable feature input data.
87 * @param[in] StdHeader Standard AMD configuration parameters.
89 * @retval TRUE Feature is or will be enabled
90 * @retval FALSE Feature is not enabled
94 IN DISPATCHABLE_CPU_FEATURES Feature,
95 IN PLATFORM_CONFIGURATION *PlatformConfig,
96 IN AMD_CONFIG_PARAMS *StdHeader
101 ASSERT (Feature < MaxCpuFeature);
103 for (i = 0; SupportedCpuFeatureList[i] != NULL; i++) {
104 if (SupportedCpuFeatureList[i]->Feature == Feature) {
105 return (SupportedCpuFeatureList[i]->IsEnabled (PlatformConfig, StdHeader));
112 * Dispatches all features needing to perform some initialization at
115 * This routine searches the feature table for features needing to
116 * run at this time point, and invokes them.
118 * @param[in] EntryPoint Timepoint designator
119 * @param[in] PlatformConfig Contains the runtime modifiable feature input data.
120 * @param[in] StdHeader Standard AMD configuration parameters.
122 * @return The most severe status of any called service.
125 DispatchCpuFeatures (
126 IN UINT64 EntryPoint,
127 IN PLATFORM_CONFIGURATION *PlatformConfig,
128 IN AMD_CONFIG_PARAMS *StdHeader
132 AGESA_STATUS AgesaStatus;
133 AGESA_STATUS CalledStatus;
134 AGESA_STATUS IgnoredStatus;
136 AgesaStatus = AGESA_SUCCESS;
138 if (IsBsp (StdHeader, &IgnoredStatus)) {
139 for (i = 0; SupportedCpuFeatureList[i] != NULL; i++) {
140 if ((SupportedCpuFeatureList[i]->EntryPoint & EntryPoint) != 0) {
141 IDS_SKIP_HOOK (IDS_CPU_FEAT, (CPU_FEATURE_DESCRIPTOR *) SupportedCpuFeatureList[i], StdHeader) {
142 if (SupportedCpuFeatureList[i]->IsEnabled (PlatformConfig, StdHeader)) {
143 CalledStatus = SupportedCpuFeatureList[i]->InitializeFeature (EntryPoint, PlatformConfig, StdHeader);
144 if (CalledStatus > AgesaStatus) {
145 AgesaStatus = CalledStatus;
156 * This routine checks whether any non-coherent links in the system
157 * runs in HT1 mode; used to determine whether certain features
158 * should be disabled when this routine returns TRUE.
160 * @param[in] StdHeader Standard AMD configuration parameters.
162 * @retval TRUE One of the non-coherent links in the
163 * system runs in HT1 mode
164 * @retval FALSE None of the non-coherent links in the
165 * system is running in HT1 mode
169 IN AMD_CONFIG_PARAMS *StdHeader
176 AGESA_STATUS AgesaStatus;
177 HT_HOST_FEATS HtHostFeats;
178 CPU_SPECIFIC_SERVICES *CpuServices;
180 for (Socket = 0; Socket < GetPlatformNumberOfSockets (); Socket++) {
181 if (IsProcessorPresent (Socket, StdHeader)) {
182 GetCpuServicesOfSocket (Socket, (const CPU_SPECIFIC_SERVICES **)&CpuServices, StdHeader);
183 for (Module = 0; Module < GetPlatformNumberOfModules (); Module++) {
184 if (GetPciAddress (StdHeader, Socket, Module, &PciAddress, &AgesaStatus)) {
185 HtHostFeats.HtHostValue = 0;
187 while (CpuServices->GetNextHtLinkFeatures (CpuServices, &Link, &PciAddress, &HtHostFeats, StdHeader)) {
188 // Return TRUE and exit routine once we find a non-coherent link in HT1
189 if ((HtHostFeats.HtHostFeatures.NonCoherent == 1) && (HtHostFeats.HtHostFeatures.Ht1 == 1)) {