diff options
author | Rudolf Marek <r.marek@assembler.cz> | 2013-05-27 16:09:44 +0200 |
---|---|---|
committer | Ronald G. Minnich <rminnich@gmail.com> | 2013-06-24 00:53:52 +0200 |
commit | 5ce0506618c653c663251f94447e23f8c3f39fb7 (patch) | |
tree | 41664b6b5f0613eefa736dfa943d3d3e3b015e21 /src/northbridge/amd/agesa | |
parent | 88ebbeb7e2a914330c869147bacb190b4270532f (diff) |
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 <r.marek@assembler.cz>
Reviewed-on: http://review.coreboot.org/3315
Tested-by: build bot (Jenkins)
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
Diffstat (limited to 'src/northbridge/amd/agesa')
-rw-r--r-- | src/northbridge/amd/agesa/family15tn/fam15tn_callouts.c | 27 |
1 files changed, 27 insertions, 0 deletions
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 <cbmem.h> + +#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; |