mirror of
https://github.com/reactos/reactos.git
synced 2024-07-04 03:34:16 +00:00
[FORMATTING]
Fix indentation. No code changes! svn path=/trunk/; revision=61085
This commit is contained in:
parent
e5769b0d38
commit
f09cfef7f5
|
@ -69,13 +69,15 @@ FdoLocateChildDevice(
|
||||||
DPRINT("Called\n");
|
DPRINT("Called\n");
|
||||||
|
|
||||||
CurrentEntry = DeviceExtension->DeviceListHead.Flink;
|
CurrentEntry = DeviceExtension->DeviceListHead.Flink;
|
||||||
while (CurrentEntry != &DeviceExtension->DeviceListHead) {
|
while (CurrentEntry != &DeviceExtension->DeviceListHead)
|
||||||
|
{
|
||||||
CurrentDevice = CONTAINING_RECORD(CurrentEntry, PCI_DEVICE, ListEntry);
|
CurrentDevice = CONTAINING_RECORD(CurrentEntry, PCI_DEVICE, ListEntry);
|
||||||
|
|
||||||
/* If both vendor ID and device ID match, it is the same device */
|
/* If both vendor ID and device ID match, it is the same device */
|
||||||
if ((PciConfig->VendorID == CurrentDevice->PciConfig.VendorID) &&
|
if ((PciConfig->VendorID == CurrentDevice->PciConfig.VendorID) &&
|
||||||
(PciConfig->DeviceID == CurrentDevice->PciConfig.DeviceID) &&
|
(PciConfig->DeviceID == CurrentDevice->PciConfig.DeviceID) &&
|
||||||
(SlotNumber.u.AsULONG == CurrentDevice->SlotNumber.u.AsULONG)) {
|
(SlotNumber.u.AsULONG == CurrentDevice->SlotNumber.u.AsULONG))
|
||||||
|
{
|
||||||
*Device = CurrentDevice;
|
*Device = CurrentDevice;
|
||||||
DPRINT("Done\n");
|
DPRINT("Done\n");
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
|
@ -228,13 +230,14 @@ FdoQueryBusRelations(
|
||||||
|
|
||||||
DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||||
|
|
||||||
if (Irp->IoStatus.Information) {
|
if (Irp->IoStatus.Information)
|
||||||
|
{
|
||||||
/* FIXME: Another bus driver has already created a DEVICE_RELATIONS
|
/* FIXME: Another bus driver has already created a DEVICE_RELATIONS
|
||||||
structure so we must merge this structure with our own */
|
structure so we must merge this structure with our own */
|
||||||
}
|
}
|
||||||
|
|
||||||
Size = sizeof(DEVICE_RELATIONS) + sizeof(Relations->Objects) *
|
Size = sizeof(DEVICE_RELATIONS) +
|
||||||
(DeviceExtension->DeviceListCount - 1);
|
sizeof(Relations->Objects) * (DeviceExtension->DeviceListCount - 1);
|
||||||
Relations = (PDEVICE_RELATIONS)ExAllocatePool(PagedPool, Size);
|
Relations = (PDEVICE_RELATIONS)ExAllocatePool(PagedPool, Size);
|
||||||
if (!Relations)
|
if (!Relations)
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
@ -243,23 +246,25 @@ FdoQueryBusRelations(
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
CurrentEntry = DeviceExtension->DeviceListHead.Flink;
|
CurrentEntry = DeviceExtension->DeviceListHead.Flink;
|
||||||
while (CurrentEntry != &DeviceExtension->DeviceListHead) {
|
while (CurrentEntry != &DeviceExtension->DeviceListHead)
|
||||||
|
{
|
||||||
Device = CONTAINING_RECORD(CurrentEntry, PCI_DEVICE, ListEntry);
|
Device = CONTAINING_RECORD(CurrentEntry, PCI_DEVICE, ListEntry);
|
||||||
|
|
||||||
PdoDeviceExtension = NULL;
|
PdoDeviceExtension = NULL;
|
||||||
|
|
||||||
if (!Device->Pdo) {
|
if (!Device->Pdo)
|
||||||
|
{
|
||||||
/* Create a physical device object for the
|
/* Create a physical device object for the
|
||||||
device as it does not already have one */
|
device as it does not already have one */
|
||||||
Status = IoCreateDevice(
|
Status = IoCreateDevice(DeviceObject->DriverObject,
|
||||||
DeviceObject->DriverObject,
|
|
||||||
sizeof(PDO_DEVICE_EXTENSION),
|
sizeof(PDO_DEVICE_EXTENSION),
|
||||||
NULL,
|
NULL,
|
||||||
FILE_DEVICE_CONTROLLER,
|
FILE_DEVICE_CONTROLLER,
|
||||||
FILE_AUTOGENERATED_DEVICE_NAME,
|
FILE_AUTOGENERATED_DEVICE_NAME,
|
||||||
FALSE,
|
FALSE,
|
||||||
&Device->Pdo);
|
&Device->Pdo);
|
||||||
if (!NT_SUCCESS(Status)) {
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
DPRINT("IoCreateDevice() failed with status 0x%X\n", Status);
|
DPRINT("IoCreateDevice() failed with status 0x%X\n", Status);
|
||||||
ErrorStatus = Status;
|
ErrorStatus = Status;
|
||||||
ErrorOccurred = TRUE;
|
ErrorOccurred = TRUE;
|
||||||
|
@ -352,10 +357,12 @@ FdoQueryBusRelations(
|
||||||
CurrentEntry = CurrentEntry->Flink;
|
CurrentEntry = CurrentEntry->Flink;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ErrorOccurred) {
|
if (ErrorOccurred)
|
||||||
|
{
|
||||||
/* FIXME: Cleanup all new PDOs created in this call. Please give me SEH!!! ;-) */
|
/* FIXME: Cleanup all new PDOs created in this call. Please give me SEH!!! ;-) */
|
||||||
/* FIXME: Should IoAttachDeviceToDeviceStack() be undone? */
|
/* FIXME: Should IoAttachDeviceToDeviceStack() be undone? */
|
||||||
if (PdoDeviceExtension) {
|
if (PdoDeviceExtension)
|
||||||
|
{
|
||||||
RtlFreeUnicodeString(&PdoDeviceExtension->DeviceID);
|
RtlFreeUnicodeString(&PdoDeviceExtension->DeviceID);
|
||||||
RtlFreeUnicodeString(&PdoDeviceExtension->InstanceID);
|
RtlFreeUnicodeString(&PdoDeviceExtension->InstanceID);
|
||||||
RtlFreeUnicodeString(&PdoDeviceExtension->HardwareIDs);
|
RtlFreeUnicodeString(&PdoDeviceExtension->HardwareIDs);
|
||||||
|
@ -397,13 +404,15 @@ FdoStartDevice(
|
||||||
DPRINT("No allocated resources sent to driver\n");
|
DPRINT("No allocated resources sent to driver\n");
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AllocatedResources->Count < 1)
|
if (AllocatedResources->Count < 1)
|
||||||
{
|
{
|
||||||
DPRINT("Not enough allocated resources sent to driver\n");
|
DPRINT("Not enough allocated resources sent to driver\n");
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
}
|
}
|
||||||
if (AllocatedResources->List[0].PartialResourceList.Version != 1
|
|
||||||
|| AllocatedResources->List[0].PartialResourceList.Revision != 1)
|
if (AllocatedResources->List[0].PartialResourceList.Version != 1 ||
|
||||||
|
AllocatedResources->List[0].PartialResourceList.Revision != 1)
|
||||||
return STATUS_REVISION_MISMATCH;
|
return STATUS_REVISION_MISMATCH;
|
||||||
|
|
||||||
ASSERT(DeviceExtension->State == dsStopped);
|
ASSERT(DeviceExtension->State == dsStopped);
|
||||||
|
@ -417,16 +426,16 @@ FdoStartDevice(
|
||||||
switch (ResourceDescriptor->Type)
|
switch (ResourceDescriptor->Type)
|
||||||
{
|
{
|
||||||
case CmResourceTypeBusNumber:
|
case CmResourceTypeBusNumber:
|
||||||
{
|
|
||||||
if (FoundBusNumber || ResourceDescriptor->u.BusNumber.Length != 1)
|
if (FoundBusNumber || ResourceDescriptor->u.BusNumber.Length != 1)
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
|
||||||
/* Use this one instead */
|
/* Use this one instead */
|
||||||
ASSERT(AllocatedResources->List[0].BusNumber == ResourceDescriptor->u.BusNumber.Start);
|
ASSERT(AllocatedResources->List[0].BusNumber == ResourceDescriptor->u.BusNumber.Start);
|
||||||
DeviceExtension->BusNumber = ResourceDescriptor->u.BusNumber.Start;
|
DeviceExtension->BusNumber = ResourceDescriptor->u.BusNumber.Start;
|
||||||
DPRINT("Found bus number resource: %lu\n", DeviceExtension->BusNumber);
|
DPRINT("Found bus number resource: %lu\n", DeviceExtension->BusNumber);
|
||||||
FoundBusNumber = TRUE;
|
FoundBusNumber = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
DPRINT("Unknown resource descriptor type 0x%x\n", ResourceDescriptor->Type);
|
DPRINT("Unknown resource descriptor type 0x%x\n", ResourceDescriptor->Type);
|
||||||
}
|
}
|
||||||
|
@ -461,10 +470,13 @@ FdoSetPower(
|
||||||
|
|
||||||
DPRINT("Called\n");
|
DPRINT("Called\n");
|
||||||
|
|
||||||
if (IrpSp->Parameters.Power.Type == DevicePowerState) {
|
if (IrpSp->Parameters.Power.Type == DevicePowerState)
|
||||||
|
{
|
||||||
/* FIXME: Set device power state for the device */
|
/* FIXME: Set device power state for the device */
|
||||||
Status = STATUS_UNSUCCESSFUL;
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
Status = STATUS_UNSUCCESSFUL;
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -496,7 +508,8 @@ FdoPnpControl(
|
||||||
DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||||
|
|
||||||
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||||
switch (IrpSp->MinorFunction) {
|
switch (IrpSp->MinorFunction)
|
||||||
|
{
|
||||||
#if 0
|
#if 0
|
||||||
case IRP_MN_CANCEL_REMOVE_DEVICE:
|
case IRP_MN_CANCEL_REMOVE_DEVICE:
|
||||||
Status = STATUS_NOT_IMPLEMENTED;
|
Status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
@ -556,8 +569,10 @@ FdoPnpControl(
|
||||||
Status = STATUS_NOT_IMPLEMENTED;
|
Status = STATUS_NOT_IMPLEMENTED;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case IRP_MN_FILTER_RESOURCE_REQUIREMENTS:
|
case IRP_MN_FILTER_RESOURCE_REQUIREMENTS:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IRP_MN_REMOVE_DEVICE:
|
case IRP_MN_REMOVE_DEVICE:
|
||||||
/* Detach the device object from the device stack */
|
/* Detach the device object from the device stack */
|
||||||
IoDetachDevice(DeviceExtension->Ldo);
|
IoDetachDevice(DeviceExtension->Ldo);
|
||||||
|
@ -568,6 +583,7 @@ FdoPnpControl(
|
||||||
/* Return success */
|
/* Return success */
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DPRINT1("Unknown IOCTL 0x%lx\n", IrpSp->MinorFunction);
|
DPRINT1("Unknown IOCTL 0x%lx\n", IrpSp->MinorFunction);
|
||||||
break;
|
break;
|
||||||
|
@ -603,7 +619,8 @@ FdoPowerControl(
|
||||||
|
|
||||||
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||||
|
|
||||||
switch (IrpSp->MinorFunction) {
|
switch (IrpSp->MinorFunction)
|
||||||
|
{
|
||||||
case IRP_MN_SET_POWER:
|
case IRP_MN_SET_POWER:
|
||||||
Status = FdoSetPower(DeviceObject, Irp, IrpSp);
|
Status = FdoSetPower(DeviceObject, Irp, IrpSp);
|
||||||
break;
|
break;
|
||||||
|
@ -614,7 +631,8 @@ FdoPowerControl(
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Status != STATUS_PENDING) {
|
if (Status != STATUS_PENDING)
|
||||||
|
{
|
||||||
Irp->IoStatus.Status = Status;
|
Irp->IoStatus.Status = Status;
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,14 +58,16 @@ PciDispatchDeviceControl(
|
||||||
Irp->IoStatus.Information = 0;
|
Irp->IoStatus.Information = 0;
|
||||||
|
|
||||||
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||||
switch (IrpSp->Parameters.DeviceIoControl.IoControlCode) {
|
switch (IrpSp->Parameters.DeviceIoControl.IoControlCode)
|
||||||
|
{
|
||||||
default:
|
default:
|
||||||
DPRINT("Unknown IOCTL 0x%X\n", IrpSp->Parameters.DeviceIoControl.IoControlCode);
|
DPRINT("Unknown IOCTL 0x%X\n", IrpSp->Parameters.DeviceIoControl.IoControlCode);
|
||||||
Status = STATUS_NOT_IMPLEMENTED;
|
Status = STATUS_NOT_IMPLEMENTED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Status != STATUS_PENDING) {
|
if (Status != STATUS_PENDING)
|
||||||
|
{
|
||||||
Irp->IoStatus.Status = Status;
|
Irp->IoStatus.Status = Status;
|
||||||
|
|
||||||
DPRINT("Completing IRP at 0x%p\n", Irp);
|
DPRINT("Completing IRP at 0x%p\n", Irp);
|
||||||
|
@ -100,9 +102,12 @@ PciPnpControl(
|
||||||
|
|
||||||
DPRINT("IsFDO %u\n", DeviceExtension->IsFDO);
|
DPRINT("IsFDO %u\n", DeviceExtension->IsFDO);
|
||||||
|
|
||||||
if (DeviceExtension->IsFDO) {
|
if (DeviceExtension->IsFDO)
|
||||||
|
{
|
||||||
Status = FdoPnpControl(DeviceObject, Irp);
|
Status = FdoPnpControl(DeviceObject, Irp);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
Status = PdoPnpControl(DeviceObject, Irp);
|
Status = PdoPnpControl(DeviceObject, Irp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,9 +134,12 @@ PciPowerControl(
|
||||||
|
|
||||||
DeviceExtension = (PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
DeviceExtension = (PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||||
|
|
||||||
if (DeviceExtension->IsFDO) {
|
if (DeviceExtension->IsFDO)
|
||||||
|
{
|
||||||
Status = FdoPowerControl(DeviceObject, Irp);
|
Status = FdoPowerControl(DeviceObject, Irp);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
Status = PdoPowerControl(DeviceObject, Irp);
|
Status = PdoPowerControl(DeviceObject, Irp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,9 +161,15 @@ PciAddDevice(
|
||||||
if (PhysicalDeviceObject == NULL)
|
if (PhysicalDeviceObject == NULL)
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
|
|
||||||
Status = IoCreateDevice(DriverObject, sizeof(FDO_DEVICE_EXTENSION),
|
Status = IoCreateDevice(DriverObject,
|
||||||
NULL, FILE_DEVICE_BUS_EXTENDER, FILE_DEVICE_SECURE_OPEN, TRUE, &Fdo);
|
sizeof(FDO_DEVICE_EXTENSION),
|
||||||
if (!NT_SUCCESS(Status)) {
|
NULL,
|
||||||
|
FILE_DEVICE_BUS_EXTENDER,
|
||||||
|
FILE_DEVICE_SECURE_OPEN,
|
||||||
|
TRUE,
|
||||||
|
&Fdo);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
DPRINT("IoCreateDevice() failed with status 0x%X\n", Status);
|
DPRINT("IoCreateDevice() failed with status 0x%X\n", Status);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
@ -166,8 +180,8 @@ PciAddDevice(
|
||||||
|
|
||||||
DeviceExtension->Common.IsFDO = TRUE;
|
DeviceExtension->Common.IsFDO = TRUE;
|
||||||
|
|
||||||
DeviceExtension->Ldo =
|
DeviceExtension->Ldo = IoAttachDeviceToDeviceStack(Fdo,
|
||||||
IoAttachDeviceToDeviceStack(Fdo, PhysicalDeviceObject);
|
PhysicalDeviceObject);
|
||||||
|
|
||||||
DeviceExtension->State = dsStopped;
|
DeviceExtension->State = dsStopped;
|
||||||
|
|
||||||
|
@ -208,13 +222,13 @@ DriverEntry(
|
||||||
DriverObject->DriverExtension->AddDevice = PciAddDevice;
|
DriverObject->DriverExtension->AddDevice = PciAddDevice;
|
||||||
DriverObject->DriverUnload = PciUnload;
|
DriverObject->DriverUnload = PciUnload;
|
||||||
|
|
||||||
Status = IoAllocateDriverObjectExtension(
|
Status = IoAllocateDriverObjectExtension(DriverObject,
|
||||||
DriverObject,
|
|
||||||
DriverObject,
|
DriverObject,
|
||||||
sizeof(PCI_DRIVER_EXTENSION),
|
sizeof(PCI_DRIVER_EXTENSION),
|
||||||
(PVOID*)&DriverExtension);
|
(PVOID*)&DriverExtension);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
return Status;
|
return Status;
|
||||||
|
|
||||||
RtlZeroMemory(DriverExtension, sizeof(PCI_DRIVER_EXTENSION));
|
RtlZeroMemory(DriverExtension, sizeof(PCI_DRIVER_EXTENSION));
|
||||||
|
|
||||||
InitializeListHead(&DriverExtension->BusListHead);
|
InitializeListHead(&DriverExtension->BusListHead);
|
||||||
|
@ -659,17 +673,18 @@ PciDuplicateUnicodeString(
|
||||||
IN PCUNICODE_STRING SourceString,
|
IN PCUNICODE_STRING SourceString,
|
||||||
OUT PUNICODE_STRING DestinationString)
|
OUT PUNICODE_STRING DestinationString)
|
||||||
{
|
{
|
||||||
if (SourceString == NULL || DestinationString == NULL
|
if (SourceString == NULL ||
|
||||||
|| SourceString->Length > SourceString->MaximumLength
|
DestinationString == NULL ||
|
||||||
|| (SourceString->Length == 0 && SourceString->MaximumLength > 0 && SourceString->Buffer == NULL)
|
SourceString->Length > SourceString->MaximumLength ||
|
||||||
|| Flags == RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING || Flags >= 4)
|
(SourceString->Length == 0 && SourceString->MaximumLength > 0 && SourceString->Buffer == NULL) ||
|
||||||
|
Flags == RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING ||
|
||||||
|
Flags >= 4)
|
||||||
{
|
{
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((SourceString->Length == 0) &&
|
||||||
if ((SourceString->Length == 0)
|
(Flags != (RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE |
|
||||||
&& (Flags != (RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE |
|
|
||||||
RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING)))
|
RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING)))
|
||||||
{
|
{
|
||||||
DestinationString->Length = 0;
|
DestinationString->Length = 0;
|
||||||
|
|
|
@ -26,7 +26,8 @@ typedef struct _PCI_DEVICE
|
||||||
} PCI_DEVICE, *PPCI_DEVICE;
|
} PCI_DEVICE, *PPCI_DEVICE;
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum
|
||||||
|
{
|
||||||
dsStopped,
|
dsStopped,
|
||||||
dsStarted,
|
dsStarted,
|
||||||
dsPaused,
|
dsPaused,
|
||||||
|
|
|
@ -80,10 +80,10 @@ PdoQueryId(
|
||||||
|
|
||||||
RtlInitUnicodeString(&String, NULL);
|
RtlInitUnicodeString(&String, NULL);
|
||||||
|
|
||||||
switch (IrpSp->Parameters.QueryId.IdType) {
|
switch (IrpSp->Parameters.QueryId.IdType)
|
||||||
|
{
|
||||||
case BusQueryDeviceID:
|
case BusQueryDeviceID:
|
||||||
Status = PciDuplicateUnicodeString(
|
Status = PciDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
|
||||||
RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
|
|
||||||
&DeviceExtension->DeviceID,
|
&DeviceExtension->DeviceID,
|
||||||
&String);
|
&String);
|
||||||
|
|
||||||
|
@ -93,8 +93,7 @@ PdoQueryId(
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BusQueryHardwareIDs:
|
case BusQueryHardwareIDs:
|
||||||
Status = PciDuplicateUnicodeString(
|
Status = PciDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
|
||||||
RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
|
|
||||||
&DeviceExtension->HardwareIDs,
|
&DeviceExtension->HardwareIDs,
|
||||||
&String);
|
&String);
|
||||||
|
|
||||||
|
@ -102,8 +101,7 @@ PdoQueryId(
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BusQueryCompatibleIDs:
|
case BusQueryCompatibleIDs:
|
||||||
Status = PciDuplicateUnicodeString(
|
Status = PciDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
|
||||||
RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
|
|
||||||
&DeviceExtension->CompatibleIDs,
|
&DeviceExtension->CompatibleIDs,
|
||||||
&String);
|
&String);
|
||||||
|
|
||||||
|
@ -111,8 +109,7 @@ PdoQueryId(
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BusQueryInstanceID:
|
case BusQueryInstanceID:
|
||||||
Status = PciDuplicateUnicodeString(
|
Status = PciDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
|
||||||
RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
|
|
||||||
&DeviceExtension->InstanceID,
|
&DeviceExtension->InstanceID,
|
||||||
&String);
|
&String);
|
||||||
|
|
||||||
|
@ -389,6 +386,7 @@ PdoQueryResourceRequirements(
|
||||||
if (Length != 0)
|
if (Length != 0)
|
||||||
ResCount += 2;
|
ResCount += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DeviceExtension->PciDevice->PciConfig.BaseClass == PCI_CLASS_BRIDGE_DEV)
|
if (DeviceExtension->PciDevice->PciConfig.BaseClass == PCI_CLASS_BRIDGE_DEV)
|
||||||
ResCount++;
|
ResCount++;
|
||||||
}
|
}
|
||||||
|
@ -408,14 +406,15 @@ PdoQueryResourceRequirements(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Calculate the resource list size */
|
/* Calculate the resource list size */
|
||||||
ListSize = FIELD_OFFSET(IO_RESOURCE_REQUIREMENTS_LIST, List[0].Descriptors)
|
ListSize = FIELD_OFFSET(IO_RESOURCE_REQUIREMENTS_LIST, List[0].Descriptors) +
|
||||||
+ ResCount * sizeof(IO_RESOURCE_DESCRIPTOR);
|
ResCount * sizeof(IO_RESOURCE_DESCRIPTOR);
|
||||||
|
|
||||||
DPRINT("ListSize %lu (0x%lx)\n", ListSize, ListSize);
|
DPRINT("ListSize %lu (0x%lx)\n", ListSize, ListSize);
|
||||||
|
|
||||||
/* Allocate the resource requirements list */
|
/* Allocate the resource requirements list */
|
||||||
ResourceList = ExAllocatePoolWithTag(PagedPool,
|
ResourceList = ExAllocatePoolWithTag(PagedPool,
|
||||||
ListSize, TAG_PCI);
|
ListSize,
|
||||||
|
TAG_PCI);
|
||||||
if (ResourceList == NULL)
|
if (ResourceList == NULL)
|
||||||
{
|
{
|
||||||
Irp->IoStatus.Information = 0;
|
Irp->IoStatus.Information = 0;
|
||||||
|
@ -600,6 +599,7 @@ PdoQueryResourceRequirements(
|
||||||
}
|
}
|
||||||
Descriptor++;
|
Descriptor++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DeviceExtension->PciDevice->PciConfig.BaseClass == PCI_CLASS_BRIDGE_DEV)
|
if (DeviceExtension->PciDevice->PciConfig.BaseClass == PCI_CLASS_BRIDGE_DEV)
|
||||||
{
|
{
|
||||||
Descriptor->Option = 0; /* Required */
|
Descriptor->Option = 0; /* Required */
|
||||||
|
@ -699,6 +699,7 @@ PdoQueryResources(
|
||||||
if (Length != 0)
|
if (Length != 0)
|
||||||
ResCount++;
|
ResCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DeviceExtension->PciDevice->PciConfig.BaseClass == PCI_CLASS_BRIDGE_DEV)
|
if (DeviceExtension->PciDevice->PciConfig.BaseClass == PCI_CLASS_BRIDGE_DEV)
|
||||||
ResCount++;
|
ResCount++;
|
||||||
}
|
}
|
||||||
|
@ -718,12 +719,13 @@ PdoQueryResources(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Calculate the resource list size */
|
/* Calculate the resource list size */
|
||||||
ListSize = FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.PartialDescriptors)
|
ListSize = FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.PartialDescriptors) +
|
||||||
+ ResCount * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
|
ResCount * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
|
||||||
|
|
||||||
/* Allocate the resource list */
|
/* Allocate the resource list */
|
||||||
ResourceList = ExAllocatePoolWithTag(PagedPool,
|
ResourceList = ExAllocatePoolWithTag(PagedPool,
|
||||||
ListSize, TAG_PCI);
|
ListSize,
|
||||||
|
TAG_PCI);
|
||||||
if (ResourceList == NULL)
|
if (ResourceList == NULL)
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
|
||||||
|
@ -763,8 +765,7 @@ PdoQueryResources(
|
||||||
Descriptor->Type = CmResourceTypePort;
|
Descriptor->Type = CmResourceTypePort;
|
||||||
Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
|
Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
|
||||||
Descriptor->Flags = CM_RESOURCE_PORT_IO;
|
Descriptor->Flags = CM_RESOURCE_PORT_IO;
|
||||||
Descriptor->u.Port.Start.QuadPart =
|
Descriptor->u.Port.Start.QuadPart = (ULONGLONG)Base;
|
||||||
(ULONGLONG)Base;
|
|
||||||
Descriptor->u.Port.Length = Length;
|
Descriptor->u.Port.Length = Length;
|
||||||
|
|
||||||
/* Enable IO space access */
|
/* Enable IO space access */
|
||||||
|
@ -775,8 +776,7 @@ PdoQueryResources(
|
||||||
Descriptor->Type = CmResourceTypeMemory;
|
Descriptor->Type = CmResourceTypeMemory;
|
||||||
Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
|
Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
|
||||||
Descriptor->Flags = CM_RESOURCE_MEMORY_READ_WRITE;
|
Descriptor->Flags = CM_RESOURCE_MEMORY_READ_WRITE;
|
||||||
Descriptor->u.Memory.Start.QuadPart =
|
Descriptor->u.Memory.Start.QuadPart = (ULONGLONG)Base;
|
||||||
(ULONGLONG)Base;
|
|
||||||
Descriptor->u.Memory.Length = Length;
|
Descriptor->u.Memory.Length = Length;
|
||||||
|
|
||||||
/* Enable memory space access */
|
/* Enable memory space access */
|
||||||
|
@ -827,8 +827,7 @@ PdoQueryResources(
|
||||||
Descriptor->Type = CmResourceTypePort;
|
Descriptor->Type = CmResourceTypePort;
|
||||||
Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
|
Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
|
||||||
Descriptor->Flags = CM_RESOURCE_PORT_IO;
|
Descriptor->Flags = CM_RESOURCE_PORT_IO;
|
||||||
Descriptor->u.Port.Start.QuadPart =
|
Descriptor->u.Port.Start.QuadPart = (ULONGLONG)Base;
|
||||||
(ULONGLONG)Base;
|
|
||||||
Descriptor->u.Port.Length = Length;
|
Descriptor->u.Port.Length = Length;
|
||||||
|
|
||||||
/* Enable IO space access */
|
/* Enable IO space access */
|
||||||
|
@ -839,8 +838,7 @@ PdoQueryResources(
|
||||||
Descriptor->Type = CmResourceTypeMemory;
|
Descriptor->Type = CmResourceTypeMemory;
|
||||||
Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
|
Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
|
||||||
Descriptor->Flags = CM_RESOURCE_MEMORY_READ_WRITE;
|
Descriptor->Flags = CM_RESOURCE_MEMORY_READ_WRITE;
|
||||||
Descriptor->u.Memory.Start.QuadPart =
|
Descriptor->u.Memory.Start.QuadPart = (ULONGLONG)Base;
|
||||||
(ULONGLONG)Base;
|
|
||||||
Descriptor->u.Memory.Length = Length;
|
Descriptor->u.Memory.Length = Length;
|
||||||
|
|
||||||
/* Enable memory space access */
|
/* Enable memory space access */
|
||||||
|
@ -849,6 +847,7 @@ PdoQueryResources(
|
||||||
|
|
||||||
Descriptor++;
|
Descriptor++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DeviceExtension->PciDevice->PciConfig.BaseClass == PCI_CLASS_BRIDGE_DEV)
|
if (DeviceExtension->PciDevice->PciConfig.BaseClass == PCI_CLASS_BRIDGE_DEV)
|
||||||
{
|
{
|
||||||
Descriptor->Type = CmResourceTypeBusNumber;
|
Descriptor->Type = CmResourceTypeBusNumber;
|
||||||
|
@ -915,9 +914,11 @@ InterfaceBusTranslateBusAddress(
|
||||||
|
|
||||||
DeviceExtension = (PPDO_DEVICE_EXTENSION)((PDEVICE_OBJECT)Context)->DeviceExtension;
|
DeviceExtension = (PPDO_DEVICE_EXTENSION)((PDEVICE_OBJECT)Context)->DeviceExtension;
|
||||||
|
|
||||||
return HalTranslateBusAddress(
|
return HalTranslateBusAddress(PCIBus,
|
||||||
PCIBus, DeviceExtension->PciDevice->BusNumber,
|
DeviceExtension->PciDevice->BusNumber,
|
||||||
BusAddress, AddressSpace, TranslatedAddress);
|
BusAddress,
|
||||||
|
AddressSpace,
|
||||||
|
TranslatedAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GET_DMA_ADAPTER InterfaceBusGetDmaAdapter;
|
static GET_DMA_ADAPTER InterfaceBusGetDmaAdapter;
|
||||||
|
@ -1037,8 +1038,8 @@ InterfacePciDevicePresent(
|
||||||
if (PciDevice->PciConfig.VendorID == VendorID &&
|
if (PciDevice->PciConfig.VendorID == VendorID &&
|
||||||
PciDevice->PciConfig.DeviceID == DeviceID)
|
PciDevice->PciConfig.DeviceID == DeviceID)
|
||||||
{
|
{
|
||||||
if (!(Flags & PCI_USE_SUBSYSTEM_IDS) || (
|
if (!(Flags & PCI_USE_SUBSYSTEM_IDS) ||
|
||||||
PciDevice->PciConfig.u.type0.SubVendorID == SubVendorID &&
|
(PciDevice->PciConfig.u.type0.SubVendorID == SubVendorID &&
|
||||||
PciDevice->PciConfig.u.type0.SubSystemID == SubSystemID))
|
PciDevice->PciConfig.u.type0.SubSystemID == SubSystemID))
|
||||||
{
|
{
|
||||||
if (!(Flags & PCI_USE_REVISION) ||
|
if (!(Flags & PCI_USE_REVISION) ||
|
||||||
|
@ -1067,34 +1068,39 @@ CheckPciDevice(
|
||||||
IN PPCI_COMMON_CONFIG PciConfig,
|
IN PPCI_COMMON_CONFIG PciConfig,
|
||||||
IN PPCI_DEVICE_PRESENCE_PARAMETERS Parameters)
|
IN PPCI_DEVICE_PRESENCE_PARAMETERS Parameters)
|
||||||
{
|
{
|
||||||
if ((Parameters->Flags & PCI_USE_VENDEV_IDS) && (
|
if ((Parameters->Flags & PCI_USE_VENDEV_IDS) &&
|
||||||
PciConfig->VendorID != Parameters->VendorID ||
|
(PciConfig->VendorID != Parameters->VendorID ||
|
||||||
PciConfig->DeviceID != Parameters->DeviceID))
|
PciConfig->DeviceID != Parameters->DeviceID))
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if ((Parameters->Flags & PCI_USE_CLASS_SUBCLASS) && (
|
|
||||||
PciConfig->BaseClass != Parameters->BaseClass ||
|
if ((Parameters->Flags & PCI_USE_CLASS_SUBCLASS) &&
|
||||||
|
(PciConfig->BaseClass != Parameters->BaseClass ||
|
||||||
PciConfig->SubClass != Parameters->SubClass))
|
PciConfig->SubClass != Parameters->SubClass))
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((Parameters->Flags & PCI_USE_PROGIF) &&
|
if ((Parameters->Flags & PCI_USE_PROGIF) &&
|
||||||
PciConfig->ProgIf != Parameters->ProgIf)
|
PciConfig->ProgIf != Parameters->ProgIf)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if ((Parameters->Flags & PCI_USE_SUBSYSTEM_IDS) && (
|
|
||||||
PciConfig->u.type0.SubVendorID != Parameters->SubVendorID ||
|
if ((Parameters->Flags & PCI_USE_SUBSYSTEM_IDS) &&
|
||||||
|
(PciConfig->u.type0.SubVendorID != Parameters->SubVendorID ||
|
||||||
PciConfig->u.type0.SubSystemID != Parameters->SubSystemID))
|
PciConfig->u.type0.SubSystemID != Parameters->SubSystemID))
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((Parameters->Flags & PCI_USE_REVISION) &&
|
if ((Parameters->Flags & PCI_USE_REVISION) &&
|
||||||
PciConfig->RevisionID != Parameters->RevisionID)
|
PciConfig->RevisionID != Parameters->RevisionID)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1167,6 +1173,7 @@ PdoQueryInterface(
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
UNREFERENCED_PARAMETER(Irp);
|
UNREFERENCED_PARAMETER(Irp);
|
||||||
|
|
||||||
if (RtlCompareMemory(IrpSp->Parameters.QueryInterface.InterfaceType,
|
if (RtlCompareMemory(IrpSp->Parameters.QueryInterface.InterfaceType,
|
||||||
&GUID_BUS_INTERFACE_STANDARD, sizeof(GUID)) == sizeof(GUID))
|
&GUID_BUS_INTERFACE_STANDARD, sizeof(GUID)) == sizeof(GUID))
|
||||||
{
|
{
|
||||||
|
@ -1329,8 +1336,7 @@ PdoReadConfig(
|
||||||
|
|
||||||
DPRINT("PdoReadConfig() called\n");
|
DPRINT("PdoReadConfig() called\n");
|
||||||
|
|
||||||
Size = InterfaceBusGetBusData(
|
Size = InterfaceBusGetBusData(DeviceObject,
|
||||||
DeviceObject,
|
|
||||||
IrpSp->Parameters.ReadWriteConfig.WhichSpace,
|
IrpSp->Parameters.ReadWriteConfig.WhichSpace,
|
||||||
IrpSp->Parameters.ReadWriteConfig.Buffer,
|
IrpSp->Parameters.ReadWriteConfig.Buffer,
|
||||||
IrpSp->Parameters.ReadWriteConfig.Offset,
|
IrpSp->Parameters.ReadWriteConfig.Offset,
|
||||||
|
@ -1360,8 +1366,7 @@ PdoWriteConfig(
|
||||||
DPRINT1("PdoWriteConfig() called\n");
|
DPRINT1("PdoWriteConfig() called\n");
|
||||||
|
|
||||||
/* Get PCI configuration space */
|
/* Get PCI configuration space */
|
||||||
Size = InterfaceBusSetBusData(
|
Size = InterfaceBusSetBusData(DeviceObject,
|
||||||
DeviceObject,
|
|
||||||
IrpSp->Parameters.ReadWriteConfig.WhichSpace,
|
IrpSp->Parameters.ReadWriteConfig.WhichSpace,
|
||||||
IrpSp->Parameters.ReadWriteConfig.Buffer,
|
IrpSp->Parameters.ReadWriteConfig.Buffer,
|
||||||
IrpSp->Parameters.ReadWriteConfig.Offset,
|
IrpSp->Parameters.ReadWriteConfig.Offset,
|
||||||
|
@ -1419,13 +1424,18 @@ PdoSetPower(
|
||||||
UNREFERENCED_PARAMETER(Irp);
|
UNREFERENCED_PARAMETER(Irp);
|
||||||
DPRINT("Called\n");
|
DPRINT("Called\n");
|
||||||
|
|
||||||
if (IrpSp->Parameters.Power.Type == DevicePowerState) {
|
if (IrpSp->Parameters.Power.Type == DevicePowerState)
|
||||||
|
{
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
switch (IrpSp->Parameters.Power.State.SystemState) {
|
|
||||||
|
switch (IrpSp->Parameters.Power.State.SystemState)
|
||||||
|
{
|
||||||
default:
|
default:
|
||||||
Status = STATUS_UNSUCCESSFUL;
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
Status = STATUS_UNSUCCESSFUL;
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1457,8 +1467,8 @@ PdoPnpControl(
|
||||||
|
|
||||||
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||||
|
|
||||||
switch (IrpSp->MinorFunction) {
|
switch (IrpSp->MinorFunction)
|
||||||
|
{
|
||||||
case IRP_MN_DEVICE_USAGE_NOTIFICATION:
|
case IRP_MN_DEVICE_USAGE_NOTIFICATION:
|
||||||
DPRINT("Unimplemented IRP_MN_DEVICE_USAGE_NOTIFICATION received\n");
|
DPRINT("Unimplemented IRP_MN_DEVICE_USAGE_NOTIFICATION received\n");
|
||||||
break;
|
break;
|
||||||
|
@ -1570,7 +1580,8 @@ PdoPnpControl(
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Status != STATUS_PENDING) {
|
if (Status != STATUS_PENDING)
|
||||||
|
{
|
||||||
Irp->IoStatus.Status = Status;
|
Irp->IoStatus.Status = Status;
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
}
|
}
|
||||||
|
@ -1600,7 +1611,8 @@ PdoPowerControl(
|
||||||
|
|
||||||
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||||
|
|
||||||
switch (IrpSp->MinorFunction) {
|
switch (IrpSp->MinorFunction)
|
||||||
|
{
|
||||||
case IRP_MN_SET_POWER:
|
case IRP_MN_SET_POWER:
|
||||||
Status = PdoSetPower(DeviceObject, Irp, IrpSp);
|
Status = PdoSetPower(DeviceObject, Irp, IrpSp);
|
||||||
break;
|
break;
|
||||||
|
@ -1611,7 +1623,8 @@ PdoPowerControl(
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Status != STATUS_PENDING) {
|
if (Status != STATUS_PENDING)
|
||||||
|
{
|
||||||
Irp->IoStatus.Status = Status;
|
Irp->IoStatus.Status = Status;
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue