[NTOSKRNL] Add a raw implementation of !irpfind in kdbg
[reactos.git] / ntoskrnl / cache / newcc.h
1 #pragma once
2
3 typedef struct _NOCC_BCB
4 {
5 /* Public part */
6 PUBLIC_BCB Bcb;
7
8 struct _NOCC_CACHE_MAP *Map;
9 PROS_SECTION_OBJECT SectionObject;
10 LARGE_INTEGER FileOffset;
11 ULONG Length;
12 PVOID BaseAddress;
13 BOOLEAN Dirty;
14 PVOID OwnerPointer;
15
16 /* Reference counts */
17 ULONG RefCount;
18
19 LIST_ENTRY ThisFileList;
20
21 KEVENT ExclusiveWait;
22 ULONG ExclusiveWaiter;
23 BOOLEAN Exclusive;
24 } NOCC_BCB, *PNOCC_BCB;
25
26 typedef struct _NOCC_CACHE_MAP
27 {
28 LIST_ENTRY Entry;
29 LIST_ENTRY AssociatedBcb;
30 LIST_ENTRY PrivateCacheMaps;
31 ULONG NumberOfMaps;
32 ULONG RefCount;
33 CC_FILE_SIZES FileSizes;
34 CACHE_MANAGER_CALLBACKS Callbacks;
35 PVOID LazyContext;
36 PVOID LogHandle;
37 PFLUSH_TO_LSN FlushToLsn;
38 ULONG ReadAheadGranularity;
39 } NOCC_CACHE_MAP, *PNOCC_CACHE_MAP;
40
41 INIT_FUNCTION
42 VOID
43 NTAPI
44 CcPfInitializePrefetcher(VOID);
45
46 VOID
47 NTAPI
48 CcMdlReadComplete2(IN PFILE_OBJECT FileObject,
49 IN PMDL MemoryDescriptorList);
50
51 VOID
52 NTAPI
53 CcMdlWriteComplete2(IN PFILE_OBJECT FileObject,
54 IN PLARGE_INTEGER FileOffset,
55 IN PMDL MdlChain);
56
57 INIT_FUNCTION
58 VOID
59 NTAPI
60 CcInitView(VOID);
61
62 BOOLEAN
63 NTAPI
64 CcpUnpinData(PNOCC_BCB Bcb,
65 BOOLEAN ActuallyRelease);
66
67 INIT_FUNCTION
68 BOOLEAN
69 NTAPI
70 CcInitializeCacheManager(VOID);
71
72 VOID
73 NTAPI
74 CcShutdownSystem(VOID);
75
76 VOID
77 NTAPI
78 CcInitCacheZeroPage(VOID);
79
80 /* Called by section.c */
81 BOOLEAN
82 NTAPI
83 CcFlushImageSection(PSECTION_OBJECT_POINTERS SectionObjectPointer,
84 MMFLUSH_TYPE FlushType);
85
86 VOID
87 NTAPI
88 _CcpFlushCache(IN PNOCC_CACHE_MAP Map,
89 IN OPTIONAL PLARGE_INTEGER FileOffset,
90 IN ULONG Length,
91 OUT OPTIONAL PIO_STATUS_BLOCK IoStatus,
92 BOOLEAN Delete,
93 const char *File,
94 int Line);
95
96 #define CcpFlushCache(M,F,L,I,D) _CcpFlushCache(M,F,L,I,D,__FILE__,__LINE__)
97
98 BOOLEAN
99 NTAPI
100 CcGetFileSizes(PFILE_OBJECT FileObject,
101 PCC_FILE_SIZES FileSizes);
102
103 ULONG
104 NTAPI
105 CcpCountCacheSections(PNOCC_CACHE_MAP Map);
106
107 BOOLEAN
108 NTAPI
109 CcpAcquireFileLock(PNOCC_CACHE_MAP Map);
110
111 VOID
112 NTAPI
113 CcpReleaseFileLock(PNOCC_CACHE_MAP Map);
114
115 /*
116 * Macro for generic cache manage bugchecking. Note that this macro assumes
117 * that the file name including extension is always longer than 4 characters.
118 */
119 #define KEBUGCHECKCC \
120 KEBUGCHECKEX(CACHE_MANAGER, \
121 (*(ULONG*)(__FILE__ + sizeof(__FILE__) - 4) << 16) | \
122 (__LINE__ & 0xFFFF), 0, 0, 0)
123
124 /* Private data */
125
126 #define CACHE_SINGLE_FILE_MAX (16)
127 #define CACHE_OVERALL_SIZE (32 * 1024 * 1024)
128 #define CACHE_STRIPE VACB_MAPPING_GRANULARITY
129 #define CACHE_SHIFT 18
130 #define CACHE_NUM_SECTIONS (CACHE_OVERALL_SIZE / CACHE_STRIPE)
131 #define CACHE_ROUND_UP(x) (((x) + (CACHE_STRIPE-1)) & ~(CACHE_STRIPE-1))
132 #define CACHE_ROUND_DOWN(x) ((x) & ~(CACHE_STRIPE-1))
133 #define INVALID_CACHE ((ULONG)~0)
134
135 extern NOCC_BCB CcCacheSections[CACHE_NUM_SECTIONS];
136 extern PRTL_BITMAP CcCacheBitmap;
137 extern FAST_MUTEX CcMutex;
138 extern KEVENT CcDeleteEvent;
139 extern ULONG CcCacheClockHand;
140 extern LIST_ENTRY CcPendingUnmap;
141 extern KEVENT CcpLazyWriteEvent;
142
143 #define CcpLock() _CcpLock(__FILE__,__LINE__)
144 #define CcpUnlock() _CcpUnlock(__FILE__,__LINE__)
145
146 extern VOID _CcpLock(const char *file, int line);
147 extern VOID _CcpUnlock(const char *file, int line);
148
149 extern VOID CcpReferenceCache(ULONG Sector);
150 extern VOID CcpDereferenceCache(ULONG Sector, BOOLEAN Immediate);
151
152 BOOLEAN
153 NTAPI
154 CcpMapData(IN PFILE_OBJECT FileObject,
155 IN PLARGE_INTEGER FileOffset,
156 IN ULONG Length,
157 IN ULONG Flags,
158 OUT PVOID *BcbResult,
159 OUT PVOID *Buffer);
160
161 BOOLEAN
162 NTAPI
163 CcpPinMappedData(IN PNOCC_CACHE_MAP Map,
164 IN PLARGE_INTEGER FileOffset,
165 IN ULONG Length,
166 IN ULONG Flags,
167 IN OUT PVOID *Bcb);