Author: mjmartin Date: Sat Dec 27 11:16:07 2008 New Revision: 38394
URL: http://svn.reactos.org/svn/reactos?rev=38394&view=rev Log: - Fixes VideoPortGetAccessRanges. - Previous implementation was missing the Device number when searching the bus resulting in failure to find Device and Vendor ID. - Function was also passing NULL for first 4 parameters of HalAssignSlotResources causing failure. - Due to this, the device object was then deleted causing failure when trying to find the display device in Csrss:CsrpInitVideo(). - Part 3 of ? fixes for bug 2286.
Modified: trunk/reactos/drivers/video/videoprt/resource.c
Modified: trunk/reactos/drivers/video/videoprt/resource.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/video/videoprt/reso... ============================================================================== --- trunk/reactos/drivers/video/videoprt/resource.c [iso-8859-1] (original) +++ trunk/reactos/drivers/video/videoprt/resource.c [iso-8859-1] Sat Dec 27 11:16:07 2008 @@ -401,6 +401,7 @@ IN PULONG Slot) { PCI_SLOT_NUMBER PciSlotNumber; + ULONG DeviceNumber; ULONG FunctionNumber; PCI_COMMON_CONFIG Config; PCM_RESOURCE_LIST AllocatedResources; @@ -413,6 +414,7 @@ USHORT DeviceIdToFind; ULONG SlotIdToFind; ULONG ReturnedLength; + BOOLEAN DeviceAndVendorFound = FALSE;
TRACE_(VIDEOPRT, "VideoPortGetAccessRanges\n");
@@ -453,36 +455,40 @@ /* * Search for the device id and vendor id on this bus. */ - - for (FunctionNumber = 0; FunctionNumber < 8; FunctionNumber++) + for (DeviceNumber = 0; DeviceNumber < PCI_MAX_DEVICES; DeviceNumber++) { - INFO_(VIDEOPRT, "- Function number: %d\n", FunctionNumber); - PciSlotNumber.u.bits.FunctionNumber = FunctionNumber; - ReturnedLength = HalGetBusData( - PCIConfiguration, - DeviceExtension->SystemIoBusNumber, - PciSlotNumber.u.AsULONG, - &Config, - sizeof(PCI_COMMON_CONFIG)); - INFO_(VIDEOPRT, "- Length of data: %x\n", ReturnedLength); - if (ReturnedLength == sizeof(PCI_COMMON_CONFIG)) + PciSlotNumber.u.bits.DeviceNumber = DeviceNumber; + for (FunctionNumber = 0; FunctionNumber < 8; FunctionNumber++) { - INFO_(VIDEOPRT, "- Slot 0x%02x (Device %d Function %d) VendorId 0x%04x " - "DeviceId 0x%04x\n", - PciSlotNumber.u.AsULONG, - PciSlotNumber.u.bits.DeviceNumber, - PciSlotNumber.u.bits.FunctionNumber, - Config.VendorID, - Config.DeviceID); - - if ((VendorIdToFind == 0 || Config.VendorID == VendorIdToFind) && - (DeviceIdToFind == 0 || Config.DeviceID == DeviceIdToFind)) + INFO_(VIDEOPRT, "- Function number: %d\n", FunctionNumber); + PciSlotNumber.u.bits.FunctionNumber = FunctionNumber; + ReturnedLength = HalGetBusData( + PCIConfiguration, + DeviceExtension->SystemIoBusNumber, + PciSlotNumber.u.AsULONG, + &Config, + sizeof(PCI_COMMON_CONFIG)); + INFO_(VIDEOPRT, "- Length of data: %x\n", ReturnedLength); + if (ReturnedLength == sizeof(PCI_COMMON_CONFIG)) { - break; + INFO_(VIDEOPRT, "- Slot 0x%02x (Device %d Function %d) VendorId 0x%04x " + "DeviceId 0x%04x\n", + PciSlotNumber.u.AsULONG, + PciSlotNumber.u.bits.DeviceNumber, + PciSlotNumber.u.bits.FunctionNumber, + Config.VendorID, + Config.DeviceID); + + if ((VendorIdToFind == 0 || Config.VendorID == VendorIdToFind) && + (DeviceIdToFind == 0 || Config.DeviceID == DeviceIdToFind)) + { + DeviceAndVendorFound = TRUE; + break; + } } } + if (DeviceAndVendorFound) break; } - if (FunctionNumber == 8) { WARN_(VIDEOPRT, "Didn't find device.\n"); @@ -491,7 +497,10 @@ }
Status = HalAssignSlotResources( - NULL, NULL, NULL, NULL, + &DeviceExtension->RegistryPath, + NULL, + DeviceExtension->DriverObject, + DeviceExtension->DriverObject->DeviceObject, DeviceExtension->AdapterInterfaceType, DeviceExtension->SystemIoBusNumber, PciSlotNumber.u.AsULONG, @@ -499,13 +508,13 @@
if (!NT_SUCCESS(Status)) { + WARN_(VIDEOPRT, "HalAssignSlotResources failed with status %x.\n",Status); return Status; } DeviceExtension->AllocatedResources = AllocatedResources; } if (AllocatedResources == NULL) return ERROR_NOT_ENOUGH_MEMORY; - AssignedCount = 0; for (FullList = AllocatedResources->List; FullList < AllocatedResources->List + AllocatedResources->Count; @@ -515,7 +524,7 @@ FullList->BusNumber == DeviceExtension->SystemIoBusNumber && 1 == FullList->PartialResourceList.Version && 1 == FullList->PartialResourceList.Revision); - for (Descriptor = FullList->PartialResourceList.PartialDescriptors; + for (Descriptor = FullList->PartialResourceList.PartialDescriptors; Descriptor < FullList->PartialResourceList.PartialDescriptors + FullList->PartialResourceList.Count; Descriptor++) {