Trim cache
[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.8 2001/12/29 14:32:22 dwelch 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 } BCB;
15
16 typedef struct _CACHE_SEGMENT
17 {
18 /* Base address of the region where the cache segment data is mapped. */
19 PVOID BaseAddress;
20 /* Memory area representing the region where the cache segment data is mapped. */
21 struct _MEMORY_AREA* MemoryArea;
22 /* Are the contents of the cache segment data valid. */
23 BOOLEAN Valid;
24 /* Are the contents of the cache segment data newer than those on disk. */
25 BOOLEAN Dirty;
26 ULONG MappedCount;
27 /* Entry in the list of segments for this BCB. */
28 LIST_ENTRY BcbSegmentListEntry;
29 /* Entry in the list of segments which are dirty. */
30 LIST_ENTRY DirtySegmentListEntry;
31 /* Entry in the list of segments. */
32 LIST_ENTRY CacheSegmentListEntry;
33 LIST_ENTRY CacheSegmentLRUListEntry;
34 /* Offset in the file which this cache segment maps. */
35 ULONG FileOffset;
36 /* Lock. */
37 FAST_MUTEX Lock;
38 /* Number of references. */
39 ULONG ReferenceCount;
40 /* Pointer to the BCB for the file which this cache segment maps data for. */
41 PBCB Bcb;
42 } CACHE_SEGMENT;
43
44 VOID STDCALL
45 CcMdlReadCompleteDev (IN PMDL MdlChain,
46 IN PDEVICE_OBJECT DeviceObject);
47 NTSTATUS
48 CcRosGetCacheSegment(PBCB Bcb,
49 ULONG FileOffset,
50 PULONG BaseOffset,
51 PVOID* BaseAddress,
52 PBOOLEAN UptoDate,
53 PCACHE_SEGMENT* CacheSeg);
54 VOID
55 CcInitView(VOID);
56
57
58 NTSTATUS STDCALL CcRosFreeCacheSegment(PBCB, PCACHE_SEGMENT);
59
60 NTSTATUS ReadCacheSegment(PCACHE_SEGMENT CacheSeg);
61
62 NTSTATUS WriteCacheSegment(PCACHE_SEGMENT CacheSeg);
63
64 VOID CcInit(VOID);
65
66 #endif