[FORMATTING]
authorEric Kohl <eric.kohl@reactos.org>
Sat, 23 Nov 2013 22:08:48 +0000 (22:08 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Sat, 23 Nov 2013 22:08:48 +0000 (22:08 +0000)
Fix indentation. No code changes!

svn path=/trunk/; revision=61085

reactos/drivers/bus/pci/fdo.c
reactos/drivers/bus/pci/pci.c
reactos/drivers/bus/pci/pci.h
reactos/drivers/bus/pci/pdo.c

index a158215..03bc36b 100644 (file)
@@ -20,427 +20,436 @@ static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion;
 
 static NTSTATUS NTAPI
 ForwardIrpAndWaitCompletion(
-       IN PDEVICE_OBJECT DeviceObject,
-       IN PIRP Irp,
-       IN PVOID Context)
+    IN PDEVICE_OBJECT DeviceObject,
+    IN PIRP Irp,
+    IN PVOID Context)
 {
-       UNREFERENCED_PARAMETER(DeviceObject);
-       if (Irp->PendingReturned)
-               KeSetEvent((PKEVENT)Context, IO_NO_INCREMENT, FALSE);
-       return STATUS_MORE_PROCESSING_REQUIRED;
+    UNREFERENCED_PARAMETER(DeviceObject);
+    if (Irp->PendingReturned)
+        KeSetEvent((PKEVENT)Context, IO_NO_INCREMENT, FALSE);
+    return STATUS_MORE_PROCESSING_REQUIRED;
 }
 
 NTSTATUS NTAPI
 ForwardIrpAndWait(
-       IN PDEVICE_OBJECT DeviceObject,
-       IN PIRP Irp)
+    IN PDEVICE_OBJECT DeviceObject,
+    IN PIRP Irp)
 {
-       KEVENT Event;
-       NTSTATUS Status;
-       PDEVICE_OBJECT LowerDevice = ((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Ldo;
-       ASSERT(LowerDevice);
+    KEVENT Event;
+    NTSTATUS Status;
+    PDEVICE_OBJECT LowerDevice = ((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Ldo;
+    ASSERT(LowerDevice);
 
-       KeInitializeEvent(&Event, NotificationEvent, FALSE);
-       IoCopyCurrentIrpStackLocationToNext(Irp);
+    KeInitializeEvent(&Event, NotificationEvent, FALSE);
+    IoCopyCurrentIrpStackLocationToNext(Irp);
 
-       IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE, TRUE);
+    IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE, TRUE);
 
-       Status = IoCallDriver(LowerDevice, Irp);
-       if (Status == STATUS_PENDING)
-       {
-               Status = KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
-               if (NT_SUCCESS(Status))
-                       Status = Irp->IoStatus.Status;
-       }
+    Status = IoCallDriver(LowerDevice, Irp);
+    if (Status == STATUS_PENDING)
+    {
+        Status = KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
+        if (NT_SUCCESS(Status))
+            Status = Irp->IoStatus.Status;
+    }
 
-       return Status;
+    return Status;
 }
 
 static NTSTATUS
 FdoLocateChildDevice(
-  PPCI_DEVICE *Device,
-  PFDO_DEVICE_EXTENSION DeviceExtension,
-  PCI_SLOT_NUMBER SlotNumber,
-  PPCI_COMMON_CONFIG PciConfig)
+    PPCI_DEVICE *Device,
+    PFDO_DEVICE_EXTENSION DeviceExtension,
+    PCI_SLOT_NUMBER SlotNumber,
+    PPCI_COMMON_CONFIG PciConfig)
 {
-  PLIST_ENTRY CurrentEntry;
-  PPCI_DEVICE CurrentDevice;
-
-  DPRINT("Called\n");
-
-  CurrentEntry = DeviceExtension->DeviceListHead.Flink;
-  while (CurrentEntry != &DeviceExtension->DeviceListHead) {
-    CurrentDevice = CONTAINING_RECORD(CurrentEntry, PCI_DEVICE, ListEntry);
-
-    /* If both vendor ID and device ID match, it is the same device */
-    if ((PciConfig->VendorID == CurrentDevice->PciConfig.VendorID) &&
-        (PciConfig->DeviceID == CurrentDevice->PciConfig.DeviceID) &&
-        (SlotNumber.u.AsULONG == CurrentDevice->SlotNumber.u.AsULONG)) {
-      *Device = CurrentDevice;
-      DPRINT("Done\n");
-      return STATUS_SUCCESS;
-    }
+    PLIST_ENTRY CurrentEntry;
+    PPCI_DEVICE CurrentDevice;
+
+    DPRINT("Called\n");
 
-    CurrentEntry = CurrentEntry->Flink;
-  }
+    CurrentEntry = DeviceExtension->DeviceListHead.Flink;
+    while (CurrentEntry != &DeviceExtension->DeviceListHead)
+    {
+        CurrentDevice = CONTAINING_RECORD(CurrentEntry, PCI_DEVICE, ListEntry);
+
+        /* If both vendor ID and device ID match, it is the same device */
+        if ((PciConfig->VendorID == CurrentDevice->PciConfig.VendorID) &&
+            (PciConfig->DeviceID == CurrentDevice->PciConfig.DeviceID) &&
+            (SlotNumber.u.AsULONG == CurrentDevice->SlotNumber.u.AsULONG))
+        {
+            *Device = CurrentDevice;
+            DPRINT("Done\n");
+            return STATUS_SUCCESS;
+        }
+
+        CurrentEntry = CurrentEntry->Flink;
+    }
 
-  *Device = NULL;
-  DPRINT("Done\n");
-  return STATUS_UNSUCCESSFUL;
+    *Device = NULL;
+    DPRINT("Done\n");
+    return STATUS_UNSUCCESSFUL;
 }
 
 
 static NTSTATUS
 FdoEnumerateDevices(
-  PDEVICE_OBJECT DeviceObject)
+    PDEVICE_OBJECT DeviceObject)
 {
-  PFDO_DEVICE_EXTENSION DeviceExtension;
-  PCI_COMMON_CONFIG PciConfig;
-  PPCI_DEVICE Device;
-  PCI_SLOT_NUMBER SlotNumber;
-  ULONG DeviceNumber;
-  ULONG FunctionNumber;
-  ULONG Size;
-  NTSTATUS Status;
-
-  DPRINT("Called\n");
-
-  DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
-
-  DeviceExtension->DeviceListCount = 0;
-
-  /* Enumerate devices on the PCI bus */
-  SlotNumber.u.AsULONG = 0;
-  for (DeviceNumber = 0; DeviceNumber < PCI_MAX_DEVICES; DeviceNumber++)
-  {
-    SlotNumber.u.bits.DeviceNumber = DeviceNumber;
-    for (FunctionNumber = 0; FunctionNumber < PCI_MAX_FUNCTION; FunctionNumber++)
+    PFDO_DEVICE_EXTENSION DeviceExtension;
+    PCI_COMMON_CONFIG PciConfig;
+    PPCI_DEVICE Device;
+    PCI_SLOT_NUMBER SlotNumber;
+    ULONG DeviceNumber;
+    ULONG FunctionNumber;
+    ULONG Size;
+    NTSTATUS Status;
+
+    DPRINT("Called\n");
+
+    DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+
+    DeviceExtension->DeviceListCount = 0;
+
+    /* Enumerate devices on the PCI bus */
+    SlotNumber.u.AsULONG = 0;
+    for (DeviceNumber = 0; DeviceNumber < PCI_MAX_DEVICES; DeviceNumber++)
     {
-      SlotNumber.u.bits.FunctionNumber = FunctionNumber;
-
-      DPRINT("Bus %1lu  Device %2lu  Func %1lu\n",
-        DeviceExtension->BusNumber,
-        DeviceNumber,
-        FunctionNumber);
-
-      RtlZeroMemory(&PciConfig,
-                    sizeof(PCI_COMMON_CONFIG));
-
-      Size = HalGetBusData(PCIConfiguration,
-                           DeviceExtension->BusNumber,
-                           SlotNumber.u.AsULONG,
-                           &PciConfig,
-                           PCI_COMMON_HDR_LENGTH);
-      DPRINT("Size %lu\n", Size);
-      if (Size < PCI_COMMON_HDR_LENGTH)
-      {
-        if (FunctionNumber == 0)
-        {
-          break;
-        }
-        else
+        SlotNumber.u.bits.DeviceNumber = DeviceNumber;
+        for (FunctionNumber = 0; FunctionNumber < PCI_MAX_FUNCTION; FunctionNumber++)
         {
-          continue;
-        }
-      }
-
-      DPRINT("Bus %1lu  Device %2lu  Func %1lu  VenID 0x%04hx  DevID 0x%04hx\n",
-        DeviceExtension->BusNumber,
-        DeviceNumber,
-        FunctionNumber,
-        PciConfig.VendorID,
-        PciConfig.DeviceID);
-
-      Status = FdoLocateChildDevice(&Device, DeviceExtension, SlotNumber, &PciConfig);
-      if (!NT_SUCCESS(Status))
-      {
-        Device = (PPCI_DEVICE)ExAllocatePoolWithTag(NonPagedPool, sizeof(PCI_DEVICE),TAG_PCI);
-        if (!Device)
-        {
-          /* FIXME: Cleanup resources for already discovered devices */
-          return STATUS_INSUFFICIENT_RESOURCES;
+            SlotNumber.u.bits.FunctionNumber = FunctionNumber;
+
+            DPRINT("Bus %1lu  Device %2lu  Func %1lu\n",
+                   DeviceExtension->BusNumber,
+                   DeviceNumber,
+                   FunctionNumber);
+
+            RtlZeroMemory(&PciConfig,
+                          sizeof(PCI_COMMON_CONFIG));
+
+            Size = HalGetBusData(PCIConfiguration,
+                                 DeviceExtension->BusNumber,
+                                 SlotNumber.u.AsULONG,
+                                 &PciConfig,
+                                 PCI_COMMON_HDR_LENGTH);
+            DPRINT("Size %lu\n", Size);
+            if (Size < PCI_COMMON_HDR_LENGTH)
+            {
+                if (FunctionNumber == 0)
+                {
+                    break;
+                }
+                else
+                {
+                    continue;
+                }
+            }
+
+            DPRINT("Bus %1lu  Device %2lu  Func %1lu  VenID 0x%04hx  DevID 0x%04hx\n",
+                   DeviceExtension->BusNumber,
+                   DeviceNumber,
+                   FunctionNumber,
+                   PciConfig.VendorID,
+                   PciConfig.DeviceID);
+
+            Status = FdoLocateChildDevice(&Device, DeviceExtension, SlotNumber, &PciConfig);
+            if (!NT_SUCCESS(Status))
+            {
+                Device = (PPCI_DEVICE)ExAllocatePoolWithTag(NonPagedPool, sizeof(PCI_DEVICE),TAG_PCI);
+                if (!Device)
+                {
+                    /* FIXME: Cleanup resources for already discovered devices */
+                    return STATUS_INSUFFICIENT_RESOURCES;
+                }
+
+                RtlZeroMemory(Device,
+                              sizeof(PCI_DEVICE));
+
+                Device->BusNumber = DeviceExtension->BusNumber;
+
+                RtlCopyMemory(&Device->SlotNumber,
+                              &SlotNumber,
+                              sizeof(PCI_SLOT_NUMBER));
+
+                RtlCopyMemory(&Device->PciConfig,
+                              &PciConfig,
+                              sizeof(PCI_COMMON_CONFIG));
+
+                ExInterlockedInsertTailList(
+                    &DeviceExtension->DeviceListHead,
+                    &Device->ListEntry,
+                    &DeviceExtension->DeviceListLock);
+            }
+
+            DeviceExtension->DeviceListCount++;
+
+            /* Skip to next device if the current one is not a multifunction device */
+            if ((FunctionNumber == 0) &&
+                ((PciConfig.HeaderType & 0x80) == 0))
+            {
+                break;
+            }
         }
+    }
 
-        RtlZeroMemory(Device,
-                      sizeof(PCI_DEVICE));
+    DPRINT("Done\n");
 
-        Device->BusNumber = DeviceExtension->BusNumber;
+    return STATUS_SUCCESS;
+}
 
-        RtlCopyMemory(&Device->SlotNumber,
-                      &SlotNumber,
-                      sizeof(PCI_SLOT_NUMBER));
 
-        RtlCopyMemory(&Device->PciConfig,
-                      &PciConfig,
-                      sizeof(PCI_COMMON_CONFIG));
+static NTSTATUS
+FdoQueryBusRelations(
+    IN PDEVICE_OBJECT DeviceObject,
+    IN PIRP Irp,
+    PIO_STACK_LOCATION IrpSp)
+{
+    PPDO_DEVICE_EXTENSION PdoDeviceExtension = NULL;
+    PFDO_DEVICE_EXTENSION DeviceExtension;
+    PDEVICE_RELATIONS Relations;
+    PLIST_ENTRY CurrentEntry;
+    PPCI_DEVICE Device;
+    NTSTATUS Status;
+    BOOLEAN ErrorOccurred;
+    NTSTATUS ErrorStatus;
+    ULONG Size;
+    ULONG i;
 
-        ExInterlockedInsertTailList(
-          &DeviceExtension->DeviceListHead,
-          &Device->ListEntry,
-          &DeviceExtension->DeviceListLock);
-      }
+    UNREFERENCED_PARAMETER(IrpSp);
 
-      DeviceExtension->DeviceListCount++;
+    DPRINT("Called\n");
 
-      /* Skip to next device if the current one is not a multifunction device */
-      if ((FunctionNumber == 0) &&
-          ((PciConfig.HeaderType & 0x80) == 0))
-      {
-        break;
-      }
-    }
-  }
+    ErrorStatus = STATUS_INSUFFICIENT_RESOURCES;
 
-  DPRINT("Done\n");
+    Status = STATUS_SUCCESS;
 
-  return STATUS_SUCCESS;
-}
+    ErrorOccurred = FALSE;
 
+    FdoEnumerateDevices(DeviceObject);
 
-static NTSTATUS
-FdoQueryBusRelations(
-  IN PDEVICE_OBJECT DeviceObject,
-  IN PIRP Irp,
-  PIO_STACK_LOCATION IrpSp)
-{
-  PPDO_DEVICE_EXTENSION PdoDeviceExtension = NULL;
-  PFDO_DEVICE_EXTENSION DeviceExtension;
-  PDEVICE_RELATIONS Relations;
-  PLIST_ENTRY CurrentEntry;
-  PPCI_DEVICE Device;
-  NTSTATUS Status;
-  BOOLEAN ErrorOccurred;
-  NTSTATUS ErrorStatus;
-  ULONG Size;
-  ULONG i;
+    DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
 
-  UNREFERENCED_PARAMETER(IrpSp);
-
-  DPRINT("Called\n");
-
-  ErrorStatus = STATUS_INSUFFICIENT_RESOURCES;
-
-  Status = STATUS_SUCCESS;
-
-  ErrorOccurred = FALSE;
-
-  FdoEnumerateDevices(DeviceObject);
-
-  DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
-
-  if (Irp->IoStatus.Information) {
-    /* FIXME: Another bus driver has already created a DEVICE_RELATIONS
-              structure so we must merge this structure with our own */
-  }
-
-  Size = sizeof(DEVICE_RELATIONS) + sizeof(Relations->Objects) *
-    (DeviceExtension->DeviceListCount - 1);
-  Relations = (PDEVICE_RELATIONS)ExAllocatePool(PagedPool, Size);
-  if (!Relations)
-    return STATUS_INSUFFICIENT_RESOURCES;
-
-  Relations->Count = DeviceExtension->DeviceListCount;
-
-  i = 0;
-  CurrentEntry = DeviceExtension->DeviceListHead.Flink;
-  while (CurrentEntry != &DeviceExtension->DeviceListHead) {
-    Device = CONTAINING_RECORD(CurrentEntry, PCI_DEVICE, ListEntry);
-
-    PdoDeviceExtension = NULL;
-
-    if (!Device->Pdo) {
-      /* Create a physical device object for the
-         device as it does not already have one */
-      Status = IoCreateDevice(
-        DeviceObject->DriverObject,
-        sizeof(PDO_DEVICE_EXTENSION),
-        NULL,
-        FILE_DEVICE_CONTROLLER,
-        FILE_AUTOGENERATED_DEVICE_NAME,
-        FALSE,
-        &Device->Pdo);
-      if (!NT_SUCCESS(Status)) {
-        DPRINT("IoCreateDevice() failed with status 0x%X\n", Status);
-        ErrorStatus = Status;
-        ErrorOccurred = TRUE;
-        break;
-      }
-
-      Device->Pdo->Flags &= ~DO_DEVICE_INITIALIZING;
-
-      //Device->Pdo->Flags |= DO_POWER_PAGABLE;
-
-      PdoDeviceExtension = (PPDO_DEVICE_EXTENSION)Device->Pdo->DeviceExtension;
-
-      RtlZeroMemory(PdoDeviceExtension, sizeof(PDO_DEVICE_EXTENSION));
-
-      PdoDeviceExtension->Common.IsFDO = FALSE;
-
-      PdoDeviceExtension->Common.DeviceObject = Device->Pdo;
-
-      PdoDeviceExtension->Common.DevicePowerState = PowerDeviceD0;
-
-      PdoDeviceExtension->Fdo = DeviceObject;
-
-      PdoDeviceExtension->PciDevice = Device;
-
-      /* Add Device ID string */
-      Status = PciCreateDeviceIDString(&PdoDeviceExtension->DeviceID, Device);
-      if (!NT_SUCCESS(Status))
-      {
-        ErrorStatus = Status;
-        ErrorOccurred = TRUE;
-        break;
-      }
-
-      DPRINT("DeviceID: %S\n", PdoDeviceExtension->DeviceID.Buffer);
-
-      /* Add Instance ID string */
-      Status = PciCreateInstanceIDString(&PdoDeviceExtension->InstanceID, Device);
-      if (!NT_SUCCESS(Status))
-      {
-        ErrorStatus = Status;
-        ErrorOccurred = TRUE;
-        break;
-      }
-
-      /* Add Hardware IDs string */
-      Status = PciCreateHardwareIDsString(&PdoDeviceExtension->HardwareIDs, Device);
-      if (!NT_SUCCESS(Status))
-      {
-        ErrorStatus = Status;
-        ErrorOccurred = TRUE;
-        break;
-      }
-
-      /* Add Compatible IDs string */
-      Status = PciCreateCompatibleIDsString(&PdoDeviceExtension->CompatibleIDs, Device);
-      if (!NT_SUCCESS(Status))
-      {
-        ErrorStatus = Status;
-        ErrorOccurred = TRUE;
-        break;
-      }
-
-      /* Add device description string */
-      Status = PciCreateDeviceDescriptionString(&PdoDeviceExtension->DeviceDescription, Device);
-      if (!NT_SUCCESS(Status))
-      {
-        ErrorStatus = Status;
-        ErrorOccurred = TRUE;
-        break;
-      }
-
-      /* Add device location string */
-      Status = PciCreateDeviceLocationString(&PdoDeviceExtension->DeviceLocation, Device);
-      if (!NT_SUCCESS(Status))
-      {
-        ErrorStatus = Status;
-        ErrorOccurred = TRUE;
-        break;
-      }
+    if (Irp->IoStatus.Information)
+    {
+        /* FIXME: Another bus driver has already created a DEVICE_RELATIONS
+                  structure so we must merge this structure with our own */
     }
 
-    /* Reference the physical device object. The PnP manager
-       will dereference it again when it is no longer needed */
-    ObReferenceObject(Device->Pdo);
+    Size = sizeof(DEVICE_RELATIONS) +
+           sizeof(Relations->Objects) * (DeviceExtension->DeviceListCount - 1);
+    Relations = (PDEVICE_RELATIONS)ExAllocatePool(PagedPool, Size);
+    if (!Relations)
+        return STATUS_INSUFFICIENT_RESOURCES;
+
+    Relations->Count = DeviceExtension->DeviceListCount;
 
-    Relations->Objects[i] = Device->Pdo;
+    i = 0;
+    CurrentEntry = DeviceExtension->DeviceListHead.Flink;
+    while (CurrentEntry != &DeviceExtension->DeviceListHead)
+    {
+        Device = CONTAINING_RECORD(CurrentEntry, PCI_DEVICE, ListEntry);
+
+        PdoDeviceExtension = NULL;
+
+        if (!Device->Pdo)
+        {
+            /* Create a physical device object for the
+               device as it does not already have one */
+            Status = IoCreateDevice(DeviceObject->DriverObject,
+                                    sizeof(PDO_DEVICE_EXTENSION),
+                                    NULL,
+                                    FILE_DEVICE_CONTROLLER,
+                                    FILE_AUTOGENERATED_DEVICE_NAME,
+                                    FALSE,
+                                    &Device->Pdo);
+            if (!NT_SUCCESS(Status))
+            {
+                DPRINT("IoCreateDevice() failed with status 0x%X\n", Status);
+                ErrorStatus = Status;
+                ErrorOccurred = TRUE;
+                break;
+            }
+
+            Device->Pdo->Flags &= ~DO_DEVICE_INITIALIZING;
+
+            //Device->Pdo->Flags |= DO_POWER_PAGABLE;
+
+            PdoDeviceExtension = (PPDO_DEVICE_EXTENSION)Device->Pdo->DeviceExtension;
+
+            RtlZeroMemory(PdoDeviceExtension, sizeof(PDO_DEVICE_EXTENSION));
+
+            PdoDeviceExtension->Common.IsFDO = FALSE;
+
+            PdoDeviceExtension->Common.DeviceObject = Device->Pdo;
+
+            PdoDeviceExtension->Common.DevicePowerState = PowerDeviceD0;
+
+            PdoDeviceExtension->Fdo = DeviceObject;
+
+            PdoDeviceExtension->PciDevice = Device;
+
+            /* Add Device ID string */
+            Status = PciCreateDeviceIDString(&PdoDeviceExtension->DeviceID, Device);
+            if (!NT_SUCCESS(Status))
+            {
+                ErrorStatus = Status;
+                ErrorOccurred = TRUE;
+                break;
+            }
+
+            DPRINT("DeviceID: %S\n", PdoDeviceExtension->DeviceID.Buffer);
+
+            /* Add Instance ID string */
+            Status = PciCreateInstanceIDString(&PdoDeviceExtension->InstanceID, Device);
+            if (!NT_SUCCESS(Status))
+            {
+                ErrorStatus = Status;
+                ErrorOccurred = TRUE;
+                break;
+            }
+
+            /* Add Hardware IDs string */
+            Status = PciCreateHardwareIDsString(&PdoDeviceExtension->HardwareIDs, Device);
+            if (!NT_SUCCESS(Status))
+            {
+                ErrorStatus = Status;
+                ErrorOccurred = TRUE;
+                break;
+            }
+
+            /* Add Compatible IDs string */
+            Status = PciCreateCompatibleIDsString(&PdoDeviceExtension->CompatibleIDs, Device);
+            if (!NT_SUCCESS(Status))
+            {
+                ErrorStatus = Status;
+                ErrorOccurred = TRUE;
+                break;
+            }
+
+             /* Add device description string */
+            Status = PciCreateDeviceDescriptionString(&PdoDeviceExtension->DeviceDescription, Device);
+            if (!NT_SUCCESS(Status))
+            {
+                ErrorStatus = Status;
+                ErrorOccurred = TRUE;
+                break;
+            }
+
+            /* Add device location string */
+            Status = PciCreateDeviceLocationString(&PdoDeviceExtension->DeviceLocation, Device);
+            if (!NT_SUCCESS(Status))
+            {
+                ErrorStatus = Status;
+                ErrorOccurred = TRUE;
+                break;
+            }
+        }
+
+        /* Reference the physical device object. The PnP manager
+           will dereference it again when it is no longer needed */
+        ObReferenceObject(Device->Pdo);
 
-    i++;
+        Relations->Objects[i] = Device->Pdo;
 
-    CurrentEntry = CurrentEntry->Flink;
-  }
+        i++;
 
-  if (ErrorOccurred) {
-    /* FIXME: Cleanup all new PDOs created in this call. Please give me SEH!!! ;-) */
-    /* FIXME: Should IoAttachDeviceToDeviceStack() be undone? */
-    if (PdoDeviceExtension) {
-      RtlFreeUnicodeString(&PdoDeviceExtension->DeviceID);
-      RtlFreeUnicodeString(&PdoDeviceExtension->InstanceID);
-      RtlFreeUnicodeString(&PdoDeviceExtension->HardwareIDs);
-      RtlFreeUnicodeString(&PdoDeviceExtension->CompatibleIDs);
-      RtlFreeUnicodeString(&PdoDeviceExtension->DeviceDescription);
-      RtlFreeUnicodeString(&PdoDeviceExtension->DeviceLocation);
+        CurrentEntry = CurrentEntry->Flink;
     }
 
-    ExFreePool(Relations);
-    return ErrorStatus;
-  }
+    if (ErrorOccurred)
+    {
+        /* FIXME: Cleanup all new PDOs created in this call. Please give me SEH!!! ;-) */
+        /* FIXME: Should IoAttachDeviceToDeviceStack() be undone? */
+        if (PdoDeviceExtension)
+        {
+            RtlFreeUnicodeString(&PdoDeviceExtension->DeviceID);
+            RtlFreeUnicodeString(&PdoDeviceExtension->InstanceID);
+            RtlFreeUnicodeString(&PdoDeviceExtension->HardwareIDs);
+            RtlFreeUnicodeString(&PdoDeviceExtension->CompatibleIDs);
+            RtlFreeUnicodeString(&PdoDeviceExtension->DeviceDescription);
+            RtlFreeUnicodeString(&PdoDeviceExtension->DeviceLocation);
+        }
+
+        ExFreePool(Relations);
+        return ErrorStatus;
+    }
 
-  Irp->IoStatus.Information = (ULONG_PTR)Relations;
+    Irp->IoStatus.Information = (ULONG_PTR)Relations;
 
-  DPRINT("Done\n");
+    DPRINT("Done\n");
 
-  return Status;
+    return Status;
 }
 
 
 static NTSTATUS
 FdoStartDevice(
-  IN PDEVICE_OBJECT DeviceObject,
-  IN PIRP Irp)
+    IN PDEVICE_OBJECT DeviceObject,
+    IN PIRP Irp)
 {
-  PFDO_DEVICE_EXTENSION DeviceExtension;
-  PCM_RESOURCE_LIST AllocatedResources;
-  PCM_PARTIAL_RESOURCE_DESCRIPTOR ResourceDescriptor;
-  ULONG FoundBusNumber = FALSE;
-  ULONG i;
-
-  DPRINT("Called\n");
-
-  DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
-
-  AllocatedResources = IoGetCurrentIrpStackLocation(Irp)->Parameters.StartDevice.AllocatedResources;
-  if (!AllocatedResources)
-  {
-    DPRINT("No allocated resources sent to driver\n");
-    return STATUS_INSUFFICIENT_RESOURCES;
-  }
-  if (AllocatedResources->Count < 1)
-  {
-    DPRINT("Not enough allocated resources sent to driver\n");
-    return STATUS_INSUFFICIENT_RESOURCES;
-  }
-  if (AllocatedResources->List[0].PartialResourceList.Version != 1
-    || AllocatedResources->List[0].PartialResourceList.Revision != 1)
-    return STATUS_REVISION_MISMATCH;
-
-  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];
-    switch (ResourceDescriptor->Type)
+    PFDO_DEVICE_EXTENSION DeviceExtension;
+    PCM_RESOURCE_LIST AllocatedResources;
+    PCM_PARTIAL_RESOURCE_DESCRIPTOR ResourceDescriptor;
+    ULONG FoundBusNumber = FALSE;
+    ULONG i;
+
+    DPRINT("Called\n");
+
+    DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+
+    AllocatedResources = IoGetCurrentIrpStackLocation(Irp)->Parameters.StartDevice.AllocatedResources;
+    if (!AllocatedResources)
+    {
+        DPRINT("No allocated resources sent to driver\n");
+        return STATUS_INSUFFICIENT_RESOURCES;
+    }
+
+    if (AllocatedResources->Count < 1)
+    {
+        DPRINT("Not enough allocated resources sent to driver\n");
+        return STATUS_INSUFFICIENT_RESOURCES;
+    }
+
+    if (AllocatedResources->List[0].PartialResourceList.Version != 1 ||
+        AllocatedResources->List[0].PartialResourceList.Revision != 1)
+        return STATUS_REVISION_MISMATCH;
+
+    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++)
     {
-      case CmResourceTypeBusNumber:
-      {
-        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;
-        break;
-      }
-      default:
-        DPRINT("Unknown resource descriptor type 0x%x\n", ResourceDescriptor->Type);
+        ResourceDescriptor = &AllocatedResources->List[0].PartialResourceList.PartialDescriptors[i];
+        switch (ResourceDescriptor->Type)
+        {
+            case CmResourceTypeBusNumber:
+                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;
+                break;
+
+            default:
+                DPRINT("Unknown resource descriptor type 0x%x\n", ResourceDescriptor->Type);
+        }
     }
