Due to CcRos's abusive usage and dependency on our broken Fast Mutex implementation...
[reactos.git] / reactos / ntoskrnl / include / internal / cc.h
1 #ifndef __INCLUDE_INTERNAL_CC_H
2 #define __INCLUDE_INTERNAL_CC_H
3
4 VOID
5 FASTCALL
6 CcAcquireBrokenMutex(PFAST_MUTEX FastMutex);
7
8 VOID
9 FASTCALL
10 CcReleaseBrokenMutex(PFAST_MUTEX FastMutex);
11
12 BOOLEAN
13 FASTCALL
14 CcTryToAcquireBrokenMutex(PFAST_MUTEX FastMutex);
15
16 typedef struct _BCB
17 {
18 LIST_ENTRY BcbSegmentListHead;
19 LIST_ENTRY BcbRemoveListEntry;
20 BOOLEAN RemoveOnClose;
21 ULONG TimeStamp;
22 PFILE_OBJECT FileObject;
23 ULONG CacheSegmentSize;
24 LARGE_INTEGER AllocationSize;
25 LARGE_INTEGER FileSize;
26 KSPIN_LOCK BcbLock;
27 ULONG RefCount;
28 #if defined(DBG) || defined(KDBG)
29 BOOLEAN Trace; /* enable extra trace output for this BCB and it's cache segments */
30 #endif
31 } BCB, *PBCB;
32
33 typedef struct _CACHE_SEGMENT
34 {
35 /* Base address of the region where the cache segment data is mapped. */
36 PVOID BaseAddress;
37 /*
38 * Memory area representing the region where the cache segment data is
39 * mapped.
40 */
41 struct _MEMORY_AREA* MemoryArea;
42 /* Are the contents of the cache segment data valid. */
43 BOOLEAN Valid;
44 /* Are the contents of the cache segment data newer than those on disk. */
45 BOOLEAN Dirty;
46 /* Page out in progress */
47 BOOLEAN PageOut;
48 ULONG MappedCount;
49 /* Entry in the list of segments for this BCB. */
50 LIST_ENTRY BcbSegmentListEntry;
51 /* Entry in the list of segments which are dirty. */
52 LIST_ENTRY DirtySegmentListEntry;
53 /* Entry in the list of segments. */
54 LIST_ENTRY CacheSegmentListEntry;
55 LIST_ENTRY CacheSegmentLRUListEntry;
56 /* Offset in the file which this cache segment maps. */
57 ULONG FileOffset;
58 /* Lock. */
59 FAST_MUTEX Lock;
60 /* Number of references. */
61 ULONG ReferenceCount;
62 /* Pointer to the BCB for the file which this cache segment maps data for. */
63 PBCB Bcb;
64 /* Pointer to the next cache segment in a chain. */
65 struct _CACHE_SEGMENT* NextInChain;
66 } CACHE_SEGMENT, *PCACHE_SEGMENT;
67
68 typedef struct _INTERNAL_BCB
69 {
70 PUBLIC_BCB PFCB;
71 PCACHE_SEGMENT CacheSegment;
72 BOOLEAN Dirty;
73 CSHORT RefCount; /* (At offset 0x34 on WinNT4) */
74 } INTERNAL_BCB, *PINTERNAL_BCB;
75
76 VOID
77 STDCALL
78 CcMdlReadCompleteDev(
79 IN PMDL MdlChain,
80 IN PFILE_OBJECT FileObject
81 );
82
83 VOID
84 STDCALL
85 CcMdlWriteCompleteDev(
86 IN PLARGE_INTEGER FileOffset,
87 IN PMDL MdlChain,
88 IN PFILE_OBJECT FileObject
89 );
90
91 NTSTATUS
92 NTAPI
93 CcRosFlushCacheSegment(PCACHE_SEGMENT CacheSegment);
94
95 NTSTATUS
96 NTAPI
97 CcRosGetCacheSegment(
98 PBCB Bcb,
99 ULONG FileOffset,
100 PULONG BaseOffset,
101 PVOID *BaseAddress,
102 PBOOLEAN UptoDate,
103 PCACHE_SEGMENT *CacheSeg
104 );
105
106 VOID
107 NTAPI
108 CcInitView(VOID);
109
110 NTSTATUS
111 NTAPI
112 CcRosFreeCacheSegment(
113 PBCB,
114 PCACHE_SEGMENT
115 );
116
117 NTSTATUS
118 NTAPI
119 ReadCacheSegment(PCACHE_SEGMENT CacheSeg);
120
121 NTSTATUS
122 NTAPI
123 WriteCacheSegment(PCACHE_SEGMENT CacheSeg);
124
125 VOID
126 NTAPI
127 CcInit(VOID);
128
129 NTSTATUS
130 NTAPI
131 CcRosUnmapCacheSegment(
132 PBCB Bcb,
133 ULONG FileOffset,
134 BOOLEAN NowDirty
135 );
136
137 PCACHE_SEGMENT
138 NTAPI
139 CcRosLookupCacheSegment(
140 PBCB Bcb,
141 ULONG FileOffset
142 );
143
144 NTSTATUS
145 NTAPI
146 CcRosGetCacheSegmentChain(
147 PBCB Bcb,
148 ULONG FileOffset,
149 ULONG Length,
150 PCACHE_SEGMENT* CacheSeg
151 );
152
153 VOID
154 NTAPI
155 CcInitCacheZeroPage(VOID);
156
157 NTSTATUS
158 NTAPI
159 CcRosMarkDirtyCacheSegment(
160 PBCB Bcb,
161 ULONG FileOffset
162 );
163
164 NTSTATUS
165 NTAPI
166 CcRosFlushDirtyPages(
167 ULONG Target,
168 PULONG Count
169 );
170
171 VOID
172 NTAPI
173 CcRosDereferenceCache(PFILE_OBJECT FileObject);
174
175 VOID
176 NTAPI
177 CcRosReferenceCache(PFILE_OBJECT FileObject);
178
179 VOID
180 NTAPI
181 CcRosSetRemoveOnClose(PSECTION_OBJECT_POINTERS SectionObjectPointer);
182
183 NTSTATUS
184 NTAPI
185 CcRosReleaseCacheSegment(
186 BCB* Bcb,
187 CACHE_SEGMENT *CacheSeg,
188 BOOLEAN Valid,
189 BOOLEAN Dirty,
190 BOOLEAN Mapped
191 );
192
193 NTSTATUS
194 STDCALL
195 CcRosRequestCacheSegment(
196 BCB *Bcb,
197 ULONG FileOffset,
198 PVOID* BaseAddress,
199 PBOOLEAN UptoDate,
200 CACHE_SEGMENT **CacheSeg
201 );
202
203 NTSTATUS
204 NTAPI
205 CcTryToInitializeFileCache(PFILE_OBJECT FileObject);
206
207 /*
208 * Macro for generic cache manage bugchecking. Note that this macro assumes
209 * that the file name including extension is always longer than 4 characters.
210 */
211 #define KEBUGCHECKCC \
212 KEBUGCHECKEX(CACHE_MANAGER, \
213 (*(DWORD*)(__FILE__ + sizeof(__FILE__) - 4) << 16) | \
214 (__LINE__ & 0xFFFF), 0, 0, 0)
215
216 #endif