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
;
26 UNICODE_STRING String
;
31 DeviceExtension
= (PPDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
33 switch (IrpSp
->Parameters
.QueryDeviceText
.DeviceTextType
)
35 case DeviceTextDescription
:
36 Status
= PciDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
,
37 &DeviceExtension
->DeviceDescription
,
40 DPRINT("DeviceTextDescription\n");
41 Irp
->IoStatus
.Information
= (ULONG_PTR
)String
.Buffer
;
44 case DeviceTextLocationInformation
:
45 Status
= PciDuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
,
46 &DeviceExtension
->DeviceLocation
,
49 DPRINT("DeviceTextLocationInformation\n");
50 Irp
->IoStatus
.Information
= (ULONG_PTR
)String
.Buffer
;
54 Irp
->IoStatus
.Information
= 0;
55 Status
= STATUS_INVALID_PARAMETER
;
65 IN PDEVICE_OBJECT DeviceObject
,
67 PIO_STACK_LOCATION IrpSp
)
69 PPDO_DEVICE_EXTENSION DeviceExtension
;
70 UNICODE_STRING String
;
75 DeviceExtension
= (PPDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
77 // Irp->IoStatus.Information = 0;
79 Status
= STATUS_SUCCESS
;
81 RtlInitUnicodeString(&String
, NULL
);
83 switch (IrpSp
->Parameters
.QueryId
.IdType
) {
84 case BusQueryDeviceID
:
85 Status
= PciDuplicateUnicodeString(
86 RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
,
87 &DeviceExtension
->DeviceID
,
90 DPRINT("DeviceID: %S\n", String
.Buffer
);
92 Irp
->IoStatus
.Information
= (ULONG_PTR
)String
.Buffer
;
95 case BusQueryHardwareIDs
:
96 Status
= PciDuplicateUnicodeString(
97 RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
,
98 &DeviceExtension
->HardwareIDs
,
101 Irp
->IoStatus
.Information
= (ULONG_PTR
)String
.Buffer
;
104 case BusQueryCompatibleIDs
:
105 Status
= PciDuplicateUnicodeString(
106 RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
,
107 &DeviceExtension
->CompatibleIDs
,
110 Irp
->IoStatus
.Information
= (ULONG_PTR
)String
.Buffer
;
113 case BusQueryInstanceID
:
114 Status
= PciDuplicateUnicodeString(
115 RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
,
116 &DeviceExtension
->InstanceID
,
119 DPRINT("InstanceID: %S\n", String
.Buffer
);
121 Irp
->IoStatus
.Information
= (ULONG_PTR
)String
.Buffer
;
124 case BusQueryDeviceSerialNumber
:
126 Status
= STATUS_NOT_IMPLEMENTED
;
134 PdoQueryBusInformation(
135 IN PDEVICE_OBJECT DeviceObject
,
137 PIO_STACK_LOCATION IrpSp
)
139 PPDO_DEVICE_EXTENSION DeviceExtension
;
140 PPNP_BUS_INFORMATION BusInformation
;
142 UNREFERENCED_PARAMETER(IrpSp
);
145 DeviceExtension
= (PPDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
146 BusInformation
= ExAllocatePool(PagedPool
, sizeof(PNP_BUS_INFORMATION
));
147 Irp
->IoStatus
.Information
= (ULONG_PTR
)BusInformation
;
148 if (BusInformation
!= NULL
)
150 BusInformation
->BusTypeGuid
= GUID_BUS_TYPE_PCI
;
151 BusInformation
->LegacyBusType
= PCIBus
;
152 BusInformation
->BusNumber
= DeviceExtension
->PciDevice
->BusNumber
;
154 return STATUS_SUCCESS
;
157 return STATUS_INSUFFICIENT_RESOURCES
;
162 PdoQueryCapabilities(
163 IN PDEVICE_OBJECT DeviceObject
,
165 PIO_STACK_LOCATION IrpSp
)
167 PPDO_DEVICE_EXTENSION DeviceExtension
;
168 PDEVICE_CAPABILITIES DeviceCapabilities
;
169 ULONG DeviceNumber
, FunctionNumber
;
171 UNREFERENCED_PARAMETER(Irp
);
174 DeviceExtension
= (PPDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
175 DeviceCapabilities
= IrpSp
->Parameters
.DeviceCapabilities
.Capabilities
;
177 if (DeviceCapabilities
->Version
!= 1)
178 return STATUS_UNSUCCESSFUL
;
180 DeviceNumber
= DeviceExtension
->PciDevice
->SlotNumber
.u
.bits
.DeviceNumber
;
181 FunctionNumber
= DeviceExtension
->PciDevice
->SlotNumber
.u
.bits
.FunctionNumber
;
183 DeviceCapabilities
->UniqueID
= FALSE
;
184 DeviceCapabilities
->Address
= ((DeviceNumber
<< 16) & 0xFFFF0000) + (FunctionNumber
& 0xFFFF);
185 DeviceCapabilities
->UINumber
= MAXULONG
; /* FIXME */
187 return STATUS_SUCCESS
;
192 PdoGetRangeLength(PPDO_DEVICE_EXTENSION DeviceExtension
,
204 /* Save original value */
205 Size
= HalGetBusDataByOffset(PCIConfiguration
,
206 DeviceExtension
->PciDevice
->BusNumber
,
207 DeviceExtension
->PciDevice
->SlotNumber
.u
.AsULONG
,
211 if (Size
!= sizeof(ULONG
))
213 DPRINT1("Wrong size %lu\n", Size
);
217 BaseValue
= (OrigValue
& 0x00000001) ? (OrigValue
& ~0x3) : (OrigValue
& ~0xF);
221 /* Set magic value */
223 Size
= HalSetBusDataByOffset(PCIConfiguration
,
224 DeviceExtension
->PciDevice
->BusNumber
,
225 DeviceExtension
->PciDevice
->SlotNumber
.u
.AsULONG
,
229 if (Size
!= sizeof(ULONG
))
231 DPRINT1("Wrong size %lu\n", Size
);
235 /* Get the range length */
236 Size
= HalGetBusDataByOffset(PCIConfiguration
,
237 DeviceExtension
->PciDevice
->BusNumber
,
238 DeviceExtension
->PciDevice
->SlotNumber
.u
.AsULONG
,
242 if (Size
!= sizeof(ULONG
))
244 DPRINT1("Wrong size %lu\n", Size
);
248 /* Restore original value */
249 Size
= HalSetBusDataByOffset(PCIConfiguration
,
250 DeviceExtension
->PciDevice
->BusNumber
,
251 DeviceExtension
->PciDevice
->SlotNumber
.u
.AsULONG
,
255 if (Size
!= sizeof(ULONG
))
257 DPRINT1("Wrong size %lu\n", Size
);
263 DPRINT("Unused address register\n");
270 XLength
= ~((NewValue
& 0x00000001) ? (NewValue
& ~0x3) : (NewValue
& ~0xF)) + 1;
273 DbgPrint("BaseAddress 0x%08lx Length 0x%08lx",
276 if (NewValue
& 0x00000001)
278 DbgPrint(" IO range");
282 DbgPrint(" Memory range");
283 if ((NewValue
& 0x00000006) == 0)
285 DbgPrint(" in 32-Bit address space");
287 else if ((NewValue
& 0x00000006) == 2)
289 DbgPrint(" below 1BM ");
291 else if ((NewValue
& 0x00000006) == 4)
293 DbgPrint(" in 64-Bit address space");
296 if (NewValue
& 0x00000008)
298 DbgPrint(" prefetchable");
306 *Flags
= (NewValue
& 0x00000001) ? (NewValue
& 0x3) : (NewValue
& 0xF);
313 PdoQueryResourceRequirements(
314 IN PDEVICE_OBJECT DeviceObject
,
316 PIO_STACK_LOCATION IrpSp
)
318 PPDO_DEVICE_EXTENSION DeviceExtension
;
319 PCI_COMMON_CONFIG PciConfig
;
320 PIO_RESOURCE_REQUIREMENTS_LIST ResourceList
;
321 PIO_RESOURCE_DESCRIPTOR Descriptor
;
330 UNREFERENCED_PARAMETER(IrpSp
);
331 DPRINT("PdoQueryResourceRequirements() called\n");
333 DeviceExtension
= (PPDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
335 /* Get PCI configuration space */
336 Size
= HalGetBusData(PCIConfiguration
,
337 DeviceExtension
->PciDevice
->BusNumber
,
338 DeviceExtension
->PciDevice
->SlotNumber
.u
.AsULONG
,
340 PCI_COMMON_HDR_LENGTH
);
341 DPRINT("Size %lu\n", Size
);
342 if (Size
< PCI_COMMON_HDR_LENGTH
)
344 Irp
->IoStatus
.Information
= 0;
345 return STATUS_UNSUCCESSFUL
;
348 DPRINT("Command register: 0x%04hx\n", PciConfig
.Command
);
350 /* Count required resource descriptors */
352 if (PCI_CONFIGURATION_TYPE(&PciConfig
) == PCI_DEVICE_TYPE
)
354 for (i
= 0; i
< PCI_TYPE0_ADDRESSES
; i
++)
356 if (!PdoGetRangeLength(DeviceExtension
,
367 /* FIXME: Check ROM address */
369 if (PciConfig
.u
.type0
.InterruptPin
!= 0)
372 else if (PCI_CONFIGURATION_TYPE(&PciConfig
) == PCI_BRIDGE_TYPE
)
374 for (i
= 0; i
< PCI_TYPE1_ADDRESSES
; i
++)
376 if (!PdoGetRangeLength(DeviceExtension
,
386 if (DeviceExtension
->PciDevice
->PciConfig
.BaseClass
== PCI_CLASS_BRIDGE_DEV
)
389 else if (PCI_CONFIGURATION_TYPE(&PciConfig
) == PCI_CARDBUS_BRIDGE_TYPE
)
391 /* FIXME: Count Cardbus bridge resources */
395 DPRINT1("Unsupported header type %u\n", PCI_CONFIGURATION_TYPE(&PciConfig
));
400 Irp
->IoStatus
.Information
= 0;
401 return STATUS_SUCCESS
;
404 /* Calculate the resource list size */
405 ListSize
= FIELD_OFFSET(IO_RESOURCE_REQUIREMENTS_LIST
, List
[0].Descriptors
)
406 + ResCount
* sizeof(IO_RESOURCE_DESCRIPTOR
);
408 DPRINT("ListSize %lu (0x%lx)\n", ListSize
, ListSize
);
410 /* Allocate the resource requirements list */
411 ResourceList
= ExAllocatePoolWithTag(PagedPool
,
413 if (ResourceList
== NULL
)
415 Irp
->IoStatus
.Information
= 0;
416 return STATUS_INSUFFICIENT_RESOURCES
;
419 RtlZeroMemory(ResourceList
, ListSize
);
420 ResourceList
->ListSize
= ListSize
;
421 ResourceList
->InterfaceType
= PCIBus
;
422 ResourceList
->BusNumber
= DeviceExtension
->PciDevice
->BusNumber
;
423 ResourceList
->SlotNumber
= DeviceExtension
->PciDevice
->SlotNumber
.u
.AsULONG
;
424 ResourceList
->AlternativeLists
= 1;
426 ResourceList
->List
[0].Version
= 1;
427 ResourceList
->List
[0].Revision
= 1;
428 ResourceList
->List
[0].Count
= ResCount
;
430 Descriptor
= &ResourceList
->List
[0].Descriptors
[0];
431 if (PCI_CONFIGURATION_TYPE(&PciConfig
) == PCI_DEVICE_TYPE
)
433 for (i
= 0; i
< PCI_TYPE0_ADDRESSES
; i
++)
435 if (!PdoGetRangeLength(DeviceExtension
,
441 DPRINT1("PdoGetRangeLength() failed\n");
447 DPRINT("Unused address register\n");
451 /* Set preferred descriptor */
452 Descriptor
->Option
= IO_RESOURCE_PREFERRED
;
453 if (Flags
& PCI_ADDRESS_IO_SPACE
)
455 Descriptor
->Type
= CmResourceTypePort
;
456 Descriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
457 Descriptor
->Flags
= CM_RESOURCE_PORT_IO
|
458 CM_RESOURCE_PORT_16_BIT_DECODE
|
459 CM_RESOURCE_PORT_POSITIVE_DECODE
;
461 Descriptor
->u
.Port
.Length
= Length
;
462 Descriptor
->u
.Port
.Alignment
= 1;
463 Descriptor
->u
.Port
.MinimumAddress
.QuadPart
= (ULONGLONG
)Base
;
464 Descriptor
->u
.Port
.MaximumAddress
.QuadPart
= (ULONGLONG
)(Base
+ Length
- 1);
468 Descriptor
->Type
= CmResourceTypeMemory
;
469 Descriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
470 Descriptor
->Flags
= CM_RESOURCE_MEMORY_READ_WRITE
;
472 Descriptor
->u
.Memory
.Length
= Length
;
473 Descriptor
->u
.Memory
.Alignment
= 1;
474 Descriptor
->u
.Memory
.MinimumAddress
.QuadPart
= (ULONGLONG
)Base
;
475 Descriptor
->u
.Memory
.MaximumAddress
.QuadPart
= (ULONGLONG
)(Base
+ Length
- 1);
479 /* Set alternative descriptor */
480 Descriptor
->Option
= IO_RESOURCE_ALTERNATIVE
;
481 if (Flags
& PCI_ADDRESS_IO_SPACE
)
483 Descriptor
->Type
= CmResourceTypePort
;
484 Descriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
485 Descriptor
->Flags
= CM_RESOURCE_PORT_IO
|
486 CM_RESOURCE_PORT_16_BIT_DECODE
|
487 CM_RESOURCE_PORT_POSITIVE_DECODE
;
489 Descriptor
->u
.Port
.Length
= Length
;
490 Descriptor
->u
.Port
.Alignment
= Length
;
491 Descriptor
->u
.Port
.MinimumAddress
.QuadPart
= (ULONGLONG
)0;
492 Descriptor
->u
.Port
.MaximumAddress
.QuadPart
= (ULONGLONG
)0x00000000FFFFFFFF;
496 Descriptor
->Type
= CmResourceTypeMemory
;
497 Descriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
498 Descriptor
->Flags
= CM_RESOURCE_MEMORY_READ_WRITE
;
500 Descriptor
->u
.Memory
.Length
= Length
;
501 Descriptor
->u
.Memory
.Alignment
= Length
;
502 Descriptor
->u
.Port
.MinimumAddress
.QuadPart
= (ULONGLONG
)0;
503 Descriptor
->u
.Port
.MaximumAddress
.QuadPart
= (ULONGLONG
)0x00000000FFFFFFFF;
508 /* FIXME: Check ROM address */
510 if (PciConfig
.u
.type0
.InterruptPin
!= 0)
512 Descriptor
->Option
= 0; /* Required */
513 Descriptor
->Type
= CmResourceTypeInterrupt
;
514 Descriptor
->ShareDisposition
= CmResourceShareShared
;
515 Descriptor
->Flags
= CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE
;
517 Descriptor
->u
.Interrupt
.MinimumVector
= 0;
518 Descriptor
->u
.Interrupt
.MaximumVector
= 0xFF;
521 else if (PCI_CONFIGURATION_TYPE(&PciConfig
) == PCI_BRIDGE_TYPE
)
523 for (i
= 0; i
< PCI_TYPE1_ADDRESSES
; i
++)
525 if (!PdoGetRangeLength(DeviceExtension
,
531 DPRINT1("PdoGetRangeLength() failed\n");
537 DPRINT("Unused address register\n");
541 /* Set preferred descriptor */
542 Descriptor
->Option
= IO_RESOURCE_PREFERRED
;
543 if (Flags
& PCI_ADDRESS_IO_SPACE
)
545 Descriptor
->Type
= CmResourceTypePort
;
546 Descriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
547 Descriptor
->Flags
= CM_RESOURCE_PORT_IO
|
548 CM_RESOURCE_PORT_16_BIT_DECODE
|
549 CM_RESOURCE_PORT_POSITIVE_DECODE
;
551 Descriptor
->u
.Port
.Length
= Length
;
552 Descriptor
->u
.Port
.Alignment
= 1;
553 Descriptor
->u
.Port
.MinimumAddress
.QuadPart
= (ULONGLONG
)Base
;
554 Descriptor
->u
.Port
.MaximumAddress
.QuadPart
= (ULONGLONG
)(Base
+ Length
- 1);
558 Descriptor
->Type
= CmResourceTypeMemory
;
559 Descriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
560 Descriptor
->Flags
= CM_RESOURCE_MEMORY_READ_WRITE
;
562 Descriptor
->u
.Memory
.Length
= Length
;
563 Descriptor
->u
.Memory
.Alignment
= 1;
564 Descriptor
->u
.Memory
.MinimumAddress
.QuadPart
= (ULONGLONG
)Base
;
565 Descriptor
->u
.Memory
.MaximumAddress
.QuadPart
= (ULONGLONG
)(Base
+ Length
- 1);
569 /* Set alternative descriptor */
570 Descriptor
->Option
= IO_RESOURCE_ALTERNATIVE
;
571 if (Flags
& PCI_ADDRESS_IO_SPACE
)
573 Descriptor
->Type
= CmResourceTypePort
;
574 Descriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
575 Descriptor
->Flags
= CM_RESOURCE_PORT_IO
|
576 CM_RESOURCE_PORT_16_BIT_DECODE
|
577 CM_RESOURCE_PORT_POSITIVE_DECODE
;
579 Descriptor
->u
.Port
.Length
= Length
;
580 Descriptor
->u
.Port
.Alignment
= Length
;
581 Descriptor
->u
.Port
.MinimumAddress
.QuadPart
= (ULONGLONG
)0;
582 Descriptor
->u
.Port
.MaximumAddress
.QuadPart
= (ULONGLONG
)0x00000000FFFFFFFF;
586 Descriptor
->Type
= CmResourceTypeMemory
;
587 Descriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
588 Descriptor
->Flags
= CM_RESOURCE_MEMORY_READ_WRITE
;
590 Descriptor
->u
.Memory
.Length
= Length
;
591 Descriptor
->u
.Memory
.Alignment
= Length
;
592 Descriptor
->u
.Port
.MinimumAddress
.QuadPart
= (ULONGLONG
)0;
593 Descriptor
->u
.Port
.MaximumAddress
.QuadPart
= (ULONGLONG
)0x00000000FFFFFFFF;
597 if (DeviceExtension
->PciDevice
->PciConfig
.BaseClass
== PCI_CLASS_BRIDGE_DEV
)
599 Descriptor
->Option
= 0; /* Required */
600 Descriptor
->Type
= CmResourceTypeBusNumber
;
601 Descriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
603 ResourceList
->BusNumber
=
604 Descriptor
->u
.BusNumber
.MinBusNumber
=
605 Descriptor
->u
.BusNumber
.MaxBusNumber
= DeviceExtension
->PciDevice
->PciConfig
.u
.type1
.SecondaryBus
;
606 Descriptor
->u
.BusNumber
.Length
= 1;
607 Descriptor
->u
.BusNumber
.Reserved
= 0;
610 else if (PCI_CONFIGURATION_TYPE(&PciConfig
) == PCI_CARDBUS_BRIDGE_TYPE
)
612 /* FIXME: Add Cardbus bridge resources */
615 Irp
->IoStatus
.Information
= (ULONG_PTR
)ResourceList
;
617 return STATUS_SUCCESS
;
623 IN PDEVICE_OBJECT DeviceObject
,
625 PIO_STACK_LOCATION IrpSp
)
627 PPDO_DEVICE_EXTENSION DeviceExtension
;
628 PCI_COMMON_CONFIG PciConfig
;
629 PCM_RESOURCE_LIST ResourceList
;
630 PCM_PARTIAL_RESOURCE_LIST PartialList
;
631 PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor
;
640 DPRINT("PdoQueryResources() called\n");
642 UNREFERENCED_PARAMETER(IrpSp
);
643 DeviceExtension
= (PPDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
645 /* Get PCI configuration space */
646 Size
= HalGetBusData(PCIConfiguration
,
647 DeviceExtension
->PciDevice
->BusNumber
,
648 DeviceExtension
->PciDevice
->SlotNumber
.u
.AsULONG
,
650 PCI_COMMON_HDR_LENGTH
);
651 DPRINT("Size %lu\n", Size
);
652 if (Size
< PCI_COMMON_HDR_LENGTH
)
654 Irp
->IoStatus
.Information
= 0;
655 return STATUS_UNSUCCESSFUL
;
658 DPRINT("Command register: 0x%04hx\n", PciConfig
.Command
);
660 /* Count required resource descriptors */
662 if (PCI_CONFIGURATION_TYPE(&PciConfig
) == PCI_DEVICE_TYPE
)
664 for (i
= 0; i
< PCI_TYPE0_ADDRESSES
; i
++)
666 if (!PdoGetRangeLength(DeviceExtension
,
677 if ((PciConfig
.u
.type0
.InterruptPin
!= 0) &&
678 (PciConfig
.u
.type0
.InterruptLine
!= 0) &&
679 (PciConfig
.u
.type0
.InterruptLine
!= 0xFF))
682 else if (PCI_CONFIGURATION_TYPE(&PciConfig
) == PCI_BRIDGE_TYPE
)
684 for (i
= 0; i
< PCI_TYPE1_ADDRESSES
; i
++)
686 if (!PdoGetRangeLength(DeviceExtension
,
696 if (DeviceExtension
->PciDevice
->PciConfig
.BaseClass
== PCI_CLASS_BRIDGE_DEV
)
699 else if (PCI_CONFIGURATION_TYPE(&PciConfig
) == PCI_CARDBUS_BRIDGE_TYPE
)
701 /* FIXME: Count Cardbus bridge resources */
705 DPRINT1("Unsupported header type %u\n", PCI_CONFIGURATION_TYPE(&PciConfig
));
710 Irp
->IoStatus
.Information
= 0;
711 return STATUS_SUCCESS
;
714 /* Calculate the resource list size */
715 ListSize
= FIELD_OFFSET(CM_RESOURCE_LIST
, List
[0].PartialResourceList
.PartialDescriptors
)
716 + ResCount
* sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR
);
718 /* Allocate the resource list */
719 ResourceList
= ExAllocatePoolWithTag(PagedPool
,
721 if (ResourceList
== NULL
)
722 return STATUS_INSUFFICIENT_RESOURCES
;
724 RtlZeroMemory(ResourceList
, ListSize
);
725 ResourceList
->Count
= 1;
726 ResourceList
->List
[0].InterfaceType
= PCIBus
;
727 ResourceList
->List
[0].BusNumber
= DeviceExtension
->PciDevice
->BusNumber
;
729 PartialList
= &ResourceList
->List
[0].PartialResourceList
;
730 PartialList
->Version
= 1;
731 PartialList
->Revision
= 1;
732 PartialList
->Count
= ResCount
;
734 Descriptor
= &PartialList
->PartialDescriptors
[0];
735 if (PCI_CONFIGURATION_TYPE(&PciConfig
) == PCI_DEVICE_TYPE
)
737 for (i
= 0; i
< PCI_TYPE0_ADDRESSES
; i
++)
739 if (!PdoGetRangeLength(DeviceExtension
,
745 DPRINT1("PdoGetRangeLength() failed\n");
751 DPRINT("Unused address register\n");
755 if (Flags
& PCI_ADDRESS_IO_SPACE
)
757 Descriptor
->Type
= CmResourceTypePort
;
758 Descriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
759 Descriptor
->Flags
= CM_RESOURCE_PORT_IO
;
760 Descriptor
->u
.Port
.Start
.QuadPart
=
762 Descriptor
->u
.Port
.Length
= Length
;
766 Descriptor
->Type
= CmResourceTypeMemory
;
767 Descriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
768 Descriptor
->Flags
= CM_RESOURCE_MEMORY_READ_WRITE
;
769 Descriptor
->u
.Memory
.Start
.QuadPart
=
771 Descriptor
->u
.Memory
.Length
= Length
;
777 /* Add interrupt resource */
778 if ((PciConfig
.u
.type0
.InterruptPin
!= 0) &&
779 (PciConfig
.u
.type0
.InterruptLine
!= 0) &&
780 (PciConfig
.u
.type0
.InterruptLine
!= 0xFF))
782 Descriptor
->Type
= CmResourceTypeInterrupt
;
783 Descriptor
->ShareDisposition
= CmResourceShareShared
;
784 Descriptor
->Flags
= CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE
;
785 Descriptor
->u
.Interrupt
.Level
= PciConfig
.u
.type0
.InterruptLine
;
786 Descriptor
->u
.Interrupt
.Vector
= PciConfig
.u
.type0
.InterruptLine
;
787 Descriptor
->u
.Interrupt
.Affinity
= 0xFFFFFFFF;
790 else if (PCI_CONFIGURATION_TYPE(&PciConfig
) == PCI_BRIDGE_TYPE
)
792 for (i
= 0; i
< PCI_TYPE1_ADDRESSES
; i
++)
794 if (!PdoGetRangeLength(DeviceExtension
,
800 DPRINT1("PdoGetRangeLength() failed\n");
806 DPRINT("Unused address register\n");
810 if (Flags
& PCI_ADDRESS_IO_SPACE
)
812 Descriptor
->Type
= CmResourceTypePort
;
813 Descriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
814 Descriptor
->Flags
= CM_RESOURCE_PORT_IO
;
815 Descriptor
->u
.Port
.Start
.QuadPart
=
817 Descriptor
->u
.Port
.Length
= Length
;
821 Descriptor
->Type
= CmResourceTypeMemory
;
822 Descriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
823 Descriptor
->Flags
= CM_RESOURCE_MEMORY_READ_WRITE
;
824 Descriptor
->u
.Memory
.Start
.QuadPart
=
826 Descriptor
->u
.Memory
.Length
= Length
;
831 if (DeviceExtension
->PciDevice
->PciConfig
.BaseClass
== PCI_CLASS_BRIDGE_DEV
)
833 Descriptor
->Type
= CmResourceTypeBusNumber
;
834 Descriptor
->ShareDisposition
= CmResourceShareDeviceExclusive
;
836 ResourceList
->List
[0].BusNumber
=
837 Descriptor
->u
.BusNumber
.Start
= DeviceExtension
->PciDevice
->PciConfig
.u
.type1
.SecondaryBus
;
838 Descriptor
->u
.BusNumber
.Length
= 1;
839 Descriptor
->u
.BusNumber
.Reserved
= 0;
842 else if (PCI_CONFIGURATION_TYPE(&PciConfig
) == PCI_CARDBUS_BRIDGE_TYPE
)
844 /* FIXME: Add Cardbus bridge resources */
847 Irp
->IoStatus
.Information
= (ULONG_PTR
)ResourceList
;
849 return STATUS_SUCCESS
;
857 PPDO_DEVICE_EXTENSION DeviceExtension
;
859 DPRINT("InterfaceReference(%p)\n", Context
);
861 DeviceExtension
= (PPDO_DEVICE_EXTENSION
)((PDEVICE_OBJECT
)Context
)->DeviceExtension
;
862 InterlockedIncrement(&DeviceExtension
->References
);
867 InterfaceDereference(
870 PPDO_DEVICE_EXTENSION DeviceExtension
;
872 DPRINT("InterfaceDereference(%p)\n", Context
);
874 DeviceExtension
= (PPDO_DEVICE_EXTENSION
)((PDEVICE_OBJECT
)Context
)->DeviceExtension
;
875 InterlockedDecrement(&DeviceExtension
->References
);
880 InterfaceBusTranslateBusAddress(
882 IN PHYSICAL_ADDRESS BusAddress
,
884 IN OUT PULONG AddressSpace
,
885 OUT PPHYSICAL_ADDRESS TranslatedAddress
)
887 PPDO_DEVICE_EXTENSION DeviceExtension
;
889 DPRINT("InterfaceBusTranslateBusAddress(%p %p 0x%lx %p %p)\n",
890 Context
, BusAddress
, Length
, AddressSpace
, TranslatedAddress
);
892 DeviceExtension
= (PPDO_DEVICE_EXTENSION
)((PDEVICE_OBJECT
)Context
)->DeviceExtension
;
894 return HalTranslateBusAddress(
895 PCIBus
, DeviceExtension
->PciDevice
->BusNumber
,
896 BusAddress
, AddressSpace
, TranslatedAddress
);
900 static PDMA_ADAPTER NTAPI
901 InterfaceBusGetDmaAdapter(
903 IN PDEVICE_DESCRIPTION DeviceDescription
,
904 OUT PULONG NumberOfMapRegisters
)
906 DPRINT("InterfaceBusGetDmaAdapter(%p %p %p)\n",
907 Context
, DeviceDescription
, NumberOfMapRegisters
);
908 return (PDMA_ADAPTER
)HalGetAdapter(DeviceDescription
, NumberOfMapRegisters
);
913 InterfaceBusSetBusData(
920 PPDO_DEVICE_EXTENSION DeviceExtension
;
923 DPRINT("InterfaceBusSetBusData(%p 0x%lx %p 0x%lx 0x%lx)\n",
924 Context
, DataType
, Buffer
, Offset
, Length
);
926 if (DataType
!= PCI_WHICHSPACE_CONFIG
)
928 DPRINT("Unknown DataType %lu\n", DataType
);
932 DeviceExtension
= (PPDO_DEVICE_EXTENSION
)((PDEVICE_OBJECT
)Context
)->DeviceExtension
;
934 /* Get PCI configuration space */
935 Size
= HalSetBusDataByOffset(PCIConfiguration
,
936 DeviceExtension
->PciDevice
->BusNumber
,
937 DeviceExtension
->PciDevice
->SlotNumber
.u
.AsULONG
,
946 InterfaceBusGetBusData(
953 PPDO_DEVICE_EXTENSION DeviceExtension
;
956 DPRINT("InterfaceBusGetBusData(%p 0x%lx %p 0x%lx 0x%lx) called\n",
957 Context
, DataType
, Buffer
, Offset
, Length
);
959 if (DataType
!= PCI_WHICHSPACE_CONFIG
)
961 DPRINT("Unknown DataType %lu\n", DataType
);
965 DeviceExtension
= (PPDO_DEVICE_EXTENSION
)((PDEVICE_OBJECT
)Context
)->DeviceExtension
;
967 /* Get PCI configuration space */
968 Size
= HalGetBusDataByOffset(PCIConfiguration
,
969 DeviceExtension
->PciDevice
->BusNumber
,
970 DeviceExtension
->PciDevice
->SlotNumber
.u
.AsULONG
,
979 InterfacePciDevicePresent(
983 IN USHORT SubVendorID
,
984 IN USHORT SubSystemID
,
987 PFDO_DEVICE_EXTENSION FdoDeviceExtension
;
988 PPCI_DEVICE PciDevice
;
989 PLIST_ENTRY CurrentBus
, CurrentEntry
;
991 BOOLEAN Found
= FALSE
;
993 KeAcquireSpinLock(&DriverExtension
->BusListLock
, &OldIrql
);
994 CurrentBus
= DriverExtension
->BusListHead
.Flink
;
995 while (!Found
&& CurrentBus
!= &DriverExtension
->BusListHead
)
997 FdoDeviceExtension
= CONTAINING_RECORD(CurrentBus
, FDO_DEVICE_EXTENSION
, ListEntry
);
999 KeAcquireSpinLockAtDpcLevel(&FdoDeviceExtension
->DeviceListLock
);
1000 CurrentEntry
= FdoDeviceExtension
->DeviceListHead
.Flink
;
1001 while (!Found
&& CurrentEntry
!= &FdoDeviceExtension
->DeviceListHead
)
1003 PciDevice
= CONTAINING_RECORD(CurrentEntry
, PCI_DEVICE
, ListEntry
);
1004 if (PciDevice
->PciConfig
.VendorID
== VendorID
&&
1005 PciDevice
->PciConfig
.DeviceID
== DeviceID
)
1007 if (!(Flags
& PCI_USE_SUBSYSTEM_IDS
) || (
1008 PciDevice
->PciConfig
.u
.type0
.SubVendorID
== SubVendorID
&&
1009 PciDevice
->PciConfig
.u
.type0
.SubSystemID
== SubSystemID
))
1011 if (!(Flags
& PCI_USE_REVISION
) ||
1012 PciDevice
->PciConfig
.RevisionID
== RevisionID
)
1014 DPRINT("Found the PCI device\n");
1020 CurrentEntry
= CurrentEntry
->Flink
;
1023 KeReleaseSpinLockFromDpcLevel(&FdoDeviceExtension
->DeviceListLock
);
1024 CurrentBus
= CurrentBus
->Flink
;
1026 KeReleaseSpinLock(&DriverExtension
->BusListLock
, OldIrql
);
1034 IN PPCI_COMMON_CONFIG PciConfig
,
1035 IN PPCI_DEVICE_PRESENCE_PARAMETERS Parameters
)
1037 if ((Parameters
->Flags
& PCI_USE_VENDEV_IDS
) && (
1038 PciConfig
->VendorID
!= Parameters
->VendorID
||
1039 PciConfig
->DeviceID
!= Parameters
->DeviceID
))
1043 if ((Parameters
->Flags
& PCI_USE_CLASS_SUBCLASS
) && (
1044 PciConfig
->BaseClass
!= Parameters
->BaseClass
||
1045 PciConfig
->SubClass
!= Parameters
->SubClass
))
1049 if ((Parameters
->Flags
& PCI_USE_PROGIF
) &&
1050 PciConfig
->ProgIf
!= Parameters
->ProgIf
)
1054 if ((Parameters
->Flags
& PCI_USE_SUBSYSTEM_IDS
) && (
1055 PciConfig
->u
.type0
.SubVendorID
!= Parameters
->SubVendorID
||
1056 PciConfig
->u
.type0
.SubSystemID
!= Parameters
->SubSystemID
))
1060 if ((Parameters
->Flags
& PCI_USE_REVISION
) &&
1061 PciConfig
->RevisionID
!= Parameters
->RevisionID
)
1069 static BOOLEAN NTAPI
1070 InterfacePciDevicePresentEx(
1072 IN PPCI_DEVICE_PRESENCE_PARAMETERS Parameters
)
1074 PPDO_DEVICE_EXTENSION DeviceExtension
;
1075 PFDO_DEVICE_EXTENSION MyFdoDeviceExtension
;
1076 PFDO_DEVICE_EXTENSION FdoDeviceExtension
;
1077 PPCI_DEVICE PciDevice
;
1078 PLIST_ENTRY CurrentBus
, CurrentEntry
;
1080 BOOLEAN Found
= FALSE
;
1082 DPRINT("InterfacePciDevicePresentEx(%p %p) called\n",
1083 Context
, Parameters
);
1085 if (!Parameters
|| Parameters
->Size
!= sizeof(PCI_DEVICE_PRESENCE_PARAMETERS
))
1088 DeviceExtension
= (PPDO_DEVICE_EXTENSION
)((PDEVICE_OBJECT
)Context
)->DeviceExtension
;
1089 MyFdoDeviceExtension
= (PFDO_DEVICE_EXTENSION
)DeviceExtension
->Fdo
->DeviceExtension
;
1091 if (Parameters
->Flags
& PCI_USE_LOCAL_DEVICE
)
1093 return CheckPciDevice(&DeviceExtension
->PciDevice
->PciConfig
, Parameters
);
1096 KeAcquireSpinLock(&DriverExtension
->BusListLock
, &OldIrql
);
1097 CurrentBus
= DriverExtension
->BusListHead
.Flink
;
1098 while (!Found
&& CurrentBus
!= &DriverExtension
->BusListHead
)
1100 FdoDeviceExtension
= CONTAINING_RECORD(CurrentBus
, FDO_DEVICE_EXTENSION
, ListEntry
);
1101 if (!(Parameters
->Flags
& PCI_USE_LOCAL_BUS
) || FdoDeviceExtension
== MyFdoDeviceExtension
)
1103 KeAcquireSpinLockAtDpcLevel(&FdoDeviceExtension
->DeviceListLock
);
1104 CurrentEntry
= FdoDeviceExtension
->DeviceListHead
.Flink
;
1105 while (!Found
&& CurrentEntry
!= &FdoDeviceExtension
->DeviceListHead
)
1107 PciDevice
= CONTAINING_RECORD(CurrentEntry
, PCI_DEVICE
, ListEntry
);
1109 if (CheckPciDevice(&PciDevice
->PciConfig
, Parameters
))
1111 DPRINT("Found the PCI device\n");
1115 CurrentEntry
= CurrentEntry
->Flink
;
1118 KeReleaseSpinLockFromDpcLevel(&FdoDeviceExtension
->DeviceListLock
);
1120 CurrentBus
= CurrentBus
->Flink
;
1122 KeReleaseSpinLock(&DriverExtension
->BusListLock
, OldIrql
);
1130 IN PDEVICE_OBJECT DeviceObject
,
1132 PIO_STACK_LOCATION IrpSp
)
1136 UNREFERENCED_PARAMETER(Irp
);
1137 if (RtlCompareMemory(IrpSp
->Parameters
.QueryInterface
.InterfaceType
,
1138 &GUID_BUS_INTERFACE_STANDARD
, sizeof(GUID
)) == sizeof(GUID
))
1140 /* BUS_INTERFACE_STANDARD */
1141 if (IrpSp
->Parameters
.QueryInterface
.Version
< 1)
1142 Status
= STATUS_NOT_SUPPORTED
;
1143 else if (IrpSp
->Parameters
.QueryInterface
.Size
< sizeof(BUS_INTERFACE_STANDARD
))
1144 Status
= STATUS_BUFFER_TOO_SMALL
;
1147 PBUS_INTERFACE_STANDARD BusInterface
;
1148 BusInterface
= (PBUS_INTERFACE_STANDARD
)IrpSp
->Parameters
.QueryInterface
.Interface
;
1149 BusInterface
->Size
= sizeof(BUS_INTERFACE_STANDARD
);
1150 BusInterface
->Version
= 1;
1151 BusInterface
->TranslateBusAddress
= InterfaceBusTranslateBusAddress
;
1152 BusInterface
->GetDmaAdapter
= InterfaceBusGetDmaAdapter
;
1153 BusInterface
->SetBusData
= InterfaceBusSetBusData
;
1154 BusInterface
->GetBusData
= InterfaceBusGetBusData
;
1155 Status
= STATUS_SUCCESS
;
1158 else if (RtlCompareMemory(IrpSp
->Parameters
.QueryInterface
.InterfaceType
,
1159 &GUID_PCI_DEVICE_PRESENT_INTERFACE
, sizeof(GUID
)) == sizeof(GUID
))
1161 /* PCI_DEVICE_PRESENT_INTERFACE */
1162 if (IrpSp
->Parameters
.QueryInterface
.Version
< 1)
1163 Status
= STATUS_NOT_SUPPORTED
;
1164 else if (IrpSp
->Parameters
.QueryInterface
.Size
< sizeof(PCI_DEVICE_PRESENT_INTERFACE
))
1165 Status
= STATUS_BUFFER_TOO_SMALL
;
1168 PPCI_DEVICE_PRESENT_INTERFACE PciDevicePresentInterface
;
1169 PciDevicePresentInterface
= (PPCI_DEVICE_PRESENT_INTERFACE
)IrpSp
->Parameters
.QueryInterface
.Interface
;
1170 PciDevicePresentInterface
->Size
= sizeof(PCI_DEVICE_PRESENT_INTERFACE
);
1171 PciDevicePresentInterface
->Version
= 1;
1172 PciDevicePresentInterface
->IsDevicePresent
= InterfacePciDevicePresent
;
1173 PciDevicePresentInterface
->IsDevicePresentEx
= InterfacePciDevicePresentEx
;
1174 Status
= STATUS_SUCCESS
;
1179 /* Not a supported interface */
1180 return STATUS_NOT_SUPPORTED
;
1183 if (NT_SUCCESS(Status
))
1185 /* Add a reference for the returned interface */
1186 PINTERFACE Interface
;
1187 Interface
= (PINTERFACE
)IrpSp
->Parameters
.QueryInterface
.Interface
;
1188 Interface
->Context
= DeviceObject
;
1189 Interface
->InterfaceReference
= InterfaceReference
;
1190 Interface
->InterfaceDereference
= InterfaceDereference
;
1191 Interface
->InterfaceReference(Interface
->Context
);
1199 IN PDEVICE_OBJECT DeviceObject
,
1201 PIO_STACK_LOCATION IrpSp
)
1203 PCM_RESOURCE_LIST RawResList
= IrpSp
->Parameters
.StartDevice
.AllocatedResources
;
1204 PCM_FULL_RESOURCE_DESCRIPTOR RawFullDesc
;
1205 PCM_PARTIAL_RESOURCE_DESCRIPTOR RawPartialDesc
;
1207 PPDO_DEVICE_EXTENSION DeviceExtension
= DeviceObject
->DeviceExtension
;
1211 return STATUS_SUCCESS
;
1213 /* TODO: Assign the other resources we get to the card */
1215 for (i
= 0; i
< RawResList
->Count
; i
++)
1217 RawFullDesc
= &RawResList
->List
[i
];
1219 for (ii
= 0; ii
< RawFullDesc
->PartialResourceList
.Count
; ii
++)
1221 RawPartialDesc
= &RawFullDesc
->PartialResourceList
.PartialDescriptors
[ii
];
1223 if (RawPartialDesc
->Type
== CmResourceTypeInterrupt
)
1225 DPRINT1("Assigning IRQ %x to PCI device (%x, %x)\n",
1226 RawPartialDesc
->u
.Interrupt
.Vector
,
1227 DeviceExtension
->PciDevice
->SlotNumber
.u
.AsULONG
,
1228 DeviceExtension
->PciDevice
->BusNumber
);
1230 Irq
= (UCHAR
)RawPartialDesc
->u
.Interrupt
.Vector
;
1231 HalSetBusDataByOffset(PCIConfiguration
,
1232 DeviceExtension
->PciDevice
->BusNumber
,
1233 DeviceExtension
->PciDevice
->SlotNumber
.u
.AsULONG
,
1235 0x3c /* PCI_INTERRUPT_LINE */,
1241 return STATUS_SUCCESS
;
1246 IN PDEVICE_OBJECT DeviceObject
,
1248 PIO_STACK_LOCATION IrpSp
)
1252 DPRINT("PdoReadConfig() called\n");
1254 Size
= InterfaceBusGetBusData(
1256 IrpSp
->Parameters
.ReadWriteConfig
.WhichSpace
,
1257 IrpSp
->Parameters
.ReadWriteConfig
.Buffer
,
1258 IrpSp
->Parameters
.ReadWriteConfig
.Offset
,
1259 IrpSp
->Parameters
.ReadWriteConfig
.Length
);
1261 if (Size
!= IrpSp
->Parameters
.ReadWriteConfig
.Length
)
1263 DPRINT1("Size %lu Length %lu\n", Size
, IrpSp
->Parameters
.ReadWriteConfig
.Length
);
1264 Irp
->IoStatus
.Information
= 0;
1265 return STATUS_UNSUCCESSFUL
;
1268 Irp
->IoStatus
.Information
= Size
;
1270 return STATUS_SUCCESS
;
1276 IN PDEVICE_OBJECT DeviceObject
,
1278 PIO_STACK_LOCATION IrpSp
)
1282 DPRINT1("PdoWriteConfig() called\n");
1284 /* Get PCI configuration space */
1285 Size
= InterfaceBusSetBusData(
1287 IrpSp
->Parameters
.ReadWriteConfig
.WhichSpace
,
1288 IrpSp
->Parameters
.ReadWriteConfig
.Buffer
,
1289 IrpSp
->Parameters
.ReadWriteConfig
.Offset
,
1290 IrpSp
->Parameters
.ReadWriteConfig
.Length
);
1292 if (Size
!= IrpSp
->Parameters
.ReadWriteConfig
.Length
)
1294 DPRINT1("Size %lu Length %lu\n", Size
, IrpSp
->Parameters
.ReadWriteConfig
.Length
);
1295 Irp
->IoStatus
.Information
= 0;
1296 return STATUS_UNSUCCESSFUL
;
1299 Irp
->IoStatus
.Information
= Size
;
1301 return STATUS_SUCCESS
;
1305 PdoQueryDeviceRelations(
1306 IN PDEVICE_OBJECT DeviceObject
,
1308 PIO_STACK_LOCATION IrpSp
)
1310 PDEVICE_RELATIONS DeviceRelations
;
1312 /* We only support TargetDeviceRelation for child PDOs */
1313 if (IrpSp
->Parameters
.QueryDeviceRelations
.Type
!= TargetDeviceRelation
)
1314 return Irp
->IoStatus
.Status
;
1316 /* We can do this because we only return 1 PDO for TargetDeviceRelation */
1317 DeviceRelations
= ExAllocatePool(PagedPool
, sizeof(*DeviceRelations
));
1318 if (!DeviceRelations
)
1319 return STATUS_INSUFFICIENT_RESOURCES
;
1321 DeviceRelations
->Count
= 1;
1322 DeviceRelations
->Objects
[0] = DeviceObject
;
1324 /* The PnP manager will remove this when it is done with the PDO */
1325 ObReferenceObject(DeviceObject
);
1327 Irp
->IoStatus
.Information
= (ULONG_PTR
)DeviceRelations
;
1329 return STATUS_SUCCESS
;
1334 IN PDEVICE_OBJECT DeviceObject
,
1336 PIO_STACK_LOCATION IrpSp
)
1340 UNREFERENCED_PARAMETER(Irp
);
1343 if (IrpSp
->Parameters
.Power
.Type
== DevicePowerState
) {
1344 Status
= STATUS_SUCCESS
;
1345 switch (IrpSp
->Parameters
.Power
.State
.SystemState
) {
1347 Status
= STATUS_UNSUCCESSFUL
;
1350 Status
= STATUS_UNSUCCESSFUL
;
1357 /*** PUBLIC ******************************************************************/
1361 PDEVICE_OBJECT DeviceObject
,
1364 * FUNCTION: Handle Plug and Play IRPs for the child device
1366 * DeviceObject = Pointer to physical device object of the child device
1367 * Irp = Pointer to IRP that should be handled
1372 PIO_STACK_LOCATION IrpSp
;
1377 Status
= Irp
->IoStatus
.Status
;
1379 IrpSp
= IoGetCurrentIrpStackLocation(Irp
);
1381 switch (IrpSp
->MinorFunction
) {
1383 case IRP_MN_DEVICE_USAGE_NOTIFICATION
:
1384 DPRINT("Unimplemented IRP_MN_DEVICE_USAGE_NOTIFICATION received\n");
1388 DPRINT("Unimplemented IRP_MN_EJECT received\n");
1391 case IRP_MN_QUERY_BUS_INFORMATION
:
1392 Status
= PdoQueryBusInformation(DeviceObject
, Irp
, IrpSp
);
1395 case IRP_MN_QUERY_CAPABILITIES
:
1396 Status
= PdoQueryCapabilities(DeviceObject
, Irp
, IrpSp
);
1399 case IRP_MN_QUERY_DEVICE_RELATIONS
:
1400 Status
= PdoQueryDeviceRelations(DeviceObject
, Irp
, IrpSp
);
1403 case IRP_MN_QUERY_DEVICE_TEXT
:
1404 DPRINT("IRP_MN_QUERY_DEVICE_TEXT received\n");
1405 Status
= PdoQueryDeviceText(DeviceObject
, Irp
, IrpSp
);
1408 case IRP_MN_QUERY_ID
:
1409 DPRINT("IRP_MN_QUERY_ID received\n");
1410 Status
= PdoQueryId(DeviceObject
, Irp
, IrpSp
);
1413 case IRP_MN_QUERY_PNP_DEVICE_STATE
:
1414 DPRINT("Unimplemented IRP_MN_QUERY_ID received\n");
1417 case IRP_MN_QUERY_RESOURCE_REQUIREMENTS
:
1418 DPRINT("IRP_MN_QUERY_RESOURCE_REQUIREMENTS received\n");
1419 Status
= PdoQueryResourceRequirements(DeviceObject
, Irp
, IrpSp
);
1422 case IRP_MN_QUERY_RESOURCES
:
1423 DPRINT("IRP_MN_QUERY_RESOURCES received\n");
1424 Status
= PdoQueryResources(DeviceObject
, Irp
, IrpSp
);
1427 case IRP_MN_SET_LOCK
:
1428 DPRINT("Unimplemented IRP_MN_SET_LOCK received\n");
1431 case IRP_MN_START_DEVICE
:
1432 Status
= PdoStartDevice(DeviceObject
, Irp
, IrpSp
);
1435 case IRP_MN_QUERY_STOP_DEVICE
:
1436 case IRP_MN_CANCEL_STOP_DEVICE
:
1437 case IRP_MN_STOP_DEVICE
:
1438 case IRP_MN_QUERY_REMOVE_DEVICE
:
1439 case IRP_MN_CANCEL_REMOVE_DEVICE
:
1440 case IRP_MN_REMOVE_DEVICE
:
1441 case IRP_MN_SURPRISE_REMOVAL
:
1442 Status
= STATUS_SUCCESS
;
1445 case IRP_MN_QUERY_INTERFACE
:
1446 DPRINT("IRP_MN_QUERY_INTERFACE received\n");
1447 Status
= PdoQueryInterface(DeviceObject
, Irp
, IrpSp
);
1450 case IRP_MN_READ_CONFIG
:
1451 DPRINT("IRP_MN_READ_CONFIG received\n");
1452 Status
= PdoReadConfig(DeviceObject
, Irp
, IrpSp
);
1455 case IRP_MN_WRITE_CONFIG
:
1456 DPRINT("IRP_MN_WRITE_CONFIG received\n");
1457 Status
= PdoWriteConfig(DeviceObject
, Irp
, IrpSp
);
1460 case IRP_MN_FILTER_RESOURCE_REQUIREMENTS
:
1461 DPRINT("IRP_MN_FILTER_RESOURCE_REQUIREMENTS received\n");
1463 Irp
->IoStatus
.Status
= Status
;
1467 DPRINT1("Unknown IOCTL 0x%lx\n", IrpSp
->MinorFunction
);
1471 if (Status
!= STATUS_PENDING
) {
1472 Irp
->IoStatus
.Status
= Status
;
1473 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
1476 DPRINT("Leaving. Status 0x%X\n", Status
);
1483 PDEVICE_OBJECT DeviceObject
,
1486 * FUNCTION: Handle power management IRPs for the child device
1488 * DeviceObject = Pointer to physical device object of the child device
1489 * Irp = Pointer to IRP that should be handled
1494 PIO_STACK_LOCATION IrpSp
;
1499 IrpSp
= IoGetCurrentIrpStackLocation(Irp
);
1501 switch (IrpSp
->MinorFunction
) {
1502 case IRP_MN_SET_POWER
:
1503 Status
= PdoSetPower(DeviceObject
, Irp
, IrpSp
);
1507 DPRINT("Unknown IOCTL 0x%X\n", IrpSp
->MinorFunction
);
1508 Status
= STATUS_NOT_IMPLEMENTED
;
1512 if (Status
!= STATUS_PENDING
) {
1513 Irp
->IoStatus
.Status
= Status
;
1514 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
1517 DPRINT("Leaving. Status 0x%X\n", Status
);