soc/amd/common: Add S3 resume functions to wrapper

Add new functions that can execute InitRtb, InitResume, LateResume,
and FinalResume.

Note that the name AmdInitRtb supersedes the deprecated AmdS3Save.

TEST=Suspend/Resume Kahlee with complete S3 patch stack
BUG=b:69614064

Change-Id: I5c6a9c1a679a1c4d3f7d1d3b41a32efd0a2c2c01
Signed-off-by: Marshall Dawson <marshalldawson3rd@gmail.com>
Reviewed-on: https://review.coreboot.org/22730
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Martin Roth <martinroth@google.com>
This commit is contained in:
Marshall Dawson 2017-12-04 15:28:10 -07:00 committed by Martin Roth
parent e71745bdf9
commit c2f6da00f4
3 changed files with 140 additions and 2 deletions

View File

@ -43,9 +43,10 @@ AGESA_STATUS agesawrapper_amdinitmid(void);
void *agesawrapper_getlateinitptr(int pick);
AGESA_STATUS agesawrapper_amdlaterunaptask(UINT32 Func, UINTN Data,
void *ConfigPtr);
AGESA_STATUS agesawrapper_amdS3Save(void);
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);

View File

@ -23,6 +23,7 @@
#include <rmodule.h>
#include <string.h>
#include <timestamp.h>
#include <amdblocks/s3_resume.h>
#include <amdblocks/agesawrapper.h>
#include <amdblocks/BiosCallOuts.h>
@ -374,6 +375,142 @@ AGESA_STATUS agesawrapper_amdlaterunaptask(UINT32 Func, UINTN Data,
return Status;
}
AGESA_STATUS agesawrapper_amdinitrtb(void)
{
AGESA_STATUS Status;
AMD_INTERFACE_PARAMS AmdParamStruct = {
.AgesaFunctionName = AMD_INIT_RTB,
.AllocationMethod = PostMemDram,
.StdHeader.CalloutPtr = &GetBiosCallout,
};
AMD_RTB_PARAMS *RtbParams;
create_struct(&AmdParamStruct);
RtbParams = (AMD_RTB_PARAMS *)AmdParamStruct.NewStructPtr;
timestamp_add_now(TS_AGESA_INIT_RTB_START);
Status = AmdInitRtb(RtbParams);
timestamp_add_now(TS_AGESA_INIT_RTB_DONE);
if (Status != AGESA_SUCCESS) {
agesawrapper_readeventlog(AmdParamStruct.StdHeader.HeapStatus);
ASSERT(Status == AGESA_SUCCESS);
}
if (save_s3_info(RtbParams->S3DataBlock.NvStorage,
RtbParams->S3DataBlock.NvStorageSize,
RtbParams->S3DataBlock.VolatileStorage,
RtbParams->S3DataBlock.VolatileStorageSize))
printk(BIOS_ERR, "S3 data not saved, resuming impossible\n");
AmdReleaseStruct(&AmdParamStruct);
return Status;
}
AGESA_STATUS agesawrapper_amdinitresume(void)
{
AGESA_STATUS status;
AMD_INTERFACE_PARAMS AmdParamStruct = {
.AgesaFunctionName = AMD_INIT_RESUME,
.AllocationMethod = PreMemHeap,
.StdHeader.CalloutPtr = &GetBiosCallout,
};
AMD_RESUME_PARAMS *InitResumeParams;
size_t nv_size;
if (!acpi_s3_resume_allowed())
return AGESA_UNSUPPORTED;
create_struct(&AmdParamStruct);
InitResumeParams = (AMD_RESUME_PARAMS *)AmdParamStruct.NewStructPtr;
get_s3nv_info(&InitResumeParams->S3DataBlock.NvStorage, &nv_size);
InitResumeParams->S3DataBlock.NvStorageSize = nv_size;
timestamp_add_now(TS_AGESA_INIT_RESUME_START);
status = AmdInitResume(InitResumeParams);
timestamp_add_now(TS_AGESA_INIT_RESUME_DONE);
if (status != AGESA_SUCCESS)
agesawrapper_readeventlog(AmdParamStruct.StdHeader.HeapStatus);
AmdReleaseStruct(&AmdParamStruct);
return status;
}
AGESA_STATUS agesawrapper_amds3laterestore(void)
{
AGESA_STATUS Status;
AMD_INTERFACE_PARAMS AmdParamStruct = {
.AgesaFunctionName = AMD_S3LATE_RESTORE,
.AllocationMethod = ByHost,
.StdHeader.CalloutPtr = &GetBiosCallout,
};
AMD_S3LATE_PARAMS *S3LateParams;
size_t vol_size;
if (!acpi_s3_resume_allowed())
return AGESA_UNSUPPORTED;
amd_initcpuio();
create_struct(&AmdParamStruct);
S3LateParams = (AMD_S3LATE_PARAMS *)AmdParamStruct.NewStructPtr;
get_s3vol_info(&S3LateParams->S3DataBlock.VolatileStorage, &vol_size);
S3LateParams->S3DataBlock.VolatileStorageSize = vol_size;
timestamp_add_now(TS_AGESA_S3_LATE_START);
Status = AmdS3LateRestore(S3LateParams);
timestamp_add_now(TS_AGESA_S3_LATE_DONE);
if (Status != AGESA_SUCCESS) {
agesawrapper_readeventlog(AmdParamStruct.StdHeader.HeapStatus);
ASSERT(Status == AGESA_SUCCESS);
}
AmdReleaseStruct(&AmdParamStruct);
return Status;
}
AGESA_STATUS agesawrapper_amds3finalrestore(void)
{
AGESA_STATUS Status;
AMD_INTERFACE_PARAMS AmdParamStruct = {
.AgesaFunctionName = AMD_S3FINAL_RESTORE,
.AllocationMethod = ByHost,
.StdHeader.CalloutPtr = &GetBiosCallout,
};
AMD_S3FINAL_PARAMS *S3FinalParams;
size_t vol_size;
if (!acpi_s3_resume_allowed())
return AGESA_UNSUPPORTED;
create_struct(&AmdParamStruct);
S3FinalParams = (AMD_S3FINAL_PARAMS *)AmdParamStruct.NewStructPtr;
get_s3vol_info(&S3FinalParams->S3DataBlock.VolatileStorage, &vol_size);
S3FinalParams->S3DataBlock.VolatileStorageSize = vol_size;
timestamp_add_now(TS_AGESA_S3_FINAL_START);
Status = AmdS3FinalRestore(S3FinalParams);
timestamp_add_now(TS_AGESA_S3_FINAL_DONE);
if (Status != AGESA_SUCCESS) {
agesawrapper_readeventlog(AmdParamStruct.StdHeader.HeapStatus);
ASSERT(Status == AGESA_SUCCESS);
}
AmdReleaseStruct(&AmdParamStruct);
return Status;
}
static int agesa_locate_file(const char *name, struct region_device *rdev,
uint32_t type)
{

View File

@ -33,7 +33,7 @@ static void agesawrapper_post_device(void *unused)
if (!acpi_s3_resume_allowed())
return;
do_agesawrapper(agesawrapper_amdS3Save, "amdS3Save");
do_agesawrapper(agesawrapper_amdinitrtb, "amdinitrtb");
}
BOOT_STATE_INIT_ENTRY(BS_POST_DEVICE, BS_ON_EXIT,