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.43 2004/05/02 19:33:29 ekohl 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>
35 #include <internal/module.h>
39 #define DEVICE_TYPE_FROM_CTL_CODE(ctlCode) (((ULONG)(ctlCode&0xffff0000))>>16)
42 #define IO_METHOD_FROM_CTL_CODE(ctlCode) (ctlCode&0x00000003)
45 typedef struct _IO_COMPLETION_PACKET
{
48 IO_STATUS_BLOCK IoStatus
;
50 } IO_COMPLETION_PACKET
, *PIO_COMPLETION_PACKET
;
52 typedef struct _DEVOBJ_EXTENSION
{
55 PDEVICE_OBJECT DeviceObject
;
57 struct _DEVICE_NODE
*DeviceNode
;
58 } DEVOBJ_EXTENSION
, *PDEVOBJ_EXTENSION
;
60 typedef struct _PRIVATE_DRIVER_EXTENSIONS
{
61 struct _PRIVATE_DRIVER_EXTENSIONS
*Link
;
62 PVOID ClientIdentificationAddress
;
64 } PRIVATE_DRIVER_EXTENSIONS
, *PPRIVATE_DRIVER_EXTENSIONS
;
66 typedef struct _DEVICE_NODE
68 struct _DEVICE_NODE
*Parent
;
69 struct _DEVICE_NODE
*PrevSibling
;
70 struct _DEVICE_NODE
*NextSibling
;
71 struct _DEVICE_NODE
*Child
;
73 UNICODE_STRING InstancePath
;
74 UNICODE_STRING ServiceName
;
75 //TargetDeviceNotifyList?
76 PDEVICE_CAPABILITIES CapabilityFlags
;
79 ULONG DisableableDepends
;
81 PCM_RESOURCE_LIST CmResourceList
;
82 PCM_RESOURCE_LIST BootResourcesList
;
83 PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirementsList
;
85 UNICODE_STRING DeviceID
;
86 UNICODE_STRING InstanceID
;
87 UNICODE_STRING HardwareIDs
;
88 UNICODE_STRING CompatibleIDs
;
89 UNICODE_STRING DeviceText
;
90 UNICODE_STRING DeviceTextLocation
;
91 PPNP_BUS_INFORMATION BusInformation
;
92 } DEVICE_NODE
, *PDEVICE_NODE
;
95 #define DNF_PROCESSED 0x00000001
96 #define DNF_STARTED 0x00000002
97 #define DNF_START_FAILED 0x00000004
98 #define DNF_ENUMERATED 0x00000008
99 #define DNF_DELETED 0x00000010
100 #define DNF_MADEUP 0x00000020
101 #define DNF_START_REQUEST_PENDING 0x00000040
102 #define DNF_NO_RESOURCE_REQUIRED 0x00000080
103 #define DNF_INSUFFICIENT_RESOURCES 0x00000100
104 #define DNF_RESOURCE_ASSIGNED 0x00000200
105 #define DNF_RESOURCE_REPORTED 0x00000400
106 #define DNF_HAL_NODE 0x00000800 // ???
107 #define DNF_ADDED 0x00001000
108 #define DNF_ADD_FAILED 0x00002000
109 #define DNF_LEGACY_DRIVER 0x00004000
110 #define DNF_STOPPED 0x00008000
111 #define DNF_WILL_BE_REMOVED 0x00010000
112 #define DNF_NEED_TO_ENUM 0x00020000
113 #define DNF_NOT_CONFIGURED 0x00040000
114 #define DNF_REINSTALL 0x00080000
115 #define DNF_RESOURCE_REQUIREMENTS_NEED_FILTERED 0x00100000 // ???
116 #define DNF_DISABLED 0x00200000
117 #define DNF_RESTART_OK 0x00400000
118 #define DNF_NEED_RESTART 0x00800000
119 #define DNF_VISITED 0x01000000
120 #define DNF_ASSIGNING_RESOURCES 0x02000000
121 #define DNF_BEEING_ENUMERATED 0x04000000
122 #define DNF_NEED_ENUMERATION_ONLY 0x08000000
123 #define DNF_LOCKED 0x10000000
124 #define DNF_HAS_BOOT_CONFIG 0x20000000
125 #define DNF_BOOT_CONFIG_RESERVED 0x40000000
126 #define DNF_HAS_PROBLEM 0x80000000 // ???
128 /* For UserFlags field */
129 #define DNUF_DONT_SHOW_IN_UI 0x0002
130 #define DNUF_NOT_DISABLEABLE 0x0008
132 /* For Problem field */
133 #define CM_PROB_NOT_CONFIGURED 1
134 #define CM_PROB_FAILED_START 10
135 #define CM_PROB_NORMAL_CONFLICT 12
136 #define CM_PROB_NEED_RESTART 14
137 #define CM_PROB_REINSTALL 18
138 #define CM_PROB_WILL_BE_REMOVED 21
139 #define CM_PROB_DISABLED 22
140 #define CM_PROB_FAILED_INSTALL 28
141 #define CM_PROB_FAILED_ADD 31
145 * IopDeviceNodeSetFlag(
146 * PDEVICE_NODE DeviceNode,
149 #define IopDeviceNodeSetFlag(DeviceNode, Flag)((DeviceNode)->Flags |= (Flag))
153 * IopDeviceNodeClearFlag(
154 * PDEVICE_NODE DeviceNode,
157 #define IopDeviceNodeClearFlag(DeviceNode, Flag)((DeviceNode)->Flags &= ~(Flag))
161 * IopDeviceNodeHasFlag(
162 * PDEVICE_NODE DeviceNode,
165 #define IopDeviceNodeHasFlag(DeviceNode, Flag)(((DeviceNode)->Flags & (Flag)) > 0)
169 * IopDeviceNodeSetUserFlag(
170 * PDEVICE_NODE DeviceNode,
173 #define IopDeviceNodeSetUserFlag(DeviceNode, UserFlag)((DeviceNode)->UserFlags |= (UserFlag))
177 * IopDeviceNodeClearUserFlag(
178 * PDEVICE_NODE DeviceNode,
181 #define IopDeviceNodeClearUserFlag(DeviceNode, UserFlag)((DeviceNode)->UserFlags &= ~(UserFlag))
185 * IopDeviceNodeHasUserFlag(
186 * PDEVICE_NODE DeviceNode,
189 #define IopDeviceNodeHasUserFlag(DeviceNode, UserFlag)(((DeviceNode)->UserFlags & (UserFlag)) > 0)
193 * IopDeviceNodeSetProblem(
194 * PDEVICE_NODE DeviceNode,
197 #define IopDeviceNodeSetProblem(DeviceNode, Problem)((DeviceNode)->Problem |= (Problem))
201 * IopDeviceNodeClearProblem(
202 * PDEVICE_NODE DeviceNode,
205 #define IopDeviceNodeClearProblem(DeviceNode, Problem)((DeviceNode)->Problem &= ~(Problem))
209 * IopDeviceNodeHasProblem(
210 * PDEVICE_NODE DeviceNode,
213 #define IopDeviceNodeHasProblem(DeviceNode, Problem)(((DeviceNode)->Problem & (Problem)) > 0)
217 Called on every visit of a node during a preorder-traversal of the device
219 If the routine returns STATUS_UNSUCCESSFUL the traversal will stop and
220 STATUS_SUCCESS is returned to the caller who initiated the tree traversal.
221 Any other returned status code will be returned to the caller. If a status
222 code that indicates an error (other than STATUS_UNSUCCESSFUL) is returned,
223 the traversal is stopped immediately and the status code is returned to
226 typedef NTSTATUS (*DEVICETREE_TRAVERSE_ROUTINE
)(
227 PDEVICE_NODE DeviceNode
,
230 /* Context information for traversing the device tree */
231 typedef struct _DEVICETREE_TRAVERSE_CONTEXT
233 /* Current device node during a traversal */
234 PDEVICE_NODE DeviceNode
;
235 /* Initial device node where we start the traversal */
236 PDEVICE_NODE FirstDeviceNode
;
237 /* Action routine to be called for every device node */
238 DEVICETREE_TRAVERSE_ROUTINE Action
;
239 /* Context passed to the action routine */
241 } DEVICETREE_TRAVERSE_CONTEXT
, *PDEVICETREE_TRAVERSE_CONTEXT
;
245 * IopInitDeviceTreeTraverseContext(
246 * PDEVICETREE_TRAVERSE_CONTEXT DeviceTreeTraverseContext,
247 * PDEVICE_NODE DeviceNode,
248 * DEVICETREE_TRAVERSE_ROUTINE Action,
251 #define IopInitDeviceTreeTraverseContext( \
252 _DeviceTreeTraverseContext, _DeviceNode, _Action, _Context) { \
253 (_DeviceTreeTraverseContext)->FirstDeviceNode = (_DeviceNode); \
254 (_DeviceTreeTraverseContext)->Action = (_Action); \
255 (_DeviceTreeTraverseContext)->Context = (_Context); }
258 extern PDEVICE_NODE IopRootDeviceNode
;
259 extern ULONG IoOtherOperationCount
;
260 extern ULONGLONG IoOtherTransferCount
;
266 IopInitDriverImplementation(VOID
);
269 IopGetSystemPowerDeviceObject(PDEVICE_OBJECT
*DeviceObject
);
271 IopCreateDeviceNode(PDEVICE_NODE ParentNode
,
272 PDEVICE_OBJECT PhysicalDeviceObject
,
273 PDEVICE_NODE
*DeviceNode
);
275 IopFreeDeviceNode(PDEVICE_NODE DeviceNode
);
278 IoInitCancelHandling(VOID
);
280 IoInitFileSystemImplementation(VOID
);
282 IoInitVpbImplementation(VOID
);
285 IoMountVolume(IN PDEVICE_OBJECT DeviceObject
,
286 IN BOOLEAN AllowRawMount
);
287 POBJECT
IoOpenSymlink(POBJECT SymbolicLink
);
288 POBJECT
IoOpenFileOnDevice(POBJECT SymbolicLink
, PWCHAR Name
);
291 IoSecondStageCompletion(
293 PKNORMAL_ROUTINE
* NormalRoutine
,
294 PVOID
* NormalContext
,
295 PVOID
* SystemArgument1
,
296 PVOID
* SystemArgument2
);
299 IopCreateFile(PVOID ObjectBody
,
302 POBJECT_ATTRIBUTES ObjectAttributes
);
304 IopCreateDevice(PVOID ObjectBody
,
307 POBJECT_ATTRIBUTES ObjectAttributes
);
308 NTSTATUS
IoAttachVpb(PDEVICE_OBJECT DeviceObject
);
310 PIRP
IoBuildSynchronousFsdRequestWithMdl(ULONG MajorFunction
,
311 PDEVICE_OBJECT DeviceObject
,
313 PLARGE_INTEGER StartingOffset
,
315 PIO_STATUS_BLOCK IoStatusBlock
,
318 VOID
IoInitShutdownNotification(VOID
);
319 VOID
IoShutdownRegisteredDevices(VOID
);
320 VOID
IoShutdownRegisteredFileSystems(VOID
);
323 IoPageWrite(PFILE_OBJECT FileObject
,
325 PLARGE_INTEGER Offset
,
327 PIO_STATUS_BLOCK StatusBlock
);
330 IoCreateArcNames(VOID
);
333 IoCreateSystemRootLink(PCHAR ParameterLine
);
337 PDEVICE_OBJECT DeviceObject
,
338 PIO_STATUS_BLOCK IoStatusBlock
,
340 PIO_STACK_LOCATION Stack
);
343 IopCreateUnicodeString(
344 PUNICODE_STRING Destination
,
350 IoCreateDriverList(VOID
);
353 IoDestroyDriverList(VOID
);
359 IopInitErrorLog (VOID
);
365 RawFsIsRawFileSystemDeviceObject(IN PDEVICE_OBJECT DeviceObject
);
368 RawFsDriverEntry(PDRIVER_OBJECT DriverObject
,
369 PUNICODE_STRING RegistryPath
);
377 IN PDRIVER_OBJECT DriverObject
,
378 IN PUNICODE_STRING RegistryPath
);
382 PDEVICE_OBJECT
*PhysicalDeviceObject
);
388 PDEVICE_NODE DeviceNode
,
389 PDRIVER_OBJECT DriverObject
);
394 IopInitializeBootDrivers(VOID
);
397 IopInitializeSystemDrivers(VOID
);
400 IopCreateDriverObject(
401 PDRIVER_OBJECT
*DriverObject
,
402 PUNICODE_STRING ServiceName
,
403 BOOLEAN FileSystemDriver
,
404 PVOID DriverImageStart
,
405 ULONG DriverImageSize
);
408 IopLoadServiceModule(
409 IN PUNICODE_STRING ServiceName
,
410 OUT PMODULE_OBJECT
*ModuleObject
);
413 IopInitializeDriverModule(
414 IN PDEVICE_NODE DeviceNode
,
415 IN PMODULE_OBJECT ModuleObject
,
416 IN BOOLEAN FileSystemDriver
,
417 OUT PDRIVER_OBJECT
*DriverObject
);
420 IopAttachFilterDrivers(
421 PDEVICE_NODE DeviceNode
,
425 IopMarkLastReinitializeDriver(VOID
);
428 IopReinitializeDrivers(VOID
);
433 IopInitializePnpServices(
434 IN PDEVICE_NODE DeviceNode
,
435 IN BOOLEAN BootDrivers
);
438 IopInvalidateDeviceRelations(
439 IN PDEVICE_NODE DeviceNode
,
440 IN DEVICE_RELATION_TYPE Type
);