1 /* SPDX-License-Identifier: BSD-3-Clause */
7 * Agesa structures and definitions
9 * Contains AMD AGESA core interface
11 * @xrefitem bom "File Content Label" "Release Content"
13 * @e sub-project: Include
14 * @e \$Revision$ @e \$Date$
16 /*****************************************************************************
18 * Copyright (c) 2008 - 2017, 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 ***************************************************************************/
45 #include "check_for_wrapper.h"
50 #define AGESA_REVISION "Arch2008"
51 #define AGESA_ID "AGESA"
55 // AGESA Types and Definitions
58 #define LAST_ENTRY 0xFFFFFFFFul
59 #define Int32FromChar(a,b,c,d) (UINT32)((a) << 0 | (b) << 8 | (c) << 16 | (d) << 24)
60 #define IMAGE_SIGNATURE Int32FromChar ('$', 'A', 'M', 'D')
61 /* coreboot binaryPI - start */
62 #define MODULE_SIGNATURE Int32FromChar ('$', 'M', 'O', 'D')
63 /* coreboot binaryPI - end */
67 /// The return status for all AGESA public services.
69 /// Services return the most severe status of any logged event. Status other than SUCCESS, UNSUPPORTED, and BOUNDS_CHK
70 /// will have log entries with more detail.
73 AGESA_SUCCESS
= 0, ///< The service completed normally. Info may be logged.
74 AGESA_UNSUPPORTED
, ///< The dispatcher or create struct had an unimplemented function requested.
76 AGESA_BOUNDS_CHK
, ///< A dynamic parameter was out of range and the service was not provided.
77 ///< Example, memory address not installed, heap buffer handle not found.
79 // AGESA_STATUS of greater severity (the ones below this line), always have a log entry available.
80 AGESA_ALERT
, ///< An observed condition, but no loss of function. See Log.
81 AGESA_WARNING
, ///< Possible or minor loss of function. See Log.
82 AGESA_ERROR
, ///< Significant loss of function, boot may be possible. See Log.
83 AGESA_CRITICAL
, ///< Continue boot only to notify user. See Log.
84 AGESA_FATAL
, ///< Halt booting. See Log, however Fatal errors pertaining to heap problems
85 ///< may not be able to reliably produce log events.
86 AgesaStatusMax
///< Not a status, for limit checking.
89 /// For checking whether a status is at or above the mandatory log level.
90 #define AGESA_STATUS_LOG_LEVEL AGESA_ALERT
93 * Callout method to the host environment.
95 * Callout using a dispatch with appropriate thunk layer, which is determined by the host environment.
97 * @param[in] Function The specific callout function being invoked.
98 * @param[in] FcnData Function specific data item.
99 * @param[in,out] ConfigPtr Reference to Callout params.
101 typedef AGESA_STATUS (*CALLOUT_ENTRY
) (
104 IN OUT VOID
*ConfigPtr
107 typedef AGESA_STATUS (*IMAGE_ENTRY
) (VOID
*ConfigPtr
);
108 typedef AGESA_STATUS (*MODULE_ENTRY
) (VOID
*ConfigPtr
);
110 ///This allocation type is used by the AmdCreateStruct entry point
112 PreMemHeap
= 0, ///< Create heap in cache.
113 PostMemDram
, ///< Create heap in memory.
114 ByHost
///< Create heap by Host.
117 /// These width descriptors are used by the library function, and others, to specify the data size
118 typedef enum ACCESS_WIDTH
{
119 AccessWidthNone
= 0, ///< dummy access width
120 AccessWidth8
= 1, ///< Access width is 8 bits.
121 AccessWidth16
, ///< Access width is 16 bits.
122 AccessWidth32
, ///< Access width is 32 bits.
123 AccessWidth64
, ///< Access width is 64 bits.
125 AccessS3SaveWidth8
= 0x81, ///< Save 8 bits data.
126 AccessS3SaveWidth16
, ///< Save 16 bits data.
127 AccessS3SaveWidth32
, ///< Save 32 bits data.
128 AccessS3SaveWidth64
, ///< Save 64 bits data.
131 /// AGESA struct name
133 // AGESA BASIC FUNCTIONS
134 AMD_INIT_RECOVERY
= 0x00020000, ///< AmdInitRecovery entry point handle
135 AMD_CREATE_STRUCT
, ///< AmdCreateStruct handle
136 AMD_INIT_EARLY
, ///< AmdInitEarly entry point handle
137 AMD_INIT_ENV
, ///< AmdInitEnv entry point handle
138 AMD_INIT_LATE
, ///< AmdInitLate entry point handle
139 AMD_INIT_MID
, ///< AmdInitMid entry point handle
140 AMD_INIT_POST
, ///< AmdInitPost entry point handle
141 AMD_INIT_RESET
, ///< AmdInitReset entry point handle
142 AMD_INIT_RESUME
, ///< AmdInitResume entry point handle
143 AMD_RELEASE_STRUCT
, ///< AmdReleaseStruct handle
144 AMD_S3LATE_RESTORE
, ///< AmdS3LateRestore entry point handle
145 AMD_GET_APIC_ID
, ///< AmdGetApicId entry point handle
146 AMD_GET_PCI_ADDRESS
, ///< AmdGetPciAddress entry point handle
147 AMD_IDENTIFY_CORE
, ///< AmdIdentifyCore general service handle
148 AMD_READ_EVENT_LOG
, ///< AmdReadEventLog general service handle
149 AMD_GET_EXECACHE_SIZE
, ///< AmdGetAvailableExeCacheSize general service handle
150 AMD_LATE_RUN_AP_TASK
, ///< AmdLateRunApTask entry point handle
151 AMD_IDENTIFY_DIMMS
, ///< AmdIdentifyDimm general service handle
152 AMD_GET_2D_DATA_EYE
, ///< AmdGet2DDataEye general service handle
153 AMD_S3FINAL_RESTORE
, ///< AmdS3FinalRestore entry point handle
154 AMD_INIT_RTB
///< AmdInitRtb entry point handle
157 /* ResetType constant values */
158 #define WARM_RESET_WHENEVER 1
159 #define COLD_RESET_WHENEVER 2
160 #define WARM_RESET_IMMEDIATELY 3
161 #define COLD_RESET_IMMEDIATELY 4
166 /// The standard header for all AGESA services.
167 /// For internal AGESA naming conventions, see @ref amdconfigparamname .
169 IN VOID
* ImageBasePtr
; ///< The AGESA Image base address.
170 IN UINT32 Func
; ///< The service desired
171 IN VOID
* AltImageBasePtr
; ///< Alternate Image location
172 IN CALLOUT_ENTRY CalloutPtr
; ///< For Callout from AGESA
173 IN UINT8 HeapStatus
; ///< For heap status from boot time slide.
174 IN UINT64 HeapBasePtr
; ///< Location of the heap
175 IN OUT UINT8 Reserved
[7]; ///< This space is reserved for future use.
179 /// Create Struct Interface.
181 IN AMD_CONFIG_PARAMS StdHeader
; ///< Standard configuration header
182 IN AGESA_STRUCT_NAME AgesaFunctionName
; ///< The service to init
183 IN ALLOCATION_METHOD AllocationMethod
; ///< How to handle buffer allocation
184 IN OUT UINT32 NewStructSize
; ///< The size of the allocated data, in for ByHost, else out only.
185 IN OUT VOID
*NewStructPtr
; ///< The struct for the service.
186 ///< The struct to init for ByHost allocation,
187 ///< the initialized struct on return.
188 } AMD_INTERFACE_PARAMS
;
190 #define FUNC_0 0 // bit-placed for PCI address creation
199 /// AGESA Binary module header structure
201 IN UINT32 Signature
; ///< Binary Signature
202 IN CHAR8 CreatorID
[8]; ///< 8 characters ID
203 IN CHAR8 Version
[12]; ///< 12 characters version
204 IN UINT32 ModuleInfoOffset
; ///< Offset of module
205 IN UINT32 EntryPointAddress
; ///< Entry address
206 IN UINT32 ImageBase
; ///< Image base
207 IN UINT32 RelocTableOffset
; ///< Relocate Table offset
208 IN UINT32 ImageSize
; ///< Size
209 IN UINT16 Checksum
; ///< Checksum
210 IN UINT8 ImageType
; ///< Type
211 IN UINT8 V_Reserved
; ///< Reserved
213 /// AGESA Binary module header structure
214 typedef struct _AMD_MODULE_HEADER
{
215 IN UINT32 ModuleHeaderSignature
; ///< Module signature
216 IN CHAR8 ModuleIdentifier
[8]; ///< 8 characters ID
217 IN CHAR8 ModuleVersion
[12]; ///< 12 characters version
218 IN VOID
*ModuleDispatcher
; ///< A pointer point to dispatcher
219 IN
struct _AMD_MODULE_HEADER
*NextBlock
; ///< Next module header link
222 // AMD_CODE_HEADER Signatures.
223 #define AGESA_CODE_SIGNATURE {'!', '!', '!', 'A', 'G', 'E', 'S', 'A'}
224 #define CIMXNB_CODE_SIGNATURE {'!', '!', 'C', 'I', 'M', 'X', 'N', 'B'}
225 #define CIMXSB_CODE_SIGNATURE {'!', '!', 'C', 'I', 'M', 'X', 'S', 'B'}
227 /// AGESA_CODE_SIGNATURE
229 IN CHAR8 Signature
[8]; ///< code header Signature
230 IN CHAR8 ComponentName
[16]; ///< 16 character name of the code module
231 IN CHAR8 Version
[12]; ///< 12 character version string
232 IN CHAR8 TerminatorNull
; ///< null terminated string
233 IN CHAR8 VerReserved
[7]; ///< reserved space
236 /// Extended PCI address format
238 IN OUT UINT32 Register
:12; ///< Register offset
239 IN OUT UINT32 Function
:3; ///< Function number
240 IN OUT UINT32 Device
:5; ///< Device number
241 IN OUT UINT32 Bus
:8; ///< Bus number
242 IN OUT UINT32 Segment
:4; ///< Segment
245 /// Union type for PCI address
246 typedef union _PCI_ADDR
{
247 IN UINT32 AddressValue
; ///< Formal address
248 IN EXT_PCI_ADDR Address
; ///< Extended address
251 // SBDFO - Segment Bus Device Function Offset
252 // 31:28 Segment (4-bits)
253 // 27:20 Bus (8-bits)
254 // 19:15 Device (5-bits)
255 // 14:12 Function(3-bits)
256 // 11:00 Offset (12-bits)
258 #define MAKE_SBDFO(Seg, Bus, Dev, Fun, Off) ((((UINT32) (Seg)) << 28) | (((UINT32) (Bus)) << 20) | \
259 (((UINT32)(Dev)) << 15) | (((UINT32)(Fun)) << 12) | ((UINT32)(Off)))
260 #define ILLEGAL_SBDFO 0xFFFFFFFFul
262 /// CPUID data received registers format
264 OUT UINT32 EAX_Reg
; ///< CPUID instruction result in EAX
265 OUT UINT32 EBX_Reg
; ///< CPUID instruction result in EBX
266 OUT UINT32 ECX_Reg
; ///< CPUID instruction result in ECX
267 OUT UINT32 EDX_Reg
; ///< CPUID instruction result in EDX
270 // Topology Services definitions and macros
271 #define TOPOLOGY_LIST_TERMINAL 0xFF ///< End of list.
275 #define BIT0 0x0000000000000001ull
278 #define BIT1 0x0000000000000002ull
281 #define BIT2 0x0000000000000004ull
284 #define BIT3 0x0000000000000008ull
287 #define BIT4 0x0000000000000010ull
290 #define BIT5 0x0000000000000020ull
293 #define BIT6 0x0000000000000040ull
296 #define BIT7 0x0000000000000080ull
299 #define BIT8 0x0000000000000100ull
302 #define BIT9 0x0000000000000200ull
305 #define BIT10 0x0000000000000400ull
308 #define BIT11 0x0000000000000800ull
311 #define BIT12 0x0000000000001000ull
314 #define BIT13 0x0000000000002000ull
317 #define BIT14 0x0000000000004000ull
320 #define BIT15 0x0000000000008000ull
323 #define BIT16 0x0000000000010000ull
326 #define BIT17 0x0000000000020000ull
329 #define BIT18 0x0000000000040000ull
332 #define BIT19 0x0000000000080000ull
335 #define BIT20 0x0000000000100000ull
338 #define BIT21 0x0000000000200000ull
341 #define BIT22 0x0000000000400000ull
344 #define BIT23 0x0000000000800000ull
347 #define BIT24 0x0000000001000000ull
350 #define BIT25 0x0000000002000000ull
353 #define BIT26 0x0000000004000000ull
356 #define BIT27 0x0000000008000000ull
359 #define BIT28 0x0000000010000000ull
362 #define BIT29 0x0000000020000000ull
365 #define BIT30 0x0000000040000000ull
368 #define BIT31 0x0000000080000000ull
371 #define BIT32 0x0000000100000000ull
374 #define BIT33 0x0000000200000000ull
377 #define BIT34 0x0000000400000000ull
380 #define BIT35 0x0000000800000000ull
383 #define BIT36 0x0000001000000000ull
386 #define BIT37 0x0000002000000000ull
389 #define BIT38 0x0000004000000000ull
392 #define BIT39 0x0000008000000000ull
395 #define BIT40 0x0000010000000000ull
398 #define BIT41 0x0000020000000000ull
401 #define BIT42 0x0000040000000000ull
404 #define BIT43 0x0000080000000000ull
407 #define BIT44 0x0000100000000000ull
410 #define BIT45 0x0000200000000000ull
413 #define BIT46 0x0000400000000000ull
416 #define BIT47 0x0000800000000000ull
419 #define BIT48 0x0001000000000000ull
422 #define BIT49 0x0002000000000000ull
425 #define BIT50 0x0004000000000000ull
428 #define BIT51 0x0008000000000000ull
431 #define BIT52 0x0010000000000000ull
434 #define BIT53 0x0020000000000000ull
437 #define BIT54 0x0040000000000000ull
440 #define BIT55 0x0080000000000000ull
443 #define BIT56 0x0100000000000000ull
446 #define BIT57 0x0200000000000000ull
449 #define BIT58 0x0400000000000000ull
452 #define BIT59 0x0800000000000000ull
455 #define BIT60 0x1000000000000000ull
458 #define BIT61 0x2000000000000000ull
461 #define BIT62 0x4000000000000000ull
464 #define BIT63 0x8000000000000000ull