-/* $Id: pci.c,v 1.9 2004/08/20 13:33:51 ekohl Exp $
+/* $Id$
*
* PROJECT: ReactOS PCI Bus driver
* FILE: pci.c
*/
#include <ddk/ntddk.h>
+#include <ddk/ntifs.h>
+#include <stdio.h>
#include "pcidef.h"
#include "pci.h"
#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;
}
-NTSTATUS
+static NTSTATUS
STDCALL
PciPnpControl(
IN PDEVICE_OBJECT DeviceObject,
}
-NTSTATUS
+static NTSTATUS
STDCALL
PciPowerControl(
IN PDEVICE_OBJECT DeviceObject,
}
-NTSTATUS
+static NTSTATUS
STDCALL
PciAddDevice(
IN PDRIVER_OBJECT DriverObject,
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;
}
-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)
Device->PciConfig.u.type0.SubVendorID,
Device->PciConfig.RevisionID);
- if (!PciCreateUnicodeString(DeviceID, Buffer, PagedPool))
+ if (!RtlCreateUnicodeString(DeviceID, Buffer))
{
return FALSE;
}
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"");
}