update for HEAD-2003050101
[reactos.git] / 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$
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 VOID
232 PnpInit(VOID);
233
234 VOID
235 IopInitDriverImplementation(VOID);
236
237 NTSTATUS
238 IopGetSystemPowerDeviceObject(PDEVICE_OBJECT *DeviceObject);
239 NTSTATUS
240 IopCreateDeviceNode(PDEVICE_NODE ParentNode,
241                     PDEVICE_OBJECT PhysicalDeviceObject,
242                     PDEVICE_NODE *DeviceNode);
243 NTSTATUS
244 IopFreeDeviceNode(PDEVICE_NODE DeviceNode);
245 NTSTATUS
246 IopInterrogateBusExtender(PDEVICE_NODE DeviceNode,
247                           PDEVICE_OBJECT Pdo,
248                           BOOLEAN BootDriversOnly);
249 VOID
250 IopLoadBootStartDrivers(VOID);
251 NTSTATUS
252 IopCreateDriverObject(PDRIVER_OBJECT *DriverObject,
253                       PUNICODE_STRING ServiceName,
254                       BOOLEAN FileSystemDriver);
255 NTSTATUS
256 IopInitializeDeviceNodeService(PDEVICE_NODE DeviceNode);
257 NTSTATUS
258 IopInitializeDriver(PDRIVER_INITIALIZE DriverEntry,
259                     PDEVICE_NODE DeviceNode,
260                     BOOLEAN FileSystemDriver);
261 VOID
262 IoInitCancelHandling(VOID);
263 VOID
264 IoInitFileSystemImplementation(VOID);
265 VOID
266 IoInitVpbImplementation(VOID);
267
268 NTSTATUS
269 IoMountVolume(IN PDEVICE_OBJECT DeviceObject,
270               IN BOOLEAN AllowRawMount);
271 POBJECT IoOpenSymlink(POBJECT SymbolicLink);
272 POBJECT IoOpenFileOnDevice(POBJECT SymbolicLink, PWCHAR Name);
273
274 VOID IoSecondStageCompletion(PIRP Irp, CCHAR PriorityBoost);
275
276 NTSTATUS STDCALL
277 IopCreateFile(PVOID ObjectBody,
278               PVOID Parent,
279               PWSTR RemainingPath,
280               POBJECT_ATTRIBUTES ObjectAttributes);
281 NTSTATUS STDCALL
282 IopCreateDevice(PVOID ObjectBody,
283                 PVOID Parent,
284                 PWSTR RemainingPath,
285                 POBJECT_ATTRIBUTES ObjectAttributes);
286 NTSTATUS IoAttachVpb(PDEVICE_OBJECT DeviceObject);
287
288 PIRP IoBuildSynchronousFsdRequestWithMdl(ULONG MajorFunction,
289                                          PDEVICE_OBJECT DeviceObject,
290                                          PMDL Mdl,
291                                          PLARGE_INTEGER StartingOffset,
292                                          PKEVENT Event,
293                                          PIO_STATUS_BLOCK IoStatusBlock,
294                                          ULONG PagingIo);
295
296 VOID IoInitShutdownNotification(VOID);
297 VOID IoShutdownRegisteredDevices(VOID);
298 VOID IoShutdownRegisteredFileSystems(VOID);
299
300 NTSTATUS STDCALL
301 IoPageWrite(PFILE_OBJECT        FileObject,
302             PMDL                Mdl,
303             PLARGE_INTEGER      Offset,
304             PKEVENT             Event,
305             PIO_STATUS_BLOCK    StatusBlock);
306
307 NTSTATUS
308 IoCreateArcNames(VOID);
309
310 NTSTATUS
311 IoCreateSystemRootLink(PCHAR ParameterLine);
312
313 NTSTATUS
314 IopInitiatePnpIrp(
315   PDEVICE_OBJECT DeviceObject,
316   PIO_STATUS_BLOCK IoStatusBlock,
317   ULONG MinorFunction,
318   PIO_STACK_LOCATION Stack);
319
320 BOOLEAN
321 IopCreateUnicodeString(
322   PUNICODE_STRING       Destination,
323   PWSTR Source,
324   POOL_TYPE PoolType);
325
326
327 NTSTATUS
328 IoCreateDriverList(VOID);
329
330 NTSTATUS
331 IoDestroyDriverList(VOID);
332
333
334 /* pnproot.c */
335
336 NTSTATUS
337 STDCALL
338 PnpRootDriverEntry(
339   IN PDRIVER_OBJECT DriverObject,
340   IN PUNICODE_STRING RegistryPath);
341
342 NTSTATUS
343 PnpRootCreateDevice(
344   PDEVICE_OBJECT *PhysicalDeviceObject);
345
346 #endif