blob: 8097e43f2a7da6b3a9aa5f84ce02dc50ba1a258a [file] [log] [blame]
zbao7d94cf92012-07-02 14:19:14 +08001/* $NoKeywords:$ */
2/**
3 * @file
4 *
5 * AMD AGESA Basic Level Public APIs
6 *
7 * Contains basic Level Initialization routines.
8 *
9 * @xrefitem bom "File Content Label" "Release Content"
10 * @e project: AGESA
11 * @e sub-project: Interface
12 * @e \$Revision: 63425 $ @e \$Date: 2011-12-22 11:24:10 -0600 (Thu, 22 Dec 2011) $
13 *
14 */
15/*****************************************************************************
16 *
Siyuan Wang641f00c2013-06-08 11:50:55 +080017 * Copyright (c) 2008 - 2012, Advanced Micro Devices, Inc.
18 * All rights reserved.
zbao7d94cf92012-07-02 14:19:14 +080019 *
Siyuan Wang641f00c2013-06-08 11:50:55 +080020 * Redistribution and use in source and binary forms, with or without
21 * modification, are permitted provided that the following conditions are met:
22 * * Redistributions of source code must retain the above copyright
23 * notice, this list of conditions and the following disclaimer.
24 * * Redistributions in binary form must reproduce the above copyright
25 * notice, this list of conditions and the following disclaimer in the
26 * documentation and/or other materials provided with the distribution.
27 * * Neither the name of Advanced Micro Devices, Inc. nor the names of
28 * its contributors may be used to endorse or promote products derived
29 * from this software without specific prior written permission.
zbao7d94cf92012-07-02 14:19:14 +080030 *
Siyuan Wang641f00c2013-06-08 11:50:55 +080031 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
32 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
33 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
34 * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
35 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
36 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
37 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
38 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
40 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
zbao7d94cf92012-07-02 14:19:14 +080041 ******************************************************************************
42 */
43
44
45/*----------------------------------------------------------------------------------------
46 * M O D U L E S U S E D
47 *----------------------------------------------------------------------------------------
48 */
49#include "AGESA.h"
50#include "Ids.h"
51#include "cpuEnvInit.h"
52#include "heapManager.h"
53#include "GnbInterface.h"
54#include "CommonInits.h"
55#include "AmdFch.h"
56#include "S3SaveState.h"
57#include "Filecode.h"
58#include "CreateStruct.h"
59CODE_GROUP (G1_PEICC)
60RDATA_GROUP (G1_PEICC)
61
62#define FILECODE PROC_COMMON_AMDINITENV_FILECODE
63
64extern BLDOPT_FCH_FUNCTION BldoptFchFunction;
65
66/*----------------------------------------------------------------------------------------
67 * D E F I N I T I O N S A N D M A C R O S
68 *----------------------------------------------------------------------------------------
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/*----------------------------------------------------------------------------------------
79 * 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
80 *----------------------------------------------------------------------------------------
81 */
82
83
84/*----------------------------------------------------------------------------------------
85 * E X P O R T E D F U N C T I O N S
86 *----------------------------------------------------------------------------------------
87 */
88/*
89 *---------------------------------------------------------------------------------------
90 *
91 * Initializer routine that will be invoked by the wrapper
92 * to initialize the input structure for the AmdInitEnv
93 *
94 * @param[in,out] EnvParamsPtr Newly created interface parameters for AmdInitEnv
95 *
96 * @retval AGESA_SUCCESS Always succeeds
97 *
98 *---------------------------------------------------------------------------------------
99 */
100AGESA_STATUS
101AmdInitEnvInitializer (
102 IN AMD_CONFIG_PARAMS *StdHeader,
103 IN OUT AMD_ENV_PARAMS *EnvParamsPtr
104 )
105{
106 ASSERT (StdHeader != NULL);
107 ASSERT (EnvParamsPtr != NULL);
108
109 EnvParamsPtr->StdHeader = *StdHeader;
110
111 CommonPlatformConfigInit (&EnvParamsPtr->PlatformConfig, &EnvParamsPtr->StdHeader);
112 BldoptFchFunction.InitEnvConstructor (EnvParamsPtr);
113 GnbInitDataStructAtEnvDef (&EnvParamsPtr->GnbEnvConfiguration, EnvParamsPtr);
114
115 return AGESA_SUCCESS;
116}
117
118
119/*---------------------------------------------------------------------------------------*/
120/**
121 * Main entry point for the AMD_INIT_ENV function.
122 *
123 * This entry point is responsible for copying the heap contents from the
124 * temp RAM area to main memory.
125 *
126 * @param[in,out] EnvParams Required input parameters for the AMD_INIT_ENV
127 * entry point.
128 *
129 * @return Aggregated status across all internal AMD env calls invoked.
130 *
131 */
132AGESA_STATUS
133AmdInitEnv (
134 IN OUT AMD_ENV_PARAMS *EnvParams
135 )
136{
137 AGESA_STATUS AgesaStatus;
138 AGESA_STATUS AmdInitEnvStatus;
139
140 AGESA_TESTPOINT (TpIfAmdInitEnvEntry, &EnvParams->StdHeader);
141
142 ASSERT (EnvParams != NULL);
143 AmdInitEnvStatus = AGESA_SUCCESS;
144
145
146 //Copy Temp Ram heap content to Main Ram
147 AgesaStatus = CopyHeapToMainRamAtPost (&(EnvParams->StdHeader));
148 if (AgesaStatus > AmdInitEnvStatus) {
149 AmdInitEnvStatus = AgesaStatus;
150 }
151 EnvParams->StdHeader.HeapStatus = HEAP_SYSTEM_MEM;
152 EnvParams->StdHeader.HeapBasePtr = HeapGetBaseAddress (&EnvParams->StdHeader);
153 // Any heap allocate/deallocat/locate buffer should be used after heap is rebuild from here.
154 // After persist heaps are tansfer and rebuild, HeapLocateBuffer can start to be used in IDS hook.
155
156 //Heap have been relocated, so Debug Print need be init again to get new address
157 IDS_PERF_TIMESTAMP (&EnvParams->StdHeader);
158 IDS_HDT_CONSOLE_INIT (&EnvParams->StdHeader);
159 IDS_HDT_CONSOLE (MAIN_FLOW, "Heap transfer End\n");
160 IDS_HDT_CONSOLE (MAIN_FLOW, "AmdInitEnv: Start\n\n");
161 IDS_OPTION_HOOK (IDS_PLATFORMCFG_OVERRIDE, &EnvParams->PlatformConfig, &(EnvParams->StdHeader));
162 IDS_OPTION_HOOK (IDS_BEFORE_PCI_INIT, EnvParams, &(EnvParams->StdHeader));
163
164 AgesaStatus = S3ScriptInit (&EnvParams->StdHeader);
165 if (AgesaStatus > AmdInitEnvStatus) {
166 AmdInitEnvStatus = AgesaStatus;
167 }
168
169 IDS_PERF_TIMESTAMP (&EnvParams->StdHeader);
170 AgesaStatus = BldoptFchFunction.InitEnv (EnvParams);
171 AmdInitEnvStatus = (AgesaStatus > AmdInitEnvStatus) ? AgesaStatus : AmdInitEnvStatus;
172
173 IDS_PERF_TIMESTAMP (&EnvParams->StdHeader);
174 AgesaStatus = GnbInitAtEnv (EnvParams);
175 if (AgesaStatus > AmdInitEnvStatus) {
176 AmdInitEnvStatus = AgesaStatus;
177 }
178
179 AGESA_TESTPOINT (TpIfAmdInitEnvExit, &EnvParams->StdHeader);
180 IDS_HDT_CONSOLE (MAIN_FLOW, "\nAmdInitEnv: End\n");
181 IDS_PERF_TIMESTAMP (&EnvParams->StdHeader);
182 IDS_HDT_CONSOLE_FLUSH_BUFFER (&EnvParams->StdHeader);
183 return AmdInitEnvStatus;
184}
185
186