AGESA: Refactor S3 support functions
Producer and consumer of these buffers now appear in same file. Also add test for uninitialized NonVolatileStorage in SPI. Change-Id: Ibbf6581a0bf1d4bffda870fc055721627b538b92 Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: https://review.coreboot.org/19037 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth <martinroth@google.com>
This commit is contained in:
parent
85782b2152
commit
424c63950b
|
@ -62,16 +62,6 @@ void EmptyHeap(void)
|
||||||
(unsigned int)(uintptr_t) base, (unsigned int)(uintptr_t) base + BIOS_HEAP_SIZE - 1);
|
(unsigned int)(uintptr_t) base, (unsigned int)(uintptr_t) base + BIOS_HEAP_SIZE - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResumeHeap(void **heap, size_t *len)
|
|
||||||
{
|
|
||||||
void *base = GetHeapBase();
|
|
||||||
*heap = base;
|
|
||||||
*len = BIOS_HEAP_SIZE;
|
|
||||||
|
|
||||||
printk(BIOS_DEBUG, "Using resume HEAP at [%08x - %08x]\n",
|
|
||||||
(unsigned int)(uintptr_t) base, (unsigned int)(uintptr_t) base + BIOS_HEAP_SIZE - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if (IS_ENABLED(CONFIG_NORTHBRIDGE_AMD_AGESA_FAMILY15_TN) || \
|
#if (IS_ENABLED(CONFIG_NORTHBRIDGE_AMD_AGESA_FAMILY15_TN) || \
|
||||||
IS_ENABLED(CONFIG_NORTHBRIDGE_AMD_AGESA_FAMILY15_RL)) && !defined(__PRE_RAM__)
|
IS_ENABLED(CONFIG_NORTHBRIDGE_AMD_AGESA_FAMILY15_RL)) && !defined(__PRE_RAM__)
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,6 @@ void amd_initenv(void);
|
||||||
|
|
||||||
void *GetHeapBase(void);
|
void *GetHeapBase(void);
|
||||||
void EmptyHeap(void);
|
void EmptyHeap(void);
|
||||||
void ResumeHeap(void **heap, size_t *len);
|
|
||||||
|
|
||||||
#define BSP_STACK_BASE_ADDR 0x30000
|
#define BSP_STACK_BASE_ADDR 0x30000
|
||||||
|
|
||||||
|
|
|
@ -61,24 +61,33 @@ static void get_s3nv_data(S3_DATA_TYPE S3DataType, uintptr_t *pos, uintptr_t *le
|
||||||
AGESA_STATUS OemInitResume(AMD_S3_PARAMS *dataBlock)
|
AGESA_STATUS OemInitResume(AMD_S3_PARAMS *dataBlock)
|
||||||
{
|
{
|
||||||
uintptr_t pos, size;
|
uintptr_t pos, size;
|
||||||
|
|
||||||
get_s3nv_data(S3DataTypeNonVolatile, &pos, &size);
|
get_s3nv_data(S3DataTypeNonVolatile, &pos, &size);
|
||||||
|
|
||||||
/* TODO: Our NvStorage is really const. */
|
u32 len = *(u32*)pos;
|
||||||
dataBlock->NvStorageSize = *(UINT32 *) pos;
|
|
||||||
dataBlock->NvStorage = (void *) (pos + sizeof(UINT32));
|
/* Test for uninitialized s3nv data in SPI. */
|
||||||
|
if (len == 0 || len == (u32)-1ULL)
|
||||||
|
return AGESA_FATAL;
|
||||||
|
|
||||||
|
dataBlock->NvStorageSize = len;
|
||||||
|
dataBlock->NvStorage = (void *) (pos + sizeof(u32));
|
||||||
return AGESA_SUCCESS;
|
return AGESA_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
AGESA_STATUS OemS3LateRestore(AMD_S3_PARAMS *dataBlock)
|
AGESA_STATUS OemS3LateRestore(AMD_S3_PARAMS *dataBlock)
|
||||||
{
|
{
|
||||||
void *dst;
|
char *heap = cbmem_find(CBMEM_ID_RESUME_SCRATCH);
|
||||||
size_t len;
|
if (heap == NULL)
|
||||||
|
return AGESA_FATAL;
|
||||||
|
|
||||||
ResumeHeap(&dst, &len);
|
printk(BIOS_DEBUG, "Using resume HEAP at %08x\n",
|
||||||
dataBlock->VolatileStorageSize = len;
|
(unsigned int)(uintptr_t) heap);
|
||||||
dataBlock->VolatileStorage = dst;
|
|
||||||
|
|
||||||
|
/* Return allocated CBMEM size, we do not keep track of
|
||||||
|
* how much was actually used.
|
||||||
|
*/
|
||||||
|
dataBlock->VolatileStorageSize = HIGH_MEMORY_SCRATCH;
|
||||||
|
dataBlock->VolatileStorage = heap;
|
||||||
return AGESA_SUCCESS;
|
return AGESA_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue