Synchronize with trunk revision 59636 (just before Alex's CreateProcess revamp).
[reactos.git] / ntoskrnl / cc / mdl.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: ntoskrnl/cc/fs.c
5 * PURPOSE: Implements MDL Cache Manager Functions
6 *
7 * PROGRAMMERS: Alex Ionescu
8 */
9
10 /* INCLUDES ******************************************************************/
11
12 #include <ntoskrnl.h>
13 #define NDEBUG
14 #include <debug.h>
15
16 /* FUNCTIONS *****************************************************************/
17
18 /*
19 * @implemented
20 */
21 VOID
22 NTAPI
23 CcMdlRead (
24 IN PFILE_OBJECT FileObject,
25 IN PLARGE_INTEGER FileOffset,
26 IN ULONG Length,
27 OUT PMDL * MdlChain,
28 OUT PIO_STATUS_BLOCK IoStatus
29 )
30 {
31 UNIMPLEMENTED;
32 }
33
34 /*
35 * NAME INTERNAL
36 * CcMdlReadComplete2@8
37 *
38 * DESCRIPTION
39 *
40 * ARGUMENTS
41 * MdlChain
42 * DeviceObject
43 *
44 * RETURN VALUE
45 * None.
46 *
47 * NOTE
48 * Used by CcMdlReadComplete@8 and FsRtl
49 *
50 */
51 VOID
52 NTAPI
53 CcMdlReadComplete2 (
54 IN PFILE_OBJECT FileObject,
55 IN PMDL MemoryDescriptorList
56 )
57 {
58 PMDL Mdl;
59
60 /* Free MDLs */
61 while ((Mdl = MemoryDescriptorList))
62 {
63 MemoryDescriptorList = Mdl->Next;
64 MmUnlockPages(Mdl);
65 IoFreeMdl(Mdl);
66 }
67 }
68
69 /*
70 * NAME EXPORTED
71 * CcMdlReadComplete@8
72 *
73 * DESCRIPTION
74 *
75 * ARGUMENTS
76 *
77 * RETURN VALUE
78 * None.
79 *
80 * NOTE
81 * From Bo Branten's ntifs.h v13.
82 *
83 * @implemented
84 */
85 VOID
86 NTAPI
87 CcMdlReadComplete (
88 IN PFILE_OBJECT FileObject,
89 IN PMDL MdlChain)
90 {
91 PDEVICE_OBJECT DeviceObject = NULL;
92 PFAST_IO_DISPATCH FastDispatch;
93
94 /* Get Fast Dispatch Data */
95 DeviceObject = IoGetRelatedDeviceObject(FileObject);
96 FastDispatch = DeviceObject->DriverObject->FastIoDispatch;
97
98 /* Check if we support Fast Calls, and check this one */
99 if (FastDispatch && FastDispatch->MdlReadComplete)
100 {
101 /* Use the fast path */
102 FastDispatch->MdlReadComplete(FileObject,
103 MdlChain,
104 DeviceObject);
105 }
106
107 /* Use slow path */
108 CcMdlReadComplete2(FileObject, MdlChain);
109 }
110
111 /*
112 * @implemented
113 */
114 VOID
115 NTAPI
116 CcMdlWriteComplete (
117 IN PFILE_OBJECT FileObject,
118 IN PLARGE_INTEGER FileOffset,
119 IN PMDL MdlChain)
120 {
121 PDEVICE_OBJECT DeviceObject = NULL;
122 PFAST_IO_DISPATCH FastDispatch;
123
124 /* Get Fast Dispatch Data */
125 DeviceObject = IoGetRelatedDeviceObject(FileObject);
126 FastDispatch = DeviceObject->DriverObject->FastIoDispatch;
127
128 /* Check if we support Fast Calls, and check this one */
129 if (FastDispatch && FastDispatch->MdlWriteComplete)
130 {
131 /* Use the fast path */
132 FastDispatch->MdlWriteComplete(FileObject,
133 FileOffset,
134 MdlChain,
135 DeviceObject);
136 }
137
138 /* Use slow path */
139 CcMdlWriteComplete2(FileObject,FileOffset, MdlChain);
140 }
141
142 VOID
143 NTAPI
144 CcMdlWriteComplete2 (
145 IN PFILE_OBJECT FileObject,
146 IN PLARGE_INTEGER FileOffset,
147 IN PMDL MdlChain)
148 {
149 UNIMPLEMENTED;
150 }
151
152 /*
153 * @unimplemented
154 */
155 VOID
156 NTAPI
157 CcMdlWriteAbort (
158 IN PFILE_OBJECT FileObject,
159 IN PMDL MdlChain)
160 {
161 UNIMPLEMENTED;
162 }
163
164 /*
165 * @unimplemented
166 */
167 VOID
168 NTAPI
169 CcPrepareMdlWrite (
170 IN PFILE_OBJECT FileObject,
171 IN PLARGE_INTEGER FileOffset,
172 IN ULONG Length,
173 OUT PMDL * MdlChain,
174 OUT PIO_STATUS_BLOCK IoStatus)
175 {
176 UNIMPLEMENTED;
177 }