[coreboot-gerrit] New patch to review for coreboot: f119833 AGESA fam12: Add GetHeapBase()

Kyösti Mälkki (kyosti.malkki@gmail.com) gerrit at coreboot.org
Sun May 4 07:56:08 CEST 2014


Kyösti Mälkki (kyosti.malkki at gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/5654

-gerrit

commit f119833cd996fb9a60ed32607989fac34c48406c
Author: Kyösti Mälkki <kyosti.malkki at gmail.com>
Date:   Fri May 2 09:40:04 2014 +0300

    AGESA fam12: Add GetHeapBase()
    
    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 <kyosti.malkki at gmail.com>
---
 src/mainboard/amd/torpedo/agesawrapper.c           |  2 +-
 .../amd/agesa/family12/fam12_callouts.c            | 30 +++++++++++++++++-----
 .../amd/agesa/family12/fam12_callouts.h            |  2 ++
 3 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/src/mainboard/amd/torpedo/agesawrapper.c b/src/mainboard/amd/torpedo/agesawrapper.c
index 45b591a..eb4da38 100644
--- a/src/mainboard/amd/torpedo/agesawrapper.c
+++ b/src/mainboard/amd/torpedo/agesawrapper.c
@@ -391,7 +391,7 @@ agesawrapper_amdinitpost (
   AmdReleaseStruct (&AmdParamStruct);
 
   /* Initialize heap space */
-  BiosManagerPtr = (BIOS_HEAP_MANAGER *)BIOS_HEAP_START_ADDRESS;
+  BiosManagerPtr = (BIOS_HEAP_MANAGER *)GetHeapBase(&AmdParamStruct.StdHeader);
 
   HeadPtr = (UINT32 *) ((UINT8 *) BiosManagerPtr + sizeof (BIOS_HEAP_MANAGER));
   for (i = 0; i < ((BIOS_HEAP_SIZE/4) - (sizeof (BIOS_HEAP_MANAGER)/4)); i++)
diff --git a/src/northbridge/amd/agesa/family12/fam12_callouts.c b/src/northbridge/amd/agesa/family12/fam12_callouts.c
index 192c5dd..491f3ce 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 <cbmem.h>
+#include <arch/acpi.h>
 
+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 fd08cfe..387ff30 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
  */



More information about the coreboot-gerrit mailing list