From 4c5a3b67e0767c59e9db27fa84e09effcb57209e Mon Sep 17 00:00:00 2001 From: Marshall Dawson Date: Thu, 25 Jan 2018 11:13:35 -0700 Subject: soc/amd/common: Add generic create_struct call to wrapper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Create a generic function that reports an unsuccessful call to AmdCreateStruct(). Change-Id: I2654b4f21de5a2621086142681181a687be2c8e3 Signed-off-by: Marshall Dawson Reviewed-on: https://review.coreboot.org/23440 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin Reviewed-by: Kyösti Mälkki --- src/soc/amd/common/block/pi/agesawrapper.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'src/soc/amd/common') diff --git a/src/soc/amd/common/block/pi/agesawrapper.c b/src/soc/amd/common/block/pi/agesawrapper.c index 976412778a..d454e32289 100644 --- a/src/soc/amd/common/block/pi/agesawrapper.c +++ b/src/soc/amd/common/block/pi/agesawrapper.c @@ -69,6 +69,22 @@ static AGESA_STATUS agesawrapper_readeventlog(UINT8 HeapStatus) return Status; } +static AGESA_STATUS create_struct(AMD_INTERFACE_PARAMS *interface_struct) +{ + AGESA_STATUS status = AmdCreateStruct(interface_struct); + if (status == AGESA_SUCCESS) + return status; + + printk(BIOS_ERR, "Error: AmdCreateStruct() for 0x%x returned 0x%x. " + "Proper system initialization may not be possible.\n", + interface_struct->AgesaFunctionName, status); + + if (!interface_struct->NewStructPtr) /* Avoid NULL pointer usage */ + die("No AGESA structure created"); + + return status; +} + AGESA_STATUS agesawrapper_amdinitreset(void) { AGESA_STATUS status; @@ -80,7 +96,7 @@ AGESA_STATUS agesawrapper_amdinitreset(void) .NewStructPtr = &ResetParams, .StdHeader.CalloutPtr = &GetBiosCallout }; - AmdCreateStruct(&AmdParamStruct); + create_struct(&AmdParamStruct); SetFchResetParams(&ResetParams.FchInterface); timestamp_add_now(TS_AGESA_INIT_RESET_START); @@ -103,7 +119,7 @@ AGESA_STATUS agesawrapper_amdinitearly(void) .StdHeader.CalloutPtr = &GetBiosCallout, }; - AmdCreateStruct(&AmdParamStruct); + create_struct(&AmdParamStruct); EarlyParams = (AMD_EARLY_PARAMS *)AmdParamStruct.NewStructPtr; OemCustomizeInitEarly(EarlyParams); @@ -164,7 +180,7 @@ AGESA_STATUS agesawrapper_amdinitpost(void) }; AMD_POST_PARAMS *PostParams; - AmdCreateStruct(&AmdParamStruct); + create_struct(&AmdParamStruct); PostParams = (AMD_POST_PARAMS *)AmdParamStruct.NewStructPtr; PostParams->MemConfig.UmaMode = CONFIG_GFXUMA ? UMA_AUTO : UMA_NONE; @@ -215,7 +231,7 @@ AGESA_STATUS agesawrapper_amdinitenv(void) }; AMD_ENV_PARAMS *EnvParams; - status = AmdCreateStruct(&AmdParamStruct); + status = create_struct(&AmdParamStruct); EnvParams = (AMD_ENV_PARAMS *)AmdParamStruct.NewStructPtr; SetFchEnvParams(&EnvParams->FchInterface); @@ -270,7 +286,7 @@ AGESA_STATUS agesawrapper_amdinitmid(void) /* Enable MMIO on AMD CPU Address Map Controller */ amd_initcpuio(); - AmdCreateStruct(&AmdParamStruct); + create_struct(&AmdParamStruct); MidParams = (AMD_MID_PARAMS *)AmdParamStruct.NewStructPtr; SetFchMidParams(&MidParams->FchInterface); @@ -301,7 +317,7 @@ AGESA_STATUS agesawrapper_amdinitlate(void) * NOTE: if not call amdcreatestruct, the initializer * (AmdInitLateInitializer) would not be called. */ - AmdCreateStruct(&AmdParamStruct); + create_struct(&AmdParamStruct); LateParams = (AMD_LATE_PARAMS *)AmdParamStruct.NewStructPtr; timestamp_add_now(TS_AGESA_INIT_LATE_START); -- cgit v1.2.3