- Fill Level field in DEVICE_NODE structure
[reactos.git] / reactos / drivers / bus / pci / pci.c
index 85970fb..ff31d77 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: pci.c,v 1.9 2004/08/20 13:33:51 ekohl Exp $
+/* $Id$
  *
  * PROJECT:         ReactOS PCI Bus driver
  * FILE:            pci.c
@@ -9,6 +9,8 @@
  */
 
 #include <ddk/ntddk.h>
+#include <ddk/ntifs.h>
+#include <stdio.h>
 
 #include "pcidef.h"
 #include "pci.h"
@@ -19,7 +21,7 @@
 
 #ifdef  ALLOC_PRAGMA
 
-// Make the initialization routines discardable, so that they 
+// Make the initialization routines discardable, so that they
 // don't waste space
 
 #pragma  alloc_text(init, DriverEntry)
 
 /*** PRIVATE *****************************************************************/
 
-NTSTATUS
+static NTSTATUS
 STDCALL
 PciDispatchDeviceControl(
-  IN PDEVICE_OBJECT DeviceObject, 
-  IN PIRP Irp) 
+  IN PDEVICE_OBJECT DeviceObject,
+  IN PIRP Irp)
 {
   PIO_STACK_LOCATION IrpSp;
   NTSTATUS Status;
@@ -66,7 +68,7 @@ PciDispatchDeviceControl(
 }
 
 
-NTSTATUS
+static NTSTATUS
 STDCALL
 PciPnpControl(
   IN PDEVICE_OBJECT DeviceObject,
@@ -97,7 +99,7 @@ PciPnpControl(
 }
 
 
-NTSTATUS
+static NTSTATUS
 STDCALL
 PciPowerControl(
   IN PDEVICE_OBJECT DeviceObject,
@@ -126,7 +128,7 @@ PciPowerControl(
 }
 
 
-NTSTATUS
+static NTSTATUS
 STDCALL
 PciAddDevice(
   IN PDRIVER_OBJECT DriverObject,
@@ -172,7 +174,7 @@ DriverEntry(
   IN PDRIVER_OBJECT DriverObject,
   IN PUNICODE_STRING RegistryPath)
 {
-  DbgPrint("Peripheral Component Interconnect Bus Driver\n");
+  DPRINT("Peripheral Component Interconnect Bus Driver\n");
 
   DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = PciDispatchDeviceControl;
   DriverObject->MajorFunction[IRP_MJ_PNP] = PciPnpControl;
@@ -183,65 +185,6 @@ DriverEntry(
 }
 
 
-BOOLEAN
-PciCreateUnicodeString(
-  PUNICODE_STRING Destination,
-  PWSTR Source,
-  POOL_TYPE PoolType)
-{
-  ULONG Length;
-
-  if (!Source)
-  {
-    RtlInitUnicodeString(Destination, NULL);
-    return TRUE;
-  }
-
-  Length = (wcslen(Source) + 1) * sizeof(WCHAR);
-
-  Destination->Buffer = ExAllocatePool(PoolType, Length);
-
-  if (Destination->Buffer == NULL)
-  {
-    return FALSE;
-  }
-
-  RtlCopyMemory(Destination->Buffer, Source, Length);
-
-  Destination->MaximumLength = Length;
-
-  Destination->Length = Length - sizeof(WCHAR);
-
-  return TRUE;
-}
-
-
-NTSTATUS
-PciDuplicateUnicodeString(
-  PUNICODE_STRING Destination,
-  PUNICODE_STRING Source,
-  POOL_TYPE PoolType)
-{
-  if (Source == NULL)
-  {
-    RtlInitUnicodeString(Destination, NULL);
-    return STATUS_SUCCESS;
-  }
-
-  Destination->Buffer = ExAllocatePool(PoolType, Source->MaximumLength);
-  if (Destination->Buffer == NULL)
-  {
-    return STATUS_INSUFFICIENT_RESOURCES;
-  }
-
-  Destination->MaximumLength = Source->MaximumLength;
-  Destination->Length = Source->Length;
-  RtlCopyMemory(Destination->Buffer, Source->Buffer, Source->MaximumLength);
-
-  return STATUS_SUCCESS;
-}
-
-
 BOOLEAN
 PciCreateDeviceIDString(PUNICODE_STRING DeviceID,
                         PPCI_DEVICE Device)
@@ -256,7 +199,7 @@ PciCreateDeviceIDString(PUNICODE_STRING DeviceID,
            Device->PciConfig.u.type0.SubVendorID,
            Device->PciConfig.RevisionID);
 
-  if (!PciCreateUnicodeString(DeviceID, Buffer, PagedPool))
+  if (!RtlCreateUnicodeString(DeviceID, Buffer))
   {
     return FALSE;
   }
@@ -295,7 +238,27 @@ PciCreateInstanceIDString(PUNICODE_STRING InstanceID,
 
   return TRUE;
 #endif
-  return PciCreateUnicodeString(InstanceID, L"0000", PagedPool);
+  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);
+
+  // XBOX HACK
+  if (!wcscmp(L"PCI\\VEN_10DE&DEV_01C2&SUBSYS_00000000&REV_D4", Buffer))
+  {
+     //DPRINT("xbox ohci controler found at bus 0x%lX, dev num %d, func num %d\n", Device->BusNumber, Device->SlotNumber.u.bits.DeviceNumber, Device->SlotNumber.u.bits.FunctionNumber);
+        if (Device->SlotNumber.u.bits.DeviceNumber == 2)
+       return RtlCreateUnicodeString(InstanceID, L"0000");
+        else
+       return RtlCreateUnicodeString(InstanceID, L"0001");
+  }
+  else
+       return RtlCreateUnicodeString(InstanceID, L"");
 }