mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 13:56:05 +00:00
[HAL]
- Return the correct value if the PCI slot number is invalid - Use the bus number from the PCI BIOS instead of doing a manual probe if we can because it is much more accurate (our probing code doesn't detect buses without devices present) - Don't probe for devices at invalid locations on PCI type 2 buses - Check for a valid bus number so we don't return the wrong value svn path=/trunk/; revision=47162
This commit is contained in:
parent
c5e12bcf40
commit
0a6ca40598
1 changed files with 59 additions and 39 deletions
|
@ -360,15 +360,19 @@ HalpGetPCIData(IN PBUS_HANDLER BusHandler,
|
||||||
(1 == BusHandler->BusNumber && 0 != Slot.u.bits.DeviceNumber))
|
(1 == BusHandler->BusNumber && 0 != Slot.u.bits.DeviceNumber))
|
||||||
{
|
{
|
||||||
DPRINT("Blacklisted PCI slot\n");
|
DPRINT("Blacklisted PCI slot\n");
|
||||||
if (0 == Offset && 2 <= Length)
|
if (0 == Offset && sizeof(USHORT) <= Length)
|
||||||
{
|
{
|
||||||
*(PUSHORT)Buffer = PCI_INVALID_VENDORID;
|
*(PUSHORT)Buffer = PCI_INVALID_VENDORID;
|
||||||
return 2;
|
return sizeof(USHORT);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Make sure the bus number is in our range of good bus numbers */
|
||||||
|
if (BusHandler->BusNumber > HalpMaxPciBus || BusHandler->BusNumber < HalpMinPciBus)
|
||||||
|
return 0;
|
||||||
|
|
||||||
/* Normalize the length */
|
/* Normalize the length */
|
||||||
if (Length > sizeof(PCI_COMMON_CONFIG)) Length = sizeof(PCI_COMMON_CONFIG);
|
if (Length > sizeof(PCI_COMMON_CONFIG)) Length = sizeof(PCI_COMMON_CONFIG);
|
||||||
|
|
||||||
|
@ -390,9 +394,15 @@ HalpGetPCIData(IN PBUS_HANDLER BusHandler,
|
||||||
/* Validate the vendor ID */
|
/* Validate the vendor ID */
|
||||||
if (PciConfig->VendorID == PCI_INVALID_VENDORID)
|
if (PciConfig->VendorID == PCI_INVALID_VENDORID)
|
||||||
{
|
{
|
||||||
/* It's invalid, but we want to return this much */
|
/* It's invalid, but we can copy PCI_INVALID_VENDORID */
|
||||||
PciConfig->VendorID = PCI_INVALID_VENDORID;
|
if (Offset == 0 && Length >= sizeof(USHORT))
|
||||||
Len = sizeof(USHORT);
|
{
|
||||||
|
*(PUSHORT)Buffer = PCI_INVALID_VENDORID;
|
||||||
|
return sizeof(USHORT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We can't copy PCI_INVALID_VENDORID so just return 0 */
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now check if there's space left */
|
/* Now check if there's space left */
|
||||||
|
@ -455,6 +465,10 @@ HalpSetPCIData(IN PBUS_HANDLER BusHandler,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Make sure this bus number is in our range of good bus numbers */
|
||||||
|
if (BusHandler->BusNumber > HalpMaxPciBus || BusHandler->BusNumber < HalpMinPciBus)
|
||||||
|
return 0;
|
||||||
|
|
||||||
/* Normalize the length */
|
/* Normalize the length */
|
||||||
if (Length > sizeof(PCI_COMMON_CONFIG)) Length = sizeof(PCI_COMMON_CONFIG);
|
if (Length > sizeof(PCI_COMMON_CONFIG)) Length = sizeof(PCI_COMMON_CONFIG);
|
||||||
|
|
||||||
|
@ -700,7 +714,6 @@ HaliPciInterfaceReadConfig(IN PBUS_HANDLER RootBusHandler,
|
||||||
IN ULONG Length)
|
IN ULONG Length)
|
||||||
{
|
{
|
||||||
BUS_HANDLER BusHandler;
|
BUS_HANDLER BusHandler;
|
||||||
PPCI_COMMON_CONFIG PciData = (PPCI_COMMON_CONFIG)Buffer;
|
|
||||||
|
|
||||||
/* Setup fake PCI Bus handler */
|
/* Setup fake PCI Bus handler */
|
||||||
RtlCopyMemory(&BusHandler, &HalpFakePciBusHandler, sizeof(BUS_HANDLER));
|
RtlCopyMemory(&BusHandler, &HalpFakePciBusHandler, sizeof(BUS_HANDLER));
|
||||||
|
@ -709,21 +722,6 @@ HaliPciInterfaceReadConfig(IN PBUS_HANDLER RootBusHandler,
|
||||||
/* Read configuration data */
|
/* Read configuration data */
|
||||||
HalpReadPCIConfig(&BusHandler, SlotNumber, Buffer, Offset, Length);
|
HalpReadPCIConfig(&BusHandler, SlotNumber, Buffer, Offset, Length);
|
||||||
|
|
||||||
/* Check if caller only wanted at least Vendor ID */
|
|
||||||
if (Length >= 2)
|
|
||||||
{
|
|
||||||
/* Validate it */
|
|
||||||
if (PciData->VendorID != PCI_INVALID_VENDORID)
|
|
||||||
{
|
|
||||||
/* Check if this is the new maximum bus number */
|
|
||||||
if (HalpMaxPciBus < BusHandler.BusNumber)
|
|
||||||
{
|
|
||||||
/* Set it */
|
|
||||||
HalpMaxPciBus = BusHandler.BusNumber;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return length */
|
/* Return length */
|
||||||
return Length;
|
return Length;
|
||||||
}
|
}
|
||||||
|
@ -970,6 +968,7 @@ HalpInitializePciStubs(VOID)
|
||||||
ULONG i;
|
ULONG i;
|
||||||
PCI_SLOT_NUMBER j;
|
PCI_SLOT_NUMBER j;
|
||||||
ULONG VendorId = 0;
|
ULONG VendorId = 0;
|
||||||
|
ULONG MaxPciBusNumber;
|
||||||
|
|
||||||
/* Query registry information */
|
/* Query registry information */
|
||||||
PciRegistryInfo = HalpQueryPciRegistryInfo();
|
PciRegistryInfo = HalpQueryPciRegistryInfo();
|
||||||
|
@ -977,11 +976,19 @@ HalpInitializePciStubs(VOID)
|
||||||
{
|
{
|
||||||
/* Assume type 1 */
|
/* Assume type 1 */
|
||||||
PciType = 1;
|
PciType = 1;
|
||||||
|
|
||||||
|
/* Force a manual bus scan later */
|
||||||
|
MaxPciBusNumber = MAXULONG;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Get the type and free the info structure */
|
/* Get the PCI type */
|
||||||
PciType = PciRegistryInfo->HardwareMechanism & 0xF;
|
PciType = PciRegistryInfo->HardwareMechanism & 0xF;
|
||||||
|
|
||||||
|
/* Get MaxPciBusNumber and make it 0-based */
|
||||||
|
MaxPciBusNumber = PciRegistryInfo->NoBuses - 1;
|
||||||
|
|
||||||
|
/* Free the info structure */
|
||||||
ExFreePool(PciRegistryInfo);
|
ExFreePool(PciRegistryInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1007,7 +1014,7 @@ HalpInitializePciStubs(VOID)
|
||||||
/* Type 2 PCI Bus */
|
/* Type 2 PCI Bus */
|
||||||
case 2:
|
case 2:
|
||||||
|
|
||||||
/* Copy the Type 1 handler data */
|
/* Copy the Type 2 handler data */
|
||||||
RtlCopyMemory(&PCIConfigHandler,
|
RtlCopyMemory(&PCIConfigHandler,
|
||||||
&PCIConfigHandlerType2,
|
&PCIConfigHandlerType2,
|
||||||
sizeof (PCIConfigHandler));
|
sizeof (PCIConfigHandler));
|
||||||
|
@ -1027,31 +1034,44 @@ HalpInitializePciStubs(VOID)
|
||||||
DbgPrint("HAL: Unknown PCI type\n");
|
DbgPrint("HAL: Unknown PCI type\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Loop all possible buses */
|
/* Run a forced bus scan if needed */
|
||||||
for (i = 0; i < 256; i++)
|
if (MaxPciBusNumber == MAXULONG)
|
||||||
{
|
{
|
||||||
/* Loop all devices */
|
/* Initialize the max bus number to 0xFF */
|
||||||
for (j.u.AsULONG = 0; j.u.AsULONG < 32; j.u.AsULONG++)
|
HalpMaxPciBus = 0xFF;
|
||||||
|
|
||||||
|
/* Initialize the counter */
|
||||||
|
MaxPciBusNumber = 0;
|
||||||
|
|
||||||
|
/* Loop all possible buses */
|
||||||
|
for (i = 0; i < HalpMaxPciBus; i++)
|
||||||
{
|
{
|
||||||
/* Query the interface */
|
/* Loop all devices */
|
||||||
if (HaliPciInterfaceReadConfig(NULL,
|
for (j.u.AsULONG = 0; j.u.AsULONG < BusData->MaxDevice; j.u.AsULONG++)
|
||||||
i,
|
|
||||||
j,
|
|
||||||
&VendorId,
|
|
||||||
0,
|
|
||||||
sizeof(ULONG)))
|
|
||||||
{
|
{
|
||||||
/* Validate the vendor ID */
|
/* Query the interface */
|
||||||
if ((USHORT)VendorId != PCI_INVALID_VENDORID)
|
if (HaliPciInterfaceReadConfig(NULL,
|
||||||
|
i,
|
||||||
|
j,
|
||||||
|
&VendorId,
|
||||||
|
0,
|
||||||
|
sizeof(ULONG)))
|
||||||
{
|
{
|
||||||
/* Set this as the maximum ID */
|
/* Validate the vendor ID */
|
||||||
HalpMaxPciBus = i;
|
if ((USHORT)VendorId != PCI_INVALID_VENDORID)
|
||||||
break;
|
{
|
||||||
|
/* Set this as the maximum ID */
|
||||||
|
MaxPciBusNumber = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set the real max bus number */
|
||||||
|
HalpMaxPciBus = MaxPciBusNumber;
|
||||||
|
|
||||||
/* We're done */
|
/* We're done */
|
||||||
HalpPCIConfigInitialized = TRUE;
|
HalpPCIConfigInitialized = TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue