5 * AMD CPU AGESA Callout Functions
7 * Contains code to set / get useful platform information.
9 * @xrefitem bom "File Content Label" "Release Content"
11 * @e sub-project: Common
12 * @e \$Revision: 50871 $ @e \$Date: 2011-04-14 15:39:51 -0600 (Thu, 14 Apr 2011) $
15 /*****************************************************************************
16 * AMD Generic Encapsulated Software Architecture
18 * Description: agesaCallouts.c - AGESA Call out functions
20 ******************************************************************************
22 * Copyright (C) 2012 Advanced Micro Devices, Inc.
23 * All rights reserved.
25 * Redistribution and use in source and binary forms, with or without
26 * modification, are permitted provided that the following conditions are met:
27 * * Redistributions of source code must retain the above copyright
28 * notice, this list of conditions and the following disclaimer.
29 * * Redistributions in binary form must reproduce the above copyright
30 * notice, this list of conditions and the following disclaimer in the
31 * documentation and/or other materials provided with the distribution.
32 * * Neither the name of Advanced Micro Devices, Inc. nor the names of
33 * its contributors may be used to endorse or promote products derived
34 * from this software without specific prior written permission.
36 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
37 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
38 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39 * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
40 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
41 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
42 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
43 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
44 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
45 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47 ******************************************************************************
50 /*----------------------------------------------------------------------------------------
51 * M O D U L E S U S E D
52 *----------------------------------------------------------------------------------------
55 #include "cpuRegisters.h"
56 #include "Dispatcher.h"
57 #include "cpuServices.h"
61 #define FILECODE LEGACY_PROC_AGESACALLOUTS_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 *----------------------------------------------------------------------------------------
83 /*----------------------------------------------------------------------------------------
84 * E X P O R T E D F U N C T I O N S - (AGESA ONLY)
85 *----------------------------------------------------------------------------------------
89 /*---------------------------------------------------------------------------------------*/
92 * Call the host environment interface to do the warm or cold reset.
94 * @param[in] ResetType Warm or Cold Reset is requested
95 * @param[in,out] StdHeader Config header
101 IN OUT AMD_CONFIG_PARAMS *StdHeader
105 WARM_RESET_REQUEST Request;
107 // Clear warm request bit and set state bits to the current post stage
108 GetWarmResetFlag (StdHeader, &Request);
109 Request.RequestBit = FALSE;
110 Request.StateBits = Request.PostStage;
111 SetWarmResetFlag (StdHeader, &Request);
113 Status = AmdAgesaCallout (AGESA_DO_RESET, (UINT32)ResetType, (VOID *) StdHeader);
116 /*---------------------------------------------------------------------------------------*/
119 * Call the host environment interface to allocate buffer in main system memory.
122 * @param[in,out] AllocParams Heap manager parameters
124 * @return The AGESA Status returned from the callout.
128 AgesaAllocateBuffer (
130 IN OUT AGESA_BUFFER_PARAMS *AllocParams
135 Status = AmdAgesaCallout (AGESA_ALLOCATE_BUFFER, (UINT32)FcnData, (VOID *) AllocParams);
141 /*---------------------------------------------------------------------------------------*/
143 * Call the host environment interface to deallocate buffer in main system memory.
146 * @param[in,out] DeallocParams Heap Manager parameters
148 * @return The AGESA Status returned from the callout.
151 AgesaDeallocateBuffer (
153 IN OUT AGESA_BUFFER_PARAMS *DeallocParams
158 Status = AmdAgesaCallout (AGESA_DEALLOCATE_BUFFER, (UINT32)FcnData, (VOID *) DeallocParams);
164 /*---------------------------------------------------------------------------------------*/
167 * Call the host environment interface to Locate buffer Pointer in main system memory
170 * @param[in,out] LocateParams Heap manager parameters
172 * @return The AGESA Status returned from the callout.
178 IN OUT AGESA_BUFFER_PARAMS *LocateParams
183 Status = AmdAgesaCallout (AGESA_LOCATE_BUFFER, (UINT32)FcnData, (VOID *) LocateParams);
189 /*---------------------------------------------------------------------------------------*/
191 * Call the host environment interface to launch APs
193 * @param[in] ApicIdOfCore
194 * @param[in,out] LaunchApParams
196 * @return The AGESA Status returned from the callout.
201 IN UINTN ApicIdOfCore,
202 IN AP_EXE_PARAMS *LaunchApParams
207 Status = AmdAgesaCallout (AGESA_RUNFUNC_ONAP, (UINT32)ApicIdOfCore, (VOID *) LaunchApParams);
213 /*---------------------------------------------------------------------------------------*/
215 * Call the host environment interface to read an SPD's content.
218 * @param[in,out] ReadSpd
220 * @return The AGESA Status returned from the callout.
226 IN OUT AGESA_READ_SPD_PARAMS *ReadSpd
231 Status = AmdAgesaCallout (AGESA_READ_SPD, (UINT32)FcnData, ReadSpd);
237 /*---------------------------------------------------------------------------------------*/
239 * Call the host environment interface to read an SPD's content.
242 * @param[in,out] ReadSpd
244 * @return The AGESA Status returned from the callout.
248 AgesaReadSpdRecovery (
250 IN OUT AGESA_READ_SPD_PARAMS *ReadSpd
255 Status = AmdAgesaCallout (AGESA_READ_SPD_RECOVERY, (UINT32)FcnData, ReadSpd);
261 /*---------------------------------------------------------------------------------------*/
263 * Call the host environment interface to provide a user hook opportunity.
266 * @param[in,out] MemData
268 * @return The AGESA Status returned from the callout.
272 AgesaHookBeforeDramInitRecovery (
274 IN OUT MEM_DATA_STRUCT *MemData
279 Status = AmdAgesaCallout (AGESA_HOOKBEFORE_DRAM_INIT_RECOVERY, (UINT32)FcnData, MemData);
285 /*---------------------------------------------------------------------------------------*/
287 * Call the host environment interface to provide a user hook opportunity.
289 * @param[in] SocketIdModuleId - (SocketID << 8) | ModuleId
290 * @param[in,out] MemData
292 * @return The AGESA Status returned from the callout.
296 AgesaHookBeforeDramInit (
297 IN UINTN SocketIdModuleId,
298 IN OUT MEM_DATA_STRUCT *MemData
303 Status = AmdAgesaCallout (AGESA_HOOKBEFORE_DRAM_INIT, (UINT32)SocketIdModuleId, MemData);
308 /*---------------------------------------------------------------------------------------*/
310 * Call the host environment interface to provide a user hook opportunity.
312 * @param[in] SocketIdModuleId - (SocketID << 8) | ModuleId
313 * @param[in,out] MemData
315 * @return The AGESA Status returned from the callout.
319 AgesaHookBeforeDQSTraining (
320 IN UINTN SocketIdModuleId,
321 IN OUT MEM_DATA_STRUCT *MemData
326 Status = AmdAgesaCallout (AGESA_HOOKBEFORE_DQS_TRAINING, (UINT32)SocketIdModuleId, MemData);
331 /*---------------------------------------------------------------------------------------*/
333 * Call the host environment interface to provide a user hook opportunity.
336 * @param[in,out] MemData
338 * @return The AGESA Status returned from the callout.
342 AgesaHookBeforeExitSelfRefresh (
344 IN OUT MEM_DATA_STRUCT *MemData
349 Status = AmdAgesaCallout (AGESA_HOOKBEFORE_EXIT_SELF_REF, (UINT32)FcnData, MemData);
354 /*---------------------------------------------------------------------------------------*/
356 * Call the host environment interface to provide a user hook opportunity.
359 * @param[in,out] IdsCalloutData
361 * @return The AGESA Status returned from the callout.
369 IN OUT IDS_CALLOUT_STRUCT *IdsCalloutData
374 Status = AmdAgesaCallout (AGESA_GET_IDS_INIT_DATA, (UINT32)Data, IdsCalloutData);
380 /*----------------------------------------------------------------------------------------*/
382 * PCIE slot reset control
386 * @param[in] FcnData Function data
387 * @param[in] ResetInfo Reset information
388 * @retval Status Agesa status
392 AgesaPcieSlotResetControl (
394 IN PCIe_SLOT_RESET_INFO *ResetInfo
398 Status = AmdAgesaCallout (AGESA_GNB_PCIE_SLOT_RESET, (UINT32) FcnData, ResetInfo);
403 /*----------------------------------------------------------------------------------------*/
405 * OEM callout function for FCH data override
408 * @param[in] FchData FCH data pointer
409 * @retval Status This feature is not supported
417 return AGESA_UNSUPPORTED;
420 /*---------------------------------------------------------------------------------------*/
422 * Optional call to the host environment interface to change the external Vref for training.
424 * @param[in] SocketIdModuleId - (SocketID << 8) | ModuleId
425 * @param[in,out] MemData
427 * @return The AGESA Status returned from the callout.
431 AgesaExternal__TrainVrefChange (
432 IN UINTN SocketIdModuleId,
433 IN OUT MEM_DATA_STRUCT *MemData
438 Status = AmdAgesaCallout (AGESA_EXTERNAL____TRAIN_VREF_CHANGE, (UINT32)SocketIdModuleId, MemData);