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.
19 /* $Id: io.h,v 1.25 2002/09/08 10:23:21 chorns Exp $
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
;
231 extern POBJECT_TYPE IoSymbolicLinkType
;
237 IopInitDriverImplementation(VOID
);
240 IopGetSystemPowerDeviceObject(PDEVICE_OBJECT
*DeviceObject
);
242 IopCreateDeviceNode(PDEVICE_NODE ParentNode
,
243 PDEVICE_OBJECT PhysicalDeviceObject
,
244 PDEVICE_NODE
*DeviceNode
);
246 IopFreeDeviceNode(PDEVICE_NODE DeviceNode
);
248 IopInterrogateBusExtender(PDEVICE_NODE DeviceNode
,
250 BOOLEAN BootDriversOnly
);
252 IopLoadBootStartDrivers(VOID
);
254 IopCreateDriverObject(PDRIVER_OBJECT
*DriverObject
,
255 PUNICODE_STRING ServiceName
,
256 BOOLEAN FileSystemDriver
);
258 IopInitializeDeviceNodeService(PDEVICE_NODE DeviceNode
);
260 IopInitializeDriver(PDRIVER_INITIALIZE DriverEntry
,
261 PDEVICE_NODE DeviceNode
,
262 BOOLEAN FileSystemDriver
);
264 IoInitCancelHandling(VOID
);
266 IoInitSymbolicLinkImplementation(VOID
);
268 IoInitFileSystemImplementation(VOID
);
270 IoInitVpbImplementation (VOID
);
273 IoMountVolume(IN PDEVICE_OBJECT DeviceObject
,
274 IN BOOLEAN AllowRawMount
);
275 POBJECT
IoOpenSymlink(POBJECT SymbolicLink
);
276 POBJECT
IoOpenFileOnDevice(POBJECT SymbolicLink
, PWCHAR Name
);
278 VOID
IoSecondStageCompletion(PIRP Irp
, CCHAR PriorityBoost
);
281 IopCreateFile(PVOID ObjectBody
,
284 POBJECT_ATTRIBUTES ObjectAttributes
);
286 IopCreateDevice(PVOID ObjectBody
,
289 POBJECT_ATTRIBUTES ObjectAttributes
);
290 NTSTATUS
IoAttachVpb(PDEVICE_OBJECT DeviceObject
);
292 PIRP
IoBuildSynchronousFsdRequestWithMdl(ULONG MajorFunction
,
293 PDEVICE_OBJECT DeviceObject
,
295 PLARGE_INTEGER StartingOffset
,
297 PIO_STATUS_BLOCK IoStatusBlock
,
300 VOID
IoInitShutdownNotification(VOID
);
301 VOID
IoShutdownRegisteredDevices(VOID
);
302 VOID
IoShutdownRegisteredFileSystems(VOID
);
305 IoPageWrite(PFILE_OBJECT FileObject
,
307 PLARGE_INTEGER Offset
,
309 PIO_STATUS_BLOCK StatusBlock
);
312 IoCreateArcNames(VOID
);
315 IoCreateSystemRootLink(PCHAR ParameterLine
);
319 PDEVICE_OBJECT DeviceObject
,
320 PIO_STATUS_BLOCK IoStatusBlock
,
322 PIO_STACK_LOCATION Stack
);
325 IopCreateUnicodeString(
326 PUNICODE_STRING Destination
,
332 IoCreateDriverList(VOID
);
335 IoDestroyDriverList(VOID
);
343 IN PDRIVER_OBJECT DriverObject
,
344 IN PUNICODE_STRING RegistryPath
);
348 PDEVICE_OBJECT
*PhysicalDeviceObject
);