-/* $Id: fdo.c,v 1.7 2004/03/14 17:10:43 navaraf Exp $
+/* $Id: fdo.c,v 1.8 2004/06/09 14:22:53 ekohl Exp $
*
* PROJECT: ReactOS PCI bus driver
* FILE: fdo.c
return STATUS_INSUFFICIENT_RESOURCES;
}
- RtlZeroMemory (Device,
- sizeof(PCI_DEVICE));
+ RtlZeroMemory(Device,
+ sizeof(PCI_DEVICE));
- Device->BusNumber = BusNumber;
+ Device->BusNumber = BusNumber;
- RtlCopyMemory (&Device->SlotNumber,
- &SlotNumber,
- sizeof(PCI_SLOT_NUMBER));
+ RtlCopyMemory(&Device->SlotNumber,
+ &SlotNumber,
+ sizeof(PCI_SLOT_NUMBER));
- RtlCopyMemory (&Device->PciConfig,
- &PciConfig,
- sizeof(PCI_COMMON_CONFIG));
+ RtlCopyMemory(&Device->PciConfig,
+ &PciConfig,
+ sizeof(PCI_COMMON_CONFIG));
ExInterlockedInsertTailList(
&DeviceExtension->DeviceListHead,
NTSTATUS Status;
BOOLEAN ErrorOccurred;
NTSTATUS ErrorStatus;
- WCHAR Buffer[MAX_PATH];
ULONG Size;
ULONG i;
&Device->SlotNumber,
sizeof(PCI_SLOT_NUMBER));
- /* FIXME: Get device properties (Hardware IDs, etc.) */
-
- 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);
-
- if (!PciCreateUnicodeString(
- &PdoDeviceExtension->DeviceID,
- Buffer,
- PagedPool)) {
+ /* Add Device ID string */
+ if (!PciCreateDeviceIDString(&PdoDeviceExtension->DeviceID,
+ Device))
+ {
+ ErrorStatus = STATUS_INSUFFICIENT_RESOURCES;
ErrorOccurred = TRUE;
break;
}
DPRINT("DeviceID: %S\n", PdoDeviceExtension->DeviceID.Buffer);
+
+ /* Add Instance ID string */
+ if (!PciCreateInstanceIDString(&PdoDeviceExtension->InstanceID,
+ Device))
+ {
+ ErrorStatus = STATUS_INSUFFICIENT_RESOURCES;
+ ErrorOccurred = TRUE;
+ break;
+ }
+
+ /* Add Hardware IDs string */
+ if (!PciCreateHardwareIDsString(&PdoDeviceExtension->HardwareIDs,
+ Device))
+ {
+ ErrorStatus = STATUS_INSUFFICIENT_RESOURCES;
+ ErrorOccurred = TRUE;
+ break;
+ }
+
+ /* Add Compatible IDs string */
+ if (!PciCreateCompatibleIDsString(&PdoDeviceExtension->CompatibleIDs,
+ Device))
+ {
+ ErrorStatus = STATUS_INSUFFICIENT_RESOURCES;
+ ErrorOccurred = TRUE;
+ break;
+ }
}
if (!Device->RemovePending) {
-/* $Id: pci.c,v 1.6 2004/02/10 16:22:55 navaraf Exp $
+/* $Id: pci.c,v 1.7 2004/06/09 14:22:53 ekohl Exp $
*
* PROJECT: ReactOS PCI Bus driver
* FILE: pci.c
BOOLEAN
PciCreateUnicodeString(
- PUNICODE_STRING Destination,
+ PUNICODE_STRING Destination,
PWSTR Source,
POOL_TYPE PoolType)
{
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)
+{
+ 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);
+
+ if (!PciCreateUnicodeString(DeviceID, Buffer, PagedPool))
+ {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+BOOLEAN
+PciCreateInstanceIDString(PUNICODE_STRING DeviceID,
+ PPCI_DEVICE Device)
+{
+ /* FIXME */
+
+#if 0
+ swprintf(Buffer,
+ L"%02lx&%04lx",
+ Device->BusNumber,
+ Device->SlotNumber.SlotNumber.u.AsULONG);
+#endif
+
+ return PciCreateUnicodeString(DeviceID, L"0000", PagedPool);
+}
+
+
+BOOLEAN
+PciCreateHardwareIDsString(PUNICODE_STRING HardwareIDs,
+ PPCI_DEVICE Device)
+{
+ WCHAR Buffer[256];
+ ULONG Length;
+ 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++;
+
+ Buffer[Index] = UNICODE_NULL;
+
+ Length = (Index + 1) * sizeof(WCHAR);
+ HardwareIDs->Buffer = ExAllocatePool(PagedPool, Length);
+ if (Buffer == NULL)
+ {
+ return FALSE;
+ }
+
+ HardwareIDs->Length = Length - sizeof(WCHAR);
+ HardwareIDs->MaximumLength = Length;
+ RtlCopyMemory(HardwareIDs->Buffer, Buffer, Length);
+
+ return TRUE;
+}
+
+
+BOOLEAN
+PciCreateCompatibleIDsString(PUNICODE_STRING HardwareIDs,
+ PPCI_DEVICE Device)
+{
+ WCHAR Buffer[256];
+ ULONG Length;
+ ULONG Index;
+
+ Index = 0;
+ Index += swprintf(&Buffer[Index],
+ L"PCI\\VEN_%04X&DEV_%04X&REV_%02X&CC_%02X%02X",
+ Device->PciConfig.VendorID,
+ Device->PciConfig.DeviceID,
+ Device->PciConfig.RevisionID,
+ Device->PciConfig.BaseClass,
+ Device->PciConfig.SubClass);
+ 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++;
+
+ 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;
+
+ Length = (Index + 1) * sizeof(WCHAR);
+ HardwareIDs->Buffer = ExAllocatePool(PagedPool, Length);
+ if (Buffer == NULL)
+ {
+ return FALSE;
+ }
+
+ HardwareIDs->Length = Length - sizeof(WCHAR);
+ HardwareIDs->MaximumLength = Length;
+ RtlCopyMemory(HardwareIDs->Buffer, Buffer, Length);
+
+ return TRUE;
+}
+
/* EOF */
-/* $Id: pdo.c,v 1.4 2004/03/14 17:10:43 navaraf Exp $
+/* $Id: pdo.c,v 1.5 2004/06/09 14:22:53 ekohl Exp $
*
* PROJECT: ReactOS PCI bus driver
* FILE: pdo.c
switch (IrpSp->Parameters.QueryId.IdType) {
case BusQueryDeviceID:
- Status = PciCreateUnicodeString(
+ Status = PciDuplicateUnicodeString(
&String,
- DeviceExtension->DeviceID.Buffer,
+ &DeviceExtension->DeviceID,
PagedPool);
DPRINT("DeviceID: %S\n", String.Buffer);
break;
case BusQueryHardwareIDs:
+ Status = PciDuplicateUnicodeString(
+ &String,
+ &DeviceExtension->HardwareIDs,
+ PagedPool);
+
+ Irp->IoStatus.Information = (ULONG_PTR)String.Buffer;
+ break;
+
case BusQueryCompatibleIDs:
- Status = STATUS_NOT_IMPLEMENTED;
+ Status = PciDuplicateUnicodeString(
+ &String,
+ &DeviceExtension->CompatibleIDs,
+ PagedPool);
+
+ Irp->IoStatus.Information = (ULONG_PTR)String.Buffer;
break;
case BusQueryInstanceID:
- Status = PciCreateUnicodeString(
+ Status = PciDuplicateUnicodeString(
&String,
- L"0000",
+ &DeviceExtension->InstanceID,
PagedPool);
DPRINT("InstanceID: %S\n", String.Buffer);