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