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>
36 typedef struct _DEVICE_NODE
38 struct _DEVICE_NODE *Parent;
39 struct _DEVICE_NODE *PrevSibling;
40 struct _DEVICE_NODE *NextSibling;
41 struct _DEVICE_NODE *Child;
42 PDRIVER_OBJECT DriverObject;
44 UNICODE_STRING InstancePath;
45 UNICODE_STRING ServiceName;
46 //TargetDeviceNotifyList?
47 PDEVICE_CAPABILITIES CapabilityFlags;
50 ULONG DisableableDepends;
52 PCM_RESOURCE_LIST CmResourceList;
53 PCM_RESOURCE_LIST BootResourcesList;
54 PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirementsList;
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;
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 // ???
99 /* For UserFlags field */
100 #define DNUF_DONT_SHOW_IN_UI 0x0002
101 #define DNUF_NOT_DISABLEABLE 0x0008
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
116 * IopDeviceNodeSetFlag(
117 * PDEVICE_NODE DeviceNode,
120 #define IopDeviceNodeSetFlag(DeviceNode, Flag)((DeviceNode)->Flags |= (Flag))
124 * IopDeviceNodeClearFlag(
125 * PDEVICE_NODE DeviceNode,
128 #define IopDeviceNodeClearFlag(DeviceNode, Flag)((DeviceNode)->Flags &= ~(Flag))
132 * IopDeviceNodeHasFlag(
133 * PDEVICE_NODE DeviceNode,
136 #define IopDeviceNodeHasFlag(DeviceNode, Flag)(((DeviceNode)->Flags & (Flag)) > 0)
140 * IopDeviceNodeSetUserFlag(
141 * PDEVICE_NODE DeviceNode,
144 #define IopDeviceNodeSetUserFlag(DeviceNode, UserFlag)((DeviceNode)->UserFlags |= (UserFlag))
148 * IopDeviceNodeClearUserFlag(
149 * PDEVICE_NODE DeviceNode,
152 #define IopDeviceNodeClearUserFlag(DeviceNode, UserFlag)((DeviceNode)->UserFlags &= ~(UserFlag))
156 * IopDeviceNodeHasUserFlag(
157 * PDEVICE_NODE DeviceNode,
160 #define IopDeviceNodeHasUserFlag(DeviceNode, UserFlag)(((DeviceNode)->UserFlags & (UserFlag)) > 0)
164 * IopDeviceNodeSetProblem(
165 * PDEVICE_NODE DeviceNode,
168 #define IopDeviceNodeSetProblem(DeviceNode, Problem)((DeviceNode)->Problem |= (Problem))
172 * IopDeviceNodeClearProblem(
173 * PDEVICE_NODE DeviceNode,
176 #define IopDeviceNodeClearProblem(DeviceNode, Problem)((DeviceNode)->Problem &= ~(Problem))
180 * IopDeviceNodeHasProblem(
181 * PDEVICE_NODE DeviceNode,
184 #define IopDeviceNodeHasProblem(DeviceNode, Problem)(((DeviceNode)->Problem & (Problem)) > 0)
188 Called on every visit of a node during a preorder-traversal of the device
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
197 typedef NTSTATUS (*DEVICETREE_TRAVERSE_ROUTINE)(
198 PDEVICE_NODE DeviceNode,
201 /* Context information for traversing the device tree */
202 typedef struct _DEVICETREE_TRAVERSE_CONTEXT
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 */
212 } DEVICETREE_TRAVERSE_CONTEXT, *PDEVICETREE_TRAVERSE_CONTEXT;
216 * IopInitDeviceTreeTraverseContext(
217 * PDEVICETREE_TRAVERSE_CONTEXT DeviceTreeTraverseContext,
218 * PDEVICE_NODE DeviceNode,
219 * DEVICETREE_TRAVERSE_ROUTINE Action,
222 #define IopInitDeviceTreeTraverseContext( \
223 _DeviceTreeTraverseContext, _DeviceNode, _Action, _Context) { \
224 (_DeviceTreeTraverseContext)->FirstDeviceNode = (_DeviceNode); \
225 (_DeviceTreeTraverseContext)->Action = (_Action); \
226 (_DeviceTreeTraverseContext)->Context = (_Context); }
229 extern PDEVICE_NODE IopRootDeviceNode;
235 IopInitDriverImplementation(VOID);
238 IopGetSystemPowerDeviceObject(PDEVICE_OBJECT *DeviceObject);
240 IopCreateDeviceNode(PDEVICE_NODE ParentNode,
241 PDEVICE_OBJECT PhysicalDeviceObject,
242 PDEVICE_NODE *DeviceNode);
244 IopFreeDeviceNode(PDEVICE_NODE DeviceNode);
246 IopInterrogateBusExtender(PDEVICE_NODE DeviceNode,
248 BOOLEAN BootDriversOnly);
250 IopLoadBootStartDrivers(VOID);
252 IopCreateDriverObject(PDRIVER_OBJECT *DriverObject,
253 PUNICODE_STRING ServiceName,
254 BOOLEAN FileSystemDriver);
256 IopInitializeDeviceNodeService(PDEVICE_NODE DeviceNode);
258 IopInitializeDriver(PDRIVER_INITIALIZE DriverEntry,
259 PDEVICE_NODE DeviceNode,
260 BOOLEAN FileSystemDriver);
262 IoInitCancelHandling(VOID);
264 IoInitFileSystemImplementation(VOID);
266 IoInitVpbImplementation(VOID);
269 IoMountVolume(IN PDEVICE_OBJECT DeviceObject,
270 IN BOOLEAN AllowRawMount);
271 POBJECT IoOpenSymlink(POBJECT SymbolicLink);
272 POBJECT IoOpenFileOnDevice(POBJECT SymbolicLink, PWCHAR Name);
274 VOID IoSecondStageCompletion(PIRP Irp, CCHAR PriorityBoost);
277 IopCreateFile(PVOID ObjectBody,
280 POBJECT_ATTRIBUTES ObjectAttributes);
282 IopCreateDevice(PVOID ObjectBody,
285 POBJECT_ATTRIBUTES ObjectAttributes);
286 NTSTATUS IoAttachVpb(PDEVICE_OBJECT DeviceObject);
288 PIRP IoBuildSynchronousFsdRequestWithMdl(ULONG MajorFunction,
289 PDEVICE_OBJECT DeviceObject,
291 PLARGE_INTEGER StartingOffset,
293 PIO_STATUS_BLOCK IoStatusBlock,
296 VOID IoInitShutdownNotification(VOID);
297 VOID IoShutdownRegisteredDevices(VOID);
298 VOID IoShutdownRegisteredFileSystems(VOID);
301 IoPageWrite(PFILE_OBJECT FileObject,
303 PLARGE_INTEGER Offset,
305 PIO_STATUS_BLOCK StatusBlock);
308 IoCreateArcNames(VOID);
311 IoCreateSystemRootLink(PCHAR ParameterLine);
315 PDEVICE_OBJECT DeviceObject,
316 PIO_STATUS_BLOCK IoStatusBlock,
318 PIO_STACK_LOCATION Stack);
321 IopCreateUnicodeString(
322 PUNICODE_STRING Destination,
328 IoCreateDriverList(VOID);
331 IoDestroyDriverList(VOID);
339 IN PDRIVER_OBJECT DriverObject,
340 IN PUNICODE_STRING RegistryPath);
344 PDEVICE_OBJECT *PhysicalDeviceObject);