AGESA: Split S3 backup in CBMEM
Use separate CBMEM allocations for stack and heap on S3 resume path. The allocation of HIGH_SCRATCH_MEMORY is specific to AGESA and is moved out of globals and ACPI. This region is a replacement for BIOS_HEAP_SIZE used on non-resume paths. Change-Id: I6658ce1c06964de5cf13b4e3c84d571f46ce76f3 Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: http://review.coreboot.org/10316 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
parent
49d30668b6
commit
f7284089e3
|
@ -913,9 +913,6 @@ void acpi_prepare_resume_backup(void)
|
||||||
|
|
||||||
if (HIGH_MEMORY_SAVE)
|
if (HIGH_MEMORY_SAVE)
|
||||||
cbmem_add(CBMEM_ID_RESUME, HIGH_MEMORY_SAVE);
|
cbmem_add(CBMEM_ID_RESUME, HIGH_MEMORY_SAVE);
|
||||||
|
|
||||||
if (HIGH_MEMORY_SCRATCH)
|
|
||||||
cbmem_add(CBMEM_ID_RESUME_SCRATCH, HIGH_MEMORY_SCRATCH);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static acpi_rsdp_t *valid_rsdp(acpi_rsdp_t *rsdp)
|
static acpi_rsdp_t *valid_rsdp(acpi_rsdp_t *rsdp)
|
||||||
|
|
|
@ -40,9 +40,4 @@ config XIP_ROM_SIZE
|
||||||
hex
|
hex
|
||||||
default 0x80000
|
default 0x80000
|
||||||
|
|
||||||
config HIGH_SCRATCH_MEMORY_SIZE
|
|
||||||
hex
|
|
||||||
# Assume the maximum size of stack as (0xA0000 - 0x30000 + 0x1000)
|
|
||||||
default 0x71000
|
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -41,9 +41,4 @@ config XIP_ROM_SIZE
|
||||||
hex
|
hex
|
||||||
default 0x100000
|
default 0x100000
|
||||||
|
|
||||||
config HIGH_SCRATCH_MEMORY_SIZE
|
|
||||||
hex
|
|
||||||
# Assume the maximum size of stack as (0xA0000 - 0x30000 + 0x1000)
|
|
||||||
default 0xA1000
|
|
||||||
|
|
||||||
endif # CPU_AMD_AGESA_FAMILY15_RL
|
endif # CPU_AMD_AGESA_FAMILY15_RL
|
||||||
|
|
|
@ -40,9 +40,4 @@ config XIP_ROM_SIZE
|
||||||
hex
|
hex
|
||||||
default 0x100000
|
default 0x100000
|
||||||
|
|
||||||
config HIGH_SCRATCH_MEMORY_SIZE
|
|
||||||
hex
|
|
||||||
# Assume the maximum size of stack as (0xA0000 - 0x30000 + 0x1000)
|
|
||||||
default 0xA1000
|
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -44,11 +44,6 @@ config XIP_ROM_SIZE
|
||||||
hex
|
hex
|
||||||
default 0x100000
|
default 0x100000
|
||||||
|
|
||||||
config HIGH_SCRATCH_MEMORY_SIZE
|
|
||||||
hex
|
|
||||||
# Assume the maximum size of stack as (0xA0000 - 0x30000 + 0x1000)
|
|
||||||
default 0xA1000
|
|
||||||
|
|
||||||
config FORCE_AM1_SOCKET_SUPPORT
|
config FORCE_AM1_SOCKET_SUPPORT
|
||||||
bool
|
bool
|
||||||
default n
|
default n
|
||||||
|
|
|
@ -1,21 +1,25 @@
|
||||||
|
|
||||||
#include "AGESA.h"
|
#include "AGESA.h"
|
||||||
#include "amdlib.h"
|
#include "amdlib.h"
|
||||||
#include <northbridge/amd/agesa/BiosCallOuts.h>
|
|
||||||
#include "heapManager.h"
|
#include "heapManager.h"
|
||||||
|
|
||||||
#include <cbmem.h>
|
#include <cbmem.h>
|
||||||
|
#include <cpu/amd/agesa/s3_resume.h>
|
||||||
|
#include <northbridge/amd/agesa/BiosCallOuts.h>
|
||||||
|
|
||||||
#include <arch/acpi.h>
|
#include <arch/acpi.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#if IS_ENABLED(CONFIG_HAVE_ACPI_RESUME) && (HIGH_MEMORY_SCRATCH < BIOS_HEAP_SIZE)
|
||||||
|
#error Increase HIGH_MEMORY_SCRATCH allocation
|
||||||
|
#endif
|
||||||
|
|
||||||
UINT32 GetHeapBase(AMD_CONFIG_PARAMS *StdHeader)
|
UINT32 GetHeapBase(AMD_CONFIG_PARAMS *StdHeader)
|
||||||
{
|
{
|
||||||
UINT32 heap = BIOS_HEAP_START_ADDRESS;
|
UINT32 heap = BIOS_HEAP_START_ADDRESS;
|
||||||
|
|
||||||
if (acpi_is_wakeup_s3())
|
if (acpi_is_wakeup_s3())
|
||||||
heap = (UINT32) cbmem_find(CBMEM_ID_RESUME_SCRATCH) +
|
heap = (UINT32) cbmem_find(CBMEM_ID_RESUME_SCRATCH);
|
||||||
(CONFIG_HIGH_SCRATCH_MEMORY_SIZE - BIOS_HEAP_SIZE);
|
|
||||||
/* himem_heap_base + high_stack_size */
|
|
||||||
|
|
||||||
return heap;
|
return heap;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include <cpu/x86/cache.h>
|
#include <cpu/x86/cache.h>
|
||||||
#include <cbmem.h>
|
#include <cbmem.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <northbridge/amd/agesa/BiosCallOuts.h>
|
|
||||||
#include <halt.h>
|
#include <halt.h>
|
||||||
#include "s3_resume.h"
|
#include "s3_resume.h"
|
||||||
|
|
||||||
|
@ -51,12 +50,12 @@ static void *backup_resume(void)
|
||||||
|
|
||||||
static void move_stack_high_mem(void)
|
static void move_stack_high_mem(void)
|
||||||
{
|
{
|
||||||
void *high_stack;
|
void *high_stack = cbmem_find(CBMEM_ID_ROMSTAGE_RAM_STACK);
|
||||||
|
|
||||||
high_stack = cbmem_find(CBMEM_ID_RESUME_SCRATCH);
|
/* TODO: Make the switch with empty stack instead. */
|
||||||
memcpy(high_stack, (void *)BSP_STACK_BASE_ADDR,
|
memcpy(high_stack, (void *)BSP_STACK_BASE_ADDR, HIGH_ROMSTAGE_STACK_SIZE);
|
||||||
(CONFIG_HIGH_SCRATCH_MEMORY_SIZE - BIOS_HEAP_SIZE));
|
|
||||||
|
|
||||||
|
/* TODO: We only switch stack on BSP. */
|
||||||
__asm__
|
__asm__
|
||||||
volatile ("add %0, %%esp; add %0, %%ebp; invd"::"g"
|
volatile ("add %0, %%esp; add %0, %%ebp; invd"::"g"
|
||||||
(high_stack - BSP_STACK_BASE_ADDR)
|
(high_stack - BSP_STACK_BASE_ADDR)
|
||||||
|
@ -95,7 +94,6 @@ void prepare_for_resume(void)
|
||||||
post_code(0x62);
|
post_code(0x62);
|
||||||
printk(BIOS_DEBUG, "Move CAR stack.\n");
|
printk(BIOS_DEBUG, "Move CAR stack.\n");
|
||||||
move_stack_high_mem();
|
move_stack_high_mem();
|
||||||
printk(BIOS_DEBUG, "stack moved to: 0x%x\n", (u32) (resume_backup_memory + HIGH_MEMORY_SAVE));
|
|
||||||
|
|
||||||
post_code(0x63);
|
post_code(0x63);
|
||||||
disable_cache_as_ram();
|
disable_cache_as_ram();
|
||||||
|
|
|
@ -26,4 +26,16 @@ void prepare_for_resume(void);
|
||||||
void backup_mtrr(void *mtrr_store, u32 *mtrr_store_size);
|
void backup_mtrr(void *mtrr_store, u32 *mtrr_store_size);
|
||||||
const void *OemS3Saved_MTRR_Storage(void);
|
const void *OemS3Saved_MTRR_Storage(void);
|
||||||
|
|
||||||
|
#define BSP_STACK_BASE_ADDR 0x30000
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
/* This covers node 0 only. */
|
||||||
|
#define HIGH_ROMSTAGE_STACK_SIZE (0x48000 - BSP_STACK_BASE_ADDR)
|
||||||
|
#else
|
||||||
|
/* This covers total of 8 nodes. */
|
||||||
|
#define HIGH_ROMSTAGE_STACK_SIZE (0xA0000 - BSP_STACK_BASE_ADDR)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define HIGH_MEMORY_SCRATCH 0x30000
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -28,13 +28,6 @@
|
||||||
#define HIGH_MEMORY_SAVE 0
|
#define HIGH_MEMORY_SAVE 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if IS_ENABLED(CONFIG_HAVE_ACPI_RESUME) && \
|
|
||||||
defined(CONFIG_HIGH_SCRATCH_MEMORY_SIZE)
|
|
||||||
#define HIGH_MEMORY_SCRATCH CONFIG_HIGH_SCRATCH_MEMORY_SIZE
|
|
||||||
#else
|
|
||||||
#define HIGH_MEMORY_SCRATCH 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Delegation of resume backup memory so we don't have to
|
/* Delegation of resume backup memory so we don't have to
|
||||||
* (slowly) handle backing up OS memory in romstage.c
|
* (slowly) handle backing up OS memory in romstage.c
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -30,13 +30,11 @@
|
||||||
|
|
||||||
#define BIOS_HEAP_START_ADDRESS 0x010000000
|
#define BIOS_HEAP_START_ADDRESS 0x010000000
|
||||||
#define BIOS_HEAP_SIZE 0x30000
|
#define BIOS_HEAP_SIZE 0x30000
|
||||||
#define BSP_STACK_BASE_ADDR 0x30000
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define BIOS_HEAP_START_ADDRESS 0x10000 /* HEAP during cold boot */
|
#define BIOS_HEAP_START_ADDRESS 0x10000 /* HEAP during cold boot */
|
||||||
#define BIOS_HEAP_SIZE 0x20000
|
#define BIOS_HEAP_SIZE 0x20000
|
||||||
#define BSP_STACK_BASE_ADDR 0x30000
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <spi-generic.h>
|
#include <spi-generic.h>
|
||||||
#include <spi_flash.h>
|
#include <spi_flash.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <cbmem.h>
|
||||||
#include <cpu/amd/agesa/s3_resume.h>
|
#include <cpu/amd/agesa/s3_resume.h>
|
||||||
#include <northbridge/amd/agesa/BiosCallOuts.h>
|
#include <northbridge/amd/agesa/BiosCallOuts.h>
|
||||||
#include <northbridge/amd/agesa/agesawrapper.h>
|
#include <northbridge/amd/agesa/agesawrapper.h>
|
||||||
|
@ -133,6 +134,12 @@ AGESA_STATUS OemS3Save(AMD_S3SAVE_PARAMS *S3SaveParams)
|
||||||
u32 MTRRStorageSize = 0;
|
u32 MTRRStorageSize = 0;
|
||||||
u32 pos, size;
|
u32 pos, size;
|
||||||
|
|
||||||
|
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. */
|
/* 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)
|
||||||
|
|
Loading…
Reference in New Issue