Moved IoVerifyVolume().
[reactos.git] / reactos / ntoskrnl / include / internal / io.h
1 /*
2 * ReactOS kernel
3 * Copyright (C) 2000 David Welch <welch@cwcom.net>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 /* $Id: io.h,v 1.18 2002/04/10 09:58:02 ekohl Exp $
20 *
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS kernel
23 * FILE: include/internal/io.h
24 * PURPOSE: Internal io manager declarations
25 * PROGRAMMER: David Welch (welch@mcmail.com)
26 * UPDATE HISTORY:
27 * 28/05/97: Created
28 */
29
30 #ifndef __NTOSKRNL_INCLUDE_INTERNAL_IO_H
31 #define __NTOSKRNL_INCLUDE_INTERNAL_IO_H
32
33 #include <ddk/ntddk.h>
34 #include <internal/ob.h>
35
36 typedef struct _DEVICE_NODE
37 {
38 struct _DEVICE_NODE *Parent;
39 struct _DEVICE_NODE *PrevSibling;
40 struct _DEVICE_NODE *NextSibling;
41 struct _DEVICE_NODE *Child;
42 PDRIVER_OBJECT DriverObject;
43 PDEVICE_OBJECT Pdo;
44 UNICODE_STRING InstancePath;
45 UNICODE_STRING ServiceName;
46 //TargetDeviceNotifyList?
47 PDEVICE_CAPABILITIES CapabilityFlags;
48 ULONG Flags;
49 ULONG UserFlags;
50 ULONG DisableableDepends;
51 ULONG Problem;
52 PCM_RESOURCE_LIST CmResourceList;
53 PCM_RESOURCE_LIST BootResourcesList;
54 PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirementsList;
55 /* Not NT's */
56 UNICODE_STRING DeviceID;
57 UNICODE_STRING InstanceID;
58 UNICODE_STRING HardwareIDs;
59 UNICODE_STRING CompatibleIDs;
60 UNICODE_STRING DeviceText;
61 UNICODE_STRING DeviceTextLocation;
62 PPNP_BUS_INFORMATION BusInformation;
63 } DEVICE_NODE, *PDEVICE_NODE;
64
65 /* For Flags field */
66 #define DNF_PROCESSED 0x00000001
67 #define DNF_STARTED 0x00000002
68 #define DNF_START_FAILED 0x00000004
69 #define DNF_ENUMERATED 0x00000008
70 #define DNF_DELETED 0x00000010
71 #define DNF_MADEUP 0x00000020
72 #define DNF_START_REQUEST_PENDING 0x00000040
73 #define DNF_NO_RESOURCE_REQUIRED 0x00000080
74 #define DNF_INSUFFICIENT_RESOURCES 0x00000100
75 #define DNF_RESOURCE_ASSIGNED 0x00000200
76 #define DNF_RESOURCE_REPORTED 0x00000400
77 #define DNF_HAL_NODE 0x00000800 // ???
78 #define DNF_ADDED 0x00001000
79 #define DNF_ADD_FAILED 0x00002000
80 #define DNF_LEGACY_DRIVER 0x00004000
81 #define DNF_STOPPED 0x00008000
82 #define DNF_WILL_BE_REMOVED 0x00010000
83 #define DNF_NEED_TO_ENUM 0x00020000
84 #define DNF_NOT_CONFIGURED 0x00040000
85 #define DNF_REINSTALL 0x00080000
86 #define DNF_RESOURCE_REQUIREMENTS_NEED_FILTERED 0x00100000 // ???
87 #define DNF_DISABLED 0x00200000
88 #define DNF_RESTART_OK 0x00400000
89 #define DNF_NEED_RESTART 0x00800000
90 #define DNF_VISITED 0x01000000
91 #define DNF_ASSIGNING_RESOURCES 0x02000000
92 #define DNF_BEEING_ENUMERATED 0x04000000
93 #define DNF_NEED_ENUMERATION_ONLY 0x08000000
94 #define DNF_LOCKED 0x10000000
95 #define DNF_HAS_BOOT_CONFIG 0x20000000
96 #define DNF_BOOT_CONFIG_RESERVED 0x40000000
97 #define DNF_HAS_PROBLEM 0x80000000 // ???
98
99 /* For UserFlags field */
100 #define DNUF_DONT_SHOW_IN_UI 0x0002
101 #define DNUF_NOT_DISABLEABLE 0x0008
102
103 /* For Problem field */
104 #define CM_PROB_NOT_CONFIGURED 1
105 #define CM_PROB_FAILED_START 10
106 #define CM_PROB_NORMAL_CONFLICT 12
107 #define CM_PROB_NEED_RESTART 14
108 #define CM_PROB_REINSTALL 18
109 #define CM_PROB_WILL_BE_REMOVED 21
110 #define CM_PROB_DISABLED 22
111 #define CM_PROB_FAILED_INSTALL 28
112 #define CM_PROB_FAILED_ADD 31
113
114 /*
115 * VOID
116 * IopDeviceNodeSetFlag(
117 * PDEVICE_NODE DeviceNode,
118 * ULONG Flag);
119 */
120 #define IopDeviceNodeSetFlag(DeviceNode, Flag)((DeviceNode)->Flags |= (Flag))
121
122 /*
123 * VOID
124 * IopDeviceNodeClearFlag(
125 * PDEVICE_NODE DeviceNode,
126 * ULONG Flag);
127 */
128 #define IopDeviceNodeClearFlag(DeviceNode, Flag)((DeviceNode)->Flags &= ~(Flag))
129
130 /*
131 * BOOLEAN
132 * IopDeviceNodeHasFlag(
133 * PDEVICE_NODE DeviceNode,
134 * ULONG Flag);
135 */
136 #define IopDeviceNodeHasFlag(DeviceNode, Flag)(((DeviceNode)->Flags & (Flag)) > 0)
137
138 /*
139 * VOID
140 * IopDeviceNodeSetUserFlag(
141 * PDEVICE_NODE DeviceNode,
142 * ULONG UserFlag);
143 */
144 #define IopDeviceNodeSetUserFlag(DeviceNode, UserFlag)((DeviceNode)->UserFlags |= (UserFlag))
145
146 /*
147 * VOID
148 * IopDeviceNodeClearUserFlag(
149 * PDEVICE_NODE DeviceNode,
150 * ULONG UserFlag);
151 */
152 #define IopDeviceNodeClearUserFlag(DeviceNode, UserFlag)((DeviceNode)->UserFlags &= ~(UserFlag))
153
154 /*
155 * BOOLEAN
156 * IopDeviceNodeHasUserFlag(
157 * PDEVICE_NODE DeviceNode,
158 * ULONG UserFlag);
159 */
160 #define IopDeviceNodeHasUserFlag(DeviceNode, UserFlag)(((DeviceNode)->UserFlags & (UserFlag)) > 0)
161
162 /*
163 * VOID
164 * IopDeviceNodeSetProblem(
165 * PDEVICE_NODE DeviceNode,
166 * ULONG Problem);
167 */
168 #define IopDeviceNodeSetProblem(DeviceNode, Problem)((DeviceNode)->Problem |= (Problem))
169
170 /*
171 * VOID
172 * IopDeviceNodeClearProblem(
173 * PDEVICE_NODE DeviceNode,
174 * ULONG Problem);
175 */
176 #define IopDeviceNodeClearProblem(DeviceNode, Problem)((DeviceNode)->Problem &= ~(Problem))
177
178 /*
179 * BOOLEAN
180 * IopDeviceNodeHasProblem(
181 * PDEVICE_NODE DeviceNode,
182 * ULONG Problem);
183 */
184 #define IopDeviceNodeHasProblem(DeviceNode, Problem)(((DeviceNode)->Problem & (Problem)) > 0)
185
186
187 /*
188 Called on every visit of a node during a preorder-traversal of the device
189 node tree.
190 If the routine returns STATUS_UNSUCCESSFUL the traversal will stop and
191 STATUS_SUCCESS is returned to the caller who initiated the tree traversal.
192 Any other returned status code will be returned to the caller. If a status
193 code that indicates an error (other than STATUS_UNSUCCESSFUL) is returned,
194 the traversal is stopped immediately and the status code is returned to
195 the caller.
196 */
197 typedef NTSTATUS (*DEVICETREE_TRAVERSE_ROUTINE)(
198 PDEVICE_NODE DeviceNode,
199 PVOID Context);
200
201 /* Context information for traversing the device tree */
202 typedef struct _DEVICETREE_TRAVERSE_CONTEXT
203 {
204 /* Current device node during a traversal */
205 PDEVICE_NODE DeviceNode;
206 /* Initial device node where we start the traversal */
207 PDEVICE_NODE FirstDeviceNode;
208 /* Action routine to be called for every device node */
209 DEVICETREE_TRAVERSE_ROUTINE Action;
210 /* Context passed to the action routine */
211 PVOID Context;
212 } DEVICETREE_TRAVERSE_CONTEXT, *PDEVICETREE_TRAVERSE_CONTEXT;
213
214 /*
215 * VOID
216 * IopInitDeviceTreeTraverseContext(
217 * PDEVICETREE_TRAVERSE_CONTEXT DeviceTreeTraverseContext,
218 * PDEVICE_NODE DeviceNode,
219 * DEVICETREE_TRAVERSE_ROUTINE Action,
220 * PVOID Context);
221 */
222 #define IopInitDeviceTreeTraverseContext( \
223 _DeviceTreeTraverseContext, _DeviceNode, _Action, _Context) { \
224 (_DeviceTreeTraverseContext)->FirstDeviceNode = (_DeviceNode); \
225 (_DeviceTreeTraverseContext)->Action = (_Action); \
226 (_DeviceTreeTraverseContext)->Context = (_Context); }
227
228
229 extern PDEVICE_NODE IopRootDeviceNode;
230
231 extern POBJECT_TYPE IoSymbolicLinkType;
232
233 VOID
234 PnpInit(VOID);
235
236 NTSTATUS
237 IopGetSystemPowerDeviceObject(PDEVICE_OBJECT *DeviceObject);
238 NTSTATUS
239 IopCreateDeviceNode(PDEVICE_NODE ParentNode,
240 PDEVICE_OBJECT PhysicalDeviceObject,
241 PDEVICE_NODE *DeviceNode);
242 NTSTATUS
243 IopFreeDeviceNode(PDEVICE_NODE DeviceNode);
244 NTSTATUS
245 IopInterrogateBusExtender(PDEVICE_NODE DeviceNode,
246 PDEVICE_OBJECT Pdo,
247 BOOLEAN BootDriversOnly);
248 VOID
249 IopLoadBootStartDrivers(VOID);
250
251 NTSTATUS
252 IopCreateDriverObject(PDRIVER_OBJECT *DriverObject);
253 NTSTATUS
254 IopInitializeDeviceNodeService(PDEVICE_NODE DeviceNode);
255 NTSTATUS
256 IopInitializeDriver(PDRIVER_INITIALIZE DriverEntry,
257 PDEVICE_NODE DeviceNode);
258 VOID
259 IoInitCancelHandling(VOID);
260 VOID
261 IoInitSymbolicLinkImplementation(VOID);
262 VOID
263 IoInitFileSystemImplementation(VOID);
264 VOID
265 IoInitVpbImplementation (VOID);
266
267 NTSTATUS
268 IoTryToMountStorageDevice(IN PDEVICE_OBJECT DeviceObject,
269 IN BOOLEAN AllowRawMount);
270 POBJECT IoOpenSymlink(POBJECT SymbolicLink);
271 POBJECT IoOpenFileOnDevice(POBJECT SymbolicLink, PWCHAR Name);
272
273 PIRP IoBuildFilesystemControlRequest(ULONG MinorFunction,
274 PDEVICE_OBJECT DeviceObject,
275 PKEVENT UserEvent,
276 PIO_STATUS_BLOCK IoStatusBlock,
277 PDEVICE_OBJECT DeviceToMount);
278 VOID IoSecondStageCompletion(PIRP Irp, CCHAR PriorityBoost);
279
280 NTSTATUS STDCALL
281 IopCreateFile(PVOID ObjectBody,
282 PVOID Parent,
283 PWSTR RemainingPath,
284 POBJECT_ATTRIBUTES ObjectAttributes);
285 NTSTATUS STDCALL
286 IopCreateDevice(PVOID ObjectBody,
287 PVOID Parent,
288 PWSTR RemainingPath,
289 POBJECT_ATTRIBUTES ObjectAttributes);
290 NTSTATUS IoAttachVpb(PDEVICE_OBJECT DeviceObject);
291
292 PIRP IoBuildSynchronousFsdRequestWithMdl(ULONG MajorFunction,
293 PDEVICE_OBJECT DeviceObject,
294 PMDL Mdl,
295 PLARGE_INTEGER StartingOffset,
296 PKEVENT Event,
297 PIO_STATUS_BLOCK IoStatusBlock,
298 ULONG PagingIo);
299
300 VOID IoInitShutdownNotification(VOID);
301 VOID IoShutdownRegisteredDevices(VOID);
302 VOID IoShutdownRegisteredFileSystems(VOID);
303
304 NTSTATUS STDCALL
305 IoPageRead(PFILE_OBJECT FileObject,
306 PMDL Mdl,
307 PLARGE_INTEGER Offset,
308 PIO_STATUS_BLOCK StatusBlock,
309 BOOLEAN PagingIo);
310 NTSTATUS STDCALL
311 IoPageWrite(PFILE_OBJECT FileObject,
312 PMDL Mdl,
313 PLARGE_INTEGER Offset,
314 PIO_STATUS_BLOCK StatusBlock,
315 BOOLEAN PagingIo);
316
317 NTSTATUS
318 IoCreateArcNames(VOID);
319
320 NTSTATUS
321 IoCreateSystemRootLink(PCHAR ParameterLine);
322
323 NTSTATUS
324 IopInitiatePnpIrp(
325 PDEVICE_OBJECT DeviceObject,
326 PIO_STATUS_BLOCK IoStatusBlock,
327 ULONG MinorFunction,
328 PIO_STACK_LOCATION Stack);
329
330 BOOLEAN
331 IopCreateUnicodeString(
332 PUNICODE_STRING Destination,
333 PWSTR Source,
334 POOL_TYPE PoolType);
335
336
337 /* pnproot.c */
338
339 NTSTATUS
340 STDCALL
341 PnpRootDriverEntry(
342 IN PDRIVER_OBJECT DriverObject,
343 IN PUNICODE_STRING RegistryPath);
344
345 NTSTATUS
346 PnpRootCreateDevice(
347 PDEVICE_OBJECT *PhysicalDeviceObject);
348
349 #endif