2 * PROJECT: ReactOS PCI bus driver
4 * PURPOSE: Child device object dispatch routines
5 * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
7 * 10-09-2001 CSH Created
17 /*** PRIVATE *****************************************************************/
21 IN PDEVICE_OBJECT DeviceObject
,
23 PIO_STACK_LOCATION IrpSp
)
25 PPDO_DEVICE_EXTENSION DeviceExtension
;
30 DeviceExtension
= (PPDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
32 Status
= STATUS_SUCCESS
;
34 switch (IrpSp
->Parameters
.QueryDeviceText
.DeviceTextType
)
36 case DeviceTextDescription
:
37 DPRINT("DeviceTextDescription\n");
38 Irp
->IoStatus
.Information
= (ULONG_PTR
)DeviceExtension
->DeviceDescription
.Buffer
;
41 case DeviceTextLocationInformation
:
42 DPRINT("DeviceTextLocationInformation\n");
43 Irp
->IoStatus
.Information
= (ULONG_PTR
)DeviceExtension
->DeviceLocation
.Buffer
;
47 Irp
->IoStatus
.Information
= 0;
48 Status
= STATUS_INVALID_PARAMETER
;
57 IN PDEVICE_OBJECT DeviceObject
,
59 PIO_STACK_LOCATION IrpSp
)
61 PPDO_DEVICE_EXTENSION DeviceExtension
;
62 UNICODE_STRING String
;
67 DeviceExtension
= (PPDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
69 // Irp->IoStatus.Information = 0;
71 Status
= STATUS_SUCCESS
;
73 RtlInitUnicodeString(&String
, NULL
);
75 switch (IrpSp
->Parameters
.QueryId
.IdType
) {
76 case BusQueryDeviceID
:
77 Status
= PciDuplicateUnicodeString(
78 RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
,
79 &DeviceExtension
->DeviceID
,
82 DPRINT("DeviceID: %S\n", String
.Buffer
);
84 Irp
->IoStatus
.Information
= (ULONG_PTR
)String
.Buffer
;
87 case BusQueryHardwareIDs
:
88 Status
= PciDuplicateUnicodeString(
89 RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
,
90 &DeviceExtension
->HardwareIDs
,
93 Irp
->IoStatus
.Information
= (ULONG_PTR
)String
.Buffer
;
96 case BusQueryCompatibleIDs
:
97 Status
= PciDuplicateUnicodeString(
98 RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
,
99 &DeviceExtension
->CompatibleIDs
,
102 Irp
->IoStatus
.Information
= (ULONG_PTR
)String
.Buffer
;
105 case BusQueryInstanceID
:
106 Status
= PciDuplicateUnicodeString(
107 RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
,
108 &DeviceExtension
->InstanceID
,
111 DPRINT("InstanceID: %S\n", String
.Buffer
);
113 Irp
->IoStatus
.Information
= (ULONG_PTR
)String
.Buffer
;
116 case BusQueryDeviceSerialNumber
:
118 Status
= STATUS_NOT_IMPLEMENTED
;
126 PdoQueryBusInformation(
127 IN PDEVICE_OBJECT DeviceObject
,
129 PIO_STACK_LOCATION IrpSp
)
131 PPDO_DEVICE_EXTENSION DeviceExtension
;
132 PFDO_DEVICE_EXTENSION FdoDeviceExtension
;
133 PPNP_BUS_INFORMATION BusInformation
;
135 UNREFERENCED_PARAMETER(IrpSp
);
138 DeviceExtension
= (PPDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
139 FdoDeviceExtension
= (PFDO_DEVICE_EXTENSION
)DeviceExtension
->Fdo
->DeviceExtension
;
140 BusInformation
= ExAllocatePool(PagedPool
, sizeof(PNP_BUS_INFORMATION
));
141 Irp
->IoStatus
.Information
= (ULONG_PTR
)BusInformation
;
142 if (BusInformation
!= NULL
)
144 BusInformation
->BusTypeGuid
= GUID_BUS_TYPE_PCI
;
145 BusInformation
->LegacyBusType
= PCIBus
;
146 BusInformation
->BusNumber
= DeviceExtension
->PciDevice
->BusNumber
;
148 return STATUS_SUCCESS
;
151 return STATUS_INSUFFICIENT_RESOURCES
;
156 PdoQueryCapabilities(
157 IN PDEVICE_OBJECT DeviceObject
,
159 PIO_STACK_LOCATION IrpSp
)
161 PPDO_DEVICE_EXTENSION DeviceExtension
;
162 PDEVICE_CAPABILITIES DeviceCapabilities
;
163 ULONG DeviceNumber
, FunctionNumber
;
165 UNREFERENCED_PARAMETER(Irp
);
168 DeviceExtension
= (PPDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
169 DeviceCapabilities
= IrpSp
->Parameters
.DeviceCapabilities
.Capabilities
;
171 if (DeviceCapabilities
->Version
!= 1)
172 return STATUS_UNSUCCESSFUL
;
174 DeviceNumber
= DeviceExtension
->PciDevice
->SlotNumber
.u
.bits
.DeviceNumber
;
175 FunctionNumber
= DeviceExtension
->PciDevice
->SlotNumber
.u
.bits
.FunctionNumber
;
177 DeviceCapabilities
->UniqueID
= FALSE
;
178 DeviceCapabilities
->Address
= ((DeviceNumber
<< 16) & 0xFFFF0000) + (FunctionNumber
& 0xFFFF);
179 DeviceCapabilities
->UINumber
= MAXULONG
; /* FIXME */
181 return STATUS_SUCCESS
;
186 PdoGetRangeLength(PPDO_DEVICE_EXTENSION DeviceExtension
,
198 /* Save original value */
199 Size
= HalGetBusDataByOffset(PCIConfiguration
,
200 DeviceExtension
->PciDevice
->BusNumber
,
201 DeviceExtension
->PciDevice
->SlotNumber
.u
.AsULONG
,
205 if (Size
!= sizeof(ULONG
))
207 DPRINT1("Wrong size %lu\n", Size
);
211 BaseValue
= (OrigValue
& 0x00000001) ? (OrigValue
& ~0x3) : (OrigValue
& ~0xF);
215 /* Set magic value */
217 Size
= HalSetBusDataByOffset(PCIConfiguration
,
218 DeviceExtension
->PciDevice
->BusNumber
,
219 DeviceExtension
->PciDevice
->SlotNumber
.u
.AsULONG
,
223 if (Size
!= sizeof(ULONG
))
225 DPRINT1("Wrong size %lu\n", Size
);
229 /* Get the range length */
230 Size
= HalGetBusDataByOffset(PCIConfiguration
,
231 DeviceExtension
->PciDevice
->BusNumber
,
232 DeviceExtension
->PciDevice
->SlotNumber
.u
.AsULONG
,
236 if (Size
!= sizeof(ULONG
))
238 DPRINT1("Wrong size %lu\n", Size
);
242 /* Restore original value */
243 Size
= HalSetBusDataByOffset(PCIConfiguration
,
244 DeviceExtension
->PciDevice
->BusNumber
,
245 DeviceExtension
->PciDevice
->SlotNumber
.u
.AsULONG
,
249 if (Size
!= sizeof(ULONG
))
251 DPRINT1("Wrong size %lu\n", Size
);
257 DPRINT("Unused address register\n");
264 XLength
= ~((NewValue
& 0x00000001) ? (NewValue
& ~0x3) : (NewValue
& ~0xF)) + 1;
267 DbgPrint("BaseAddress 0x%08lx Length 0x%08lx",
270 if (NewValue
& 0x00000001)
272 DbgPrint(" IO range");
276 DbgPrint(" Memory range");
277 if ((NewValue
& 0x00000006) == 0)
279 DbgPrint(" in 32-Bit address space");
281 else if ((NewValue
& 0x00000006) == 2)
283 DbgPrint(" below 1BM ");
285 else if ((NewValue
& 0x00000006) == 4)
287 DbgPrint(" in 64-Bit address space");
290 if (NewValue
& 0x00000008)
292 DbgPrint(" prefetchable");
300 *Flags
= (NewValue
& 0x00000001) ? (NewValue
& 0x3) : (NewValue
& 0xF);
307 PdoQueryResourceRequirements(
308 IN PDEVICE_OBJECT DeviceObject
,
310 PIO_STACK_LOCATION IrpSp
)
312 PPDO_DEVICE_EXTENSION DeviceExtension
;
313 PCI_COMMON_CONFIG PciConfig
;
314 PIO_RESOURCE_REQUIREMENTS_LIST ResourceList
;
315 PIO_RESOURCE_DESCRIPTOR Descriptor
;
324 UNREFERENCED_PARAMETER(IrpSp
);
325 DPRINT("PdoQueryResourceRequirements() called\n");
327 DeviceExtension
= (PPDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
329 /* Get PCI configuration space */
330 Size
= HalGetBusData(PCIConfiguration
,
331 DeviceExtension
->PciDevice
->BusNumber
,
332 DeviceExtension
->PciDevice
->SlotNumber
.u
.AsULONG
,
334 PCI_COMMON_HDR_LENGTH
);
335 DPRINT("Size %lu\n", Size
);
336 if (Size
< PCI_COMMON_HDR_LENGTH
)
338 Irp
->IoStatus
.Information
= 0;
339 return STATUS_UNSUCCESSFUL
;
342 DPRINT("Command register: 0x%04hx\n", PciConfig
.Command
);
344 /* Count required resource descriptors */
346 if (PCI_CONFIGURATION_TYPE(&PciConfig
) == PCI_DEVICE_TYPE
)
348 for (i
= 0; i
< PCI_TYPE0_ADDRESSES
; i
++)
350 if (!PdoGetRangeLength(DeviceExtension
,
361 /* FIXME: Check ROM address */
363 if (PciConfig
.u
.type0
.InterruptPin
!= 0)
366 else if (PCI_CONFIGURATION_TYPE(&PciConfig
) == PCI_BRIDGE_TYPE
)
368 for (i
= 0; i
< PCI_TYPE1_ADDRESSES
; i
++)
370 if (!PdoGetRangeLength(DeviceExtension
,
380 if (DeviceExtension
->PciDevice
->PciConfig
.BaseClass
== PCI_CLASS_BRIDGE_DEV
)
383 else if (PCI_CONFIGURATION_TYPE(&PciConfig
) == PCI_CARDBUS_BRIDGE_TYPE
)
385 /* FIXME: Count Cardbus bridge resources */
389 DPRINT1("Unsupported header type %u\n", PCI_CONFIGURATION_TYPE(&PciConfig
));
394 Irp
->IoStatus
.Information
= 0;
395 return STATUS_SUCCESS
;
398 /* Calculate the resource list size */
399 ListSize
= FIELD_OFFSET(IO_RESOURCE_REQUIREMENTS_LIST
, List
[0].Descriptors
)
400 + ResCount
* sizeof(IO_RESOURCE_DESCRIPTOR
);
402 DPRINT("ListSize %lu (0x%lx)\n", ListSize
, ListSize
);
404 /* Allocate the resource requirements list */
405 ResourceList
= ExAllocatePoolWithTag(PagedPool
,
407 if (ResourceList
== NULL
)
409 Irp
->IoStatus
.Information
= 0;
410 return STATUS_INSUFFICIENT_RESOURCES
;
413 RtlZeroMemory(ResourceList
, ListSize
);
414 ResourceList
->ListSize
= ListSize
;
415 ResourceList
->InterfaceType
= PCIBus
;
416 ResourceList
->BusNumber
= DeviceExtension
->PciDevice
->BusNumber
;
417 ResourceList
->SlotNumber
= DeviceExtension
->PciDevice
->SlotNumber
.u
.AsULONG
;
418 ResourceList
->AlternativeLists
= 1;
420 ResourceList
->List
[0].Version
= 1;
421 ResourceList
->List
[0].Revision
= 1;
422 ResourceList
->List
[0].Count
= ResCount
;
424 Descriptor
= &ResourceList
->List
[0].Descriptors
[0];
425 if (PCI_CONFIGURATION_TYPE(&PciConfig
) == PCI_DEVICE_TYPE
)
427 for (i
= 0; i
< PCI_TYPE0_ADDRESSES
; i
++)
429 if (!PdoGetRangeLength(DeviceExtension
,
435 DPRINT1("PdoGetRangeLength() failed\n");
441 DPRINT("Unused address register\n");
445 /* Set preferred descriptor */
446 Descriptor
->Option
= IO_RESOURCE_PREFERRED
;
447 if (Flags
& PCI_ADDRESS_IO_SPACE
)
449 Descriptor
->Type
= CmResourceTypePort
;
450 Descriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
451 Descriptor
->Flags
= CM_RESOURCE_PORT_IO
|
452 CM_RESOURCE_PORT_16_BIT_DECODE
|
453 CM_RESOURCE_PORT_POSITIVE_DECODE
;
455 Descriptor
->u
.Port
.Length
= Length
;
456 Descriptor
->u
.Port
.Alignment
= 1;
457 Descriptor
->u
.Port
.MinimumAddress
.QuadPart
= (ULONGLONG
)Base
;
458 Descriptor
->u
.Port
.MaximumAddress
.QuadPart
= (ULONGLONG
)(Base
+ Length
- 1);
462 Descriptor
->Type
= CmResourceTypeMemory
;
463 Descriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
464 Descriptor
->Flags
= CM_RESOURCE_MEMORY_READ_WRITE
;
466 Descriptor
->u
.Memory
.Length
= Length
;
467 Descriptor
->u
.Memory
.Alignment
= 1;
468 Descriptor
->u
.Memory
.MinimumAddress
.QuadPart
= (ULONGLONG
)Base
;
469 Descriptor
->u
.Memory
.MaximumAddress
.QuadPart
= (ULONGLONG
)(Base
+ Length
- 1);
473 /* Set alternative descriptor */
474 Descriptor
->Option
= IO_RESOURCE_ALTERNATIVE
;
475 if (Flags
& PCI_ADDRESS_IO_SPACE
)
477 Descriptor
->Type
= CmResourceTypePort
;
478 Descriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
479 Descriptor
->Flags
= CM_RESOURCE_PORT_IO
|
480 CM_RESOURCE_PORT_16_BIT_DECODE
|
481 CM_RESOURCE_PORT_POSITIVE_DECODE
;
483 Descriptor
->u
.Port
.Length
= Length
;
484 Descriptor
->u
.Port
.Alignment
= Length
;
485 Descriptor
->u
.Port
.MinimumAddress
.QuadPart
= (ULONGLONG
)0;
486 Descriptor
->u
.Port
.MaximumAddress
.QuadPart
= (ULONGLONG
)0x00000000FFFFFFFF;
490 Descriptor
->Type
= CmResourceTypeMemory
;
491 Descriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
492 Descriptor
->Flags
= CM_RESOURCE_MEMORY_READ_WRITE
;
494 Descriptor
->u
.Memory
.Length
= Length
;
495 Descriptor
->u
.Memory
.Alignment
= Length
;
496 Descriptor
->u
.Port
.MinimumAddress
.QuadPart
= (ULONGLONG
)0;
497 Descriptor
->u
.Port
.MaximumAddress
.QuadPart
= (ULONGLONG
)0x00000000FFFFFFFF;
502 /* FIXME: Check ROM address */
504 if (PciConfig
.u
.type0
.InterruptPin
!= 0)
506 Descriptor
->Option
= 0; /* Required */
507 Descriptor
->Type
= CmResourceTypeInterrupt
;
508 Descriptor
->ShareDisposition
= CmResourceShareShared
;
509 Descriptor
->Flags
= CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE
;
511 Descriptor
->u
.Interrupt
.MinimumVector
= 0;
512 Descriptor
->u
.Interrupt
.MaximumVector
= 0xFF;
515 else if (PCI_CONFIGURATION_TYPE(&PciConfig
) == PCI_BRIDGE_TYPE
)
517 for (i
= 0; i
< PCI_TYPE1_ADDRESSES
; i
++)
519 if (!PdoGetRangeLength(DeviceExtension
,
525 DPRINT1("PdoGetRangeLength() failed\n");
531 DPRINT("Unused address register\n");
535 /* Set preferred descriptor */
536 Descriptor
->Option
= IO_RESOURCE_PREFERRED
;
537 if (Flags
& PCI_ADDRESS_IO_SPACE
)
539 Descriptor
->Type
= CmResourceTypePort
;
540 Descriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
541 Descriptor
->Flags
= CM_RESOURCE_PORT_IO
|
542 CM_RESOURCE_PORT_16_BIT_DECODE
|
543 CM_RESOURCE_PORT_POSITIVE_DECODE
;
545 Descriptor
->u
.Port
.Length
= Length
;
546 Descriptor
->u
.Port
.Alignment
= 1;
547 Descriptor
->u
.Port
.MinimumAddress
.QuadPart
= (ULONGLONG
)Base
;
548 Descriptor
->u
.Port
.MaximumAddress
.QuadPart
= (ULONGLONG
)(Base
+ Length
- 1);
552 Descriptor
->Type
= CmResourceTypeMemory
;
553 Descriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
554 Descriptor
->Flags
= CM_RESOURCE_MEMORY_READ_WRITE
;
556 Descriptor
->u
.Memory
.Length
= Length
;
557 Descriptor
->u
.Memory
.Alignment
= 1;
558 Descriptor
->u
.Memory
.MinimumAddress
.QuadPart
= (ULONGLONG
)Base
;
559 Descriptor
->u
.Memory
.MaximumAddress
.QuadPart
= (ULONGLONG
)(Base
+ Length
- 1);
563 /* Set alternative descriptor */
564 Descriptor
->Option
= IO_RESOURCE_ALTERNATIVE
;
565 if (Flags
& PCI_ADDRESS_IO_SPACE
)
567 Descriptor
->Type
= CmResourceTypePort
;
568 Descriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
569 Descriptor
->Flags
= CM_RESOURCE_PORT_IO
|
570 CM_RESOURCE_PORT_16_BIT_DECODE
|
571 CM_RESOURCE_PORT_POSITIVE_DECODE
;
573 Descriptor
->u
.Port
.Length
= Length
;
574 Descriptor
->u
.Port
.Alignment
= Length
;
575 Descriptor
->u
.Port
.MinimumAddress
.QuadPart
= (ULONGLONG
)0;
576 Descriptor
->u
.Port
.MaximumAddress
.QuadPart
= (ULONGLONG
)0x00000000FFFFFFFF;
580 Descriptor
->Type
= CmResourceTypeMemory
;
581 Descriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
582 Descriptor
->Flags
= CM_RESOURCE_MEMORY_READ_WRITE
;
584 Descriptor
->u
.Memory
.Length
= Length
;
585 Descriptor
->u
.Memory
.Alignment
= Length
;
586 Descriptor
->u
.Port
.MinimumAddress
.QuadPart
= (ULONGLONG
)0;
587 Descriptor
->u
.Port
.MaximumAddress
.QuadPart
= (ULONGLONG
)0x00000000FFFFFFFF;
591 if (DeviceExtension
->PciDevice
->PciConfig
.BaseClass
== PCI_CLASS_BRIDGE_DEV
)
593 Descriptor
->Option
= 0; /* Required */
594 Descriptor
->Type
= CmResourceTypeBusNumber
;
595 Descriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
597 ResourceList
->BusNumber
=
598 Descriptor
->u
.BusNumber
.MinBusNumber
=
599 Descriptor
->u
.BusNumber
.MaxBusNumber
= DeviceExtension
->PciDevice
->PciConfig
.u
.type1
.SecondaryBus
;
600 Descriptor
->u
.BusNumber
.Length
= 1;
601 Descriptor
->u
.BusNumber
.Reserved
= 0;
604 else if (PCI_CONFIGURATION_TYPE(&PciConfig
) == PCI_CARDBUS_BRIDGE_TYPE
)
606 /* FIXME: Add Cardbus bridge resources */
609 Irp
->IoStatus
.Information
= (ULONG_PTR
)ResourceList
;
611 return STATUS_SUCCESS
;
617 IN PDEVICE_OBJECT DeviceObject
,
619 PIO_STACK_LOCATION IrpSp
)
621 PPDO_DEVICE_EXTENSION DeviceExtension
;
622 PCI_COMMON_CONFIG PciConfig
;
623 PCM_RESOURCE_LIST ResourceList
;
624 PCM_PARTIAL_RESOURCE_LIST PartialList
;
625 PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor
;
634 DPRINT("PdoQueryResources() called\n");
636 UNREFERENCED_PARAMETER(IrpSp
);
637 DeviceExtension
= (PPDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
639 /* Get PCI configuration space */
640 Size
= HalGetBusData(PCIConfiguration
,
641 DeviceExtension
->PciDevice
->BusNumber
,
642 DeviceExtension
->PciDevice
->SlotNumber
.u
.AsULONG
,
644 PCI_COMMON_HDR_LENGTH
);
645 DPRINT("Size %lu\n", Size
);
646 if (Size
< PCI_COMMON_HDR_LENGTH
)
648 Irp
->IoStatus
.Information
= 0;
649 return STATUS_UNSUCCESSFUL
;
652 DPRINT("Command register: 0x%04hx\n", PciConfig
.Command
);
654 /* Count required resource descriptors */
656 if (PCI_CONFIGURATION_TYPE(&PciConfig
) == PCI_DEVICE_TYPE
)
658 for (i
= 0; i
< PCI_TYPE0_ADDRESSES
; i
++)
660 if (!PdoGetRangeLength(DeviceExtension
,
671 if ((PciConfig
.u
.type0
.InterruptPin
!= 0) &&
672 (PciConfig
.u
.type0
.InterruptLine
!= 0xFF))
675 else if (PCI_CONFIGURATION_TYPE(&PciConfig
) == PCI_BRIDGE_TYPE
)
677 for (i
= 0; i
< PCI_TYPE1_ADDRESSES
; i
++)
679 if (!PdoGetRangeLength(DeviceExtension
,
689 if (DeviceExtension
->PciDevice
->PciConfig
.BaseClass
== PCI_CLASS_BRIDGE_DEV
)
692 else if (PCI_CONFIGURATION_TYPE(&PciConfig
) == PCI_CARDBUS_BRIDGE_TYPE
)
694 /* FIXME: Count Cardbus bridge resources */
698 DPRINT1("Unsupported header type %u\n", PCI_CONFIGURATION_TYPE(&PciConfig
));
703 Irp
->IoStatus
.Information
= 0;
704 return STATUS_SUCCESS
;
707 /* Calculate the resource list size */
708 ListSize
= FIELD_OFFSET(CM_RESOURCE_LIST
, List
[0].PartialResourceList
.PartialDescriptors
)
709 + ResCount
* sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR
);
711 /* Allocate the resource list */
712 ResourceList
= ExAllocatePoolWithTag(PagedPool
,
714 if (ResourceList
== NULL
)
715 return STATUS_INSUFFICIENT_RESOURCES
;
717 RtlZeroMemory(ResourceList
, ListSize
);
718 ResourceList
->Count
= 1;
719 ResourceList
->List
[0].InterfaceType
= PCIBus
;
720 ResourceList
->List
[0].BusNumber
= DeviceExtension
->PciDevice
->BusNumber
;
722 PartialList
= &ResourceList
->List
[0].PartialResourceList
;
723 PartialList
->Version
= 1;
724 PartialList
->Revision
= 1;
725 PartialList
->Count
= ResCount
;
727 Descriptor
= &PartialList
->PartialDescriptors
[0];
728 if (PCI_CONFIGURATION_TYPE(&PciConfig
) == PCI_DEVICE_TYPE
)
730 for (i
= 0; i
< PCI_TYPE0_ADDRESSES
; i
++)
732 if (!PdoGetRangeLength(DeviceExtension
,
738 DPRINT1("PdoGetRangeLength() failed\n");
744 DPRINT("Unused address register\n");
748 if (Flags
& PCI_ADDRESS_IO_SPACE
)
750 Descriptor
->Type
= CmResourceTypePort
;
751 Descriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
752 Descriptor
->Flags
= CM_RESOURCE_PORT_IO
;
753 Descriptor
->u
.Port
.Start
.QuadPart
=
755 Descriptor
->u
.Port
.Length
= Length
;
759 Descriptor
->Type
= CmResourceTypeMemory
;
760 Descriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
761 Descriptor
->Flags
= CM_RESOURCE_MEMORY_READ_WRITE
;
762 Descriptor
->u
.Memory
.Start
.QuadPart
=
764 Descriptor
->u
.Memory
.Length
= Length
;
770 /* Add interrupt resource */
771 if ((PciConfig
.u
.type0
.InterruptPin
!= 0) &&
772 (PciConfig
.u
.type0
.InterruptLine
!= 0xFF))
774 Descriptor
->Type
= CmResourceTypeInterrupt
;
775 Descriptor
->ShareDisposition
= CmResourceShareShared
;
776 Descriptor
->Flags
= CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE
;
777 Descriptor
->u
.Interrupt
.Level
= PciConfig
.u
.type0
.InterruptLine
;
778 Descriptor
->u
.Interrupt
.Vector
= PciConfig
.u
.type0
.InterruptLine
;
779 Descriptor
->u
.Interrupt
.Affinity
= 0xFFFFFFFF;
782 else if (PCI_CONFIGURATION_TYPE(&PciConfig
) == PCI_BRIDGE_TYPE
)
784 for (i
= 0; i
< PCI_TYPE1_ADDRESSES
; i
++)
786 if (!PdoGetRangeLength(DeviceExtension
,
792 DPRINT1("PdoGetRangeLength() failed\n");
798 DPRINT("Unused address register\n");
802 if (Flags
& PCI_ADDRESS_IO_SPACE
)
804 Descriptor
->Type
= CmResourceTypePort
;
805 Descriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
806 Descriptor
->Flags
= CM_RESOURCE_PORT_IO
;
807 Descriptor
->u
.Port
.Start
.QuadPart
=
809 Descriptor
->u
.Port
.Length
= Length
;
813 Descriptor
->Type
= CmResourceTypeMemory
;
814 Descriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
815 Descriptor
->Flags
= CM_RESOURCE_MEMORY_READ_WRITE
;
816 Descriptor
->u
.Memory
.Start
.QuadPart
=
818 Descriptor
->u
.Memory
.Length
= Length
;
823 if (DeviceExtension
->PciDevice
->PciConfig
.BaseClass
== PCI_CLASS_BRIDGE_DEV
)
825 Descriptor
->Type
= CmResourceTypeBusNumber
;
826 Descriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
828 ResourceList
->List
[0].BusNumber
=
829 Descriptor
->u
.BusNumber
.Start
= DeviceExtension
->PciDevice
->PciConfig
.u
.type1
.SecondaryBus
;
830 Descriptor
->u
.BusNumber
.Length
= 1;
831 Descriptor
->u
.BusNumber
.Reserved
= 0;
834 else if (PCI_CONFIGURATION_TYPE(&PciConfig
) == PCI_CARDBUS_BRIDGE_TYPE
)
836 /* FIXME: Add Cardbus bridge resources */
839 Irp
->IoStatus
.Information
= (ULONG_PTR
)ResourceList
;
841 return STATUS_SUCCESS
;
849 PPDO_DEVICE_EXTENSION DeviceExtension
;
851 DPRINT("InterfaceReference(%p)\n", Context
);
853 DeviceExtension
= (PPDO_DEVICE_EXTENSION
)((PDEVICE_OBJECT
)Context
)->DeviceExtension
;
854 InterlockedIncrement(&DeviceExtension
->References
);
859 InterfaceDereference(
862 PPDO_DEVICE_EXTENSION DeviceExtension
;
864 DPRINT("InterfaceDereference(%p)\n", Context
);
866 DeviceExtension
= (PPDO_DEVICE_EXTENSION
)((PDEVICE_OBJECT
)Context
)->DeviceExtension
;
867 InterlockedDecrement(&DeviceExtension
->References
);
872 InterfaceBusTranslateBusAddress(
874 IN PHYSICAL_ADDRESS BusAddress
,
876 IN OUT PULONG AddressSpace
,
877 OUT PPHYSICAL_ADDRESS TranslatedAddress
)
879 PPDO_DEVICE_EXTENSION DeviceExtension
;
881 DPRINT("InterfaceBusTranslateBusAddress(%p %p 0x%lx %p %p)\n",
882 Context
, BusAddress
, Length
, AddressSpace
, TranslatedAddress
);
884 DeviceExtension
= (PPDO_DEVICE_EXTENSION
)((PDEVICE_OBJECT
)Context
)->DeviceExtension
;
886 return HalTranslateBusAddress(
887 PCIBus
, DeviceExtension
->PciDevice
->BusNumber
,
888 BusAddress
, AddressSpace
, TranslatedAddress
);
892 static PDMA_ADAPTER NTAPI
893 InterfaceBusGetDmaAdapter(
895 IN PDEVICE_DESCRIPTION DeviceDescription
,
896 OUT PULONG NumberOfMapRegisters
)
898 DPRINT("InterfaceBusGetDmaAdapter(%p %p %p)\n",
899 Context
, DeviceDescription
, NumberOfMapRegisters
);
900 return (PDMA_ADAPTER
)HalGetAdapter(DeviceDescription
, NumberOfMapRegisters
);
905 InterfaceBusSetBusData(
912 PPDO_DEVICE_EXTENSION DeviceExtension
;
915 DPRINT("InterfaceBusSetBusData(%p 0x%lx %p 0x%lx 0x%lx)\n",
916 Context
, DataType
, Buffer
, Offset
, Length
);
918 if (DataType
!= PCI_WHICHSPACE_CONFIG
)
920 DPRINT("Unknown DataType %lu\n", DataType
);
924 DeviceExtension
= (PPDO_DEVICE_EXTENSION
)((PDEVICE_OBJECT
)Context
)->DeviceExtension
;
926 /* Get PCI configuration space */
927 Size
= HalSetBusDataByOffset(PCIConfiguration
,
928 DeviceExtension
->PciDevice
->BusNumber
,
929 DeviceExtension
->PciDevice
->SlotNumber
.u
.AsULONG
,
938 InterfaceBusGetBusData(
945 PPDO_DEVICE_EXTENSION DeviceExtension
;
948 DPRINT("InterfaceBusGetBusData(%p 0x%lx %p 0x%lx 0x%lx) called\n",
949 Context
, DataType
, Buffer
, Offset
, Length
);
951 if (DataType
!= PCI_WHICHSPACE_CONFIG
)
953 DPRINT("Unknown DataType %lu\n", DataType
);
957 DeviceExtension
= (PPDO_DEVICE_EXTENSION
)((PDEVICE_OBJECT
)Context
)->DeviceExtension
;
959 /* Get PCI configuration space */
960 Size
= HalGetBusDataByOffset(PCIConfiguration
,
961 DeviceExtension
->PciDevice
->BusNumber
,
962 DeviceExtension
->PciDevice
->SlotNumber
.u
.AsULONG
,
971 InterfacePciDevicePresent(
975 IN USHORT SubVendorID
,
976 IN USHORT SubSystemID
,
979 PFDO_DEVICE_EXTENSION FdoDeviceExtension
;
980 PPCI_DEVICE PciDevice
;
981 PLIST_ENTRY CurrentBus
, CurrentEntry
;
983 BOOLEAN Found
= FALSE
;
985 KeAcquireSpinLock(&DriverExtension
->BusListLock
, &OldIrql
);
986 CurrentBus
= DriverExtension
->BusListHead
.Flink
;
987 while (!Found
&& CurrentBus
!= &DriverExtension
->BusListHead
)
989 FdoDeviceExtension
= CONTAINING_RECORD(CurrentBus
, FDO_DEVICE_EXTENSION
, ListEntry
);
991 KeAcquireSpinLockAtDpcLevel(&FdoDeviceExtension
->DeviceListLock
);
992 CurrentEntry
= FdoDeviceExtension
->DeviceListHead
.Flink
;
993 while (!Found
&& CurrentEntry
!= &FdoDeviceExtension
->DeviceListHead
)
995 PciDevice
= CONTAINING_RECORD(CurrentEntry
, PCI_DEVICE
, ListEntry
);
996 if (PciDevice
->PciConfig
.VendorID
== VendorID
&&
997 PciDevice
->PciConfig
.DeviceID
== DeviceID
)
999 if (!(Flags
& PCI_USE_SUBSYSTEM_IDS
) || (
1000 PciDevice
->PciConfig
.u
.type0
.SubVendorID
== SubVendorID
&&
1001 PciDevice
->PciConfig
.u
.type0
.SubSystemID
== SubSystemID
))
1003 if (!(Flags
& PCI_USE_REVISION
) ||
1004 PciDevice
->PciConfig
.RevisionID
== RevisionID
)
1006 DPRINT("Found the PCI device\n");
1012 CurrentEntry
= CurrentEntry
->Flink
;
1015 KeReleaseSpinLockFromDpcLevel(&FdoDeviceExtension
->DeviceListLock
);
1016 CurrentBus
= CurrentBus
->Flink
;
1018 KeReleaseSpinLock(&DriverExtension
->BusListLock
, OldIrql
);
1026 IN PPCI_COMMON_CONFIG PciConfig
,
1027 IN PPCI_DEVICE_PRESENCE_PARAMETERS Parameters
)
1029 if ((Parameters
->Flags
& PCI_USE_VENDEV_IDS
) && (
1030 PciConfig
->VendorID
!= Parameters
->VendorID
||
1031 PciConfig
->DeviceID
!= Parameters
->DeviceID
))
1035 if ((Parameters
->Flags
& PCI_USE_CLASS_SUBCLASS
) && (
1036 PciConfig
->BaseClass
!= Parameters
->BaseClass
||
1037 PciConfig
->SubClass
!= Parameters
->SubClass
))
1041 if ((Parameters
->Flags
& PCI_USE_PROGIF
) &&
1042 PciConfig
->ProgIf
!= Parameters
->ProgIf
)
1046 if ((Parameters
->Flags
& PCI_USE_SUBSYSTEM_IDS
) && (
1047 PciConfig
->u
.type0
.SubVendorID
!= Parameters
->SubVendorID
||
1048 PciConfig
->u
.type0
.SubSystemID
!= Parameters
->SubSystemID
))
1052 if ((Parameters
->Flags
& PCI_USE_REVISION
) &&
1053 PciConfig
->RevisionID
!= Parameters
->RevisionID
)
1061 static BOOLEAN NTAPI
1062 InterfacePciDevicePresentEx(
1064 IN PPCI_DEVICE_PRESENCE_PARAMETERS Parameters
)
1066 PPDO_DEVICE_EXTENSION DeviceExtension
;
1067 PFDO_DEVICE_EXTENSION MyFdoDeviceExtension
;
1068 PFDO_DEVICE_EXTENSION FdoDeviceExtension
;
1069 PPCI_DEVICE PciDevice
;
1070 PLIST_ENTRY CurrentBus
, CurrentEntry
;
1072 BOOLEAN Found
= FALSE
;
1074 DPRINT("InterfacePciDevicePresentEx(%p %p) called\n",
1075 Context
, Parameters
);
1077 if (!Parameters
|| Parameters
->Size
!= sizeof(PCI_DEVICE_PRESENCE_PARAMETERS
))
1080 DeviceExtension
= (PPDO_DEVICE_EXTENSION
)((PDEVICE_OBJECT
)Context
)->DeviceExtension
;
1081 MyFdoDeviceExtension
= (PFDO_DEVICE_EXTENSION
)DeviceExtension
->Fdo
->DeviceExtension
;
1083 if (Parameters
->Flags
& PCI_USE_LOCAL_DEVICE
)
1085 return CheckPciDevice(&DeviceExtension
->PciDevice
->PciConfig
, Parameters
);
1088 KeAcquireSpinLock(&DriverExtension
->BusListLock
, &OldIrql
);
1089 CurrentBus
= DriverExtension
->BusListHead
.Flink
;
1090 while (!Found
&& CurrentBus
!= &DriverExtension
->BusListHead
)
1092 FdoDeviceExtension
= CONTAINING_RECORD(CurrentBus
, FDO_DEVICE_EXTENSION
, ListEntry
);
1093 if (!(Parameters
->Flags
& PCI_USE_LOCAL_BUS
) || FdoDeviceExtension
== MyFdoDeviceExtension
)
1095 KeAcquireSpinLockAtDpcLevel(&FdoDeviceExtension
->DeviceListLock
);
1096 CurrentEntry
= FdoDeviceExtension
->DeviceListHead
.Flink
;
1097 while (!Found
&& CurrentEntry
!= &FdoDeviceExtension
->DeviceListHead
)
1099 PciDevice
= CONTAINING_RECORD(CurrentEntry
, PCI_DEVICE
, ListEntry
);
1101 if (CheckPciDevice(&PciDevice
->PciConfig
, Parameters
))
1103 DPRINT("Found the PCI device\n");
1107 CurrentEntry
= CurrentEntry
->Flink
;
1110 KeReleaseSpinLockFromDpcLevel(&FdoDeviceExtension
->DeviceListLock
);
1112 CurrentBus
= CurrentBus
->Flink
;
1114 KeReleaseSpinLock(&DriverExtension
->BusListLock
, OldIrql
);
1122 IN PDEVICE_OBJECT DeviceObject
,
1124 PIO_STACK_LOCATION IrpSp
)
1128 UNREFERENCED_PARAMETER(Irp
);
1129 if (RtlCompareMemory(IrpSp
->Parameters
.QueryInterface
.InterfaceType
,
1130 &GUID_BUS_INTERFACE_STANDARD
, sizeof(GUID
)) == sizeof(GUID
))
1132 /* BUS_INTERFACE_STANDARD */
1133 if (IrpSp
->Parameters
.QueryInterface
.Version
< 1)
1134 Status
= STATUS_NOT_SUPPORTED
;
1135 else if (IrpSp
->Parameters
.QueryInterface
.Size
< sizeof(BUS_INTERFACE_STANDARD
))
1136 Status
= STATUS_BUFFER_TOO_SMALL
;
1139 PBUS_INTERFACE_STANDARD BusInterface
;
1140 BusInterface
= (PBUS_INTERFACE_STANDARD
)IrpSp
->Parameters
.QueryInterface
.Interface
;
1141 BusInterface
->Size
= sizeof(BUS_INTERFACE_STANDARD
);
1142 BusInterface
->Version
= 1;
1143 BusInterface
->TranslateBusAddress
= InterfaceBusTranslateBusAddress
;
1144 BusInterface
->GetDmaAdapter
= InterfaceBusGetDmaAdapter
;
1145 BusInterface
->SetBusData
= InterfaceBusSetBusData
;
1146 BusInterface
->GetBusData
= InterfaceBusGetBusData
;
1147 Status
= STATUS_SUCCESS
;
1150 else if (RtlCompareMemory(IrpSp
->Parameters
.QueryInterface
.InterfaceType
,
1151 &GUID_PCI_DEVICE_PRESENT_INTERFACE
, sizeof(GUID
)) == sizeof(GUID
))
1153 /* PCI_DEVICE_PRESENT_INTERFACE */
1154 if (IrpSp
->Parameters
.QueryInterface
.Version
< 1)
1155 Status
= STATUS_NOT_SUPPORTED
;
1156 else if (IrpSp
->Parameters
.QueryInterface
.Size
< sizeof(PCI_DEVICE_PRESENT_INTERFACE
))
1157 Status
= STATUS_BUFFER_TOO_SMALL
;
1160 PPCI_DEVICE_PRESENT_INTERFACE PciDevicePresentInterface
;
1161 PciDevicePresentInterface
= (PPCI_DEVICE_PRESENT_INTERFACE
)IrpSp
->Parameters
.QueryInterface
.Interface
;
1162 PciDevicePresentInterface
->Size
= sizeof(PCI_DEVICE_PRESENT_INTERFACE
);
1163 PciDevicePresentInterface
->Version
= 1;
1164 PciDevicePresentInterface
->IsDevicePresent
= InterfacePciDevicePresent
;
1165 PciDevicePresentInterface
->IsDevicePresentEx
= InterfacePciDevicePresentEx
;
1166 Status
= STATUS_SUCCESS
;
1171 /* Not a supported interface */
1172 return STATUS_NOT_SUPPORTED
;
1175 if (NT_SUCCESS(Status
))
1177 /* Add a reference for the returned interface */
1178 PINTERFACE Interface
;
1179 Interface
= (PINTERFACE
)IrpSp
->Parameters
.QueryInterface
.Interface
;
1180 Interface
->Context
= DeviceObject
;
1181 Interface
->InterfaceReference
= InterfaceReference
;
1182 Interface
->InterfaceDereference
= InterfaceDereference
;
1183 Interface
->InterfaceReference(Interface
->Context
);
1191 IN PDEVICE_OBJECT DeviceObject
,
1193 PIO_STACK_LOCATION IrpSp
)
1195 PCM_RESOURCE_LIST RawResList
= IrpSp
->Parameters
.StartDevice
.AllocatedResources
;
1196 PCM_FULL_RESOURCE_DESCRIPTOR RawFullDesc
;
1197 PCM_PARTIAL_RESOURCE_DESCRIPTOR RawPartialDesc
;
1199 PPDO_DEVICE_EXTENSION DeviceExtension
= DeviceObject
->DeviceExtension
;
1203 return STATUS_SUCCESS
;
1205 /* TODO: Assign the other resources we get to the card */
1207 for (i
= 0; i
< RawResList
->Count
; i
++)
1209 RawFullDesc
= &RawResList
->List
[i
];
1211 for (ii
= 0; ii
< RawFullDesc
->PartialResourceList
.Count
; ii
++)
1213 RawPartialDesc
= &RawFullDesc
->PartialResourceList
.PartialDescriptors
[ii
];
1215 if (RawPartialDesc
->Type
== CmResourceTypeInterrupt
)
1217 DPRINT1("Assigning IRQ %x to PCI device (%x, %x)\n",
1218 RawPartialDesc
->u
.Interrupt
.Vector
,
1219 DeviceExtension
->PciDevice
->SlotNumber
.u
.AsULONG
,
1220 DeviceExtension
->PciDevice
->BusNumber
);
1222 Irq
= (UCHAR
)RawPartialDesc
->u
.Interrupt
.Vector
;
1223 HalSetBusDataByOffset(PCIConfiguration
,
1224 DeviceExtension
->PciDevice
->BusNumber
,
1225 DeviceExtension
->PciDevice
->SlotNumber
.u
.AsULONG
,
1227 0x3c /* PCI_INTERRUPT_LINE */,
1233 return STATUS_SUCCESS
;
1238 IN PDEVICE_OBJECT DeviceObject
,
1240 PIO_STACK_LOCATION IrpSp
)
1244 DPRINT("PdoReadConfig() called\n");
1246 Size
= InterfaceBusGetBusData(
1248 IrpSp
->Parameters
.ReadWriteConfig
.WhichSpace
,
1249 IrpSp
->Parameters
.ReadWriteConfig
.Buffer
,
1250 IrpSp
->Parameters
.ReadWriteConfig
.Offset
,
1251 IrpSp
->Parameters
.ReadWriteConfig
.Length
);
1253 if (Size
!= IrpSp
->Parameters
.ReadWriteConfig
.Length
)
1255 DPRINT1("Size %lu Length %lu\n", Size
, IrpSp
->Parameters
.ReadWriteConfig
.Length
);
1256 Irp
->IoStatus
.Information
= 0;
1257 return STATUS_UNSUCCESSFUL
;
1260 Irp
->IoStatus
.Information
= Size
;
1262 return STATUS_SUCCESS
;
1268 IN PDEVICE_OBJECT DeviceObject
,
1270 PIO_STACK_LOCATION IrpSp
)
1274 DPRINT1("PdoWriteConfig() called\n");
1276 /* Get PCI configuration space */
1277 Size
= InterfaceBusSetBusData(
1279 IrpSp
->Parameters
.ReadWriteConfig
.WhichSpace
,
1280 IrpSp
->Parameters
.ReadWriteConfig
.Buffer
,
1281 IrpSp
->Parameters
.ReadWriteConfig
.Offset
,
1282 IrpSp
->Parameters
.ReadWriteConfig
.Length
);
1284 if (Size
!= IrpSp
->Parameters
.ReadWriteConfig
.Length
)
1286 DPRINT1("Size %lu Length %lu\n", Size
, IrpSp
->Parameters
.ReadWriteConfig
.Length
);
1287 Irp
->IoStatus
.Information
= 0;
1288 return STATUS_UNSUCCESSFUL
;
1291 Irp
->IoStatus
.Information
= Size
;
1293 return STATUS_SUCCESS
;
1297 PdoQueryDeviceRelations(
1298 IN PDEVICE_OBJECT DeviceObject
,
1300 PIO_STACK_LOCATION IrpSp
)
1302 PDEVICE_RELATIONS DeviceRelations
;
1304 /* We only support TargetDeviceRelation for child PDOs */
1305 if (IrpSp
->Parameters
.QueryDeviceRelations
.Type
!= TargetDeviceRelation
)
1306 return Irp
->IoStatus
.Status
;
1308 /* We can do this because we only return 1 PDO for TargetDeviceRelation */
1309 DeviceRelations
= ExAllocatePool(PagedPool
, sizeof(*DeviceRelations
));
1310 if (!DeviceRelations
)
1311 return STATUS_INSUFFICIENT_RESOURCES
;
1313 DeviceRelations
->Count
= 1;
1314 DeviceRelations
->Objects
[0] = DeviceObject
;
1316 /* The PnP manager will remove this when it is done with the PDO */
1317 ObReferenceObject(DeviceObject
);
1319 Irp
->IoStatus
.Information
= (ULONG_PTR
)DeviceRelations
;
1321 return STATUS_SUCCESS
;
1326 IN PDEVICE_OBJECT DeviceObject
,
1328 PIO_STACK_LOCATION IrpSp
)
1330 PPDO_DEVICE_EXTENSION DeviceExtension
;
1333 UNREFERENCED_PARAMETER(Irp
);
1336 DeviceExtension
= (PPDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
1338 if (IrpSp
->Parameters
.Power
.Type
== DevicePowerState
) {
1339 Status
= STATUS_SUCCESS
;
1340 switch (IrpSp
->Parameters
.Power
.State
.SystemState
) {
1342 Status
= STATUS_UNSUCCESSFUL
;
1345 Status
= STATUS_UNSUCCESSFUL
;
1352 /*** PUBLIC ******************************************************************/
1356 PDEVICE_OBJECT DeviceObject
,
1359 * FUNCTION: Handle Plug and Play IRPs for the child device
1361 * DeviceObject = Pointer to physical device object of the child device
1362 * Irp = Pointer to IRP that should be handled
1367 PIO_STACK_LOCATION IrpSp
;
1372 Status
= Irp
->IoStatus
.Status
;
1374 IrpSp
= IoGetCurrentIrpStackLocation(Irp
);
1376 switch (IrpSp
->MinorFunction
) {
1378 case IRP_MN_DEVICE_USAGE_NOTIFICATION
:
1379 DPRINT("Unimplemented IRP_MN_DEVICE_USAGE_NOTIFICATION received\n");
1383 DPRINT("Unimplemented IRP_MN_EJECT received\n");
1386 case IRP_MN_QUERY_BUS_INFORMATION
:
1387 Status
= PdoQueryBusInformation(DeviceObject
, Irp
, IrpSp
);
1390 case IRP_MN_QUERY_CAPABILITIES
:
1391 Status
= PdoQueryCapabilities(DeviceObject
, Irp
, IrpSp
);
1394 case IRP_MN_QUERY_DEVICE_RELATIONS
:
1395 Status
= PdoQueryDeviceRelations(DeviceObject
, Irp
, IrpSp
);
1398 case IRP_MN_QUERY_DEVICE_TEXT
:
1399 DPRINT("IRP_MN_QUERY_DEVICE_TEXT received\n");
1400 Status
= PdoQueryDeviceText(DeviceObject
, Irp
, IrpSp
);
1403 case IRP_MN_QUERY_ID
:
1404 DPRINT("IRP_MN_QUERY_ID received\n");
1405 Status
= PdoQueryId(DeviceObject
, Irp
, IrpSp
);
1408 case IRP_MN_QUERY_PNP_DEVICE_STATE
:
1409 DPRINT("Unimplemented IRP_MN_QUERY_ID received\n");
1412 case IRP_MN_QUERY_RESOURCE_REQUIREMENTS
:
1413 DPRINT("IRP_MN_QUERY_RESOURCE_REQUIREMENTS received\n");
1414 Status
= PdoQueryResourceRequirements(DeviceObject
, Irp
, IrpSp
);
1417 case IRP_MN_QUERY_RESOURCES
:
1418 DPRINT("IRP_MN_QUERY_RESOURCES received\n");
1419 Status
= PdoQueryResources(DeviceObject
, Irp
, IrpSp
);
1422 case IRP_MN_SET_LOCK
:
1423 DPRINT("Unimplemented IRP_MN_SET_LOCK received\n");
1426 case IRP_MN_START_DEVICE
:
1427 Status
= PdoStartDevice(DeviceObject
, Irp
, IrpSp
);
1430 case IRP_MN_QUERY_STOP_DEVICE
:
1431 case IRP_MN_CANCEL_STOP_DEVICE
:
1432 case IRP_MN_STOP_DEVICE
:
1433 case IRP_MN_QUERY_REMOVE_DEVICE
:
1434 case IRP_MN_CANCEL_REMOVE_DEVICE
:
1435 case IRP_MN_REMOVE_DEVICE
:
1436 case IRP_MN_SURPRISE_REMOVAL
:
1437 Status
= STATUS_SUCCESS
;
1440 case IRP_MN_QUERY_INTERFACE
:
1441 DPRINT("IRP_MN_QUERY_INTERFACE received\n");
1442 Status
= PdoQueryInterface(DeviceObject
, Irp
, IrpSp
);
1445 case IRP_MN_READ_CONFIG
:
1446 DPRINT("IRP_MN_READ_CONFIG received\n");
1447 Status
= PdoReadConfig(DeviceObject
, Irp
, IrpSp
);
1450 case IRP_MN_WRITE_CONFIG
:
1451 DPRINT("IRP_MN_WRITE_CONFIG received\n");
1452 Status
= PdoWriteConfig(DeviceObject
, Irp
, IrpSp
);
1455 case IRP_MN_FILTER_RESOURCE_REQUIREMENTS
:
1456 DPRINT("IRP_MN_FILTER_RESOURCE_REQUIREMENTS received\n");
1458 Irp
->IoStatus
.Status
= Status
;
1462 DPRINT1("Unknown IOCTL 0x%lx\n", IrpSp
->MinorFunction
);
1466 if (Status
!= STATUS_PENDING
) {
1467 Irp
->IoStatus
.Status
= Status
;
1468 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
1471 DPRINT("Leaving. Status 0x%X\n", Status
);
1478 PDEVICE_OBJECT DeviceObject
,
1481 * FUNCTION: Handle power management IRPs for the child device
1483 * DeviceObject = Pointer to physical device object of the child device
1484 * Irp = Pointer to IRP that should be handled
1489 PIO_STACK_LOCATION IrpSp
;
1494 IrpSp
= IoGetCurrentIrpStackLocation(Irp
);
1496 switch (IrpSp
->MinorFunction
) {
1497 case IRP_MN_SET_POWER
:
1498 Status
= PdoSetPower(DeviceObject
, Irp
, IrpSp
);
1502 DPRINT("Unknown IOCTL 0x%X\n", IrpSp
->MinorFunction
);
1503 Status
= STATUS_NOT_IMPLEMENTED
;
1507 if (Status
!= STATUS_PENDING
) {
1508 Irp
->IoStatus
.Status
= Status
;
1509 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
1512 DPRINT("Leaving. Status 0x%X\n", Status
);