-  }
 
-  InitializeListHead(&DeviceExtension->DeviceListHead);
-  KeInitializeSpinLock(&DeviceExtension->DeviceListLock);
-  DeviceExtension->DeviceListCount = 0;
-  DeviceExtension->State = dsStarted;
+    InitializeListHead(&DeviceExtension->DeviceListHead);
+    KeInitializeSpinLock(&DeviceExtension->DeviceListLock);
+    DeviceExtension->DeviceListCount = 0;
+    DeviceExtension->State = dsStarted;
 
-  ExInterlockedInsertTailList(
-    &DriverExtension->BusListHead,
-    &DeviceExtension->ListEntry,
-    &DriverExtension->BusListLock);
+    ExInterlockedInsertTailList(
+        &DriverExtension->BusListHead,
+        &DeviceExtension->ListEntry,
+        &DriverExtension->BusListLock);
 
   Irp->IoStatus.Information = 0;
 
@@ -450,25 +459,28 @@ FdoStartDevice(
 
 static NTSTATUS
 FdoSetPower(
-  IN PDEVICE_OBJECT DeviceObject,
-  IN PIRP Irp,
-  PIO_STACK_LOCATION IrpSp)
+    IN PDEVICE_OBJECT DeviceObject,
+    IN PIRP Irp,
+    PIO_STACK_LOCATION IrpSp)
 {
-  NTSTATUS Status;
+    NTSTATUS Status;
 
-  UNREFERENCED_PARAMETER(DeviceObject);
-  UNREFERENCED_PARAMETER(Irp);
+    UNREFERENCED_PARAMETER(DeviceObject);
+    UNREFERENCED_PARAMETER(Irp);
 
-  DPRINT("Called\n");
+    DPRINT("Called\n");
 
-  if (IrpSp->Parameters.Power.Type == DevicePowerState) {
-    /* FIXME: Set device power state for the device */
-    Status = STATUS_UNSUCCESSFUL;
-  } else {
-    Status = STATUS_UNSUCCESSFUL;
-  }
+    if (IrpSp->Parameters.Power.Type == DevicePowerState)
+    {
+        /* FIXME: Set device power state for the device */
+        Status = STATUS_UNSUCCESSFUL;
+    }
+    else
+    {
+        Status = STATUS_UNSUCCESSFUL;
+    }
 
-  return Status;
+    return Status;
 }
 
 
@@ -476,8 +488,8 @@ FdoSetPower(
 
 NTSTATUS
 FdoPnpControl(
-  PDEVICE_OBJECT DeviceObject,
-  PIRP Irp)
+    PDEVICE_OBJECT DeviceObject,
+    PIRP Irp)
 /*
  * FUNCTION: Handle Plug and Play IRPs for the PCI device object
  * ARGUMENTS:
@@ -487,106 +499,110 @@ FdoPnpControl(
  *     Status
  */
 {
-  PFDO_DEVICE_EXTENSION DeviceExtension;
-  PIO_STACK_LOCATION IrpSp;
-  NTSTATUS Status = Irp->IoStatus.Status;
+    PFDO_DEVICE_EXTENSION DeviceExtension;
+    PIO_STACK_LOCATION IrpSp;
+    NTSTATUS Status = Irp->IoStatus.Status;
 
-  DPRINT("Called\n");
+    DPRINT("Called\n");
 
-  DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+    DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
 
-  IrpSp = IoGetCurrentIrpStackLocation(Irp);
-  switch (IrpSp->MinorFunction) {
+    IrpSp = IoGetCurrentIrpStackLocation(Irp);
+    switch (IrpSp->MinorFunction)
+    {
 #if 0
-  case IRP_MN_CANCEL_REMOVE_DEVICE:
-    Status = STATUS_NOT_IMPLEMENTED;
-    break;
+        case IRP_MN_CANCEL_REMOVE_DEVICE:
+            Status = STATUS_NOT_IMPLEMENTED;
+            break;
 
-  case IRP_MN_CANCEL_STOP_DEVICE:
-    Status = STATUS_NOT_IMPLEMENTED;
-    break;
+        case IRP_MN_CANCEL_STOP_DEVICE:
+            Status = STATUS_NOT_IMPLEMENTED;
+            break;
 
-  case IRP_MN_DEVICE_USAGE_NOTIFICATION:
-    Status = STATUS_NOT_IMPLEMENTED;
-    break;
+        case IRP_MN_DEVICE_USAGE_NOTIFICATION:
+            Status = STATUS_NOT_IMPLEMENTED;
+            break;
 
-  case IRP_MN_FILTER_RESOURCE_REQUIREMENTS:
-    Status = STATUS_NOT_IMPLEMENTED;
-    break;
+        case IRP_MN_FILTER_RESOURCE_REQUIREMENTS:
+            Status = STATUS_NOT_IMPLEMENTED;
+            break;
 #endif
-  case IRP_MN_QUERY_DEVICE_RELATIONS:
-    if (IrpSp->Parameters.QueryDeviceRelations.Type != BusRelations)
-        break;
-
-    Status = FdoQueryBusRelations(DeviceObject, Irp, IrpSp);
-    Irp->IoStatus.Status = Status;
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-    return Status;
+        case IRP_MN_QUERY_DEVICE_RELATIONS:
+            if (IrpSp->Parameters.QueryDeviceRelations.Type != BusRelations)
+                break;
+
+            Status = FdoQueryBusRelations(DeviceObject, Irp, IrpSp);
+            Irp->IoStatus.Status = Status;
+            IoCompleteRequest(Irp, IO_NO_INCREMENT);
+            return Status;
 #if 0
-  case IRP_MN_QUERY_PNP_DEVICE_STATE:
-    Status = STATUS_NOT_IMPLEMENTED;
-    break;
+        case IRP_MN_QUERY_PNP_DEVICE_STATE:
+            Status = STATUS_NOT_IMPLEMENTED;
+            break;
 
-  case IRP_MN_QUERY_REMOVE_DEVICE:
-    Status = STATUS_NOT_IMPLEMENTED;
-    break;
+        case IRP_MN_QUERY_REMOVE_DEVICE:
+            Status = STATUS_NOT_IMPLEMENTED;
+            break;
 #endif
-  case IRP_MN_START_DEVICE:
-    DPRINT("IRP_MN_START_DEVICE received\n");
-    Status = ForwardIrpAndWait(DeviceObject, Irp);
-    if (NT_SUCCESS(Status))
-       Status = FdoStartDevice(DeviceObject, Irp);
-
-    Irp->IoStatus.Status = Status;
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-    return Status;
-
-  case IRP_MN_QUERY_STOP_DEVICE:
-    /* We don't support stopping yet */
-    Status = STATUS_UNSUCCESSFUL;
-    Irp->IoStatus.Status = Status;
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-    return Status;
-    
-  case IRP_MN_STOP_DEVICE:
-    /* We can't fail this one so we fail the QUERY_STOP request that precedes it */
-    break;
+        case IRP_MN_START_DEVICE:
+            DPRINT("IRP_MN_START_DEVICE received\n");
+            Status = ForwardIrpAndWait(DeviceObject, Irp);
+            if (NT_SUCCESS(Status))
+                Status = FdoStartDevice(DeviceObject, Irp);
+
+            Irp->IoStatus.Status = Status;
+            IoCompleteRequest(Irp, IO_NO_INCREMENT);
+            return Status;
+
+        case IRP_MN_QUERY_STOP_DEVICE:
+            /* We don't support stopping yet */
+            Status = STATUS_UNSUCCESSFUL;
+            Irp->IoStatus.Status = Status;
+            IoCompleteRequest(Irp, IO_NO_INCREMENT);
+            return Status;
+
+        case IRP_MN_STOP_DEVICE:
+            /* We can't fail this one so we fail the QUERY_STOP request that precedes it */
+            break;
 #if 0
-  case IRP_MN_SURPRISE_REMOVAL:
-    Status = STATUS_NOT_IMPLEMENTED;
-    break;
+        case IRP_MN_SURPRISE_REMOVAL:
+            Status = STATUS_NOT_IMPLEMENTED;
+            break;
 #endif
-  case IRP_MN_FILTER_RESOURCE_REQUIREMENTS:
-    break;
-  case IRP_MN_REMOVE_DEVICE:
-    /* Detach the device object from the device stack */
-    IoDetachDevice(DeviceExtension->Ldo);
 
-    /* Delete the device object */
-    IoDeleteDevice(DeviceObject);
+        case IRP_MN_FILTER_RESOURCE_REQUIREMENTS:
+            break;
 
-    /* Return success */
-    Status = STATUS_SUCCESS;
-    break;
-  default:
-    DPRINT1("Unknown IOCTL 0x%lx\n", IrpSp->MinorFunction);
-    break;
-  }
+        case IRP_MN_REMOVE_DEVICE:
+            /* Detach the device object from the device stack */
+            IoDetachDevice(DeviceExtension->Ldo);
+
+            /* Delete the device object */
+            IoDeleteDevice(DeviceObject);
+
+            /* Return success */
+            Status = STATUS_SUCCESS;
+            break;
 
-  Irp->IoStatus.Status = Status;
-  IoSkipCurrentIrpStackLocation(Irp);
-  Status = IoCallDriver(DeviceExtension->Ldo, Irp);
+        default:
+            DPRINT1("Unknown IOCTL 0x%lx\n", IrpSp->MinorFunction);
+            break;
+    }
+
+    Irp->IoStatus.Status = Status;
+    IoSkipCurrentIrpStackLocation(Irp);
+    Status = IoCallDriver(DeviceExtension->Ldo, Irp);
 
-  DPRINT("Leaving. Status 0x%X\n", Status);
+    DPRINT("Leaving. Status 0x%X\n", Status);
 
-  return Status;
+    return Status;
 }
 
 
 NTSTATUS
 FdoPowerControl(
-  PDEVICE_OBJECT DeviceObject,
-  PIRP Irp)
+    PDEVICE_OBJECT DeviceObject,
+    PIRP Irp)
 /*
  * FUNCTION: Handle power management IRPs for the PCI device object
  * ARGUMENTS:
@@ -596,32 +612,34 @@ FdoPowerControl(
  *     Status
  */
 {
-  PIO_STACK_LOCATION IrpSp;
-  NTSTATUS Status;
-
-  DPRINT("Called\n");
+    PIO_STACK_LOCATION IrpSp;
+    NTSTATUS Status;
 
-  IrpSp = IoGetCurrentIrpStackLocation(Irp);
+    DPRINT("Called\n");
 
-  switch (IrpSp->MinorFunction) {
-  case IRP_MN_SET_POWER:
-    Status = FdoSetPower(DeviceObject, Irp, IrpSp);
-    break;
+    IrpSp = IoGetCurrentIrpStackLocation(Irp);
 
-  default:
-    DPRINT("Unknown IOCTL 0x%X\n", IrpSp->MinorFunction);
-    Status = STATUS_NOT_IMPLEMENTED;
-    break;
-  }
+    switch (IrpSp->MinorFunction)
+    {
+        case IRP_MN_SET_POWER:
+            Status = FdoSetPower(DeviceObject, Irp, IrpSp);
+            break;
+
+        default:
+            DPRINT("Unknown IOCTL 0x%X\n", IrpSp->MinorFunction);
+            Status = STATUS_NOT_IMPLEMENTED;
+            break;
+    }
 
-  if (Status != STATUS_PENDING) {
-    Irp->IoStatus.Status = Status;
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-  }
+    if (Status != STATUS_PENDING)
+    {
+        Irp->IoStatus.Status = Status;
+        IoCompleteRequest(Irp, IO_NO_INCREMENT);
+    }
 
-  DPRINT("Leaving. Status 0x%X\n", Status);
+    DPRINT("Leaving. Status 0x%X\n", Status);
 
-  return Status;
+    return Status;
 }
 
 /* EOF */
index f953a9d..6d28f01 100644 (file)
@@ -46,44 +46,46 @@ PPCI_DRIVER_EXTENSION DriverExtension = NULL;
 static NTSTATUS
 NTAPI
 PciDispatchDeviceControl(
-  IN PDEVICE_OBJECT DeviceObject,
-  IN PIRP Irp)
+    IN PDEVICE_OBJECT DeviceObject,
+    IN PIRP Irp)
 {
-  PIO_STACK_LOCATION IrpSp;
-  NTSTATUS Status;
+    PIO_STACK_LOCATION IrpSp;
+    NTSTATUS Status;
 
-  UNREFERENCED_PARAMETER(DeviceObject);
-  DPRINT("Called. IRP is at (0x%p)\n", Irp);
+    UNREFERENCED_PARAMETER(DeviceObject);
+    DPRINT("Called. IRP is at (0x%p)\n", Irp);
 
-  Irp->IoStatus.Information = 0;
+    Irp->IoStatus.Information = 0;
 
-  IrpSp = IoGetCurrentIrpStackLocation(Irp);
-  switch (IrpSp->Parameters.DeviceIoControl.IoControlCode) {
-  default:
-    DPRINT("Unknown IOCTL 0x%X\n", IrpSp->Parameters.DeviceIoControl.IoControlCode);
-    Status = STATUS_NOT_IMPLEMENTED;
-    break;
-  }
+    IrpSp = IoGetCurrentIrpStackLocation(Irp);
+    switch (IrpSp->Parameters.DeviceIoControl.IoControlCode)
+    {
+        default:
+            DPRINT("Unknown IOCTL 0x%X\n", IrpSp->Parameters.DeviceIoControl.IoControlCode);
+            Status = STATUS_NOT_IMPLEMENTED;
+            break;
+    }
 
-  if (Status != STATUS_PENDING) {
-    Irp->IoStatus.Status = Status;
+    if (Status != STATUS_PENDING)
+    {
+        Irp->IoStatus.Status = Status;
 
-    DPRINT("Completing IRP at 0x%p\n", Irp);
+        DPRINT("Completing IRP at 0x%p\n", Irp);
 
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-  }
+        IoCompleteRequest(Irp, IO_NO_INCREMENT);
+    }
 
-  DPRINT("Leaving. Status 0x%X\n", Status);
+    DPRINT("Leaving. Status 0x%X\n", Status);
 
-  return Status;
+    return Status;
 }
 
 
 static NTSTATUS
 NTAPI
 PciPnpControl(
-  IN PDEVICE_OBJECT DeviceObject,
-  IN PIRP Irp)
+    IN PDEVICE_OBJECT DeviceObject,
+    IN PIRP Irp)
 /*
  * FUNCTION: Handle Plug and Play IRPs
  * ARGUMENTS:
@@ -93,28 +95,31 @@ PciPnpControl(
  *     Status
  */
 {
-  PCOMMON_DEVICE_EXTENSION DeviceExtension;
-  NTSTATUS Status;
+    PCOMMON_DEVICE_EXTENSION DeviceExtension;
+    NTSTATUS Status;
 
-  DeviceExtension = (PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+    DeviceExtension = (PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
 
-  DPRINT("IsFDO %u\n", DeviceExtension->IsFDO);
+    DPRINT("IsFDO %u\n", DeviceExtension->IsFDO);
 
-  if (DeviceExtension->IsFDO) {
-    Status = FdoPnpControl(DeviceObject, Irp);
-  } else {
-    Status = PdoPnpControl(DeviceObject, Irp);
-  }
+    if (DeviceExtension->IsFDO)
+    {
+        Status = FdoPnpControl(DeviceObject, Irp);
+    }
+    else
+    {
+        Status = PdoPnpControl(DeviceObject, Irp);
+    }
 
-  return Status;
+    return Status;
 }
 
 
 static NTSTATUS
 NTAPI
 PciPowerControl(
-  IN PDEVICE_OBJECT DeviceObject,
-  IN PIRP Irp)
+    IN PDEVICE_OBJECT DeviceObject,
+    IN PIRP Irp)
 /*
  * FUNCTION: Handle power management IRPs
  * ARGUMENTS:
@@ -124,60 +129,69 @@ PciPowerControl(
  *     Status
  */
 {
-  PCOMMON_DEVICE_EXTENSION DeviceExtension;
-  NTSTATUS Status;
+    PCOMMON_DEVICE_EXTENSION DeviceExtension;
+    NTSTATUS Status;
 
-  DeviceExtension = (PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+    DeviceExtension = (PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
 
-  if (DeviceExtension->IsFDO) {
-    Status = FdoPowerControl(DeviceObject, Irp);
-  } else {
-    Status = PdoPowerControl(DeviceObject, Irp);
-  }
+    if (DeviceExtension->IsFDO)
+    {
+        Status = FdoPowerControl(DeviceObject, Irp);
+    }
+    else
+    {
+        Status = PdoPowerControl(DeviceObject, Irp);
+    }
 
-  return Status;
+    return Status;
 }
 
 
 static NTSTATUS
 NTAPI
 PciAddDevice(
-  IN PDRIVER_OBJECT DriverObject,
-  IN PDEVICE_OBJECT PhysicalDeviceObject)
+    IN PDRIVER_OBJECT DriverObject,
+    IN PDEVICE_OBJECT PhysicalDeviceObject)
 {
-  PFDO_DEVICE_EXTENSION DeviceExtension;
-  PDEVICE_OBJECT Fdo;
-  NTSTATUS Status;
-
-  DPRINT("Called\n");
-  if (PhysicalDeviceObject == NULL)
-    return STATUS_SUCCESS;
-
-  Status = IoCreateDevice(DriverObject, sizeof(FDO_DEVICE_EXTENSION),
-    NULL, FILE_DEVICE_BUS_EXTENDER, FILE_DEVICE_SECURE_OPEN, TRUE, &Fdo);
-  if (!NT_SUCCESS(Status)) {
-    DPRINT("IoCreateDevice() failed with status 0x%X\n", Status);
-    return Status;
-  }
+    PFDO_DEVICE_EXTENSION DeviceExtension;
+    PDEVICE_OBJECT Fdo;
+    NTSTATUS Status;
+
+    DPRINT("Called\n");
+    if (PhysicalDeviceObject == NULL)
+        return STATUS_SUCCESS;
+
+    Status = IoCreateDevice(DriverObject,
+                            sizeof(FDO_DEVICE_EXTENSION),
+                            NULL,
+                            FILE_DEVICE_BUS_EXTENDER,
+                            FILE_DEVICE_SECURE_OPEN,
+                            TRUE,
+                            &Fdo);
+    if (!NT_SUCCESS(Status))
+    {
+        DPRINT("IoCreateDevice() failed with status 0x%X\n", Status);
+        return Status;
+    }
 
-  DeviceExtension = (PFDO_DEVICE_EXTENSION)Fdo->DeviceExtension;
+    DeviceExtension = (PFDO_DEVICE_EXTENSION)Fdo->DeviceExtension;
 
-  RtlZeroMemory(DeviceExtension, sizeof(FDO_DEVICE_EXTENSION));
+    RtlZeroMemory(DeviceExtension, sizeof(FDO_DEVICE_EXTENSION));
 
-  DeviceExtension->Common.IsFDO = TRUE;
+    DeviceExtension->Common.IsFDO = TRUE;
 
-  DeviceExtension->Ldo =
-    IoAttachDeviceToDeviceStack(Fdo, PhysicalDeviceObject);
+    DeviceExtension->Ldo = IoAttachDeviceToDeviceStack(Fdo,
+                                                       PhysicalDeviceObject);
 
-  DeviceExtension->State = dsStopped;
+    DeviceExtension->State = dsStopped;
 
-  Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
+    Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
 
-  //Fdo->Flags |= DO_POWER_PAGABLE;
+    //Fdo->Flags |= DO_POWER_PAGABLE;
 
-  DPRINT("Done AddDevice\n");
+    DPRINT("Done AddDevice\n");
 
-  return STATUS_SUCCESS;
+    return STATUS_SUCCESS;
 }
 
 DRIVER_UNLOAD PciUnload;
@@ -185,7 +199,7 @@ DRIVER_UNLOAD PciUnload;
 VOID
 NTAPI
 PciUnload(
-  IN PDRIVER_OBJECT DriverObject)
+    IN PDRIVER_OBJECT DriverObject)
 {
     /* The driver object extension is destroyed by the I/O manager */
     UNREFERENCED_PARAMETER(DriverObject);
@@ -194,33 +208,33 @@ PciUnload(
 NTSTATUS
 NTAPI
 DriverEntry(
-  IN PDRIVER_OBJECT DriverObject,
-  IN PUNICODE_STRING RegistryPath)
+    IN PDRIVER_OBJECT DriverObject,
+    IN PUNICODE_STRING RegistryPath)
 {
-  NTSTATUS Status;
-
-  UNREFERENCED_PARAMETER(RegistryPath);
-  DPRINT("Peripheral Component Interconnect Bus Driver\n");
-
-  DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = PciDispatchDeviceControl;
-  DriverObject->MajorFunction[IRP_MJ_PNP] = PciPnpControl;
-  DriverObject->MajorFunction[IRP_MJ_POWER] = PciPowerControl;
-  DriverObject->DriverExtension->AddDevice = PciAddDevice;
-  DriverObject->DriverUnload = PciUnload;
-
-  Status = IoAllocateDriverObjectExtension(
-    DriverObject,
-    DriverObject,
-    sizeof(PCI_DRIVER_EXTENSION),
-    (PVOID*)&DriverExtension);
-  if (!NT_SUCCESS(Status))
-    return Status;
-  RtlZeroMemory(DriverExtension, sizeof(PCI_DRIVER_EXTENSION));
+    NTSTATUS Status;
+
+    UNREFERENCED_PARAMETER(RegistryPath);
+    DPRINT("Peripheral Component Interconnect Bus Driver\n");
+
+    DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = PciDispatchDeviceControl;
+    DriverObject->MajorFunction[IRP_MJ_PNP] = PciPnpControl;
+    DriverObject->MajorFunction[IRP_MJ_POWER] = PciPowerControl;
+    DriverObject->DriverExtension->AddDevice = PciAddDevice;
+    DriverObject->DriverUnload = PciUnload;
 
-  InitializeListHead(&DriverExtension->BusListHead);
-  KeInitializeSpinLock(&DriverExtension->BusListLock);
+    Status = IoAllocateDriverObjectExtension(DriverObject,
+                                             DriverObject,
+                                             sizeof(PCI_DRIVER_EXTENSION),
+                                             (PVOID*)&DriverExtension);
+    if (!NT_SUCCESS(Status))
+        return Status;
 
-  return STATUS_SUCCESS;
+    RtlZeroMemory(DriverExtension, sizeof(PCI_DRIVER_EXTENSION));
+
+    InitializeListHead(&DriverExtension->BusListHead);
+    KeInitializeSpinLock(&DriverExtension->BusListLock);
+
+    return STATUS_SUCCESS;
 }
 
 
@@ -228,17 +242,17 @@ NTSTATUS
 PciCreateDeviceIDString(PUNICODE_STRING DeviceID,
                         PPCI_DEVICE Device)
 {
-  WCHAR Buffer[256];
+    WCHAR Buffer[256];
 
-  swprintf(Buffer,
-           L"PCI\\VEN_%04X&DEV_%04X&SUBSYS_%08X&REV_%02X",
-           Device->PciConfig.VendorID,
-           Device->PciConfig.DeviceID,
-           (Device->PciConfig.u.type0.SubSystemID << 16) +
-           Device->PciConfig.u.type0.SubVendorID,
-           Device->PciConfig.RevisionID);
+    swprintf(Buffer,
+             L"PCI\\VEN_%04X&DEV_%04X&SUBSYS_%08X&REV_%02X",
+             Device->PciConfig.VendorID,
+             Device->PciConfig.DeviceID,
+             (Device->PciConfig.u.type0.SubSystemID << 16) +
+             Device->PciConfig.u.type0.SubVendorID,
+             Device->PciConfig.RevisionID);
 
-  return RtlCreateUnicodeString(DeviceID, Buffer) ? STATUS_SUCCESS : STATUS_INSUFFICIENT_RESOURCES;
+    return RtlCreateUnicodeString(DeviceID, Buffer) ? STATUS_SUCCESS : STATUS_INSUFFICIENT_RESOURCES;
 }
 
 
@@ -246,11 +260,11 @@ NTSTATUS
 PciCreateInstanceIDString(PUNICODE_STRING InstanceID,
                           PPCI_DEVICE Device)
 {
-  WCHAR Buffer[3];
+    WCHAR Buffer[3];
 
-  swprintf(Buffer, L"%02X", Device->SlotNumber.u.AsULONG & 0xff);
+    swprintf(Buffer, L"%02X", Device->SlotNumber.u.AsULONG & 0xff);
 
-  return RtlCreateUnicodeString(InstanceID, Buffer) ? STATUS_SUCCESS : STATUS_INSUFFICIENT_RESOURCES;
+    return RtlCreateUnicodeString(InstanceID, Buffer) ? STATUS_SUCCESS : STATUS_INSUFFICIENT_RESOURCES;
 }
 
 
@@ -258,51 +272,51 @@ NTSTATUS
 PciCreateHardwareIDsString(PUNICODE_STRING HardwareIDs,
                            PPCI_DEVICE Device)
 {
-  WCHAR Buffer[256];
-  UNICODE_STRING BufferU;
-  ULONG Index;
-
-  Index = 0;
-  Index += swprintf(&Buffer[Index],
-           L"PCI\\VEN_%04X&DEV_%04X&SUBSYS_%08X&REV_%02X",
-           Device->PciConfig.VendorID,
-           Device->PciConfig.DeviceID,
-           (Device->PciConfig.u.type0.SubSystemID << 16) +
-           Device->PciConfig.u.type0.SubVendorID,
-           Device->PciConfig.RevisionID);
-  Index++;
-
-  Index += swprintf(&Buffer[Index],
-           L"PCI\\VEN_%04X&DEV_%04X&SUBSYS_%08X",
-           Device->PciConfig.VendorID,
-           Device->PciConfig.DeviceID,
-           (Device->PciConfig.u.type0.SubSystemID << 16) +
-           Device->PciConfig.u.type0.SubVendorID);
-  Index++;
-
-  Index += swprintf(&Buffer[Index],
-           L"PCI\\VEN_%04X&DEV_%04X&CC_%02X%02X%02X",
-           Device->PciConfig.VendorID,
-           Device->PciConfig.DeviceID,
-           Device->PciConfig.BaseClass,
-           Device->PciConfig.SubClass,
-           Device->PciConfig.ProgIf);
-  Index++;
-
-  Index += swprintf(&Buffer[Index],
-           L"PCI\\VEN_%04X&DEV_%04X&CC_%02X%02X",
-           Device->PciConfig.VendorID,
-           Device->PciConfig.DeviceID,
-           Device->PciConfig.BaseClass,
-           Device->PciConfig.SubClass);
-  Index++;
-
-  Buffer[Index] = UNICODE_NULL;
-
-  BufferU.Length = BufferU.MaximumLength = (USHORT) Index * sizeof(WCHAR);
-  BufferU.Buffer = Buffer;
-
-  return PciDuplicateUnicodeString(0, &BufferU, HardwareIDs);
+    WCHAR Buffer[256];
+    UNICODE_STRING BufferU;
+    ULONG Index;
+
+    Index = 0;
+    Index += swprintf(&Buffer[Index],
+                      L"PCI\\VEN_%04X&DEV_%04X&SUBSYS_%08X&REV_%02X",
+                      Device->PciConfig.VendorID,
+                      Device->PciConfig.DeviceID,
+                      (Device->PciConfig.u.type0.SubSystemID << 16) +
+                      Device->PciConfig.u.type0.SubVendorID,
+                      Device->PciConfig.RevisionID);
+    Index++;
+
+    Index += swprintf(&Buffer[Index],
+                      L"PCI\\VEN_%04X&DEV_%04X&SUBSYS_%08X",
+                      Device->PciConfig.VendorID,
+                      Device->PciConfig.DeviceID,
+                      (Device->PciConfig.u.type0.SubSystemID << 16) +
+                      Device->PciConfig.u.type0.SubVendorID);
+    Index++;
+
+    Index += swprintf(&Buffer[Index],
+                      L"PCI\\VEN_%04X&DEV_%04X&CC_%02X%02X%02X",
+                      Device->PciConfig.VendorID,
+                      Device->PciConfig.DeviceID,
+                      Device->PciConfig.BaseClass,
+                      Device->PciConfig.SubClass,
+                      Device->PciConfig.ProgIf);
+    Index++;
+
+    Index += swprintf(&Buffer[Index],
+                      L"PCI\\VEN_%04X&DEV_%04X&CC_%02X%02X",
+                      Device->PciConfig.VendorID,
+                      Device->PciConfig.DeviceID,
+                      Device->PciConfig.BaseClass,
+                      Device->PciConfig.SubClass);
+    Index++;
+
+    Buffer[Index] = UNICODE_NULL;
+
+    BufferU.Length = BufferU.MaximumLength = (USHORT) Index * sizeof(WCHAR);
+    BufferU.Buffer = Buffer;
+
+    return PciDuplicateUnicodeString(0, &BufferU, HardwareIDs);
 }
 
 
@@ -310,63 +324,63 @@ NTSTATUS
 PciCreateCompatibleIDsString(PUNICODE_STRING CompatibleIDs,
                              PPCI_DEVICE Device)
 {
-  WCHAR Buffer[256];
-  UNICODE_STRING BufferU;
-  ULONG Index;
-
-  Index = 0;
-  Index += swprintf(&Buffer[Index],
-           L"PCI\\VEN_%04X&DEV_%04X&REV_%02X",
-           Device->PciConfig.VendorID,
-           Device->PciConfig.DeviceID,
-           Device->PciConfig.RevisionID);
-  Index++;
-
-  Index += swprintf(&Buffer[Index],
-           L"PCI\\VEN_%04X&DEV_%04X",
-           Device->PciConfig.VendorID,
-           Device->PciConfig.DeviceID);
-  Index++;
-
-  Index += swprintf(&Buffer[Index],
-           L"PCI\\VEN_%04X&CC_%02X%02X%02X",
-           Device->PciConfig.VendorID,
-           Device->PciConfig.BaseClass,
-           Device->PciConfig.SubClass,
-           Device->PciConfig.ProgIf);
-  Index++;
-
-  Index += swprintf(&Buffer[Index],
-           L"PCI\\VEN_%04X&CC_%02X%02X",
-           Device->PciConfig.VendorID,
-           Device->PciConfig.BaseClass,
-           Device->PciConfig.SubClass);
-  Index++;
-
-  Index += swprintf(&Buffer[Index],
-           L"PCI\\VEN_%04X",
-           Device->PciConfig.VendorID);
-  Index++;
-
-  Index += swprintf(&Buffer[Index],
-           L"PCI\\CC_%02X%02X%02X",
-           Device->PciConfig.BaseClass,
-           Device->PciConfig.SubClass,
-           Device->PciConfig.ProgIf);
-  Index++;
-
-  Index += swprintf(&Buffer[Index],
-           L"PCI\\CC_%02X%02X",
-           Device->PciConfig.BaseClass,
-           Device->PciConfig.SubClass);
-  Index++;
-
-  Buffer[Index] = UNICODE_NULL;
-
-  BufferU.Length = BufferU.MaximumLength = (USHORT)Index * sizeof(WCHAR);
-  BufferU.Buffer = Buffer;
-
-  return PciDuplicateUnicodeString(0, &BufferU, CompatibleIDs);
+    WCHAR Buffer[256];
+    UNICODE_STRING BufferU;
+    ULONG Index;
+
+    Index = 0;
+    Index += swprintf(&Buffer[Index],
+                      L"PCI\\VEN_%04X&DEV_%04X&REV_%02X",
+                      Device->PciConfig.VendorID,
+                      Device->PciConfig.DeviceID,
+                      Device->PciConfig.RevisionID);
+    Index++;
+
+    Index += swprintf(&Buffer[Index],
+                      L"PCI\\VEN_%04X&DEV_%04X",
+                      Device->PciConfig.VendorID,
+                      Device->PciConfig.DeviceID);
+    Index++;
+
+    Index += swprintf(&Buffer[Index],
+                      L"PCI\\VEN_%04X&CC_%02X%02X%02X",
+                      Device->PciConfig.VendorID,
+                      Device->PciConfig.BaseClass,
+                      Device->PciConfig.SubClass,
+                      Device->PciConfig.ProgIf);
+    Index++;
+
+    Index += swprintf(&Buffer[Index],
+                      L"PCI\\VEN_%04X&CC_%02X%02X",
+                      Device->PciConfig.VendorID,
+                      Device->PciConfig.BaseClass,
+                      Device->PciConfig.SubClass);
+    Index++;
+
+    Index += swprintf(&Buffer[Index],
+                      L"PCI\\VEN_%04X",
+                      Device->PciConfig.VendorID);
+    Index++;
+
+    Index += swprintf(&Buffer[Index],
+                      L"PCI\\CC_%02X%02X%02X",
+                      Device->PciConfig.BaseClass,
+                      Device->PciConfig.SubClass,
+                      Device->PciConfig.ProgIf);
+    Index++;
+
+    Index += swprintf(&Buffer[Index],
+                      L"PCI\\CC_%02X%02X",
+                      Device->PciConfig.BaseClass,
+                      Device->PciConfig.SubClass);
+    Index++;
+
+    Buffer[Index] = UNICODE_NULL;
+
+    BufferU.Length = BufferU.MaximumLength = (USHORT)Index * sizeof(WCHAR);
+    BufferU.Buffer = Buffer;
+
+    return PciDuplicateUnicodeString(0, &BufferU, CompatibleIDs);
 }
 
 
@@ -374,267 +388,267 @@ NTSTATUS
 PciCreateDeviceDescriptionString(PUNICODE_STRING DeviceDescription,
                                  PPCI_DEVICE Device)
 {
-  PCWSTR Description;
-
-  switch (Device->PciConfig.BaseClass)
-  {
-    case PCI_CLASS_PRE_20:
-      switch (Device->PciConfig.SubClass)
-      {
-        case PCI_SUBCLASS_PRE_20_VGA:
-          Description = L"VGA device";
-          break;
+    PCWSTR Description;
 
-        default:
-        case PCI_SUBCLASS_PRE_20_NON_VGA:
-          Description = L"PCI device";
-          break;
-      }
-      break;
-
-    case PCI_CLASS_MASS_STORAGE_CTLR:
-      switch (Device->PciConfig.SubClass)
-      {
-        case PCI_SUBCLASS_MSC_SCSI_BUS_CTLR:
-          Description = L"SCSI controller";
-          break;
-
-        case PCI_SUBCLASS_MSC_IDE_CTLR:
-          Description = L"IDE controller";
-          break;
-
-        case PCI_SUBCLASS_MSC_FLOPPY_CTLR:
-          Description = L"Floppy disk controller";
-          break;
-
-        case PCI_SUBCLASS_MSC_IPI_CTLR:
-          Description = L"IPI controller";
-          break;
-
-        case PCI_SUBCLASS_MSC_RAID_CTLR:
-          Description = L"RAID controller";
-          break;
-
-        default:
-          Description = L"Mass storage controller";
-          break;
-      }
-      break;
-
-    case PCI_CLASS_NETWORK_CTLR:
-      switch (Device->PciConfig.SubClass)
-      {
-        case PCI_SUBCLASS_NET_ETHERNET_CTLR:
-          Description = L"Ethernet controller";
-          break;
-
-        case PCI_SUBCLASS_NET_TOKEN_RING_CTLR:
-          Description = L"Token-Ring controller";
-          break;
-
-        case PCI_SUBCLASS_NET_FDDI_CTLR:
-          Description = L"FDDI controller";
-          break;
-
-        case PCI_SUBCLASS_NET_ATM_CTLR:
-          Description = L"ATM controller";
-          break;
-
-        default:
-          Description = L"Network controller";
-          break;
-      }
-      break;
-
-    case PCI_CLASS_DISPLAY_CTLR:
-      switch (Device->PciConfig.SubClass)
-      {
-        case PCI_SUBCLASS_VID_VGA_CTLR:
-          Description = L"VGA display controller";
-          break;
-
-        case PCI_SUBCLASS_VID_XGA_CTLR:
-          Description = L"XGA display controller";
-          break;
-
-        case PCI_SUBCLASS_VID_3D_CTLR:
-          Description = L"Multimedia display controller";
-          break;
-
-        default:
-          Description = L"Other display controller";
-          break;
-      }
-      break;
-
-    case PCI_CLASS_MULTIMEDIA_DEV:
-      switch (Device->PciConfig.SubClass)
-      {
-        case PCI_SUBCLASS_MM_VIDEO_DEV:
-          Description = L"Multimedia video device";
-          break;
-
-        case PCI_SUBCLASS_MM_AUDIO_DEV:
-          Description = L"Multimedia audio device";
-          break;
-
-        case PCI_SUBCLASS_MM_TELEPHONY_DEV:
-          Description = L"Multimedia telephony device";
-          break;
-
-        default:
-          Description = L"Other multimedia device";
-          break;
-      }
-      break;
-
-    case PCI_CLASS_MEMORY_CTLR:
-      switch (Device->PciConfig.SubClass)
-      {
-        case PCI_SUBCLASS_MEM_RAM:
-          Description = L"PCI Memory";
-          break;
-
-        case PCI_SUBCLASS_MEM_FLASH:
-          Description = L"PCI Flash Memory";
-          break;
-
-        default:
-          Description = L"Other memory controller";
-          break;
-      }
-      break;
-
-    case PCI_CLASS_BRIDGE_DEV:
-      switch (Device->PciConfig.SubClass)
-      {
-        case PCI_SUBCLASS_BR_HOST:
-          Description = L"PCI-Host bridge";
-          break;
-
-        case PCI_SUBCLASS_BR_ISA:
-          Description = L"PCI-ISA bridge";
-          break;
-
-        case PCI_SUBCLASS_BR_EISA:
-          Description = L"PCI-EISA bridge";
-          break;
-
-        case PCI_SUBCLASS_BR_MCA:
-          Description = L"PCI-Micro Channel bridge";
-          break;
-
-        case PCI_SUBCLASS_BR_PCI_TO_PCI:
-          Description = L"PCI-PCI bridge";
-          break;
-
-        case PCI_SUBCLASS_BR_PCMCIA:
-          Description = L"PCI-PCMCIA bridge";
-          break;
-
-        case PCI_SUBCLASS_BR_NUBUS:
-          Description = L"PCI-NUBUS bridge";
-          break;
-
-        case PCI_SUBCLASS_BR_CARDBUS:
-          Description = L"PCI-CARDBUS bridge";
-          break;
-
-        default:
-          Description = L"Other bridge device";
-          break;
-      }
-      break;
-
-    case PCI_CLASS_SIMPLE_COMMS_CTLR:
-      switch (Device->PciConfig.SubClass)
-      {
-
-        default:
-          Description = L"Communication device";
-          break;
-      }
-      break;
-
-    case PCI_CLASS_BASE_SYSTEM_DEV:
-      switch (Device->PciConfig.SubClass)
-      {
-
-        default:
-          Description = L"System device";
-          break;
-      }
-      break;
-
-    case PCI_CLASS_INPUT_DEV:
-      switch (Device->PciConfig.SubClass)
-      {
-
-        default:
-          Description = L"Input device";
-          break;
-      }
-      break;
-
-    case PCI_CLASS_DOCKING_STATION:
-      switch (Device->PciConfig.SubClass)
-      {
-
-        default:
-          Description = L"Docking station";
-          break;
-      }
-      break;
-
-    case PCI_CLASS_PROCESSOR:
-      switch (Device->PciConfig.SubClass)
-      {
-
-        default:
-          Description = L"Processor";
-          break;
-      }
-      break;
-
-    case PCI_CLASS_SERIAL_BUS_CTLR:
-      switch (Device->PciConfig.SubClass)
-      {
-        case PCI_SUBCLASS_SB_IEEE1394:
-          Description = L"FireWire controller";
-          break;
-
-        case PCI_SUBCLASS_SB_ACCESS:
-          Description = L"ACCESS bus controller";
-          break;
-
-        case PCI_SUBCLASS_SB_SSA:
-          Description = L"SSA controller";
-          break;
-
-        case PCI_SUBCLASS_SB_USB:
-          Description = L"USB controller";
-          break;
-
-        case PCI_SUBCLASS_SB_FIBRE_CHANNEL:
-          Description = L"Fibre Channel controller";
-          break;
-
-        case PCI_SUBCLASS_SB_SMBUS:
-          Description = L"SMBus controller";
-          break;
+    switch (Device->PciConfig.BaseClass)
+    {
+        case PCI_CLASS_PRE_20:
+            switch (Device->PciConfig.SubClass)
+            {
+                case PCI_SUBCLASS_PRE_20_VGA:
+                    Description = L"VGA device";
+                    break;
+
+                default:
+                case PCI_SUBCLASS_PRE_20_NON_VGA:
+                    Description = L"PCI device";
+                    break;
+            }
+            break;
+
+        case PCI_CLASS_MASS_STORAGE_CTLR:
+            switch (Device->PciConfig.SubClass)
+            {
+                case PCI_SUBCLASS_MSC_SCSI_BUS_CTLR:
+                    Description = L"SCSI controller";
+                    break;
+
+                case PCI_SUBCLASS_MSC_IDE_CTLR:
+                    Description = L"IDE controller";
+                    break;
+
+                case PCI_SUBCLASS_MSC_FLOPPY_CTLR:
+                    Description = L"Floppy disk controller";
+                    break;
+
+                case PCI_SUBCLASS_MSC_IPI_CTLR:
+                    Description = L"IPI controller";
+                    break;
+
+                case PCI_SUBCLASS_MSC_RAID_CTLR:
+                    Description = L"RAID controller";
+                    break;
+
+                default:
+                    Description = L"Mass storage controller";
+                    break;
+            }
+            break;
+
+        case PCI_CLASS_NETWORK_CTLR:
+            switch (Device->PciConfig.SubClass)
+            {
+                case PCI_SUBCLASS_NET_ETHERNET_CTLR:
+                    Description = L"Ethernet controller";
+                    break;
+
+                case PCI_SUBCLASS_NET_TOKEN_RING_CTLR:
+                    Description = L"Token-Ring controller";
+                    break;
+
+                case PCI_SUBCLASS_NET_FDDI_CTLR:
+                    Description = L"FDDI controller";
+                    break;
+
+                case PCI_SUBCLASS_NET_ATM_CTLR:
+                    Description = L"ATM controller";
+                    break;
+
+                default:
+                    Description = L"Network controller";
+                    break;
+            }
+            break;
+
+        case PCI_CLASS_DISPLAY_CTLR:
+            switch (Device->PciConfig.SubClass)
+            {
+                case PCI_SUBCLASS_VID_VGA_CTLR:
+                    Description = L"VGA display controller";
+                    break;
+
+                case PCI_SUBCLASS_VID_XGA_CTLR:
+                    Description = L"XGA display controller";
+                    break;
+
+                case PCI_SUBCLASS_VID_3D_CTLR:
+                    Description = L"Multimedia display controller";
+                    break;
+
+                default:
+                    Description = L"Other display controller";
+                    break;
+            }
+            break;
+
+        case PCI_CLASS_MULTIMEDIA_DEV:
+            switch (Device->PciConfig.SubClass)
+            {
+                case PCI_SUBCLASS_MM_VIDEO_DEV:
+                    Description = L"Multimedia video device";
+                    break;
+
+                case PCI_SUBCLASS_MM_AUDIO_DEV:
+                    Description = L"Multimedia audio device";
+                    break;
+
+                case PCI_SUBCLASS_MM_TELEPHONY_DEV:
+                    Description = L"Multimedia telephony device";
+                    break;
+
+                default:
+                    Description = L"Other multimedia device";
+                    break;
+            }
+            break;
+
+        case PCI_CLASS_MEMORY_CTLR:
+            switch (Device->PciConfig.SubClass)
+            {
+                case PCI_SUBCLASS_MEM_RAM:
+                    Description = L"PCI Memory";
+                    break;
+
+                case PCI_SUBCLASS_MEM_FLASH:
+                    Description = L"PCI Flash Memory";
+                    break;
+
+                default:
+                    Description = L"Other memory controller";
+                    break;
+            }
+            break;
+
+        case PCI_CLASS_BRIDGE_DEV:
+            switch (Device->PciConfig.SubClass)
+            {
+                case PCI_SUBCLASS_BR_HOST:
+                    Description = L"PCI-Host bridge";
+                    break;
+
+                case PCI_SUBCLASS_BR_ISA:
+                    Description = L"PCI-ISA bridge";
+                    break;
+
+                case PCI_SUBCLASS_BR_EISA:
+                    Description = L"PCI-EISA bridge";
+                    break;
+
+                case PCI_SUBCLASS_BR_MCA:
+                    Description = L"PCI-Micro Channel bridge";
+                    break;
+
+                case PCI_SUBCLASS_BR_PCI_TO_PCI:
+                    Description = L"PCI-PCI bridge";
+                    break;
+
+                case PCI_SUBCLASS_BR_PCMCIA:
+                    Description = L"PCI-PCMCIA bridge";
+                    break;
+
+                case PCI_SUBCLASS_BR_NUBUS:
+                    Description = L"PCI-NUBUS bridge";
+                    break;
+
+                case PCI_SUBCLASS_BR_CARDBUS:
+                    Description = L"PCI-CARDBUS bridge";
+                    break;
+
+                default:
+                    Description = L"Other bridge device";
+                    break;
+            }
+            break;
+
+        case PCI_CLASS_SIMPLE_COMMS_CTLR:
+            switch (Device->PciConfig.SubClass)
+            {
+
+                default:
+                    Description = L"Communication device";
+                    break;
+            }
+            break;
+
+        case PCI_CLASS_BASE_SYSTEM_DEV:
+            switch (Device->PciConfig.SubClass)
+            {
+
+                default:
+                    Description = L"System device";
+                    break;
+            }
+            break;
+
+        case PCI_CLASS_INPUT_DEV:
+            switch (Device->PciConfig.SubClass)
+            {
+
+                default:
+                    Description = L"Input device";
+                    break;
+            }
+            break;
+
+        case PCI_CLASS_DOCKING_STATION:
+            switch (Device->PciConfig.SubClass)
+            {
+
+                default:
+                    Description = L"Docking station";
+                    break;
+            }
+            break;
+
+        case PCI_CLASS_PROCESSOR:
+            switch (Device->PciConfig.SubClass)
+            {
+
+                default:
+                    Description = L"Processor";
+                    break;
+            }
+            break;
+
+        case PCI_CLASS_SERIAL_BUS_CTLR:
+            switch (Device->PciConfig.SubClass)
+            {
+                case PCI_SUBCLASS_SB_IEEE1394:
+                    Description = L"FireWire controller";
+                    break;
+
+                case PCI_SUBCLASS_SB_ACCESS:
+                    Description = L"ACCESS bus controller";
+                    break;
+
+                case PCI_SUBCLASS_SB_SSA:
+                    Description = L"SSA controller";
+                    break;
+
+                case PCI_SUBCLASS_SB_USB:
+                    Description = L"USB controller";
+                    break;
+
+                case PCI_SUBCLASS_SB_FIBRE_CHANNEL:
+                    Description = L"Fibre Channel controller";
+                    break;
+
+                case PCI_SUBCLASS_SB_SMBUS:
+                    Description = L"SMBus controller";
+                    break;
+
+                default:
+                    Description = L"Other serial bus controller";
+                    break;
+            }
+            break;
 
         default:
-          Description = L"Other serial bus controller";
-          break;
-      }
-      break;
-
-    default:
-      Description = L"Other PCI Device";
-      break;
-  }
+            Description = L"Other PCI Device";
+            break;
+    }
 
-  return RtlCreateUnicodeString(DeviceDescription, Description) ? STATUS_SUCCESS : STATUS_INSUFFICIENT_RESOURCES;
+    return RtlCreateUnicodeString(DeviceDescription, Description) ? STATUS_SUCCESS : STATUS_INSUFFICIENT_RESOURCES;
 }
 
 
@@ -642,15 +656,15 @@ NTSTATUS
 PciCreateDeviceLocationString(PUNICODE_STRING DeviceLocation,
                               PPCI_DEVICE Device)
 {
-  WCHAR Buffer[256];
+    WCHAR Buffer[256];
 
-  swprintf(Buffer,
-           L"PCI-Bus %lu, Device %u, Function %u",
-           Device->BusNumber,
-           Device->SlotNumber.u.bits.DeviceNumber,
-           Device->SlotNumber.u.bits.FunctionNumber);
+    swprintf(Buffer,
+             L"PCI-Bus %lu, Device %u, Function %u",
+             Device->BusNumber,
+             Device->SlotNumber.u.bits.DeviceNumber,
+             Device->SlotNumber.u.bits.FunctionNumber);
 
-  return RtlCreateUnicodeString(DeviceLocation, Buffer) ? STATUS_SUCCESS : STATUS_INSUFFICIENT_RESOURCES;
+    return RtlCreateUnicodeString(DeviceLocation, Buffer) ? STATUS_SUCCESS : STATUS_INSUFFICIENT_RESOURCES;
 }
 
 NTSTATUS
@@ -659,17 +673,18 @@ PciDuplicateUnicodeString(
     IN PCUNICODE_STRING SourceString,
     OUT PUNICODE_STRING DestinationString)
 {
-    if (SourceString == NULL || DestinationString == NULL
-     || SourceString->Length > SourceString->MaximumLength
-     || (SourceString->Length == 0 && SourceString->MaximumLength > 0 && SourceString->Buffer == NULL)
-     || Flags == RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING || Flags >= 4)
+    if (SourceString == NULL ||
+        DestinationString == NULL ||
+        SourceString->Length > SourceString->MaximumLength ||
+        (SourceString->Length == 0 && SourceString->MaximumLength > 0 && SourceString->Buffer == NULL) ||
+        Flags == RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING ||
+        Flags >= 4)
     {
         return STATUS_INVALID_PARAMETER;
     }
 
-
-    if ((SourceString->Length == 0)
-     && (Flags != (RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE |
+    if ((SourceString->Length == 0) &&
+        (Flags != (RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE |
                    RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING)))
     {
         DestinationString->Length = 0;
index 605be08..1cfc32c 100644 (file)
 
 typedef struct _PCI_DEVICE
 {
-  // Entry on device list
-  LIST_ENTRY ListEntry;
-  // Physical Device Object of device
-  PDEVICE_OBJECT Pdo;
-  // PCI bus number
-  ULONG BusNumber;
-  // PCI slot number
-  PCI_SLOT_NUMBER SlotNumber;
-  // PCI configuration data
-  PCI_COMMON_CONFIG PciConfig;
-  // Enable memory space
-  BOOLEAN EnableMemorySpace;
-  // Enable I/O space
-  BOOLEAN EnableIoSpace;
-  // Enable bus master
-  BOOLEAN EnableBusMaster;
+    // Entry on device list
+    LIST_ENTRY ListEntry;
+    // Physical Device Object of device
+    PDEVICE_OBJECT Pdo;
+    // PCI bus number
+    ULONG BusNumber;
+    // PCI slot number
+    PCI_SLOT_NUMBER SlotNumber;
+    // PCI configuration data
+    PCI_COMMON_CONFIG PciConfig;
+    // Enable memory space
+    BOOLEAN EnableMemorySpace;
+    // Enable I/O space
+    BOOLEAN EnableIoSpace;
+    // Enable bus master
+    BOOLEAN EnableBusMaster;
 } PCI_DEVICE, *PPCI_DEVICE;
 
 
-typedef enum {
-  dsStopped,
-  dsStarted,
-  dsPaused,
-  dsRemoved,
-  dsSurpriseRemoved
+typedef enum
+{
+    dsStopped,
+    dsStarted,
+    dsPaused,
+    dsRemoved,
+    dsSurpriseRemoved
 } PCI_DEVICE_STATE;
 
 
 typedef struct _COMMON_DEVICE_EXTENSION
 {
-  // Pointer to device object, this device extension is associated with
-  PDEVICE_OBJECT DeviceObject;
-  // Wether this device extension is for an FDO or PDO
-  BOOLEAN IsFDO;
-  // Wether the device is removed
-  BOOLEAN Removed;
-  // Current device power state for the device
-  DEVICE_POWER_STATE DevicePowerState;
+    // Pointer to device object, this device extension is associated with
+    PDEVICE_OBJECT DeviceObject;
+    // Wether this device extension is for an FDO or PDO
+    BOOLEAN IsFDO;
+    // Wether the device is removed
+    BOOLEAN Removed;
+    // Current device power state for the device
+    DEVICE_POWER_STATE DevicePowerState;
 } COMMON_DEVICE_EXTENSION, *PCOMMON_DEVICE_EXTENSION;
 
 /* Physical Device Object device extension for a child device */
 typedef struct _PDO_DEVICE_EXTENSION
 {
-  // Common device data
-  COMMON_DEVICE_EXTENSION Common;
-  // Functional device object
-  PDEVICE_OBJECT Fdo;
-  // Pointer to PCI Device informations
-  PPCI_DEVICE PciDevice;
-  // Device ID
-  UNICODE_STRING DeviceID;
-  // Instance ID
-  UNICODE_STRING InstanceID;
-  // Hardware IDs
-  UNICODE_STRING HardwareIDs;
-  // Compatible IDs
-  UNICODE_STRING CompatibleIDs;
-  // Textual description of device
-  UNICODE_STRING DeviceDescription;
-  // Textual description of device location
-  UNICODE_STRING DeviceLocation;
-  // Number of interfaces references
-  LONG References;
+    // Common device data
+    COMMON_DEVICE_EXTENSION Common;
+    // Functional device object
+    PDEVICE_OBJECT Fdo;
+    // Pointer to PCI Device informations
+    PPCI_DEVICE PciDevice;
+    // Device ID
+    UNICODE_STRING DeviceID;
+    // Instance ID
+    UNICODE_STRING InstanceID;
+    // Hardware IDs
+    UNICODE_STRING HardwareIDs;
+    // Compatible IDs
+    UNICODE_STRING CompatibleIDs;
+    // Textual description of device
+    UNICODE_STRING DeviceDescription;
+    // Textual description of device location
+    UNICODE_STRING DeviceLocation;
+    // Number of interfaces references
+    LONG References;
 } PDO_DEVICE_EXTENSION, *PPDO_DEVICE_EXTENSION;
 
 /* Functional Device Object device extension for the PCI driver device object */
 typedef struct _FDO_DEVICE_EXTENSION
 {
-  // Common device data
-  COMMON_DEVICE_EXTENSION Common;
-  // Entry on device list
-  LIST_ENTRY ListEntry;
-  // PCI bus number serviced by this FDO
-  ULONG BusNumber;
-  // Current state of the driver
-  PCI_DEVICE_STATE State;
-  // Namespace device list
-  LIST_ENTRY DeviceListHead;
-  // Number of (not removed) devices in device list
-  ULONG DeviceListCount;
-  // Lock for namespace device list
-  KSPIN_LOCK DeviceListLock;
-  // Lower device object
-  PDEVICE_OBJECT Ldo;
+    // Common device data
+    COMMON_DEVICE_EXTENSION Common;
+    // Entry on device list
+    LIST_ENTRY ListEntry;
+    // PCI bus number serviced by this FDO
+    ULONG BusNumber;
+    // Current state of the driver
+    PCI_DEVICE_STATE State;
+    // Namespace device list
+    LIST_ENTRY DeviceListHead;
+    // Number of (not removed) devices in device list
+    ULONG DeviceListCount;
+    // Lock for namespace device list
+    KSPIN_LOCK DeviceListLock;
+    // Lower device object
+    PDEVICE_OBJECT Ldo;
 } FDO_DEVICE_EXTENSION, *PFDO_DEVICE_EXTENSION;
 
 
 /* Driver extension associated with PCI driver */
 typedef struct _PCI_DRIVER_EXTENSION
 {
-  //
-  LIST_ENTRY BusListHead;
-  // Lock for namespace bus list
-  KSPIN_LOCK BusListLock;
+    //
+    LIST_ENTRY BusListHead;
+    // Lock for namespace bus list
+    KSPIN_LOCK BusListLock;
 } PCI_DRIVER_EXTENSION, *PPCI_DRIVER_EXTENSION;
 
 
@@ -113,66 +114,66 @@ extern PPCI_DRIVER_EXTENSION DriverExtension;
 
 NTSTATUS
 FdoPnpControl(
-  PDEVICE_OBJECT DeviceObject,
-  PIRP Irp);
+    PDEVICE_OBJECT DeviceObject,
+    PIRP Irp);
 
 NTSTATUS
 FdoPowerControl(
-  PDEVICE_OBJECT DeviceObject,
-  PIRP Irp);
+    PDEVICE_OBJECT DeviceObject,
+    PIRP Irp);
 
 /* pci.c */
 
 NTSTATUS
 PciCreateDeviceIDString(
-  PUNICODE_STRING DeviceID,
-  PPCI_DEVICE Device);
+    PUNICODE_STRING DeviceID,
+    PPCI_DEVICE Device);
 
 NTSTATUS
 PciCreateInstanceIDString(
-  PUNICODE_STRING InstanceID,
-  PPCI_DEVICE Device);
+    PUNICODE_STRING InstanceID,
+    PPCI_DEVICE Device);
 
 NTSTATUS
 PciCreateHardwareIDsString(
-  PUNICODE_STRING HardwareIDs,
-  PPCI_DEVICE Device);
+    PUNICODE_STRING HardwareIDs,
+    PPCI_DEVICE Device);
 
 NTSTATUS
 PciCreateCompatibleIDsString(
-  PUNICODE_STRING HardwareIDs,
-  PPCI_DEVICE Device);
+    PUNICODE_STRING HardwareIDs,
+    PPCI_DEVICE Device);
 
 NTSTATUS
 PciCreateDeviceDescriptionString(
-  PUNICODE_STRING DeviceDescription,
-  PPCI_DEVICE Device);
+    PUNICODE_STRING DeviceDescription,
+    PPCI_DEVICE Device);
 
 NTSTATUS
 PciCreateDeviceLocationString(
-  PUNICODE_STRING DeviceLocation,
-  PPCI_DEVICE Device);
+    PUNICODE_STRING DeviceLocation,
+    PPCI_DEVICE Device);
 
 NTSTATUS
 PciDuplicateUnicodeString(
-  IN ULONG Flags,
-  IN PCUNICODE_STRING SourceString,
-  OUT PUNICODE_STRING DestinationString);
+    IN ULONG Flags,
+    IN PCUNICODE_STRING SourceString,
+    OUT PUNICODE_STRING DestinationString);
 
 /* pdo.c */
 
 NTSTATUS
 PdoPnpControl(
-  PDEVICE_OBJECT DeviceObject,
-  PIRP Irp);
+    PDEVICE_OBJECT DeviceObject,
+    PIRP Irp);
 
 NTSTATUS
 PdoPowerControl(
-  PDEVICE_OBJECT DeviceObject,
-  PIRP Irp);
+    PDEVICE_OBJECT DeviceObject,
+    PIRP Irp);
 
 NTSTATUS
 NTAPI
 DriverEntry(
-  IN PDRIVER_OBJECT DriverObject,
-  IN PUNICODE_STRING RegistryPath);
+    IN PDRIVER_OBJECT DriverObject,
+    IN PUNICODE_STRING RegistryPath);
index 150493a..1263e3c 100644 (file)
 
 static NTSTATUS
 PdoQueryDeviceText(
-  IN PDEVICE_OBJECT DeviceObject,
-  IN PIRP Irp,
-  PIO_STACK_LOCATION IrpSp)
+    IN PDEVICE_OBJECT DeviceObject,
+    IN PIRP Irp,
+    PIO_STACK_LOCATION IrpSp)
 {
-  PPDO_DEVICE_EXTENSION DeviceExtension;
-  UNICODE_STRING String;
-  NTSTATUS Status;
+    PPDO_DEVICE_EXTENSION DeviceExtension;
+    UNICODE_STRING String;
+    NTSTATUS Status;
 
-  DPRINT("Called\n");
+    DPRINT("Called\n");
 
-  DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+    DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
 
-  switch (IrpSp->Parameters.QueryDeviceText.DeviceTextType)
-  {
-    case DeviceTextDescription:
-      Status = PciDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
-                                         &DeviceExtension->DeviceDescription,
-                                         &String);
-
-      DPRINT("DeviceTextDescription\n");
-      Irp->IoStatus.Information = (ULONG_PTR)String.Buffer;
-      break;
-
-    case DeviceTextLocationInformation:
-      Status = PciDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
-                                         &DeviceExtension->DeviceLocation,
-                                         &String);
-
-      DPRINT("DeviceTextLocationInformation\n");
-      Irp->IoStatus.Information = (ULONG_PTR)String.Buffer;
-      break;
-
-    default:
-      Irp->IoStatus.Information = 0;
-      Status = STATUS_INVALID_PARAMETER;
-      break;
-  }
+    switch (IrpSp->Parameters.QueryDeviceText.DeviceTextType)
+    {
+        case DeviceTextDescription:
+            Status = PciDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
+                                               &DeviceExtension->DeviceDescription,
+                                               &String);
+
+            DPRINT("DeviceTextDescription\n");
+            Irp->IoStatus.Information = (ULONG_PTR)String.Buffer;
+            break;
+
+        case DeviceTextLocationInformation:
+            Status = PciDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
+                                               &DeviceExtension->DeviceLocation,
+                                               &String);
+
+            DPRINT("DeviceTextLocationInformation\n");
+            Irp->IoStatus.Information = (ULONG_PTR)String.Buffer;
+            break;
+
+        default:
+            Irp->IoStatus.Information = 0;
+            Status = STATUS_INVALID_PARAMETER;
+            break;
+    }
 
