From 5ce0506618c653c663251f94447e23f8c3f39fb7 Mon Sep 17 00:00:00 2001 From: Rudolf Marek Date: Mon, 27 May 2013 16:09:44 +0200 Subject: AMD Fam15tn: Add support for AGESA runtime allocation in CBMEM The IOMMU AGESA needs a reserved scratch space and it wants to allocate the stuff for runtime. So provide a simple allocator for 4 KB CBMEM page. Change-Id: I53bdfcd2cd69f84fbfbc6edea53a051f516c05cc Signed-off-by: Rudolf Marek Reviewed-on: http://review.coreboot.org/3315 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel Reviewed-by: Ronald G. Minnich --- src/include/cbmem.h | 1 + src/lib/cbmem_info.c | 1 + .../amd/agesa/family15tn/fam15tn_callouts.c | 27 ++++++++++++++++++++++ 3 files changed, 29 insertions(+) (limited to 'src') diff --git a/src/include/cbmem.h b/src/include/cbmem.h index baec780156..efb0f904cf 100644 --- a/src/include/cbmem.h +++ b/src/include/cbmem.h @@ -71,6 +71,7 @@ #define CBMEM_ID_VBOOT_HANDOFF 0x780074f0 #define CBMEM_ID_CAR_GLOBALS 0xcac4e6a3 #define CBMEM_ID_NONE 0x00000000 +#define CBMEM_ID_AGESA_RUNTIME 0x41474553 #ifndef __ASSEMBLER__ #include diff --git a/src/lib/cbmem_info.c b/src/lib/cbmem_info.c index 7031a70d54..65be67c17a 100644 --- a/src/lib/cbmem_info.c +++ b/src/lib/cbmem_info.c @@ -47,6 +47,7 @@ static struct cbmem_id_to_name { { CBMEM_ID_ROOT, "CBMEM ROOT " }, { CBMEM_ID_VBOOT_HANDOFF, "VBOOT " }, { CBMEM_ID_CAR_GLOBALS, "CAR GLOBALS" }, + { CBMEM_ID_AGESA_RUNTIME, "AGESA RSVD " }, }; void cbmem_print_entry(int n, u32 id, u64 base, u64 size) diff --git a/src/northbridge/amd/agesa/family15tn/fam15tn_callouts.c b/src/northbridge/amd/agesa/family15tn/fam15tn_callouts.c index 59c892fc14..38bf975f51 100644 --- a/src/northbridge/amd/agesa/family15tn/fam15tn_callouts.c +++ b/src/northbridge/amd/agesa/family15tn/fam15tn_callouts.c @@ -26,6 +26,29 @@ #include "cbfs.h" #include "dimmSpd.h" #include "fam15tn_callouts.h" +#include + +#define AGESA_RUNTIME_SIZE 4096 + +static AGESA_STATUS alloc_cbmem(AGESA_BUFFER_PARAMS *AllocParams) { + static unsigned int used = 0; + void *p = cbmem_find(CBMEM_ID_AGESA_RUNTIME); + + if ((AGESA_RUNTIME_SIZE - used) < AllocParams->BufferLength) { + return AGESA_BOUNDS_CHK; + } + + /* first time allocation */ + if (!p) { + p = cbmem_add(CBMEM_ID_AGESA_RUNTIME, AGESA_RUNTIME_SIZE); + if (!p) + return AGESA_BOUNDS_CHK; + } + + AllocParams->BufferPointer = p + used; + used += AllocParams->BufferLength; + return AGESA_SUCCESS; +} AGESA_STATUS fam15tn_AllocateBuffer (UINT32 Func, UINT32 Data, VOID *ConfigPtr) { @@ -48,6 +71,10 @@ AGESA_STATUS fam15tn_AllocateBuffer (UINT32 Func, UINT32 Data, VOID *ConfigPtr) AllocParams = ((AGESA_BUFFER_PARAMS *) ConfigPtr); AllocParams->BufferPointer = NULL; + /* if the allocation is for runtime use simple CBMEM data */ + if (Data == HEAP_CALLOUT_RUNTIME) + return alloc_cbmem(AllocParams); + AvailableHeapSize = BIOS_HEAP_SIZE - sizeof (BIOS_HEAP_MANAGER); BiosHeapBaseAddr = (UINT8 *) GetHeapBase(&(AllocParams->StdHeader)); BiosHeapBasePtr = (BIOS_HEAP_MANAGER *) BiosHeapBaseAddr; -- cgit v1.2.3