From 4f998a07b51340dde499701fbff739f7df373059 Mon Sep 17 00:00:00 2001 From: Kyösti Mälkki Date: Fri, 2 May 2014 09:40:04 +0300 Subject: AGESA fam12: Add GetHeapBase() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While amd/torpedo does not select HAVE_ACPI_RESUME, backport this from fam14. Implementation of this function is common across different families. Change-Id: I0e5099a0991a2655ec2b6990929196900e842fc1 Signed-off-by: Kyösti Mälkki Reviewed-on: http://review.coreboot.org/5654 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi --- .../amd/agesa/family12/fam12_callouts.c | 30 +++++++++++++++++----- .../amd/agesa/family12/fam12_callouts.h | 2 ++ 2 files changed, 25 insertions(+), 7 deletions(-) (limited to 'src/northbridge') diff --git a/src/northbridge/amd/agesa/family12/fam12_callouts.c b/src/northbridge/amd/agesa/family12/fam12_callouts.c index 192c5ddaff..491f3ce47b 100644 --- a/src/northbridge/amd/agesa/family12/fam12_callouts.c +++ b/src/northbridge/amd/agesa/family12/fam12_callouts.c @@ -25,7 +25,23 @@ #include "OptionsIds.h" #include "heapManager.h" #include "Hudson-2.h" +#include +#include +UINT32 GetHeapBase(AMD_CONFIG_PARAMS *StdHeader) +{ + UINT32 heap = BIOS_HEAP_START_ADDRESS; + +#if CONFIG_HAVE_ACPI_RESUME + /* Both romstage and ramstage has this S3 detect. */ + if (acpi_get_sleep_type() == 3) + heap = (UINT32) cbmem_find(CBMEM_ID_RESUME_SCRATCH) + + (CONFIG_HIGH_SCRATCH_MEMORY_SIZE - BIOS_HEAP_SIZE); + /* himem_heap_base + high_stack_size */ +#endif + + return heap; +} AGESA_STATUS BiosAllocateBuffer (UINT32 Func, UINT32 Data, VOID *ConfigPtr) { @@ -49,8 +65,8 @@ AGESA_STATUS BiosAllocateBuffer (UINT32 Func, UINT32 Data, VOID *ConfigPtr) AllocParams->BufferPointer = NULL; AvailableHeapSize = BIOS_HEAP_SIZE - sizeof (BIOS_HEAP_MANAGER); - BiosHeapBaseAddr = (UINT8 *) BIOS_HEAP_START_ADDRESS; - BiosHeapBasePtr = (BIOS_HEAP_MANAGER *) BIOS_HEAP_START_ADDRESS; + BiosHeapBaseAddr = (UINT8 *) GetHeapBase(&(AllocParams->StdHeader)); + BiosHeapBasePtr = (BIOS_HEAP_MANAGER *) BiosHeapBaseAddr; if (BiosHeapBasePtr->StartOfAllocatedNodes == 0) { /* First allocation */ @@ -172,11 +188,11 @@ AGESA_STATUS BiosDeallocateBuffer (UINT32 Func, UINT32 Data, VOID *ConfigPtr) BIOS_HEAP_MANAGER *BiosHeapBasePtr; AGESA_BUFFER_PARAMS *AllocParams; - BiosHeapBaseAddr = (UINT8 *) BIOS_HEAP_START_ADDRESS; - BiosHeapBasePtr = (BIOS_HEAP_MANAGER *) BIOS_HEAP_START_ADDRESS; - AllocParams = (AGESA_BUFFER_PARAMS *) ConfigPtr; + BiosHeapBaseAddr = (UINT8 *) GetHeapBase(&(AllocParams->StdHeader)); + BiosHeapBasePtr = (BIOS_HEAP_MANAGER *) BiosHeapBaseAddr; + /* Find target node to deallocate in list of allocated nodes. Return AGESA_BOUNDS_CHK if the BufferHandle is not found */ @@ -285,8 +301,8 @@ AGESA_STATUS BiosLocateBuffer (UINT32 Func, UINT32 Data, VOID *ConfigPtr) AllocParams = (AGESA_BUFFER_PARAMS *) ConfigPtr; - BiosHeapBaseAddr = (UINT8 *) BIOS_HEAP_START_ADDRESS; - BiosHeapBasePtr = (BIOS_HEAP_MANAGER *) BIOS_HEAP_START_ADDRESS; + BiosHeapBaseAddr = (UINT8 *) GetHeapBase(&(AllocParams->StdHeader)); + BiosHeapBasePtr = (BIOS_HEAP_MANAGER *) BiosHeapBaseAddr; AllocNodeOffset = BiosHeapBasePtr->StartOfAllocatedNodes; AllocNodePtr = (BIOS_BUFFER_NODE *) (BiosHeapBaseAddr + AllocNodeOffset); diff --git a/src/northbridge/amd/agesa/family12/fam12_callouts.h b/src/northbridge/amd/agesa/family12/fam12_callouts.h index fd08cfe65a..387ff303ef 100644 --- a/src/northbridge/amd/agesa/family12/fam12_callouts.h +++ b/src/northbridge/amd/agesa/family12/fam12_callouts.h @@ -38,6 +38,8 @@ typedef struct _BIOS_BUFFER_NODE { UINT32 NextNodeOffset; } BIOS_BUFFER_NODE; +UINT32 GetHeapBase(AMD_CONFIG_PARAMS *StdHeader); + /* REQUIRED CALLOUTS * AGESA ADVANCED CALLOUTS - CPU */ -- cgit v1.2.3