-  return Status;
+    return Status;
 }
 
 
 static NTSTATUS
 PdoQueryId(
-  IN PDEVICE_OBJECT DeviceObject,
-  IN PIRP Irp,
-  PIO_STACK_LOCATION IrpSp)
+    IN PDEVICE_OBJECT DeviceObject,
+    IN PIRP Irp,
+    PIO_STACK_LOCATION IrpSp)
 {
-  PPDO_DEVICE_EXTENSION DeviceExtension;
-  UNICODE_STRING String;
-  NTSTATUS Status;
+    PPDO_DEVICE_EXTENSION DeviceExtension;
+    UNICODE_STRING String;
+    NTSTATUS Status;
 
-  DPRINT("Called\n");
+    DPRINT("Called\n");
 
-  DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+    DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
 
-//  Irp->IoStatus.Information = 0;
+//    Irp->IoStatus.Information = 0;
 
-  Status = STATUS_SUCCESS;
+    Status = STATUS_SUCCESS;
 
-  RtlInitUnicodeString(&String, NULL);
+    RtlInitUnicodeString(&String, NULL);
 
-  switch (IrpSp->Parameters.QueryId.IdType) {
-    case BusQueryDeviceID:
-      Status = PciDuplicateUnicodeString(
-        RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
-        &DeviceExtension->DeviceID,
-        &String);
+    switch (IrpSp->Parameters.QueryId.IdType)
+    {
+        case BusQueryDeviceID:
+            Status = PciDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
+                                               &DeviceExtension->DeviceID,
+                                               &String);
 
-      DPRINT("DeviceID: %S\n", String.Buffer);
+            DPRINT("DeviceID: %S\n", String.Buffer);
 
-      Irp->IoStatus.Information = (ULONG_PTR)String.Buffer;
-      break;
+            Irp->IoStatus.Information = (ULONG_PTR)String.Buffer;
+            break;
 
-    case BusQueryHardwareIDs:
-      Status = PciDuplicateUnicodeString(
-        RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
-        &DeviceExtension->HardwareIDs,
-        &String);
+        case BusQueryHardwareIDs:
+            Status = PciDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
+                                               &DeviceExtension->HardwareIDs,
+                                               &String);
 
-      Irp->IoStatus.Information = (ULONG_PTR)String.Buffer;
-      break;
+            Irp->IoStatus.Information = (ULONG_PTR)String.Buffer;
+            break;
 
-    case BusQueryCompatibleIDs:
-      Status = PciDuplicateUnicodeString(
-        RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
-        &DeviceExtension->CompatibleIDs,
-        &String);
+        case BusQueryCompatibleIDs:
+            Status = PciDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
+                                               &DeviceExtension->CompatibleIDs,
+                                               &String);
 
-      Irp->IoStatus.Information = (ULONG_PTR)String.Buffer;
-      break;
+            Irp->IoStatus.Information = (ULONG_PTR)String.Buffer;
+            break;
 
-    case BusQueryInstanceID:
-      Status = PciDuplicateUnicodeString(
-        RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
-        &DeviceExtension->InstanceID,
-        &String);
+        case BusQueryInstanceID:
+            Status = PciDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
+                                               &DeviceExtension->InstanceID,
+                                               &String);
 
-      DPRINT("InstanceID: %S\n", String.Buffer);
+            DPRINT("InstanceID: %S\n", String.Buffer);
 
-      Irp->IoStatus.Information = (ULONG_PTR)String.Buffer;
-      break;
+            Irp->IoStatus.Information = (ULONG_PTR)String.Buffer;
+            break;
 
-    case BusQueryDeviceSerialNumber:
-    default:
-      Status = STATUS_NOT_IMPLEMENTED;
-  }
+        case BusQueryDeviceSerialNumber:
+        default:
+            Status = STATUS_NOT_IMPLEMENTED;
+    }
 
-  return Status;
+    return Status;
 }
 
 
 static NTSTATUS
 PdoQueryBusInformation(
-  IN PDEVICE_OBJECT DeviceObject,
-  IN PIRP Irp,
-  PIO_STACK_LOCATION IrpSp)
+    IN PDEVICE_OBJECT DeviceObject,
+    IN PIRP Irp,
+    PIO_STACK_LOCATION IrpSp)
 {
-  PPDO_DEVICE_EXTENSION DeviceExtension;
-  PPNP_BUS_INFORMATION BusInformation;
+    PPDO_DEVICE_EXTENSION DeviceExtension;
+    PPNP_BUS_INFORMATION BusInformation;
 
-  UNREFERENCED_PARAMETER(IrpSp);
-  DPRINT("Called\n");
+    UNREFERENCED_PARAMETER(IrpSp);
+    DPRINT("Called\n");
 
-  DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
-  BusInformation = ExAllocatePool(PagedPool, sizeof(PNP_BUS_INFORMATION));
-  Irp->IoStatus.Information = (ULONG_PTR)BusInformation;
-  if (BusInformation != NULL)
-  {
-    BusInformation->BusTypeGuid = GUID_BUS_TYPE_PCI;
-    BusInformation->LegacyBusType = PCIBus;
-    BusInformation->BusNumber = DeviceExtension->PciDevice->BusNumber;
+    DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+    BusInformation = ExAllocatePool(PagedPool, sizeof(PNP_BUS_INFORMATION));
+    Irp->IoStatus.Information = (ULONG_PTR)BusInformation;
+    if (BusInformation != NULL)
+    {
+        BusInformation->BusTypeGuid = GUID_BUS_TYPE_PCI;
+        BusInformation->LegacyBusType = PCIBus;
+        BusInformation->BusNumber = DeviceExtension->PciDevice->BusNumber;
 
-    return STATUS_SUCCESS;
-  }
+        return STATUS_SUCCESS;
+    }
 
-  return STATUS_INSUFFICIENT_RESOURCES;
+    return STATUS_INSUFFICIENT_RESOURCES;
 }
 
 
 static NTSTATUS
 PdoQueryCapabilities(
-  IN PDEVICE_OBJECT DeviceObject,
-  IN PIRP Irp,
-  PIO_STACK_LOCATION IrpSp)
+    IN PDEVICE_OBJECT DeviceObject,
+    IN PIRP Irp,
+    PIO_STACK_LOCATION IrpSp)
 {
-  PPDO_DEVICE_EXTENSION DeviceExtension;
-  PDEVICE_CAPABILITIES DeviceCapabilities;
-  ULONG DeviceNumber, FunctionNumber;
+    PPDO_DEVICE_EXTENSION DeviceExtension;
+    PDEVICE_CAPABILITIES DeviceCapabilities;
+    ULONG DeviceNumber, FunctionNumber;
 
-  UNREFERENCED_PARAMETER(Irp);
-  DPRINT("Called\n");
+    UNREFERENCED_PARAMETER(Irp);
+    DPRINT("Called\n");
 
-  DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
-  DeviceCapabilities = IrpSp->Parameters.DeviceCapabilities.Capabilities;
+    DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+    DeviceCapabilities = IrpSp->Parameters.DeviceCapabilities.Capabilities;
 
-  if (DeviceCapabilities->Version != 1)
-    return STATUS_UNSUCCESSFUL;
+    if (DeviceCapabilities->Version != 1)
+        return STATUS_UNSUCCESSFUL;
 
-  DeviceNumber = DeviceExtension->PciDevice->SlotNumber.u.bits.DeviceNumber;
-  FunctionNumber = DeviceExtension->PciDevice->SlotNumber.u.bits.FunctionNumber;
+    DeviceNumber = DeviceExtension->PciDevice->SlotNumber.u.bits.DeviceNumber;
+    FunctionNumber = DeviceExtension->PciDevice->SlotNumber.u.bits.FunctionNumber;
 
-  DeviceCapabilities->UniqueID = FALSE;
-  DeviceCapabilities->Address = ((DeviceNumber << 16) & 0xFFFF0000) + (FunctionNumber & 0xFFFF);
-  DeviceCapabilities->UINumber = MAXULONG; /* FIXME */
+    DeviceCapabilities->UniqueID = FALSE;
+    DeviceCapabilities->Address = ((DeviceNumber << 16) & 0xFFFF0000) + (FunctionNumber & 0xFFFF);
+    DeviceCapabilities->UINumber = MAXULONG; /* FIXME */
 
-  return STATUS_SUCCESS;
+    return STATUS_SUCCESS;
 }
 
 
