summaryrefslogtreecommitdiff
path: root/src/northbridge/amd/agesa
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/northbridge/amd/agesa
parent0e01c4841ddcd2216ab21d3f009024bfc8879908 (diff)
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/northbridge/amd/agesa')
-rw-r--r--src/northbridge/amd/agesa/eventlog.c70
-rw-r--r--src/northbridge/amd/agesa/state_machine.h1
2 files changed, 51 insertions, 20 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
{