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