Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 1 | /* $NoKeywords:$ */ |
| 2 | /** |
| 3 | * @file |
| 4 | * |
| 5 | * AMD AGESA CPU HW 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'Callaghan | 1542a6f | 2014-07-06 19:24:06 +1000 | [diff] [blame] | 20 | * |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 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. |
Edward O'Callaghan | 1542a6f | 2014-07-06 19:24:06 +1000 | [diff] [blame] | 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 |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 30 | * from this software without specific prior written permission. |
Edward O'Callaghan | 1542a6f | 2014-07-06 19:24:06 +1000 | [diff] [blame] | 31 | * |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 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. |
Edward O'Callaghan | 1542a6f | 2014-07-06 19:24:06 +1000 | [diff] [blame] | 42 | * |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 43 | * *************************************************************************** |
| 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 "cpuHwC1e.h" |
| 62 | #include "Filecode.h" |
| 63 | CODE_GROUP (G1_PEICC) |
| 64 | RDATA_GROUP (G1_PEICC) |
| 65 | |
| 66 | #define FILECODE PROC_CPU_FEATURE_CPUHWC1E_FILECODE |
| 67 | /*---------------------------------------------------------------------------------------- |
| 68 | * D E F I N I T I O N S A N D M A C R O S |
| 69 | *---------------------------------------------------------------------------------------- |
| 70 | */ |
| 71 | |
| 72 | /*---------------------------------------------------------------------------------------- |
| 73 | * T Y P E D E F S A N D S T R U C T U R E S |
| 74 | *---------------------------------------------------------------------------------------- |
| 75 | */ |
| 76 | |
| 77 | /*---------------------------------------------------------------------------------------- |
| 78 | * 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 |
| 79 | *---------------------------------------------------------------------------------------- |
| 80 | */ |
| 81 | |
| 82 | /*---------------------------------------------------------------------------------------- |
| 83 | * E X P O R T E D F U N C T I O N S |
| 84 | *---------------------------------------------------------------------------------------- |
| 85 | */ |
| 86 | extern CPU_FAMILY_SUPPORT_TABLE HwC1eFamilyServiceTable; |
| 87 | |
| 88 | /*---------------------------------------------------------------------------------------*/ |
| 89 | /** |
| 90 | * Should hardware C1e be enabled |
| 91 | * |
| 92 | * @param[in] PlatformConfig Contains the runtime modifiable feature input data. |
| 93 | * @param[in] StdHeader Config Handle for library, services. |
| 94 | * |
| 95 | * @retval TRUE HW C1e is supported. |
| 96 | * @retval FALSE HW C1e cannot be enabled. |
| 97 | * |
| 98 | */ |
| 99 | BOOLEAN |
| 100 | STATIC |
| 101 | IsHwC1eFeatureEnabled ( |
| 102 | IN PLATFORM_CONFIGURATION *PlatformConfig, |
| 103 | IN AMD_CONFIG_PARAMS *StdHeader |
| 104 | ) |
| 105 | { |
| 106 | BOOLEAN IsEnabled; |
| 107 | AP_MAILBOXES ApMailboxes; |
| 108 | HW_C1E_FAMILY_SERVICES *FamilyServices; |
| 109 | |
| 110 | ASSERT (PlatformConfig->C1eMode < MaxC1eMode); |
| 111 | IsEnabled = FALSE; |
| 112 | if ((PlatformConfig->C1eMode == C1eModeHardware) || (PlatformConfig->C1eMode == C1eModeHardwareSoftwareDeprecated)) { |
| 113 | ASSERT (PlatformConfig->C1ePlatformData < 0x10000); |
| 114 | ASSERT (PlatformConfig->C1ePlatformData != 0); |
| 115 | if ((PlatformConfig->C1ePlatformData != 0) && (PlatformConfig->C1ePlatformData < 0xFFFE)) { |
| 116 | if (!IsNonCoherentHt1 (StdHeader)) { |
| 117 | if (GetNumberOfProcessors (StdHeader) == 1) { |
| 118 | GetApMailbox (&ApMailboxes.ApMailInfo.Info, StdHeader); |
| 119 | if (ApMailboxes.ApMailInfo.Fields.ModuleType == 0) { |
efdesign98 | 84cbce2 | 2011-08-04 12:09:17 -0600 | [diff] [blame] | 120 | GetFeatureServicesOfCurrentCore (&HwC1eFamilyServiceTable, (const VOID **)&FamilyServices, StdHeader); |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 121 | if (FamilyServices != NULL) { |
| 122 | IsEnabled = FamilyServices->IsHwC1eSupported (FamilyServices, StdHeader); |
| 123 | } |
| 124 | } |
| 125 | } |
| 126 | } |
| 127 | } |
| 128 | } |
| 129 | return IsEnabled; |
| 130 | } |
| 131 | |
| 132 | /*---------------------------------------------------------------------------------------*/ |
| 133 | /** |
| 134 | * Enable Hardware C1e |
| 135 | * |
| 136 | * @param[in] EntryPoint Timepoint designator. |
| 137 | * @param[in] PlatformConfig Contains the runtime modifiable feature input data. |
| 138 | * @param[in] StdHeader Config Handle for library, services. |
| 139 | * |
| 140 | * @return The most severe status of any family specific service. |
| 141 | * |
| 142 | */ |
| 143 | AGESA_STATUS |
| 144 | STATIC |
| 145 | InitializeHwC1eFeature ( |
| 146 | IN UINT64 EntryPoint, |
| 147 | IN PLATFORM_CONFIGURATION *PlatformConfig, |
| 148 | IN AMD_CONFIG_PARAMS *StdHeader |
| 149 | ) |
| 150 | { |
| 151 | AGESA_STATUS CalledStatus; |
| 152 | AGESA_STATUS AgesaStatus; |
| 153 | HW_C1E_FAMILY_SERVICES *FamilyServices; |
| 154 | |
| 155 | AgesaStatus = AGESA_SUCCESS; |
| 156 | |
| 157 | IDS_HDT_CONSOLE (CPU_TRACE, " HW C1e is enabled\n"); |
| 158 | |
| 159 | if (IsWarmReset (StdHeader)) { |
efdesign98 | 84cbce2 | 2011-08-04 12:09:17 -0600 | [diff] [blame] | 160 | GetFeatureServicesOfCurrentCore (&HwC1eFamilyServiceTable, (const VOID **)&FamilyServices, StdHeader); |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 161 | CalledStatus = FamilyServices->InitializeHwC1e (FamilyServices, EntryPoint, PlatformConfig, StdHeader); |
| 162 | if (CalledStatus > AgesaStatus) { |
| 163 | AgesaStatus = CalledStatus; |
| 164 | } |
| 165 | } |
| 166 | return AgesaStatus; |
| 167 | } |
| 168 | |
| 169 | CONST CPU_FEATURE_DESCRIPTOR ROMDATA CpuFeatureHwC1e = |
| 170 | { |
| 171 | HardwareC1e, |
| 172 | CPU_FEAT_AFTER_PM_INIT, |
| 173 | IsHwC1eFeatureEnabled, |
| 174 | InitializeHwC1eFeature |
| 175 | }; |