[PCI]
[reactos.git] / reactos / drivers / bus / pci / fdo.c
index e92a294..8072a89 100644 (file)
@@ -176,7 +176,7 @@ FdoQueryBusRelations(
   IN PIRP Irp,
   PIO_STACK_LOCATION IrpSp)
 {
-  PPDO_DEVICE_EXTENSION PdoDeviceExtension;
+  PPDO_DEVICE_EXTENSION PdoDeviceExtension = NULL;
   PFDO_DEVICE_EXTENSION DeviceExtension;
   PDEVICE_RELATIONS Relations;
   PLIST_ENTRY CurrentEntry;
@@ -187,6 +187,8 @@ FdoQueryBusRelations(
   ULONG Size;
   ULONG i;
 
+  UNREFERENCED_PARAMETER(IrpSp);
+
   DPRINT("Called\n");
 
   ErrorStatus = STATUS_INSUFFICIENT_RESOURCES;
@@ -206,7 +208,7 @@ FdoQueryBusRelations(
 
   Size = sizeof(DEVICE_RELATIONS) + sizeof(Relations->Objects) *
     (DeviceExtension->DeviceListCount - 1);
-  Relations = (PDEVICE_RELATIONS)ExAllocatePoolWithTag(PagedPool, Size, TAG_PCI);
+  Relations = (PDEVICE_RELATIONS)ExAllocatePool(PagedPool, Size);
   if (!Relations)
     return STATUS_INSUFFICIENT_RESOURCES;
 
@@ -237,8 +239,6 @@ FdoQueryBusRelations(
         break;
       }
 
-      Device->Pdo->Flags |= DO_BUS_ENUMERATED_DEVICE;
-
       Device->Pdo->Flags &= ~DO_DEVICE_INITIALIZING;
 
       //Device->Pdo->Flags |= DO_POWER_PAGABLE;
@@ -356,7 +356,6 @@ FdoStartDevice(
   IN PDEVICE_OBJECT DeviceObject,
   IN PIRP Irp)
 {
-  static BOOLEAN FoundBuggyAllocatedResourcesList = FALSE;
   PFDO_DEVICE_EXTENSION DeviceExtension;
   PCM_RESOURCE_LIST AllocatedResources;
   PCM_PARTIAL_RESOURCE_DESCRIPTOR ResourceDescriptor;
@@ -384,6 +383,9 @@ FdoStartDevice(
 
   ASSERT(DeviceExtension->State == dsStopped);
 
+  /* By default, use the bus number in the resource list header */
+  DeviceExtension->BusNumber = AllocatedResources->List[0].BusNumber;
+
   for (i = 0; i < AllocatedResources->List[0].PartialResourceList.Count; i++)
   {
     ResourceDescriptor = &AllocatedResources->List[0].PartialResourceList.PartialDescriptors[i];
@@ -393,6 +395,8 @@ FdoStartDevice(
       {
         if (FoundBusNumber || ResourceDescriptor->u.BusNumber.Length != 1)
           return STATUS_INVALID_PARAMETER;
+        /* Use this one instead */
+        ASSERT(AllocatedResources->List[0].BusNumber == ResourceDescriptor->u.BusNumber.Start);
         DeviceExtension->BusNumber = ResourceDescriptor->u.BusNumber.Start;
         DPRINT("Found bus number resource: %lu\n", DeviceExtension->BusNumber);
         FoundBusNumber = TRUE;
@@ -402,22 +406,7 @@ FdoStartDevice(
         DPRINT("Unknown resource descriptor type 0x%x\n", ResourceDescriptor->Type);
     }
   }
-  /* HACK due to a bug in ACPI driver, which doesn't report the bus number */
-  if (!FoundBuggyAllocatedResourcesList && !FoundBusNumber)
-  {
-    FoundBuggyAllocatedResourcesList = TRUE;
-    DPRINT1("No bus number resource found (bug in acpi.sys?), assuming bus number #0\n");
-    DeviceExtension->BusNumber = 0;
-    goto next;
-  }
-  /* END HACK */
-  if (!FoundBusNumber)
-  {
-    DPRINT("Some required resources were not found in allocated resources list\n");
-    return STATUS_INSUFFICIENT_RESOURCES;
-  }
 
-next:
   InitializeListHead(&DeviceExtension->DeviceListHead);
   KeInitializeSpinLock(&DeviceExtension->DeviceListLock);
   DeviceExtension->DeviceListCount = 0;
@@ -443,6 +432,8 @@ FdoSetPower(
   PFDO_DEVICE_EXTENSION DeviceExtension;
   NTSTATUS Status;
 
+  UNREFERENCED_PARAMETER(Irp);
+
   DPRINT("Called\n");
 
   DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;