AGESA: Reduce SPI use by 24kB for S3 support

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 <kyosti.malkki@gmail.com>
Reviewed-on: http://review.coreboot.org/10318
Tested-by: build bot (Jenkins)
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Edward O'Callaghan <edward.ocallaghan@koparo.com>
This commit is contained in:
Kyösti Mälkki 2015-05-26 15:38:58 +03:00
parent b1fcbf364f
commit c74b53fffd
2 changed files with 8 additions and 25 deletions

View File

@ -49,7 +49,6 @@ void EmptyHeap(void)
void ResumeHeap(void **heap, size_t *len) void ResumeHeap(void **heap, size_t *len)
{ {
void *base = GetHeapBase(); void *base = GetHeapBase();
memset(base, 0, BIOS_HEAP_SIZE);
*heap = base; *heap = base;
*len = BIOS_HEAP_SIZE; *len = BIOS_HEAP_SIZE;
} }

View File

@ -27,17 +27,15 @@
typedef enum { typedef enum {
S3DataTypeNonVolatile=0, ///< NonVolatile Data Type S3DataTypeNonVolatile=0, ///< NonVolatile Data Type
S3DataTypeVolatile, ///< Volatile Data Type
S3DataTypeMTRR ///< MTRR storage S3DataTypeMTRR ///< MTRR storage
} S3_DATA_TYPE; } S3_DATA_TYPE;
/* The size needs to be 4k aligned, which is the sector size of most flashes. */ /* 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_MTRR_SIZE 0x1000
#define S3_DATA_NONVOLATILE_SIZE 0x1000 #define S3_DATA_NONVOLATILE_SIZE 0x1000
#if IS_ENABLED(CONFIG_HAVE_ACPI_RESUME) && \ #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" #error "Please increase the value of S3_DATA_SIZE"
#endif #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; u32 s3_data = CONFIG_S3_DATA_POS;
switch (S3DataType) { switch (S3DataType) {
case S3DataTypeVolatile:
*pos = s3_data;
*len = S3_DATA_VOLATILE_SIZE;
break;
case S3DataTypeMTRR: case S3DataTypeMTRR:
*pos = s3_data + S3_DATA_VOLATILE_SIZE; *pos = s3_data;
*len = S3_DATA_MTRR_SIZE; *len = S3_DATA_MTRR_SIZE;
break; break;
case S3DataTypeNonVolatile: 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; *len = S3_DATA_NONVOLATILE_SIZE;
break; break;
default: default:
@ -84,21 +78,13 @@ AGESA_STATUS OemInitResume(AMD_RESUME_PARAMS *ResumeParams)
AGESA_STATUS OemS3LateRestore(AMD_S3LATE_PARAMS *S3LateParams) AGESA_STATUS OemS3LateRestore(AMD_S3LATE_PARAMS *S3LateParams)
{ {
AMD_S3_PARAMS *dataBlock = &S3LateParams->S3DataBlock; AMD_S3_PARAMS *dataBlock = &S3LateParams->S3DataBlock;
u32 pos, size;
void *dst; void *dst;
size_t len; 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); ResumeHeap(&dst, &len);
dataBlock->VolatileStorageSize = len; dataBlock->VolatileStorageSize = len;
dataBlock->VolatileStorage = dst; dataBlock->VolatileStorage = dst;
len = *(UINT32 *) pos;
memcpy(dst, src, len);
return AGESA_SUCCESS; return AGESA_SUCCESS;
} }
@ -139,9 +125,6 @@ AGESA_STATUS OemS3Save(AMD_S3SAVE_PARAMS *S3SaveParams)
if (HIGH_ROMSTAGE_STACK_SIZE) if (HIGH_ROMSTAGE_STACK_SIZE)
cbmem_add(CBMEM_ID_ROMSTAGE_RAM_STACK, 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. */ /* To be consumed in AmdInitResume. */
get_s3nv_data(S3DataTypeNonVolatile, &pos, &size); get_s3nv_data(S3DataTypeNonVolatile, &pos, &size);
if (size && dataBlock->NvStorageSize) if (size && dataBlock->NvStorageSize)
@ -149,10 +132,11 @@ AGESA_STATUS OemS3Save(AMD_S3SAVE_PARAMS *S3SaveParams)
dataBlock->NvStorageSize); dataBlock->NvStorageSize);
/* To be consumed in AmdS3LateRestore. */ /* To be consumed in AmdS3LateRestore. */
get_s3nv_data(S3DataTypeVolatile, &pos, &size); char *heap = cbmem_add(CBMEM_ID_RESUME_SCRATCH, HIGH_MEMORY_SCRATCH);
if (size && dataBlock->VolatileStorageSize) if (heap) {
spi_SaveS3info(pos, size, dataBlock->VolatileStorage, memset(heap, 0, HIGH_MEMORY_SCRATCH);
dataBlock->VolatileStorageSize); memcpy(heap, dataBlock->VolatileStorage, dataBlock->VolatileStorageSize);
}
/* Collect MTRR setup. */ /* Collect MTRR setup. */
backup_mtrr(MTRRStorage, &MTRRStorageSize); backup_mtrr(MTRRStorage, &MTRRStorageSize);