3 * Copyright (C) 2000 David Welch <welch@cwcom.net>
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.
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.
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.
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)
30 #ifndef __NTOSKRNL_INCLUDE_INTERNAL_IO_H
31 #define __NTOSKRNL_INCLUDE_INTERNAL_IO_H
33 #include <ddk/ntddk.h>
34 #include <internal/ob.h>
38 #define DEVICE_TYPE_FROM_CTL_CODE(ctlCode) (((ULONG)(ctlCode&0xffff0000))>>16)
41 #define IO_METHOD_FROM_CTL_CODE(ctlCode) (ctlCode&0x00000003)
44 typedef struct _IO_COMPLETION_PACKET{
47 IO_STATUS_BLOCK IoStatus;
49 } IO_COMPLETION_PACKET, *PIO_COMPLETION_PACKET;
52 typedef struct _DEVICE_NODE
54 struct _DEVICE_NODE *Parent;
55 struct _DEVICE_NODE *PrevSibling;
56 struct _DEVICE_NODE *NextSibling;
57 struct _DEVICE_NODE *Child;
58 PDRIVER_OBJECT DriverObject;
60 UNICODE_STRING InstancePath;
61 UNICODE_STRING ServiceName;
62 //TargetDeviceNotifyList?
63 PDEVICE_CAPABILITIES CapabilityFlags;
66 ULONG DisableableDepends;
68 PCM_RESOURCE_LIST CmResourceList;
69 PCM_RESOURCE_LIST BootResourcesList;
70 PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirementsList;
72 UNICODE_STRING DeviceID;
73 UNICODE_STRING InstanceID;
74 UNICODE_STRING HardwareIDs;
75 UNICODE_STRING CompatibleIDs;
76 UNICODE_STRING DeviceText;
77 UNICODE_STRING DeviceTextLocation;
78 PPNP_BUS_INFORMATION BusInformation;
79 } DEVICE_NODE, *PDEVICE_NODE;
82 #define DNF_PROCESSED 0x00000001
83 #define DNF_STARTED 0x00000002
84 #define DNF_START_FAILED 0x00000004
85 #define DNF_ENUMERATED 0x00000008
86 #define DNF_DELETED 0x00000010
87 #define DNF_MADEUP 0x00000020
88 #define DNF_START_REQUEST_PENDING 0x00000040
89 #define DNF_NO_RESOURCE_REQUIRED 0x00000080
90 #define DNF_INSUFFICIENT_RESOURCES 0x00000100
91 #define DNF_RESOURCE_ASSIGNED 0x00000200
92 #define DNF_RESOURCE_REPORTED 0x00000400
93 #define DNF_HAL_NODE 0x00000800 // ???
94 #define DNF_ADDED 0x00001000
95 #define DNF_ADD_FAILED 0x00002000
96 #define DNF_LEGACY_DRIVER 0x00004000
97 #define DNF_STOPPED 0x00008000
98 #define DNF_WILL_BE_REMOVED 0x00010000
99 #define DNF_NEED_TO_ENUM 0x00020000
100 #define DNF_NOT_CONFIGURED 0x00040000
101 #define DNF_REINSTALL 0x00080000
102 #define DNF_RESOURCE_REQUIREMENTS_NEED_FILTERED 0x00100000 // ???
103 #define DNF_DISABLED 0x00200000
104 #define DNF_RESTART_OK 0x00400000
105 #define DNF_NEED_RESTART 0x00800000
106 #define DNF_VISITED 0x01000000
107 #define DNF_ASSIGNING_RESOURCES 0x02000000
108 #define DNF_BEEING_ENUMERATED 0x04000000
109 #define DNF_NEED_ENUMERATION_ONLY 0x08000000
110 #define DNF_LOCKED 0x10000000
111 #define DNF_HAS_BOOT_CONFIG 0x20000000
112 #define DNF_BOOT_CONFIG_RESERVED 0x40000000
113 #define DNF_HAS_PROBLEM 0x80000000 // ???
115 /* For UserFlags field */
116 #define DNUF_DONT_SHOW_IN_UI 0x0002
117 #define DNUF_NOT_DISABLEABLE 0x0008
119 /* For Problem field */
120 #define CM_PROB_NOT_CONFIGURED 1
121 #define CM_PROB_FAILED_START 10
122 #define CM_PROB_NORMAL_CONFLICT 12
123 #define CM_PROB_NEED_RESTART 14
124 #define CM_PROB_REINSTALL 18
125 #define CM_PROB_WILL_BE_REMOVED 21
126 #define CM_PROB_DISABLED 22
127 #define CM_PROB_FAILED_INSTALL 28
128 #define CM_PROB_FAILED_ADD 31
132 * IopDeviceNodeSetFlag(
133 * PDEVICE_NODE DeviceNode,
136 #define IopDeviceNodeSetFlag(DeviceNode, Flag)((DeviceNode)->Flags |= (Flag))
140 * IopDeviceNodeClearFlag(
141 * PDEVICE_NODE DeviceNode,
144 #define IopDeviceNodeClearFlag(DeviceNode, Flag)((DeviceNode)->Flags &= ~(Flag))
148 * IopDeviceNodeHasFlag(
149 * PDEVICE_NODE DeviceNode,
152 #define IopDeviceNodeHasFlag(DeviceNode, Flag)(((DeviceNode)->Flags & (Flag)) > 0)
156 * IopDeviceNodeSetUserFlag(
157 * PDEVICE_NODE DeviceNode,
160 #define IopDeviceNodeSetUserFlag(DeviceNode, UserFlag)((DeviceNode)->UserFlags |= (UserFlag))
164 * IopDeviceNodeClearUserFlag(
165 * PDEVICE_NODE DeviceNode,
168 #define IopDeviceNodeClearUserFlag(DeviceNode, UserFlag)((DeviceNode)->UserFlags &= ~(UserFlag))
172 * IopDeviceNodeHasUserFlag(
173 * PDEVICE_NODE DeviceNode,
176 #define IopDeviceNodeHasUserFlag(DeviceNode, UserFlag)(((DeviceNode)->UserFlags & (UserFlag)) > 0)
180 * IopDeviceNodeSetProblem(
181 * PDEVICE_NODE DeviceNode,
184 #define IopDeviceNodeSetProblem(DeviceNode, Problem)((DeviceNode)->Problem |= (Problem))
188 * IopDeviceNodeClearProblem(
189 * PDEVICE_NODE DeviceNode,
192 #define IopDeviceNodeClearProblem(DeviceNode, Problem)((DeviceNode)->Problem &= ~(Problem))
196 * IopDeviceNodeHasProblem(
197 * PDEVICE_NODE DeviceNode,
200 #define IopDeviceNodeHasProblem(DeviceNode, Problem)(((DeviceNode)->Problem & (Problem)) > 0)
204 Called on every visit of a node during a preorder-traversal of the device
206 If the routine returns STATUS_UNSUCCESSFUL the traversal will stop and
207 STATUS_SUCCESS is returned to the caller who initiated the tree traversal.
208 Any other returned status code will be returned to the caller. If a status
209 code that indicates an error (other than STATUS_UNSUCCESSFUL) is returned,
210 the traversal is stopped immediately and the status code is returned to
213 typedef NTSTATUS (*DEVICETREE_TRAVERSE_ROUTINE)(
214 PDEVICE_NODE DeviceNode,
217 /* Context information for traversing the device tree */
218 typedef struct _DEVICETREE_TRAVERSE_CONTEXT
220 /* Current device node during a traversal */
221 PDEVICE_NODE DeviceNode;
222 /* Initial device node where we start the traversal */
223 PDEVICE_NODE FirstDeviceNode;
224 /* Action routine to be called for every device node */
225 DEVICETREE_TRAVERSE_ROUTINE Action;
226 /* Context passed to the action routine */
228 } DEVICETREE_TRAVERSE_CONTEXT, *PDEVICETREE_TRAVERSE_CONTEXT;
232 * IopInitDeviceTreeTraverseContext(
233 * PDEVICETREE_TRAVERSE_CONTEXT DeviceTreeTraverseContext,
234 * PDEVICE_NODE DeviceNode,
235 * DEVICETREE_TRAVERSE_ROUTINE Action,
238 #define IopInitDeviceTreeTraverseContext( \
239 _DeviceTreeTraverseContext, _DeviceNode, _Action, _Context) { \
240 (_DeviceTreeTraverseContext)->FirstDeviceNode = (_DeviceNode); \
241 (_DeviceTreeTraverseContext)->Action = (_Action); \
242 (_DeviceTreeTraverseContext)->Context = (_Context); }
245 extern PDEVICE_NODE IopRootDeviceNode;
251 IopInitDriverImplementation(VOID);
254 IopGetSystemPowerDeviceObject(PDEVICE_OBJECT *DeviceObject);
256 IopCreateDeviceNode(PDEVICE_NODE ParentNode,
257 PDEVICE_OBJECT PhysicalDeviceObject,
258 PDEVICE_NODE *DeviceNode);
260 IopFreeDeviceNode(PDEVICE_NODE DeviceNode);
262 IopInterrogateBusExtender(PDEVICE_NODE DeviceNode,
264 BOOLEAN BootDriversOnly);
266 IopLoadBootStartDrivers(VOID);
268 IopCreateDriverObject(PDRIVER_OBJECT *DriverObject,
269 PUNICODE_STRING ServiceName,
270 BOOLEAN FileSystemDriver,
271 PVOID DriverImageStart,
272 ULONG DriverImageSize);
274 IopInitializeDeviceNodeService(PDEVICE_NODE DeviceNode);
276 IopInitializeDriver(PDRIVER_INITIALIZE DriverEntry,
277 PDEVICE_NODE DeviceNode,
278 BOOLEAN FileSystemDriver,
279 PVOID DriverImageStart,
280 ULONG DriverImageSize);
282 IoInitCancelHandling(VOID);
284 IoInitFileSystemImplementation(VOID);
286 IoInitVpbImplementation(VOID);
289 IoMountVolume(IN PDEVICE_OBJECT DeviceObject,
290 IN BOOLEAN AllowRawMount);
291 POBJECT IoOpenSymlink(POBJECT SymbolicLink);
292 POBJECT IoOpenFileOnDevice(POBJECT SymbolicLink, PWCHAR Name);
295 IoSecondStageCompletion(
297 PKNORMAL_ROUTINE* NormalRoutine,
298 PVOID* NormalContext,
299 PVOID* SystemArgument1,
300 PVOID* SystemArgument2);
303 IopCreateFile(PVOID ObjectBody,
306 POBJECT_ATTRIBUTES ObjectAttributes);
308 IopCreateDevice(PVOID ObjectBody,
311 POBJECT_ATTRIBUTES ObjectAttributes);
312 NTSTATUS IoAttachVpb(PDEVICE_OBJECT DeviceObject);
314 PIRP IoBuildSynchronousFsdRequestWithMdl(ULONG MajorFunction,
315 PDEVICE_OBJECT DeviceObject,
317 PLARGE_INTEGER StartingOffset,
319 PIO_STATUS_BLOCK IoStatusBlock,
322 VOID IoInitShutdownNotification(VOID);
323 VOID IoShutdownRegisteredDevices(VOID);
324 VOID IoShutdownRegisteredFileSystems(VOID);
327 IoPageWrite(PFILE_OBJECT FileObject,
329 PLARGE_INTEGER Offset,
331 PIO_STATUS_BLOCK StatusBlock);
334 IoCreateArcNames(VOID);
337 IoCreateSystemRootLink(PCHAR ParameterLine);
341 PDEVICE_OBJECT DeviceObject,
342 PIO_STATUS_BLOCK IoStatusBlock,
344 PIO_STACK_LOCATION Stack);
347 IopCreateUnicodeString(
348 PUNICODE_STRING Destination,
354 IoCreateDriverList(VOID);
357 IoDestroyDriverList(VOID);
363 IopInitErrorLog (VOID);
369 RawFsIsRawFileSystemDeviceObject(IN PDEVICE_OBJECT DeviceObject);
372 RawFsDriverEntry(PDRIVER_OBJECT DriverObject,
373 PUNICODE_STRING RegistryPath);
381 IN PDRIVER_OBJECT DriverObject,
382 IN PUNICODE_STRING RegistryPath);
386 PDEVICE_OBJECT *PhysicalDeviceObject);