mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 09:25:10 +00:00
Build Hardware IDs and Compatible IDs for PCI devices.
svn path=/trunk/; revision=9646
This commit is contained in:
parent
869566fc97
commit
25e4bf3404
4 changed files with 284 additions and 35 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $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
|
* PROJECT: ReactOS PCI bus driver
|
||||||
* FILE: fdo.c
|
* FILE: fdo.c
|
||||||
|
@ -128,16 +128,16 @@ FdoEnumerateDevices(
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
RtlZeroMemory (Device,
|
RtlZeroMemory(Device,
|
||||||
sizeof(PCI_DEVICE));
|
sizeof(PCI_DEVICE));
|
||||||
|
|
||||||
Device->BusNumber = BusNumber;
|
Device->BusNumber = BusNumber;
|
||||||
|
|
||||||
RtlCopyMemory (&Device->SlotNumber,
|
RtlCopyMemory(&Device->SlotNumber,
|
||||||
&SlotNumber,
|
&SlotNumber,
|
||||||
sizeof(PCI_SLOT_NUMBER));
|
sizeof(PCI_SLOT_NUMBER));
|
||||||
|
|
||||||
RtlCopyMemory (&Device->PciConfig,
|
RtlCopyMemory(&Device->PciConfig,
|
||||||
&PciConfig,
|
&PciConfig,
|
||||||
sizeof(PCI_COMMON_CONFIG));
|
sizeof(PCI_COMMON_CONFIG));
|
||||||
|
|
||||||
|
@ -175,7 +175,6 @@ FdoQueryBusRelations(
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
BOOLEAN ErrorOccurred;
|
BOOLEAN ErrorOccurred;
|
||||||
NTSTATUS ErrorStatus;
|
NTSTATUS ErrorStatus;
|
||||||
WCHAR Buffer[MAX_PATH];
|
|
||||||
ULONG Size;
|
ULONG Size;
|
||||||
ULONG i;
|
ULONG i;
|
||||||
|
|
||||||
|
@ -254,26 +253,43 @@ FdoQueryBusRelations(
|
||||||
&Device->SlotNumber,
|
&Device->SlotNumber,
|
||||||
sizeof(PCI_SLOT_NUMBER));
|
sizeof(PCI_SLOT_NUMBER));
|
||||||
|
|
||||||
/* FIXME: Get device properties (Hardware IDs, etc.) */
|
/* Add Device ID string */
|
||||||
|
if (!PciCreateDeviceIDString(&PdoDeviceExtension->DeviceID,
|
||||||
swprintf(
|
Device))
|
||||||
Buffer,
|
{
|
||||||
L"PCI\\VEN_%04X&DEV_%04X&SUBSYS_%08X&REV_%02X",
|
ErrorStatus = STATUS_INSUFFICIENT_RESOURCES;
|
||||||
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)) {
|
|
||||||
ErrorOccurred = TRUE;
|
ErrorOccurred = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT("DeviceID: %S\n", PdoDeviceExtension->DeviceID.Buffer);
|
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) {
|
if (!Device->RemovePending) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $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
|
* PROJECT: ReactOS PCI Bus driver
|
||||||
* FILE: pci.c
|
* FILE: pci.c
|
||||||
|
@ -215,4 +215,198 @@ PciCreateUnicodeString(
|
||||||
return TRUE;
|
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 */
|
/* EOF */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: pci.h,v 1.6 2004/03/14 17:10:43 navaraf Exp $ */
|
/* $Id: pci.h,v 1.7 2004/06/09 14:22:53 ekohl Exp $ */
|
||||||
|
|
||||||
#ifndef __PCI_H
|
#ifndef __PCI_H
|
||||||
#define __PCI_H
|
#define __PCI_H
|
||||||
|
@ -112,6 +112,32 @@ PciCreateUnicodeString(
|
||||||
PWSTR Source,
|
PWSTR Source,
|
||||||
POOL_TYPE PoolType);
|
POOL_TYPE PoolType);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
PciDuplicateUnicodeString(
|
||||||
|
PUNICODE_STRING Destination,
|
||||||
|
PUNICODE_STRING Source,
|
||||||
|
POOL_TYPE PoolType);
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
PciCreateDeviceIDString(
|
||||||
|
PUNICODE_STRING DeviceID,
|
||||||
|
PPCI_DEVICE Device);
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
PciCreateInstanceIDString(
|
||||||
|
PUNICODE_STRING InstanceID,
|
||||||
|
PPCI_DEVICE Device);
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
PciCreateHardwareIDsString(
|
||||||
|
PUNICODE_STRING HardwareIDs,
|
||||||
|
PPCI_DEVICE Device);
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
PciCreateCompatibleIDsString(
|
||||||
|
PUNICODE_STRING HardwareIDs,
|
||||||
|
PPCI_DEVICE Device);
|
||||||
|
|
||||||
/* pdo.c */
|
/* pdo.c */
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $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
|
* PROJECT: ReactOS PCI bus driver
|
||||||
* FILE: pdo.c
|
* FILE: pdo.c
|
||||||
|
@ -42,9 +42,9 @@ PdoQueryId(
|
||||||
|
|
||||||
switch (IrpSp->Parameters.QueryId.IdType) {
|
switch (IrpSp->Parameters.QueryId.IdType) {
|
||||||
case BusQueryDeviceID:
|
case BusQueryDeviceID:
|
||||||
Status = PciCreateUnicodeString(
|
Status = PciDuplicateUnicodeString(
|
||||||
&String,
|
&String,
|
||||||
DeviceExtension->DeviceID.Buffer,
|
&DeviceExtension->DeviceID,
|
||||||
PagedPool);
|
PagedPool);
|
||||||
|
|
||||||
DPRINT("DeviceID: %S\n", String.Buffer);
|
DPRINT("DeviceID: %S\n", String.Buffer);
|
||||||
|
@ -53,14 +53,27 @@ PdoQueryId(
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BusQueryHardwareIDs:
|
case BusQueryHardwareIDs:
|
||||||
|
Status = PciDuplicateUnicodeString(
|
||||||
|
&String,
|
||||||
|
&DeviceExtension->HardwareIDs,
|
||||||
|
PagedPool);
|
||||||
|
|
||||||
|
Irp->IoStatus.Information = (ULONG_PTR)String.Buffer;
|
||||||
|
break;
|
||||||
|
|
||||||
case BusQueryCompatibleIDs:
|
case BusQueryCompatibleIDs:
|
||||||
Status = STATUS_NOT_IMPLEMENTED;
|
Status = PciDuplicateUnicodeString(
|
||||||
|
&String,
|
||||||
|
&DeviceExtension->CompatibleIDs,
|
||||||
|
PagedPool);
|
||||||
|
|
||||||
|
Irp->IoStatus.Information = (ULONG_PTR)String.Buffer;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BusQueryInstanceID:
|
case BusQueryInstanceID:
|
||||||
Status = PciCreateUnicodeString(
|
Status = PciDuplicateUnicodeString(
|
||||||
&String,
|
&String,
|
||||||
L"0000",
|
&DeviceExtension->InstanceID,
|
||||||
PagedPool);
|
PagedPool);
|
||||||
|
|
||||||
DPRINT("InstanceID: %S\n", String.Buffer);
|
DPRINT("InstanceID: %S\n", String.Buffer);
|
||||||
|
|
Loading…
Reference in a new issue