summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyösti Mälkki <kyosti.malkki@gmail.com>2018-06-14 06:57:05 +0300
committerPatrick Georgi <pgeorgi@google.com>2019-05-06 10:26:25 +0000
commit85b2ed5438d5d42d00519114e385bf3ae2d56e8f (patch)
tree025e3947019b969f06ba1be1394cbbaf8b0d6235
parent43fc38943da7839d2fe83bf7ca1b9c509c327dc0 (diff)
downloadcoreboot-85b2ed5438d5d42d00519114e385bf3ae2d56e8f.tar.xz
soc/amd/common: Introduce module_dispatch()
This change removes all the separate entrypoint dispatch functions as they all share the same pattern. Furthermore, none of the function definitions under vendorcode binaryPI/AGESA.c file have proper declarations, the ones compiler picks up from AGESA.h are for the internal implementations and with sanely organized headerfiles would not be exposed outside the build of AGESA at all. Change-Id: I0b72badc007565740c93b58743cfd048e8b42775 Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/31485 Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
-rw-r--r--src/soc/amd/common/block/pi/agesawrapper.c55
-rw-r--r--src/vendorcode/amd/pi/00670F00/binaryPI/AGESA.c154
2 files changed, 39 insertions, 170 deletions
diff --git a/src/soc/amd/common/block/pi/agesawrapper.c b/src/soc/amd/common/block/pi/agesawrapper.c
index 0570b5a3ee..5f58346625 100644
--- a/src/soc/amd/common/block/pi/agesawrapper.c
+++ b/src/soc/amd/common/block/pi/agesawrapper.c
@@ -41,8 +41,34 @@ static void *AcpiAlib;
static void *AcpiIvrs;
static void *AcpiCrat;
+static AGESA_STATUS module_dispatch(AGESA_STRUCT_NAME func,
+ AMD_CONFIG_PARAMS *StdHeader)
+{
+ MODULE_ENTRY dispatcher = agesa_get_dispatcher();
+
+ if (!dispatcher)
+ return AGESA_UNSUPPORTED;
+
+ StdHeader->Func = func;
+ return dispatcher(StdHeader);
+}
+
+static AGESA_STATUS amd_dispatch(void *Params)
+{
+ AMD_CONFIG_PARAMS *StdHeader = Params;
+ return module_dispatch(StdHeader->Func, StdHeader);
+}
+
+AGESA_STATUS amd_late_run_ap_task(AP_EXE_PARAMS *ApExeParams)
+{
+ AMD_CONFIG_PARAMS *StdHeader = (void *)ApExeParams;
+ return module_dispatch(AMD_LATE_RUN_AP_TASK, StdHeader);
+}
+
static void *create_struct(AMD_INTERFACE_PARAMS *interface_struct)
{
+ AMD_CONFIG_PARAMS *StdHeader;
+
/* Should clone entire StdHeader here. */
interface_struct->StdHeader.CalloutPtr = &GetBiosCallout;
@@ -57,7 +83,9 @@ static void *create_struct(AMD_INTERFACE_PARAMS *interface_struct)
if (!interface_struct->NewStructPtr) /* Avoid NULL pointer usage */
die("No AGESA structure created");
- return interface_struct->NewStructPtr;
+ StdHeader = interface_struct->NewStructPtr;
+ StdHeader->Func = interface_struct->AgesaFunctionName;
+ return StdHeader;
}
static AGESA_STATUS amd_init_reset(void)
@@ -76,7 +104,7 @@ static AGESA_STATUS amd_init_reset(void)
SetFchResetParams(&ResetParams->FchInterface);
timestamp_add_now(TS_AGESA_INIT_RESET_START);
- status = AmdInitReset(ResetParams);
+ status = amd_dispatch(ResetParams);
timestamp_add_now(TS_AGESA_INIT_RESET_DONE);
AmdReleaseStruct(&AmdParamStruct);
@@ -97,7 +125,7 @@ static AGESA_STATUS amd_init_early(void)
OemCustomizeInitEarly(EarlyParams);
timestamp_add_now(TS_AGESA_INIT_EARLY_START);
- status = AmdInitEarly(EarlyParams);
+ status = amd_dispatch(EarlyParams);
timestamp_add_now(TS_AGESA_INIT_EARLY_DONE);
AmdReleaseStruct(&AmdParamStruct);
@@ -162,7 +190,7 @@ static AGESA_STATUS amd_init_post(void)
);
timestamp_add_now(TS_AGESA_INIT_POST_START);
- status = AmdInitPost(PostParams);
+ status = amd_dispatch(PostParams);
timestamp_add_now(TS_AGESA_INIT_POST_DONE);
/*
@@ -205,7 +233,7 @@ static AGESA_STATUS amd_init_env(void)
SetNbEnvParams(&EnvParams->GnbEnvConfiguration);
timestamp_add_now(TS_AGESA_INIT_ENV_START);
- status = AmdInitEnv(EnvParams);
+ status = amd_dispatch(EnvParams);
timestamp_add_now(TS_AGESA_INIT_ENV_DONE);
AmdReleaseStruct(&AmdParamStruct);
@@ -256,7 +284,7 @@ static AGESA_STATUS amd_init_mid(void)
SetNbMidParams(&MidParams->GnbMidConfiguration);
timestamp_add_now(TS_AGESA_INIT_MID_START);
- status = AmdInitMid(MidParams);
+ status = amd_dispatch(MidParams);
timestamp_add_now(TS_AGESA_INIT_MID_DONE);
AmdReleaseStruct(&AmdParamStruct);
@@ -286,7 +314,7 @@ static AGESA_STATUS amd_init_late(void)
}
timestamp_add_now(TS_AGESA_INIT_LATE_START);
- Status = AmdInitLate(LateParams);
+ Status = amd_dispatch(LateParams);
timestamp_add_now(TS_AGESA_INIT_LATE_DONE);
DmiTable = LateParams->DmiTable;
@@ -309,11 +337,6 @@ static AGESA_STATUS amd_init_late(void)
return Status;
}
-AGESA_STATUS amd_late_run_ap_task(AP_EXE_PARAMS *ApExeParams)
-{
- return AmdLateRunApTask(ApExeParams);
-}
-
static AGESA_STATUS amd_init_rtb(void)
{
AGESA_STATUS Status;
@@ -325,7 +348,7 @@ static AGESA_STATUS amd_init_rtb(void)
AMD_RTB_PARAMS *RtbParams = create_struct(&AmdParamStruct);
timestamp_add_now(TS_AGESA_INIT_RTB_START);
- Status = AmdInitRtb(RtbParams);
+ Status = amd_dispatch(RtbParams);
timestamp_add_now(TS_AGESA_INIT_RTB_DONE);
if (save_s3_info(RtbParams->S3DataBlock.NvStorage,
@@ -354,7 +377,7 @@ static AGESA_STATUS amd_init_resume(void)
InitResumeParams->S3DataBlock.NvStorageSize = nv_size;
timestamp_add_now(TS_AGESA_INIT_RESUME_START);
- status = AmdInitResume(InitResumeParams);
+ status = amd_dispatch(InitResumeParams);
timestamp_add_now(TS_AGESA_INIT_RESUME_DONE);
AmdReleaseStruct(&AmdParamStruct);
@@ -382,7 +405,7 @@ static AGESA_STATUS amd_s3late_restore(void)
S3LateParams->S3DataBlock.VolatileStorageSize = vol_size;
timestamp_add_now(TS_AGESA_S3_LATE_START);
- Status = AmdS3LateRestore(S3LateParams);
+ Status = amd_dispatch(S3LateParams);
timestamp_add_now(TS_AGESA_S3_LATE_DONE);
AmdReleaseStruct(&AmdParamStruct);
@@ -408,7 +431,7 @@ static AGESA_STATUS amd_s3final_restore(void)
S3FinalParams->S3DataBlock.VolatileStorageSize = vol_size;
timestamp_add_now(TS_AGESA_S3_FINAL_START);
- Status = AmdS3FinalRestore(S3FinalParams);
+ Status = amd_dispatch(S3FinalParams);
timestamp_add_now(TS_AGESA_S3_FINAL_DONE);
AmdReleaseStruct(&AmdParamStruct);
diff --git a/src/vendorcode/amd/pi/00670F00/binaryPI/AGESA.c b/src/vendorcode/amd/pi/00670F00/binaryPI/AGESA.c
index 2efee4eb62..e17cedcb64 100644
--- a/src/vendorcode/amd/pi/00670F00/binaryPI/AGESA.c
+++ b/src/vendorcode/amd/pi/00670F00/binaryPI/AGESA.c
@@ -72,157 +72,3 @@ AmdReleaseStruct (
if (!Dispatcher) return AGESA_UNSUPPORTED;
return Dispatcher(InterfaceParams);
}
-
-/**********************************************************************
- * Interface call: AmdInitReset
- **********************************************************************/
-AGESA_STATUS
-AmdInitReset (
- IN OUT AMD_RESET_PARAMS *ResetParams
- )
-{
- MODULE_ENTRY Dispatcher = agesa_get_dispatcher();
- ResetParams->StdHeader.Func = AMD_INIT_RESET;
- if (!Dispatcher) return AGESA_UNSUPPORTED;
- return Dispatcher(ResetParams);
-}
-
-/**********************************************************************
- * Interface call: AmdInitEarly
- **********************************************************************/
-AGESA_STATUS
-AmdInitEarly (
- IN OUT AMD_EARLY_PARAMS *EarlyParams
- )
-{
- MODULE_ENTRY Dispatcher = agesa_get_dispatcher();
- EarlyParams->StdHeader.Func = AMD_INIT_EARLY;
- if (!Dispatcher) return AGESA_UNSUPPORTED;
- return Dispatcher(EarlyParams);
-}
-
-/**********************************************************************
- * Interface call: AmdInitPost
- **********************************************************************/
-AGESA_STATUS
-AmdInitPost (
- IN OUT AMD_POST_PARAMS *PostParams ///< Amd Cpu init param
- )
-{
- MODULE_ENTRY Dispatcher = agesa_get_dispatcher();
- PostParams->StdHeader.Func = AMD_INIT_POST;
- if (!Dispatcher) return AGESA_UNSUPPORTED;
- return Dispatcher(PostParams);
-}
-
-/**********************************************************************
- * Interface call: AmdInitEnv
- **********************************************************************/
-AGESA_STATUS
-AmdInitEnv (
- IN OUT AMD_ENV_PARAMS *EnvParams
- )
-{
- MODULE_ENTRY Dispatcher = agesa_get_dispatcher();
- EnvParams->StdHeader.Func = AMD_INIT_ENV;
- if (!Dispatcher) return AGESA_UNSUPPORTED;
- return Dispatcher(EnvParams);
-}
-
-/**********************************************************************
- * Interface call: AmdInitMid
- **********************************************************************/
-AGESA_STATUS
-AmdInitMid (
- IN OUT AMD_MID_PARAMS *MidParams
- )
-{
- MODULE_ENTRY Dispatcher = agesa_get_dispatcher();
- MidParams->StdHeader.Func = AMD_INIT_MID;
- if (!Dispatcher) return AGESA_UNSUPPORTED;
- return Dispatcher(MidParams);
-}
-
-/**********************************************************************
- * Interface call: AmdInitLate
- **********************************************************************/
-AGESA_STATUS
-AmdInitLate (
- IN OUT AMD_LATE_PARAMS *LateParams
- )
-{
- MODULE_ENTRY Dispatcher = agesa_get_dispatcher();
- LateParams->StdHeader.Func = AMD_INIT_LATE;
- if (!Dispatcher) return AGESA_UNSUPPORTED;
- return Dispatcher(LateParams);
-}
-
-/**********************************************************************
- * Interface call: AmdInitResume
- **********************************************************************/
-AGESA_STATUS
-AmdInitResume (
- IN AMD_RESUME_PARAMS *ResumeParams
- )
-{
- MODULE_ENTRY Dispatcher = agesa_get_dispatcher();
- ResumeParams->StdHeader.Func = AMD_INIT_RESUME;
- if (!Dispatcher) return AGESA_UNSUPPORTED;
- return Dispatcher(ResumeParams);
-}
-
-/**********************************************************************
- * Interface call: AmdS3LateRestore
- **********************************************************************/
-AGESA_STATUS
-AmdS3LateRestore (
- IN OUT AMD_S3LATE_PARAMS *S3LateParams
- )
-{
- MODULE_ENTRY Dispatcher = agesa_get_dispatcher();
- S3LateParams->StdHeader.Func = AMD_S3LATE_RESTORE;
- if (!Dispatcher) return AGESA_UNSUPPORTED;
- return Dispatcher(S3LateParams);
-}
-
-/**********************************************************************
- * Interface call: AmdS3FinalRestore
- **********************************************************************/
-AGESA_STATUS
-AmdS3FinalRestore (
- IN OUT AMD_S3FINAL_PARAMS *S3FinalParams
- )
-{
- MODULE_ENTRY Dispatcher = agesa_get_dispatcher();
- S3FinalParams->StdHeader.Func = AMD_S3FINAL_RESTORE;
- if (!Dispatcher) return AGESA_UNSUPPORTED;
- return Dispatcher(S3FinalParams);
-}
-
-/**********************************************************************
- * Interface call: AmdInitRtb
- **********************************************************************/
-AGESA_STATUS
-AmdInitRtb (
- IN OUT AMD_RTB_PARAMS *AmdInitRtbParams
- )
-{
- MODULE_ENTRY Dispatcher = agesa_get_dispatcher();
- AmdInitRtbParams->StdHeader.Func = AMD_INIT_RTB;
- if (!Dispatcher) return AGESA_UNSUPPORTED;
- return Dispatcher(AmdInitRtbParams);
-}
-
-/**********************************************************************
- * Interface call: AmdLateRunApTask
- **********************************************************************/
-AGESA_STATUS
-AmdLateRunApTask (
- IN AP_EXE_PARAMS *AmdApExeParams
-)
-{
- MODULE_ENTRY Dispatcher = agesa_get_dispatcher();
- AmdApExeParams->StdHeader.Func = AMD_LATE_RUN_AP_TASK;
- if (!Dispatcher) return AGESA_UNSUPPORTED;
- return Dispatcher(AmdApExeParams);
-}