5 * AMD AGESA Basic Level Public APIs
7 * Contains basic Level Initialization routines.
9 * @xrefitem bom "File Content Label" "Release Content"
11 * @e sub-project: Interface
12 * @e \$Revision: 37658 $ @e \$Date: 2010-09-09 15:25:38 +0800 (Thu, 09 Sep 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 * ***************************************************************************
48 /*----------------------------------------------------------------------------------------
49 * M O D U L E S U S E D
50 *----------------------------------------------------------------------------------------
54 #include "cpuEnvInit.h"
55 #include "heapManager.h"
56 #include "CreateStruct.h"
57 #include "GnbInterface.h"
58 #include "CommonInits.h"
59 #include "S3SaveState.h"
62 RDATA_GROUP (G1_PEICC
)
64 #define FILECODE PROC_COMMON_AMDINITENV_FILECODE
65 /*----------------------------------------------------------------------------------------
66 * D E F I N I T I O N S A N D M A C R O S
67 *----------------------------------------------------------------------------------------
71 /*----------------------------------------------------------------------------------------
72 * T Y P E D E F S A N D S T R U C T U R E S
73 *----------------------------------------------------------------------------------------
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 *----------------------------------------------------------------------------------------
83 /*----------------------------------------------------------------------------------------
84 * E X P O R T E D F U N C T I O N S
85 *----------------------------------------------------------------------------------------
88 *---------------------------------------------------------------------------------------
90 * Initializer routine that will be invoked by the wrapper
91 * to initialize the input structure for the AmdInitEnv
93 * @param[in,out] EnvParamsPtr Newly created interface parameters for AmdInitEnv
95 * @retval AGESA_SUCCESS Always succeeds
97 *---------------------------------------------------------------------------------------
100 AmdInitEnvInitializer (
101 IN AMD_CONFIG_PARAMS
*StdHeader
,
102 IN OUT AMD_ENV_PARAMS
*EnvParamsPtr
105 ASSERT (StdHeader
!= NULL
);
106 ASSERT (EnvParamsPtr
!= NULL
);
108 EnvParamsPtr
->StdHeader
= *StdHeader
;
110 CommonPlatformConfigInit (&EnvParamsPtr
->PlatformConfig
, &EnvParamsPtr
->StdHeader
);
111 GnbInitDataStructAtEnvDef (&EnvParamsPtr
->GnbEnvConfiguration
, EnvParamsPtr
);
113 return AGESA_SUCCESS
;
117 /*---------------------------------------------------------------------------------------*/
119 * Main entry point for the AMD_INIT_ENV function.
121 * This entry point is responsible for copying the heap contents from the
122 * temp RAM area to main memory.
124 * @param[in,out] EnvParams Required input parameters for the AMD_INIT_ENV
127 * @return Aggregated status across all internal AMD env calls invoked.
132 IN OUT AMD_ENV_PARAMS
*EnvParams
135 AGESA_STATUS AgesaStatus
;
136 AGESA_STATUS AmdInitEnvStatus
;
138 AGESA_TESTPOINT (TpIfAmdInitEnvEntry
, &EnvParams
->StdHeader
);
140 ASSERT (EnvParams
!= NULL
);
141 AmdInitEnvStatus
= AGESA_SUCCESS
;
144 //Copy Temp Ram heap content to Main Ram
145 AgesaStatus
= CopyHeapToMainRamAtPost (&(EnvParams
->StdHeader
));
146 if (AgesaStatus
> AmdInitEnvStatus
) {
147 AmdInitEnvStatus
= AgesaStatus
;
149 EnvParams
->StdHeader
.HeapStatus
= HEAP_SYSTEM_MEM
;
150 EnvParams
->StdHeader
.HeapBasePtr
= HeapGetBaseAddress (&EnvParams
->StdHeader
);
151 // Any heap allocate/deallocat/locate buffer should be used after heap is rebuild from here.
152 // After persist heaps are tansfer and rebuild, HeapLocateBuffer can start to be used in IDS hook.
154 //Heap have been relocated, so Debug Print need be init again to get new address
155 IDS_HDT_CONSOLE_INIT (&EnvParams
->StdHeader
);
156 IDS_HDT_CONSOLE (MAIN_FLOW
, "Heap transfer End\n");
157 IDS_HDT_CONSOLE (MAIN_FLOW
, "AmdInitEnv: Start\n\n");
158 IDS_OPTION_HOOK (IDS_PLATFORMCFG_OVERRIDE
, &EnvParams
->PlatformConfig
, &(EnvParams
->StdHeader
));
159 IDS_OPTION_HOOK (IDS_BEFORE_PCI_INIT
, EnvParams
, &(EnvParams
->StdHeader
));
161 AgesaStatus
= S3ScriptInit (&EnvParams
->StdHeader
);
162 if (AgesaStatus
> AmdInitEnvStatus
) {
163 AmdInitEnvStatus
= AgesaStatus
;
166 AgesaStatus
= GnbInitAtEnv (EnvParams
);
167 if (AgesaStatus
> AmdInitEnvStatus
) {
168 AmdInitEnvStatus
= AgesaStatus
;
171 AGESA_TESTPOINT (TpIfAmdInitEnvExit
, &EnvParams
->StdHeader
);
172 IDS_HDT_CONSOLE (MAIN_FLOW
, "\nAmdInitEnv: End\n");
173 IDS_HDT_CONSOLE_FLUSH_BUFFER (&EnvParams
->StdHeader
);
174 return AmdInitEnvStatus
;