From c74b53fffd7f7f938f5695ecb58c099985a47fa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ky=C3=B6sti=20M=C3=A4lkki?= Date: Tue, 26 May 2015 15:38:58 +0300 Subject: AGESA: Reduce SPI use by 24kB for S3 support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is no need to backup VolatileStorage in SPI flash at all. At the time we need it, we have CBMEM available. Change-Id: If0ca57b314140a833d6d59fe9e236e07816f05a4 Signed-off-by: Kyösti Mälkki Reviewed-on: http://review.coreboot.org/10318 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel Reviewed-by: Aaron Durbin Reviewed-by: Edward O'Callaghan --- src/northbridge/amd/agesa/oem_s3.c | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) (limited to 'src/northbridge/amd/agesa') diff --git a/src/northbridge/amd/agesa/oem_s3.c b/src/northbridge/amd/agesa/oem_s3.c index 16426bc518..dfc1ebc936 100644 --- a/src/northbridge/amd/agesa/oem_s3.c +++ b/src/northbridge/amd/agesa/oem_s3.c @@ -27,17 +27,15 @@ typedef enum { S3DataTypeNonVolatile=0, ///< NonVolatile Data Type - S3DataTypeVolatile, ///< Volatile Data Type S3DataTypeMTRR ///< MTRR storage } S3_DATA_TYPE; /* The size needs to be 4k aligned, which is the sector size of most flashes. */ -#define S3_DATA_VOLATILE_SIZE 0x6000 #define S3_DATA_MTRR_SIZE 0x1000 #define S3_DATA_NONVOLATILE_SIZE 0x1000 #if IS_ENABLED(CONFIG_HAVE_ACPI_RESUME) && \ - (S3_DATA_VOLATILE_SIZE + S3_DATA_MTRR_SIZE + S3_DATA_NONVOLATILE_SIZE) > CONFIG_S3_DATA_SIZE + (S3_DATA_MTRR_SIZE + S3_DATA_NONVOLATILE_SIZE) > CONFIG_S3_DATA_SIZE #error "Please increase the value of S3_DATA_SIZE" #endif @@ -47,16 +45,12 @@ static void get_s3nv_data(S3_DATA_TYPE S3DataType, u32 *pos, u32 *len) u32 s3_data = CONFIG_S3_DATA_POS; switch (S3DataType) { - case S3DataTypeVolatile: - *pos = s3_data; - *len = S3_DATA_VOLATILE_SIZE; - break; case S3DataTypeMTRR: - *pos = s3_data + S3_DATA_VOLATILE_SIZE; + *pos = s3_data; *len = S3_DATA_MTRR_SIZE; break; case S3DataTypeNonVolatile: - *pos = s3_data + S3_DATA_VOLATILE_SIZE + S3_DATA_MTRR_SIZE; + *pos = s3_data + S3_DATA_MTRR_SIZE; *len = S3_DATA_NONVOLATILE_SIZE; break; default: @@ -84,21 +78,13 @@ AGESA_STATUS OemInitResume(AMD_RESUME_PARAMS *ResumeParams) AGESA_STATUS OemS3LateRestore(AMD_S3LATE_PARAMS *S3LateParams) { AMD_S3_PARAMS *dataBlock = &S3LateParams->S3DataBlock; - u32 pos, size; void *dst; size_t len; - /* TODO: Named volatile, do we need to save it over S3? */ - get_s3nv_data(S3DataTypeVolatile, &pos, &size); - void *src = (void *) (pos + sizeof(UINT32)); - ResumeHeap(&dst, &len); dataBlock->VolatileStorageSize = len; dataBlock->VolatileStorage = dst; - len = *(UINT32 *) pos; - memcpy(dst, src, len); - return AGESA_SUCCESS; } @@ -139,9 +125,6 @@ AGESA_STATUS OemS3Save(AMD_S3SAVE_PARAMS *S3SaveParams) if (HIGH_ROMSTAGE_STACK_SIZE) cbmem_add(CBMEM_ID_ROMSTAGE_RAM_STACK, HIGH_ROMSTAGE_STACK_SIZE); - if (HIGH_MEMORY_SCRATCH) - cbmem_add(CBMEM_ID_RESUME_SCRATCH, HIGH_MEMORY_SCRATCH); - /* To be consumed in AmdInitResume. */ get_s3nv_data(S3DataTypeNonVolatile, &pos, &size); if (size && dataBlock->NvStorageSize) @@ -149,10 +132,11 @@ AGESA_STATUS OemS3Save(AMD_S3SAVE_PARAMS *S3SaveParams) dataBlock->NvStorageSize); /* To be consumed in AmdS3LateRestore. */ - get_s3nv_data(S3DataTypeVolatile, &pos, &size); - if (size && dataBlock->VolatileStorageSize) - spi_SaveS3info(pos, size, dataBlock->VolatileStorage, - dataBlock->VolatileStorageSize); + char *heap = cbmem_add(CBMEM_ID_RESUME_SCRATCH, HIGH_MEMORY_SCRATCH); + if (heap) { + memset(heap, 0, HIGH_MEMORY_SCRATCH); + memcpy(heap, dataBlock->VolatileStorage, dataBlock->VolatileStorageSize); + } /* Collect MTRR setup. */ backup_mtrr(MTRRStorage, &MTRRStorageSize); -- cgit v1.2.3