2 * This file is part of the coreboot project.
4 * Copyright (C) 2012 Advanced Micro Devices, Inc.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 // AGESA Types and Definitions
28 #define LAST_ENTRY 0xFFFFFFFF
35 #define Int16FromChar(a,b) ((a) << 0 | (b) << 8)
38 #define Int32FromChar(a,b,c,d) ((a) << 0 | (b) << 8 | (c) << 16 | (d) << 24)
41 #define IMAGE_SIGNATURE Int32FromChar ('$', 'A', 'M', 'D')
43 typedef unsigned int AGESA_STATUS;
45 #define AGESA_SUCCESS ((AGESA_STATUS) 0x0)
46 #define AGESA_ALERT ((AGESA_STATUS) 0x40000000)
47 #define AGESA_WARNING ((AGESA_STATUS) 0x40000001)
48 #define AGESA_UNSUPPORTED ((AGESA_STATUS) 0x80000003)
49 #define AGESA_ERROR ((AGESA_STATUS) 0xC0000001)
50 #define AGESA_CRITICAL ((AGESA_STATUS) 0xC0000002)
51 #define AGESA_FATAL ((AGESA_STATUS) 0xC0000003)
53 typedef AGESA_STATUS (*CALLOUT_ENTRY) (unsigned int Param1, unsigned int Param2, void* ConfigPtr);
54 typedef AGESA_STATUS (*IMAGE_ENTRY) (IN OUT void* ConfigPtr);
55 typedef AGESA_STATUS (*MODULE_ENTRY) (IN OUT void* ConfigPtr);
57 ///This allocation type is used by the AmdCreateStruct entry point
59 PreMemHeap = 0, ///< Create heap in cache.
60 PostMemDram, ///< Create heap in memory.
61 ByHost ///< Create heap by Host.
64 /// These width descriptors are used by the library function, and others, to specify the data size
65 typedef enum ACCESS_WIDTH {
66 AccessWidth8 = 1, ///< Access width is 8 bits.
67 AccessWidth16, ///< Access width is 16 bits.
68 AccessWidth32, ///< Access width is 32 bits.
69 AccessWidth64, ///< Access width is 64 bits.
71 AccessS3SaveWidth8 = 0x81, ///< Save 8 bits data.
72 AccessS3SaveWidth16, ///< Save 16 bits data.
73 AccessS3SaveWidth32, ///< Save 32 bits data.
74 AccessS3SaveWidth64, ///< Save 64 bits data.
79 /// The standard header for all AGESA services.
80 typedef struct _AMD_CONFIG_PARAMS {
81 IN unsigned int ImageBasePtr; ///< The AGESA Image base address.
82 IN unsigned int Func; ///< The service desired, @sa dispatch.h.
83 IN unsigned int AltImageBasePtr; ///< Alternate Image location
84 IN unsigned int PcieBasePtr; ///< PCIe MMIO Base address, if configured.
85 union { ///< Callback pointer
86 IN unsigned long long PlaceHolder; ///< Place holder
87 IN CALLOUT_ENTRY CalloutPtr; ///< For Callout from AGESA
89 IN OUT unsigned int Reserved[2]; ///< This space is reserved for future use.
93 /// AGESA Binary module header structure
94 typedef struct _AMD_IMAGE_HEADER {
95 IN unsigned int Signature; ///< Binary Signature
96 IN signed char CreatorID[8]; ///< 8 characters ID
97 IN signed char Version[12]; ///< 12 characters version
98 IN unsigned int ModuleInfoOffset; ///< Offset of module
99 IN unsigned int EntryPointAddress; ///< Entry address
100 IN unsigned int ImageBase; ///< Image base
101 IN unsigned int RelocTableOffset; ///< Relocate Table offset
102 IN unsigned int ImageSize; ///< Size
103 IN unsigned short Checksum; ///< Checksum
104 IN unsigned char ImageType; ///< Type
105 IN unsigned char V_Reserved; ///< Reserved
108 /// AGESA Binary module header structure
109 typedef struct _AMD_MODULE_HEADER {
110 IN unsigned int ModuleHeaderSignature; ///< Module signature
111 IN signed char ModuleIdentifier[8]; ///< 8 characters ID
112 IN signed char ModuleVersion[12]; ///< 12 characters version
113 IN MODULE_ENTRY ModuleDispatcherPtr; ///< A pointer point to dispatcher
114 IN struct _AMD_MODULE_HEADER *NextBlockPtr; ///< Next module header link
117 #define FUNC_0 0 // bit-placed for PCI address creation
126 // SBDFO - Segment Bus Device Function Offset
127 // 31:28 Segment (4-bits)
128 // 27:20 Bus (8-bits)
129 // 19:15 Device (5-bits)
130 // 14:12 Function (3-bits)
131 // 11:00 Offset (12-bits)
134 #define MAKE_SBDFO(Seg, Bus, Dev, Fun, Off) ((((unsigned int) (Seg)) << 28) | (((unsigned int) (Bus)) << 20) | \
135 (((unsigned int) (Dev)) << 15) | (((unsigned int) (Fun)) << 12) | ((unsigned int) (Off)))
137 #define ILLEGAL_SBDFO 0xFFFFFFFF
139 /// CPUID data received registers format
140 typedef struct _SB_CPUID_DATA {
141 IN OUT unsigned int EAX_Reg; ///< CPUID instruction result in EAX
142 IN OUT unsigned int EBX_Reg; ///< CPUID instruction result in EBX
143 IN OUT unsigned int ECX_Reg; ///< CPUID instruction result in ECX
144 IN OUT unsigned int EDX_Reg; ///< CPUID instruction result in EDX
148 #define COLD_RESET 2 // Cold reset
149 #define RESET_CPU 4 // Triggers a CPU reset
151 /// HT frequency for external callbacks
153 HT_FREQUENCY_200M = 0, ///< HT speed 200 for external callbacks
154 HT_FREQUENCY_400M = 2, ///< HT speed 400 for external callbacks
155 HT_FREQUENCY_600M = 4, ///< HT speed 600 for external callbacks
156 HT_FREQUENCY_800M = 5, ///< HT speed 800 for external callbacks
157 HT_FREQUENCY_1000M = 6, ///< HT speed 1000 for external callbacks
158 HT_FREQUENCY_1200M = 7, ///< HT speed 1200 for external callbacks
159 HT_FREQUENCY_1400M = 8, ///< HT speed 1400 for external callbacks
160 HT_FREQUENCY_1600M = 9, ///< HT speed 1600 for external callbacks
161 HT_FREQUENCY_1800M = 10, ///< HT speed 1800 for external callbacks
162 HT_FREQUENCY_2000M = 11, ///< HT speed 2000 for external callbacks
163 HT_FREQUENCY_2200M = 12, ///< HT speed 2200 for external callbacks
164 HT_FREQUENCY_2400M = 13, ///< HT speed 2400 for external callbacks
165 HT_FREQUENCY_2600M = 14, ///< HT speed 2600 for external callbacks
166 HT_FREQUENCY_2800M = 17, ///< HT speed 2800 for external callbacks
167 HT_FREQUENCY_3000M = 18, ///< HT speed 3000 for external callbacks
168 HT_FREQUENCY_3200M = 19 ///< HT speed 3200 for external callbacks
172 #define BIT0 0x0000000000000001ull
175 #define BIT1 0x0000000000000002ull
178 #define BIT2 0x0000000000000004ull
181 #define BIT3 0x0000000000000008ull
184 #define BIT4 0x0000000000000010ull
187 #define BIT5 0x0000000000000020ull
190 #define BIT6 0x0000000000000040ull
193 #define BIT7 0x0000000000000080ull
196 #define BIT8 0x0000000000000100ull
199 #define BIT9 0x0000000000000200ull
202 #define BIT10 0x0000000000000400ull
205 #define BIT11 0x0000000000000800ull
208 #define BIT12 0x0000000000001000ull
211 #define BIT13 0x0000000000002000ull
214 #define BIT14 0x0000000000004000ull
217 #define BIT15 0x0000000000008000ull
220 #define BIT16 0x0000000000010000ull
223 #define BIT17 0x0000000000020000ull
226 #define BIT18 0x0000000000040000ull
229 #define BIT19 0x0000000000080000ull
232 #define BIT20 0x0000000000100000ull
235 #define BIT21 0x0000000000200000ull
238 #define BIT22 0x0000000000400000ull
241 #define BIT23 0x0000000000800000ull
244 #define BIT24 0x0000000001000000ull
247 #define BIT25 0x0000000002000000ull
250 #define BIT26 0x0000000004000000ull
253 #define BIT27 0x0000000008000000ull
256 #define BIT28 0x0000000010000000ull
259 #define BIT29 0x0000000020000000ull
262 #define BIT30 0x0000000040000000ull
265 #define BIT31 0x0000000080000000ull
268 #define BIT32 0x0000000100000000ull
271 #define BIT33 0x0000000200000000ull
274 #define BIT34 0x0000000400000000ull
277 #define BIT35 0x0000000800000000ull
280 #define BIT36 0x0000001000000000ull
283 #define BIT37 0x0000002000000000ull
286 #define BIT38 0x0000004000000000ull
289 #define BIT39 0x0000008000000000ull
292 #define BIT40 0x0000010000000000ull
295 #define BIT41 0x0000020000000000ull
298 #define BIT42 0x0000040000000000ull
301 #define BIT43 0x0000080000000000ull
304 #define BIT44 0x0000100000000000ull
307 #define BIT45 0x0000200000000000ull
310 #define BIT46 0x0000400000000000ull
313 #define BIT47 0x0000800000000000ull
316 #define BIT48 0x0001000000000000ull
319 #define BIT49 0x0002000000000000ull
322 #define BIT50 0x0004000000000000ull
325 #define BIT51 0x0008000000000000ull
328 #define BIT52 0x0010000000000000ull
331 #define BIT53 0x0020000000000000ull
334 #define BIT54 0x0040000000000000ull
337 #define BIT55 0x0080000000000000ull
340 #define BIT56 0x0100000000000000ull
343 #define BIT57 0x0200000000000000ull
346 #define BIT58 0x0400000000000000ull
349 #define BIT59 0x0800000000000000ull
352 #define BIT60 0x1000000000000000ull
355 #define BIT61 0x2000000000000000ull
358 #define BIT62 0x4000000000000000ull
361 #define BIT63 0x8000000000000000ull