ReactOS  0.4.15-dev-2522-g9e0a3cd
newmm.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <internal/arch/mm.h>
4 
5 /* TYPES *********************************************************************/
6 #define MM_SEGMENT_FINALIZE (0x40000000)
7 
8 
9 #define MIN(x,y) (((x)<(y))?(x):(y))
10 #define MAX(x,y) (((x)>(y))?(x):(y))
11 
12 /* Determine what's needed to make paged pool fit in this category.
13  * it seems that something more is required to satisfy arm3. */
14 #define BALANCER_CAN_EVICT(Consumer) \
15  (((Consumer) == MC_USER) || \
16  ((Consumer) == MC_CACHE))
17 
18 #define SEC_CACHE (0x20000000)
19 
20 /* We store 8 bits of location with a page association */
21 #define ENTRIES_PER_ELEMENT 256
22 
23 extern KEVENT MmWaitPageEvent;
24 
26 {
32 
34 
35 typedef NTSTATUS (NTAPI * AcquireResource)(
39 
42  struct _MEMORY_AREA *MemoryArea,
43  PVOID Address,
46 
49  struct _MEMORY_AREA *MemoryArea,
50  PVOID Address,
52 
53 typedef struct _MM_REQUIRED_RESOURCES
54 {
61  AcquireResource DoAcquisition;
65  const char *File;
66  int Line;
68 
70 NTAPI
74  PLARGE_INTEGER UMaximumSize,
78 
80 NTAPI
83  BOOLEAN *Dirty);
84 
86 NTAPI
90  BOOLEAN Dirty);
91 
92 /* sptab.c *******************************************************************/
93 
94 VOID
95 NTAPI
97 
101 
102 VOID
103 NTAPI
106 
107 NTSTATUS
108 NTAPI
112 
113 VOID
114 NTAPI
116 
117 NTSTATUS
118 NTAPI
120 
121 /* io.c **********************************************************************/
122 
123 NTSTATUS
125 
126 NTSTATUS
127 NTAPI
130  PVOID Buffer,
131  ULONG Length,
132  BOOLEAN Paging,
134 
135 NTSTATUS
136 NTAPI
139  PVOID Buffer,
140  ULONG Length,
142  const char *file,
143  int line);
144 
145 #define MiSimpleWrite(F,O,B,L,R) _MiSimpleWrite(F,O,B,L,R,__FILE__,__LINE__)
146 
147 NTSTATUS
148 NTAPI
151  ULONG Length,
153  const char *File,
154  int Line);
155 
156 #define MiWriteBackPage(F,O,L,P) _MiWriteBackPage(F,O,L,P,__FILE__,__LINE__)
157 
158 /* section.c *****************************************************************/
159 
160 NTSTATUS
161 NTAPI
164  BOOLEAN FromMdl);
165 
166 NTSTATUS
167 NTAPI
170  PMM_REQUIRED_RESOURCES RequiredResources);
171 
172 NTSTATUS
173 NTAPI
176  PMM_REQUIRED_RESOURCES RequiredResources);
177 
178 NTSTATUS
179 NTAPI
182  PMM_REQUIRED_RESOURCES RequiredResources);
183 
184 NTSTATUS
185 NTAPI
189 
190 NTSTATUS
191 NTAPI
195 
196 VOID
197 NTAPI
200 
201 _Success_(1)
203 NTSTATUS
204 NTAPI
205 MiCowCacheSectionPage (
211 
212 VOID
215  PVOID Address);
216 
217 VOID
220  PVOID Address,
222  SWAPENTRY SwapEntry,
223  BOOLEAN Dirty);
224 
225 NTSTATUS
226 NTAPI
228  PLARGE_INTEGER BaseOffset,
230  BOOLEAN Dirty,
231  const char *File,
232  int Line);
233 
234 #define MiFlushMappedSection(A,O,S,D) _MiFlushMappedSection(A,O,S,D,__FILE__,__LINE__)
235 
236 VOID
237 NTAPI
239 
240 VOID
241 NTAPI
243 
244 NTSTATUS
245 NTAPI
248  IN PLARGE_INTEGER ViewOffset,
250 
251 NTSTATUS
252 NTAPI
257  ULONG Protect,
258  PLARGE_INTEGER ViewOffset,
260  const char *file,
261  int line);
262 
263 #define MiMapViewOfSegment(AddressSpace,Segment,BaseAddress,ViewSize,Protect,ViewOffset,AllocationType) \
264  _MiMapViewOfSegment(AddressSpace,Segment,BaseAddress,ViewSize,Protect,ViewOffset,AllocationType,__FILE__,__LINE__)
265 
266 NTSTATUS
267 NTAPI
270 
271 NTSTATUS
272 NTAPI
274 
275 _Success_(1)
277 NTSTATUS
278 NTAPI
279 MmNotPresentFaultCachePage (
285 
286 NTSTATUS
287 NTAPI
290  PVOID Address,
292 
294 BOOLEAN
296  const char *file,
297  int line)
298 {
300  //DbgPrint("(%s:%d) Try Lock Address Space %x -> %s\n", file, line, AddressSpace, Result ? "true" : "false");
301  return Result;
302 }
303 
304 #define MmTryToLockAddressSpace(x) _MmTryToLockAddressSpace(x,__FILE__,__LINE__)
305 
306 NTSTATUS
307 NTAPI
310  PMM_REQUIRED_RESOURCES RequiredResources);
311 
312 NTSTATUS
313 NTAPI
316  PMM_REQUIRED_RESOURCES RequiredResources);
317 
318 NTSTATUS
319 NTAPI
322  BOOLEAN ExtendFile);
323 
324 NTSTATUS
325 NTAPI
327  PLARGE_INTEGER BaseOffset,
329  BOOLEAN Dirty,
330  const char *File,
331  int Line);
332 
333 #define MiFlushMappedSection(A,O,S,D) _MiFlushMappedSection(A,O,S,D,__FILE__,__LINE__)
334 
335 PVOID
336 NTAPI
338  PULONG RawOffset);
339 
340 NTSTATUS
341 NTAPI
344  BOOLEAN FromMdl);
345 
346 ULONG
347 NTAPI
349  ULONG Target);
350 
351 NTSTATUS
353  ULONG Priority,
354  PULONG NrFreed);
_Must_inspect_result_ _Outptr_ PVOID * SectionObject
Definition: fsrtlfuncs.h:860
VOID(NTAPI * FREE_SECTION_PAGE_FUN)(PMM_SECTION_SEGMENT Segment, PLARGE_INTEGER Offset)
Definition: newmm.h:98
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define IN
Definition: typedefs.h:39
NTSTATUS NTAPI MmAccessFaultCacheSection(KPROCESSOR_MODE Mode, ULONG_PTR Address, BOOLEAN FromMdl)
return
Definition: dirsup.c:529
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2654
NTSTATUS NTAPI _MiMapViewOfSegment(PMMSUPPORT AddressSpace, PMM_SECTION_SEGMENT Segment, PVOID *BaseAddress, SIZE_T ViewSize, ULONG Protect, PLARGE_INTEGER ViewOffset, ULONG AllocationType, const char *file, int line)
PVOID NTAPI MmGetSegmentRmap(PFN_NUMBER Page, PULONG RawOffset)
Definition: rmap.c:459
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
NTSTATUS NTAPI MiSimpleRead(PFILE_OBJECT FileObject, PLARGE_INTEGER FileOffset, PVOID Buffer, ULONG Length, BOOLEAN Paging, PIO_STATUS_BLOCK ReadStatus)
Definition: io.c:109
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ ULONG AllocationAttributes
Definition: mmfuncs.h:360
_In_ ULONG Mode
Definition: hubbusif.h:303
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:68
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T _In_ SECTION_INHERIT _In_ ULONG _In_ ULONG Protect
Definition: zwfuncs.h:214
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG AddressSpace
Definition: iofuncs.h:2268
_At_(Required->DoAcquisition, _Post_notnull_)) NTSTATUS NTAPI MiCowCacheSectionPage(_In_ PMMSUPPORT AddressSpace
_In_ PMEMORY_AREA _In_ PVOID Address
Definition: newmm.h:207
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI MmFinalizeSectionPageOut(PMM_SECTION_SEGMENT Segment, PLARGE_INTEGER FileOffset, PFN_NUMBER Page, BOOLEAN Dirty)
Definition: swapout.c:165
AcquireResource DoAcquisition
Definition: newmm.h:61
struct _CACHE_SECTION_PAGE_TABLE * PCACHE_SECTION_PAGE_TABLE
NTSTATUS NTAPI MiReadFilePage(PMMSUPPORT AddressSpace, PMEMORY_AREA MemoryArea, PMM_REQUIRED_RESOURCES RequiredResources)
Definition: reqtools.c:133
NTSTATUS MiRosTrimCache(ULONG Target, ULONG Priority, PULONG NrFreed)
Definition: swapout.c:633
NTSTATUS(NTAPI * NotPresentFaultHandler)(PMMSUPPORT AddressSpace, struct _MEMORY_AREA *MemoryArea, PVOID Address, BOOLEAN Locked, struct _MM_REQUIRED_RESOURCES *Required)
Definition: newmm.h:40
NTSTATUS NTAPI MiSwapInPage(PMMSUPPORT AddressSpace, PMEMORY_AREA MemoryArea, PMM_REQUIRED_RESOURCES RequiredResources)
Definition: reqtools.c:220
NTSTATUS NTAPI _MiSimpleWrite(PFILE_OBJECT FileObject, PLARGE_INTEGER FileOffset, PVOID Buffer, ULONG Length, PIO_STATUS_BLOCK ReadStatus, const char *file, int line)
VOID NTAPI MiFreeSegmentPage(PMM_SECTION_SEGMENT Segment, PLARGE_INTEGER FileOffset)
Definition: data.c:617
uint32_t ULONG_PTR
Definition: typedefs.h:65
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_opt_ PLARGE_INTEGER _In_ ULONG SectionPageProtection
Definition: mmfuncs.h:360
ULONG PFN_NUMBER
Definition: ke.h:9
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
ULONG_PTR PageEntries[ENTRIES_PER_ELEMENT]
Definition: newmm.h:30
NTSTATUS NTAPI MiGetOnePage(PMMSUPPORT AddressSpace, PMEMORY_AREA MemoryArea, PMM_REQUIRED_RESOURCES RequiredResources)
Definition: reqtools.c:83
VOID MmFreeCacheSectionPage(PVOID Context, MEMORY_AREA *MemoryArea, PVOID Address, PFN_NUMBER Page, SWAPENTRY SwapEntry, BOOLEAN Dirty)
Definition: data.c:663
PFN_NUMBER Page[2]
Definition: newmm.h:62
_In_ PMEMORY_AREA _In_ PVOID _In_ BOOLEAN Locked
Definition: newmm.h:207
VOID NTAPI MmFinalizeSegment(PMM_SECTION_SEGMENT Segment)
NTSTATUS NTAPI MmpPageOutPhysicalAddress(PFN_NUMBER Page)
Definition: swapout.c:345
VOID NTAPI MmDeleteSectionAssociation(PFN_NUMBER Page)
Definition: rmap.c:498
NTSTATUS NTAPI MmUnmapCacheViewInSystemSpace(PVOID Address)
unsigned char BOOLEAN
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
Definition: parser.c:48
Definition: bufpool.h:45
NTSTATUS NTAPI MmExtendCacheSection(PSECTION Section, PLARGE_INTEGER NewSize, BOOLEAN ExtendFile)
PFN_NUMBER Page
Definition: section.c:4756
VOID MmPageOutDeleteMapping(PVOID Context, PEPROCESS Process, PVOID Address)
NTSTATUS NTAPI MmSetSectionAssociation(PFN_NUMBER Page, PMM_SECTION_SEGMENT Segment, PLARGE_INTEGER Offset)
Definition: sptab.c:373
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
_Inout_ PVOID Segment
Definition: exfuncs.h:1101
PMM_SECTION_SEGMENT Segment
Definition: newmm.h:28
NTSTATUS NTAPI _MiWriteBackPage(PFILE_OBJECT FileObject, PLARGE_INTEGER Offset, ULONG Length, PFN_NUMBER Page, const char *File, int Line)
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
VOID NTAPI MmFreeSectionSegments(PFILE_OBJECT FileObject)
static USHORT ReadStatus(IN PUCHAR ReadDataPort)
Definition: hardware.c:128
LARGE_INTEGER FileOffset
Definition: newmm.h:27
VOID NTAPI MmFreePageTablesSectionSegment(PMM_SECTION_SEGMENT Segment, FREE_SECTION_PAGE_FUN FreePage)
Definition: sptab.c:299
#define _Inout_
Definition: no_sal2.h:162
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
* PFILE_OBJECT
Definition: iotypes.h:1998
FORCEINLINE BOOLEAN _MmTryToLockAddressSpace(IN PMMSUPPORT AddressSpace, const char *file, int line)
Definition: newmm.h:295
Definition: ncftp.h:79
#define _Post_notnull_
Definition: sal.h:701
_In_ WDFINTERRUPT _In_ WDF_INTERRUPT_POLICY _In_ WDF_INTERRUPT_PRIORITY Priority
Definition: wdfinterrupt.h:651
struct _MM_REQUIRED_RESOURCES * PMM_REQUIRED_RESOURCES
struct _MM_REQUIRED_RESOURCES MM_REQUIRED_RESOURCES
NTSTATUS NTAPI MiSwapInSectionPage(PMMSUPPORT AddressSpace, PMEMORY_AREA MemoryArea, PMM_REQUIRED_RESOURCES RequiredResources)
#define VOID
Definition: acefi.h:82
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
_Must_inspect_result_ _In_ USHORT NewSize
Definition: fltkernel.h:975
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T _In_ SECTION_INHERIT _In_ ULONG AllocationType
Definition: mmfuncs.h:404
VOID NTAPI MiInitializeSectionPageTable(PMM_SECTION_SEGMENT Segment)
Definition: sptab.c:165
NTSTATUS NTAPI MmUnmapViewOfCacheSegment(PMMSUPPORT AddressSpace, PVOID BaseAddress)
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define _In_
Definition: no_sal2.h:158
typedef NTSTATUS(NTAPI *AcquireResource)(PMMSUPPORT AddressSpace
ULONG_PTR SIZE_T
Definition: typedefs.h:80
_Success_(1) _When_(return
ULONG NTAPI MiCacheEvictPages(PMM_SECTION_SEGMENT Segment, ULONG Target)
Definition: swapout.c:590
NTSTATUS MmspWaitForFileLock(PFILE_OBJECT File)
Definition: section.c:908
BOOLEAN FASTCALL KeTryToAcquireGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:86
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:159
ULONG_PTR SWAPENTRY
Definition: mm.h:51
#define FORCEINLINE
Definition: wdftypes.h:67
unsigned int * PULONG
Definition: retypes.h:1
NTSTATUS(NTAPI * FaultHandler)(PMMSUPPORT AddressSpace, struct _MEMORY_AREA *MemoryArea, PVOID Address, struct _MM_REQUIRED_RESOURCES *Required)
Definition: newmm.h:47
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306
_Must_inspect_result_ _Outptr_result_bytebuffer_ ViewSize PVOID * MappedBase
Definition: mmfuncs.h:492
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
NTSTATUS NTAPI MiWriteSwapPage(PMMSUPPORT AddressSpace, PMEMORY_AREA MemoryArea, PMM_REQUIRED_RESOURCES Resources)
#define _When_(c, a)
Definition: no_sal2.h:38
SWAPENTRY SwapEntry
Definition: newmm.h:64
#define OUT
Definition: typedefs.h:40
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T ViewSize
Definition: mmfuncs.h:404
LARGE_INTEGER FileOffset
Definition: newmm.h:60
const char * File
Definition: newmm.h:65
unsigned int ULONG
Definition: retypes.h:1
#define const
Definition: zconf.h:230
KEVENT MmWaitPageEvent
Definition: section.c:66
struct _CACHE_SECTION_PAGE_TABLE CACHE_SECTION_PAGE_TABLE
NTSTATUS NTAPI _MiFlushMappedSection(PVOID BaseAddress, PLARGE_INTEGER BaseOffset, PLARGE_INTEGER FileSize, BOOLEAN Dirty, const char *File, int Line)
NTSTATUS NTAPI MmNotPresentFaultCacheSection(KPROCESSOR_MODE Mode, ULONG_PTR Address, BOOLEAN FromMdl)
Definition: File.h:15
NTSTATUS NTAPI MmCreateCacheSection(PSECTION *SectionObject, ACCESS_MASK DesiredAccess, POBJECT_ATTRIBUTES ObjectAttributes, PLARGE_INTEGER UMaximumSize, ULONG SectionPageProtection, ULONG AllocationAttributes, PFILE_OBJECT FileObject)
struct _MEMORY_AREA struct _MM_REQUIRED_RESOURCES * Required
Definition: newmm.h:38
NTSTATUS NTAPI MmMapCacheViewInSystemSpaceAtOffset(IN PMM_SECTION_SEGMENT Segment, OUT PVOID *MappedBase, IN PLARGE_INTEGER ViewOffset, IN OUT PULONG ViewSize)
NTSTATUS NTAPI MiWriteFilePage(PMMSUPPORT AddressSpace, PMEMORY_AREA MemoryArea, PMM_REQUIRED_RESOURCES Resources)
Definition: reqtools.c:271
NTSTATUS NTAPI MmPageOutPageFileView(PMMSUPPORT AddressSpace, PMEMORY_AREA MemoryArea, PVOID Address, PMM_REQUIRED_RESOURCES Required)
struct _MEMORY_AREA * MemoryArea
Definition: newmm.h:37
ULONG ACCESS_MASK
Definition: nt_native.h:40
NTSTATUS NTAPI MiWidenSegment(PMMSUPPORT AddressSpace, PMEMORY_AREA MemoryArea, PMM_REQUIRED_RESOURCES RequiredResources)
PFN_NUMBER NTAPI MmWithdrawSectionPage(PMM_SECTION_SEGMENT Segment, PLARGE_INTEGER FileOffset, BOOLEAN *Dirty)
Definition: swapout.c:87
#define ENTRIES_PER_ELEMENT
Definition: newmm.h:21
Definition: fci.c:126