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