2 * This file is part of the coreboot project.
4 * Copyright (C) 2011 - 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
20 /*----------------------------------------------------------------------------------------
21 * M O D U L E S U S E D
22 *----------------------------------------------------------------------------------------
27 #include "agesawrapper.h"
28 #include "BiosCallOuts.h"
29 #include "cpuRegisters.h"
30 #include "cpuCacheInit.h"
31 #include "cpuApicUtilities.h"
32 #include "cpuEarlyInit.h"
33 #include "cpuLateInit.h"
34 #include "Dispatcher.h"
35 #include "cpuCacheInit.h"
38 #include "heapManager.h"
39 #include <cpuFamilyTranslation.h> /* CPU_SPECIFIC_SERVICES */
41 #define FILECODE UNASSIGNED_FILE_FILECODE
43 /*----------------------------------------------------------------------------------------
44 * D E F I N I T I O N S A N D M A C R O S
45 *----------------------------------------------------------------------------------------
48 /* ACPI table pointers returned by AmdInitLate */
49 VOID *DmiTable = NULL;
50 VOID *AcpiPstate = NULL;
51 VOID *AcpiSrat = NULL;
52 VOID *AcpiSlit = NULL;
54 VOID *AcpiWheaMce = NULL;
55 VOID *AcpiWheaCmc = NULL;
56 VOID *AcpiAlib = NULL;
59 /*----------------------------------------------------------------------------------------
60 * T Y P E D E F S A N D S T R U C T U R E S
61 *----------------------------------------------------------------------------------------
64 /*----------------------------------------------------------------------------------------
65 * 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
66 *----------------------------------------------------------------------------------------
69 /*----------------------------------------------------------------------------------------
70 * E X P O R T E D F U N C T I O N S
71 *----------------------------------------------------------------------------------------
74 /*---------------------------------------------------------------------------------------
75 * L O C A L F U N C T I O N S
76 *---------------------------------------------------------------------------------------
78 extern VOID OemCustomizeInitEarly(IN OUT AMD_EARLY_PARAMS *InitEarly);
80 static UINT32 agesawrapper_amdinitcpuio(VOID)
85 AMD_CONFIG_PARAMS StdHeader;
92 /* get the number of coherent nodes in the system */
93 PciAddress.AddressValue = MAKE_SBDFO(0, 0, CONFIG_CDB, FUNC_0, 0x60);
94 LibAmdPciRead(AccessWidth32, PciAddress, &PciData, &StdHeader);
95 nodes = ((PciData >> 4) & 7) + 1; //NodeCnt[2:0]
97 /* Find out the Link ID of Node0 that connects to the
98 * Southbridge (system IO hub). e.g. family10 MCM Processor,
99 * sbLink is Processor0 Link2, internal Node0 Link3
101 PciAddress.AddressValue = MAKE_SBDFO(0, 0, CONFIG_CDB, FUNC_0, 0x64);
102 LibAmdPciRead(AccessWidth32, PciAddress, &PciData, &StdHeader);
103 sblink = (PciData >> 8) & 3; //assume ganged
105 /* Enable MMIO on AMD CPU Address Map Controller for all nodes */
106 for (node = 0; node < nodes; node++) {
107 /* clear all MMIO Mapped Base/Limit Registers */
108 for (i = 0; i < 8; i++) {
109 PciData = 0x00000000;
110 PciAddress.AddressValue = MAKE_SBDFO(0, 0, CONFIG_CDB + node, FUNC_1, 0x80 + i*8);
111 LibAmdPciWrite(AccessWidth32, PciAddress, &PciData, &StdHeader);
112 PciAddress.AddressValue = MAKE_SBDFO(0, 0, CONFIG_CDB + node, FUNC_1, 0x84 + i*8);
113 LibAmdPciWrite(AccessWidth32, PciAddress, &PciData, &StdHeader);
116 /* clear all IO Space Base/Limit Registers */
117 for (i = 0; i < 4; i++) {
118 PciData = 0x00000000;
119 PciAddress.AddressValue = MAKE_SBDFO(0, 0, CONFIG_CDB + node, FUNC_1, 0xC4 + i*8);
120 LibAmdPciWrite(AccessWidth32, PciAddress, &PciData, &StdHeader);
121 PciAddress.AddressValue = MAKE_SBDFO(0, 0, CONFIG_CDB + node, FUNC_1, 0xC0 + i*8);
122 LibAmdPciWrite(AccessWidth32, PciAddress, &PciData, &StdHeader);
125 /* Set VGA Ram MMIO 0000A0000-0000BFFFF to Node0 sbLink */
126 PciAddress.AddressValue = MAKE_SBDFO(0, 0, CONFIG_CDB + node, FUNC_1, 0x84);
127 PciData = 0x00000B00;
128 PciData |= sblink << 4;
129 LibAmdPciWrite(AccessWidth32, PciAddress, &PciData, &StdHeader);
130 PciAddress.AddressValue = MAKE_SBDFO(0, 0, CONFIG_CDB + node, FUNC_1, 0x80);
131 PciData = 0x00000A03;
132 LibAmdPciWrite(AccessWidth32, PciAddress, &PciData, &StdHeader);
134 /* Set TOM1-FFFFFFFF to Node0 sbLink. */
135 PciAddress.AddressValue = MAKE_SBDFO(0, 0, CONFIG_CDB + node, FUNC_1, 0x8C);
136 PciData = 0x00FFFF00;
137 PciData |= sblink << 4;
138 LibAmdPciWrite(AccessWidth32, PciAddress, &PciData, &StdHeader);
139 TOM = (UINT32)MsrRead(TOP_MEM);
140 PciData = (TOM >> 8) | 0x03;
141 PciAddress.AddressValue = MAKE_SBDFO(0, 0, CONFIG_CDB + node, FUNC_1, 0x88);
142 LibAmdPciWrite(AccessWidth32, PciAddress, &PciData, &StdHeader);
144 /* Set MMCONF space to Node0 sbLink with NP set.
145 * default E0000000-EFFFFFFF
146 * Just have all mmio set to non-posted,
147 * coreboot not implemente the range by range setting yet.
149 PciAddress.AddressValue = MAKE_SBDFO(0, 0, CONFIG_CDB + node, FUNC_1, 0xBC);
150 PciData = CONFIG_MMCONF_BASE_ADDRESS + (CONFIG_MMCONF_BUS_NUMBER * 0x100000);//1MB each bus
151 PciData = (PciData >> 8) & 0xFFFFFF00;
152 PciData |= 0x80; //NP
153 PciData |= sblink << 4;
154 LibAmdPciWrite(AccessWidth32, PciAddress, &PciData, &StdHeader);
155 PciAddress.AddressValue = MAKE_SBDFO(0, 0, CONFIG_CDB + node, FUNC_1, 0xB8);
156 PciData = (PCIE_BASE_ADDRESS >> 8) | 0x03;
157 LibAmdPciWrite(AccessWidth32, PciAddress, &PciData, &StdHeader);
160 /* Set PCIO: 0x0 - 0xFFF000 to Node0 sbLink and enabled VGA IO*/
161 PciAddress.AddressValue = MAKE_SBDFO(0, 0, CONFIG_CDB + node, FUNC_1, 0xC4);
162 PciData = 0x00FFF000;
163 PciData |= sblink << 4;
164 LibAmdPciWrite(AccessWidth32, PciAddress, &PciData, &StdHeader);
165 PciAddress.AddressValue = MAKE_SBDFO(0, 0, CONFIG_CDB + node, FUNC_1, 0xC0);
166 PciData = 0x00000033;
167 LibAmdPciWrite(AccessWidth32, PciAddress, &PciData, &StdHeader);
170 Status = AGESA_SUCCESS;
171 return (UINT32)Status;
174 UINT32 agesawrapper_amdinitmmio(VOID)
178 AMD_CONFIG_PARAMS StdHeader;
181 * Set the MMIO Configuration Base Address and Bus Range onto
182 * MMIO configuration base Address MSR register.
184 MsrReg = CONFIG_MMCONF_BASE_ADDRESS | (LibAmdBitScanReverse(CONFIG_MMCONF_BUS_NUMBER) << 2) | 1;
185 LibAmdMsrWrite(0xC0010058, &MsrReg, &StdHeader);
188 * Set the NB_CFG MSR register. Enable CF8 extended configuration cycles.
190 LibAmdMsrRead(0xC001001F, &MsrReg, &StdHeader);
191 MsrReg = MsrReg | (1ULL << 46);
192 LibAmdMsrWrite(0xC001001F, &MsrReg, &StdHeader);
194 /* Set ROM cache onto WP to decrease post time */
195 MsrReg = (0x0100000000 - CONFIG_ROM_SIZE) | 5;
196 LibAmdMsrWrite (0x20C, &MsrReg, &StdHeader);
197 MsrReg = (0x1000000000 - CONFIG_ROM_SIZE) | 0x800;
198 LibAmdMsrWrite(0x20D, &MsrReg, &StdHeader);
200 Status = AGESA_SUCCESS;
201 return (UINT32)Status;
204 UINT32 agesawrapper_amdinitreset(VOID)
206 AGESA_STATUS status = AGESA_SUCCESS;
207 AMD_INTERFACE_PARAMS AmdParamStruct;
208 AMD_RESET_PARAMS AmdResetParams;
210 LibAmdMemFill(&AmdParamStruct,
212 sizeof(AMD_INTERFACE_PARAMS),
213 &(AmdParamStruct.StdHeader));
215 LibAmdMemFill(&AmdResetParams,
217 sizeof(AMD_RESET_PARAMS),
218 &(AmdResetParams.StdHeader));
220 AmdParamStruct.AgesaFunctionName = AMD_INIT_RESET;
221 AmdParamStruct.AllocationMethod = ByHost;
222 AmdParamStruct.NewStructSize = sizeof(AMD_RESET_PARAMS);
223 AmdParamStruct.NewStructPtr = &AmdResetParams;
224 AmdParamStruct.StdHeader.AltImageBasePtr = 0;
225 AmdParamStruct.StdHeader.CalloutPtr = NULL;
226 AmdParamStruct.StdHeader.Func = 0;
227 AmdParamStruct.StdHeader.ImageBasePtr = 0;
228 status = AmdCreateStruct(&AmdParamStruct);
229 if (status != AGESA_SUCCESS) {
230 return (UINT32)status;
232 AmdResetParams.HtConfig.Depth = 0;
234 //MARG34PI disabled AGESA_ENTRY_INIT_RESET by default
235 //but we need to call AmdCreateStruct to call HeapManagerInit, or the event log not work
236 #if (defined AGESA_ENTRY_INIT_RESET) && (AGESA_ENTRY_INIT_RESET == TRUE)
237 status = AmdInitReset((AMD_RESET_PARAMS *)AmdParamStruct.NewStructPtr);
239 if (status != AGESA_SUCCESS)
240 agesawrapper_amdreadeventlog(AmdParamStruct.StdHeader.HeapStatus);
241 AmdReleaseStruct(&AmdParamStruct);
243 return (UINT32)status;
246 UINT32 agesawrapper_amdinitearly(VOID)
249 AMD_INTERFACE_PARAMS AmdParamStruct;
250 AMD_EARLY_PARAMS *AmdEarlyParamsPtr;
252 CPU_SPECIFIC_SERVICES *FamilySpecificServices;
254 LibAmdMemFill(&AmdParamStruct,
256 sizeof(AMD_INTERFACE_PARAMS),
257 &(AmdParamStruct.StdHeader));
259 AmdParamStruct.AgesaFunctionName = AMD_INIT_EARLY;
260 AmdParamStruct.AllocationMethod = PreMemHeap;
261 AmdParamStruct.StdHeader.AltImageBasePtr = 0;
262 AmdParamStruct.StdHeader.CalloutPtr = (CALLOUT_ENTRY) &GetBiosCallout;
263 AmdParamStruct.StdHeader.Func = 0;
264 AmdParamStruct.StdHeader.ImageBasePtr = 0;
265 status = AmdCreateStruct(&AmdParamStruct);
266 if (status != AGESA_SUCCESS) {
267 return (UINT32)status;
270 AmdEarlyParamsPtr = (AMD_EARLY_PARAMS *)AmdParamStruct.NewStructPtr;
271 OemCustomizeInitEarly(AmdEarlyParamsPtr);
273 status = AmdInitEarly(AmdEarlyParamsPtr);
274 if (status != AGESA_SUCCESS)
275 agesawrapper_amdreadeventlog(AmdParamStruct.StdHeader.HeapStatus);
277 GetCpuServicesOfCurrentCore((CONST CPU_SPECIFIC_SERVICES **)&FamilySpecificServices, &AmdParamStruct.StdHeader);
278 FamilySpecificServices->GetTscRate(FamilySpecificServices, &TscRateInMhz, &AmdParamStruct.StdHeader);
279 printk(BIOS_DEBUG, "BSP Frequency: %luMHz\n", TscRateInMhz);
281 AmdReleaseStruct(&AmdParamStruct);
282 return (UINT32)status;
285 UINT32 agesawrapper_amdinitpost(VOID)
290 AMD_INTERFACE_PARAMS AmdParamStruct;
291 AMD_POST_PARAMS *PostParams;
292 BIOS_HEAP_MANAGER *BiosManagerPtr;
294 CPU_SPECIFIC_SERVICES *FamilySpecificServices;
296 LibAmdMemFill(&AmdParamStruct,
298 sizeof(AMD_INTERFACE_PARAMS),
299 &(AmdParamStruct.StdHeader));
301 AmdParamStruct.AgesaFunctionName = AMD_INIT_POST;
302 AmdParamStruct.AllocationMethod = PreMemHeap;
303 AmdParamStruct.StdHeader.AltImageBasePtr = 0;
304 AmdParamStruct.StdHeader.CalloutPtr = (CALLOUT_ENTRY) &GetBiosCallout;
305 AmdParamStruct.StdHeader.Func = 0;
306 AmdParamStruct.StdHeader.ImageBasePtr = 0;
308 status = AmdCreateStruct(&AmdParamStruct);
309 if (status != AGESA_SUCCESS) {
310 return (UINT32)status;
312 PostParams = (AMD_POST_PARAMS *)AmdParamStruct.NewStructPtr;
313 status = AmdInitPost(PostParams);
314 if (status != AGESA_SUCCESS) {
315 agesawrapper_amdreadeventlog(PostParams->StdHeader.HeapStatus);
317 AmdReleaseStruct(&AmdParamStruct);
319 /* Initialize heap space */
320 BiosManagerPtr = (BIOS_HEAP_MANAGER *)BIOS_HEAP_START_ADDRESS;
322 HeadPtr = (UINT32 *) ((UINT8 *) BiosManagerPtr + sizeof(BIOS_HEAP_MANAGER));
323 for (i = 0; i < ((BIOS_HEAP_SIZE/4) - (sizeof(BIOS_HEAP_MANAGER)/4)); i++) {
324 *HeadPtr = 0x00000000;
327 BiosManagerPtr->StartOfAllocatedNodes = 0;
328 BiosManagerPtr->StartOfFreedNodes = 0;
330 GetCpuServicesOfCurrentCore ((CONST CPU_SPECIFIC_SERVICES **)&FamilySpecificServices, &AmdParamStruct.StdHeader);
331 FamilySpecificServices->GetTscRate (FamilySpecificServices, &TscRateInMhz, &AmdParamStruct.StdHeader);
332 printk(BIOS_DEBUG, "BSP Frequency: %luMHz\n", TscRateInMhz);
334 return (UINT32)status;
337 UINT32 agesawrapper_amdinitenv(VOID)
340 AMD_INTERFACE_PARAMS AmdParamStruct;
341 AMD_ENV_PARAMS *EnvParams;
343 LibAmdMemFill(&AmdParamStruct,
345 sizeof(AMD_INTERFACE_PARAMS),
346 &(AmdParamStruct.StdHeader));
348 AmdParamStruct.AgesaFunctionName = AMD_INIT_ENV;
349 AmdParamStruct.AllocationMethod = PostMemDram;
350 AmdParamStruct.StdHeader.AltImageBasePtr = 0;
351 AmdParamStruct.StdHeader.CalloutPtr = (CALLOUT_ENTRY) &GetBiosCallout;
352 AmdParamStruct.StdHeader.Func = 0;
353 AmdParamStruct.StdHeader.ImageBasePtr = 0;
355 status = AmdCreateStruct(&AmdParamStruct);
356 if (status != AGESA_SUCCESS) {
357 return (UINT32)status;
359 EnvParams = (AMD_ENV_PARAMS *)AmdParamStruct.NewStructPtr;
360 status = AmdInitEnv(EnvParams);
361 if (status != AGESA_SUCCESS)
362 agesawrapper_amdreadeventlog(EnvParams->StdHeader.HeapStatus);
364 AmdReleaseStruct(&AmdParamStruct);
365 return (UINT32)status;
368 VOID * agesawrapper_getlateinitptr(int pick)
395 UINT32 agesawrapper_amdinitmid(VOID)
398 AMD_INTERFACE_PARAMS AmdParamStruct;
400 /* Enable MMIO on AMD CPU Address Map Controller */
401 agesawrapper_amdinitcpuio();
403 LibAmdMemFill(&AmdParamStruct,
405 sizeof(AMD_INTERFACE_PARAMS),
406 &(AmdParamStruct.StdHeader));
408 AmdParamStruct.AgesaFunctionName = AMD_INIT_MID;
409 AmdParamStruct.AllocationMethod = PostMemDram;
410 AmdParamStruct.StdHeader.AltImageBasePtr = 0;
411 AmdParamStruct.StdHeader.CalloutPtr = (CALLOUT_ENTRY) &GetBiosCallout;
412 AmdParamStruct.StdHeader.Func = 0;
413 AmdParamStruct.StdHeader.ImageBasePtr = 0;
415 status = AmdCreateStruct(&AmdParamStruct);
416 if (status != AGESA_SUCCESS) {
417 return (UINT32)status;
419 status = AmdInitMid((AMD_MID_PARAMS *)AmdParamStruct.NewStructPtr);
420 if (status != AGESA_SUCCESS)
421 agesawrapper_amdreadeventlog(AmdParamStruct.StdHeader.HeapStatus);
422 AmdReleaseStruct(&AmdParamStruct);
424 return (UINT32)status;
427 UINT32 agesawrapper_amdinitlate(VOID)
430 AMD_INTERFACE_PARAMS AmdParamStruct;
431 AMD_LATE_PARAMS *AmdLateParamsPtr;
433 LibAmdMemFill(&AmdParamStruct,
435 sizeof (AMD_INTERFACE_PARAMS),
436 &(AmdParamStruct.StdHeader));
438 AmdParamStruct.AgesaFunctionName = AMD_INIT_LATE;
439 AmdParamStruct.AllocationMethod = PostMemDram;
440 AmdParamStruct.StdHeader.AltImageBasePtr = 0;
441 AmdParamStruct.StdHeader.CalloutPtr = (CALLOUT_ENTRY) &GetBiosCallout;
442 AmdParamStruct.StdHeader.Func = 0;
443 AmdParamStruct.StdHeader.ImageBasePtr = 0;
445 AmdCreateStruct (&AmdParamStruct);
446 AmdLateParamsPtr = (AMD_LATE_PARAMS *) AmdParamStruct.NewStructPtr;
448 printk(BIOS_DEBUG, "agesawrapper_amdinitlate: AmdLateParamsPtr = %X\n", (u32)AmdLateParamsPtr);
450 Status = AmdInitLate(AmdLateParamsPtr);
451 if (Status != AGESA_SUCCESS) {
452 agesawrapper_amdreadeventlog(AmdLateParamsPtr->StdHeader.HeapStatus);
453 ASSERT(Status == AGESA_SUCCESS);
455 DmiTable = AmdLateParamsPtr->DmiTable;
456 AcpiPstate = AmdLateParamsPtr->AcpiPState;
457 AcpiSrat = AmdLateParamsPtr->AcpiSrat;
458 AcpiSlit = AmdLateParamsPtr->AcpiSlit;
459 AcpiWheaMce = AmdLateParamsPtr->AcpiWheaMce;
460 AcpiWheaCmc = AmdLateParamsPtr->AcpiWheaCmc;
461 AcpiAlib = AmdLateParamsPtr->AcpiAlib;
463 printk(BIOS_DEBUG, "In %s, AGESA generated ACPI tables:\n"
464 " DmiTable:%p\n AcpiPstate: %p\n AcpiSrat:%p\n AcpiSlit:%p\n"
465 " Mce:%p\n Cmc:%p\n Alib:%p\n",
466 __func__, DmiTable, AcpiPstate, AcpiSrat, AcpiSlit,
467 AcpiWheaMce, AcpiWheaCmc, AcpiAlib);
469 /* Don't release the structure until coreboot has copied the ACPI tables.
470 * AmdReleaseStruct (&AmdLateParams);
473 return (UINT32)Status;
477 * @param[in] UINTN ApicIdOfCore,
478 * @param[in] AP_EXE_PARAMS *LaunchApParams
480 UINT32 agesawrapper_amdlaterunaptask(UINT32 Data, VOID *ConfigPtr)
483 AMD_LATE_PARAMS AmdLateParams;
485 LibAmdMemFill(&AmdLateParams,
487 sizeof(AMD_LATE_PARAMS),
488 &(AmdLateParams.StdHeader));
490 AmdLateParams.StdHeader.AltImageBasePtr = 0;
491 AmdLateParams.StdHeader.CalloutPtr = (CALLOUT_ENTRY) &GetBiosCallout;
492 AmdLateParams.StdHeader.Func = 0;
493 AmdLateParams.StdHeader.ImageBasePtr = 0;
494 AmdLateParams.StdHeader.HeapStatus = HEAP_TEMP_MEM;
496 printk(BIOS_DEBUG, "AmdLateRunApTask on Core: %x\n", (uint32_t)Data);
497 Status = AmdLateRunApTask((AP_EXE_PARAMS *)ConfigPtr);
498 if (Status != AGESA_SUCCESS) {
499 agesawrapper_amdreadeventlog(AmdLateParams.StdHeader.HeapStatus);
500 ASSERT(Status <= AGESA_UNSUPPORTED);
503 return (UINT32)Status;
509 static void agesa_bound_check(EVENT_PARAMS *event)
511 switch (event->EventInfo) {
512 case CPU_ERROR_HEAP_IS_FULL:
513 printk(BIOS_DEBUG, "Heap allocation for specified buffer handle failed as heap is full\n");
516 case CPU_ERROR_HEAP_BUFFER_HANDLE_IS_ALREADY_USED:
517 printk(BIOS_DEBUG, "Allocation incomplete as buffer has previously been allocated\n");
520 case CPU_ERROR_HEAP_BUFFER_HANDLE_IS_NOT_PRESENT:
521 printk(BIOS_DEBUG, "Unable to locate buffer handle or deallocate heap as buffer handle cannot be located\n");
524 case CPU_ERROR_HEAP_BUFFER_IS_NOT_PRESENT:
525 printk(BIOS_DEBUG, "Unable to locate pointer to the heap buffer\n");
536 static void agesa_alert(EVENT_PARAMS *event)
538 switch (event->EventInfo) {
539 case MEM_ALERT_USER_TMG_MODE_OVERRULED:
540 printk(BIOS_DEBUG, "Socket %lx Dct %lx Channel %lx "
541 "TIMING_MODE_SPECIFIC is requested but can not be applied to current configurations.\n",
547 case MEM_ALERT_ORG_MISMATCH_DIMM:
548 printk(BIOS_DEBUG, "Socket %lx Dct %lx Channel %lx "
549 "DIMM organization miss-match\n",
555 case MEM_ALERT_BK_INT_DIS:
556 printk(BIOS_DEBUG, "Socket %lx Dct %lx Channel %lx "
557 "Bank interleaving disable for internal issue\n",
563 case CPU_EVENT_BIST_ERROR:
564 printk(BIOS_DEBUG, "BIST error: %lx reported on Socket %lx Core %lx\n",
570 case HT_EVENT_HW_SYNCFLOOD:
571 printk(BIOS_DEBUG, "HT_EVENT_DATA_HW_SYNCFLOOD error on Socket %lx Link %lx\n",
576 case HT_EVENT_HW_HTCRC:
577 printk(BIOS_DEBUG, "HT_EVENT_HW_HTCRC error on Socket %lx Link %lx Lanemask:%lx\n",
591 static void agesa_warning(EVENT_PARAMS *event)
594 if (event->EventInfo == CPU_EVENT_STACK_REENTRY) {
596 "The stack has already been enabled and this is a
597 redundant invocation of AMD_ENABLE_STACK. There is no event logged and
598 no data values. The event sub-class is returned along with the status code\n");
603 switch (event->EventInfo >> 24) {
605 printk(BIOS_DEBUG, "Memory: Socket %lx Dct %lx Channel%lx ",
612 printk(BIOS_DEBUG, "Processor: ");
616 printk(BIOS_DEBUG, "Hyper Transport: ");
623 switch (event->EventInfo) {
624 case MEM_WARNING_UNSUPPORTED_QRDIMM:
625 printk(BIOS_DEBUG, "QR DIMMs detected but not supported\n");
628 case MEM_WARNING_UNSUPPORTED_UDIMM:
629 printk(BIOS_DEBUG, "Unbuffered DIMMs detected but not supported\n");
632 case MEM_WARNING_UNSUPPORTED_SODIMM:
633 printk(BIOS_DEBUG, "SO-DIMMs detected but not supported");
636 case MEM_WARNING_UNSUPPORTED_X4DIMM:
637 printk(BIOS_DEBUG, "x4 DIMMs detected but not supported");
640 case MEM_WARNING_UNSUPPORTED_RDIMM:
641 printk(BIOS_DEBUG, "Registered DIMMs detected but not supported");
645 case MEM_WARNING_UNSUPPORTED_LRDIMM:
646 printk(BIOS_DEBUG, "Load Reduced DIMMs detected but not supported");
650 case MEM_WARNING_NO_SPDTRC_FOUND:
651 printk(BIOS_DEBUG, "NO_SPDTRC_FOUND");
654 case MEM_WARNING_EMP_NOT_SUPPORTED:
655 printk(BIOS_DEBUG, "Processor is not capable for EMP");//
658 case MEM_WARNING_EMP_CONFLICT:
659 printk(BIOS_DEBUG, "EMP cannot be enabled if channel interleaving bank interleaving, or bank swizzle is enabled\n");//
662 case MEM_WARNING_EMP_NOT_ENABLED:
663 printk(BIOS_DEBUG, "Memory size is not power of two\n");//
666 case MEM_WARNING_PERFORMANCE_ENABLED_BATTERY_LIFE_PREFERRED:
667 printk(BIOS_DEBUG, "MEM_WARNING_PERFORMANCE_ENABLED_BATTERY_LIFE_PREFERRED\n");
670 case MEM_WARNING_NODE_INTERLEAVING_NOT_ENABLED:
671 printk(BIOS_DEBUG, "MEM_WARNING_NODE_INTERLEAVING_NOT_ENABLED\n");
674 case MEM_WARNING_CHANNEL_INTERLEAVING_NOT_ENABLED:
675 printk(BIOS_DEBUG, "MEM_WARNING_CHANNEL_INTERLEAVING_NOT_ENABLED\n");
678 case MEM_WARNING_BANK_INTERLEAVING_NOT_ENABLED:
679 printk(BIOS_DEBUG, "MEM_WARNING_BANK_INTERLEAVING_NOT_ENABLED\n");
682 case MEM_WARNING_VOLTAGE_1_35_NOT_SUPPORTED:
683 printk(BIOS_DEBUG, "MEM_WARNING_VOLTAGE_1_35_NOT_SUPPORTED\n");
687 case MEM_WARNING_INITIAL_DDR3VOLT_NONZERO:
688 printk(BIOS_DEBUG, "MEM_WARNING_INITIAL_DDR3VOLT_NONZERO\n");
691 case MEM_WARNING_NO_COMMONLY_SUPPORTED_VDDIO:
692 printk(BIOS_DEBUG, "MEM_WARNING_NO_COMMONLY_SUPPORTED_VDDIO\n");
696 case CPU_EVENT_EXECUTION_CACHE_ALLOCATION_ERROR:
697 printk(BIOS_DEBUG, "Allocation rule number that has been violated:");
698 if ((event->EventInfo & 0x000000FF) == 0x01) {
699 printk(BIOS_DEBUG, "AGESA_CACHE_SIZE_REDUCED\n");
700 } else if ((event->EventInfo & 0x000000FF) == 0x02) {
701 printk(BIOS_DEBUG, "AGESA_CACHE_REGIONS_ACROSS_1MB\n");
702 } else if ((event->EventInfo & 0x000000FF) == 0x03) {
703 printk(BIOS_DEBUG, "AGESA_CACHE_REGIONS_ACROSS_4GB\n");
705 printk(BIOS_DEBUG, "cache region index:%lx, start:%lx size:%lx\n",
711 case CPU_WARNING_ADJUSTED_LEVELING_MODE:
712 printk(BIOS_DEBUG, "CPU_WARNING_ADJUSTED_LEVELING_MODE "
713 "requested: %lx, actual level:%lx\n",
718 case CPU_EVENT_PM_PSTATE_OVERCURRENT:
719 printk(BIOS_DEBUG, "CPU_EVENT_PM_PSTATE_OVERCURRENT "
720 "Socket: %lx, Pstate:%lx\n",
725 case CPU_WARNING_NONOPTIMAL_HT_ASSIST_CFG:
726 printk(BIOS_DEBUG, "CPU_WARNING_NONOPTIMAL_HT_ASSIST_CFG\n");
730 case CPU_EVENT_UNKNOWN_PROCESSOR_REVISION:
731 printk(BIOS_DEBUG, "CPU_EVENT_UNKNOWN_PROCESSOR_REVISION, socket: %lx, cpuid:%lx\n",
737 case HT_EVENT_OPT_REQUIRED_CAP_RETRY:
738 printk(BIOS_DEBUG, "HT_EVENT_OPT_REQUIRED_CAP_RETRY, Socket %lx Link %lx Depth %lx\n",
744 case HT_EVENT_OPT_REQUIRED_CAP_GEN3:
745 printk(BIOS_DEBUG, "HT_EVENT_OPT_REQUIRED_CAP_GEN3, Socket %lx Link %lx Depth %lx\n",
751 case HT_EVENT_OPT_UNUSED_LINKS:
752 printk(BIOS_DEBUG, "HT_EVENT_OPT_UNUSED_LINKS, SocketA%lx LinkA%lx SocketB%lx LinkB%lx\n",
759 case HT_EVENT_OPT_LINK_PAIR_EXCEED:
760 printk(BIOS_DEBUG, "HT_EVENT_OPT_LINK_PAIR_EXCEED, SocketA%lx MasterLink%lx SocketB%lx AltLink%lx\n",
774 static void agesa_error(EVENT_PARAMS *event)
777 switch (event->EventInfo >> 24) {
779 printk(BIOS_DEBUG, "Memory: Socket %lx Dct %lx Channel%lx ",
786 printk(BIOS_DEBUG, "Processor: ");
790 printk(BIOS_DEBUG, "Hyper Transport: ");
797 switch (event->EventInfo) {
798 case MEM_ERROR_NO_DQS_POS_RD_WINDOW:
799 printk(BIOS_DEBUG, "No DQS Position window for RD DQS\n");
802 case MEM_ERROR_SMALL_DQS_POS_RD_WINDOW:
803 printk(BIOS_DEBUG, "Small DQS Position window for RD DQS\n");
806 case MEM_ERROR_NO_DQS_POS_WR_WINDOW:
807 printk(BIOS_DEBUG, "No DQS Position window for WR DQS\n");
810 case MEM_ERROR_SMALL_DQS_POS_WR_WINDOW:
811 printk(BIOS_DEBUG, "Small DQS Position window for WR DQS\n");
814 case MEM_ERROR_DIMM_SPARING_NOT_ENABLED:
815 printk(BIOS_DEBUG, "DIMM sparing has not been enabled for an internal issues\n");
818 case MEM_ERROR_RCVR_EN_VALUE_TOO_LARGE:
819 printk(BIOS_DEBUG, "Receive Enable value is too large\n");
821 case MEM_ERROR_RCVR_EN_NO_PASSING_WINDOW:
822 printk(BIOS_DEBUG, "There is no DQS receiver enable window\n");
825 case MEM_ERROR_DRAM_ENABLED_TIME_OUT:
826 printk(BIOS_DEBUG, "Time out when polling DramEnabled bit\n");
829 case MEM_ERROR_DCT_ACCESS_DONE_TIME_OUT:
830 printk(BIOS_DEBUG, "Time out when polling DctAccessDone bit\n");
833 case MEM_ERROR_SEND_CTRL_WORD_TIME_OUT:
834 printk(BIOS_DEBUG, "Time out when polling SendCtrlWord bit\n");
837 case MEM_ERROR_PREF_DRAM_TRAIN_MODE_TIME_OUT:
838 printk(BIOS_DEBUG, "Time out when polling PrefDramTrainMode bit\n");
841 case MEM_ERROR_ENTER_SELF_REF_TIME_OUT:
842 printk(BIOS_DEBUG, "Time out when polling EnterSelfRef bit\n");
845 case MEM_ERROR_FREQ_CHG_IN_PROG_TIME_OUT:
846 printk(BIOS_DEBUG, "Time out when polling FreqChgInProg bit\n");
849 case MEM_ERROR_EXIT_SELF_REF_TIME_OUT:
850 printk(BIOS_DEBUG, "Time out when polling ExitSelfRef bit\n");
853 case MEM_ERROR_SEND_MRS_CMD_TIME_OUT:
854 printk(BIOS_DEBUG, "Time out when polling SendMrsCmd bit\n");
857 case MEM_ERROR_SEND_ZQ_CMD_TIME_OUT:
858 printk(BIOS_DEBUG, "Time out when polling SendZQCmd bit\n");
861 case MEM_ERROR_DCT_EXTRA_ACCESS_DONE_TIME_OUT:
862 printk(BIOS_DEBUG, "Time out when polling DctExtraAccessDone bit\n");
865 case MEM_ERROR_MEM_CLR_BUSY_TIME_OUT:
866 printk(BIOS_DEBUG, "Time out when polling MemClrBusy bit\n");
869 case MEM_ERROR_MEM_CLEARED_TIME_OUT:
870 printk(BIOS_DEBUG, "Time out when polling MemCleared bit\n");
873 case MEM_ERROR_FLUSH_WR_TIME_OUT:
874 printk(BIOS_DEBUG, "Time out when polling FlushWr bit\n");
877 case MEM_ERROR_MAX_LAT_NO_WINDOW:
878 printk(BIOS_DEBUG, "Fail to find pass during Max Rd Latency training\n");
881 case MEM_ERROR_PARALLEL_TRAINING_LAUNCH_FAIL:
882 printk(BIOS_DEBUG, "Fail to launch training code on an AP\n");
885 case MEM_ERROR_PARALLEL_TRAINING_TIME_OUT:
886 printk(BIOS_DEBUG, "Fail to finish parallel training\n");
889 case MEM_ERROR_NO_ADDRESS_MAPPING:
890 printk(BIOS_DEBUG, "No address mapping found for a dimm\n");
893 case MEM_ERROR_RCVR_EN_NO_PASSING_WINDOW_EQUAL_LIMIT:
894 printk(BIOS_DEBUG, "There is no DQS receiver enable window and the value is equal to the largest value\n");
897 case MEM_ERROR_RCVR_EN_VALUE_TOO_LARGE_LIMIT_LESS_ONE:
898 printk(BIOS_DEBUG, "Receive Enable value is too large and is 1 less than limit\n");
901 case MEM_ERROR_CHECKSUM_NV_SPDCHK_RESTRT_ERROR:
902 printk(BIOS_DEBUG, "SPD Checksum error for NV_SPDCHK_RESTRT\n");
905 case MEM_ERROR_NO_CHIPSELECT:
906 printk(BIOS_DEBUG, "No chipselects found\n");
909 case MEM_ERROR_UNSUPPORTED_333MHZ_UDIMM:
910 printk(BIOS_DEBUG, "Unbuffered dimm is not supported at 333MHz\n");
913 case MEM_ERROR_WL_PRE_OUT_OF_RANGE:
914 printk(BIOS_DEBUG, "Returned PRE value during write levelizzation was out of range\n");
917 case CPU_ERROR_BRANDID_HEAP_NOT_AVAILABLE:
918 printk(BIOS_DEBUG, "No heap is allocated for BrandId structure\n");
921 case CPU_ERROR_MICRO_CODE_PATCH_IS_NOT_LOADED:
922 printk(BIOS_DEBUG, "Unable to load micro code patch\n");
925 case CPU_ERROR_PSTATE_HEAP_NOT_AVAILABLE:
926 printk(BIOS_DEBUG, "No heap is allocated for the Pstate structure\n");
930 case CPU_ERROR_PM_NB_PSTATE_MISMATCH:
931 printk(BIOS_DEBUG, "NB P-state indicated by Index was disabled due to mismatch between processors\n");
935 case CPU_EVENT_EXECUTION_CACHE_ALLOCATION_ERROR:
936 printk(BIOS_DEBUG, "Allocation rule number that has been violated:");
937 if ((event->EventInfo & 0x000000FF) == 0x04) {
938 printk(BIOS_DEBUG, "AGESA_REGION_NOT_ALIGNED_ON_BOUNDARY\n");
939 } else if ((event->EventInfo & 0x000000FF) == 0x05) {
940 printk(BIOS_DEBUG, "AGESA_START_ADDRESS_LESS_D0000\n");
941 } else if ((event->EventInfo & 0x000000FF) == 0x06) {
942 printk(BIOS_DEBUG, "AGESA_THREE_CACHE_REGIONS_ABOVE_1MB\n");
943 } else if ((event->EventInfo & 0x000000FF) == 0x07) {
944 printk(BIOS_DEBUG, "AGESA_DEALLOCATE_CACHE_REGIONS\n");
946 printk(BIOS_DEBUG, "cache region index:%lx, start:%lx size:%lx\n",
952 case HT_EVENT_COH_NO_TOPOLOGY:
953 printk(BIOS_DEBUG, "no Matching Topology was found during coherent initializatio TotalHtNodes: %lx\n",
957 case HT_EVENT_NCOH_BUID_EXCEED:
958 printk(BIOS_DEBUG, "there is a limit of 32 unit IDs per chain Socket%lx Link%lx Depth%lx"
959 "Current BUID: %lx, Unit Count: %lx\n",
963 event->DataParam4 >> 16,
964 event->DataParam4 & 0x0000FFFF);
967 case HT_EVENT_NCOH_BUS_MAX_EXCEED:
968 printk(BIOS_DEBUG, "maximum auto bus limit exceeded, Socket %lx Link %lx Bus %lx\n",
974 case HT_EVENT_NCOH_CFG_MAP_EXCEED:
975 printk(BIOS_DEBUG, "there is a limit of four non-coherent chains, Socket %lx Link %lx\n",
980 case HT_EVENT_NCOH_DEVICE_FAILED:
981 printk(BIOS_DEBUG, "after assigning an IO Device an ID, it does not respond at the new ID"
982 "Socket %lx Link %lx Depth %lx DeviceID %lx\n",
994 static void agesa_critical(EVENT_PARAMS *event)
996 switch (event->EventInfo) {
997 case MEM_ERROR_HEAP_ALLOCATE_FOR_DMI_TABLE_DDR3:
998 printk(BIOS_DEBUG, "Socket: %lx, Heap allocation error for DMI table for DDR3\n",
1002 case MEM_ERROR_HEAP_ALLOCATE_FOR_DMI_TABLE_DDR2:
1003 printk(BIOS_DEBUG, "Socket: %lx, Heap allocation error for DMI table for DDR2\n",
1007 case MEM_ERROR_UNSUPPORTED_DIMM_CONFIG:
1008 printk(BIOS_DEBUG, "Socket: %lx, Dimm population is not supported\n",
1012 case HT_EVENT_COH_PROCESSOR_TYPE_MIX:
1013 printk(BIOS_DEBUG, "Socket %lx Link %lx TotalSockets %lx, HT_EVENT_COH_PROCESSOR_TYPE_MIX \n",
1019 case HT_EVENT_COH_MPCAP_MISMATCH:
1020 printk(BIOS_DEBUG, "Socket %lx Link %lx MpCap %lx TotalSockets %lx, HT_EVENT_COH_MPCAP_MISMATCH\n",
1033 static void agesa_fatal(EVENT_PARAMS *event)
1036 switch (event->EventInfo >> 24) {
1038 printk(BIOS_DEBUG, "Memory: Socket %lx Dct %lx Channel%lx ",
1045 printk(BIOS_DEBUG, "Processor: ");
1049 printk(BIOS_DEBUG, "Hyper Transport: ");
1056 switch (event->EventInfo) {
1057 case MEM_ERROR_MINIMUM_MODE:
1058 printk(BIOS_DEBUG, "Running in minimum mode\n");
1061 case MEM_ERROR_MODULE_TYPE_MISMATCH_DIMM:
1062 printk(BIOS_DEBUG, "DIMM modules are missmatched\n");
1065 case MEM_ERROR_NO_DIMM_FOUND_ON_SYSTEM:
1066 printk(BIOS_DEBUG, "No DIMMs have been foun\n");
1069 case MEM_ERROR_MISMATCH_DIMM_CLOCKS:
1070 printk(BIOS_DEBUG, "DIMM clocks miss-matched\n");
1073 case MEM_ERROR_NO_CYC_TIME:
1074 printk(BIOS_DEBUG, "No cycle time found\n");
1076 case MEM_ERROR_HEAP_ALLOCATE_DYN_STORING_OF_TRAINED_TIMINGS:
1077 printk(BIOS_DEBUG, "Heap allocation error with dynamic storing of trained timings\n");
1080 case MEM_ERROR_HEAP_ALLOCATE_FOR_DCT_STRUCT_AND_CH_DEF_STRUCTs:
1081 printk(BIOS_DEBUG, "Heap allocation error for DCT_STRUCT and CH_DEF_STRUCT\n");
1084 case MEM_ERROR_HEAP_ALLOCATE_FOR_REMOTE_TRAINING_ENV:
1085 printk(BIOS_DEBUG, "Heap allocation error with REMOTE_TRAINING_ENV\n");
1088 case MEM_ERROR_HEAP_ALLOCATE_FOR_SPD:
1089 printk(BIOS_DEBUG, "Heap allocation error for SPD data\n");
1092 case MEM_ERROR_HEAP_ALLOCATE_FOR_RECEIVED_DATA:
1093 printk(BIOS_DEBUG, "Heap allocation error for RECEIVED_DATA during parallel training\n");
1096 case MEM_ERROR_HEAP_ALLOCATE_FOR_S3_SPECIAL_CASE_REGISTERS:
1097 printk(BIOS_DEBUG, "Heap allocation error for S3 \"SPECIAL_CASE_REGISTER\"\n");
1100 case MEM_ERROR_HEAP_ALLOCATE_FOR_TRAINING_DATA:
1101 printk(BIOS_DEBUG, "Heap allocation error for Training Data\n");
1104 case MEM_ERROR_HEAP_ALLOCATE_FOR_IDENTIFY_DIMM_MEM_NB_BLOCK:
1105 printk(BIOS_DEBUG, "Heap allocation error for DIMM Identify \"MEM_NB_BLOCK\"\n");
1108 case MEM_ERROR_NO_CONSTRUCTOR_FOR_IDENTIFY_DIMM:
1109 printk(BIOS_DEBUG, "No Constructor for DIMM Identify\n");
1112 case MEM_ERROR_VDDIO_UNSUPPORTED:
1113 printk(BIOS_DEBUG, "VDDIO of the dimms on the board is not supported\n");
1116 case CPU_EVENT_PM_ALL_PSTATE_OVERCURRENT:
1117 printk(BIOS_DEBUG, "Socket: %lx, All PStates exceeded the motherboard current limit on specified socket\n",
1128 * Interprte the agesa event log to an user readable string
1130 static void interpret_agesa_eventlog(EVENT_PARAMS *event)
1132 switch (event->EventClass) {
1133 case AGESA_BOUNDS_CHK:
1134 agesa_bound_check(event);
1142 agesa_warning(event);
1149 case AGESA_CRITICAL:
1150 agesa_critical(event);
1163 * @param HeapStatus -the current HeapStatus
1165 UINT32 agesawrapper_amdreadeventlog(UINT8 HeapStatus)
1167 printk(BIOS_DEBUG, "enter in %s\n", __func__);
1168 AGESA_STATUS Status;
1169 EVENT_PARAMS AmdEventParams;
1171 LibAmdMemFill(&AmdEventParams,
1173 sizeof(EVENT_PARAMS),
1174 &(AmdEventParams.StdHeader));
1176 AmdEventParams.StdHeader.AltImageBasePtr = 0;
1177 AmdEventParams.StdHeader.CalloutPtr = NULL;
1178 AmdEventParams.StdHeader.Func = 0;
1179 AmdEventParams.StdHeader.ImageBasePtr = 0;
1180 /* I have to know the current HeapStatus to Locate the EventLogHeapPointer */
1181 AmdEventParams.StdHeader.HeapStatus = HeapStatus;
1182 Status = AmdReadEventLog(&AmdEventParams);
1183 while (AmdEventParams.EventClass != 0) {
1184 printk(BIOS_DEBUG,"\nEventLog: EventClass = %lx, EventInfo = %lx.\n",AmdEventParams.EventClass,AmdEventParams.EventInfo);
1185 printk(BIOS_DEBUG," Param1 = %lx, Param2 = %lx.\n",AmdEventParams.DataParam1,AmdEventParams.DataParam2);
1186 printk(BIOS_DEBUG," Param3 = %lx, Param4 = %lx.\n",AmdEventParams.DataParam3,AmdEventParams.DataParam4);
1187 interpret_agesa_eventlog(&AmdEventParams);
1188 Status = AmdReadEventLog(&AmdEventParams);
1191 printk(BIOS_DEBUG, "exit %s \n", __func__);
1192 return (UINT32)Status;