Relative include path fixed to absolute path.
[reactos.git] / reactos / drivers / bus / pci / pdo.c
1 /* $Id: pdo.c,v 1.1 2001/09/16 13:18:24 chorns Exp $
2 *
3 * PROJECT: ReactOS PCI bus driver
4 * FILE: pdo.c
5 * PURPOSE: Child device object dispatch routines
6 * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
7 * UPDATE HISTORY:
8 * 10-09-2001 CSH Created
9 */
10 #include <pci.h>
11
12 #define NDEBUG
13 #include <debug.h>
14
15 /*** PRIVATE *****************************************************************/
16
17 NTSTATUS
18 PdoQueryId(
19 IN PDEVICE_OBJECT DeviceObject,
20 IN PIRP Irp,
21 PIO_STACK_LOCATION IrpSp)
22 {
23 PPDO_DEVICE_EXTENSION DeviceExtension;
24 UNICODE_STRING String;
25 NTSTATUS Status;
26
27 DPRINT("Called\n");
28
29 DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
30
31 // Irp->IoStatus.Information = 0;
32
33 Status = STATUS_SUCCESS;
34
35 RtlInitUnicodeString(&String, NULL);
36
37 switch (IrpSp->Parameters.QueryId.IdType) {
38 case BusQueryDeviceID:
39 Status = PciCreateUnicodeString(
40 &String,
41 DeviceExtension->DeviceID.Buffer,
42 PagedPool);
43
44 DPRINT("DeviceID: %S\n", String.Buffer);
45
46 Irp->IoStatus.Information = (ULONG_PTR)String.Buffer;
47 break;
48
49 case BusQueryHardwareIDs:
50 case BusQueryCompatibleIDs:
51 Status = STATUS_NOT_IMPLEMENTED;
52 break;
53
54 case BusQueryInstanceID:
55 Status = PciCreateUnicodeString(
56 &String,
57 L"0000",
58 PagedPool);
59
60 DPRINT("InstanceID: %S\n", String.Buffer);
61
62 Irp->IoStatus.Information = (ULONG_PTR)String.Buffer;
63 break;
64
65 case BusQueryDeviceSerialNumber:
66 default:
67 Status = STATUS_NOT_IMPLEMENTED;
68 }
69
70 return Status;
71 }
72
73
74 NTSTATUS
75 PdoSetPower(
76 IN PDEVICE_OBJECT DeviceObject,
77 IN PIRP Irp,
78 PIO_STACK_LOCATION IrpSp)
79 {
80 PPDO_DEVICE_EXTENSION DeviceExtension;
81 NTSTATUS Status;
82
83 DPRINT("Called\n");
84
85 DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
86
87 if (IrpSp->Parameters.Power.Type == DevicePowerState) {
88 Status = STATUS_SUCCESS;
89 switch (IrpSp->Parameters.Power.State.SystemState) {
90 default:
91 Status = STATUS_UNSUCCESSFUL;
92 }
93 } else {
94 Status = STATUS_UNSUCCESSFUL;
95 }
96
97 return Status;
98 }
99
100
101 /*** PUBLIC ******************************************************************/
102
103 NTSTATUS
104 PdoPnpControl(
105 PDEVICE_OBJECT DeviceObject,
106 PIRP Irp)
107 /*
108 * FUNCTION: Handle Plug and Play IRPs for the child device
109 * ARGUMENTS:
110 * DeviceObject = Pointer to physical device object of the child device
111 * Irp = Pointer to IRP that should be handled
112 * RETURNS:
113 * Status
114 */
115 {
116 PIO_STACK_LOCATION IrpSp;
117 NTSTATUS Status;
118
119 DPRINT("Called\n");
120
121 Status = Irp->IoStatus.Status;
122
123 IrpSp = IoGetCurrentIrpStackLocation(Irp);
124
125 switch (IrpSp->MinorFunction) {
126 #if 0
127 case IRP_MN_CANCEL_REMOVE_DEVICE:
128 break;
129
130 case IRP_MN_CANCEL_STOP_DEVICE:
131 break;
132
133 case IRP_MN_DEVICE_USAGE_NOTIFICATION:
134 break;
135
136 case IRP_MN_EJECT:
137 break;
138
139 case IRP_MN_QUERY_BUS_INFORMATION:
140 break;
141
142 case IRP_MN_QUERY_CAPABILITIES:
143 break;
144
145 case IRP_MN_QUERY_DEVICE_RELATIONS:
146 /* FIXME: Possibly handle for RemovalRelations */
147 break;
148
149 case IRP_MN_QUERY_DEVICE_TEXT:
150 break;
151 #endif
152 case IRP_MN_QUERY_ID:
153 Status = PdoQueryId(DeviceObject, Irp, IrpSp);
154 break;
155 #if 0
156 case IRP_MN_QUERY_PNP_DEVICE_STATE:
157 break;
158
159 case IRP_MN_QUERY_REMOVE_DEVICE:
160 break;
161
162 case IRP_MN_QUERY_RESOURCE_REQUIREMENTS:
163 break;
164
165 case IRP_MN_QUERY_RESOURCES:
166 break;
167
168 case IRP_MN_QUERY_STOP_DEVICE:
169 break;
170
171 case IRP_MN_REMOVE_DEVICE:
172 break;
173
174 case IRP_MN_SET_LOCK:
175 break;
176
177 case IRP_MN_START_DEVICE:
178 break;
179
180 case IRP_MN_STOP_DEVICE:
181 break;
182
183 case IRP_MN_SURPRISE_REMOVAL:
184 break;
185 #endif
186 default:
187 DPRINT("Unknown IOCTL 0x%X\n", IrpSp->MinorFunction);
188 break;
189 }
190
191 if (Status != STATUS_PENDING) {
192 Irp->IoStatus.Status = Status;
193 IoCompleteRequest(Irp, IO_NO_INCREMENT);
194 }
195
196 DPRINT("Leaving. Status 0x%X\n", Status);
197
198 return Status;
199 }
200
201 NTSTATUS
202 PdoPowerControl(
203 PDEVICE_OBJECT DeviceObject,
204 PIRP Irp)
205 /*
206 * FUNCTION: Handle power management IRPs for the child device
207 * ARGUMENTS:
208 * DeviceObject = Pointer to physical device object of the child device
209 * Irp = Pointer to IRP that should be handled
210 * RETURNS:
211 * Status
212 */
213 {
214 PIO_STACK_LOCATION IrpSp;
215 NTSTATUS Status;
216
217 DPRINT("Called\n");
218
219 IrpSp = IoGetCurrentIrpStackLocation(Irp);
220
221 switch (IrpSp->MinorFunction) {
222 case IRP_MN_SET_POWER:
223 Status = PdoSetPower(DeviceObject, Irp, IrpSp);
224 break;
225
226 default:
227 DPRINT("Unknown IOCTL 0x%X\n", IrpSp->MinorFunction);
228 Status = STATUS_NOT_IMPLEMENTED;
229 break;
230 }
231
232 if (Status != STATUS_PENDING) {
233 Irp->IoStatus.Status = Status;
234 IoCompleteRequest(Irp, IO_NO_INCREMENT);
235 }
236
237 DPRINT("Leaving. Status 0x%X\n", Status);
238
239 return Status;
240 }
241
242 /* EOF */