5 * AMD CPU Warm Reset Implementation.
7 * Implement Warm Reset Interface.
9 * @xrefitem bom "File Content Label" "Release Content"
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 *----------------------------------------------------------------------------------------
52 #include "cpuRegisters.h"
53 #include "cpuServices.h"
54 #include "cpuFamilyTranslation.h"
59 #define FILECODE PROC_CPU_CPUWARMRESET_FILECODE
60 /*----------------------------------------------------------------------------------------
61 * D E F I N I T I O N S A N D M A C R O S
62 *----------------------------------------------------------------------------------------
65 /*----------------------------------------------------------------------------------------
66 * T Y P E D E F S A N D S T R U C T U R E S
67 *----------------------------------------------------------------------------------------
70 /*----------------------------------------------------------------------------------------
71 * 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
72 *----------------------------------------------------------------------------------------
75 /*----------------------------------------------------------------------------------------
76 * E X P O R T E D F U N C T I O N S
77 *----------------------------------------------------------------------------------------
80 /*---------------------------------------------------------------------------------------*/
82 * This function will set the CPU register warm reset bits.
84 * Note: This function will be called by UEFI BIOS's
85 * The UEFI wrapper code should register this function, to be called back later point
86 * in time, before the wrapper code does warm reset.
88 * @param[in] StdHeader Config handle for library and services
89 * @param[in] Request Indicate warm reset status
91 *---------------------------------------------------------------------------------------
95 IN AMD_CONFIG_PARAMS *StdHeader,
96 IN WARM_RESET_REQUEST *Request
99 CPU_SPECIFIC_SERVICES *FamilySpecificServices;
100 FamilySpecificServices = NULL;
102 GetCpuServicesOfCurrentCore ((CONST CPU_SPECIFIC_SERVICES **)&FamilySpecificServices, StdHeader);
103 FamilySpecificServices->SetWarmResetFlag (FamilySpecificServices, StdHeader, Request);
106 /*---------------------------------------------------------------------------------------*/
108 * This function will get the CPU register warm reset bits.
110 * Note: This function will be called by UEFI BIOS's
111 * The UEFI wrapper code should register this function, to be called back later point
112 * in time, before the wrapper code does warm reset.
114 * @param[in] StdHeader Config handle for library and services
115 * @param[out] Request Indicate warm reset status
117 *---------------------------------------------------------------------------------------
121 IN AMD_CONFIG_PARAMS *StdHeader,
122 OUT WARM_RESET_REQUEST *Request
125 CPU_SPECIFIC_SERVICES *FamilySpecificServices;
126 FamilySpecificServices = NULL;
128 GetCpuServicesOfCurrentCore ((CONST CPU_SPECIFIC_SERVICES **)&FamilySpecificServices, StdHeader);
129 FamilySpecificServices->GetWarmResetFlag (FamilySpecificServices, StdHeader, Request);
131 switch (StdHeader->Func) {
133 Request->PostStage = (UINT8) WR_STATE_RESET;
136 Request->PostStage = (UINT8) WR_STATE_EARLY;
139 // Fall through to default case
141 Request->PostStage = (UINT8) WR_STATE_POST;
145 /*----------------------------------------------------------------------------------------
146 * E X P O R T E D F U N C T I O N S - (AGESA ONLY)
147 *----------------------------------------------------------------------------------------
152 /*---------------------------------------------------------------------------------------*/
154 * Is this boot a warm reset?
156 * This function reads the CPU register warm reset bit that is preserved after a warm reset.
157 * Which in fact gets set before issuing warm reset. We just use the BSP's register always.
159 * @param[in] StdHeader Config handle for library and services
161 * @retval TRUE Warm Reset
162 * @retval FALSE Not Warm Reset
167 IN AMD_CONFIG_PARAMS *StdHeader
171 WARM_RESET_REQUEST Request;
173 CPU_SPECIFIC_SERVICES *FamilySpecificServices;
175 FamilySpecificServices = NULL;
177 switch (StdHeader->Func) {
179 PostStage = WR_STATE_RESET;
182 PostStage = WR_STATE_EARLY;
186 PostStage = WR_STATE_POST;
190 GetCpuServicesOfCurrentCore ((CONST CPU_SPECIFIC_SERVICES **)&FamilySpecificServices, StdHeader);
191 FamilySpecificServices->GetWarmResetFlag (FamilySpecificServices, StdHeader, &Request);
193 if (Request.StateBits >= PostStage) {
202 /*---------------------------------------------------------------------------------------*/
204 * This function will set the CPU register warm reset bits at AmdInitEarly if it is
205 * currently in cold boot. To request for a warm reset, set the RequestBit to TRUE
206 * and the StateBits to (current poststage - 1)
208 * @param[in] Data The table data value (unused in this routine)
209 * @param[in] StdHeader Config handle for library and services
211 *---------------------------------------------------------------------------------------
214 SetWarmResetAtEarly (
216 IN AMD_CONFIG_PARAMS *StdHeader
219 WARM_RESET_REQUEST Request;
221 if (!IsWarmReset (StdHeader)) {
222 GetWarmResetFlag (StdHeader, &Request);
224 Request.RequestBit = TRUE;
225 Request.StateBits = (Request.PostStage - 1);
227 SetWarmResetFlag (StdHeader, &Request);
231 /*----------------------------------------------------------------------------------------
232 * L O C A L F U N C T I O N S
233 *----------------------------------------------------------------------------------------