1 /*
2 * PROJECT: ReactOS Floppy Disk Controller Driver
3 * LICENSE: GNU GPLv2 only as published by the Free Software Foundation
4 * FILE: drivers/storage/fdc/fdc/pdo.c
5 * PURPOSE: Physical Device Object routines
6 * PROGRAMMERS: Eric Kohl
7 */
8
9 /* INCLUDES *******************************************************************/
10
11 #include "fdc.h"
12
13 #define NDEBUG
14 #include <debug.h>
15
16 /* FUNCTIONS ******************************************************************/
17
18 static
19 NTSTATUS
FdcPdoQueryCapabilities(IN PDEVICE_OBJECT DeviceObject,PIO_STACK_LOCATION IrpSp)20 FdcPdoQueryCapabilities(
21 IN PDEVICE_OBJECT DeviceObject,
22 PIO_STACK_LOCATION IrpSp)
23 {
24 PPDO_DEVICE_EXTENSION DeviceExtension;
25 PDEVICE_CAPABILITIES DeviceCapabilities;
26
27 DPRINT("Called\n");
28
29 DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
30 DeviceCapabilities = IrpSp->Parameters.DeviceCapabilities.Capabilities;
31
32 if (DeviceCapabilities->Version != 1)
33 return STATUS_UNSUCCESSFUL;
34
35 DeviceCapabilities->UniqueID = FALSE;
36 DeviceCapabilities->Address = DeviceExtension->DriveInfo->PeripheralNumber;
37
38 return STATUS_SUCCESS;
39 }
40
41
42 static
43 NTSTATUS
FdcPdoQueryId(IN PDEVICE_OBJECT DeviceObject,IN PIO_STACK_LOCATION IrpSp,OUT ULONG_PTR * Information)44 FdcPdoQueryId(
45 IN PDEVICE_OBJECT DeviceObject,
46 IN PIO_STACK_LOCATION IrpSp,
47 OUT ULONG_PTR *Information)
48 {
49 PPDO_DEVICE_EXTENSION DeviceExtension;
50 PUNICODE_STRING SourceString;
51 UNICODE_STRING String;
52 NTSTATUS Status;
53
54 DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
55 RtlInitUnicodeString(&String, NULL);
56
57 switch (IrpSp->Parameters.QueryId.IdType)
58 {
59 case BusQueryDeviceID:
60 DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryDeviceID\n");
61 SourceString = &DeviceExtension->DeviceId;
62 break;
63
64 case BusQueryHardwareIDs:
65 DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryHardwareIDs\n");
66 SourceString = &DeviceExtension->HardwareIds;
67 break;
68
69 case BusQueryCompatibleIDs:
70 DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryCompatibleIDs\n");
71 SourceString = &DeviceExtension->CompatibleIds;
72 break;
73
74 case BusQueryInstanceID:
75 DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryInstanceID\n");
76 SourceString = &DeviceExtension->InstanceId;
77 break;
78
79 default:
80 DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_ID / unknown query id type 0x%lx\n",
81 IrpSp->Parameters.QueryId.IdType);
82 ASSERT(FALSE);
83 return STATUS_NOT_SUPPORTED;
84 }
85
86 Status = DuplicateUnicodeString(RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
87 SourceString,
88 &String);
89
90 *Information = (ULONG_PTR)String.Buffer;
91
92 return Status;
93 }
94
95
96 NTSTATUS
97 NTAPI
FdcPdoPnp(IN PDEVICE_OBJECT DeviceObject,IN PIRP Irp)98 FdcPdoPnp(
99 IN PDEVICE_OBJECT DeviceObject,
100 IN PIRP Irp)
101 {
102 PIO_STACK_LOCATION IrpSp;
103 ULONG_PTR Information = 0;
104 NTSTATUS Status;
105
106 DPRINT("FdcPdoPnp()\n");
107
108 Status = Irp->IoStatus.Status;
109
110 IrpSp = IoGetCurrentIrpStackLocation(Irp);
111
112 switch (IrpSp->MinorFunction)
113 {
114 case IRP_MN_DEVICE_USAGE_NOTIFICATION:
115 DPRINT1("Unimplemented IRP_MN_DEVICE_USAGE_NOTIFICATION received\n");
116 break;
117
118 case IRP_MN_EJECT:
119 DPRINT1("Unimplemented IRP_MN_EJECT received\n");
120 break;
121
122 case IRP_MN_QUERY_BUS_INFORMATION:
123 DPRINT("IRP_MN_QUERY_BUS_INFORMATION received\n");
124 break;
125
126 case IRP_MN_QUERY_CAPABILITIES:
127 DPRINT("IRP_MN_QUERY_CAPABILITIES received\n");
128 Status = FdcPdoQueryCapabilities(DeviceObject, IrpSp);
129 break;
130
131 case IRP_MN_QUERY_DEVICE_RELATIONS:
132 DPRINT("IRP_MN_QUERY_DEVICE_RELATIONS received\n");
133 break;
134
135 case IRP_MN_QUERY_DEVICE_TEXT:
136 DPRINT("IRP_MN_QUERY_DEVICE_TEXT received\n");
137 break;
138
139 case IRP_MN_QUERY_ID:
140 DPRINT("IRP_MN_QUERY_ID received\n");
141 Status = FdcPdoQueryId(DeviceObject, IrpSp, &Information);
142 break;
143
144 case IRP_MN_QUERY_PNP_DEVICE_STATE:
145 DPRINT1("Unimplemented IRP_MN_QUERY_ID received\n");
146 break;
147
148 case IRP_MN_QUERY_RESOURCE_REQUIREMENTS:
149 DPRINT("IRP_MN_QUERY_RESOURCE_REQUIREMENTS received\n");
150 break;
151
152 case IRP_MN_QUERY_RESOURCES:
153 DPRINT("IRP_MN_QUERY_RESOURCES received\n");
154 break;
155
156 case IRP_MN_SET_LOCK:
157 DPRINT1("Unimplemented IRP_MN_SET_LOCK received\n");
158 break;
159
160 case IRP_MN_START_DEVICE:
161 DPRINT("IRP_MN_START_DEVICE received\n");
162 break;
163
164 case IRP_MN_QUERY_STOP_DEVICE:
165 case IRP_MN_CANCEL_STOP_DEVICE:
166 case IRP_MN_STOP_DEVICE:
167 case IRP_MN_QUERY_REMOVE_DEVICE:
168 case IRP_MN_CANCEL_REMOVE_DEVICE:
169 case IRP_MN_SURPRISE_REMOVAL:
170 Status = STATUS_SUCCESS;
171 break;
172
173 case IRP_MN_REMOVE_DEVICE:
174 DPRINT("IRP_MN_REMOVE_DEVICE received\n");
175 break;
176
177 case IRP_MN_FILTER_RESOURCE_REQUIREMENTS:
178 DPRINT("IRP_MN_FILTER_RESOURCE_REQUIREMENTS received\n");
179 /* Nothing to do */
180 Irp->IoStatus.Status = Status;
181 break;
182
183 default:
184 DPRINT1("Unknown IOCTL 0x%lx\n", IrpSp->MinorFunction);
185 break;
186 }
187
188 Irp->IoStatus.Information = Information;
189 Irp->IoStatus.Status = Status;
190 IoCompleteRequest(Irp, IO_NO_INCREMENT);
191
192 DPRINT("Leaving. Status 0x%X\n", Status);
193
194 return Status;
195 }
196
197 /* EOF */
198