update for HEAD-2003091401
[reactos.git] / ntoskrnl / include / internal / cc.h
1 #ifndef __INCLUDE_INTERNAL_CC_H
2 #define __INCLUDE_INTERNAL_CC_H
3 /* $Id$ */
4 #include <ddk/ntifs.h>
5
6
7 typedef struct _BCB
8 {
9   LIST_ENTRY BcbSegmentListHead;
10   LIST_ENTRY BcbRemoveListEntry;
11   BOOLEAN RemoveOnClose;
12   ULONG TimeStamp;
13   PFILE_OBJECT FileObject;
14   ULONG CacheSegmentSize;
15   LARGE_INTEGER AllocationSize;
16   LARGE_INTEGER FileSize;
17   KSPIN_LOCK BcbLock;
18   ULONG RefCount;
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   ULONG MappedCount;
35   /* Entry in the list of segments for this BCB. */
36   LIST_ENTRY BcbSegmentListEntry;
37   /* Entry in the list of segments which are dirty. */
38   LIST_ENTRY DirtySegmentListEntry;
39   /* Entry in the list of segments. */
40   LIST_ENTRY CacheSegmentListEntry;
41   LIST_ENTRY CacheSegmentLRUListEntry;
42   /* Offset in the file which this cache segment maps. */
43   ULONG FileOffset;
44   /* Lock. */
45   FAST_MUTEX Lock;
46   /* Number of references. */
47   ULONG ReferenceCount;
48   /* Pointer to the BCB for the file which this cache segment maps data for. */
49   PBCB Bcb;
50   /* Pointer to the next cache segment in a chain. */
51   struct _CACHE_SEGMENT* NextInChain;
52 } CACHE_SEGMENT, *PCACHE_SEGMENT;
53
54 typedef struct _INTERNAL_BCB
55 {
56   PUBLIC_BCB PFCB;
57   PCACHE_SEGMENT CacheSegment;
58   BOOLEAN Dirty;
59 } INTERNAL_BCB, *PINTERNAL_BCB;
60
61 VOID STDCALL
62 CcMdlReadCompleteDev (IN PMDL           MdlChain,
63                       IN PDEVICE_OBJECT DeviceObject);
64
65 NTSTATUS
66 CcRosGetCacheSegment(PBCB Bcb,
67                      ULONG FileOffset,
68                      PULONG BaseOffset,
69                      PVOID* BaseAddress,
70                      PBOOLEAN UptoDate,
71                      PCACHE_SEGMENT* CacheSeg);
72 VOID
73 CcInitView(VOID);
74
75 NTSTATUS 
76 CcRosFreeCacheSegment(PBCB, PCACHE_SEGMENT);
77
78 NTSTATUS 
79 ReadCacheSegment(PCACHE_SEGMENT CacheSeg);
80
81 NTSTATUS 
82 WriteCacheSegment(PCACHE_SEGMENT CacheSeg);
83
84 VOID CcInit(VOID);
85
86 NTSTATUS
87 CcRosUnmapCacheSegment(PBCB Bcb, ULONG FileOffset, BOOLEAN NowDirty);
88
89 PCACHE_SEGMENT 
90 CcRosLookupCacheSegment(PBCB Bcb, ULONG FileOffset);
91
92 NTSTATUS
93 CcRosGetCacheSegmentChain(PBCB Bcb,
94                           ULONG FileOffset,
95                           ULONG Length,
96                           PCACHE_SEGMENT* CacheSeg);
97
98 VOID 
99 CcInitCacheZeroPage(VOID);
100
101 NTSTATUS
102 CcRosMarkDirtyCacheSegment(PBCB Bcb, ULONG FileOffset);
103
104 NTSTATUS
105 CcRosFlushDirtyPages(ULONG Target, PULONG Count);
106
107 VOID 
108 CcRosDereferenceCache(PFILE_OBJECT FileObject);
109
110 VOID 
111 CcRosReferenceCache(PFILE_OBJECT FileObject);
112
113 VOID 
114 CcRosSetRemoveOnClose(PSECTION_OBJECT_POINTERS SectionObjectPointer);
115
116 NTSTATUS
117 CcRosReleaseCacheSegment (BCB*              Bcb,
118                           CACHE_SEGMENT*    CacheSeg,
119                           BOOLEAN           Valid,
120                           BOOLEAN           Dirty,
121                           BOOLEAN           Mapped);
122
123 NTSTATUS STDCALL
124 CcRosRequestCacheSegment (BCB*              Bcb,
125                           ULONG             FileOffset,
126                           PVOID*            BaseAddress,
127                           PBOOLEAN          UptoDate,
128                           CACHE_SEGMENT**   CacheSeg);
129
130 NTSTATUS 
131 CcTryToInitializeFileCache(PFILE_OBJECT FileObject);
132
133
134 #endif