5 * AMD CPU Warm Reset Implementation.
7 * Implement Warm Reset Interface.
9 * @xrefitem bom "File Content Label" "Release Content"
12 * @e \$Revision: 35136 $ @e \$Date: 2010-07-16 11:29:48 +0800 (Fri, 16 Jul 2010) $
16 *****************************************************************************
18 * Copyright (c) 2011, 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 * ***************************************************************************
47 /*----------------------------------------------------------------------------------------
48 * M O D U L E S U S E D
49 *----------------------------------------------------------------------------------------
53 #include "cpuRegisters.h"
54 #include "cpuServices.h"
55 #include "cpuFamilyTranslation.h"
59 RDATA_GROUP (G1_PEICC)
61 #define FILECODE PROC_CPU_CPUWARMRESET_FILECODE
62 /*----------------------------------------------------------------------------------------
63 * D E F I N I T I O N S A N D M A C R O S
64 *----------------------------------------------------------------------------------------
67 /*----------------------------------------------------------------------------------------
68 * T Y P E D E F S A N D S T R U C T U R E S
69 *----------------------------------------------------------------------------------------
72 /*----------------------------------------------------------------------------------------
73 * 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
74 *----------------------------------------------------------------------------------------
77 /*----------------------------------------------------------------------------------------
78 * E X P O R T E D F U N C T I O N S
79 *----------------------------------------------------------------------------------------
82 /*---------------------------------------------------------------------------------------*/
84 * This function will set the CPU register warm reset bits.
86 * Note: This function will be called by UEFI BIOS's
87 * The UEFI wrapper code should register this function, to be called back later point
88 * in time, before the wrapper code does warm reset.
90 * @param[in] StdHeader Config handle for library and services
91 * @param[in] Request Indicate warm reset status
93 *---------------------------------------------------------------------------------------
97 IN AMD_CONFIG_PARAMS *StdHeader,
98 IN WARM_RESET_REQUEST *Request
101 CPU_SPECIFIC_SERVICES *FamilySpecificServices;
102 FamilySpecificServices = NULL;
104 GetCpuServicesOfCurrentCore ((const CPU_SPECIFIC_SERVICES **)&FamilySpecificServices, StdHeader);
105 FamilySpecificServices->SetWarmResetFlag (FamilySpecificServices, StdHeader, Request);
108 /*---------------------------------------------------------------------------------------*/
110 * This function will get the CPU register warm reset bits.
112 * Note: This function will be called by UEFI BIOS's
113 * The UEFI wrapper code should register this function, to be called back later point
114 * in time, before the wrapper code does warm reset.
116 * @param[in] StdHeader Config handle for library and services
117 * @param[out] Request Indicate warm reset status
119 *---------------------------------------------------------------------------------------
123 IN AMD_CONFIG_PARAMS *StdHeader,
124 OUT WARM_RESET_REQUEST *Request
127 CPU_SPECIFIC_SERVICES *FamilySpecificServices;
128 FamilySpecificServices = NULL;
130 GetCpuServicesOfCurrentCore ((const CPU_SPECIFIC_SERVICES **)&FamilySpecificServices, StdHeader);
131 FamilySpecificServices->GetWarmResetFlag (FamilySpecificServices, StdHeader, Request);
133 switch (StdHeader->Func) {
135 Request->PostStage = (UINT8) WR_STATE_RESET;
138 Request->PostStage = (UINT8) WR_STATE_EARLY;
141 // Fall through to default case
143 Request->PostStage = (UINT8) WR_STATE_POST;
147 /*----------------------------------------------------------------------------------------
148 * E X P O R T E D F U N C T I O N S - (AGESA ONLY)
149 *----------------------------------------------------------------------------------------
154 /*---------------------------------------------------------------------------------------*/
156 * Is this boot a warm reset?
158 * This function reads the CPU register warm reset bit that is preserved after a warm reset.
159 * Which in fact gets set before issuing warm reset. We just use the BSP's register always.
161 * @param[in] StdHeader Config handle for library and services
163 * @retval TRUE Warm Reset
164 * @retval FALSE Not Warm Reset
169 IN AMD_CONFIG_PARAMS *StdHeader
173 WARM_RESET_REQUEST Request;
175 CPU_SPECIFIC_SERVICES *FamilySpecificServices;
177 FamilySpecificServices = NULL;
179 switch (StdHeader->Func) {
181 PostStage = WR_STATE_RESET;
184 PostStage = WR_STATE_EARLY;
188 PostStage = WR_STATE_POST;
192 GetCpuServicesOfCurrentCore ((const CPU_SPECIFIC_SERVICES **)&FamilySpecificServices, StdHeader);
193 FamilySpecificServices->GetWarmResetFlag (FamilySpecificServices, StdHeader, &Request);
195 if (Request.StateBits >= PostStage) {
204 /*---------------------------------------------------------------------------------------*/
206 * This function will set the CPU register warm reset bits at AmdInitEarly if it is
207 * currently in cold boot. To request for a warm reset, set the RequestBit to TRUE
208 * and the StateBits to (current poststage - 1)
210 * @param[in] Data The table data value (unused in this routine)
211 * @param[in] StdHeader Config handle for library and services
213 *---------------------------------------------------------------------------------------
216 SetWarmResetAtEarly (
218 IN AMD_CONFIG_PARAMS *StdHeader
221 WARM_RESET_REQUEST Request;
223 if (!IsWarmReset (StdHeader)) {
224 GetWarmResetFlag (StdHeader, &Request);
226 Request.RequestBit = TRUE;
227 Request.StateBits = (Request.PostStage - 1);
229 SetWarmResetFlag (StdHeader, &Request);
233 /*----------------------------------------------------------------------------------------
234 * L O C A L F U N C T I O N S
235 *----------------------------------------------------------------------------------------