vendorcode/amd/pi/Lib/amdlib.c: remove StdHeader references

Nothing in the amdlib.c file actually uses the StdHeader structure, so
remove the asserts verifying that it's not null, and remove references
to it from calls.

For now, I've left it in the parameters for the functions for
compatibility, but we might want to remove these at some point as well.

Change-Id: Ib13e9209c8119fdcc3720470aaa9dcdbde6ac388
Signed-off-by: Martin Roth <martinroth@google.com>
Reviewed-on: https://review.coreboot.org/20451
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Marshall Dawson <marshalldawson3rd@gmail.com>
This commit is contained in:
Martin Roth 2017-07-01 12:25:31 -06:00
parent dab81a4e26
commit de0acb5583

View file

@ -605,9 +605,9 @@ LibAmdIoRMW (
UINT32 TempMask; UINT32 TempMask;
UINT32 Value; UINT32 Value;
LibAmdGetDataFromPtr (AccessWidth, Data, DataMask, &TempData, &TempMask); LibAmdGetDataFromPtr (AccessWidth, Data, DataMask, &TempData, &TempMask);
LibAmdIoRead (AccessWidth, IoAddress, &Value, StdHeader); LibAmdIoRead (AccessWidth, IoAddress, &Value, NULL);
Value = (Value & (~TempMask)) | TempData; Value = (Value & (~TempMask)) | TempData;
LibAmdIoWrite (AccessWidth, IoAddress, &Value, StdHeader); LibAmdIoWrite (AccessWidth, IoAddress, &Value, NULL);
} }
/*---------------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------------*/
@ -639,7 +639,7 @@ LibAmdIoPoll (
UINT32 Value; UINT32 Value;
LibAmdGetDataFromPtr (AccessWidth, Data, DataMask, &TempData, &TempMask); LibAmdGetDataFromPtr (AccessWidth, Data, DataMask, &TempData, &TempMask);
do { do {
LibAmdIoRead (AccessWidth, IoAddress, &Value, StdHeader); LibAmdIoRead (AccessWidth, IoAddress, &Value, NULL);
} while (TempData != (Value & TempMask)); } while (TempData != (Value & TempMask));
} }
@ -744,9 +744,9 @@ LibAmdMemRMW (
UINT32 TempMask; UINT32 TempMask;
UINT32 Value; UINT32 Value;
LibAmdGetDataFromPtr (AccessWidth, Data, DataMask, &TempData, &TempMask); LibAmdGetDataFromPtr (AccessWidth, Data, DataMask, &TempData, &TempMask);
LibAmdMemRead (AccessWidth, MemAddress, &Value, StdHeader); LibAmdMemRead (AccessWidth, MemAddress, &Value, NULL);
Value = (Value & (~TempMask)) | TempData; Value = (Value & (~TempMask)) | TempData;
LibAmdMemWrite (AccessWidth, MemAddress, &Value, StdHeader); LibAmdMemWrite (AccessWidth, MemAddress, &Value, NULL);
} }
/*---------------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------------*/
@ -778,7 +778,7 @@ LibAmdMemPoll (
UINT32 Value; UINT32 Value;
LibAmdGetDataFromPtr (AccessWidth, Data, DataMask, &TempData, &TempMask); LibAmdGetDataFromPtr (AccessWidth, Data, DataMask, &TempData, &TempMask);
do { do {
LibAmdMemRead (AccessWidth, MemAddress, &Value, StdHeader); LibAmdMemRead (AccessWidth, MemAddress, &Value, NULL);
} while (TempData != (Value & TempMask)); } while (TempData != (Value & TempMask));
} }
@ -807,28 +807,28 @@ LibAmdPciRead (
UINT64 RMWritePrevious; UINT64 RMWritePrevious;
UINT64 MMIOAddress; UINT64 MMIOAddress;
ASSERT (StdHeader != NULL);
ASSERT (PciAddress.AddressValue != ILLEGAL_SBDFO); ASSERT (PciAddress.AddressValue != ILLEGAL_SBDFO);
if (!GetPciMmioAddress (&MMIOAddress, &MMIOSize, StdHeader)) { if (!GetPciMmioAddress (&MMIOAddress, &MMIOSize, NULL)) {
// We need to convert our "portable" PCI address into a "real" PCI access // We need to convert our "portable" PCI address into a "real" PCI access
LegacyPciAccess = ((1 << 31) + (PciAddress.Address.Register & 0xFC) + (PciAddress.Address.Function << 8) + (PciAddress.Address.Device << 11) + (PciAddress.Address.Bus << 16) + ((PciAddress.Address.Register & 0xF00) << (24 - 8))); LegacyPciAccess = ((1 << 31) + (PciAddress.Address.Register & 0xFC) + (PciAddress.Address.Function << 8) + (PciAddress.Address.Device << 11) + (PciAddress.Address.Bus << 16) + ((PciAddress.Address.Register & 0xF00) << (24 - 8)));
if (PciAddress.Address.Register <= 0xFF) { if (PciAddress.Address.Register <= 0xFF) {
LibAmdIoWrite (AccessWidth32, IOCF8, &LegacyPciAccess, StdHeader); LibAmdIoWrite (AccessWidth32, IOCF8, &LegacyPciAccess, NULL);
LibAmdIoRead (AccessWidth, IOCFC + (UINT16) (PciAddress.Address.Register & 0x3), Value, StdHeader); LibAmdIoRead (AccessWidth, IOCFC + (UINT16) (PciAddress.Address.Register & 0x3), Value, NULL);
} else { } else {
LibAmdMsrRead (NB_CFG, &RMWritePrevious, StdHeader); LibAmdMsrRead (NB_CFG, &RMWritePrevious, NULL);
RMWrite = RMWritePrevious | 0x0000400000000000; RMWrite = RMWritePrevious | 0x0000400000000000;
LibAmdMsrWrite (NB_CFG, &RMWrite, StdHeader); LibAmdMsrWrite (NB_CFG, &RMWrite, NULL);
LibAmdIoWrite (AccessWidth32, IOCF8, &LegacyPciAccess, StdHeader); LibAmdIoWrite (AccessWidth32, IOCF8, &LegacyPciAccess, NULL);
LibAmdIoRead (AccessWidth, IOCFC + (UINT16) (PciAddress.Address.Register & 0x3), Value, StdHeader); LibAmdIoRead (AccessWidth, IOCFC + (UINT16) (PciAddress.Address.Register & 0x3), Value, NULL);
LibAmdMsrWrite (NB_CFG, &RMWritePrevious, StdHeader); LibAmdMsrWrite (NB_CFG, &RMWritePrevious, NULL);
} }
//IDS_HDT_CONSOLE (LIB_PCI_RD, "~PCI RD %08x = %08x\n", LegacyPciAccess, *(UINT32 *)Value); //IDS_HDT_CONSOLE (LIB_PCI_RD, "~PCI RD %08x = %08x\n", LegacyPciAccess, *(UINT32 *)Value);
} else { } else {
// Setup the MMIO address // Setup the MMIO address
ASSERT ((MMIOAddress + MMIOSize) > (MMIOAddress + (PciAddress.AddressValue & 0x0FFFFFFF))); ASSERT ((MMIOAddress + MMIOSize) > (MMIOAddress + (PciAddress.AddressValue & 0x0FFFFFFF)));
MMIOAddress += (PciAddress.AddressValue & 0x0FFFFFFF); MMIOAddress += (PciAddress.AddressValue & 0x0FFFFFFF);
LibAmdMemRead (AccessWidth, MMIOAddress, Value, StdHeader); LibAmdMemRead (AccessWidth, MMIOAddress, Value, NULL);
//IDS_HDT_CONSOLE (LIB_PCI_RD, "~MMIO RD %08x = %08x\n", (UINT32) MMIOAddress, *(UINT32 *)Value); //IDS_HDT_CONSOLE (LIB_PCI_RD, "~MMIO RD %08x = %08x\n", (UINT32) MMIOAddress, *(UINT32 *)Value);
} }
} }
@ -858,21 +858,21 @@ LibAmdPciWrite (
UINT64 RMWritePrevious; UINT64 RMWritePrevious;
UINT64 MMIOAddress; UINT64 MMIOAddress;
ASSERT (StdHeader != NULL);
ASSERT (PciAddress.AddressValue != ILLEGAL_SBDFO); ASSERT (PciAddress.AddressValue != ILLEGAL_SBDFO);
if (!GetPciMmioAddress (&MMIOAddress, &MMIOSize, StdHeader)) { if (!GetPciMmioAddress (&MMIOAddress, &MMIOSize, NULL)) {
// We need to convert our "portable" PCI address into a "real" PCI access // We need to convert our "portable" PCI address into a "real" PCI access
LegacyPciAccess = ((1 << 31) + (PciAddress.Address.Register & 0xFC) + (PciAddress.Address.Function << 8) + (PciAddress.Address.Device << 11) + (PciAddress.Address.Bus << 16) + ((PciAddress.Address.Register & 0xF00) << (24 - 8))); LegacyPciAccess = ((1 << 31) + (PciAddress.Address.Register & 0xFC) + (PciAddress.Address.Function << 8) + (PciAddress.Address.Device << 11) + (PciAddress.Address.Bus << 16) + ((PciAddress.Address.Register & 0xF00) << (24 - 8)));
if (PciAddress.Address.Register <= 0xFF) { if (PciAddress.Address.Register <= 0xFF) {
LibAmdIoWrite (AccessWidth32, IOCF8, &LegacyPciAccess, StdHeader); LibAmdIoWrite (AccessWidth32, IOCF8, &LegacyPciAccess, NULL);
LibAmdIoWrite (AccessWidth, IOCFC + (UINT16) (PciAddress.Address.Register & 0x3), Value, StdHeader); LibAmdIoWrite (AccessWidth, IOCFC + (UINT16) (PciAddress.Address.Register & 0x3), Value, NULL);
} else { } else {
LibAmdMsrRead (NB_CFG, &RMWritePrevious, StdHeader); LibAmdMsrRead (NB_CFG, &RMWritePrevious, NULL);
RMWrite = RMWritePrevious | 0x0000400000000000; RMWrite = RMWritePrevious | 0x0000400000000000;
LibAmdMsrWrite (NB_CFG, &RMWrite, StdHeader); LibAmdMsrWrite (NB_CFG, &RMWrite, NULL);
LibAmdIoWrite (AccessWidth32, IOCF8, &LegacyPciAccess, StdHeader); LibAmdIoWrite (AccessWidth32, IOCF8, &LegacyPciAccess, NULL);
LibAmdIoWrite (AccessWidth, IOCFC + (UINT16) (PciAddress.Address.Register & 0x3), Value, StdHeader); LibAmdIoWrite (AccessWidth, IOCFC + (UINT16) (PciAddress.Address.Register & 0x3), Value, NULL);
LibAmdMsrWrite (NB_CFG, &RMWritePrevious, StdHeader); LibAmdMsrWrite (NB_CFG, &RMWritePrevious, NULL);
} }
//IDS_HDT_CONSOLE (LIB_PCI_WR, "~PCI WR %08x = %08x\n", LegacyPciAccess, *(UINT32 *)Value); //IDS_HDT_CONSOLE (LIB_PCI_WR, "~PCI WR %08x = %08x\n", LegacyPciAccess, *(UINT32 *)Value);
//printk(BIOS_DEBUG, "~PCI WR %08x = %08x\n", LegacyPciAccess, *(UINT32 *)Value); //printk(BIOS_DEBUG, "~PCI WR %08x = %08x\n", LegacyPciAccess, *(UINT32 *)Value);
@ -881,7 +881,7 @@ LibAmdPciWrite (
// Setup the MMIO address // Setup the MMIO address
ASSERT ((MMIOAddress + MMIOSize) > (MMIOAddress + (PciAddress.AddressValue & 0x0FFFFFFF))); ASSERT ((MMIOAddress + MMIOSize) > (MMIOAddress + (PciAddress.AddressValue & 0x0FFFFFFF)));
MMIOAddress += (PciAddress.AddressValue & 0x0FFFFFFF); MMIOAddress += (PciAddress.AddressValue & 0x0FFFFFFF);
LibAmdMemWrite (AccessWidth, MMIOAddress, Value, StdHeader); LibAmdMemWrite (AccessWidth, MMIOAddress, Value, NULL);
//IDS_HDT_CONSOLE (LIB_PCI_WR, "~MMIO WR %08x = %08x\n", (UINT32) MMIOAddress, *(UINT32 *)Value); //IDS_HDT_CONSOLE (LIB_PCI_WR, "~MMIO WR %08x = %08x\n", (UINT32) MMIOAddress, *(UINT32 *)Value);
//printk(BIOS_DEBUG, "~MMIO WR %08x = %08x\n", (UINT32) MMIOAddress, *(UINT32 *)Value); //printk(BIOS_DEBUG, "~MMIO WR %08x = %08x\n", (UINT32) MMIOAddress, *(UINT32 *)Value);
//printk(BIOS_DEBUG, "LibAmdPciWrite mmio\n"); //printk(BIOS_DEBUG, "LibAmdPciWrite mmio\n");
@ -913,9 +913,9 @@ LibAmdPciRMW (
UINT32 TempMask = 0; UINT32 TempMask = 0;
UINT32 Value; UINT32 Value;
LibAmdGetDataFromPtr (AccessWidth, Data, DataMask, &TempData, &TempMask); LibAmdGetDataFromPtr (AccessWidth, Data, DataMask, &TempData, &TempMask);
LibAmdPciRead (AccessWidth, PciAddress, &Value, StdHeader); LibAmdPciRead (AccessWidth, PciAddress, &Value, NULL);
Value = (Value & (~TempMask)) | TempData; Value = (Value & (~TempMask)) | TempData;
LibAmdPciWrite (AccessWidth, PciAddress, &Value, StdHeader); LibAmdPciWrite (AccessWidth, PciAddress, &Value, NULL);
} }
/*---------------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------------*/
@ -947,7 +947,7 @@ LibAmdPciPoll (
UINT32 Value; UINT32 Value;
LibAmdGetDataFromPtr (AccessWidth, Data, DataMask, &TempData, &TempMask); LibAmdGetDataFromPtr (AccessWidth, Data, DataMask, &TempData, &TempMask);
do { do {
LibAmdPciRead (AccessWidth, PciAddress, &Value, StdHeader); LibAmdPciRead (AccessWidth, PciAddress, &Value, NULL);
} while (TempData != (Value & TempMask)); } while (TempData != (Value & TempMask));
} }
@ -973,10 +973,8 @@ GetPciMmioAddress (
UINT32 EncodedSize; UINT32 EncodedSize;
UINT64 LocalMsrRegister; UINT64 LocalMsrRegister;
ASSERT (StdHeader != NULL);
MmioIsEnabled = FALSE; MmioIsEnabled = FALSE;
LibAmdMsrRead (MSR_MMIO_Cfg_Base, &LocalMsrRegister, StdHeader); LibAmdMsrRead (MSR_MMIO_Cfg_Base, &LocalMsrRegister, NULL);
if ((LocalMsrRegister & BIT0) != 0) { if ((LocalMsrRegister & BIT0) != 0) {
*MmioAddress = LocalMsrRegister & 0xFFFFFFFFFFF00000; *MmioAddress = LocalMsrRegister & 0xFFFFFFFFFFF00000;
EncodedSize = (UINT32) ((LocalMsrRegister & 0x3C) >> 2); EncodedSize = (UINT32) ((LocalMsrRegister & 0x3C) >> 2);
@ -1009,7 +1007,7 @@ LibAmdPciReadBits (
{ {
ASSERT (Highbit < 32 && Lowbit < 32 && Highbit >= Lowbit && (Address.AddressValue & 3) == 0); ASSERT (Highbit < 32 && Lowbit < 32 && Highbit >= Lowbit && (Address.AddressValue & 3) == 0);
LibAmdPciRead (AccessWidth32, Address, Value, StdHeader); LibAmdPciRead (AccessWidth32, Address, Value, NULL);
*Value >>= Lowbit; // Shift *Value >>= Lowbit; // Shift
// A 1 << 32 == 1 << 0 due to x86 SHL instruction, so skip if that is the case // A 1 << 32 == 1 << 0 due to x86 SHL instruction, so skip if that is the case
@ -1053,10 +1051,10 @@ LibAmdPciWriteBits (
Mask = (UINT32) 0xFFFFFFFF; Mask = (UINT32) 0xFFFFFFFF;
} }
LibAmdPciRead (AccessWidth32, Address, &Temp, StdHeader); LibAmdPciRead (AccessWidth32, Address, &Temp, NULL);
Temp &= ~(Mask << Lowbit); Temp &= ~(Mask << Lowbit);
Temp |= (*Value & Mask) << Lowbit; Temp |= (*Value & Mask) << Lowbit;
LibAmdPciWrite (AccessWidth32, Address, &Temp, StdHeader); LibAmdPciWrite (AccessWidth32, Address, &Temp, NULL);
} }
/*---------------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------------*/
@ -1093,7 +1091,7 @@ LibAmdPciFindNextCap (
Address->AddressValue = (UINT32) ILLEGAL_SBDFO; Address->AddressValue = (UINT32) ILLEGAL_SBDFO;
// Verify that the SBDFO points to a valid PCI device SANITY CHECK // Verify that the SBDFO points to a valid PCI device SANITY CHECK
LibAmdPciRead (AccessWidth32, Base, &Temp, StdHeader); LibAmdPciRead (AccessWidth32, Base, &Temp, NULL);
if (Temp == 0xFFFFFFFF) { if (Temp == 0xFFFFFFFF) {
ASSERT (FALSE); ASSERT (FALSE);
return; // There is no device at this address return; // There is no device at this address
@ -1101,7 +1099,7 @@ LibAmdPciFindNextCap (
// Verify that the device supports a capability list // Verify that the device supports a capability list
TempAddress.AddressValue = Base.AddressValue + 0x04; TempAddress.AddressValue = Base.AddressValue + 0x04;
LibAmdPciReadBits (TempAddress, 20, 20, &Temp, StdHeader); LibAmdPciReadBits (TempAddress, 20, 20, &Temp, NULL);
if (Temp == 0) { if (Temp == 0) {
return; // This PCI device does not support capability lists return; // This PCI device does not support capability lists
} }
@ -1109,11 +1107,11 @@ LibAmdPciFindNextCap (
if (Offset != 0) { if (Offset != 0) {
// If we are continuing on an existing list // If we are continuing on an existing list
TempAddress.AddressValue = Base.AddressValue + Offset; TempAddress.AddressValue = Base.AddressValue + Offset;
LibAmdPciReadBits (TempAddress, 15, 8, &Temp, StdHeader); LibAmdPciReadBits (TempAddress, 15, 8, &Temp, NULL);
} else { } else {
// We are starting on a new list // We are starting on a new list
TempAddress.AddressValue = Base.AddressValue + 0x34; TempAddress.AddressValue = Base.AddressValue + 0x34;
LibAmdPciReadBits (TempAddress, 7, 0, &Temp, StdHeader); LibAmdPciReadBits (TempAddress, 7, 0, &Temp, NULL);
} }
if (Temp == 0) { if (Temp == 0) {
@ -1152,7 +1150,6 @@ LibAmdMemFill (
) )
{ {
UINT8 *Dest; UINT8 *Dest;
ASSERT (StdHeader != NULL);
Dest = Destination; Dest = Destination;
while ((FillLength--) != 0) { while ((FillLength--) != 0) {
*Dest++ = Value; *Dest++ = Value;
@ -1179,7 +1176,6 @@ LibAmdMemCopy (
{ {
UINT8 *Dest; UINT8 *Dest;
CONST UINT8 *SourcePtr; CONST UINT8 *SourcePtr;
ASSERT (StdHeader != NULL);
Dest = Destination; Dest = Destination;
SourcePtr = Source; SourcePtr = Source;
while ((CopyLength--) != 0) { while ((CopyLength--) != 0) {
@ -1287,7 +1283,7 @@ LibAmdGetPackageType (
UINT32 ProcessorPackageType; UINT32 ProcessorPackageType;
CPUID_DATA CpuId; CPUID_DATA CpuId;
LibAmdCpuidRead (0x80000001, &CpuId, StdHeader); LibAmdCpuidRead (0x80000001, &CpuId, NULL);
ProcessorPackageType = (UINT32) (CpuId.EBX_Reg >> 28) & 0xF; // bit 31:28 ProcessorPackageType = (UINT32) (CpuId.EBX_Reg >> 28) & 0xF; // bit 31:28
return (UINT32) (1 << ProcessorPackageType); return (UINT32) (1 << ProcessorPackageType);
} }