Marshall Dawson has uploaded this change for review. ( https://review.coreboot.org/22730
Change subject: WIP soc/amd/common: Add S3 resume functions to wrapper ......................................................................
WIP soc/amd/common: Add S3 resume functions to wrapper
Change-Id: I5c6a9c1a679a1c4d3f7d1d3b41a32efd0a2c2c01 Signed-off-by: Marshall Dawson marshalldawson3rd@gmail.com --- M src/soc/amd/common/agesawrapper.c 1 file changed, 146 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/30/22730/1
diff --git a/src/soc/amd/common/agesawrapper.c b/src/soc/amd/common/agesawrapper.c index 28c290b..87e1550 100644 --- a/src/soc/amd/common/agesawrapper.c +++ b/src/soc/amd/common/agesawrapper.c @@ -21,6 +21,7 @@ #include <cpu/x86/mtrr.h> #include <BiosCallOuts.h> #include <string.h> +#include "s3_resume.h"
void __attribute__((weak)) SetMemParams(AMD_POST_PARAMS *PostParams) {} void __attribute__((weak)) OemPostParams(AMD_POST_PARAMS *PostParams) {} @@ -382,6 +383,151 @@ return Status; }
+AGESA_STATUS agesawrapper_amdinitresume(void) +{ + AGESA_STATUS status; + AMD_INTERFACE_PARAMS AmdParamStruct; + AMD_RESUME_PARAMS *AmdResumeParamsPtr; + struct region nv_data; + + if (!acpi_s3_resume_allowed()) + return AGESA_UNSUPPORTED; + + memset(&AmdParamStruct, 0, sizeof(AmdParamStruct)); + + AmdParamStruct.AgesaFunctionName = AMD_INIT_RESUME; + AmdParamStruct.AllocationMethod = PreMemHeap; + AmdParamStruct.StdHeader.AltImageBasePtr = 0; + AmdParamStruct.StdHeader.CalloutPtr = &GetBiosCallout; + AmdParamStruct.StdHeader.Func = 0; + AmdParamStruct.StdHeader.ImageBasePtr = 0; + AmdCreateStruct (&AmdParamStruct); + + AmdResumeParamsPtr = (AMD_RESUME_PARAMS *)AmdParamStruct.NewStructPtr; + + get_s3_info(S3_DATA_TYPE_NV, &nv_data); + AmdResumeParamsPtr->S3DataBlock.NvStorage = (void *)nv_data.offset; + AmdResumeParamsPtr->S3DataBlock.NvStorageSize = nv_data.size; + + status = AmdInitResume ((AMD_RESUME_PARAMS *)AmdParamStruct.NewStructPtr); + + if (status != AGESA_SUCCESS) agesawrapper_amdreadeventlog(AmdParamStruct.StdHeader.HeapStatus); + AmdReleaseStruct (&AmdParamStruct); + + return status; +} + +AGESA_STATUS agesawrapper_amds3laterestore(void) +{ + AGESA_STATUS Status; + AMD_INTERFACE_PARAMS AmdInterfaceParams; + AMD_S3LATE_PARAMS AmdS3LateParams; + AMD_S3LATE_PARAMS *AmdS3LateParamsPtr; + struct region vol_data; + + if (!acpi_s3_resume_allowed()) + return AGESA_UNSUPPORTED; + + amd_initcpuio(); + + memset(&AmdS3LateParams, 0, sizeof(AmdS3LateParams)); + + AmdInterfaceParams.StdHeader.ImageBasePtr = 0; + AmdInterfaceParams.AllocationMethod = ByHost; + AmdInterfaceParams.AgesaFunctionName = AMD_S3LATE_RESTORE; + AmdInterfaceParams.NewStructPtr = &AmdS3LateParams; + AmdInterfaceParams.StdHeader.CalloutPtr = &GetBiosCallout; + AmdS3LateParamsPtr = &AmdS3LateParams; + AmdInterfaceParams.NewStructSize = sizeof(AMD_S3LATE_PARAMS); + + AmdCreateStruct(&AmdInterfaceParams); + + get_s3_info(S3_DATA_TYPE_VOLATILE, &vol_data); + AmdS3LateParamsPtr->S3DataBlock.VolatileStorage = (void *)vol_data.offset; + AmdS3LateParamsPtr->S3DataBlock.VolatileStorageSize = vol_data.size; + + Status = AmdS3LateRestore(AmdS3LateParamsPtr); + /* todo: debug status of UNSUPPORTED */ + if (Status != AGESA_SUCCESS) { + agesawrapper_amdreadeventlog(AmdInterfaceParams.StdHeader.HeapStatus); + ASSERT(Status == AGESA_SUCCESS); + } + + return Status; +} + +AGESA_STATUS agesawrapper_fchs3earlyrestore(void) +{ + AGESA_STATUS status = AGESA_SUCCESS; + FCH_DATA_BLOCK FchParams; + AMD_CONFIG_PARAMS StdHeader; + struct cbmem_usage *amd_cbmem; + + if (!acpi_s3_resume_allowed()) + return AGESA_UNSUPPORTED; + + amd_cbmem = (struct cbmem_usage *)GetHeapBase(); + if (!amd_cbmem) { + printk(BIOS_ERR, "Error locating CBMEM_ID_RESUME_SCRATCH\n"); + return AGESA_ERROR; + } + + StdHeader.HeapStatus = HEAP_SYSTEM_MEM; + StdHeader.HeapBasePtr = (uintptr_t)&amd_cbmem->heap_base; + StdHeader.AltImageBasePtr = 0; + StdHeader.CalloutPtr = &GetBiosCallout; + StdHeader.Func = 0; + StdHeader.ImageBasePtr = 0; + + memset(&FchParams, 0, sizeof(FchParams)); + + FchParams.StdHeader = &StdHeader; +// todo +// see example in southbridge/amd/agesa/hudson/resume.c +// s3_resume_init_data(&FchParams); + + FchInitS3EarlyRestore(&FchParams); + + return status; +} + +AGESA_STATUS agesawrapper_fchs3laterestore(void) +{ + AGESA_STATUS status = AGESA_SUCCESS; + AMD_CONFIG_PARAMS StdHeader; + FCH_DATA_BLOCK FchParams; + struct cbmem_usage *amd_cbmem; + + if (!acpi_s3_resume_allowed()) + return AGESA_UNSUPPORTED; + + amd_cbmem = (struct cbmem_usage *)GetHeapBase(); + if (!amd_cbmem) { + printk(BIOS_ERR, "Error locating CBMEM_ID_RESUME_SCRATCH\n"); + return AGESA_ERROR; + } + + StdHeader.HeapStatus = HEAP_SYSTEM_MEM; + StdHeader.HeapBasePtr = (uintptr_t)&amd_cbmem->heap_base; + StdHeader.AltImageBasePtr = 0; + StdHeader.CalloutPtr = &GetBiosCallout; + StdHeader.Func = 0; + StdHeader.ImageBasePtr = 0; + + memset(&FchParams, 0, sizeof(FchParams)); + + FchParams.StdHeader = &StdHeader; +// todo +// see example in southbridge/amd/agesa/hudson/resume.c +// s3_resume_init_data(&FchParams); + FchInitS3LateRestore(&FchParams); + + // todo: still need to reload interrupt values? native agesa doesn't + // but old PI code used to. + + return status; +} + AGESA_STATUS agesawrapper_amdreadeventlog (UINT8 HeapStatus) { AGESA_STATUS Status;