Reverted latest changes.
[reactos.git] / reactos / ntoskrnl / include / internal / cc.h
1 #ifndef __INCLUDE_INTERNAL_CC_H
2 #define __INCLUDE_INTERNAL_CC_H
3 /* $Id: cc.h,v 1.16 2002/09/08 10:23:21 chorns Exp $ */
4 #include <ddk/ntifs.h>
5
6 typedef struct _BCB
7 {
8 LIST_ENTRY BcbSegmentListHead;
9 PFILE_OBJECT FileObject;
10 ULONG CacheSegmentSize;
11 LARGE_INTEGER AllocationSize;
12 LARGE_INTEGER FileSize;
13 KSPIN_LOCK BcbLock;
14 ULONG RefCount;
15 } BCB;
16
17 typedef struct _CACHE_SEGMENT
18 {
19 /* Base address of the region where the cache segment data is mapped. */
20 PVOID BaseAddress;
21 /*
22 * Memory area representing the region where the cache segment data is
23 * mapped.
24 */
25 struct _MEMORY_AREA* MemoryArea;
26 /* Are the contents of the cache segment data valid. */
27 BOOLEAN Valid;
28 /* Are the contents of the cache segment data newer than those on disk. */
29 BOOLEAN Dirty;
30 ULONG MappedCount;
31 /* Entry in the list of segments for this BCB. */
32 LIST_ENTRY BcbSegmentListEntry;
33 /* Entry in the list of segments which are dirty. */
34 LIST_ENTRY DirtySegmentListEntry;
35 /* Entry in the list of segments. */
36 LIST_ENTRY CacheSegmentListEntry;
37 LIST_ENTRY CacheSegmentLRUListEntry;
38 /* Offset in the file which this cache segment maps. */
39 ULONG FileOffset;
40 /* Lock. */
41 FAST_MUTEX Lock;
42 /* Number of references. */
43 ULONG ReferenceCount;
44 /* Pointer to the BCB for the file which this cache segment maps data for. */
45 PBCB Bcb;
46 /* Pointer to the next cache segment in a chain. */
47 struct _CACHE_SEGMENT* NextInChain;
48 } CACHE_SEGMENT;
49
50 VOID STDCALL
51 CcMdlReadCompleteDev (IN PMDL MdlChain,
52 IN PDEVICE_OBJECT DeviceObject);
53 NTSTATUS
54 CcRosGetCacheSegment(PBCB Bcb,
55 ULONG FileOffset,
56 PULONG BaseOffset,
57 PVOID* BaseAddress,
58 PBOOLEAN UptoDate,
59 PCACHE_SEGMENT* CacheSeg);
60 VOID
61 CcInitView(VOID);
62
63
64 NTSTATUS STDCALL CcRosFreeCacheSegment(PBCB, PCACHE_SEGMENT);
65
66 NTSTATUS ReadCacheSegment(PCACHE_SEGMENT CacheSeg);
67
68 NTSTATUS WriteCacheSegment(PCACHE_SEGMENT CacheSeg);
69
70 VOID CcInit(VOID);
71 NTSTATUS
72 CcRosUnmapCacheSegment(PBCB Bcb, ULONG FileOffset, BOOLEAN NowDirty);
73 NTSTATUS
74 CcRosSuggestFreeCacheSegment(PBCB Bcb, ULONG FileOffset, BOOLEAN NowDirty);
75 NTSTATUS
76 CcRosGetCacheSegmentChain(PBCB Bcb,
77 ULONG FileOffset,
78 ULONG Length,
79 PCACHE_SEGMENT* CacheSeg);
80 VOID CcInitCacheZeroPage(VOID);
81 NTSTATUS
82 CcRosMarkDirtyCacheSegment(PBCB Bcb, ULONG FileOffset);
83 NTSTATUS
84 CcRosFlushDirtyPages(ULONG Target, PULONG Count);
85
86 VOID CcRosDereferenceCache(PFILE_OBJECT FileObject);
87 VOID CcRosReferenceCache(PFILE_OBJECT FileObject);
88
89 #endif