summaryrefslogtreecommitdiff
path: root/src/soc/amd
diff options
context:
space:
mode:
Diffstat (limited to 'src/soc/amd')
-rw-r--r--src/soc/amd/common/block/pi/agesawrapper.c21
-rw-r--r--src/soc/amd/common/block/pi/heapmanager.c137
2 files changed, 86 insertions, 72 deletions
diff --git a/src/soc/amd/common/block/pi/agesawrapper.c b/src/soc/amd/common/block/pi/agesawrapper.c
index 7fb5485fe5..f2327f1679 100644
--- a/src/soc/amd/common/block/pi/agesawrapper.c
+++ b/src/soc/amd/common/block/pi/agesawrapper.c
@@ -244,10 +244,11 @@ AGESA_STATUS agesawrapper_amdinitenv(void)
if (status != AGESA_SUCCESS)
agesawrapper_readeventlog(EnvParam->StdHeader.HeapStatus);
- /* Initialize Subordinate Bus Number and Secondary Bus Number
+ /*
+ * Initialize Subordinate Bus Number and Secondary Bus Number
* In platform BIOS this address is allocated by PCI enumeration code
- Modify D1F0x18
- */
+ * Modify D1F0x18
+ */
return status;
}
@@ -329,7 +330,10 @@ AGESA_STATUS agesawrapper_amdinitlate(void)
AmdParamStruct.StdHeader.Func = 0;
AmdParamStruct.StdHeader.ImageBasePtr = 0;
- /* NOTE: if not call amdcreatestruct, the initializer(AmdInitLateInitializer) would not be called */
+ /*
+ * NOTE: if not call amdcreatestruct, the initializer
+ * (AmdInitLateInitializer) would not be called.
+ */
AmdCreateStruct(&AmdParamStruct);
AmdLateParams = (AMD_LATE_PARAMS *)AmdParamStruct.NewStructPtr;
@@ -354,8 +358,9 @@ AGESA_STATUS agesawrapper_amdinitlate(void)
printk(BIOS_DEBUG, "DmiTable:%x, AcpiPstatein: %x, AcpiSrat:%x,"
"AcpiSlit:%x, Mce:%x, Cmc:%x,"
"Alib:%x, AcpiIvrs:%x in %s\n",
- (unsigned int)DmiTable, (unsigned int)AcpiPstate, (unsigned int)AcpiSrat,
- (unsigned int)AcpiSlit, (unsigned int)AcpiWheaMce, (unsigned int)AcpiWheaCmc,
+ (unsigned int)DmiTable, (unsigned int)AcpiPstate,
+ (unsigned int)AcpiSrat, (unsigned int)AcpiSlit,
+ (unsigned int)AcpiWheaMce, (unsigned int)AcpiWheaCmc,
(unsigned int)AcpiAlib, (unsigned int)AcpiIvrs, __func__);
/* AmdReleaseStruct (&AmdParamStruct); */
@@ -420,8 +425,8 @@ static int agesa_locate_stage_file(const char *name, struct region_device *rdev)
const void *agesawrapper_locate_module (const CHAR8 name[8])
{
- const void* agesa;
- const AMD_IMAGE_HEADER* image;
+ const void *agesa;
+ const AMD_IMAGE_HEADER *image;
struct region_device rdev;
size_t file_size;
const char *fname = CONFIG_AGESA_CBFS_NAME;
diff --git a/src/soc/amd/common/block/pi/heapmanager.c b/src/soc/amd/common/block/pi/heapmanager.c
index bda521f07f..cea3171aa5 100644
--- a/src/soc/amd/common/block/pi/heapmanager.c
+++ b/src/soc/amd/common/block/pi/heapmanager.c
@@ -113,17 +113,31 @@ AGESA_STATUS agesa_AllocateBuffer (UINT32 Func, UINTN Data, VOID *ConfigPtr)
while (FreedNodeOffset != 0) { /* todo: simplify this */
FreedNodePtr = (BIOS_BUFFER_NODE *)(BiosHeapBaseAddr
+ FreedNodeOffset);
- if (FreedNodePtr->BufferSize >= (AllocParams->BufferLength + sizeof(BIOS_BUFFER_NODE))) {
+ if (FreedNodePtr->BufferSize >=
+ (AllocParams->BufferLength +
+ sizeof(BIOS_BUFFER_NODE))) {
if (BestFitNodeOffset == 0) {
- /* First node that fits the requested buffer size */
+ /*
+ * First node that fits the requested
+ * buffer size
+ */
BestFitNodeOffset = FreedNodeOffset;
BestFitPrevNodeOffset = PrevNodeOffset;
} else {
- /* Find out whether current node is a better fit than the previous nodes */
- BestFitNodePtr = (BIOS_BUFFER_NODE *)(BiosHeapBaseAddr + BestFitNodeOffset);
- if (BestFitNodePtr->BufferSize > FreedNodePtr->BufferSize) {
- BestFitNodeOffset = FreedNodeOffset;
- BestFitPrevNodeOffset = PrevNodeOffset;
+ /*
+ * Find out whether current node is a
+ * betterfit than the previous nodes
+ */
+ BestFitNodePtr = (BIOS_BUFFER_NODE *)
+ (BiosHeapBaseAddr +
+ BestFitNodeOffset);
+ if (BestFitNodePtr->BufferSize >
+ FreedNodePtr->BufferSize) {
+
+ BestFitNodeOffset =
+ FreedNodeOffset;
+ BestFitPrevNodeOffset =
+ PrevNodeOffset;
}
}
}
@@ -132,65 +146,60 @@ AGESA_STATUS agesa_AllocateBuffer (UINT32 Func, UINTN Data, VOID *ConfigPtr)
} /* end of while loop */
if (BestFitNodeOffset == 0) {
- /* If we could not find a node that fits the requested
+ /*
+ * If we could not find a node that fits the requested
* buffer size, return AGESA_BOUNDS_CHK.
*/
return AGESA_BOUNDS_CHK;
- } else {
- BestFitNodePtr = (BIOS_BUFFER_NODE *)(BiosHeapBaseAddr
- + BestFitNodeOffset);
- BestFitPrevNodePtr = (BIOS_BUFFER_NODE *)
- (BiosHeapBaseAddr
- + BestFitPrevNodeOffset);
-
- /* If BestFitNode is larger than the requested buffer,
- * fragment the node further
- */
- if (BestFitNodePtr->BufferSize >
- (AllocParams->BufferLength
- + sizeof(BIOS_BUFFER_NODE))) {
- NextFreeOffset = BestFitNodeOffset
- + AllocParams->BufferLength
- + sizeof(BIOS_BUFFER_NODE);
+ }
- NextFreePtr = (BIOS_BUFFER_NODE *)
- (BiosHeapBaseAddr
- + NextFreeOffset);
- NextFreePtr->BufferSize =
- BestFitNodePtr->BufferSize
- - (AllocParams->BufferLength
- + sizeof(BIOS_BUFFER_NODE));
- NextFreePtr->NextNodeOffset =
- BestFitNodePtr->NextNodeOffset;
- } else {
- /* Otherwise, next free node is
- * NextNodeOffset of BestFitNode
- */
- NextFreeOffset = BestFitNodePtr->NextNodeOffset;
- }
+ BestFitNodePtr = (BIOS_BUFFER_NODE *)(BiosHeapBaseAddr
+ + BestFitNodeOffset);
+ BestFitPrevNodePtr = (BIOS_BUFFER_NODE *) (BiosHeapBaseAddr +
+ BestFitPrevNodeOffset);
- /* If BestFitNode is the first buffer in the list, then
- * update StartOfFreedNodes to reflect new free node.
+ /*
+ * If BestFitNode is larger than the requested buffer,
+ * fragment the node further
+ */
+ if (BestFitNodePtr->BufferSize >
+ (AllocParams->BufferLength + sizeof(BIOS_BUFFER_NODE))) {
+ NextFreeOffset = BestFitNodeOffset +
+ AllocParams->BufferLength +
+ sizeof(BIOS_BUFFER_NODE);
+ NextFreePtr = (BIOS_BUFFER_NODE *) (BiosHeapBaseAddr +
+ NextFreeOffset);
+ NextFreePtr->BufferSize = BestFitNodePtr->BufferSize -
+ (AllocParams->BufferLength +
+ sizeof(BIOS_BUFFER_NODE));
+ NextFreePtr->NextNodeOffset =
+ BestFitNodePtr->NextNodeOffset;
+ } else {
+ /*
+ * Otherwise, next free node is
+ * NextNodeOffset of BestFitNode
*/
- if (BestFitNodeOffset ==
- BiosHeapBasePtr->StartOfFreedNodes)
- BiosHeapBasePtr->StartOfFreedNodes =
- NextFreeOffset;
- else
- BestFitPrevNodePtr->NextNodeOffset =
- NextFreeOffset;
-
- /* Add BestFitNode to the list of Allocated nodes */
- CurrNodePtr->NextNodeOffset = BestFitNodeOffset;
- BestFitNodePtr->BufferSize = AllocParams->BufferLength;
- BestFitNodePtr->BufferHandle =
- AllocParams->BufferHandle;
- BestFitNodePtr->NextNodeOffset = 0;
-
- /* Remove BestFitNode from list of Freed nodes */
- AllocParams->BufferPointer = (UINT8 *)BestFitNodePtr
- + sizeof(BIOS_BUFFER_NODE);
+ NextFreeOffset = BestFitNodePtr->NextNodeOffset;
}
+
+ /*
+ * If BestFitNode is the first buffer in the list, then
+ * update StartOfFreedNodes to reflect new free node.
+ */
+ if (BestFitNodeOffset == BiosHeapBasePtr->StartOfFreedNodes)
+ BiosHeapBasePtr->StartOfFreedNodes = NextFreeOffset;
+ else
+ BestFitPrevNodePtr->NextNodeOffset = NextFreeOffset;
+
+ /* Add BestFitNode to the list of Allocated nodes */
+ CurrNodePtr->NextNodeOffset = BestFitNodeOffset;
+ BestFitNodePtr->BufferSize = AllocParams->BufferLength;
+ BestFitNodePtr->BufferHandle = AllocParams->BufferHandle;
+ BestFitNodePtr->NextNodeOffset = 0;
+
+ /* Remove BestFitNode from list of Freed nodes */
+ AllocParams->BufferPointer = (UINT8 *)BestFitNodePtr +
+ sizeof(BIOS_BUFFER_NODE);
}
return AGESA_SUCCESS;
@@ -306,7 +315,8 @@ AGESA_STATUS agesa_DeallocateBuffer (UINT32 Func, UINTN Data, VOID *ConfigPtr)
* FreedNodePtr->NextNodeOffset; */
AllocNodePtr->NextNodeOffset = NextNodeOffset;
}
- /* If deallocated node is adjacent to the previous node,
+ /*
+ * If deallocated node is adjacent to the previous node,
* concatenate both nodes.
*/
PrevNodePtr = (BIOS_BUFFER_NODE *)(BiosHeapBaseAddr
@@ -347,11 +357,10 @@ AGESA_STATUS agesa_LocateBuffer (UINT32 Func, UINTN Data, VOID *ConfigPtr)
AllocParams->BufferPointer = NULL;
AllocParams->BufferLength = 0;
return AGESA_BOUNDS_CHK;
- } else {
- AllocNodeOffset = AllocNodePtr->NextNodeOffset;
- AllocNodePtr = (BIOS_BUFFER_NODE *)(BiosHeapBaseAddr
- + AllocNodeOffset);
}
+ AllocNodeOffset = AllocNodePtr->NextNodeOffset;
+ AllocNodePtr = (BIOS_BUFFER_NODE *)(BiosHeapBaseAddr +
+ AllocNodeOffset);
}
AllocParams->BufferPointer = (UINT8 *)((UINT8 *)AllocNodePtr