summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKyösti Mälkki <kyosti.malkki@gmail.com>2015-05-26 11:25:13 +0300
committerKyösti Mälkki <kyosti.malkki@gmail.com>2015-05-27 12:52:07 +0200
commitb1fcbf364f0d81b8d28755055ae9558af2f4b712 (patch)
tree3cb520bf43ac71083ac8071891800c9097e18803 /src
parentf7284089e3657c66efeeb180a1f101a60d832901 (diff)
AGESA: Separate HeapManager declarations from BiosCallOuts
Change-Id: I168db92b10d5abc05be2dc374df3f892003d5255 Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: http://review.coreboot.org/10317 Tested-by: build bot (Jenkins) Reviewed-by: Edward O'Callaghan <edward.ocallaghan@koparo.com>
Diffstat (limited to 'src')
-rw-r--r--src/cpu/amd/agesa/heapmanager.c40
-rw-r--r--src/cpu/amd/agesa/s3_resume.h4
-rw-r--r--src/northbridge/amd/agesa/BiosCallOuts.h18
-rw-r--r--src/northbridge/amd/agesa/agesawrapper.c1
-rw-r--r--src/northbridge/amd/agesa/oem_s3.c14
-rw-r--r--src/southbridge/amd/agesa/hudson/agesawrapper.c8
6 files changed, 51 insertions, 34 deletions
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 <arch/acpi.h>
#include <string.h>
+#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
diff --git a/src/northbridge/amd/agesa/BiosCallOuts.h b/src/northbridge/amd/agesa/BiosCallOuts.h
index cfe1852fd4..e763b8c9a0 100644
--- a/src/northbridge/amd/agesa/BiosCallOuts.h
+++ b/src/northbridge/amd/agesa/BiosCallOuts.h
@@ -24,24 +24,6 @@
#include "Porting.h"
#include "AGESA.h"
-#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)
-
-#define BIOS_HEAP_START_ADDRESS 0x010000000
-#define BIOS_HEAP_SIZE 0x30000
-
-#else
-
-#define BIOS_HEAP_START_ADDRESS 0x10000 /* HEAP during cold boot */
-#define BIOS_HEAP_SIZE 0x20000
-
-#endif
-
-
-UINT32 GetHeapBase(AMD_CONFIG_PARAMS *StdHeader);
-void EmptyHeap(void);
-
AGESA_STATUS agesa_NoopUnsupported (UINT32 Func, UINT32 Data, VOID *ConfigPtr);
AGESA_STATUS agesa_NoopSuccess (UINT32 Func, UINT32 Data, VOID *ConfigPtr);
AGESA_STATUS agesa_EmptyIdsInitData (UINT32 Func, UINT32 Data, VOID *ConfigPtr);
diff --git a/src/northbridge/amd/agesa/agesawrapper.c b/src/northbridge/amd/agesa/agesawrapper.c
index 8ad36c7df2..bfad605d9c 100644
--- a/src/northbridge/amd/agesa/agesawrapper.c
+++ b/src/northbridge/amd/agesa/agesawrapper.c
@@ -23,6 +23,7 @@
#include <northbridge/amd/agesa/agesawrapper.h>
#include <northbridge/amd/agesa/BiosCallOuts.h>
#include "amdlib.h"
+#include <cpu/amd/agesa/s3_resume.h>
#include "heapManager.h"
diff --git a/src/northbridge/amd/agesa/oem_s3.c b/src/northbridge/amd/agesa/oem_s3.c
index 779e28b553..16426bc518 100644
--- a/src/northbridge/amd/agesa/oem_s3.c
+++ b/src/northbridge/amd/agesa/oem_s3.c
@@ -22,7 +22,6 @@
#include <string.h>
#include <cbmem.h>
#include <cpu/amd/agesa/s3_resume.h>
-#include <northbridge/amd/agesa/BiosCallOuts.h>
#include <northbridge/amd/agesa/agesawrapper.h>
#include <AGESA.h>
@@ -85,18 +84,21 @@ AGESA_STATUS OemInitResume(AMD_RESUME_PARAMS *ResumeParams)
AGESA_STATUS OemS3LateRestore(AMD_S3LATE_PARAMS *S3LateParams)
{
AMD_S3_PARAMS *dataBlock = &S3LateParams->S3DataBlock;
- AMD_CONFIG_PARAMS StdHeader;
u32 pos, size;
+ void *dst;
+ size_t len;
+ /* TODO: Named volatile, do we need to save it over S3? */
get_s3nv_data(S3DataTypeVolatile, &pos, &size);
-
- u32 len = *(UINT32 *) pos;
void *src = (void *) (pos + sizeof(UINT32));
- void *dst = (void *) GetHeapBase(&StdHeader);
- memcpy(dst, src, len);
+ ResumeHeap(&dst, &len);
dataBlock->VolatileStorageSize = len;
dataBlock->VolatileStorage = dst;
+
+ len = *(UINT32 *) pos;
+ memcpy(dst, src, len);
+
return AGESA_SUCCESS;
}
diff --git a/src/southbridge/amd/agesa/hudson/agesawrapper.c b/src/southbridge/amd/agesa/hudson/agesawrapper.c
index a7e4289a19..b98d7b4c8d 100644
--- a/src/southbridge/amd/agesa/hudson/agesawrapper.c
+++ b/src/southbridge/amd/agesa/hudson/agesawrapper.c
@@ -41,13 +41,17 @@
extern UINT8 picr_data[0x54], intr_data[0x54];
+#if IS_ENABLED(CONFIG_HAVE_ACPI_RESUME)
+#error Use of GetHeapBase() is incorrect or at least suspicious
+#endif
+
AGESA_STATUS agesawrapper_fchs3earlyrestore (void)
{
FCH_DATA_BLOCK FchParams;
AMD_CONFIG_PARAMS StdHeader;
StdHeader.HeapStatus = HEAP_SYSTEM_MEM;
- StdHeader.HeapBasePtr = GetHeapBase(&StdHeader) + 0x10;
+ StdHeader.HeapBasePtr = (uintptr_t) GetHeapBase() + 0x10;
StdHeader.AltImageBasePtr = 0;
StdHeader.CalloutPtr = (CALLOUT_ENTRY) &GetBiosCallout;
StdHeader.Func = 0;
@@ -67,7 +71,7 @@ AGESA_STATUS agesawrapper_fchs3laterestore (void)
UINT8 byte;
StdHeader.HeapStatus = HEAP_SYSTEM_MEM;
- StdHeader.HeapBasePtr = GetHeapBase(&StdHeader) + 0x10;
+ StdHeader.HeapBasePtr = (uintptr_t) GetHeapBase() + 0x10;
StdHeader.AltImageBasePtr = 0;
StdHeader.CalloutPtr = (CALLOUT_ENTRY) &GetBiosCallout;
StdHeader.Func = 0;