Kyösti Mälkki (kyosti.malkki@gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/10317
-gerrit
commit ce1130682543aee26ab519a4b4eabfe59b6b495b Author: Kyösti Mälkki kyosti.malkki@gmail.com Date: Tue May 26 11:25:13 2015 +0300
AGESA: Separate HeapManager declarations from BiosCallOuts
Change-Id: I168db92b10d5abc05be2dc374df3f892003d5255 Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com --- src/cpu/amd/agesa/heapmanager.c | 44 +++++++++++++++++++++++++------- src/cpu/amd/agesa/s3_resume.h | 3 +++ src/northbridge/amd/agesa/BiosCallOuts.h | 18 ------------- src/northbridge/amd/agesa/agesawrapper.c | 1 + src/northbridge/amd/agesa/oem_s3.c | 14 +++++----- 5 files changed, 47 insertions(+), 33 deletions(-)
diff --git a/src/cpu/amd/agesa/heapmanager.c b/src/cpu/amd/agesa/heapmanager.c index b7c4984..093d7cf 100644 --- a/src/cpu/amd/agesa/heapmanager.c +++ b/src/cpu/amd/agesa/heapmanager.c @@ -1,31 +1,57 @@
#include "AGESA.h" #include "amdlib.h" -#include <northbridge/amd/agesa/BiosCallOuts.h> #include "heapManager.h"
#include <cbmem.h> +#include <cpu/amd/agesa/s3_resume.h> +#include <northbridge/amd/agesa/BiosCallOuts.h> + #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) +static 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) || \ @@ -94,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) { @@ -219,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. @@ -330,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 97a2a21..579af73 100644 --- a/src/cpu/amd/agesa/s3_resume.h +++ b/src/cpu/amd/agesa/s3_resume.h @@ -26,6 +26,9 @@ void prepare_for_resume(void); void backup_mtrr(void *mtrr_store, u32 *mtrr_store_size); const void *OemS3Saved_MTRR_Storage(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 cfe1852..e763b8c 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 8ad36c7..bfad605 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 779e28b..16426bc 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; }