mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
[HAL] HalpDebugPciDumpBus: Fix parsing bugs
- Bridge devices don't have Subsystem ID and Subsystem Vendor ID
- Also they have only two BARs, don't parse data outside of bounds
Addendum to b232efe1
. CORE-16319 CORE-16216
This commit is contained in:
parent
2047cf3613
commit
5caa59b31a
1 changed files with 31 additions and 18 deletions
|
@ -791,6 +791,7 @@ HalpDebugPciDumpBus(IN ULONG i,
|
||||||
IN PPCI_COMMON_CONFIG PciData)
|
IN PPCI_COMMON_CONFIG PciData)
|
||||||
{
|
{
|
||||||
PCHAR p, ClassName, Boundary, SubClassName, VendorName, ProductName, SubVendorName;
|
PCHAR p, ClassName, Boundary, SubClassName, VendorName, ProductName, SubVendorName;
|
||||||
|
UCHAR HeaderType;
|
||||||
ULONG Length;
|
ULONG Length;
|
||||||
CHAR LookupString[16] = "";
|
CHAR LookupString[16] = "";
|
||||||
CHAR bSubClassName[64] = "Unknown";
|
CHAR bSubClassName[64] = "Unknown";
|
||||||
|
@ -799,6 +800,8 @@ HalpDebugPciDumpBus(IN ULONG i,
|
||||||
CHAR bSubVendorName[128] = "Unknown";
|
CHAR bSubVendorName[128] = "Unknown";
|
||||||
ULONG Size, Mem, b;
|
ULONG Size, Mem, b;
|
||||||
|
|
||||||
|
HeaderType = (PciData->HeaderType & ~PCI_MULTIFUNCTION);
|
||||||
|
|
||||||
/* Isolate the class name */
|
/* Isolate the class name */
|
||||||
sprintf(LookupString, "C %02x ", PciData->BaseClass);
|
sprintf(LookupString, "C %02x ", PciData->BaseClass);
|
||||||
ClassName = strstr((PCHAR)ClassTable, LookupString);
|
ClassName = strstr((PCHAR)ClassTable, LookupString);
|
||||||
|
@ -872,16 +875,20 @@ HalpDebugPciDumpBus(IN ULONG i,
|
||||||
p += strlen("\r\n");
|
p += strlen("\r\n");
|
||||||
}
|
}
|
||||||
Boundary = p;
|
Boundary = p;
|
||||||
|
SubVendorName = NULL;
|
||||||
|
|
||||||
/* Isolate the subvendor and subsystem name */
|
if (HeaderType == PCI_DEVICE_TYPE)
|
||||||
sprintf(LookupString,
|
|
||||||
"\t\t%04x %04x ",
|
|
||||||
PciData->u.type0.SubVendorID,
|
|
||||||
PciData->u.type0.SubSystemID);
|
|
||||||
SubVendorName = strstr(ProductName, LookupString);
|
|
||||||
if (Boundary && SubVendorName >= Boundary)
|
|
||||||
{
|
{
|
||||||
SubVendorName = NULL;
|
/* Isolate the subvendor and subsystem name */
|
||||||
|
sprintf(LookupString,
|
||||||
|
"\t\t%04x %04x ",
|
||||||
|
PciData->u.type0.SubVendorID,
|
||||||
|
PciData->u.type0.SubSystemID);
|
||||||
|
SubVendorName = strstr(ProductName, LookupString);
|
||||||
|
if (Boundary && SubVendorName >= Boundary)
|
||||||
|
{
|
||||||
|
SubVendorName = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (SubVendorName)
|
if (SubVendorName)
|
||||||
{
|
{
|
||||||
|
@ -897,8 +904,7 @@ HalpDebugPciDumpBus(IN ULONG i,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Print out the data */
|
/* Print out the data */
|
||||||
DbgPrint("%02x:%02x.%x %s [%02x%02x]: %s %s [%04x:%04x] (rev %02x)\n"
|
DbgPrint("%02x:%02x.%x %s [%02x%02x]: %s %s [%04x:%04x] (rev %02x)\n",
|
||||||
"\tSubsystem: %s [%04x:%04x]\n",
|
|
||||||
i,
|
i,
|
||||||
j,
|
j,
|
||||||
k,
|
k,
|
||||||
|
@ -909,10 +915,15 @@ HalpDebugPciDumpBus(IN ULONG i,
|
||||||
bProductName,
|
bProductName,
|
||||||
PciData->VendorID,
|
PciData->VendorID,
|
||||||
PciData->DeviceID,
|
PciData->DeviceID,
|
||||||
PciData->RevisionID,
|
PciData->RevisionID);
|
||||||
bSubVendorName,
|
|
||||||
PciData->u.type0.SubVendorID,
|
if (HeaderType == PCI_DEVICE_TYPE)
|
||||||
PciData->u.type0.SubSystemID);
|
{
|
||||||
|
DbgPrint("\tSubsystem: %s [%04x:%04x]\n",
|
||||||
|
bSubVendorName,
|
||||||
|
PciData->u.type0.SubVendorID,
|
||||||
|
PciData->u.type0.SubSystemID);
|
||||||
|
}
|
||||||
|
|
||||||
/* Print out and decode flags */
|
/* Print out and decode flags */
|
||||||
DbgPrint("\tFlags:");
|
DbgPrint("\tFlags:");
|
||||||
|
@ -929,8 +940,7 @@ HalpDebugPciDumpBus(IN ULONG i,
|
||||||
else if (PciData->u.type0.InterruptPin != 0) DbgPrint(", IRQ assignment required");
|
else if (PciData->u.type0.InterruptPin != 0) DbgPrint(", IRQ assignment required");
|
||||||
DbgPrint("\n");
|
DbgPrint("\n");
|
||||||
|
|
||||||
if ((PciData->HeaderType & ~PCI_MULTIFUNCTION) == PCI_BRIDGE_TYPE &&
|
if (HeaderType == PCI_BRIDGE_TYPE)
|
||||||
PciData->BaseClass == PCI_CLASS_BRIDGE_DEV)
|
|
||||||
{
|
{
|
||||||
DbgPrint("\tBridge:");
|
DbgPrint("\tBridge:");
|
||||||
DbgPrint(" primary bus %d,", PciData->u.type1.PrimaryBus);
|
DbgPrint(" primary bus %d,", PciData->u.type1.PrimaryBus);
|
||||||
|
@ -942,10 +952,13 @@ HalpDebugPciDumpBus(IN ULONG i,
|
||||||
|
|
||||||
/* Scan addresses */
|
/* Scan addresses */
|
||||||
Size = 0;
|
Size = 0;
|
||||||
for (b = 0; b < PCI_TYPE0_ADDRESSES; b++)
|
for (b = 0; b < (HeaderType == PCI_DEVICE_TYPE ? PCI_TYPE0_ADDRESSES : PCI_TYPE1_ADDRESSES); b++)
|
||||||
{
|
{
|
||||||
/* Check for a BAR */
|
/* Check for a BAR */
|
||||||
Mem = PciData->u.type0.BaseAddresses[b];
|
if (HeaderType != PCI_CARDBUS_BRIDGE_TYPE)
|
||||||
|
Mem = PciData->u.type0.BaseAddresses[b];
|
||||||
|
else
|
||||||
|
Mem = 0;
|
||||||
if (Mem)
|
if (Mem)
|
||||||
{
|
{
|
||||||
/* Decode the address type */
|
/* Decode the address type */
|
||||||
|
|
Loading…
Reference in a new issue