@@ -195,705 +192,707 @@ PdoGetRangeLength(PPDO_DEVICE_EXTENSION DeviceExtension,
                   PULONG Length,
                   PULONG Flags)
 {
-  ULONG OrigValue;
-  ULONG BaseValue;
-  ULONG NewValue;
-  ULONG Size;
-  ULONG XLength;
-
-  /* Save original value */
-  Size= HalGetBusDataByOffset(PCIConfiguration,
-                              DeviceExtension->PciDevice->BusNumber,
-                              DeviceExtension->PciDevice->SlotNumber.u.AsULONG,
-                              &OrigValue,
-                              Offset,
-                              sizeof(ULONG));
-  if (Size != sizeof(ULONG))
-  {
-    DPRINT1("Wrong size %lu\n", Size);
-    return FALSE;
-  }
-
-  BaseValue = (OrigValue & PCI_ADDRESS_IO_SPACE)
-              ? (OrigValue & PCI_ADDRESS_IO_ADDRESS_MASK)
-              : (OrigValue & PCI_ADDRESS_MEMORY_ADDRESS_MASK);
-
-  *Base = BaseValue;
-
-  /* Set magic value */
-  NewValue = MAXULONG;
-  Size= HalSetBusDataByOffset(PCIConfiguration,
-                              DeviceExtension->PciDevice->BusNumber,
-                              DeviceExtension->PciDevice->SlotNumber.u.AsULONG,
-                              &NewValue,
-                              Offset,
-                              sizeof(ULONG));
-  if (Size != sizeof(ULONG))
-  {
-    DPRINT1("Wrong size %lu\n", Size);
-    return FALSE;
-  }
-
-  /* Get the range length */
-  Size= HalGetBusDataByOffset(PCIConfiguration,
-                              DeviceExtension->PciDevice->BusNumber,
-                              DeviceExtension->PciDevice->SlotNumber.u.AsULONG,
-                              &NewValue,
-                              Offset,
-                              sizeof(ULONG));
-  if (Size != sizeof(ULONG))
-  {
-    DPRINT1("Wrong size %lu\n", Size);
-    return FALSE;
-  }
-
-  /* Restore original value */
-  Size= HalSetBusDataByOffset(PCIConfiguration,
-                              DeviceExtension->PciDevice->BusNumber,
-                              DeviceExtension->PciDevice->SlotNumber.u.AsULONG,
-                              &OrigValue,
-                              Offset,
-                              sizeof(ULONG));
-  if (Size != sizeof(ULONG))
-  {
-    DPRINT1("Wrong size %lu\n", Size);
-    return FALSE;
-  }
-
-  if (NewValue == 0)
-  {
-    DPRINT("Unused address register\n");
-    *Base = 0;
-    *Length = 0;
-    *Flags = 0;
-     return TRUE;
-  }
-
-  XLength = ~((NewValue & PCI_ADDRESS_IO_SPACE)
-              ? (NewValue & PCI_ADDRESS_IO_ADDRESS_MASK)
-              : (NewValue & PCI_ADDRESS_MEMORY_ADDRESS_MASK)) + 1;
+    ULONG OrigValue;
+    ULONG BaseValue;
+    ULONG NewValue;
+    ULONG Size;
+    ULONG XLength;
+
+    /* Save original value */
+    Size= HalGetBusDataByOffset(PCIConfiguration,
+                                DeviceExtension->PciDevice->BusNumber,
+                                DeviceExtension->PciDevice->SlotNumber.u.AsULONG,
+                                &OrigValue,
+                                Offset,
+                                sizeof(ULONG));
+    if (Size != sizeof(ULONG))
+    {
+        DPRINT1("Wrong size %lu\n", Size);
+        return FALSE;
+    }
 
-#if 0
-  DbgPrint("BaseAddress 0x%08lx  Length 0x%08lx",
-           BaseValue, XLength);
-
-  if (NewValue & PCI_ADDRESS_IO_SPACE)
-  {
-    DbgPrint("  IO range");
-  }
-  else
-  {
-    DbgPrint("  Memory range");
-    if ((NewValue & PCI_ADDRESS_MEMORY_TYPE_MASK) == 0)
+    BaseValue = (OrigValue & PCI_ADDRESS_IO_SPACE)
+                ? (OrigValue & PCI_ADDRESS_IO_ADDRESS_MASK)
+                : (OrigValue & PCI_ADDRESS_MEMORY_ADDRESS_MASK);
+
+    *Base = BaseValue;
+
+    /* Set magic value */
+    NewValue = MAXULONG;
+    Size= HalSetBusDataByOffset(PCIConfiguration,
+                                DeviceExtension->PciDevice->BusNumber,
+                                DeviceExtension->PciDevice->SlotNumber.u.AsULONG,
+                                &NewValue,
+                                Offset,
+                                sizeof(ULONG));
+    if (Size != sizeof(ULONG))
+    {
+        DPRINT1("Wrong size %lu\n", Size);
+        return FALSE;
+    }
+
+    /* Get the range length */
+    Size= HalGetBusDataByOffset(PCIConfiguration,
+                                DeviceExtension->PciDevice->BusNumber,
+                                DeviceExtension->PciDevice->SlotNumber.u.AsULONG,
+                                &NewValue,
+                                Offset,
+                                sizeof(ULONG));
+    if (Size != sizeof(ULONG))
     {
-      DbgPrint(" in 32-Bit address space");
+        DPRINT1("Wrong size %lu\n", Size);
+        return FALSE;
     }
-    else if ((NewValue & PCI_ADDRESS_MEMORY_TYPE_MASK) == 2)
+
+    /* Restore original value */
+    Size= HalSetBusDataByOffset(PCIConfiguration,
+                                DeviceExtension->PciDevice->BusNumber,
+                                DeviceExtension->PciDevice->SlotNumber.u.AsULONG,
+                                &OrigValue,
+                                Offset,
+                                sizeof(ULONG));
+    if (Size != sizeof(ULONG))
     {
-      DbgPrint(" below 1BM ");
+        DPRINT1("Wrong size %lu\n", Size);
+        return FALSE;
     }
-    else if ((NewValue & PCI_ADDRESS_MEMORY_TYPE_MASK) == 4)
+
+    if (NewValue == 0)
     {
-      DbgPrint(" in 64-Bit address space");
+        DPRINT("Unused address register\n");
+        *Base = 0;
+        *Length = 0;
+        *Flags = 0;
+        return TRUE;
     }
 
-    if (NewValue & PCI_ADDRESS_MEMORY_PREFETCHABLE)
+    XLength = ~((NewValue & PCI_ADDRESS_IO_SPACE)
+                ? (NewValue & PCI_ADDRESS_IO_ADDRESS_MASK)
+                : (NewValue & PCI_ADDRESS_MEMORY_ADDRESS_MASK)) + 1;
+
+#if 0
+    DbgPrint("BaseAddress 0x%08lx  Length 0x%08lx",
+             BaseValue, XLength);
+
+    if (NewValue & PCI_ADDRESS_IO_SPACE)
     {
-      DbgPrint(" prefetchable");
+        DbgPrint("  IO range");
+    }
+    else
+    {
+        DbgPrint("  Memory range");
+        if ((NewValue & PCI_ADDRESS_MEMORY_TYPE_MASK) == 0)
+        {
+            DbgPrint(" in 32-Bit address space");
+        }
+        else if ((NewValue & PCI_ADDRESS_MEMORY_TYPE_MASK) == 2)
+        {
+            DbgPrint(" below 1BM ");
+        }
+        else if ((NewValue & PCI_ADDRESS_MEMORY_TYPE_MASK) == 4)
+        {
+            DbgPrint(" in 64-Bit address space");
+        }
+
+        if (NewValue & PCI_ADDRESS_MEMORY_PREFETCHABLE)
+        {
+            DbgPrint(" prefetchable");
+        }
     }
-  }
 
-  DbgPrint("\n");
+    DbgPrint("\n");
 #endif
 
-  *Length = XLength;
-  *Flags = (NewValue & PCI_ADDRESS_IO_SPACE)
-           ? (NewValue & ~PCI_ADDRESS_IO_ADDRESS_MASK)
-           : (NewValue & ~PCI_ADDRESS_MEMORY_ADDRESS_MASK);
+    *Length = XLength;
+    *Flags = (NewValue & PCI_ADDRESS_IO_SPACE)
+             ? (NewValue & ~PCI_ADDRESS_IO_ADDRESS_MASK)
+             : (NewValue & ~PCI_ADDRESS_MEMORY_ADDRESS_MASK);
 
-  return TRUE;
+    return TRUE;
 }
 
 
 static NTSTATUS
 PdoQueryResourceRequirements(
-  IN PDEVICE_OBJECT DeviceObject,
-  IN PIRP Irp,
-  PIO_STACK_LOCATION IrpSp)
+    IN PDEVICE_OBJECT DeviceObject,
+    IN PIRP Irp,
+    PIO_STACK_LOCATION IrpSp)
 {
-  PPDO_DEVICE_EXTENSION DeviceExtension;
-  PCI_COMMON_CONFIG PciConfig;
-  PIO_RESOURCE_REQUIREMENTS_LIST ResourceList;
-  PIO_RESOURCE_DESCRIPTOR Descriptor;
-  ULONG Size;
-  ULONG ResCount = 0;
-  ULONG ListSize;
-  ULONG i;
-  ULONG Base;
-  ULONG Length;
-  ULONG Flags;
-
-  UNREFERENCED_PARAMETER(IrpSp);
-  DPRINT("PdoQueryResourceRequirements() called\n");
-
-  DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
-
-  /* Get PCI configuration space */
-  Size= HalGetBusData(PCIConfiguration,
-                      DeviceExtension->PciDevice->BusNumber,
-                      DeviceExtension->PciDevice->SlotNumber.u.AsULONG,
-                      &PciConfig,
-                      PCI_COMMON_HDR_LENGTH);
-  DPRINT("Size %lu\n", Size);
-  if (Size < PCI_COMMON_HDR_LENGTH)
-  {
-    Irp->IoStatus.Information = 0;
-    return STATUS_UNSUCCESSFUL;
-  }
-
-  DPRINT("Command register: 0x%04hx\n", PciConfig.Command);
-
-  /* Count required resource descriptors */
-  ResCount = 0;
-  if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_DEVICE_TYPE)
-  {
-    for (i = 0; i < PCI_TYPE0_ADDRESSES; i++)
+    PPDO_DEVICE_EXTENSION DeviceExtension;
+    PCI_COMMON_CONFIG PciConfig;
+    PIO_RESOURCE_REQUIREMENTS_LIST ResourceList;
+    PIO_RESOURCE_DESCRIPTOR Descriptor;
+    ULONG Size;
+    ULONG ResCount = 0;
+    ULONG ListSize;
+    ULONG i;
+    ULONG Base;
+    ULONG Length;
+    ULONG Flags;
+
+    UNREFERENCED_PARAMETER(IrpSp);
+    DPRINT("PdoQueryResourceRequirements() called\n");
+
+    DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+
+    /* Get PCI configuration space */
+    Size= HalGetBusData(PCIConfiguration,
+                        DeviceExtension->PciDevice->BusNumber,
+                        DeviceExtension->PciDevice->SlotNumber.u.AsULONG,
+                        &PciConfig,
+                        PCI_COMMON_HDR_LENGTH);
+    DPRINT("Size %lu\n", Size);
+    if (Size < PCI_COMMON_HDR_LENGTH)
     {
-      if (!PdoGetRangeLength(DeviceExtension,
-                            0x10 + i * 4,
-                            &Base,
-                            &Length,
-                            &Flags))
-       break;
-
-      if (Length != 0)
-        ResCount += 2;
+        Irp->IoStatus.Information = 0;
+        return STATUS_UNSUCCESSFUL;
     }
 
-    /* FIXME: Check ROM address */
+    DPRINT("Command register: 0x%04hx\n", PciConfig.Command);
+
+    /* Count required resource descriptors */
+    ResCount = 0;
+    if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_DEVICE_TYPE)
+    {
+        for (i = 0; i < PCI_TYPE0_ADDRESSES; i++)
+        {
+            if (!PdoGetRangeLength(DeviceExtension,
+                                   0x10 + i * 4,
+                                   &Base,
+                                   &Length,
+                                   &Flags))
+                break;
+
+            if (Length != 0)
+                ResCount += 2;
+        }
+
+        /* FIXME: Check ROM address */
 
-    if (PciConfig.u.type0.InterruptPin != 0)
-      ResCount++;
-  }
-  else if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_BRIDGE_TYPE)
-  {
-    for (i = 0; i < PCI_TYPE1_ADDRESSES; i++)
+        if (PciConfig.u.type0.InterruptPin != 0)
+            ResCount++;
+    }
+    else if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_BRIDGE_TYPE)
     {
-      if (!PdoGetRangeLength(DeviceExtension,
-                            0x10 + i * 4,
-                            &Base,
-                            &Length,
-                            &Flags))
-       break;
-
-      if (Length != 0)
-        ResCount += 2;
+        for (i = 0; i < PCI_TYPE1_ADDRESSES; i++)
+        {
+            if (!PdoGetRangeLength(DeviceExtension,
+                                   0x10 + i * 4,
+                                   &Base,
+                                   &Length,
+                                   &Flags))
+                break;
+
+            if (Length != 0)
+                ResCount += 2;
+        }
+
+        if (DeviceExtension->PciDevice->PciConfig.BaseClass == PCI_CLASS_BRIDGE_DEV)
+            ResCount++;
+    }
+    else if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_CARDBUS_BRIDGE_TYPE)
+    {
+        /* FIXME: Count Cardbus bridge resources */
+    }
+    else
+    {
+        DPRINT1("Unsupported header type %d\n", PCI_CONFIGURATION_TYPE(&PciConfig));
     }
-    if (DeviceExtension->PciDevice->PciConfig.BaseClass == PCI_CLASS_BRIDGE_DEV)
-      ResCount++;
-  }
-  else if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_CARDBUS_BRIDGE_TYPE)
-  {
-    /* FIXME: Count Cardbus bridge resources */
-  }
-  else
-  {
-    DPRINT1("Unsupported header type %d\n", PCI_CONFIGURATION_TYPE(&PciConfig));
-  }
-
-  if (ResCount == 0)
-  {
-    Irp->IoStatus.Information = 0;
-    return STATUS_SUCCESS;
-  }
 
-  /* Calculate the resource list size */
-  ListSize = FIELD_OFFSET(IO_RESOURCE_REQUIREMENTS_LIST, List[0].Descriptors)
-    + ResCount * sizeof(IO_RESOURCE_DESCRIPTOR);
+    if (ResCount == 0)
+    {
+        Irp->IoStatus.Information = 0;
+        return STATUS_SUCCESS;
+    }
 
-  DPRINT("ListSize %lu (0x%lx)\n", ListSize, ListSize);
+    /* Calculate the resource list size */
+    ListSize = FIELD_OFFSET(IO_RESOURCE_REQUIREMENTS_LIST, List[0].Descriptors) +
+               ResCount * sizeof(IO_RESOURCE_DESCRIPTOR);
 
-  /* Allocate the resource requirements list */
-  ResourceList = ExAllocatePoolWithTag(PagedPool,
-                                ListSize, TAG_PCI);
-  if (ResourceList == NULL)
-  {
-    Irp->IoStatus.Information = 0;
-    return STATUS_INSUFFICIENT_RESOURCES;
-  }
-
-  RtlZeroMemory(ResourceList, ListSize);
-  ResourceList->ListSize = ListSize;
-  ResourceList->InterfaceType = PCIBus;
-  ResourceList->BusNumber = DeviceExtension->PciDevice->BusNumber;
-  ResourceList->SlotNumber = DeviceExtension->PciDevice->SlotNumber.u.AsULONG;
-  ResourceList->AlternativeLists = 1;
-
-  ResourceList->List[0].Version = 1;
-  ResourceList->List[0].Revision = 1;
-  ResourceList->List[0].Count = ResCount;
-
-  Descriptor = &ResourceList->List[0].Descriptors[0];
-  if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_DEVICE_TYPE)
-  {
-    for (i = 0; i < PCI_TYPE0_ADDRESSES; i++)
+    DPRINT("ListSize %lu (0x%lx)\n", ListSize, ListSize);
+
+    /* Allocate the resource requirements list */
+    ResourceList = ExAllocatePoolWithTag(PagedPool,
+                                         ListSize,
+                                         TAG_PCI);
+    if (ResourceList == NULL)
     {
-      if (!PdoGetRangeLength(DeviceExtension,
-                            0x10 + i * 4,
-                            &Base,
-                            &Length,
-                            &Flags))
-      {
-        DPRINT1("PdoGetRangeLength() failed\n");
-        break;
-      }
-
-      if (Length == 0)
-      {
-        DPRINT("Unused address register\n");
-        continue;
-      }
-
-      /* Set preferred descriptor */
-      Descriptor->Option = IO_RESOURCE_PREFERRED;
-      if (Flags & PCI_ADDRESS_IO_SPACE)
-      {
-        Descriptor->Type = CmResourceTypePort;
-        Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
-        Descriptor->Flags = CM_RESOURCE_PORT_IO |
-                            CM_RESOURCE_PORT_16_BIT_DECODE |
-                            CM_RESOURCE_PORT_POSITIVE_DECODE;
-
-        Descriptor->u.Port.Length = Length;
-        Descriptor->u.Port.Alignment = 1;
-        Descriptor->u.Port.MinimumAddress.QuadPart = (ULONGLONG)Base;
-        Descriptor->u.Port.MaximumAddress.QuadPart = (ULONGLONG)(Base + Length - 1);
-      }
-      else
-      {
-        Descriptor->Type = CmResourceTypeMemory;
-        Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
-        Descriptor->Flags = CM_RESOURCE_MEMORY_READ_WRITE;
-
-        Descriptor->u.Memory.Length = Length;
-        Descriptor->u.Memory.Alignment = 1;
-        Descriptor->u.Memory.MinimumAddress.QuadPart = (ULONGLONG)Base;
-        Descriptor->u.Memory.MaximumAddress.QuadPart = (ULONGLONG)(Base + Length - 1);
-      }
-      Descriptor++;
-
-      /* Set alternative descriptor */
-      Descriptor->Option = IO_RESOURCE_ALTERNATIVE;
-      if (Flags & PCI_ADDRESS_IO_SPACE)
-      {
-        Descriptor->Type = CmResourceTypePort;
-        Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
-        Descriptor->Flags = CM_RESOURCE_PORT_IO |
-                            CM_RESOURCE_PORT_16_BIT_DECODE |
-                            CM_RESOURCE_PORT_POSITIVE_DECODE;
-
-        Descriptor->u.Port.Length = Length;
-        Descriptor->u.Port.Alignment = Length;
-        Descriptor->u.Port.MinimumAddress.QuadPart = (ULONGLONG)0;
-        Descriptor->u.Port.MaximumAddress.QuadPart = (ULONGLONG)0x00000000FFFFFFFF;
-      }
-      else
-      {
-        Descriptor->Type = CmResourceTypeMemory;
-        Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
-        Descriptor->Flags = CM_RESOURCE_MEMORY_READ_WRITE;
-
-        Descriptor->u.Memory.Length = Length;
-        Descriptor->u.Memory.Alignment = Length;
-        Descriptor->u.Port.MinimumAddress.QuadPart = (ULONGLONG)0;
-        Descriptor->u.Port.MaximumAddress.QuadPart = (ULONGLONG)0x00000000FFFFFFFF;
-      }
-      Descriptor++;
+        Irp->IoStatus.Information = 0;
+        return STATUS_INSUFFICIENT_RESOURCES;
     }
 
-    /* FIXME: Check ROM address */
+    RtlZeroMemory(ResourceList, ListSize);
+    ResourceList->ListSize = ListSize;
+    ResourceList->InterfaceType = PCIBus;
+    ResourceList->BusNumber = DeviceExtension->PciDevice->BusNumber;
+    ResourceList->SlotNumber = DeviceExtension->PciDevice->SlotNumber.u.AsULONG;
+    ResourceList->AlternativeLists = 1;
+
+    ResourceList->List[0].Version = 1;
+    ResourceList->List[0].Revision = 1;
+    ResourceList->List[0].Count = ResCount;
 
-    if (PciConfig.u.type0.InterruptPin != 0)
+    Descriptor = &ResourceList->List[0].Descriptors[0];
+    if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_DEVICE_TYPE)
     {
-      Descriptor->Option = 0; /* Required */
-      Descriptor->Type = CmResourceTypeInterrupt;
-      Descriptor->ShareDisposition = CmResourceShareShared;
-      Descriptor->Flags = CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE;
+        for (i = 0; i < PCI_TYPE0_ADDRESSES; i++)
+        {
+            if (!PdoGetRangeLength(DeviceExtension,
+                                   0x10 + i * 4,
+                                   &Base,
+                                   &Length,
+                                   &Flags))
+            {
+                DPRINT1("PdoGetRangeLength() failed\n");
+                break;
+            }
+
+            if (Length == 0)
+            {
+                DPRINT("Unused address register\n");
+                continue;
+            }
+
+            /* Set preferred descriptor */
+            Descriptor->Option = IO_RESOURCE_PREFERRED;
+            if (Flags & PCI_ADDRESS_IO_SPACE)
+            {
+                Descriptor->Type = CmResourceTypePort;
+                Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
+                Descriptor->Flags = CM_RESOURCE_PORT_IO |
+                                    CM_RESOURCE_PORT_16_BIT_DECODE |
+                                    CM_RESOURCE_PORT_POSITIVE_DECODE;
+
+                Descriptor->u.Port.Length = Length;
+                Descriptor->u.Port.Alignment = 1;
+                Descriptor->u.Port.MinimumAddress.QuadPart = (ULONGLONG)Base;
+                Descriptor->u.Port.MaximumAddress.QuadPart = (ULONGLONG)(Base + Length - 1);
+            }
+            else
+            {
+                Descriptor->Type = CmResourceTypeMemory;
+                Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
+                Descriptor->Flags = CM_RESOURCE_MEMORY_READ_WRITE;
+
+                Descriptor->u.Memory.Length = Length;
+                Descriptor->u.Memory.Alignment = 1;
+                Descriptor->u.Memory.MinimumAddress.QuadPart = (ULONGLONG)Base;
+                Descriptor->u.Memory.MaximumAddress.QuadPart = (ULONGLONG)(Base + Length - 1);
+            }
+            Descriptor++;
+
+            /* Set alternative descriptor */
+            Descriptor->Option = IO_RESOURCE_ALTERNATIVE;
+            if (Flags & PCI_ADDRESS_IO_SPACE)
+            {
+                Descriptor->Type = CmResourceTypePort;
+                Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
+                Descriptor->Flags = CM_RESOURCE_PORT_IO |
+                                    CM_RESOURCE_PORT_16_BIT_DECODE |
+                                    CM_RESOURCE_PORT_POSITIVE_DECODE;
+
+                Descriptor->u.Port.Length = Length;
+                Descriptor->u.Port.Alignment = Length;
+                Descriptor->u.Port.MinimumAddress.QuadPart = (ULONGLONG)0;
+                Descriptor->u.Port.MaximumAddress.QuadPart = (ULONGLONG)0x00000000FFFFFFFF;
+            }
+            else
+            {
+                Descriptor->Type = CmResourceTypeMemory;
+                Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
+                Descriptor->Flags = CM_RESOURCE_MEMORY_READ_WRITE;
+
+                Descriptor->u.Memory.Length = Length;
+                Descriptor->u.Memory.Alignment = Length;
+                Descriptor->u.Port.MinimumAddress.QuadPart = (ULONGLONG)0;
+                Descriptor->u.Port.MaximumAddress.QuadPart = (ULONGLONG)0x00000000FFFFFFFF;
+            }
+            Descriptor++;
+        }
 
-      Descriptor->u.Interrupt.MinimumVector = 0;
-      Descriptor->u.Interrupt.MaximumVector = 0xFF;
+        /* FIXME: Check ROM address */
+
+        if (PciConfig.u.type0.InterruptPin != 0)
+        {
+            Descriptor->Option = 0; /* Required */
+            Descriptor->Type = CmResourceTypeInterrupt;
+            Descriptor->ShareDisposition = CmResourceShareShared;
+            Descriptor->Flags = CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE;
+
+            Descriptor->u.Interrupt.MinimumVector = 0;
+            Descriptor->u.Interrupt.MaximumVector = 0xFF;
+        }
     }
