summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKyösti Mälkki <kyosti.malkki@gmail.com>2017-07-29 08:11:52 +0300
committerKyösti Mälkki <kyosti.malkki@gmail.com>2017-08-02 04:40:37 +0000
commit0a7cab8de85d205bb4193e797f5987a6a68e6348 (patch)
tree0b07f28e0945bc37a7cf7c96a689e63428bb0f47 /src
parent0e01c4841ddcd2216ab21d3f009024bfc8879908 (diff)
downloadcoreboot-0a7cab8de85d205bb4193e797f5987a6a68e6348.tar.xz
AGESA: Refactor eventlog read loop
Also avoid infinite loop. Change-Id: I7571f9efdc2bf0335788136b8c56e9290581d748 Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: https://review.coreboot.org/20695 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'src')
-rw-r--r--src/northbridge/amd/agesa/eventlog.c70
-rw-r--r--src/northbridge/amd/agesa/state_machine.h1
-rw-r--r--src/northbridge/amd/pi/Makefile.inc4
-rw-r--r--src/northbridge/amd/pi/agesawrapper.c27
-rw-r--r--src/northbridge/amd/pi/agesawrapper.h1
5 files changed, 54 insertions, 49 deletions
diff --git a/src/northbridge/amd/agesa/eventlog.c b/src/northbridge/amd/agesa/eventlog.c
index c8dbe6025e..3291333dca 100644
--- a/src/northbridge/amd/agesa/eventlog.c
+++ b/src/northbridge/amd/agesa/eventlog.c
@@ -739,11 +739,44 @@ static void interpret_agesa_eventlog(EVENT_PARAMS *event)
}
#endif
-static void amd_readeventlog(AMD_CONFIG_PARAMS *StdHeader)
+static void show_event(EVENT_PARAMS *Event)
+{
+ printk(BIOS_DEBUG,"\nEventLog: EventClass = %x, EventInfo = %x.\n",
+ (unsigned int)Event->EventClass,
+ (unsigned int)Event->EventInfo);
+ printk(BIOS_DEBUG," Param1 = %x, Param2 = %x.\n",
+ (unsigned int)Event->DataParam1,
+ (unsigned int)Event->DataParam2);
+ printk(BIOS_DEBUG," Param3 = %x, Param4 = %x.\n",
+ (unsigned int)Event->DataParam3,
+ (unsigned int)Event->DataParam4);
+}
+
+#define MAX_LOG_ENTRIES 100
+
+static void amd_flush_eventlog(EVENT_PARAMS *Event)
+{
+ int i = 0;
+
+ do {
+ AGESA_STATUS status = AmdReadEventLog(Event);
+ if (status != AGESA_SUCCESS)
+ return;
+ if (Event->EventClass == 0)
+ return;
+ show_event(Event);
+ } while (++i < MAX_LOG_ENTRIES);
+}
+
+void agesawrapper_trace(AGESA_STATUS ret, AMD_CONFIG_PARAMS *StdHeader,
+ const char *func)
{
- AGESA_STATUS status;
EVENT_PARAMS AmdEventParams;
+ printk(BIOS_DEBUG, "%s() returned %s\n", func, decodeAGESA_STATUS(ret));
+ if (ret == AGESA_SUCCESS)
+ return;
+
memset(&AmdEventParams, 0, sizeof(EVENT_PARAMS));
AmdEventParams.StdHeader.AltImageBasePtr = 0;
@@ -752,25 +785,22 @@ static void amd_readeventlog(AMD_CONFIG_PARAMS *StdHeader)
AmdEventParams.StdHeader.ImageBasePtr = 0;
AmdEventParams.StdHeader.HeapStatus = StdHeader->HeapStatus;
- status = AmdReadEventLog(&AmdEventParams);
- while ((status == AGESA_SUCCESS) && (AmdEventParams.EventClass != 0)) {
- printk(BIOS_DEBUG,"\nEventLog: EventClass = %x, EventInfo = %x.\n",
- (unsigned int)AmdEventParams.EventClass,
- (unsigned int)AmdEventParams.EventInfo);
- printk(BIOS_DEBUG," Param1 = %x, Param2 = %x.\n",
- (unsigned int)AmdEventParams.DataParam1,
- (unsigned int)AmdEventParams.DataParam2);
- printk(BIOS_DEBUG," Param3 = %x, Param4 = %x.\n",
- (unsigned int)AmdEventParams.DataParam3,
- (unsigned int)AmdEventParams.DataParam4);
- status = AmdReadEventLog(&AmdEventParams);
- }
+ amd_flush_eventlog(&AmdEventParams);
}
-
-void agesawrapper_trace(AGESA_STATUS ret, AMD_CONFIG_PARAMS *StdHeader, const char *func)
+AGESA_STATUS agesawrapper_amdreadeventlog (UINT8 HeapStatus)
{
- printk(BIOS_DEBUG, "%s() returned %s\n", func, decodeAGESA_STATUS(ret));
- if (ret != AGESA_SUCCESS)
- amd_readeventlog(StdHeader);
+ EVENT_PARAMS AmdEventParams;
+
+ memset(&AmdEventParams, 0, sizeof(EVENT_PARAMS));
+
+ AmdEventParams.StdHeader.AltImageBasePtr = 0;
+ AmdEventParams.StdHeader.CalloutPtr = &GetBiosCallout;
+ AmdEventParams.StdHeader.Func = 0;
+ AmdEventParams.StdHeader.ImageBasePtr = 0;
+ AmdEventParams.StdHeader.HeapStatus = HeapStatus;
+
+ amd_flush_eventlog(&AmdEventParams);
+
+ return AGESA_SUCCESS;
}
diff --git a/src/northbridge/amd/agesa/state_machine.h b/src/northbridge/amd/agesa/state_machine.h
index 8711503456..86424d1084 100644
--- a/src/northbridge/amd/agesa/state_machine.h
+++ b/src/northbridge/amd/agesa/state_machine.h
@@ -23,6 +23,7 @@
const char *agesa_struct_name(int state);
const char *heap_status_name(int status);
void agesawrapper_trace(AGESA_STATUS ret, AMD_CONFIG_PARAMS *StdHeader, const char *func);
+AGESA_STATUS agesawrapper_amdreadeventlog(UINT8 HeapStatus);
struct sysinfo
{
diff --git a/src/northbridge/amd/pi/Makefile.inc b/src/northbridge/amd/pi/Makefile.inc
index c12c405098..43c6e83ab4 100644
--- a/src/northbridge/amd/pi/Makefile.inc
+++ b/src/northbridge/amd/pi/Makefile.inc
@@ -22,8 +22,8 @@ subdirs-$(CONFIG_NORTHBRIDGE_AMD_PI_00660F01) += 00660F01
romstage-y += agesawrapper.c
ramstage-y += agesawrapper.c
-romstage-y += ../agesa/def_callouts.c
-ramstage-y += ../agesa/def_callouts.c ../agesa/acpi_tables.c
+romstage-y += ../agesa/def_callouts.c ../agesa/eventlog.c
+ramstage-y += ../agesa/def_callouts.c ../agesa/eventlog.c ../agesa/acpi_tables.c
romstage-y += ramtop.c
ramstage-y += ramtop.c
diff --git a/src/northbridge/amd/pi/agesawrapper.c b/src/northbridge/amd/pi/agesawrapper.c
index 4274d40b6c..0d4b24fd6e 100644
--- a/src/northbridge/amd/pi/agesawrapper.c
+++ b/src/northbridge/amd/pi/agesawrapper.c
@@ -21,6 +21,7 @@
#include <cpuRegisters.h>
#include <FchPlatform.h>
#include <heapManager.h>
+#include <northbridge/amd/agesa/state_machine.h>
#include <northbridge/amd/pi/agesawrapper.h>
#include <northbridge/amd/agesa/BiosCallOuts.h>
@@ -315,32 +316,6 @@ AGESA_STATUS agesawrapper_amdlaterunaptask (
return Status;
}
-AGESA_STATUS agesawrapper_amdreadeventlog (UINT8 HeapStatus)
-{
- AGESA_STATUS Status;
- EVENT_PARAMS AmdEventParams;
-
- LibAmdMemFill (&AmdEventParams,
- 0,
- sizeof(EVENT_PARAMS),
- &(AmdEventParams.StdHeader));
-
- AmdEventParams.StdHeader.AltImageBasePtr = 0;
- AmdEventParams.StdHeader.CalloutPtr = &GetBiosCallout;
- AmdEventParams.StdHeader.Func = 0;
- AmdEventParams.StdHeader.ImageBasePtr = 0;
- AmdEventParams.StdHeader.HeapStatus = HeapStatus;
- Status = AmdReadEventLog (&AmdEventParams);
- while (AmdEventParams.EventClass != 0) {
- printk(BIOS_DEBUG,"\nEventLog: EventClass = %x, EventInfo = %x.\n", (unsigned int)AmdEventParams.EventClass,(unsigned int)AmdEventParams.EventInfo);
- printk(BIOS_DEBUG," Param1 = %x, Param2 = %x.\n",(unsigned int)AmdEventParams.DataParam1, (unsigned int)AmdEventParams.DataParam2);
- printk(BIOS_DEBUG," Param3 = %x, Param4 = %x.\n",(unsigned int)AmdEventParams.DataParam3, (unsigned int)AmdEventParams.DataParam4);
- Status = AmdReadEventLog (&AmdEventParams);
- }
-
- return Status;
-}
-
const void *agesawrapper_locate_module (const CHAR8 name[8])
{
const void* agesa;
diff --git a/src/northbridge/amd/pi/agesawrapper.h b/src/northbridge/amd/pi/agesawrapper.h
index 5cc3ab107f..53283a1dbb 100644
--- a/src/northbridge/amd/pi/agesawrapper.h
+++ b/src/northbridge/amd/pi/agesawrapper.h
@@ -38,7 +38,6 @@ AGESA_STATUS agesawrapper_amdinitenv(void);
AGESA_STATUS agesawrapper_amdinitlate(void);
AGESA_STATUS agesawrapper_amdinitpost(void);
AGESA_STATUS agesawrapper_amdinitmid(void);
-AGESA_STATUS agesawrapper_amdreadeventlog(UINT8 HeapStatus);
void agesawrapper_setlateinitptr (void *Late);
void *agesawrapper_getlateinitptr(int pick);
AGESA_STATUS agesawrapper_amdlaterunaptask(UINT32 Func, UINTN Data, void *ConfigPtr);