migrate substitution keywords to SVN
[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 STDCALL
66 CcMdlReadCompleteDev (IN PMDL MdlChain,
67 IN PDEVICE_OBJECT DeviceObject);
68
69 NTSTATUS
70 CcRosFlushCacheSegment(PCACHE_SEGMENT CacheSegment);
71
72 NTSTATUS
73 CcRosGetCacheSegment(PBCB Bcb,
74 ULONG FileOffset,
75 PULONG BaseOffset,
76 PVOID* BaseAddress,
77 PBOOLEAN UptoDate,
78 PCACHE_SEGMENT* CacheSeg);
79 VOID
80 CcInitView(VOID);
81
82 NTSTATUS
83 CcRosFreeCacheSegment(PBCB, PCACHE_SEGMENT);
84
85 NTSTATUS
86 ReadCacheSegment(PCACHE_SEGMENT CacheSeg);
87
88 NTSTATUS
89 WriteCacheSegment(PCACHE_SEGMENT CacheSeg);
90
91 VOID CcInit(VOID);
92
93 NTSTATUS
94 CcRosUnmapCacheSegment(PBCB Bcb, ULONG FileOffset, BOOLEAN NowDirty);
95
96 PCACHE_SEGMENT
97 CcRosLookupCacheSegment(PBCB Bcb, ULONG FileOffset);
98
99 NTSTATUS
100 CcRosGetCacheSegmentChain(PBCB Bcb,
101 ULONG FileOffset,
102 ULONG Length,
103 PCACHE_SEGMENT* CacheSeg);
104
105 VOID
106 CcInitCacheZeroPage(VOID);
107
108 NTSTATUS
109 CcRosMarkDirtyCacheSegment(PBCB Bcb, ULONG FileOffset);
110
111 NTSTATUS
112 CcRosFlushDirtyPages(ULONG Target, PULONG Count);
113
114 VOID
115 CcRosDereferenceCache(PFILE_OBJECT FileObject);
116
117 VOID
118 CcRosReferenceCache(PFILE_OBJECT FileObject);
119
120 VOID
121 CcRosSetRemoveOnClose(PSECTION_OBJECT_POINTERS SectionObjectPointer);
122
123 NTSTATUS
124 CcRosReleaseCacheSegment (BCB* Bcb,
125 CACHE_SEGMENT* CacheSeg,
126 BOOLEAN Valid,
127 BOOLEAN Dirty,
128 BOOLEAN Mapped);
129
130 NTSTATUS STDCALL
131 CcRosRequestCacheSegment (BCB* Bcb,
132 ULONG FileOffset,
133 PVOID* BaseAddress,
134 PBOOLEAN UptoDate,
135 CACHE_SEGMENT** CacheSeg);
136
137 NTSTATUS
138 CcTryToInitializeFileCache(PFILE_OBJECT FileObject);
139
140 /*
141 * Macro for generic cache manage bugchecking. Note that this macro assumes
142 * that the file name including extension is always longer than 4 characters.
143 */
144 #define KEBUGCHECKCC \
145 KEBUGCHECKEX(CACHE_MANAGER, \
146 (*(DWORD*)(__FILE__ + sizeof(__FILE__) - 4) << 16) | \
147 (__LINE__ & 0xFFFF), 0, 0, 0)
148
149 #endif