From b1fcbf364f0d81b8d28755055ae9558af2f4b712 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ky=C3=B6sti=20M=C3=A4lkki?= Date: Tue, 26 May 2015 11:25:13 +0300 Subject: AGESA: Separate HeapManager declarations from BiosCallOuts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I168db92b10d5abc05be2dc374df3f892003d5255 Signed-off-by: Kyösti Mälkki Reviewed-on: http://review.coreboot.org/10317 Tested-by: build bot (Jenkins) Reviewed-by: Edward O'Callaghan --- src/cpu/amd/agesa/heapmanager.c | 40 ++++++++++++++++++++++++++++++++-------- src/cpu/amd/agesa/s3_resume.h | 4 ++++ 2 files changed, 36 insertions(+), 8 deletions(-) (limited to 'src/cpu/amd') diff --git a/src/cpu/amd/agesa/heapmanager.c b/src/cpu/amd/agesa/heapmanager.c index b3af18c7ba..52a4e502b0 100644 --- a/src/cpu/amd/agesa/heapmanager.c +++ b/src/cpu/amd/agesa/heapmanager.c @@ -10,24 +10,48 @@ #include #include +#if IS_ENABLED(CONFIG_NORTHBRIDGE_AMD_AGESA_FAMILY15_TN) || \ + IS_ENABLED(CONFIG_NORTHBRIDGE_AMD_AGESA_FAMILY15_RL) || \ + IS_ENABLED(CONFIG_NORTHBRIDGE_AMD_AGESA_FAMILY16_KB) + +/* BIOS_HEAP_START_ADDRESS is only for cold boots. */ +#define BIOS_HEAP_SIZE 0x30000 +#define BIOS_HEAP_START_ADDRESS 0x010000000 + +#else + +/* BIOS_HEAP_START_ADDRESS is only for cold boots. */ +#define BIOS_HEAP_SIZE 0x20000 +#define BIOS_HEAP_START_ADDRESS (BSP_STACK_BASE_ADDR - BIOS_HEAP_SIZE) + +#endif + #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) +void *GetHeapBase(void) { - UINT32 heap = BIOS_HEAP_START_ADDRESS; + void *heap = (void *)BIOS_HEAP_START_ADDRESS; if (acpi_is_wakeup_s3()) - heap = (UINT32) cbmem_find(CBMEM_ID_RESUME_SCRATCH); + heap = cbmem_find(CBMEM_ID_RESUME_SCRATCH); return heap; } void EmptyHeap(void) { - void *BiosManagerPtr = (void *) GetHeapBase(NULL); - memset(BiosManagerPtr, 0, BIOS_HEAP_SIZE); + void *base = GetHeapBase(); + memset(base, 0, BIOS_HEAP_SIZE); +} + +void ResumeHeap(void **heap, size_t *len) +{ + void *base = GetHeapBase(); + memset(base, 0, BIOS_HEAP_SIZE); + *heap = base; + *len = BIOS_HEAP_SIZE; } #if (IS_ENABLED(CONFIG_NORTHBRIDGE_AMD_AGESA_FAMILY15_TN) || \ @@ -96,7 +120,7 @@ static AGESA_STATUS agesa_AllocateBuffer(UINT32 Func, UINT32 Data, VOID *ConfigP #endif AvailableHeapSize = BIOS_HEAP_SIZE - sizeof (BIOS_HEAP_MANAGER); - BiosHeapBaseAddr = (UINT8 *) GetHeapBase(&(AllocParams->StdHeader)); + BiosHeapBaseAddr = GetHeapBase(); BiosHeapBasePtr = (BIOS_HEAP_MANAGER *) BiosHeapBaseAddr; if (BiosHeapBasePtr->StartOfAllocatedNodes == 0) { @@ -221,7 +245,7 @@ static AGESA_STATUS agesa_DeallocateBuffer(UINT32 Func, UINT32 Data, VOID *Confi AllocParams = (AGESA_BUFFER_PARAMS *) ConfigPtr; - BiosHeapBaseAddr = (UINT8 *) GetHeapBase(&(AllocParams->StdHeader)); + BiosHeapBaseAddr = GetHeapBase(); BiosHeapBasePtr = (BIOS_HEAP_MANAGER *) BiosHeapBaseAddr; /* Find target node to deallocate in list of allocated nodes. @@ -332,7 +356,7 @@ static AGESA_STATUS agesa_LocateBuffer(UINT32 Func, UINT32 Data, VOID *ConfigPtr AllocParams = (AGESA_BUFFER_PARAMS *) ConfigPtr; - BiosHeapBaseAddr = (UINT8 *) GetHeapBase(&(AllocParams->StdHeader)); + BiosHeapBaseAddr = GetHeapBase(); BiosHeapBasePtr = (BIOS_HEAP_MANAGER *) BiosHeapBaseAddr; AllocNodeOffset = BiosHeapBasePtr->StartOfAllocatedNodes; diff --git a/src/cpu/amd/agesa/s3_resume.h b/src/cpu/amd/agesa/s3_resume.h index 97a2a21b91..8a855e283b 100644 --- a/src/cpu/amd/agesa/s3_resume.h +++ b/src/cpu/amd/agesa/s3_resume.h @@ -26,6 +26,10 @@ void prepare_for_resume(void); void backup_mtrr(void *mtrr_store, u32 *mtrr_store_size); const void *OemS3Saved_MTRR_Storage(void); +void *GetHeapBase(void); +void EmptyHeap(void); +void ResumeHeap(void **heap, size_t *len); + #define BSP_STACK_BASE_ADDR 0x30000 #if 1 -- cgit v1.2.3