AMD Trinity boards: Use `sizeof(var)` to get its size
Change `sizeof(type) * n`, where n is the number of array elements, to `sizeof(variable)` to directly get the size of the variable (struct, array). Determining the size by counting array elements is error prone and unnecessary. Not sure why the copy is needed instead of direct reference. Maybe it has something to do with CAR? These changes are based on Rudolf’s original patch »ASUS F2A85-M: Correct and clean up PCIe config« [1], where it was just done for the ASUS board. [1] http://review.coreboot.org/#/c/3194/ Change-Id: I4aa4c6cde5a27b7f335a71afc21d1603f2ae814b Signed-off-by: Rudolf Marek <r.marek@assembler.cz> Signed-off-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-on: http://review.coreboot.org/3247 Tested-by: build bot (Jenkins) Reviewed-by: David Hubbard <david.c.hubbard+coreboot@gmail.com> Reviewed-by: Bruce Griffith <Bruce.Griffith@se-eng.com>
This commit is contained in:
parent
1a71f4c21f
commit
d3ed411123
|
@ -183,9 +183,7 @@ 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 (PCIe_COMPLEX_DESCRIPTOR) +
|
AllocHeapParams.RequestedBufferSize = sizeof(Trinity) + sizeof(PortList) + sizeof(DdiList);
|
||||||
sizeof (PCIe_PORT_DESCRIPTOR) * 7 +
|
|
||||||
sizeof (PCIe_DDI_DESCRIPTOR) * 3;
|
|
||||||
|
|
||||||
AllocHeapParams.BufferHandle = AMD_MEM_MISC_HANDLES_START;
|
AllocHeapParams.BufferHandle = AMD_MEM_MISC_HANDLES_START;
|
||||||
AllocHeapParams.Persist = HEAP_LOCAL_CACHE;
|
AllocHeapParams.Persist = HEAP_LOCAL_CACHE;
|
||||||
|
@ -198,30 +196,30 @@ OemCustomizeInitEarly (
|
||||||
|
|
||||||
TrinityPcieComplexListPtr = (PCIe_COMPLEX_DESCRIPTOR *) AllocHeapParams.BufferPtr;
|
TrinityPcieComplexListPtr = (PCIe_COMPLEX_DESCRIPTOR *) AllocHeapParams.BufferPtr;
|
||||||
|
|
||||||
AllocHeapParams.BufferPtr += sizeof (PCIe_COMPLEX_DESCRIPTOR);
|
AllocHeapParams.BufferPtr += sizeof(Trinity);
|
||||||
TrinityPciePortPtr = (PCIe_PORT_DESCRIPTOR *)AllocHeapParams.BufferPtr;
|
TrinityPciePortPtr = (PCIe_PORT_DESCRIPTOR *)AllocHeapParams.BufferPtr;
|
||||||
|
|
||||||
AllocHeapParams.BufferPtr += sizeof (PCIe_PORT_DESCRIPTOR) * 7;
|
AllocHeapParams.BufferPtr += sizeof(PortList);
|
||||||
TrinityPcieDdiPtr = (PCIe_DDI_DESCRIPTOR *) AllocHeapParams.BufferPtr;
|
TrinityPcieDdiPtr = (PCIe_DDI_DESCRIPTOR *) AllocHeapParams.BufferPtr;
|
||||||
|
|
||||||
LibAmdMemFill (TrinityPcieComplexListPtr,
|
LibAmdMemFill (TrinityPcieComplexListPtr,
|
||||||
0,
|
0,
|
||||||
sizeof (PCIe_COMPLEX_DESCRIPTOR),
|
sizeof(Trinity),
|
||||||
&InitEarly->StdHeader);
|
&InitEarly->StdHeader);
|
||||||
|
|
||||||
LibAmdMemFill (TrinityPciePortPtr,
|
LibAmdMemFill (TrinityPciePortPtr,
|
||||||
0,
|
0,
|
||||||
sizeof (PCIe_PORT_DESCRIPTOR) * 7,
|
sizeof(PortList),
|
||||||
&InitEarly->StdHeader);
|
&InitEarly->StdHeader);
|
||||||
|
|
||||||
LibAmdMemFill (TrinityPcieDdiPtr,
|
LibAmdMemFill (TrinityPcieDdiPtr,
|
||||||
0,
|
0,
|
||||||
sizeof (PCIe_DDI_DESCRIPTOR) * 3,
|
sizeof(DdiList),
|
||||||
&InitEarly->StdHeader);
|
&InitEarly->StdHeader);
|
||||||
|
|
||||||
LibAmdMemCopy (TrinityPcieComplexListPtr, &Trinity, sizeof (PCIe_COMPLEX_DESCRIPTOR), &InitEarly->StdHeader);
|
LibAmdMemCopy (TrinityPcieComplexListPtr, &Trinity, sizeof(Trinity), &InitEarly->StdHeader);
|
||||||
LibAmdMemCopy (TrinityPciePortPtr, &PortList[0], sizeof (PCIe_PORT_DESCRIPTOR) * 7, &InitEarly->StdHeader);
|
LibAmdMemCopy (TrinityPciePortPtr, &PortList[0], sizeof(PortList), &InitEarly->StdHeader);
|
||||||
LibAmdMemCopy (TrinityPcieDdiPtr, &DdiList[0], sizeof (PCIe_DDI_DESCRIPTOR) * 3, &InitEarly->StdHeader);
|
LibAmdMemCopy (TrinityPcieDdiPtr, &DdiList[0], sizeof(DdiList), &InitEarly->StdHeader);
|
||||||
|
|
||||||
((PCIe_COMPLEX_DESCRIPTOR*)TrinityPcieComplexListPtr)->PciePortList = (PCIe_PORT_DESCRIPTOR*)TrinityPciePortPtr;
|
((PCIe_COMPLEX_DESCRIPTOR*)TrinityPcieComplexListPtr)->PciePortList = (PCIe_PORT_DESCRIPTOR*)TrinityPciePortPtr;
|
||||||
((PCIe_COMPLEX_DESCRIPTOR*)TrinityPcieComplexListPtr)->DdiLinkList = (PCIe_DDI_DESCRIPTOR*)TrinityPcieDdiPtr;
|
((PCIe_COMPLEX_DESCRIPTOR*)TrinityPcieComplexListPtr)->DdiLinkList = (PCIe_DDI_DESCRIPTOR*)TrinityPcieDdiPtr;
|
||||||
|
|
|
@ -182,9 +182,7 @@ 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 (PCIe_COMPLEX_DESCRIPTOR) +
|
AllocHeapParams.RequestedBufferSize = sizeof(Trinity) + sizeof(PortList) + sizeof(DdiList);
|
||||||
sizeof (PCIe_PORT_DESCRIPTOR) * 7 +
|
|
||||||
sizeof (PCIe_DDI_DESCRIPTOR) * 3;
|
|
||||||
|
|
||||||
AllocHeapParams.BufferHandle = AMD_MEM_MISC_HANDLES_START;
|
AllocHeapParams.BufferHandle = AMD_MEM_MISC_HANDLES_START;
|
||||||
AllocHeapParams.Persist = HEAP_LOCAL_CACHE;
|
AllocHeapParams.Persist = HEAP_LOCAL_CACHE;
|
||||||
|
@ -197,30 +195,30 @@ OemCustomizeInitEarly (
|
||||||
|
|
||||||
TrinityPcieComplexListPtr = (PCIe_COMPLEX_DESCRIPTOR *) AllocHeapParams.BufferPtr;
|
TrinityPcieComplexListPtr = (PCIe_COMPLEX_DESCRIPTOR *) AllocHeapParams.BufferPtr;
|
||||||
|
|
||||||
AllocHeapParams.BufferPtr += sizeof (PCIe_COMPLEX_DESCRIPTOR);
|
AllocHeapParams.BufferPtr += sizeof(Trinity);
|
||||||
TrinityPciePortPtr = (PCIe_PORT_DESCRIPTOR *)AllocHeapParams.BufferPtr;
|
TrinityPciePortPtr = (PCIe_PORT_DESCRIPTOR *)AllocHeapParams.BufferPtr;
|
||||||
|
|
||||||
AllocHeapParams.BufferPtr += sizeof (PCIe_PORT_DESCRIPTOR) * 7;
|
AllocHeapParams.BufferPtr += sizeof(PortList);
|
||||||
TrinityPcieDdiPtr = (PCIe_DDI_DESCRIPTOR *) AllocHeapParams.BufferPtr;
|
TrinityPcieDdiPtr = (PCIe_DDI_DESCRIPTOR *) AllocHeapParams.BufferPtr;
|
||||||
|
|
||||||
LibAmdMemFill (TrinityPcieComplexListPtr,
|
LibAmdMemFill (TrinityPcieComplexListPtr,
|
||||||
0,
|
0,
|
||||||
sizeof (PCIe_COMPLEX_DESCRIPTOR),
|
sizeof(Trinity),
|
||||||
&InitEarly->StdHeader);
|
&InitEarly->StdHeader);
|
||||||
|
|
||||||
LibAmdMemFill (TrinityPciePortPtr,
|
LibAmdMemFill (TrinityPciePortPtr,
|
||||||
0,
|
0,
|
||||||
sizeof (PCIe_PORT_DESCRIPTOR) * 7,
|
sizeof(PortList),
|
||||||
&InitEarly->StdHeader);
|
&InitEarly->StdHeader);
|
||||||
|
|
||||||
LibAmdMemFill (TrinityPcieDdiPtr,
|
LibAmdMemFill (TrinityPcieDdiPtr,
|
||||||
0,
|
0,
|
||||||
sizeof (PCIe_DDI_DESCRIPTOR) * 3,
|
sizeof(DdiList),
|
||||||
&InitEarly->StdHeader);
|
&InitEarly->StdHeader);
|
||||||
|
|
||||||
LibAmdMemCopy (TrinityPcieComplexListPtr, &Trinity, sizeof (PCIe_COMPLEX_DESCRIPTOR), &InitEarly->StdHeader);
|
LibAmdMemCopy (TrinityPcieComplexListPtr, &Trinity, sizeof(Trinity), &InitEarly->StdHeader);
|
||||||
LibAmdMemCopy (TrinityPciePortPtr, &PortList[0], sizeof (PCIe_PORT_DESCRIPTOR) * 7, &InitEarly->StdHeader);
|
LibAmdMemCopy (TrinityPciePortPtr, &PortList[0], sizeof(PortList), &InitEarly->StdHeader);
|
||||||
LibAmdMemCopy (TrinityPcieDdiPtr, &DdiList[0], sizeof (PCIe_DDI_DESCRIPTOR) * 3, &InitEarly->StdHeader);
|
LibAmdMemCopy (TrinityPcieDdiPtr, &DdiList[0], sizeof(DdiList), &InitEarly->StdHeader);
|
||||||
|
|
||||||
((PCIe_COMPLEX_DESCRIPTOR*)TrinityPcieComplexListPtr)->PciePortList = (PCIe_PORT_DESCRIPTOR*)TrinityPciePortPtr;
|
((PCIe_COMPLEX_DESCRIPTOR*)TrinityPcieComplexListPtr)->PciePortList = (PCIe_PORT_DESCRIPTOR*)TrinityPciePortPtr;
|
||||||
((PCIe_COMPLEX_DESCRIPTOR*)TrinityPcieComplexListPtr)->DdiLinkList = (PCIe_DDI_DESCRIPTOR*)TrinityPcieDdiPtr;
|
((PCIe_COMPLEX_DESCRIPTOR*)TrinityPcieComplexListPtr)->DdiLinkList = (PCIe_DDI_DESCRIPTOR*)TrinityPcieDdiPtr;
|
||||||
|
|
|
@ -204,9 +204,7 @@ 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 (PCIe_COMPLEX_DESCRIPTOR) +
|
AllocHeapParams.RequestedBufferSize = sizeof(Trinity) + sizeof(PortList) + sizeof(DdiList);
|
||||||
sizeof (PCIe_PORT_DESCRIPTOR) * 7 +
|
|
||||||
sizeof (PCIe_DDI_DESCRIPTOR) * 6;
|
|
||||||
|
|
||||||
AllocHeapParams.BufferHandle = AMD_MEM_MISC_HANDLES_START;
|
AllocHeapParams.BufferHandle = AMD_MEM_MISC_HANDLES_START;
|
||||||
AllocHeapParams.Persist = HEAP_LOCAL_CACHE;
|
AllocHeapParams.Persist = HEAP_LOCAL_CACHE;
|
||||||
|
@ -219,30 +217,30 @@ OemCustomizeInitEarly (
|
||||||
|
|
||||||
TrinityPcieComplexListPtr = (PCIe_COMPLEX_DESCRIPTOR *) AllocHeapParams.BufferPtr;
|
TrinityPcieComplexListPtr = (PCIe_COMPLEX_DESCRIPTOR *) AllocHeapParams.BufferPtr;
|
||||||
|
|
||||||
AllocHeapParams.BufferPtr += sizeof (PCIe_COMPLEX_DESCRIPTOR);
|
AllocHeapParams.BufferPtr += sizeof(Trinity);
|
||||||
TrinityPciePortPtr = (PCIe_PORT_DESCRIPTOR *)AllocHeapParams.BufferPtr;
|
TrinityPciePortPtr = (PCIe_PORT_DESCRIPTOR *)AllocHeapParams.BufferPtr;
|
||||||
|
|
||||||
AllocHeapParams.BufferPtr += sizeof (PCIe_PORT_DESCRIPTOR) * 7;
|
AllocHeapParams.BufferPtr += sizeof(PortList);
|
||||||
TrinityPcieDdiPtr = (PCIe_DDI_DESCRIPTOR *) AllocHeapParams.BufferPtr;
|
TrinityPcieDdiPtr = (PCIe_DDI_DESCRIPTOR *) AllocHeapParams.BufferPtr;
|
||||||
|
|
||||||
LibAmdMemFill (TrinityPcieComplexListPtr,
|
LibAmdMemFill (TrinityPcieComplexListPtr,
|
||||||
0,
|
0,
|
||||||
sizeof (PCIe_COMPLEX_DESCRIPTOR),
|
sizeof(Trinity),
|
||||||
&InitEarly->StdHeader);
|
&InitEarly->StdHeader);
|
||||||
|
|
||||||
LibAmdMemFill (TrinityPciePortPtr,
|
LibAmdMemFill (TrinityPciePortPtr,
|
||||||
0,
|
0,
|
||||||
sizeof (PCIe_PORT_DESCRIPTOR) * 7,
|
sizeof(PortList),
|
||||||
&InitEarly->StdHeader);
|
&InitEarly->StdHeader);
|
||||||
|
|
||||||
LibAmdMemFill (TrinityPcieDdiPtr,
|
LibAmdMemFill (TrinityPcieDdiPtr,
|
||||||
0,
|
0,
|
||||||
sizeof (PCIe_DDI_DESCRIPTOR) * 6,
|
sizeof(DdiList),
|
||||||
&InitEarly->StdHeader);
|
&InitEarly->StdHeader);
|
||||||
|
|
||||||
LibAmdMemCopy (TrinityPcieComplexListPtr, &Trinity, sizeof (PCIe_COMPLEX_DESCRIPTOR), &InitEarly->StdHeader);
|
LibAmdMemCopy (TrinityPcieComplexListPtr, &Trinity, sizeof(Trinity), &InitEarly->StdHeader);
|
||||||
LibAmdMemCopy (TrinityPciePortPtr, &PortList[0], sizeof (PCIe_PORT_DESCRIPTOR) * 7, &InitEarly->StdHeader);
|
LibAmdMemCopy (TrinityPciePortPtr, &PortList[0], sizeof(PortList), &InitEarly->StdHeader);
|
||||||
LibAmdMemCopy (TrinityPcieDdiPtr, &DdiList[0], sizeof (PCIe_DDI_DESCRIPTOR) * 6, &InitEarly->StdHeader);
|
LibAmdMemCopy (TrinityPcieDdiPtr, &DdiList[0], sizeof(DdiList), &InitEarly->StdHeader);
|
||||||
|
|
||||||
((PCIe_COMPLEX_DESCRIPTOR*)TrinityPcieComplexListPtr)->PciePortList = (PCIe_PORT_DESCRIPTOR*)TrinityPciePortPtr;
|
((PCIe_COMPLEX_DESCRIPTOR*)TrinityPcieComplexListPtr)->PciePortList = (PCIe_PORT_DESCRIPTOR*)TrinityPciePortPtr;
|
||||||
((PCIe_COMPLEX_DESCRIPTOR*)TrinityPcieComplexListPtr)->DdiLinkList = (PCIe_DDI_DESCRIPTOR*)TrinityPcieDdiPtr;
|
((PCIe_COMPLEX_DESCRIPTOR*)TrinityPcieComplexListPtr)->DdiLinkList = (PCIe_DDI_DESCRIPTOR*)TrinityPcieDdiPtr;
|
||||||
|
|
Loading…
Reference in New Issue