tree: drop last paragraph of GPL copyright header
[coreboot.git] / src / southbridge / amd / cimx / sb900 / Amd.h
blobec8140060fa96661602fae3b34e52163175d3005
1 /*****************************************************************************
2 * AMD Generic Encapsulated Software Architecture */
3 /**
4 * @file
6 * Agesa structures and definitions
8 * Contains AMD AGESA/CIMx core interface
12 *****************************************************************************
14 * This file is part of the coreboot project.
16 * Copyright (C) 2011 Advanced Micro Devices, Inc.
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; version 2 of the License.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 * ***************************************************************************
31 #ifndef _AMD_H_
32 #define _AMD_H_
34 // AGESA Types and Definitions
35 #ifndef NULL
36 #define NULL 0
37 #endif
39 #define LAST_ENTRY 0xFFFFFFFF
40 #define IOCF8 0xCF8
41 #define IOCFC 0xCFC
42 #define IN
43 #define OUT
45 #ifndef Int16FromChar
46 #define Int16FromChar(a,b) ((a) << 0 | (b) << 8)
47 #endif
48 #ifndef Int32FromChar
49 #define Int32FromChar(a,b,c,d) ((a) << 0 | (b) << 8 | (c) << 16 | (d) << 24)
50 #endif
52 #define IMAGE_SIGNATURE Int32FromChar ('$', 'A', 'M', 'D')
54 typedef unsigned int AGESA_STATUS;
56 #define AGESA_SUCCESS ((AGESA_STATUS) 0x0)
57 #define AGESA_ALERT ((AGESA_STATUS) 0x40000000)
58 #define AGESA_WARNING ((AGESA_STATUS) 0x40000001)
59 #define AGESA_UNSUPPORTED ((AGESA_STATUS) 0x80000003)
60 #define AGESA_ERROR ((AGESA_STATUS) 0xC0000001)
61 #define AGESA_CRITICAL ((AGESA_STATUS) 0xC0000002)
62 #define AGESA_FATAL ((AGESA_STATUS) 0xC0000003)
64 typedef AGESA_STATUS (*CALLOUT_ENTRY) (unsigned int Param1, unsigned int Param2, void* ConfigPtr);
65 typedef AGESA_STATUS (*IMAGE_ENTRY) (IN OUT void* ConfigPtr);
66 typedef AGESA_STATUS (*MODULE_ENTRY) (IN OUT void* ConfigPtr);
68 ///This allocation type is used by the AmdCreateStruct entry point
69 typedef enum {
70 PreMemHeap = 0, ///< Create heap in cache.
71 PostMemDram, ///< Create heap in memory.
72 ByHost ///< Create heap by Host.
73 } ALLOCATION_METHOD;
75 /// These width descriptors are used by the library function, and others, to specify the data size
76 typedef enum ACCESS_WIDTH {
77 AccessWidth8 = 1, ///< Access width is 8 bits.
78 AccessWidth16, ///< Access width is 16 bits.
79 AccessWidth32, ///< Access width is 32 bits.
80 AccessWidth64, ///< Access width is 64 bits.
82 AccessS3SaveWidth8 = 0x81, ///< Save 8 bits data.
83 AccessS3SaveWidth16, ///< Save 16 bits data.
84 AccessS3SaveWidth32, ///< Save 32 bits data.
85 AccessS3SaveWidth64, ///< Save 64 bits data.
86 } ACCESS_WIDTH;
88 // AGESA Structures
90 /// The standard header for all AGESA services.
91 typedef struct _AMD_CONFIG_PARAMS {
92 IN unsigned int ImageBasePtr; ///< The AGESA Image base address.
93 IN unsigned int Func; ///< The service desired, @sa dispatch.h.
94 IN unsigned int AltImageBasePtr; ///< Alternate Image location
95 IN unsigned int PcieBasePtr; ///< PCIe MMIO Base address, if configured.
96 union { ///< Callback pointer
97 IN unsigned long long PlaceHolder; ///< Place holder
98 IN CALLOUT_ENTRY CalloutPtr; ///< For Callout from AGESA
99 } CALLBACK;
100 IN OUT unsigned int Reserved[2]; ///< This space is reserved for future use.
101 } AMD_CONFIG_PARAMS;
104 /// AGESA Binary module header structure
105 typedef struct _AMD_IMAGE_HEADER {
106 IN unsigned int Signature; ///< Binary Signature
107 IN signed char CreatorID[8]; ///< 8 characters ID
108 IN signed char Version[12]; ///< 12 characters version
109 IN unsigned int ModuleInfoOffset; ///< Offset of module
110 IN unsigned int EntryPointAddress; ///< Entry address
111 IN unsigned int ImageBase; ///< Image base
112 IN unsigned int RelocTableOffset; ///< Relocate Table offset
113 IN unsigned int ImageSize; ///< Size
114 IN unsigned short Checksum; ///< Checksum
115 IN unsigned char ImageType; ///< Type
116 IN unsigned char V_Reserved; ///< Reserved
117 } AMD_IMAGE_HEADER;
119 /// AGESA Binary module header structure
120 typedef struct _AMD_MODULE_HEADER {
121 IN unsigned int ModuleHeaderSignature; ///< Module signature
122 IN signed char ModuleIdentifier[8]; ///< 8 characters ID
123 IN signed char ModuleVersion[12]; ///< 12 characters version
124 IN MODULE_ENTRY ModuleDispatcherPtr; ///< A pointer point to dispatcher
125 IN struct _AMD_MODULE_HEADER *NextBlockPtr; ///< Next module header link
126 } AMD_MODULE_HEADER;
128 #define FUNC_0 0 // bit-placed for PCI address creation
129 #define FUNC_1 1
130 #define FUNC_2 2
131 #define FUNC_3 3
132 #define FUNC_4 4
133 #define FUNC_5 5
134 #define FUNC_6 6
135 #define FUNC_7 7
137 // SBDFO - Segment Bus Device Function Offset
138 // 31:28 Segment (4-bits)
139 // 27:20 Bus (8-bits)
140 // 19:15 Device (5-bits)
141 // 14:12 Function (3-bits)
142 // 11:00 Offset (12-bits)
144 #if 0
145 #define MAKE_SBDFO(Seg, Bus, Dev, Fun, Off) ((((unsigned int) (Seg)) << 28) | (((unsigned int) (Bus)) << 20) | \
146 (((unsigned int) (Dev)) << 15) | (((unsigned int) (Fun)) << 12) | ((unsigned int) (Off)))
147 #endif
148 #define ILLEGAL_SBDFO 0xFFFFFFFF
151 /// CPUID data received registers format
152 typedef struct _SB_CPUID_DATA {
153 IN OUT unsigned int EAX_Reg; ///< CPUID instruction result in EAX
154 IN OUT unsigned int EBX_Reg; ///< CPUID instruction result in EBX
155 IN OUT unsigned int ECX_Reg; ///< CPUID instruction result in ECX
156 IN OUT unsigned int EDX_Reg; ///< CPUID instruction result in EDX
157 } SB_CPUID_DATA;
160 #define WARM_RESET 1
161 #define COLD_RESET 2 // Cold reset
162 #define RESET_CPU 4 // Triggers a CPU reset
164 /// HT frequency for external callbacks
165 typedef enum {
166 HT_FREQUENCY_200M = 0, ///< HT speed 200 for external callbacks
167 HT_FREQUENCY_400M = 2, ///< HT speed 400 for external callbacks
168 HT_FREQUENCY_600M = 4, ///< HT speed 600 for external callbacks
169 HT_FREQUENCY_800M = 5, ///< HT speed 800 for external callbacks
170 HT_FREQUENCY_1000M = 6, ///< HT speed 1000 for external callbacks
171 HT_FREQUENCY_1200M = 7, ///< HT speed 1200 for external callbacks
172 HT_FREQUENCY_1400M = 8, ///< HT speed 1400 for external callbacks
173 HT_FREQUENCY_1600M = 9, ///< HT speed 1600 for external callbacks
174 HT_FREQUENCY_1800M = 10, ///< HT speed 1800 for external callbacks
175 HT_FREQUENCY_2000M = 11, ///< HT speed 2000 for external callbacks
176 HT_FREQUENCY_2200M = 12, ///< HT speed 2200 for external callbacks
177 HT_FREQUENCY_2400M = 13, ///< HT speed 2400 for external callbacks
178 HT_FREQUENCY_2600M = 14, ///< HT speed 2600 for external callbacks
179 HT_FREQUENCY_2800M = 17, ///< HT speed 2800 for external callbacks
180 HT_FREQUENCY_3000M = 18, ///< HT speed 3000 for external callbacks
181 HT_FREQUENCY_3200M = 19 ///< HT speed 3200 for external callbacks
182 } HT_FREQUENCIES;
184 #ifndef BIT0
185 #define BIT0 0x0000000000000001ull
186 #endif
187 #ifndef BIT1
188 #define BIT1 0x0000000000000002ull
189 #endif
190 #ifndef BIT2
191 #define BIT2 0x0000000000000004ull
192 #endif
193 #ifndef BIT3
194 #define BIT3 0x0000000000000008ull
195 #endif
196 #ifndef BIT4
197 #define BIT4 0x0000000000000010ull
198 #endif
199 #ifndef BIT5
200 #define BIT5 0x0000000000000020ull
201 #endif
202 #ifndef BIT6
203 #define BIT6 0x0000000000000040ull
204 #endif
205 #ifndef BIT7
206 #define BIT7 0x0000000000000080ull
207 #endif
208 #ifndef BIT8
209 #define BIT8 0x0000000000000100ull
210 #endif
211 #ifndef BIT9
212 #define BIT9 0x0000000000000200ull
213 #endif
214 #ifndef BIT10
215 #define BIT10 0x0000000000000400ull
216 #endif
217 #ifndef BIT11
218 #define BIT11 0x0000000000000800ull
219 #endif
220 #ifndef BIT12
221 #define BIT12 0x0000000000001000ull
222 #endif
223 #ifndef BIT13
224 #define BIT13 0x0000000000002000ull
225 #endif
226 #ifndef BIT14
227 #define BIT14 0x0000000000004000ull
228 #endif
229 #ifndef BIT15
230 #define BIT15 0x0000000000008000ull
231 #endif
232 #ifndef BIT16
233 #define BIT16 0x0000000000010000ull
234 #endif
235 #ifndef BIT17
236 #define BIT17 0x0000000000020000ull
237 #endif
238 #ifndef BIT18
239 #define BIT18 0x0000000000040000ull
240 #endif
241 #ifndef BIT19
242 #define BIT19 0x0000000000080000ull
243 #endif
244 #ifndef BIT20
245 #define BIT20 0x0000000000100000ull
246 #endif
247 #ifndef BIT21
248 #define BIT21 0x0000000000200000ull
249 #endif
250 #ifndef BIT22
251 #define BIT22 0x0000000000400000ull
252 #endif
253 #ifndef BIT23
254 #define BIT23 0x0000000000800000ull
255 #endif
256 #ifndef BIT24
257 #define BIT24 0x0000000001000000ull
258 #endif
259 #ifndef BIT25
260 #define BIT25 0x0000000002000000ull
261 #endif
262 #ifndef BIT26
263 #define BIT26 0x0000000004000000ull
264 #endif
265 #ifndef BIT27
266 #define BIT27 0x0000000008000000ull
267 #endif
268 #ifndef BIT28
269 #define BIT28 0x0000000010000000ull
270 #endif
271 #ifndef BIT29
272 #define BIT29 0x0000000020000000ull
273 #endif
274 #ifndef BIT30
275 #define BIT30 0x0000000040000000ull
276 #endif
277 #ifndef BIT31
278 #define BIT31 0x0000000080000000ull
279 #endif
280 #ifndef BIT32
281 #define BIT32 0x0000000100000000ull
282 #endif
283 #ifndef BIT33
284 #define BIT33 0x0000000200000000ull
285 #endif
286 #ifndef BIT34
287 #define BIT34 0x0000000400000000ull
288 #endif
289 #ifndef BIT35
290 #define BIT35 0x0000000800000000ull
291 #endif
292 #ifndef BIT36
293 #define BIT36 0x0000001000000000ull
294 #endif
295 #ifndef BIT37
296 #define BIT37 0x0000002000000000ull
297 #endif
298 #ifndef BIT38
299 #define BIT38 0x0000004000000000ull
300 #endif
301 #ifndef BIT39
302 #define BIT39 0x0000008000000000ull
303 #endif
304 #ifndef BIT40
305 #define BIT40 0x0000010000000000ull
306 #endif
307 #ifndef BIT41
308 #define BIT41 0x0000020000000000ull
309 #endif
310 #ifndef BIT42
311 #define BIT42 0x0000040000000000ull
312 #endif
313 #ifndef BIT43
314 #define BIT43 0x0000080000000000ull
315 #endif
316 #ifndef BIT44
317 #define BIT44 0x0000100000000000ull
318 #endif
319 #ifndef BIT45
320 #define BIT45 0x0000200000000000ull
321 #endif
322 #ifndef BIT46
323 #define BIT46 0x0000400000000000ull
324 #endif
325 #ifndef BIT47
326 #define BIT47 0x0000800000000000ull
327 #endif
328 #ifndef BIT48
329 #define BIT48 0x0001000000000000ull
330 #endif
331 #ifndef BIT49
332 #define BIT49 0x0002000000000000ull
333 #endif
334 #ifndef BIT50
335 #define BIT50 0x0004000000000000ull
336 #endif
337 #ifndef BIT51
338 #define BIT51 0x0008000000000000ull
339 #endif
340 #ifndef BIT52
341 #define BIT52 0x0010000000000000ull
342 #endif
343 #ifndef BIT53
344 #define BIT53 0x0020000000000000ull
345 #endif
346 #ifndef BIT54
347 #define BIT54 0x0040000000000000ull
348 #endif
349 #ifndef BIT55
350 #define BIT55 0x0080000000000000ull
351 #endif
352 #ifndef BIT56
353 #define BIT56 0x0100000000000000ull
354 #endif
355 #ifndef BIT57
356 #define BIT57 0x0200000000000000ull
357 #endif
358 #ifndef BIT58
359 #define BIT58 0x0400000000000000ull
360 #endif
361 #ifndef BIT59
362 #define BIT59 0x0800000000000000ull
363 #endif
364 #ifndef BIT60
365 #define BIT60 0x1000000000000000ull
366 #endif
367 #ifndef BIT61
368 #define BIT61 0x2000000000000000ull
369 #endif
370 #ifndef BIT62
371 #define BIT62 0x4000000000000000ull
372 #endif
373 #ifndef BIT63
374 #define BIT63 0x8000000000000000ull
375 #endif
376 #endif