From b60395bc2518bd8cdbb25e60fcfd04019d83db56 Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Tue, 21 Sep 2010 17:07:40 +0000 Subject: [PATCH 1/1] [HAL]: Partly implement HalpAdjustPCIResourceList required for legacy HAL. No actual adjustment is done yet, since the Range package is not implemented. [HAL]: Implement most of HalpGetISAFixedPCIIrq, other than the legacy PCI IRQ Routing Miniport callbacks, which aren't yet implemented by ReactOS. The Windows PCI Bus Driver seems to work now. svn path=/trunk/; revision=48844 --- .../hal/halx86/generic/legacy/bus/pcibus.c | 77 +++++++++++++++++-- 1 file changed, 71 insertions(+), 6 deletions(-) diff --git a/reactos/hal/halx86/generic/legacy/bus/pcibus.c b/reactos/hal/halx86/generic/legacy/bus/pcibus.c index 6cdbfb168ec..989028e9331 100644 --- a/reactos/hal/halx86/generic/legacy/bus/pcibus.c +++ b/reactos/hal/halx86/generic/legacy/bus/pcibus.c @@ -14,6 +14,7 @@ /* GLOBALS *******************************************************************/ +extern BOOLEAN HalpPciLockSettings; ULONG HalpBusType; PCI_TYPE1_CFG_CYCLE_BITS HalpPciDebuggingDevice[2] = {{{{0}}}}; @@ -558,8 +559,42 @@ HalpGetISAFixedPCIIrq(IN PBUS_HANDLER BusHandler, IN PCI_SLOT_NUMBER PciSlot, OUT PSUPPORTED_RANGE *Range) { - UNIMPLEMENTED; - while (TRUE); + PCI_COMMON_HEADER PciData; + + /* Read PCI configuration data */ + HalGetBusData(PCIConfiguration, + BusHandler->BusNumber, + PciSlot.u.AsULONG, + &PciData, + PCI_COMMON_HDR_LENGTH); + + /* Make sure it's a real device */ + if (PciData.VendorID == PCI_INVALID_VENDORID) return STATUS_UNSUCCESSFUL; + + /* Allocate the supported range structure */ + *Range = ExAllocatePoolWithTag(PagedPool, sizeof(SUPPORTED_RANGE), 'Hal '); + if (!*Range) return STATUS_INSUFFICIENT_RESOURCES; + + /* Set it up */ + RtlZeroMemory(*Range, sizeof(SUPPORTED_RANGE)); + (*Range)->Base = 1; + + /* If the PCI device has no IRQ, nothing to do */ + if (!PciData.u.type0.InterruptPin) return STATUS_SUCCESS; + + /* FIXME: The PCI IRQ Routing Miniport should be called */ + + /* Also if the INT# seems bogus, nothing to do either */ + if ((PciData.u.type0.InterruptLine == 0) || + (PciData.u.type0.InterruptLine == 255)) + { + /* Fake success */ + return STATUS_SUCCESS; + } + + /* Otherwise, the INT# should be valid, return it to the caller */ + (*Range)->Base = PciData.u.type0.InterruptLine; + (*Range)->Limit = PciData.u.type0.InterruptLine; return STATUS_SUCCESS; } @@ -622,10 +657,40 @@ HalpAdjustPCIResourceList(IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootHandler, IN OUT PIO_RESOURCE_REQUIREMENTS_LIST *pResourceList) { - /* Not yet supported */ - DbgPrint("HAL: PCI Resource List Adjustment not implemented!"); - while (TRUE); - return STATUS_UNSUCCESSFUL; + PPCIPBUSDATA BusData; + PCI_SLOT_NUMBER SlotNumber; + PSUPPORTED_RANGE Interrupt; + NTSTATUS Status; + + /* Get PCI bus data */ + BusData = BusHandler->BusData; + SlotNumber.u.AsULONG = (*pResourceList)->SlotNumber; + + /* Get the IRQ supported range */ + Status = BusData->GetIrqRange(BusHandler, RootHandler, SlotNumber, &Interrupt); + if (!NT_SUCCESS(Status)) return Status; +#ifndef _MINIHAL_ + /* Handle the /PCILOCK feature */ + if (HalpPciLockSettings) + { + /* /PCILOCK is not yet supported */ + UNIMPLEMENTED; + while (TRUE); + } +#endif + /* Now create the correct resource list based on the supported bus ranges */ +#if 0 + Status = HaliAdjustResourceListRange(BusHandler->BusAddresses, + Interrupt, + pResourceList); +#else + DPRINT1("HAL: No PCI Resource Adjustment done! Hardware may malfunction\n"); + Status = STATUS_SUCCESS; +#endif + + /* Return to caller */ + ExFreePool(Interrupt); + return Status; } NTSTATUS -- 2.17.1