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>
This commit is contained in:
parent
f7284089e3
commit
b1fcbf364f
|
@ -10,24 +10,48 @@
|
||||||
#include <arch/acpi.h>
|
#include <arch/acpi.h>
|
||||||
#include <string.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)
|
#if IS_ENABLED(CONFIG_HAVE_ACPI_RESUME) && (HIGH_MEMORY_SCRATCH < BIOS_HEAP_SIZE)
|
||||||
#error Increase HIGH_MEMORY_SCRATCH allocation
|
#error Increase HIGH_MEMORY_SCRATCH allocation
|
||||||
#endif
|
#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())
|
if (acpi_is_wakeup_s3())
|
||||||
heap = (UINT32) cbmem_find(CBMEM_ID_RESUME_SCRATCH);
|
heap = cbmem_find(CBMEM_ID_RESUME_SCRATCH);
|
||||||
|
|
||||||
return heap;
|
return heap;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmptyHeap(void)
|
void EmptyHeap(void)
|
||||||
{
|
{
|
||||||
void *BiosManagerPtr = (void *) GetHeapBase(NULL);
|
void *base = GetHeapBase();
|
||||||
memset(BiosManagerPtr, 0, BIOS_HEAP_SIZE);
|
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) || \
|
#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
|
#endif
|
||||||
|
|
||||||
AvailableHeapSize = BIOS_HEAP_SIZE - sizeof (BIOS_HEAP_MANAGER);
|
AvailableHeapSize = BIOS_HEAP_SIZE - sizeof (BIOS_HEAP_MANAGER);
|
||||||
BiosHeapBaseAddr = (UINT8 *) GetHeapBase(&(AllocParams->StdHeader));
|
BiosHeapBaseAddr = GetHeapBase();
|
||||||
BiosHeapBasePtr = (BIOS_HEAP_MANAGER *) BiosHeapBaseAddr;
|
BiosHeapBasePtr = (BIOS_HEAP_MANAGER *) BiosHeapBaseAddr;
|
||||||
|
|
||||||
if (BiosHeapBasePtr->StartOfAllocatedNodes == 0) {
|
if (BiosHeapBasePtr->StartOfAllocatedNodes == 0) {
|
||||||
|
@ -221,7 +245,7 @@ static AGESA_STATUS agesa_DeallocateBuffer(UINT32 Func, UINT32 Data, VOID *Confi
|
||||||
|
|
||||||
AllocParams = (AGESA_BUFFER_PARAMS *) ConfigPtr;
|
AllocParams = (AGESA_BUFFER_PARAMS *) ConfigPtr;
|
||||||
|
|
||||||
BiosHeapBaseAddr = (UINT8 *) GetHeapBase(&(AllocParams->StdHeader));
|
BiosHeapBaseAddr = GetHeapBase();
|
||||||
BiosHeapBasePtr = (BIOS_HEAP_MANAGER *) BiosHeapBaseAddr;
|
BiosHeapBasePtr = (BIOS_HEAP_MANAGER *) BiosHeapBaseAddr;
|
||||||
|
|
||||||
/* Find target node to deallocate in list of allocated nodes.
|
/* 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;
|
AllocParams = (AGESA_BUFFER_PARAMS *) ConfigPtr;
|
||||||
|
|
||||||
BiosHeapBaseAddr = (UINT8 *) GetHeapBase(&(AllocParams->StdHeader));
|
BiosHeapBaseAddr = GetHeapBase();
|
||||||
BiosHeapBasePtr = (BIOS_HEAP_MANAGER *) BiosHeapBaseAddr;
|
BiosHeapBasePtr = (BIOS_HEAP_MANAGER *) BiosHeapBaseAddr;
|
||||||
|
|
||||||
AllocNodeOffset = BiosHeapBasePtr->StartOfAllocatedNodes;
|
AllocNodeOffset = BiosHeapBasePtr->StartOfAllocatedNodes;
|
||||||
|
|
|
@ -26,6 +26,10 @@ void prepare_for_resume(void);
|
||||||
void backup_mtrr(void *mtrr_store, u32 *mtrr_store_size);
|
void backup_mtrr(void *mtrr_store, u32 *mtrr_store_size);
|
||||||
const void *OemS3Saved_MTRR_Storage(void);
|
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
|
#define BSP_STACK_BASE_ADDR 0x30000
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
|
|
|
@ -24,24 +24,6 @@
|
||||||
#include "Porting.h"
|
#include "Porting.h"
|
||||||
#include "AGESA.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_NoopUnsupported (UINT32 Func, UINT32 Data, VOID *ConfigPtr);
|
||||||
AGESA_STATUS agesa_NoopSuccess (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);
|
AGESA_STATUS agesa_EmptyIdsInitData (UINT32 Func, UINT32 Data, VOID *ConfigPtr);
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include <northbridge/amd/agesa/agesawrapper.h>
|
#include <northbridge/amd/agesa/agesawrapper.h>
|
||||||
#include <northbridge/amd/agesa/BiosCallOuts.h>
|
#include <northbridge/amd/agesa/BiosCallOuts.h>
|
||||||
#include "amdlib.h"
|
#include "amdlib.h"
|
||||||
|
#include <cpu/amd/agesa/s3_resume.h>
|
||||||
|
|
||||||
#include "heapManager.h"
|
#include "heapManager.h"
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <cbmem.h>
|
#include <cbmem.h>
|
||||||
#include <cpu/amd/agesa/s3_resume.h>
|
#include <cpu/amd/agesa/s3_resume.h>
|
||||||
#include <northbridge/amd/agesa/BiosCallOuts.h>
|
|
||||||
#include <northbridge/amd/agesa/agesawrapper.h>
|
#include <northbridge/amd/agesa/agesawrapper.h>
|
||||||
#include <AGESA.h>
|
#include <AGESA.h>
|
||||||
|
|
||||||
|
@ -85,18 +84,21 @@ AGESA_STATUS OemInitResume(AMD_RESUME_PARAMS *ResumeParams)
|
||||||
AGESA_STATUS OemS3LateRestore(AMD_S3LATE_PARAMS *S3LateParams)
|
AGESA_STATUS OemS3LateRestore(AMD_S3LATE_PARAMS *S3LateParams)
|
||||||
{
|
{
|
||||||
AMD_S3_PARAMS *dataBlock = &S3LateParams->S3DataBlock;
|
AMD_S3_PARAMS *dataBlock = &S3LateParams->S3DataBlock;
|
||||||
AMD_CONFIG_PARAMS StdHeader;
|
|
||||||
u32 pos, size;
|
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);
|
get_s3nv_data(S3DataTypeVolatile, &pos, &size);
|
||||||
|
|
||||||
u32 len = *(UINT32 *) pos;
|
|
||||||
void *src = (void *) (pos + sizeof(UINT32));
|
void *src = (void *) (pos + sizeof(UINT32));
|
||||||
void *dst = (void *) GetHeapBase(&StdHeader);
|
|
||||||
|
|
||||||
memcpy(dst, src, len);
|
ResumeHeap(&dst, &len);
|
||||||
dataBlock->VolatileStorageSize = len;
|
dataBlock->VolatileStorageSize = len;
|
||||||
dataBlock->VolatileStorage = dst;
|
dataBlock->VolatileStorage = dst;
|
||||||
|
|
||||||
|
len = *(UINT32 *) pos;
|
||||||
|
memcpy(dst, src, len);
|
||||||
|
|
||||||
return AGESA_SUCCESS;
|
return AGESA_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,13 +41,17 @@
|
||||||
|
|
||||||
extern UINT8 picr_data[0x54], intr_data[0x54];
|
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)
|
AGESA_STATUS agesawrapper_fchs3earlyrestore (void)
|
||||||
{
|
{
|
||||||
FCH_DATA_BLOCK FchParams;
|
FCH_DATA_BLOCK FchParams;
|
||||||
AMD_CONFIG_PARAMS StdHeader;
|
AMD_CONFIG_PARAMS StdHeader;
|
||||||
|
|
||||||
StdHeader.HeapStatus = HEAP_SYSTEM_MEM;
|
StdHeader.HeapStatus = HEAP_SYSTEM_MEM;
|
||||||
StdHeader.HeapBasePtr = GetHeapBase(&StdHeader) + 0x10;
|
StdHeader.HeapBasePtr = (uintptr_t) GetHeapBase() + 0x10;
|
||||||
StdHeader.AltImageBasePtr = 0;
|
StdHeader.AltImageBasePtr = 0;
|
||||||
StdHeader.CalloutPtr = (CALLOUT_ENTRY) &GetBiosCallout;
|
StdHeader.CalloutPtr = (CALLOUT_ENTRY) &GetBiosCallout;
|
||||||
StdHeader.Func = 0;
|
StdHeader.Func = 0;
|
||||||
|
@ -67,7 +71,7 @@ AGESA_STATUS agesawrapper_fchs3laterestore (void)
|
||||||
UINT8 byte;
|
UINT8 byte;
|
||||||
|
|
||||||
StdHeader.HeapStatus = HEAP_SYSTEM_MEM;
|
StdHeader.HeapStatus = HEAP_SYSTEM_MEM;
|
||||||
StdHeader.HeapBasePtr = GetHeapBase(&StdHeader) + 0x10;
|
StdHeader.HeapBasePtr = (uintptr_t) GetHeapBase() + 0x10;
|
||||||
StdHeader.AltImageBasePtr = 0;
|
StdHeader.AltImageBasePtr = 0;
|
||||||
StdHeader.CalloutPtr = (CALLOUT_ENTRY) &GetBiosCallout;
|
StdHeader.CalloutPtr = (CALLOUT_ENTRY) &GetBiosCallout;
|
||||||
StdHeader.Func = 0;
|
StdHeader.Func = 0;
|
||||||
|
|
Loading…
Reference in New Issue