-  }
-  else if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_BRIDGE_TYPE)
-  {
-    for (i = 0; i < PCI_TYPE1_ADDRESSES; i++)
+    else if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_BRIDGE_TYPE)
     {
-      if (!PdoGetRangeLength(DeviceExtension,
-                            0x10 + i * 4,
-                            &Base,
-                            &Length,
-                            &Flags))
-      {
-        DPRINT1("PdoGetRangeLength() failed\n");
-        break;
-      }
-
-      if (Length == 0)
-      {
-        DPRINT("Unused address register\n");
-        continue;
-      }
-
-      /* Set preferred descriptor */
-      Descriptor->Option = IO_RESOURCE_PREFERRED;
-      if (Flags & PCI_ADDRESS_IO_SPACE)
-      {
-        Descriptor->Type = CmResourceTypePort;
-        Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
-        Descriptor->Flags = CM_RESOURCE_PORT_IO |
-                            CM_RESOURCE_PORT_16_BIT_DECODE |
-                            CM_RESOURCE_PORT_POSITIVE_DECODE;
-
-        Descriptor->u.Port.Length = Length;
-        Descriptor->u.Port.Alignment = 1;
-        Descriptor->u.Port.MinimumAddress.QuadPart = (ULONGLONG)Base;
-        Descriptor->u.Port.MaximumAddress.QuadPart = (ULONGLONG)(Base + Length - 1);
-      }
-      else
-      {
-        Descriptor->Type = CmResourceTypeMemory;
-        Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
-        Descriptor->Flags = CM_RESOURCE_MEMORY_READ_WRITE;
-
-        Descriptor->u.Memory.Length = Length;
-        Descriptor->u.Memory.Alignment = 1;
-        Descriptor->u.Memory.MinimumAddress.QuadPart = (ULONGLONG)Base;
-        Descriptor->u.Memory.MaximumAddress.QuadPart = (ULONGLONG)(Base + Length - 1);
-      }
-      Descriptor++;
-
-      /* Set alternative descriptor */
-      Descriptor->Option = IO_RESOURCE_ALTERNATIVE;
-      if (Flags & PCI_ADDRESS_IO_SPACE)
-      {
-        Descriptor->Type = CmResourceTypePort;
-        Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
-        Descriptor->Flags = CM_RESOURCE_PORT_IO |
-                            CM_RESOURCE_PORT_16_BIT_DECODE |
-                            CM_RESOURCE_PORT_POSITIVE_DECODE;
-
-        Descriptor->u.Port.Length = Length;
-        Descriptor->u.Port.Alignment = Length;
-        Descriptor->u.Port.MinimumAddress.QuadPart = (ULONGLONG)0;
-        Descriptor->u.Port.MaximumAddress.QuadPart = (ULONGLONG)0x00000000FFFFFFFF;
-      }
-      else
-      {
-        Descriptor->Type = CmResourceTypeMemory;
-        Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
-        Descriptor->Flags = CM_RESOURCE_MEMORY_READ_WRITE;
-
-        Descriptor->u.Memory.Length = Length;
-        Descriptor->u.Memory.Alignment = Length;
-        Descriptor->u.Port.MinimumAddress.QuadPart = (ULONGLONG)0;
-        Descriptor->u.Port.MaximumAddress.QuadPart = (ULONGLONG)0x00000000FFFFFFFF;
-      }
-      Descriptor++;
+        for (i = 0; i < PCI_TYPE1_ADDRESSES; i++)
+        {
+            if (!PdoGetRangeLength(DeviceExtension,
+                                   0x10 + i * 4,
+                                   &Base,
+                                   &Length,
+                                   &Flags))
+            {
+                DPRINT1("PdoGetRangeLength() failed\n");
+                break;
+            }
+
+            if (Length == 0)
+            {
+                DPRINT("Unused address register\n");
+                continue;
+            }
+
+            /* Set preferred descriptor */
+            Descriptor->Option = IO_RESOURCE_PREFERRED;
+            if (Flags & PCI_ADDRESS_IO_SPACE)
+            {
+                Descriptor->Type = CmResourceTypePort;
+                Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
+                Descriptor->Flags = CM_RESOURCE_PORT_IO |
+                                    CM_RESOURCE_PORT_16_BIT_DECODE |
+                                    CM_RESOURCE_PORT_POSITIVE_DECODE;
+
+                Descriptor->u.Port.Length = Length;
+                Descriptor->u.Port.Alignment = 1;
+                Descriptor->u.Port.MinimumAddress.QuadPart = (ULONGLONG)Base;
+                Descriptor->u.Port.MaximumAddress.QuadPart = (ULONGLONG)(Base + Length - 1);
+            }
+            else
+            {
+                Descriptor->Type = CmResourceTypeMemory;
+                Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
+                Descriptor->Flags = CM_RESOURCE_MEMORY_READ_WRITE;
+
+                Descriptor->u.Memory.Length = Length;
+                Descriptor->u.Memory.Alignment = 1;
+                Descriptor->u.Memory.MinimumAddress.QuadPart = (ULONGLONG)Base;
+                Descriptor->u.Memory.MaximumAddress.QuadPart = (ULONGLONG)(Base + Length - 1);
+            }
+            Descriptor++;
+
+            /* Set alternative descriptor */
+            Descriptor->Option = IO_RESOURCE_ALTERNATIVE;
+            if (Flags & PCI_ADDRESS_IO_SPACE)
+            {
+                Descriptor->Type = CmResourceTypePort;
+                Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
+                Descriptor->Flags = CM_RESOURCE_PORT_IO |
+                                    CM_RESOURCE_PORT_16_BIT_DECODE |
+                                    CM_RESOURCE_PORT_POSITIVE_DECODE;
+
+                Descriptor->u.Port.Length = Length;
+                Descriptor->u.Port.Alignment = Length;
+                Descriptor->u.Port.MinimumAddress.QuadPart = (ULONGLONG)0;
+                Descriptor->u.Port.MaximumAddress.QuadPart = (ULONGLONG)0x00000000FFFFFFFF;
+            }
+            else
+            {
+                Descriptor->Type = CmResourceTypeMemory;
+                Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
+                Descriptor->Flags = CM_RESOURCE_MEMORY_READ_WRITE;
+
+                Descriptor->u.Memory.Length = Length;
+                Descriptor->u.Memory.Alignment = Length;
+                Descriptor->u.Port.MinimumAddress.QuadPart = (ULONGLONG)0;
+                Descriptor->u.Port.MaximumAddress.QuadPart = (ULONGLONG)0x00000000FFFFFFFF;
+            }
+            Descriptor++;
+        }
+
+        if (DeviceExtension->PciDevice->PciConfig.BaseClass == PCI_CLASS_BRIDGE_DEV)
+        {
+            Descriptor->Option = 0; /* Required */
+            Descriptor->Type = CmResourceTypeBusNumber;
+            Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
+
+            ResourceList->BusNumber =
+            Descriptor->u.BusNumber.MinBusNumber =
+            Descriptor->u.BusNumber.MaxBusNumber = DeviceExtension->PciDevice->PciConfig.u.type1.SecondaryBus;
+            Descriptor->u.BusNumber.Length = 1;
+            Descriptor->u.BusNumber.Reserved = 0;
+        }
     }
-    if (DeviceExtension->PciDevice->PciConfig.BaseClass == PCI_CLASS_BRIDGE_DEV)
+    else if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_CARDBUS_BRIDGE_TYPE)
     {
-      Descriptor->Option = 0; /* Required */
-      Descriptor->Type = CmResourceTypeBusNumber;
-      Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
-
-      ResourceList->BusNumber =
-      Descriptor->u.BusNumber.MinBusNumber =
-      Descriptor->u.BusNumber.MaxBusNumber = DeviceExtension->PciDevice->PciConfig.u.type1.SecondaryBus;
-      Descriptor->u.BusNumber.Length = 1;
-      Descriptor->u.BusNumber.Reserved = 0;
+        /* FIXME: Add Cardbus bridge resources */
     }
-  }
-  else if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_CARDBUS_BRIDGE_TYPE)
-  {
-    /* FIXME: Add Cardbus bridge resources */
-  }
 
-  Irp->IoStatus.Information = (ULONG_PTR)ResourceList;
+    Irp->IoStatus.Information = (ULONG_PTR)ResourceList;
 
-  return STATUS_SUCCESS;
+    return STATUS_SUCCESS;
 }
 
 
 static NTSTATUS
 PdoQueryResources(
-  IN PDEVICE_OBJECT DeviceObject,
-  IN PIRP Irp,
-  PIO_STACK_LOCATION IrpSp)
+    IN PDEVICE_OBJECT DeviceObject,
+    IN PIRP Irp,
+    PIO_STACK_LOCATION IrpSp)
 {
-  PPDO_DEVICE_EXTENSION DeviceExtension;
-  PCI_COMMON_CONFIG PciConfig;
-  PCM_RESOURCE_LIST ResourceList;
-  PCM_PARTIAL_RESOURCE_LIST PartialList;
-  PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor;
-  ULONG Size;
-  ULONG ResCount = 0;
-  ULONG ListSize;
-  ULONG i;
-  ULONG Base;
-  ULONG Length;
-  ULONG Flags;
-
-  DPRINT("PdoQueryResources() called\n");
-
-  UNREFERENCED_PARAMETER(IrpSp);
-  DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
-
-  /* Get PCI configuration space */
-  Size= HalGetBusData(PCIConfiguration,
-                      DeviceExtension->PciDevice->BusNumber,
-                      DeviceExtension->PciDevice->SlotNumber.u.AsULONG,
-                      &PciConfig,
-                      PCI_COMMON_HDR_LENGTH);
-  DPRINT("Size %lu\n", Size);
-  if (Size < PCI_COMMON_HDR_LENGTH)
-  {
-    Irp->IoStatus.Information = 0;
-    return STATUS_UNSUCCESSFUL;
-  }
-
-  DPRINT("Command register: 0x%04hx\n", PciConfig.Command);
-
-  /* Count required resource descriptors */
-  ResCount = 0;
-  if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_DEVICE_TYPE)
-  {
-    for (i = 0; i < PCI_TYPE0_ADDRESSES; i++)
-    {
-      if (!PdoGetRangeLength(DeviceExtension,
-                            0x10 + i * 4,
-                            &Base,
-                            &Length,
-                            &Flags))
-        break;
-
-      if (Length)
-        ResCount++;
-    }
-
-    if ((PciConfig.u.type0.InterruptPin != 0) &&
-        (PciConfig.u.type0.InterruptLine != 0) &&
-        (PciConfig.u.type0.InterruptLine != 0xFF))
-      ResCount++;
-  }
-  else if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_BRIDGE_TYPE)
-  {
-    for (i = 0; i < PCI_TYPE1_ADDRESSES; i++)
+    PPDO_DEVICE_EXTENSION DeviceExtension;
+    PCI_COMMON_CONFIG PciConfig;
+    PCM_RESOURCE_LIST ResourceList;
+    PCM_PARTIAL_RESOURCE_LIST PartialList;
+    PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor;
+    ULONG Size;
+    ULONG ResCount = 0;
+    ULONG ListSize;
+    ULONG i;
+    ULONG Base;
+    ULONG Length;
+    ULONG Flags;
+
+    DPRINT("PdoQueryResources() called\n");
+
+    UNREFERENCED_PARAMETER(IrpSp);
+    DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+
+    /* Get PCI configuration space */
+    Size= HalGetBusData(PCIConfiguration,
+                        DeviceExtension->PciDevice->BusNumber,
+                        DeviceExtension->PciDevice->SlotNumber.u.AsULONG,
+                        &PciConfig,
+                        PCI_COMMON_HDR_LENGTH);
+    DPRINT("Size %lu\n", Size);
+    if (Size < PCI_COMMON_HDR_LENGTH)
     {
-      if (!PdoGetRangeLength(DeviceExtension,
-                            0x10 + i * 4,
-                            &Base,
-                            &Length,
-                            &Flags))
-        break;
-
-      if (Length != 0)
-        ResCount++;
+        Irp->IoStatus.Information = 0;
+        return STATUS_UNSUCCESSFUL;
     }
-    if (DeviceExtension->PciDevice->PciConfig.BaseClass == PCI_CLASS_BRIDGE_DEV)
-      ResCount++;
-  }
-  else if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_CARDBUS_BRIDGE_TYPE)
-  {
-    /* FIXME: Count Cardbus bridge resources */
-  }
-  else
-  {
-    DPRINT1("Unsupported header type %d\n", PCI_CONFIGURATION_TYPE(&PciConfig));
-  }
-
-  if (ResCount == 0)
-  {
-    Irp->IoStatus.Information = 0;
-    return STATUS_SUCCESS;
-  }
 
-  /* Calculate the resource list size */
-  ListSize = FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.PartialDescriptors)
-    + ResCount * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
+    DPRINT("Command register: 0x%04hx\n", PciConfig.Command);
 
-  /* Allocate the resource list */
-  ResourceList = ExAllocatePoolWithTag(PagedPool,
-                                ListSize, TAG_PCI);
-  if (ResourceList == NULL)
-    return STATUS_INSUFFICIENT_RESOURCES;
-
-  RtlZeroMemory(ResourceList, ListSize);
-  ResourceList->Count = 1;
-  ResourceList->List[0].InterfaceType = PCIBus;
-  ResourceList->List[0].BusNumber = DeviceExtension->PciDevice->BusNumber;
+    /* Count required resource descriptors */
+    ResCount = 0;
+    if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_DEVICE_TYPE)
+    {
+        for (i = 0; i < PCI_TYPE0_ADDRESSES; i++)
+        {
+            if (!PdoGetRangeLength(DeviceExtension,
+                                   0x10 + i * 4,
+                                   &Base,
+                                   &Length,
+                                   &Flags))
+                break;
+
+            if (Length)
+                ResCount++;
+        }
 
-  PartialList = &ResourceList->List[0].PartialResourceList;
-  PartialList->Version = 1;
-  PartialList->Revision = 1;
-  PartialList->Count = ResCount;
+        if ((PciConfig.u.type0.InterruptPin != 0) &&
+            (PciConfig.u.type0.InterruptLine != 0) &&
+            (PciConfig.u.type0.InterruptLine != 0xFF))
+            ResCount++;
+    }
+    else if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_BRIDGE_TYPE)
+    {
+        for (i = 0; i < PCI_TYPE1_ADDRESSES; i++)
+        {
+            if (!PdoGetRangeLength(DeviceExtension,
+                                   0x10 + i * 4,
+                                   &Base,
+                                   &Length,
+                                   &Flags))
+                break;
+
+            if (Length != 0)
+                ResCount++;
+        }
 
-  Descriptor = &PartialList->PartialDescriptors[0];
-  if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_DEVICE_TYPE)
-  {
-    for (i = 0; i < PCI_TYPE0_ADDRESSES; i++)
+        if (DeviceExtension->PciDevice->PciConfig.BaseClass == PCI_CLASS_BRIDGE_DEV)
+            ResCount++;
+    }
+    else if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_CARDBUS_BRIDGE_TYPE)
     {
-      if (!PdoGetRangeLength(DeviceExtension,
-                            0x10 + i * 4,
-                            &Base,
-                            &Length,
-                            &Flags))
-      {
-        DPRINT1("PdoGetRangeLength() failed\n");
-        break;
-      }
-
-      if (Length == 0)
-      {
-        DPRINT("Unused address register\n");
-        continue;
-      }
-
-      if (Flags & PCI_ADDRESS_IO_SPACE)
-      {
-        Descriptor->Type = CmResourceTypePort;
-        Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
-        Descriptor->Flags = CM_RESOURCE_PORT_IO;
-        Descriptor->u.Port.Start.QuadPart =
-          (ULONGLONG)Base;
-        Descriptor->u.Port.Length = Length;
-
-        /* Enable IO space access */
-        DeviceExtension->PciDevice->EnableIoSpace = TRUE;
-      }
-      else
-      {
-        Descriptor->Type = CmResourceTypeMemory;
-        Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
-        Descriptor->Flags = CM_RESOURCE_MEMORY_READ_WRITE;
-        Descriptor->u.Memory.Start.QuadPart =
-          (ULONGLONG)Base;
-        Descriptor->u.Memory.Length = Length;
-
-        /* Enable memory space access */
-        DeviceExtension->PciDevice->EnableMemorySpace = TRUE;
-      }
-
-      Descriptor++;
+        /* FIXME: Count Cardbus bridge resources */
+    }
+    else
+    {
+        DPRINT1("Unsupported header type %d\n", PCI_CONFIGURATION_TYPE(&PciConfig));
     }
 
-    /* Add interrupt resource */
-    if ((PciConfig.u.type0.InterruptPin != 0) &&
-        (PciConfig.u.type0.InterruptLine != 0) &&
-        (PciConfig.u.type0.InterruptLine != 0xFF))
+    if (ResCount == 0)
     {
-      Descriptor->Type = CmResourceTypeInterrupt;
-      Descriptor->ShareDisposition = CmResourceShareShared;
-      Descriptor->Flags = CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE;
-      Descriptor->u.Interrupt.Level = PciConfig.u.type0.InterruptLine;
-      Descriptor->u.Interrupt.Vector = PciConfig.u.type0.InterruptLine;
-      Descriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
+        Irp->IoStatus.Information = 0;
+        return STATUS_SUCCESS;
     }
 
-    /* Allow bus master mode */
-    DeviceExtension->PciDevice->EnableBusMaster = TRUE;
-  }
-  else if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_BRIDGE_TYPE)
-  {
-    for (i = 0; i < PCI_TYPE1_ADDRESSES; i++)
+    /* Calculate the resource list size */
+    ListSize = FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.PartialDescriptors) +
+               ResCount * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
+
+    /* Allocate the resource list */
+    ResourceList = ExAllocatePoolWithTag(PagedPool,
+                                         ListSize,
+                                         TAG_PCI);
+    if (ResourceList == NULL)
+        return STATUS_INSUFFICIENT_RESOURCES;
+
+    RtlZeroMemory(ResourceList, ListSize);
+    ResourceList->Count = 1;
+    ResourceList->List[0].InterfaceType = PCIBus;
+    ResourceList->List[0].BusNumber = DeviceExtension->PciDevice->BusNumber;
+
+    PartialList = &ResourceList->List[0].PartialResourceList;
+    PartialList->Version = 1;
+    PartialList->Revision = 1;
+    PartialList->Count = ResCount;
+
+    Descriptor = &PartialList->PartialDescriptors[0];
+    if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_DEVICE_TYPE)
     {
-      if (!PdoGetRangeLength(DeviceExtension,
-                            0x10 + i * 4,
-                            &Base,
-                            &Length,
-                            &Flags))
-      {
-        DPRINT1("PdoGetRangeLength() failed\n");
-        break;
-      }
-
-      if (Length == 0)
-      {
-        DPRINT("Unused address register\n");
-        continue;
-      }
-
-      if (Flags & PCI_ADDRESS_IO_SPACE)
-      {
-        Descriptor->Type = CmResourceTypePort;
-        Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
-        Descriptor->Flags = CM_RESOURCE_PORT_IO;
-        Descriptor->u.Port.Start.QuadPart =
-          (ULONGLONG)Base;
-        Descriptor->u.Port.Length = Length;
-
-        /* Enable IO space access */
-        DeviceExtension->PciDevice->EnableIoSpace = TRUE;
-      }
-      else
-      {
-        Descriptor->Type = CmResourceTypeMemory;
-        Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
-        Descriptor->Flags = CM_RESOURCE_MEMORY_READ_WRITE;
-        Descriptor->u.Memory.Start.QuadPart =
-          (ULONGLONG)Base;
-        Descriptor->u.Memory.Length = Length;
-
-        /* Enable memory space access */
-        DeviceExtension->PciDevice->EnableMemorySpace = TRUE;
-      }
-
-      Descriptor++;
+        for (i = 0; i < PCI_TYPE0_ADDRESSES; i++)
+        {
+            if (!PdoGetRangeLength(DeviceExtension,
+                                   0x10 + i * 4,
+                                   &Base,
+                                   &Length,
+                                   &Flags))
+            {
+                DPRINT1("PdoGetRangeLength() failed\n");
+                break;
+            }
+
+            if (Length == 0)
+            {
+                DPRINT("Unused address register\n");
+                continue;
+            }
+
+            if (Flags & PCI_ADDRESS_IO_SPACE)
+            {
+                Descriptor->Type = CmResourceTypePort;
+                Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
+                Descriptor->Flags = CM_RESOURCE_PORT_IO;
+                Descriptor->u.Port.Start.QuadPart = (ULONGLONG)Base;
+                Descriptor->u.Port.Length = Length;
+
+                /* Enable IO space access */
+                DeviceExtension->PciDevice->EnableIoSpace = TRUE;
+            }
+            else
+            {
+                Descriptor->Type = CmResourceTypeMemory;
+                Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
+                Descriptor->Flags = CM_RESOURCE_MEMORY_READ_WRITE;
+                Descriptor->u.Memory.Start.QuadPart = (ULONGLONG)Base;
+                Descriptor->u.Memory.Length = Length;
+
+                /* Enable memory space access */
+                DeviceExtension->PciDevice->EnableMemorySpace = TRUE;
+            }
+
+            Descriptor++;
+        }
+
+        /* Add interrupt resource */
+        if ((PciConfig.u.type0.InterruptPin != 0) &&
+            (PciConfig.u.type0.InterruptLine != 0) &&
+            (PciConfig.u.type0.InterruptLine != 0xFF))
+        {
+            Descriptor->Type = CmResourceTypeInterrupt;
+            Descriptor->ShareDisposition = CmResourceShareShared;
+            Descriptor->Flags = CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE;
+            Descriptor->u.Interrupt.Level = PciConfig.u.type0.InterruptLine;
+            Descriptor->u.Interrupt.Vector = PciConfig.u.type0.InterruptLine;
+            Descriptor->u.Interrupt.Affinity = 0xFFFFFFFF;
+        }
+
+        /* Allow bus master mode */
+       DeviceExtension->PciDevice->EnableBusMaster = TRUE;
     }
-    if (DeviceExtension->PciDevice->PciConfig.BaseClass == PCI_CLASS_BRIDGE_DEV)
+    else if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_BRIDGE_TYPE)
     {
-      Descriptor->Type = CmResourceTypeBusNumber;
-      Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
+        for (i = 0; i < PCI_TYPE1_ADDRESSES; i++)
+        {
+            if (!PdoGetRangeLength(DeviceExtension,
+                                   0x10 + i * 4,
+                                   &Base,
+                                   &Length,
+                                   &Flags))
+            {
+                DPRINT1("PdoGetRangeLength() failed\n");
+                break;
+            }
+
+            if (Length == 0)
+            {
+                DPRINT("Unused address register\n");
+                continue;
+            }
 
-      ResourceList->List[0].BusNumber =
-      Descriptor->u.BusNumber.Start = DeviceExtension->PciDevice->PciConfig.u.type1.SecondaryBus;
-      Descriptor->u.BusNumber.Length = 1;
-      Descriptor->u.BusNumber.Reserved = 0;
+            if (Flags & PCI_ADDRESS_IO_SPACE)
+            {
+                Descriptor->Type = CmResourceTypePort;
+                Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
+                Descriptor->Flags = CM_RESOURCE_PORT_IO;
+                Descriptor->u.Port.Start.QuadPart = (ULONGLONG)Base;
+                Descriptor->u.Port.Length = Length;
+
+                /* Enable IO space access */
+                DeviceExtension->PciDevice->EnableIoSpace = TRUE;
+            }
+            else
+            {
+                Descriptor->Type = CmResourceTypeMemory;
+                Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
+                Descriptor->Flags = CM_RESOURCE_MEMORY_READ_WRITE;
+                Descriptor->u.Memory.Start.QuadPart = (ULONGLONG)Base;
+                Descriptor->u.Memory.Length = Length;
+
+                /* Enable memory space access */
+                DeviceExtension->PciDevice->EnableMemorySpace = TRUE;
+            }
+
+            Descriptor++;
+        }
+
+        if (DeviceExtension->PciDevice->PciConfig.BaseClass == PCI_CLASS_BRIDGE_DEV)
+        {
+            Descriptor->Type = CmResourceTypeBusNumber;
+            Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
+
+            ResourceList->List[0].BusNumber =
+            Descriptor->u.BusNumber.Start = DeviceExtension->PciDevice->PciConfig.u.type1.SecondaryBus;
+            Descriptor->u.BusNumber.Length = 1;
+            Descriptor->u.BusNumber.Reserved = 0;
+        }
+    }
+    else if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_CARDBUS_BRIDGE_TYPE)
+    {
+        /* FIXME: Add Cardbus bridge resources */
     }
-  }
-  else if (PCI_CONFIGURATION_TYPE(&PciConfig) == PCI_CARDBUS_BRIDGE_TYPE)
-  {
-    /* FIXME: Add Cardbus bridge resources */
-  }
 
-  Irp->IoStatus.Information = (ULONG_PTR)ResourceList;
+    Irp->IoStatus.Information = (ULONG_PTR)ResourceList;
 
