1 /* $Id: pdo.c,v 1.3 2004/03/12 19:40:05 navaraf Exp $
3 * PROJECT: ReactOS PCI bus driver
5 * PURPOSE: Child device object dispatch routines
6 * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
8 * 10-09-2001 CSH Created
11 #include <ddk/ntddk.h>
19 DEFINE_GUID(GUID_BUS_TYPE_PCI
, 0xc8ebdfb0L
, 0xb510, 0x11d0, 0x80, 0xe5, 0x00, 0xa0, 0xc9, 0x25, 0x42, 0xe3);
21 /*** PRIVATE *****************************************************************/
25 IN PDEVICE_OBJECT DeviceObject
,
27 PIO_STACK_LOCATION IrpSp
)
29 PPDO_DEVICE_EXTENSION DeviceExtension
;
30 UNICODE_STRING String
;
35 DeviceExtension
= (PPDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
37 // Irp->IoStatus.Information = 0;
39 Status
= STATUS_SUCCESS
;
41 RtlInitUnicodeString(&String
, NULL
);
43 switch (IrpSp
->Parameters
.QueryId
.IdType
) {
44 case BusQueryDeviceID
:
45 Status
= PciCreateUnicodeString(
47 DeviceExtension
->DeviceID
.Buffer
,
50 DPRINT("DeviceID: %S\n", String
.Buffer
);
52 Irp
->IoStatus
.Information
= (ULONG_PTR
)String
.Buffer
;
55 case BusQueryHardwareIDs
:
56 case BusQueryCompatibleIDs
:
57 Status
= STATUS_NOT_IMPLEMENTED
;
60 case BusQueryInstanceID
:
61 Status
= PciCreateUnicodeString(
66 DPRINT("InstanceID: %S\n", String
.Buffer
);
68 Irp
->IoStatus
.Information
= (ULONG_PTR
)String
.Buffer
;
71 case BusQueryDeviceSerialNumber
:
73 Status
= STATUS_NOT_IMPLEMENTED
;
81 PdoQueryBusInformation(
82 IN PDEVICE_OBJECT DeviceObject
,
84 PIO_STACK_LOCATION IrpSp
)
86 PPDO_DEVICE_EXTENSION DeviceExtension
;
87 PFDO_DEVICE_EXTENSION FdoDeviceExtension
;
88 PPNP_BUS_INFORMATION BusInformation
;
92 DeviceExtension
= (PPDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
93 FdoDeviceExtension
= (PFDO_DEVICE_EXTENSION
)DeviceExtension
->Fdo
->DeviceExtension
;
94 BusInformation
= ExAllocatePool(PagedPool
, sizeof(PNP_BUS_INFORMATION
));
95 Irp
->IoStatus
.Information
= (ULONG_PTR
)BusInformation
;
96 if (BusInformation
!= NULL
)
98 BusInformation
->BusTypeGuid
= GUID_BUS_TYPE_PCI
;
99 BusInformation
->LegacyBusType
= PCIBus
;
100 BusInformation
->BusNumber
= DeviceExtension
->BusNumber
;
102 return STATUS_INSUFFICIENT_RESOURCES
;
105 return STATUS_SUCCESS
;
111 IN PDEVICE_OBJECT DeviceObject
,
113 PIO_STACK_LOCATION IrpSp
)
115 PPDO_DEVICE_EXTENSION DeviceExtension
;
120 DeviceExtension
= (PPDO_DEVICE_EXTENSION
)DeviceObject
->DeviceExtension
;
122 if (IrpSp
->Parameters
.Power
.Type
== DevicePowerState
) {
123 Status
= STATUS_SUCCESS
;
124 switch (IrpSp
->Parameters
.Power
.State
.SystemState
) {
126 Status
= STATUS_UNSUCCESSFUL
;
129 Status
= STATUS_UNSUCCESSFUL
;
136 /*** PUBLIC ******************************************************************/
140 PDEVICE_OBJECT DeviceObject
,
143 * FUNCTION: Handle Plug and Play IRPs for the child device
145 * DeviceObject = Pointer to physical device object of the child device
146 * Irp = Pointer to IRP that should be handled
151 PIO_STACK_LOCATION IrpSp
;
156 Status
= Irp
->IoStatus
.Status
;
158 IrpSp
= IoGetCurrentIrpStackLocation(Irp
);
160 switch (IrpSp
->MinorFunction
) {
162 case IRP_MN_CANCEL_REMOVE_DEVICE
:
165 case IRP_MN_CANCEL_STOP_DEVICE
:
168 case IRP_MN_DEVICE_USAGE_NOTIFICATION
:
175 case IRP_MN_QUERY_BUS_INFORMATION
:
176 Status
= PdoQueryBusInformation(DeviceObject
, Irp
, IrpSp
);
180 case IRP_MN_QUERY_CAPABILITIES
:
183 case IRP_MN_QUERY_DEVICE_RELATIONS
:
184 /* FIXME: Possibly handle for RemovalRelations */
187 case IRP_MN_QUERY_DEVICE_TEXT
:
190 case IRP_MN_QUERY_ID
:
191 Status
= PdoQueryId(DeviceObject
, Irp
, IrpSp
);
194 case IRP_MN_QUERY_PNP_DEVICE_STATE
:
197 case IRP_MN_QUERY_REMOVE_DEVICE
:
200 case IRP_MN_QUERY_RESOURCE_REQUIREMENTS
:
203 case IRP_MN_QUERY_RESOURCES
:
206 case IRP_MN_QUERY_STOP_DEVICE
:
209 case IRP_MN_REMOVE_DEVICE
:
212 case IRP_MN_SET_LOCK
:
215 case IRP_MN_START_DEVICE
:
218 case IRP_MN_STOP_DEVICE
:
221 case IRP_MN_SURPRISE_REMOVAL
:
225 DPRINT("Unknown IOCTL 0x%X\n", IrpSp
->MinorFunction
);
229 if (Status
!= STATUS_PENDING
) {
230 Irp
->IoStatus
.Status
= Status
;
231 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
234 DPRINT("Leaving. Status 0x%X\n", Status
);
241 PDEVICE_OBJECT DeviceObject
,
244 * FUNCTION: Handle power management IRPs for the child device
246 * DeviceObject = Pointer to physical device object of the child device
247 * Irp = Pointer to IRP that should be handled
252 PIO_STACK_LOCATION IrpSp
;
257 IrpSp
= IoGetCurrentIrpStackLocation(Irp
);
259 switch (IrpSp
->MinorFunction
) {
260 case IRP_MN_SET_POWER
:
261 Status
= PdoSetPower(DeviceObject
, Irp
, IrpSp
);
265 DPRINT("Unknown IOCTL 0x%X\n", IrpSp
->MinorFunction
);
266 Status
= STATUS_NOT_IMPLEMENTED
;
270 if (Status
!= STATUS_PENDING
) {
271 Irp
->IoStatus
.Status
= Status
;
272 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
275 DPRINT("Leaving. Status 0x%X\n", Status
);