AMD Olive Hill: Eliminate unnecessary memory copy

Eliminate an unnecessary copy of the DDI descriptor list and
the PCIe port descriptor list.  As descriptor tables, these
tables do not need dynamic updating and should be used from
ROM without runtime copying.

There will be a corresponding patch for AGESA that adds CONST
modifiers to function parameters that are pass-by-reference
"IN" values (read-only pointers).

Change-Id: I7ab78e58041e9247db22d0f97a6f76d45f338db0
Signed-off-by: Bruce Griffith <Bruce.Griffith@se-eng.com>
Reviewed-by: Marc Jones <marc.jones@se-eng.com>
Tested-by: Bruce Griffith <bruce.griffith@se-eng.com>
Reviewed-by: Dave Frodin <dave.frodin@se-eng.com>
Reviewed-on: http://review.coreboot.org/3818
Tested-by: build bot (Jenkins)
Reviewed-by: Martin Roth <martin.roth@se-eng.com>
This commit is contained in:
Bruce Griffith 2013-07-10 22:24:47 -06:00 committed by Stefan Reinauer
parent 80cf7d5956
commit 5912125dff
1 changed files with 14 additions and 44 deletions

View File

@ -26,7 +26,7 @@
#define FILECODE PROC_GNB_PCIE_FAMILY_0X15_F15PCIECOMPLEXCONFIG_FILECODE #define FILECODE PROC_GNB_PCIE_FAMILY_0X15_F15PCIECOMPLEXCONFIG_FILECODE
PCIe_PORT_DESCRIPTOR PortList [] = { static const PCIe_PORT_DESCRIPTOR PortList [] = {
{ {
0, //Descriptor flags !!!IMPORTANT!!! Terminate last element of array 0, //Descriptor flags !!!IMPORTANT!!! Terminate last element of array
PCIE_ENGINE_DATA_INITIALIZER (PciePortEngine, 3, 3), PCIE_ENGINE_DATA_INITIALIZER (PciePortEngine, 3, 3),
@ -78,7 +78,7 @@ PCIe_PORT_DESCRIPTOR PortList [] = {
} }
}; };
PCIe_DDI_DESCRIPTOR DdiList [] = { static const PCIe_DDI_DESCRIPTOR DdiList [] = {
/* DP0 to HDMI0/DP */ /* DP0 to HDMI0/DP */
{ {
0, 0,
@ -99,11 +99,11 @@ PCIe_DDI_DESCRIPTOR DdiList [] = {
}, },
}; };
PCIe_COMPLEX_DESCRIPTOR Kabini = { static const PCIe_COMPLEX_DESCRIPTOR PcieComplex = {
DESCRIPTOR_TERMINATE_LIST, .Flags = DESCRIPTOR_TERMINATE_LIST,
0, .SocketId = 0,
PortList, .PciePortList = PortList,
DdiList .DdiLinkList = DdiList
}; };
/*---------------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------------*/
@ -127,10 +127,8 @@ OemCustomizeInitEarly (
IN OUT AMD_EARLY_PARAMS *InitEarly IN OUT AMD_EARLY_PARAMS *InitEarly
) )
{ {
AGESA_STATUS Status; AGESA_STATUS Status;
VOID *KabiniPcieComplexListPtr; PCIe_COMPLEX_DESCRIPTOR *PcieComplexListPtr;
VOID *KabiniPciePortPtr;
VOID *KabiniPcieDdiPtr;
ALLOCATE_HEAP_PARAMS AllocHeapParams; ALLOCATE_HEAP_PARAMS AllocHeapParams;
@ -139,46 +137,18 @@ OemCustomizeInitEarly (
/* */ /* */
/* Allocate buffer for PCIe_COMPLEX_DESCRIPTOR , PCIe_PORT_DESCRIPTOR and PCIe_DDI_DESCRIPTOR */ /* Allocate buffer for PCIe_COMPLEX_DESCRIPTOR , PCIe_PORT_DESCRIPTOR and PCIe_DDI_DESCRIPTOR */
/* */ /* */
AllocHeapParams.RequestedBufferSize = sizeof(Kabini) + sizeof(PortList) + sizeof(DdiList); AllocHeapParams.RequestedBufferSize = sizeof(PcieComplex);
AllocHeapParams.BufferHandle = AMD_MEM_MISC_HANDLES_START; AllocHeapParams.BufferHandle = AMD_MEM_MISC_HANDLES_START;
AllocHeapParams.Persist = HEAP_LOCAL_CACHE; AllocHeapParams.Persist = HEAP_LOCAL_CACHE;
Status = HeapAllocateBuffer (&AllocHeapParams, &InitEarly->StdHeader); Status = HeapAllocateBuffer (&AllocHeapParams, &InitEarly->StdHeader);
if ( Status!= AGESA_SUCCESS) { if ( Status!= AGESA_SUCCESS) {
/* Could not allocate buffer for PCIe_COMPLEX_DESCRIPTOR , PCIe_PORT_DESCRIPTOR and PCIe_DDI_DESCRIPTOR */ /* Could not allocate buffer for PCIe_COMPLEX_DESCRIPTOR */
ASSERT(FALSE); ASSERT(FALSE);
return; return;
} }
KabiniPcieComplexListPtr = (PCIe_COMPLEX_DESCRIPTOR *) AllocHeapParams.BufferPtr; PcieComplexListPtr = (PCIe_COMPLEX_DESCRIPTOR *) AllocHeapParams.BufferPtr;
LibAmdMemCopy (PcieComplexListPtr, &PcieComplex, sizeof(PcieComplex), &InitEarly->StdHeader);
AllocHeapParams.BufferPtr += sizeof(Kabini); InitEarly->GnbConfig.PcieComplexList = PcieComplexListPtr;
KabiniPciePortPtr = (PCIe_PORT_DESCRIPTOR *)AllocHeapParams.BufferPtr;
AllocHeapParams.BufferPtr += sizeof(PortList);
KabiniPcieDdiPtr = (PCIe_DDI_DESCRIPTOR *) AllocHeapParams.BufferPtr;
LibAmdMemFill (KabiniPcieComplexListPtr,
0,
sizeof (Kabini),
&InitEarly->StdHeader);
LibAmdMemFill (KabiniPciePortPtr,
0,
sizeof (PortList),
&InitEarly->StdHeader);
LibAmdMemFill (KabiniPcieDdiPtr,
0,
sizeof (DdiList),
&InitEarly->StdHeader);
LibAmdMemCopy (KabiniPcieComplexListPtr, &Kabini, sizeof (Kabini), &InitEarly->StdHeader);
LibAmdMemCopy (KabiniPciePortPtr, &PortList[0], sizeof (PortList), &InitEarly->StdHeader);
LibAmdMemCopy (KabiniPcieDdiPtr, &DdiList[0], sizeof (DdiList), &InitEarly->StdHeader);
((PCIe_COMPLEX_DESCRIPTOR*)KabiniPcieComplexListPtr)->PciePortList = (PCIe_PORT_DESCRIPTOR*)KabiniPciePortPtr;
((PCIe_COMPLEX_DESCRIPTOR*)KabiniPcieComplexListPtr)->DdiLinkList = (PCIe_DDI_DESCRIPTOR*)KabiniPcieDdiPtr;
InitEarly->GnbConfig.PcieComplexList = KabiniPcieComplexListPtr;
} }