-  return STATUS_SUCCESS;
+    return STATUS_SUCCESS;
 }
 
 
 static VOID NTAPI
 InterfaceReference(
-  IN PVOID Context)
+    IN PVOID Context)
 {
-  PPDO_DEVICE_EXTENSION DeviceExtension;
+    PPDO_DEVICE_EXTENSION DeviceExtension;
 
-  DPRINT("InterfaceReference(%p)\n", Context);
+    DPRINT("InterfaceReference(%p)\n", Context);
 
-  DeviceExtension = (PPDO_DEVICE_EXTENSION)((PDEVICE_OBJECT)Context)->DeviceExtension;
-  InterlockedIncrement(&DeviceExtension->References);
+    DeviceExtension = (PPDO_DEVICE_EXTENSION)((PDEVICE_OBJECT)Context)->DeviceExtension;
+    InterlockedIncrement(&DeviceExtension->References);
 }
 
 
 static VOID NTAPI
 InterfaceDereference(
-  IN PVOID Context)
+    IN PVOID Context)
 {
-  PPDO_DEVICE_EXTENSION DeviceExtension;
+    PPDO_DEVICE_EXTENSION DeviceExtension;
 
-  DPRINT("InterfaceDereference(%p)\n", Context);
+    DPRINT("InterfaceDereference(%p)\n", Context);
 
-  DeviceExtension = (PPDO_DEVICE_EXTENSION)((PDEVICE_OBJECT)Context)->DeviceExtension;
-  InterlockedDecrement(&DeviceExtension->References);
+    DeviceExtension = (PPDO_DEVICE_EXTENSION)((PDEVICE_OBJECT)Context)->DeviceExtension;
+    InterlockedDecrement(&DeviceExtension->References);
 }
 
 static TRANSLATE_BUS_ADDRESS InterfaceBusTranslateBusAddress;
@@ -902,22 +901,24 @@ static
 BOOLEAN
 NTAPI
 InterfaceBusTranslateBusAddress(
-  IN PVOID Context,
-  IN PHYSICAL_ADDRESS BusAddress,
-  IN ULONG Length,
-  IN OUT PULONG AddressSpace,
-  OUT PPHYSICAL_ADDRESS TranslatedAddress)
+    IN PVOID Context,
+    IN PHYSICAL_ADDRESS BusAddress,
+    IN ULONG Length,
+    IN OUT PULONG AddressSpace,
+    OUT PPHYSICAL_ADDRESS TranslatedAddress)
 {
-  PPDO_DEVICE_EXTENSION DeviceExtension;
+    PPDO_DEVICE_EXTENSION DeviceExtension;
 
-  DPRINT("InterfaceBusTranslateBusAddress(%p %p 0x%lx %p %p)\n",
-    Context, BusAddress, Length, AddressSpace, TranslatedAddress);
+    DPRINT("InterfaceBusTranslateBusAddress(%p %p 0x%lx %p %p)\n",
+           Context, BusAddress, Length, AddressSpace, TranslatedAddress);
 
-  DeviceExtension = (PPDO_DEVICE_EXTENSION)((PDEVICE_OBJECT)Context)->DeviceExtension;
+    DeviceExtension = (PPDO_DEVICE_EXTENSION)((PDEVICE_OBJECT)Context)->DeviceExtension;
 
-  return HalTranslateBusAddress(
-    PCIBus, DeviceExtension->PciDevice->BusNumber,
-    BusAddress, AddressSpace, TranslatedAddress);
+    return HalTranslateBusAddress(PCIBus,
+                                  DeviceExtension->PciDevice->BusNumber,
+                                  BusAddress,
+                                  AddressSpace,
+                                  TranslatedAddress);
 }
 
 static GET_DMA_ADAPTER InterfaceBusGetDmaAdapter;
@@ -926,13 +927,13 @@ static
 PDMA_ADAPTER
 NTAPI
 InterfaceBusGetDmaAdapter(
-  IN PVOID Context,
-  IN PDEVICE_DESCRIPTION DeviceDescription,
-  OUT PULONG NumberOfMapRegisters)
+    IN PVOID Context,
+    IN PDEVICE_DESCRIPTION DeviceDescription,
+    OUT PULONG NumberOfMapRegisters)
 {
-  DPRINT("InterfaceBusGetDmaAdapter(%p %p %p)\n",
-    Context, DeviceDescription, NumberOfMapRegisters);
-  return (PDMA_ADAPTER)HalGetAdapter(DeviceDescription, NumberOfMapRegisters);
+    DPRINT("InterfaceBusGetDmaAdapter(%p %p %p)\n",
+           Context, DeviceDescription, NumberOfMapRegisters);
+    return (PDMA_ADAPTER)HalGetAdapter(DeviceDescription, NumberOfMapRegisters);
 }
 
 static GET_SET_DEVICE_DATA InterfaceBusSetBusData;
@@ -941,34 +942,34 @@ static
 ULONG
 NTAPI
 InterfaceBusSetBusData(
-  IN PVOID Context,
-  IN ULONG DataType,
-  IN PVOID Buffer,
-  IN ULONG Offset,
-  IN ULONG Length)
+    IN PVOID Context,
+    IN ULONG DataType,
+    IN PVOID Buffer,
+    IN ULONG Offset,
+    IN ULONG Length)
 {
-  PPDO_DEVICE_EXTENSION DeviceExtension;
-  ULONG Size;
+    PPDO_DEVICE_EXTENSION DeviceExtension;
+    ULONG Size;
 
-  DPRINT("InterfaceBusSetBusData(%p 0x%lx %p 0x%lx 0x%lx)\n",
-    Context, DataType, Buffer, Offset, Length);
+    DPRINT("InterfaceBusSetBusData(%p 0x%lx %p 0x%lx 0x%lx)\n",
+           Context, DataType, Buffer, Offset, Length);
 
-  if (DataType != PCI_WHICHSPACE_CONFIG)
-  {
-    DPRINT("Unknown DataType %lu\n", DataType);
-    return 0;
-  }
+    if (DataType != PCI_WHICHSPACE_CONFIG)
+    {
+        DPRINT("Unknown DataType %lu\n", DataType);
+        return 0;
+    }
 
-  DeviceExtension = (PPDO_DEVICE_EXTENSION)((PDEVICE_OBJECT)Context)->DeviceExtension;
+    DeviceExtension = (PPDO_DEVICE_EXTENSION)((PDEVICE_OBJECT)Context)->DeviceExtension;
 
-  /* Get PCI configuration space */
-  Size = HalSetBusDataByOffset(PCIConfiguration,
-                              DeviceExtension->PciDevice->BusNumber,
-                              DeviceExtension->PciDevice->SlotNumber.u.AsULONG,
-                              Buffer,
-                              Offset,
-                              Length);
-  return Size;
+    /* Get PCI configuration space */
+    Size = HalSetBusDataByOffset(PCIConfiguration,
+                                 DeviceExtension->PciDevice->BusNumber,
+                                 DeviceExtension->PciDevice->SlotNumber.u.AsULONG,
+                                 Buffer,
+                                 Offset,
+                                 Length);
+    return Size;
 }
 
 static GET_SET_DEVICE_DATA InterfaceBusGetBusData;
@@ -977,261 +978,267 @@ static
 ULONG
 NTAPI
 InterfaceBusGetBusData(
-  IN PVOID Context,
-  IN ULONG DataType,
-  IN PVOID Buffer,
-  IN ULONG Offset,
-  IN ULONG Length)
+    IN PVOID Context,
+    IN ULONG DataType,
+    IN PVOID Buffer,
+    IN ULONG Offset,
+    IN ULONG Length)
 {
-  PPDO_DEVICE_EXTENSION DeviceExtension;
-  ULONG Size;
+    PPDO_DEVICE_EXTENSION DeviceExtension;
+    ULONG Size;
 
-  DPRINT("InterfaceBusGetBusData(%p 0x%lx %p 0x%lx 0x%lx) called\n",
-    Context, DataType, Buffer, Offset, Length);
+    DPRINT("InterfaceBusGetBusData(%p 0x%lx %p 0x%lx 0x%lx) called\n",
+           Context, DataType, Buffer, Offset, Length);
 
-  if (DataType != PCI_WHICHSPACE_CONFIG)
-  {
-    DPRINT("Unknown DataType %lu\n", DataType);
-    return 0;
-  }
+    if (DataType != PCI_WHICHSPACE_CONFIG)
+    {
+        DPRINT("Unknown DataType %lu\n", DataType);
+        return 0;
+    }
 
-  DeviceExtension = (PPDO_DEVICE_EXTENSION)((PDEVICE_OBJECT)Context)->DeviceExtension;
+    DeviceExtension = (PPDO_DEVICE_EXTENSION)((PDEVICE_OBJECT)Context)->DeviceExtension;
 
-  /* Get PCI configuration space */
-  Size = HalGetBusDataByOffset(PCIConfiguration,
-                              DeviceExtension->PciDevice->BusNumber,
-                              DeviceExtension->PciDevice->SlotNumber.u.AsULONG,
-                              Buffer,
-                              Offset,
-                              Length);
-  return Size;
+    /* Get PCI configuration space */
+    Size = HalGetBusDataByOffset(PCIConfiguration,
+                                 DeviceExtension->PciDevice->BusNumber,
+                                 DeviceExtension->PciDevice->SlotNumber.u.AsULONG,
+                                 Buffer,
+                                 Offset,
+                                 Length);
+    return Size;
 }
 
 
 static BOOLEAN NTAPI
 InterfacePciDevicePresent(
-  IN USHORT VendorID,
-  IN USHORT DeviceID,
-  IN UCHAR RevisionID,
-  IN USHORT SubVendorID,
-  IN USHORT SubSystemID,
-  IN ULONG Flags)
+    IN USHORT VendorID,
+    IN USHORT DeviceID,
+    IN UCHAR RevisionID,
+    IN USHORT SubVendorID,
+    IN USHORT SubSystemID,
+    IN ULONG Flags)
 {
-  PFDO_DEVICE_EXTENSION FdoDeviceExtension;
-  PPCI_DEVICE PciDevice;
-  PLIST_ENTRY CurrentBus, CurrentEntry;
-  KIRQL OldIrql;
-  BOOLEAN Found = FALSE;
-
-  KeAcquireSpinLock(&DriverExtension->BusListLock, &OldIrql);
-  CurrentBus = DriverExtension->BusListHead.Flink;
-  while (!Found && CurrentBus != &DriverExtension->BusListHead)
-  {
-    FdoDeviceExtension = CONTAINING_RECORD(CurrentBus, FDO_DEVICE_EXTENSION, ListEntry);
-
-    KeAcquireSpinLockAtDpcLevel(&FdoDeviceExtension->DeviceListLock);
-    CurrentEntry = FdoDeviceExtension->DeviceListHead.Flink;
-    while (!Found && CurrentEntry != &FdoDeviceExtension->DeviceListHead)
+    PFDO_DEVICE_EXTENSION FdoDeviceExtension;
+    PPCI_DEVICE PciDevice;
+    PLIST_ENTRY CurrentBus, CurrentEntry;
+    KIRQL OldIrql;
+    BOOLEAN Found = FALSE;
+
+    KeAcquireSpinLock(&DriverExtension->BusListLock, &OldIrql);
+    CurrentBus = DriverExtension->BusListHead.Flink;
+    while (!Found && CurrentBus != &DriverExtension->BusListHead)
     {
-      PciDevice = CONTAINING_RECORD(CurrentEntry, PCI_DEVICE, ListEntry);
-      if (PciDevice->PciConfig.VendorID == VendorID &&
-        PciDevice->PciConfig.DeviceID == DeviceID)
-      {
-        if (!(Flags & PCI_USE_SUBSYSTEM_IDS) || (
-          PciDevice->PciConfig.u.type0.SubVendorID == SubVendorID &&
-          PciDevice->PciConfig.u.type0.SubSystemID == SubSystemID))
+        FdoDeviceExtension = CONTAINING_RECORD(CurrentBus, FDO_DEVICE_EXTENSION, ListEntry);
+
+        KeAcquireSpinLockAtDpcLevel(&FdoDeviceExtension->DeviceListLock);
+        CurrentEntry = FdoDeviceExtension->DeviceListHead.Flink;
+        while (!Found && CurrentEntry != &FdoDeviceExtension->DeviceListHead)
         {
-          if (!(Flags & PCI_USE_REVISION) ||
-            PciDevice->PciConfig.RevisionID == RevisionID)
-          {
-            DPRINT("Found the PCI device\n");
-            Found = TRUE;
-          }
+            PciDevice = CONTAINING_RECORD(CurrentEntry, PCI_DEVICE, ListEntry);
+            if (PciDevice->PciConfig.VendorID == VendorID &&
+                PciDevice->PciConfig.DeviceID == DeviceID)
+            {
+                if (!(Flags & PCI_USE_SUBSYSTEM_IDS) ||
+                    (PciDevice->PciConfig.u.type0.SubVendorID == SubVendorID &&
+                     PciDevice->PciConfig.u.type0.SubSystemID == SubSystemID))
+                {
+                    if (!(Flags & PCI_USE_REVISION) ||
+                        PciDevice->PciConfig.RevisionID == RevisionID)
+                    {
+                        DPRINT("Found the PCI device\n");
+                        Found = TRUE;
+                    }
+                }
+            }
+
+            CurrentEntry = CurrentEntry->Flink;
         }
-      }
 
-      CurrentEntry = CurrentEntry->Flink;
+        KeReleaseSpinLockFromDpcLevel(&FdoDeviceExtension->DeviceListLock);
+        CurrentBus = CurrentBus->Flink;
     }
+    KeReleaseSpinLock(&DriverExtension->BusListLock, OldIrql);
 
-    KeReleaseSpinLockFromDpcLevel(&FdoDeviceExtension->DeviceListLock);
-    CurrentBus = CurrentBus->Flink;
-  }
-  KeReleaseSpinLock(&DriverExtension->BusListLock, OldIrql);
-
-  return Found;
+    return Found;
 }
 
 
 static BOOLEAN
 CheckPciDevice(
-  IN PPCI_COMMON_CONFIG PciConfig,
-  IN PPCI_DEVICE_PRESENCE_PARAMETERS Parameters)
+    IN PPCI_COMMON_CONFIG PciConfig,
+    IN PPCI_DEVICE_PRESENCE_PARAMETERS Parameters)
 {
-  if ((Parameters->Flags & PCI_USE_VENDEV_IDS) && (
-    PciConfig->VendorID != Parameters->VendorID ||
-    PciConfig->DeviceID != Parameters->DeviceID))
-  {
-    return FALSE;
-  }
-  if ((Parameters->Flags & PCI_USE_CLASS_SUBCLASS) && (
-    PciConfig->BaseClass != Parameters->BaseClass ||
-    PciConfig->SubClass != Parameters->SubClass))
-  {
-    return FALSE;
-  }
-  if ((Parameters->Flags & PCI_USE_PROGIF) &&
-    PciConfig->ProgIf != Parameters->ProgIf)
-  {
-    return FALSE;
-  }
-  if ((Parameters->Flags & PCI_USE_SUBSYSTEM_IDS) && (
-    PciConfig->u.type0.SubVendorID != Parameters->SubVendorID ||
-    PciConfig->u.type0.SubSystemID != Parameters->SubSystemID))
-  {
-    return FALSE;
-  }
-  if ((Parameters->Flags & PCI_USE_REVISION) &&
-    PciConfig->RevisionID != Parameters->RevisionID)
-  {
-    return FALSE;
-  }
-  return TRUE;
+    if ((Parameters->Flags & PCI_USE_VENDEV_IDS) &&
+        (PciConfig->VendorID != Parameters->VendorID ||
+         PciConfig->DeviceID != Parameters->DeviceID))
+    {
+        return FALSE;
+    }
+
+    if ((Parameters->Flags & PCI_USE_CLASS_SUBCLASS) &&
+        (PciConfig->BaseClass != Parameters->BaseClass ||
+         PciConfig->SubClass != Parameters->SubClass))
+    {
+        return FALSE;
+    }
+
+    if ((Parameters->Flags & PCI_USE_PROGIF) &&
+         PciConfig->ProgIf != Parameters->ProgIf)
+    {
+        return FALSE;
+    }
+
+    if ((Parameters->Flags & PCI_USE_SUBSYSTEM_IDS) &&
+        (PciConfig->u.type0.SubVendorID != Parameters->SubVendorID ||
+         PciConfig->u.type0.SubSystemID != Parameters->SubSystemID))
+    {
+        return FALSE;
+    }
+
+    if ((Parameters->Flags & PCI_USE_REVISION) &&
+        PciConfig->RevisionID != Parameters->RevisionID)
+    {
+        return FALSE;
+    }
+
+    return TRUE;
 }
 
 
 static BOOLEAN NTAPI
 InterfacePciDevicePresentEx(
-  IN PVOID Context,
-  IN PPCI_DEVICE_PRESENCE_PARAMETERS Parameters)
+    IN PVOID Context,
+    IN PPCI_DEVICE_PRESENCE_PARAMETERS Parameters)
 {
-  PPDO_DEVICE_EXTENSION DeviceExtension;
-  PFDO_DEVICE_EXTENSION MyFdoDeviceExtension;
-  PFDO_DEVICE_EXTENSION FdoDeviceExtension;
-  PPCI_DEVICE PciDevice;
-  PLIST_ENTRY CurrentBus, CurrentEntry;
-  KIRQL OldIrql;
-  BOOLEAN Found = FALSE;
-
-  DPRINT("InterfacePciDevicePresentEx(%p %p) called\n",
-    Context, Parameters);
-
-  if (!Parameters || Parameters->Size != sizeof(PCI_DEVICE_PRESENCE_PARAMETERS))
-    return FALSE;
-
-  DeviceExtension = (PPDO_DEVICE_EXTENSION)((PDEVICE_OBJECT)Context)->DeviceExtension;
-  MyFdoDeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceExtension->Fdo->DeviceExtension;
-
-  if (Parameters->Flags & PCI_USE_LOCAL_DEVICE)
-  {
-    return CheckPciDevice(&DeviceExtension->PciDevice->PciConfig, Parameters);
-  }
-
-  KeAcquireSpinLock(&DriverExtension->BusListLock, &OldIrql);
-  CurrentBus = DriverExtension->BusListHead.Flink;
-  while (!Found && CurrentBus != &DriverExtension->BusListHead)
-  {
-    FdoDeviceExtension = CONTAINING_RECORD(CurrentBus, FDO_DEVICE_EXTENSION, ListEntry);
-    if (!(Parameters->Flags & PCI_USE_LOCAL_BUS) || FdoDeviceExtension == MyFdoDeviceExtension)
+    PPDO_DEVICE_EXTENSION DeviceExtension;
+    PFDO_DEVICE_EXTENSION MyFdoDeviceExtension;
+    PFDO_DEVICE_EXTENSION FdoDeviceExtension;
+    PPCI_DEVICE PciDevice;
+    PLIST_ENTRY CurrentBus, CurrentEntry;
+    KIRQL OldIrql;
+    BOOLEAN Found = FALSE;
+
+    DPRINT("InterfacePciDevicePresentEx(%p %p) called\n",
+           Context, Parameters);
+
+    if (!Parameters || Parameters->Size != sizeof(PCI_DEVICE_PRESENCE_PARAMETERS))
+        return FALSE;
+
+    DeviceExtension = (PPDO_DEVICE_EXTENSION)((PDEVICE_OBJECT)Context)->DeviceExtension;
+    MyFdoDeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceExtension->Fdo->DeviceExtension;
+
+    if (Parameters->Flags & PCI_USE_LOCAL_DEVICE)
     {
-      KeAcquireSpinLockAtDpcLevel(&FdoDeviceExtension->DeviceListLock);
-      CurrentEntry = FdoDeviceExtension->DeviceListHead.Flink;
-      while (!Found && CurrentEntry != &FdoDeviceExtension->DeviceListHead)
-      {
-        PciDevice = CONTAINING_RECORD(CurrentEntry, PCI_DEVICE, ListEntry);
+        return CheckPciDevice(&DeviceExtension->PciDevice->PciConfig, Parameters);
+    }
 
-        if (CheckPciDevice(&PciDevice->PciConfig, Parameters))
+    KeAcquireSpinLock(&DriverExtension->BusListLock, &OldIrql);
+    CurrentBus = DriverExtension->BusListHead.Flink;
+    while (!Found && CurrentBus != &DriverExtension->BusListHead)
+    {
+        FdoDeviceExtension = CONTAINING_RECORD(CurrentBus, FDO_DEVICE_EXTENSION, ListEntry);
+        if (!(Parameters->Flags & PCI_USE_LOCAL_BUS) || FdoDeviceExtension == MyFdoDeviceExtension)
         {
-          DPRINT("Found the PCI device\n");
-          Found = TRUE;
-        }
+            KeAcquireSpinLockAtDpcLevel(&FdoDeviceExtension->DeviceListLock);
+            CurrentEntry = FdoDeviceExtension->DeviceListHead.Flink;
+            while (!Found && CurrentEntry != &FdoDeviceExtension->DeviceListHead)
+            {
+                PciDevice = CONTAINING_RECORD(CurrentEntry, PCI_DEVICE, ListEntry);
+
+                if (CheckPciDevice(&PciDevice->PciConfig, Parameters))
+                {
+                    DPRINT("Found the PCI device\n");
+                    Found = TRUE;
+                }
 
-        CurrentEntry = CurrentEntry->Flink;
-      }
+                CurrentEntry = CurrentEntry->Flink;
+            }
 
-      KeReleaseSpinLockFromDpcLevel(&FdoDeviceExtension->DeviceListLock);
+            KeReleaseSpinLockFromDpcLevel(&FdoDeviceExtension->DeviceListLock);
+        }
+        CurrentBus = CurrentBus->Flink;
     }
-    CurrentBus = CurrentBus->Flink;
-  }
-  KeReleaseSpinLock(&DriverExtension->BusListLock, OldIrql);
+    KeReleaseSpinLock(&DriverExtension->BusListLock, OldIrql);
 
