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