AGESA: Reduce typecasting in heapmanager calls
Change-Id: Ifc065dca00ab3dfc65a314aaaf04dd2a7afcad0e Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: https://review.coreboot.org/19040 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth <martinroth@google.com>
This commit is contained in:
parent
bceccec0f7
commit
45ff9cbaa9
|
@ -102,10 +102,11 @@ typedef struct _BIOS_BUFFER_NODE {
|
||||||
UINT32 NextNodeOffset;
|
UINT32 NextNodeOffset;
|
||||||
} BIOS_BUFFER_NODE;
|
} BIOS_BUFFER_NODE;
|
||||||
|
|
||||||
static AGESA_STATUS agesa_AllocateBuffer(UINT32 Func, UINT32 Data, VOID *ConfigPtr)
|
static AGESA_STATUS agesa_AllocateBuffer(BIOS_HEAP_MANAGER *BiosHeapBasePtr,
|
||||||
|
AGESA_BUFFER_PARAMS *AllocParams)
|
||||||
{
|
{
|
||||||
UINT32 AvailableHeapSize;
|
UINT32 AvailableHeapSize;
|
||||||
UINT8 *BiosHeapBaseAddr;
|
UINT8 *BiosHeapBaseAddr = (void *)BiosHeapBasePtr;
|
||||||
UINT32 CurrNodeOffset;
|
UINT32 CurrNodeOffset;
|
||||||
UINT32 PrevNodeOffset;
|
UINT32 PrevNodeOffset;
|
||||||
UINT32 FreedNodeOffset;
|
UINT32 FreedNodeOffset;
|
||||||
|
@ -117,14 +118,9 @@ static AGESA_STATUS agesa_AllocateBuffer(UINT32 Func, UINT32 Data, VOID *ConfigP
|
||||||
BIOS_BUFFER_NODE *BestFitNodePtr;
|
BIOS_BUFFER_NODE *BestFitNodePtr;
|
||||||
BIOS_BUFFER_NODE *BestFitPrevNodePtr;
|
BIOS_BUFFER_NODE *BestFitPrevNodePtr;
|
||||||
BIOS_BUFFER_NODE *NextFreePtr;
|
BIOS_BUFFER_NODE *NextFreePtr;
|
||||||
BIOS_HEAP_MANAGER *BiosHeapBasePtr;
|
|
||||||
AGESA_BUFFER_PARAMS *AllocParams;
|
|
||||||
|
|
||||||
AllocParams = ((AGESA_BUFFER_PARAMS *) ConfigPtr);
|
|
||||||
AllocParams->BufferPointer = NULL;
|
AllocParams->BufferPointer = NULL;
|
||||||
AvailableHeapSize = BIOS_HEAP_SIZE - sizeof(BIOS_HEAP_MANAGER);
|
AvailableHeapSize = BIOS_HEAP_SIZE - sizeof(BIOS_HEAP_MANAGER);
|
||||||
BiosHeapBaseAddr = GetHeapBase();
|
|
||||||
BiosHeapBasePtr = (BIOS_HEAP_MANAGER *) BiosHeapBaseAddr;
|
|
||||||
|
|
||||||
if (BiosHeapBasePtr->StartOfAllocatedNodes == 0) {
|
if (BiosHeapBasePtr->StartOfAllocatedNodes == 0) {
|
||||||
/* First allocation */
|
/* First allocation */
|
||||||
|
@ -230,10 +226,10 @@ static AGESA_STATUS agesa_AllocateBuffer(UINT32 Func, UINT32 Data, VOID *ConfigP
|
||||||
return AGESA_SUCCESS;
|
return AGESA_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static AGESA_STATUS agesa_DeallocateBuffer(UINT32 Func, UINT32 Data, VOID *ConfigPtr)
|
static AGESA_STATUS agesa_DeallocateBuffer(BIOS_HEAP_MANAGER *BiosHeapBasePtr,
|
||||||
|
AGESA_BUFFER_PARAMS *AllocParams)
|
||||||
{
|
{
|
||||||
|
UINT8 *BiosHeapBaseAddr = (void *)BiosHeapBasePtr;
|
||||||
UINT8 *BiosHeapBaseAddr;
|
|
||||||
UINT32 AllocNodeOffset;
|
UINT32 AllocNodeOffset;
|
||||||
UINT32 PrevNodeOffset;
|
UINT32 PrevNodeOffset;
|
||||||
UINT32 NextNodeOffset;
|
UINT32 NextNodeOffset;
|
||||||
|
@ -243,13 +239,6 @@ static AGESA_STATUS agesa_DeallocateBuffer(UINT32 Func, UINT32 Data, VOID *Confi
|
||||||
BIOS_BUFFER_NODE *PrevNodePtr;
|
BIOS_BUFFER_NODE *PrevNodePtr;
|
||||||
BIOS_BUFFER_NODE *FreedNodePtr;
|
BIOS_BUFFER_NODE *FreedNodePtr;
|
||||||
BIOS_BUFFER_NODE *NextNodePtr;
|
BIOS_BUFFER_NODE *NextNodePtr;
|
||||||
BIOS_HEAP_MANAGER *BiosHeapBasePtr;
|
|
||||||
AGESA_BUFFER_PARAMS *AllocParams;
|
|
||||||
|
|
||||||
AllocParams = (AGESA_BUFFER_PARAMS *) ConfigPtr;
|
|
||||||
|
|
||||||
BiosHeapBaseAddr = GetHeapBase();
|
|
||||||
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.
|
||||||
* Return AGESA_BOUNDS_CHK if the BufferHandle is not found.
|
* Return AGESA_BOUNDS_CHK if the BufferHandle is not found.
|
||||||
|
@ -349,18 +338,12 @@ static AGESA_STATUS agesa_DeallocateBuffer(UINT32 Func, UINT32 Data, VOID *Confi
|
||||||
return AGESA_SUCCESS;
|
return AGESA_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static AGESA_STATUS agesa_LocateBuffer(UINT32 Func, UINT32 Data, VOID *ConfigPtr)
|
static AGESA_STATUS agesa_LocateBuffer(BIOS_HEAP_MANAGER *BiosHeapBasePtr,
|
||||||
|
AGESA_BUFFER_PARAMS *AllocParams)
|
||||||
{
|
{
|
||||||
UINT32 AllocNodeOffset;
|
UINT32 AllocNodeOffset;
|
||||||
UINT8 *BiosHeapBaseAddr;
|
UINT8 *BiosHeapBaseAddr = (void *)BiosHeapBasePtr;
|
||||||
BIOS_BUFFER_NODE *AllocNodePtr;
|
BIOS_BUFFER_NODE *AllocNodePtr;
|
||||||
BIOS_HEAP_MANAGER *BiosHeapBasePtr;
|
|
||||||
AGESA_BUFFER_PARAMS *AllocParams;
|
|
||||||
|
|
||||||
AllocParams = (AGESA_BUFFER_PARAMS *) ConfigPtr;
|
|
||||||
|
|
||||||
BiosHeapBaseAddr = GetHeapBase();
|
|
||||||
BiosHeapBasePtr = (BIOS_HEAP_MANAGER *) BiosHeapBaseAddr;
|
|
||||||
|
|
||||||
AllocNodeOffset = BiosHeapBasePtr->StartOfAllocatedNodes;
|
AllocNodeOffset = BiosHeapBasePtr->StartOfAllocatedNodes;
|
||||||
AllocNodePtr = (BIOS_BUFFER_NODE *) (BiosHeapBaseAddr + AllocNodeOffset);
|
AllocNodePtr = (BIOS_BUFFER_NODE *) (BiosHeapBaseAddr + AllocNodeOffset);
|
||||||
|
@ -385,19 +368,20 @@ static AGESA_STATUS agesa_LocateBuffer(UINT32 Func, UINT32 Data, VOID *ConfigPtr
|
||||||
|
|
||||||
AGESA_STATUS HeapManagerCallout(UINT32 Func, UINTN Data, VOID *ConfigPtr)
|
AGESA_STATUS HeapManagerCallout(UINT32 Func, UINTN Data, VOID *ConfigPtr)
|
||||||
{
|
{
|
||||||
#if defined(HEAP_CALLOUT_RUNTIME) && ENV_RAMSTAGE
|
|
||||||
AGESA_BUFFER_PARAMS *AllocParams = ConfigPtr;
|
AGESA_BUFFER_PARAMS *AllocParams = ConfigPtr;
|
||||||
|
|
||||||
|
#if defined(HEAP_CALLOUT_RUNTIME) && ENV_RAMSTAGE
|
||||||
if (Func == AGESA_ALLOCATE_BUFFER && Data == HEAP_CALLOUT_RUNTIME)
|
if (Func == AGESA_ALLOCATE_BUFFER && Data == HEAP_CALLOUT_RUNTIME)
|
||||||
return alloc_cbmem(AllocParams);
|
return alloc_cbmem(AllocParams);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Must not call GetHeapBase() in AGESA_UNSUPPORTED path. */
|
||||||
if (Func == AGESA_LOCATE_BUFFER)
|
if (Func == AGESA_LOCATE_BUFFER)
|
||||||
return agesa_LocateBuffer(Func, Data, ConfigPtr);
|
return agesa_LocateBuffer(GetHeapBase(), AllocParams);
|
||||||
else if (Func == AGESA_ALLOCATE_BUFFER)
|
else if (Func == AGESA_ALLOCATE_BUFFER)
|
||||||
return agesa_AllocateBuffer(Func, Data, ConfigPtr);
|
return agesa_AllocateBuffer(GetHeapBase(), AllocParams);
|
||||||
else if (Func == AGESA_DEALLOCATE_BUFFER)
|
else if (Func == AGESA_DEALLOCATE_BUFFER)
|
||||||
return agesa_DeallocateBuffer(Func, Data, ConfigPtr);
|
return agesa_DeallocateBuffer(GetHeapBase(), AllocParams);
|
||||||
else
|
|
||||||
return AGESA_UNSUPPORTED;
|
return AGESA_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue