From 0a7cab8de85d205bb4193e797f5987a6a68e6348 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ky=C3=B6sti=20M=C3=A4lkki?= Date: Sat, 29 Jul 2017 08:11:52 +0300 Subject: AGESA: Refactor eventlog read loop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also avoid infinite loop. Change-Id: I7571f9efdc2bf0335788136b8c56e9290581d748 Signed-off-by: Kyösti Mälkki Reviewed-on: https://review.coreboot.org/20695 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin --- src/northbridge/amd/agesa/eventlog.c | 70 ++++++++++++++++++++++--------- src/northbridge/amd/agesa/state_machine.h | 1 + src/northbridge/amd/pi/Makefile.inc | 4 +- src/northbridge/amd/pi/agesawrapper.c | 27 +----------- src/northbridge/amd/pi/agesawrapper.h | 1 - 5 files changed, 54 insertions(+), 49 deletions(-) (limited to 'src/northbridge/amd') 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 #include #include +#include #include #include @@ -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); -- cgit v1.2.3