-  return Found;
+    return Found;
 }
 
 
 static NTSTATUS
 PdoQueryInterface(
-  IN PDEVICE_OBJECT DeviceObject,
-  IN PIRP Irp,
-  PIO_STACK_LOCATION IrpSp)
+    IN PDEVICE_OBJECT DeviceObject,
+    IN PIRP Irp,
+    PIO_STACK_LOCATION IrpSp)
 {
-  NTSTATUS Status;
-
-  UNREFERENCED_PARAMETER(Irp);
-  if (RtlCompareMemory(IrpSp->Parameters.QueryInterface.InterfaceType,
-    &GUID_BUS_INTERFACE_STANDARD, sizeof(GUID)) == sizeof(GUID))
-  {
-    /* BUS_INTERFACE_STANDARD */
-    if (IrpSp->Parameters.QueryInterface.Version < 1)
-      Status = STATUS_NOT_SUPPORTED;
-    else if (IrpSp->Parameters.QueryInterface.Size < sizeof(BUS_INTERFACE_STANDARD))
-      Status = STATUS_BUFFER_TOO_SMALL;
-    else
+    NTSTATUS Status;
+
+    UNREFERENCED_PARAMETER(Irp);
+
+    if (RtlCompareMemory(IrpSp->Parameters.QueryInterface.InterfaceType,
+                         &GUID_BUS_INTERFACE_STANDARD, sizeof(GUID)) == sizeof(GUID))
+    {
+        /* BUS_INTERFACE_STANDARD */
+        if (IrpSp->Parameters.QueryInterface.Version < 1)
+            Status = STATUS_NOT_SUPPORTED;
+        else if (IrpSp->Parameters.QueryInterface.Size < sizeof(BUS_INTERFACE_STANDARD))
+            Status = STATUS_BUFFER_TOO_SMALL;
+        else
+        {
+            PBUS_INTERFACE_STANDARD BusInterface;
+            BusInterface = (PBUS_INTERFACE_STANDARD)IrpSp->Parameters.QueryInterface.Interface;
+            BusInterface->Size = sizeof(BUS_INTERFACE_STANDARD);
+            BusInterface->Version = 1;
+            BusInterface->TranslateBusAddress = InterfaceBusTranslateBusAddress;
+            BusInterface->GetDmaAdapter = InterfaceBusGetDmaAdapter;
+            BusInterface->SetBusData = InterfaceBusSetBusData;
+            BusInterface->GetBusData = InterfaceBusGetBusData;
+            Status = STATUS_SUCCESS;
+        }
+    }
+    else if (RtlCompareMemory(IrpSp->Parameters.QueryInterface.InterfaceType,
+                              &GUID_PCI_DEVICE_PRESENT_INTERFACE, sizeof(GUID)) == sizeof(GUID))
     {
-      PBUS_INTERFACE_STANDARD BusInterface;
-      BusInterface = (PBUS_INTERFACE_STANDARD)IrpSp->Parameters.QueryInterface.Interface;
-      BusInterface->Size = sizeof(BUS_INTERFACE_STANDARD);
-      BusInterface->Version = 1;
-      BusInterface->TranslateBusAddress = InterfaceBusTranslateBusAddress;
-      BusInterface->GetDmaAdapter = InterfaceBusGetDmaAdapter;
-      BusInterface->SetBusData = InterfaceBusSetBusData;
-      BusInterface->GetBusData = InterfaceBusGetBusData;
-      Status = STATUS_SUCCESS;
+        /* PCI_DEVICE_PRESENT_INTERFACE */
+        if (IrpSp->Parameters.QueryInterface.Version < 1)
+            Status = STATUS_NOT_SUPPORTED;
+        else if (IrpSp->Parameters.QueryInterface.Size < sizeof(PCI_DEVICE_PRESENT_INTERFACE))
+            Status = STATUS_BUFFER_TOO_SMALL;
+        else
+        {
+            PPCI_DEVICE_PRESENT_INTERFACE PciDevicePresentInterface;
+            PciDevicePresentInterface = (PPCI_DEVICE_PRESENT_INTERFACE)IrpSp->Parameters.QueryInterface.Interface;
+            PciDevicePresentInterface->Size = sizeof(PCI_DEVICE_PRESENT_INTERFACE);
+            PciDevicePresentInterface->Version = 1;
+            PciDevicePresentInterface->IsDevicePresent = InterfacePciDevicePresent;
+            PciDevicePresentInterface->IsDevicePresentEx = InterfacePciDevicePresentEx;
+            Status = STATUS_SUCCESS;
+        }
     }
-  }
-  else if (RtlCompareMemory(IrpSp->Parameters.QueryInterface.InterfaceType,
-    &GUID_PCI_DEVICE_PRESENT_INTERFACE, sizeof(GUID)) == sizeof(GUID))
-  {
-    /* PCI_DEVICE_PRESENT_INTERFACE */
-    if (IrpSp->Parameters.QueryInterface.Version < 1)
-      Status = STATUS_NOT_SUPPORTED;
-    else if (IrpSp->Parameters.QueryInterface.Size < sizeof(PCI_DEVICE_PRESENT_INTERFACE))
-      Status = STATUS_BUFFER_TOO_SMALL;
     else
     {
-      PPCI_DEVICE_PRESENT_INTERFACE PciDevicePresentInterface;
-      PciDevicePresentInterface = (PPCI_DEVICE_PRESENT_INTERFACE)IrpSp->Parameters.QueryInterface.Interface;
-      PciDevicePresentInterface->Size = sizeof(PCI_DEVICE_PRESENT_INTERFACE);
-      PciDevicePresentInterface->Version = 1;
-      PciDevicePresentInterface->IsDevicePresent = InterfacePciDevicePresent;
-      PciDevicePresentInterface->IsDevicePresentEx = InterfacePciDevicePresentEx;
-      Status = STATUS_SUCCESS;
+        /* Not a supported interface */
+        return STATUS_NOT_SUPPORTED;
+    }
+
+    if (NT_SUCCESS(Status))
+    {
+        /* Add a reference for the returned interface */
+        PINTERFACE Interface;
+        Interface = (PINTERFACE)IrpSp->Parameters.QueryInterface.Interface;
+        Interface->Context = DeviceObject;
+        Interface->InterfaceReference = InterfaceReference;
+        Interface->InterfaceDereference = InterfaceDereference;
+        Interface->InterfaceReference(Interface->Context);
     }
-  }
-  else
-  {
-    /* Not a supported interface */
-    return STATUS_NOT_SUPPORTED;
-  }
-
-  if (NT_SUCCESS(Status))
-  {
-    /* Add a reference for the returned interface */
-    PINTERFACE Interface;
-    Interface = (PINTERFACE)IrpSp->Parameters.QueryInterface.Interface;
-    Interface->Context = DeviceObject;
-    Interface->InterfaceReference = InterfaceReference;
-    Interface->InterfaceDereference = InterfaceDereference;
-    Interface->InterfaceReference(Interface->Context);
-  }
-
-  return Status;
+
+    return Status;
 }
 
 static NTSTATUS
 PdoStartDevice(
-  IN PDEVICE_OBJECT DeviceObject,
-  IN PIRP Irp,
-  PIO_STACK_LOCATION IrpSp)
+    IN PDEVICE_OBJECT DeviceObject,
+    IN PIRP Irp,
+    PIO_STACK_LOCATION IrpSp)
 {
     PCM_RESOURCE_LIST RawResList = IrpSp->Parameters.StartDevice.AllocatedResources;
     PCM_FULL_RESOURCE_DESCRIPTOR RawFullDesc;
@@ -1321,115 +1328,118 @@ PdoStartDevice(
 
 static NTSTATUS
 PdoReadConfig(
-  IN PDEVICE_OBJECT DeviceObject,
-  IN PIRP Irp,
-  PIO_STACK_LOCATION IrpSp)
+    IN PDEVICE_OBJECT DeviceObject,
+    IN PIRP Irp,
+    PIO_STACK_LOCATION IrpSp)
 {
-  ULONG Size;
+    ULONG Size;
 
-  DPRINT("PdoReadConfig() called\n");
+    DPRINT("PdoReadConfig() called\n");
 
-  Size = InterfaceBusGetBusData(
-    DeviceObject,
-    IrpSp->Parameters.ReadWriteConfig.WhichSpace,
-    IrpSp->Parameters.ReadWriteConfig.Buffer,
-    IrpSp->Parameters.ReadWriteConfig.Offset,
-    IrpSp->Parameters.ReadWriteConfig.Length);
+    Size = InterfaceBusGetBusData(DeviceObject,
+                                  IrpSp->Parameters.ReadWriteConfig.WhichSpace,
+                                  IrpSp->Parameters.ReadWriteConfig.Buffer,
+                                  IrpSp->Parameters.ReadWriteConfig.Offset,
+                                  IrpSp->Parameters.ReadWriteConfig.Length);
 
-  if (Size != IrpSp->Parameters.ReadWriteConfig.Length)
-  {
-    DPRINT1("Size %lu  Length %lu\n", Size, IrpSp->Parameters.ReadWriteConfig.Length);
-    Irp->IoStatus.Information = 0;
-    return STATUS_UNSUCCESSFUL;
-  }
+    if (Size != IrpSp->Parameters.ReadWriteConfig.Length)
+    {
+        DPRINT1("Size %lu  Length %lu\n", Size, IrpSp->Parameters.ReadWriteConfig.Length);
+        Irp->IoStatus.Information = 0;
+        return STATUS_UNSUCCESSFUL;
+    }
 
-  Irp->IoStatus.Information = Size;
+    Irp->IoStatus.Information = Size;
 
-  return STATUS_SUCCESS;
+    return STATUS_SUCCESS;
 }
 
 
 static NTSTATUS
 PdoWriteConfig(
-  IN PDEVICE_OBJECT DeviceObject,
-  IN PIRP Irp,
-  PIO_STACK_LOCATION IrpSp)
+    IN PDEVICE_OBJECT DeviceObject,
+    IN PIRP Irp,
+    PIO_STACK_LOCATION IrpSp)
 {
-  ULONG Size;
+    ULONG Size;
 
-  DPRINT1("PdoWriteConfig() called\n");
+    DPRINT1("PdoWriteConfig() called\n");
 
-  /* Get PCI configuration space */
-  Size = InterfaceBusSetBusData(
-    DeviceObject,
-    IrpSp->Parameters.ReadWriteConfig.WhichSpace,
-    IrpSp->Parameters.ReadWriteConfig.Buffer,
-    IrpSp->Parameters.ReadWriteConfig.Offset,
-    IrpSp->Parameters.ReadWriteConfig.Length);
+    /* Get PCI configuration space */
+    Size = InterfaceBusSetBusData(DeviceObject,
+                                  IrpSp->Parameters.ReadWriteConfig.WhichSpace,
+                                  IrpSp->Parameters.ReadWriteConfig.Buffer,
+                                  IrpSp->Parameters.ReadWriteConfig.Offset,
+                                  IrpSp->Parameters.ReadWriteConfig.Length);
 
-  if (Size != IrpSp->Parameters.ReadWriteConfig.Length)
-  {
-    DPRINT1("Size %lu  Length %lu\n", Size, IrpSp->Parameters.ReadWriteConfig.Length);
-    Irp->IoStatus.Information = 0;
-    return STATUS_UNSUCCESSFUL;
-  }
+    if (Size != IrpSp->Parameters.ReadWriteConfig.Length)
+    {
+        DPRINT1("Size %lu  Length %lu\n", Size, IrpSp->Parameters.ReadWriteConfig.Length);
+        Irp->IoStatus.Information = 0;
+        return STATUS_UNSUCCESSFUL;
+    }
 
-  Irp->IoStatus.Information = Size;
+    Irp->IoStatus.Information = Size;
 
-  return STATUS_SUCCESS;
+    return STATUS_SUCCESS;
 }
 
 static NTSTATUS
 PdoQueryDeviceRelations(
-  IN PDEVICE_OBJECT DeviceObject,
-  IN PIRP Irp,
-  PIO_STACK_LOCATION IrpSp)
+    IN PDEVICE_OBJECT DeviceObject,
+    IN PIRP Irp,
+    PIO_STACK_LOCATION IrpSp)
 {
-  PDEVICE_RELATIONS DeviceRelations;
+    PDEVICE_RELATIONS DeviceRelations;
 
-  /* We only support TargetDeviceRelation for child PDOs */
-  if (IrpSp->Parameters.QueryDeviceRelations.Type != TargetDeviceRelation)
-      return Irp->IoStatus.Status;
+    /* We only support TargetDeviceRelation for child PDOs */
+    if (IrpSp->Parameters.QueryDeviceRelations.Type != TargetDeviceRelation)
+        return Irp->IoStatus.Status;
 
-  /* We can do this because we only return 1 PDO for TargetDeviceRelation */
-  DeviceRelations = ExAllocatePool(PagedPool, sizeof(*DeviceRelations));
-  if (!DeviceRelations)
-      return STATUS_INSUFFICIENT_RESOURCES;
+    /* We can do this because we only return 1 PDO for TargetDeviceRelation */
+    DeviceRelations = ExAllocatePool(PagedPool, sizeof(*DeviceRelations));
+    if (!DeviceRelations)
+        return STATUS_INSUFFICIENT_RESOURCES;
 
-  DeviceRelations->Count = 1;
-  DeviceRelations->Objects[0] = DeviceObject;
+    DeviceRelations->Count = 1;
+    DeviceRelations->Objects[0] = DeviceObject;
 
-  /* The PnP manager will remove this when it is done with the PDO */
-  ObReferenceObject(DeviceObject);
+    /* The PnP manager will remove this when it is done with the PDO */
+    ObReferenceObject(DeviceObject);
 
-  Irp->IoStatus.Information = (ULONG_PTR)DeviceRelations;
+    Irp->IoStatus.Information = (ULONG_PTR)DeviceRelations;
 
-  return STATUS_SUCCESS;
+    return STATUS_SUCCESS;
 }
 
 static NTSTATUS
 PdoSetPower(
-  IN PDEVICE_OBJECT DeviceObject,
-  IN PIRP Irp,
-  PIO_STACK_LOCATION IrpSp)
+    IN PDEVICE_OBJECT DeviceObject,
+    IN PIRP Irp,
+    PIO_STACK_LOCATION IrpSp)
 {
-  NTSTATUS Status;
+    NTSTATUS Status;
 
-  UNREFERENCED_PARAMETER(DeviceObject);
-  UNREFERENCED_PARAMETER(Irp);
-  DPRINT("Called\n");
+    UNREFERENCED_PARAMETER(DeviceObject);
+    UNREFERENCED_PARAMETER(Irp);
+    DPRINT("Called\n");
 
-  if (IrpSp->Parameters.Power.Type == DevicePowerState) {
-    Status = STATUS_SUCCESS;
-    switch (IrpSp->Parameters.Power.State.SystemState) {
-    default:
-      Status = STATUS_UNSUCCESSFUL;
+    if (IrpSp->Parameters.Power.Type == DevicePowerState)
+    {
+        Status = STATUS_SUCCESS;
+
+        switch (IrpSp->Parameters.Power.State.SystemState)
+        {
+            default:
+                Status = STATUS_UNSUCCESSFUL;
+        }
+    }
+    else
+    {
+        Status = STATUS_UNSUCCESSFUL;
     }
-  } else {
-    Status = STATUS_UNSUCCESSFUL;
-  }
 
-  return Status;
+    return Status;
 }
 
 
@@ -1437,8 +1447,8 @@ PdoSetPower(
 
 NTSTATUS
 PdoPnpControl(
-  PDEVICE_OBJECT DeviceObject,
-  PIRP Irp)
+    PDEVICE_OBJECT DeviceObject,
+    PIRP Irp)
 /*
  * FUNCTION: Handle Plug and Play IRPs for the child device
  * ARGUMENTS:
@@ -1448,142 +1458,143 @@ PdoPnpControl(
  *     Status
  */
 {
-  PIO_STACK_LOCATION IrpSp;
-  NTSTATUS Status;
-
-  DPRINT("Called\n");
-
-  Status = Irp->IoStatus.Status;
-
-  IrpSp = IoGetCurrentIrpStackLocation(Irp);
-
-  switch (IrpSp->MinorFunction) {
-
-  case IRP_MN_DEVICE_USAGE_NOTIFICATION:
-        DPRINT("Unimplemented IRP_MN_DEVICE_USAGE_NOTIFICATION received\n");
-    break;
-
-  case IRP_MN_EJECT:
-        DPRINT("Unimplemented IRP_MN_EJECT received\n");
-    break;
-
-  case IRP_MN_QUERY_BUS_INFORMATION:
-    Status = PdoQueryBusInformation(DeviceObject, Irp, IrpSp);
-    break;
-
-  case IRP_MN_QUERY_CAPABILITIES:
-    Status = PdoQueryCapabilities(DeviceObject, Irp, IrpSp);
-    break;
-
-  case IRP_MN_QUERY_DEVICE_RELATIONS:
-    Status = PdoQueryDeviceRelations(DeviceObject, Irp, IrpSp);
-    break;
-
-  case IRP_MN_QUERY_DEVICE_TEXT:
-    DPRINT("IRP_MN_QUERY_DEVICE_TEXT received\n");
-    Status = PdoQueryDeviceText(DeviceObject, Irp, IrpSp);
-    break;
-
-  case IRP_MN_QUERY_ID:
-    DPRINT("IRP_MN_QUERY_ID received\n");
-    Status = PdoQueryId(DeviceObject, Irp, IrpSp);
-    break;
-
-  case IRP_MN_QUERY_PNP_DEVICE_STATE:
-    DPRINT("Unimplemented IRP_MN_QUERY_ID received\n");
-    break;
+    PIO_STACK_LOCATION IrpSp;
+    NTSTATUS Status;
 
-  case IRP_MN_QUERY_RESOURCE_REQUIREMENTS:
-    DPRINT("IRP_MN_QUERY_RESOURCE_REQUIREMENTS received\n");
-    Status = PdoQueryResourceRequirements(DeviceObject, Irp, IrpSp);
-    break;
+    DPRINT("Called\n");
 
-  case IRP_MN_QUERY_RESOURCES:
-    DPRINT("IRP_MN_QUERY_RESOURCES received\n");
-    Status = PdoQueryResources(DeviceObject, Irp, IrpSp);
-    break;
+    Status = Irp->IoStatus.Status;
 
-  case IRP_MN_SET_LOCK:
-    DPRINT("Unimplemented IRP_MN_SET_LOCK received\n");
-    break;
+    IrpSp = IoGetCurrentIrpStackLocation(Irp);
 
-  case IRP_MN_START_DEVICE:
-    Status = PdoStartDevice(DeviceObject, Irp, IrpSp);
-    break;
-
-  case IRP_MN_QUERY_STOP_DEVICE:
-  case IRP_MN_CANCEL_STOP_DEVICE:
-  case IRP_MN_STOP_DEVICE:
-  case IRP_MN_QUERY_REMOVE_DEVICE:
-  case IRP_MN_CANCEL_REMOVE_DEVICE:
-  case IRP_MN_SURPRISE_REMOVAL:
-    Status = STATUS_SUCCESS;
-    break;
-
-  case IRP_MN_REMOVE_DEVICE:
-  {
-    PPDO_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
-    PFDO_DEVICE_EXTENSION FdoDeviceExtension = DeviceExtension->Fdo->DeviceExtension;
-    KIRQL OldIrql;
+    switch (IrpSp->MinorFunction)
+    {
+        case IRP_MN_DEVICE_USAGE_NOTIFICATION:
+            DPRINT("Unimplemented IRP_MN_DEVICE_USAGE_NOTIFICATION received\n");
+            break;
+
+        case IRP_MN_EJECT:
+            DPRINT("Unimplemented IRP_MN_EJECT received\n");
+            break;
+
+        case IRP_MN_QUERY_BUS_INFORMATION:
+            Status = PdoQueryBusInformation(DeviceObject, Irp, IrpSp);
+            break;
+
+        case IRP_MN_QUERY_CAPABILITIES:
+            Status = PdoQueryCapabilities(DeviceObject, Irp, IrpSp);
+            break;
+
+        case IRP_MN_QUERY_DEVICE_RELATIONS:
+            Status = PdoQueryDeviceRelations(DeviceObject, Irp, IrpSp);
+            break;
+
+        case IRP_MN_QUERY_DEVICE_TEXT:
+            DPRINT("IRP_MN_QUERY_DEVICE_TEXT received\n");
+            Status = PdoQueryDeviceText(DeviceObject, Irp, IrpSp);
+            break;
+
+        case IRP_MN_QUERY_ID:
+            DPRINT("IRP_MN_QUERY_ID received\n");
+            Status = PdoQueryId(DeviceObject, Irp, IrpSp);
+            break;
+
+        case IRP_MN_QUERY_PNP_DEVICE_STATE:
+            DPRINT("Unimplemented IRP_MN_QUERY_ID received\n");
+            break;
+
+        case IRP_MN_QUERY_RESOURCE_REQUIREMENTS:
+            DPRINT("IRP_MN_QUERY_RESOURCE_REQUIREMENTS received\n");
+            Status = PdoQueryResourceRequirements(DeviceObject, Irp, IrpSp);
+            break;
+
+        case IRP_MN_QUERY_RESOURCES:
+            DPRINT("IRP_MN_QUERY_RESOURCES received\n");
+            Status = PdoQueryResources(DeviceObject, Irp, IrpSp);
+            break;
+
+        case IRP_MN_SET_LOCK:
+            DPRINT("Unimplemented IRP_MN_SET_LOCK received\n");
+            break;
+
+        case IRP_MN_START_DEVICE:
+            Status = PdoStartDevice(DeviceObject, Irp, IrpSp);
+            break;
+
+        case IRP_MN_QUERY_STOP_DEVICE:
+        case IRP_MN_CANCEL_STOP_DEVICE:
+        case IRP_MN_STOP_DEVICE:
+        case IRP_MN_QUERY_REMOVE_DEVICE:
+        case IRP_MN_CANCEL_REMOVE_DEVICE:
+        case IRP_MN_SURPRISE_REMOVAL:
+            Status = STATUS_SUCCESS;
+            break;
+
+        case IRP_MN_REMOVE_DEVICE:
+            {
+                PPDO_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
+                PFDO_DEVICE_EXTENSION FdoDeviceExtension = DeviceExtension->Fdo->DeviceExtension;
+                KIRQL OldIrql;
+
+                /* Remove it from the device list */
+                KeAcquireSpinLock(&FdoDeviceExtension->DeviceListLock, &OldIrql);
+                RemoveEntryList(&DeviceExtension->PciDevice->ListEntry);
+                FdoDeviceExtension->DeviceListCount--;
+                KeReleaseSpinLock(&FdoDeviceExtension->DeviceListLock, OldIrql);
+
+                /* Free the device */
+                ExFreePool(DeviceExtension->PciDevice);
+
+                /* Complete the IRP */
+                Irp->IoStatus.Status = STATUS_SUCCESS;
+                IoCompleteRequest(Irp, IO_NO_INCREMENT);
+
+                /* Delete the DO */
+                IoDeleteDevice(DeviceObject);
+                return STATUS_SUCCESS;
+            }
 
-    /* Remove it from the device list */
-    KeAcquireSpinLock(&FdoDeviceExtension->DeviceListLock, &OldIrql);
-    RemoveEntryList(&DeviceExtension->PciDevice->ListEntry);
-    FdoDeviceExtension->DeviceListCount--;
-    KeReleaseSpinLock(&FdoDeviceExtension->DeviceListLock, OldIrql);
+        case IRP_MN_QUERY_INTERFACE:
+            DPRINT("IRP_MN_QUERY_INTERFACE received\n");
+            Status = PdoQueryInterface(DeviceObject, Irp, IrpSp);
+            break;
+
+        case IRP_MN_READ_CONFIG:
+            DPRINT("IRP_MN_READ_CONFIG received\n");
+            Status = PdoReadConfig(DeviceObject, Irp, IrpSp);
+            break;
+
+        case IRP_MN_WRITE_CONFIG:
+            DPRINT("IRP_MN_WRITE_CONFIG received\n");
+            Status = PdoWriteConfig(DeviceObject, Irp, IrpSp);
+            break;
+
+        case IRP_MN_FILTER_RESOURCE_REQUIREMENTS:
+            DPRINT("IRP_MN_FILTER_RESOURCE_REQUIREMENTS received\n");
+            /* Nothing to do */
+            Irp->IoStatus.Status = Status;
+            break;
+
+        default:
+            DPRINT1("Unknown IOCTL 0x%lx\n", IrpSp->MinorFunction);
+            break;
+    }
 
-    /* Free the device */
-    ExFreePool(DeviceExtension->PciDevice);
+    if (Status != STATUS_PENDING)
+    {
+        Irp->IoStatus.Status = Status;
+        IoCompleteRequest(Irp, IO_NO_INCREMENT);
+    }
 
-    /* Complete the IRP */
-    Irp->IoStatus.Status = STATUS_SUCCESS;
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
+    DPRINT("Leaving. Status 0x%X\n", Status);
 
-    /* Delete the DO */
-    IoDeleteDevice(DeviceObject);
-    return STATUS_SUCCESS;
-  }
-
-  case IRP_MN_QUERY_INTERFACE:
-    DPRINT("IRP_MN_QUERY_INTERFACE received\n");
-    Status = PdoQueryInterface(DeviceObject, Irp, IrpSp);
-    break;
-
-  case IRP_MN_READ_CONFIG:
-    DPRINT("IRP_MN_READ_CONFIG received\n");
-    Status = PdoReadConfig(DeviceObject, Irp, IrpSp);
-    break;
-
-  case IRP_MN_WRITE_CONFIG:
-    DPRINT("IRP_MN_WRITE_CONFIG received\n");
-    Status = PdoWriteConfig(DeviceObject, Irp, IrpSp);
-    break;
-
-  case IRP_MN_FILTER_RESOURCE_REQUIREMENTS:
-    DPRINT("IRP_MN_FILTER_RESOURCE_REQUIREMENTS received\n");
-    /* Nothing to do */
-    Irp->IoStatus.Status = Status;
-    break;
-
-  default:
-    DPRINT1("Unknown IOCTL 0x%lx\n", IrpSp->MinorFunction);
-    break;
-  }
-
-  if (Status != STATUS_PENDING) {
-    Irp->IoStatus.Status = Status;
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-  }
-
-  DPRINT("Leaving. Status 0x%X\n", Status);
-
-  return Status;
+    return Status;
 }
 
 NTSTATUS
 PdoPowerControl(
-  PDEVICE_OBJECT DeviceObject,
-  PIRP Irp)
+    PDEVICE_OBJECT DeviceObject,
+    PIRP Irp)
 /*
  * FUNCTION: Handle power management IRPs for the child device
  * ARGUMENTS:
@@ -1593,32 +1604,34 @@ PdoPowerControl(
  *     Status
  */
 {
-  PIO_STACK_LOCATION IrpSp;
-  NTSTATUS Status;
-
-  DPRINT("Called\n");
+    PIO_STACK_LOCATION IrpSp;
+    NTSTATUS Status;
 
-  IrpSp = IoGetCurrentIrpStackLocation(Irp);
+    DPRINT("Called\n");
 
-  switch (IrpSp->MinorFunction) {
-  case IRP_MN_SET_POWER:
-    Status = PdoSetPower(DeviceObject, Irp, IrpSp);
-    break;
+    IrpSp = IoGetCurrentIrpStackLocation(Irp);
 
-  default:
-    DPRINT("Unknown IOCTL 0x%X\n", IrpSp->MinorFunction);
-    Status = STATUS_NOT_IMPLEMENTED;
-    break;
-  }
+    switch (IrpSp->MinorFunction)
+    {
+        case IRP_MN_SET_POWER:
+            Status = PdoSetPower(DeviceObject, Irp, IrpSp);
+            break;
+
+        default:
+            DPRINT("Unknown IOCTL 0x%X\n", IrpSp->MinorFunction);
+            Status = STATUS_NOT_IMPLEMENTED;
+            break;
+    }
 
-  if (Status != STATUS_PENDING) {
-    Irp->IoStatus.Status = Status;
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-  }
+    if (Status != STATUS_PENDING)
+    {
+        Irp->IoStatus.Status = Status;
+        IoCompleteRequest(Irp, IO_NO_INCREMENT);
+    }
 
-  DPRINT("Leaving. Status 0x%X\n", Status);
+    DPRINT("Leaving. Status 0x%X\n", Status);
 
-  return Status;
+    return Status;
 }
 
 /* EOF */