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>
This commit is contained in:
Kyösti Mälkki 2018-06-14 06:57:05 +03:00 committed by Patrick Georgi
parent ba851170fb
commit 6e512c4d7a
9 changed files with 78 additions and 38 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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;
}

View File

@ -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,

View File

@ -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,

View File

@ -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

View File

@ -163,12 +163,11 @@ static void earliest_ramstage(void *unused)
psp_load_named_blob(MBOX_BIOS_CMD_SMU_FW2, "smu_fw2");
post_code(0x47);
do_agesawrapper(agesawrapper_amdinitenv, "amdinitenv");
do_agesawrapper(AMD_INIT_ENV, "amdinitenv");
} else {
/* Complete the initial system restoration */
post_code(0x46);
do_agesawrapper(agesawrapper_amds3laterestore,
"amds3laterestore");
do_agesawrapper(AMD_S3LATE_RESTORE, "amds3laterestore");
}
}

View File

@ -391,7 +391,7 @@ void domain_enable_resources(struct device *dev)
{
/* Must be called after PCI enumeration and resource allocation */
if (!romstage_handoff_is_resume())
do_agesawrapper(agesawrapper_amdinitmid, "amdinitmid");
do_agesawrapper(AMD_INIT_MID, "amdinitmid");
}
void domain_set_resources(struct device *dev)

View File

@ -65,11 +65,11 @@ static void load_smu_fw1(void)
static void agesa_call(void)
{
post_code(0x37);
do_agesawrapper(agesawrapper_amdinitreset, "amdinitreset");
do_agesawrapper(AMD_INIT_RESET, "amdinitreset");
post_code(0x38);
/* APs will not exit amdinitearly */
do_agesawrapper(agesawrapper_amdinitearly, "amdinitearly");
do_agesawrapper(AMD_INIT_EARLY, "amdinitearly");
}
static void bsp_agesa_call(void)
@ -102,7 +102,7 @@ asmlinkage void car_stage_entry(void)
if (!s3_resume) {
post_code(0x40);
do_agesawrapper(agesawrapper_amdinitpost, "amdinitpost");
do_agesawrapper(AMD_INIT_POST, "amdinitpost");
post_code(0x41);
/*
@ -137,7 +137,7 @@ asmlinkage void car_stage_entry(void)
} else {
printk(BIOS_INFO, "S3 detected\n");
post_code(0x60);
do_agesawrapper(agesawrapper_amdinitresume, "amdinitresume");
do_agesawrapper(AMD_INIT_RESUME, "amdinitresume");
post_code(0x61);
}