summaryrefslogtreecommitdiff
path: root/src/soc/amd/common/block
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-04-23 10:10:34 +0000
commit6e512c4d7a4faa68bf64b37c68bae8141d9e4518 (patch)
tree2e26cc89cf7f26d46a0cc370c62c5801786d6a1f /src/soc/amd/common/block
parentba851170fba9157b45bfdc74fe60873c187cac96 (diff)
downloadcoreboot-6e512c4d7a4faa68bf64b37c68bae8141d9e4518.tar.xz
soc/amd/common: Introduce agesa_execute_state()
Each entrypoint to AGESA goes through the same sequence and have same the function signature. To avoid introducing bunch of preprocessor magic, rename all the agesawrapper_amdXXX() functions that are actual entrypoints to AGESA API, make them static, and provide a single exposed entry function agesa_execute_state(). Change-Id: I96ae1874132da3843aa42c2f4e8a59ec771d3893 Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/31483 Reviewed-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/soc/amd/common/block')
-rw-r--r--src/soc/amd/common/block/include/amdblocks/agesawrapper.h13
-rw-r--r--src/soc/amd/common/block/include/amdblocks/agesawrapper_call.h4
-rw-r--r--src/soc/amd/common/block/pi/agesawrapper.c74
-rw-r--r--src/soc/amd/common/block/pi/amd_late_init.c4
-rw-r--r--src/soc/amd/common/block/pi/amd_resume_final.c2
-rw-r--r--src/soc/amd/common/block/s3/Makefile.inc4
6 files changed, 71 insertions, 30 deletions
diff --git a/src/soc/amd/common/block/include/amdblocks/agesawrapper.h b/src/soc/amd/common/block/include/amdblocks/agesawrapper.h
index 2f3b8a6268..04db4242cf 100644
--- a/src/soc/amd/common/block/include/amdblocks/agesawrapper.h
+++ b/src/soc/amd/common/block/include/amdblocks/agesawrapper.h
@@ -34,22 +34,11 @@ enum {
/* Return current dispatcher or NULL on error. */
MODULE_ENTRY agesa_get_dispatcher(void);
+AGESA_STATUS agesa_execute_state(AGESA_STRUCT_NAME func);
AGESA_STATUS amd_late_run_ap_task(AP_EXE_PARAMS *ApExeParams);
-AGESA_STATUS agesawrapper_amdinitreset(void);
-AGESA_STATUS agesawrapper_amdinitearly(void);
-AGESA_STATUS agesawrapper_amdinitenv(void);
-AGESA_STATUS agesawrapper_amdinitlate(void);
-AGESA_STATUS agesawrapper_amdinitpost(void);
-AGESA_STATUS agesawrapper_amdinitmid(void);
void *agesawrapper_getlateinitptr(int pick);
-AGESA_STATUS agesawrapper_amdinitrtb(void);
-AGESA_STATUS agesawrapper_amdinitresume(void);
-AGESA_STATUS agesawrapper_amds3laterestore(void);
-AGESA_STATUS agesawrapper_amds3finalrestore(void);
-AGESA_STATUS agesawrapper_fchs3earlyrestore(void);
-AGESA_STATUS agesawrapper_fchs3laterestore(void);
void OemCustomizeInitEarly(AMD_EARLY_PARAMS *InitEarly);
void amd_initcpuio(void);
diff --git a/src/soc/amd/common/block/include/amdblocks/agesawrapper_call.h b/src/soc/amd/common/block/include/amdblocks/agesawrapper_call.h
index 1188f054f5..86e32aff79 100644
--- a/src/soc/amd/common/block/include/amdblocks/agesawrapper_call.h
+++ b/src/soc/amd/common/block/include/amdblocks/agesawrapper_call.h
@@ -42,11 +42,11 @@ static const char *decodeAGESA_STATUS(AGESA_STATUS sret)
return statusStrings[sret];
}
-static inline u32 do_agesawrapper(AGESA_STATUS (*func)(void), const char *name)
+static inline u32 do_agesawrapper(AGESA_STRUCT_NAME func, const char *name)
{
AGESA_STATUS ret;
printk(BIOS_DEBUG, "agesawrapper_%s() entry\n", name);
- ret = func();
+ ret = agesa_execute_state(func);
printk(BIOS_DEBUG, "agesawrapper_%s() returned %s\n",
name, decodeAGESA_STATUS(ret));
return (u32)ret;
diff --git a/src/soc/amd/common/block/pi/agesawrapper.c b/src/soc/amd/common/block/pi/agesawrapper.c
index d65400e43c..6cdabd3a6c 100644
--- a/src/soc/amd/common/block/pi/agesawrapper.c
+++ b/src/soc/amd/common/block/pi/agesawrapper.c
@@ -2,7 +2,7 @@
* This file is part of the coreboot project.
*
* Copyright (C) 2012 - 2017 Advanced Micro Devices, Inc.
- * Copyright (C) 2018 Kyösti Mälkki
+ * Copyright (C) 2018 - 2019 Kyösti Mälkki
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -88,7 +88,7 @@ static void *create_struct(AMD_INTERFACE_PARAMS *interface_struct)
return interface_struct->NewStructPtr;
}
-AGESA_STATUS agesawrapper_amdinitreset(void)
+static AGESA_STATUS amd_init_reset(void)
{
AGESA_STATUS status;
AMD_RESET_PARAMS _ResetParams;
@@ -113,7 +113,7 @@ AGESA_STATUS agesawrapper_amdinitreset(void)
return status;
}
-AGESA_STATUS agesawrapper_amdinitearly(void)
+static AGESA_STATUS amd_init_early(void)
{
AGESA_STATUS status;
AMD_INTERFACE_PARAMS AmdParamStruct = {
@@ -170,7 +170,7 @@ static void print_init_post_settings(AMD_POST_PARAMS *parms)
uma_size / MiB, uma_start);
}
-AGESA_STATUS agesawrapper_amdinitpost(void)
+static AGESA_STATUS amd_init_post(void)
{
AGESA_STATUS status;
AMD_INTERFACE_PARAMS AmdParamStruct = {
@@ -225,7 +225,7 @@ AGESA_STATUS agesawrapper_amdinitpost(void)
return status;
}
-AGESA_STATUS agesawrapper_amdinitenv(void)
+static AGESA_STATUS amd_init_env(void)
{
AGESA_STATUS status;
AMD_INTERFACE_PARAMS AmdParamStruct = {
@@ -275,7 +275,7 @@ void *agesawrapper_getlateinitptr(int pick)
}
}
-AGESA_STATUS agesawrapper_amdinitmid(void)
+static AGESA_STATUS amd_init_mid(void)
{
AGESA_STATUS status;
AMD_INTERFACE_PARAMS AmdParamStruct = {
@@ -302,7 +302,7 @@ AGESA_STATUS agesawrapper_amdinitmid(void)
return status;
}
-AGESA_STATUS agesawrapper_amdinitlate(void)
+static AGESA_STATUS amd_init_late(void)
{
AGESA_STATUS Status;
AMD_INTERFACE_PARAMS AmdParamStruct = {
@@ -357,7 +357,7 @@ AGESA_STATUS amd_late_run_ap_task(AP_EXE_PARAMS *ApExeParams)
return AmdLateRunApTask(ApExeParams);
}
-AGESA_STATUS agesawrapper_amdinitrtb(void)
+static AGESA_STATUS amd_init_rtb(void)
{
AGESA_STATUS Status;
AMD_INTERFACE_PARAMS AmdParamStruct = {
@@ -387,7 +387,7 @@ AGESA_STATUS agesawrapper_amdinitrtb(void)
return Status;
}
-AGESA_STATUS agesawrapper_amdinitresume(void)
+static AGESA_STATUS amd_init_resume(void)
{
AGESA_STATUS status;
AMD_INTERFACE_PARAMS AmdParamStruct = {
@@ -412,7 +412,7 @@ AGESA_STATUS agesawrapper_amdinitresume(void)
return status;
}
-AGESA_STATUS agesawrapper_amds3laterestore(void)
+static AGESA_STATUS amd_s3late_restore(void)
{
AGESA_STATUS Status;
AMD_S3LATE_PARAMS _S3LateParams;
@@ -444,7 +444,7 @@ AGESA_STATUS agesawrapper_amds3laterestore(void)
return Status;
}
-AGESA_STATUS agesawrapper_amds3finalrestore(void)
+static AGESA_STATUS amd_s3final_restore(void)
{
AGESA_STATUS Status;
AMD_S3FINAL_PARAMS _S3FinalParams;
@@ -473,3 +473,55 @@ AGESA_STATUS agesawrapper_amds3finalrestore(void)
return Status;
}
+
+static AGESA_STATUS romstage_dispatch(AMD_CONFIG_PARAMS *StdHeader)
+{
+ switch (StdHeader->Func) {
+ case AMD_INIT_RESET:
+ return amd_init_reset();
+ case AMD_INIT_EARLY:
+ return amd_init_early();
+ case AMD_INIT_POST:
+ return amd_init_post();
+ case AMD_INIT_RESUME:
+ return amd_init_resume();
+ default:
+ return AGESA_UNSUPPORTED;
+ }
+}
+
+static AGESA_STATUS ramstage_dispatch(AMD_CONFIG_PARAMS *StdHeader)
+{
+ switch (StdHeader->Func) {
+ case AMD_INIT_ENV:
+ return amd_init_env();
+ case AMD_INIT_MID:
+ return amd_init_mid();
+ case AMD_INIT_LATE:
+ return amd_init_late();
+ case AMD_INIT_RTB:
+ return amd_init_rtb();
+ case AMD_S3LATE_RESTORE:
+ return amd_s3late_restore();
+ case AMD_S3FINAL_RESTORE:
+ return amd_s3final_restore();
+ default:
+ return AGESA_UNSUPPORTED;
+ }
+}
+
+AGESA_STATUS agesa_execute_state(AGESA_STRUCT_NAME func)
+{
+ AGESA_STATUS status = AGESA_UNSUPPORTED;
+ AMD_CONFIG_PARAMS template = {};
+ AMD_CONFIG_PARAMS *StdHeader = &template;
+
+ StdHeader->Func = func;
+
+ if (ENV_ROMSTAGE)
+ status = romstage_dispatch(StdHeader);
+ if (ENV_RAMSTAGE)
+ status = ramstage_dispatch(StdHeader);
+
+ return status;
+}
diff --git a/src/soc/amd/common/block/pi/amd_late_init.c b/src/soc/amd/common/block/pi/amd_late_init.c
index fdecf00581..80c7add261 100644
--- a/src/soc/amd/common/block/pi/amd_late_init.c
+++ b/src/soc/amd/common/block/pi/amd_late_init.c
@@ -179,12 +179,12 @@ static void agesawrapper_post_device(void *unused)
if (acpi_is_wakeup_s3())
return;
- do_agesawrapper(agesawrapper_amdinitlate, "amdinitlate");
+ do_agesawrapper(AMD_INIT_LATE, "amdinitlate");
if (!acpi_s3_resume_allowed())
return;
- do_agesawrapper(agesawrapper_amdinitrtb, "amdinitrtb");
+ do_agesawrapper(AMD_INIT_RTB, "amdinitrtb");
}
BOOT_STATE_INIT_ENTRY(BS_POST_DEVICE, BS_ON_EXIT, agesawrapper_post_device,
diff --git a/src/soc/amd/common/block/pi/amd_resume_final.c b/src/soc/amd/common/block/pi/amd_resume_final.c
index a2826659d3..363ba83a0f 100644
--- a/src/soc/amd/common/block/pi/amd_resume_final.c
+++ b/src/soc/amd/common/block/pi/amd_resume_final.c
@@ -18,7 +18,7 @@
static void agesawrapper_s3finalrestore(void *unused)
{
- do_agesawrapper(agesawrapper_amds3finalrestore, "amds3finalrestore");
+ do_agesawrapper(AMD_S3FINAL_RESTORE, "amds3finalrestore");
}
BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY,
diff --git a/src/soc/amd/common/block/s3/Makefile.inc b/src/soc/amd/common/block/s3/Makefile.inc
index 7d950b0b3a..9efc6bc414 100644
--- a/src/soc/amd/common/block/s3/Makefile.inc
+++ b/src/soc/amd/common/block/s3/Makefile.inc
@@ -1,6 +1,6 @@
ifeq ($(CONFIG_SOC_AMD_COMMON_BLOCK_S3),y)
-romstage-$(CONFIG_HAVE_ACPI_RESUME) += s3_resume.c
-ramstage-$(CONFIG_HAVE_ACPI_RESUME) += s3_resume.c
+romstage-y += s3_resume.c
+ramstage-y += s3_resume.c
endif