soc/amd/common: Change create_struct return value

Old return value was not used, and function body
has die() in case of errors in allocation.

Change-Id: I89b0e9c927d395ac6d27201e0b3a8658e9585187
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: https://review.coreboot.org/27261
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Garrett Kirkendall <garrett.kirkendall@amd.corp-partner.google.com>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
This commit is contained in:
Kyösti Mälkki 2018-06-14 06:57:05 +03:00 committed by Patrick Georgi
parent 108fb8a37e
commit 2fc1a37c04
1 changed files with 17 additions and 41 deletions

View File

@ -74,23 +74,23 @@ static AGESA_STATUS agesawrapper_readeventlog(UINT8 HeapStatus)
return Status; return Status;
} }
static AGESA_STATUS create_struct(AMD_INTERFACE_PARAMS *interface_struct) static void *create_struct(AMD_INTERFACE_PARAMS *interface_struct)
{ {
/* Should clone entire StdHeader here. */ /* Should clone entire StdHeader here. */
interface_struct->StdHeader.CalloutPtr = &GetBiosCallout; interface_struct->StdHeader.CalloutPtr = &GetBiosCallout;
AGESA_STATUS status = AmdCreateStruct(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. " if (status != AGESA_SUCCESS) {
"Proper system initialization may not be possible.\n", printk(BIOS_ERR, "Error: AmdCreateStruct() for 0x%x returned 0x%x. "
interface_struct->AgesaFunctionName, status); "Proper system initialization may not be possible.\n",
interface_struct->AgesaFunctionName, status);
}
if (!interface_struct->NewStructPtr) /* Avoid NULL pointer usage */ if (!interface_struct->NewStructPtr) /* Avoid NULL pointer usage */
die("No AGESA structure created"); die("No AGESA structure created");
return status; return interface_struct->NewStructPtr;
} }
AGESA_STATUS agesawrapper_amdinitreset(void) AGESA_STATUS agesawrapper_amdinitreset(void)
@ -103,11 +103,9 @@ AGESA_STATUS agesawrapper_amdinitreset(void)
.NewStructSize = sizeof(AMD_RESET_PARAMS), .NewStructSize = sizeof(AMD_RESET_PARAMS),
.NewStructPtr = &_ResetParams, .NewStructPtr = &_ResetParams,
}; };
AMD_RESET_PARAMS *ResetParams;
create_struct(&AmdParamStruct); AMD_RESET_PARAMS *ResetParams = create_struct(&AmdParamStruct);
ResetParams = (AMD_RESET_PARAMS *)AmdParamStruct.NewStructPtr;
SetFchResetParams(&ResetParams->FchInterface); SetFchResetParams(&ResetParams->FchInterface);
timestamp_add_now(TS_AGESA_INIT_RESET_START); timestamp_add_now(TS_AGESA_INIT_RESET_START);
@ -123,15 +121,13 @@ AGESA_STATUS agesawrapper_amdinitreset(void)
AGESA_STATUS agesawrapper_amdinitearly(void) AGESA_STATUS agesawrapper_amdinitearly(void)
{ {
AGESA_STATUS status; AGESA_STATUS status;
AMD_EARLY_PARAMS *EarlyParams;
AMD_INTERFACE_PARAMS AmdParamStruct = { AMD_INTERFACE_PARAMS AmdParamStruct = {
.AgesaFunctionName = AMD_INIT_EARLY, .AgesaFunctionName = AMD_INIT_EARLY,
.AllocationMethod = PreMemHeap, .AllocationMethod = PreMemHeap,
}; };
create_struct(&AmdParamStruct); AMD_EARLY_PARAMS *EarlyParams = create_struct(&AmdParamStruct);
EarlyParams = (AMD_EARLY_PARAMS *)AmdParamStruct.NewStructPtr;
OemCustomizeInitEarly(EarlyParams); OemCustomizeInitEarly(EarlyParams);
EarlyParams->GnbConfig.PsppPolicy = PsppDisabled; EarlyParams->GnbConfig.PsppPolicy = PsppDisabled;
@ -187,11 +183,9 @@ AGESA_STATUS agesawrapper_amdinitpost(void)
.AgesaFunctionName = AMD_INIT_POST, .AgesaFunctionName = AMD_INIT_POST,
.AllocationMethod = PreMemHeap, .AllocationMethod = PreMemHeap,
}; };
AMD_POST_PARAMS *PostParams;
create_struct(&AmdParamStruct); AMD_POST_PARAMS *PostParams = create_struct(&AmdParamStruct);
PostParams = (AMD_POST_PARAMS *)AmdParamStruct.NewStructPtr;
PostParams->MemConfig.UmaMode = CONFIG_GFXUMA ? UMA_AUTO : UMA_NONE; PostParams->MemConfig.UmaMode = CONFIG_GFXUMA ? UMA_AUTO : UMA_NONE;
PostParams->MemConfig.UmaSize = 0; PostParams->MemConfig.UmaSize = 0;
PostParams->MemConfig.BottomIo = (UINT16) PostParams->MemConfig.BottomIo = (UINT16)
@ -244,11 +238,9 @@ AGESA_STATUS agesawrapper_amdinitenv(void)
.AgesaFunctionName = AMD_INIT_ENV, .AgesaFunctionName = AMD_INIT_ENV,
.AllocationMethod = PostMemDram, .AllocationMethod = PostMemDram,
}; };
AMD_ENV_PARAMS *EnvParams;
status = create_struct(&AmdParamStruct); AMD_ENV_PARAMS *EnvParams = create_struct(&AmdParamStruct);
EnvParams = (AMD_ENV_PARAMS *)AmdParamStruct.NewStructPtr;
SetFchEnvParams(&EnvParams->FchInterface); SetFchEnvParams(&EnvParams->FchInterface);
SetNbEnvParams(&EnvParams->GnbEnvConfiguration); SetNbEnvParams(&EnvParams->GnbEnvConfiguration);
@ -296,14 +288,12 @@ AGESA_STATUS agesawrapper_amdinitmid(void)
.AgesaFunctionName = AMD_INIT_MID, .AgesaFunctionName = AMD_INIT_MID,
.AllocationMethod = PostMemDram, .AllocationMethod = PostMemDram,
}; };
AMD_MID_PARAMS *MidParams;
/* Enable MMIO on AMD CPU Address Map Controller */ /* Enable MMIO on AMD CPU Address Map Controller */
amd_initcpuio(); amd_initcpuio();
create_struct(&AmdParamStruct); AMD_MID_PARAMS *MidParams = create_struct(&AmdParamStruct);
MidParams = (AMD_MID_PARAMS *)AmdParamStruct.NewStructPtr;
SetFchMidParams(&MidParams->FchInterface); SetFchMidParams(&MidParams->FchInterface);
SetNbMidParams(&MidParams->GnbMidConfiguration); SetNbMidParams(&MidParams->GnbMidConfiguration);
@ -325,14 +315,12 @@ AGESA_STATUS agesawrapper_amdinitlate(void)
.AgesaFunctionName = AMD_INIT_LATE, .AgesaFunctionName = AMD_INIT_LATE,
.AllocationMethod = PostMemDram, .AllocationMethod = PostMemDram,
}; };
AMD_LATE_PARAMS *LateParams;
/* /*
* NOTE: if not call amdcreatestruct, the initializer * NOTE: if not call amdcreatestruct, the initializer
* (AmdInitLateInitializer) would not be called. * (AmdInitLateInitializer) would not be called.
*/ */
create_struct(&AmdParamStruct); AMD_LATE_PARAMS *LateParams = create_struct(&AmdParamStruct);
LateParams = (AMD_LATE_PARAMS *)AmdParamStruct.NewStructPtr;
timestamp_add_now(TS_AGESA_INIT_LATE_START); timestamp_add_now(TS_AGESA_INIT_LATE_START);
Status = AmdInitLate(LateParams); Status = AmdInitLate(LateParams);
@ -394,11 +382,8 @@ AGESA_STATUS agesawrapper_amdinitrtb(void)
.AgesaFunctionName = AMD_INIT_RTB, .AgesaFunctionName = AMD_INIT_RTB,
.AllocationMethod = PostMemDram, .AllocationMethod = PostMemDram,
}; };
AMD_RTB_PARAMS *RtbParams;
create_struct(&AmdParamStruct); AMD_RTB_PARAMS *RtbParams = create_struct(&AmdParamStruct);
RtbParams = (AMD_RTB_PARAMS *)AmdParamStruct.NewStructPtr;
timestamp_add_now(TS_AGESA_INIT_RTB_START); timestamp_add_now(TS_AGESA_INIT_RTB_START);
Status = AmdInitRtb(RtbParams); Status = AmdInitRtb(RtbParams);
@ -427,15 +412,12 @@ AGESA_STATUS agesawrapper_amdinitresume(void)
.AgesaFunctionName = AMD_INIT_RESUME, .AgesaFunctionName = AMD_INIT_RESUME,
.AllocationMethod = PreMemHeap, .AllocationMethod = PreMemHeap,
}; };
AMD_RESUME_PARAMS *InitResumeParams;
size_t nv_size; size_t nv_size;
if (!acpi_s3_resume_allowed()) if (!acpi_s3_resume_allowed())
return AGESA_UNSUPPORTED; return AGESA_UNSUPPORTED;
create_struct(&AmdParamStruct); AMD_RESUME_PARAMS *InitResumeParams = create_struct(&AmdParamStruct);
InitResumeParams = (AMD_RESUME_PARAMS *)AmdParamStruct.NewStructPtr;
get_s3nv_info(&InitResumeParams->S3DataBlock.NvStorage, &nv_size); get_s3nv_info(&InitResumeParams->S3DataBlock.NvStorage, &nv_size);
InitResumeParams->S3DataBlock.NvStorageSize = nv_size; InitResumeParams->S3DataBlock.NvStorageSize = nv_size;
@ -461,7 +443,6 @@ AGESA_STATUS agesawrapper_amds3laterestore(void)
.NewStructSize = sizeof(AMD_S3LATE_PARAMS), .NewStructSize = sizeof(AMD_S3LATE_PARAMS),
.NewStructPtr = &_S3LateParams, .NewStructPtr = &_S3LateParams,
}; };
AMD_S3LATE_PARAMS *S3LateParams;
size_t vol_size; size_t vol_size;
if (!acpi_s3_resume_allowed()) if (!acpi_s3_resume_allowed())
@ -469,9 +450,7 @@ AGESA_STATUS agesawrapper_amds3laterestore(void)
amd_initcpuio(); amd_initcpuio();
create_struct(&AmdParamStruct); AMD_S3LATE_PARAMS *S3LateParams = create_struct(&AmdParamStruct);
S3LateParams = (AMD_S3LATE_PARAMS *)AmdParamStruct.NewStructPtr;
get_s3vol_info(&S3LateParams->S3DataBlock.VolatileStorage, &vol_size); get_s3vol_info(&S3LateParams->S3DataBlock.VolatileStorage, &vol_size);
S3LateParams->S3DataBlock.VolatileStorageSize = vol_size; S3LateParams->S3DataBlock.VolatileStorageSize = vol_size;
@ -499,15 +478,12 @@ AGESA_STATUS agesawrapper_amds3finalrestore(void)
.NewStructSize = sizeof(AMD_S3FINAL_PARAMS), .NewStructSize = sizeof(AMD_S3FINAL_PARAMS),
.NewStructPtr = &_S3FinalParams, .NewStructPtr = &_S3FinalParams,
}; };
AMD_S3FINAL_PARAMS *S3FinalParams;
size_t vol_size; size_t vol_size;
if (!acpi_s3_resume_allowed()) if (!acpi_s3_resume_allowed())
return AGESA_UNSUPPORTED; return AGESA_UNSUPPORTED;
create_struct(&AmdParamStruct); AMD_S3FINAL_PARAMS *S3FinalParams = create_struct(&AmdParamStruct);
S3FinalParams = (AMD_S3FINAL_PARAMS *)AmdParamStruct.NewStructPtr;
get_s3vol_info(&S3FinalParams->S3DataBlock.VolatileStorage, &vol_size); get_s3vol_info(&S3FinalParams->S3DataBlock.VolatileStorage, &vol_size);
S3FinalParams->S3DataBlock.VolatileStorageSize = vol_size; S3FinalParams->S3DataBlock.VolatileStorageSize = vol_size;