ReactOS 0.4.15-dev-8102-g108db8f
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
24
26{
32
34
39
46
52
54{
65 const char *File;
66 int Line;
68
74 PLARGE_INTEGER UMaximumSize,
78
83 BOOLEAN *Dirty);
84
90 BOOLEAN Dirty);
91
92/* sptab.c *******************************************************************/
93
94VOID
97
101
102VOID
103NTAPI
106
108NTAPI
112
113VOID
114NTAPI
116
118NTAPI
120
121/* io.c **********************************************************************/
122
125
127NTAPI
132 BOOLEAN Paging,
134
136NTAPI
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
148NTAPI
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
161NTAPI
164 BOOLEAN FromMdl);
165
167NTAPI
170 PMM_REQUIRED_RESOURCES RequiredResources);
171
173NTAPI
176 PMM_REQUIRED_RESOURCES RequiredResources);
177
179NTAPI
182 PMM_REQUIRED_RESOURCES RequiredResources);
183
185NTAPI
189
191NTAPI
195
196VOID
197NTAPI
200
204NTAPI
205MiCowCacheSectionPage (
211
212VOID
215 PVOID Address);
216
217VOID
222 SWAPENTRY SwapEntry,
223 BOOLEAN Dirty);
224
226NTAPI
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
236VOID
237NTAPI
239
240VOID
241NTAPI
243
245NTAPI
248 IN PLARGE_INTEGER ViewOffset,
250
252NTAPI
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
267NTAPI
270
272NTAPI
274
275_Success_(1)
278NTAPI
279MmNotPresentFaultCachePage (
285
287NTAPI
292
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
307NTAPI
310 PMM_REQUIRED_RESOURCES RequiredResources);
311
313NTAPI
316 PMM_REQUIRED_RESOURCES RequiredResources);
317
319NTAPI
322 BOOLEAN ExtendFile);
323
325NTAPI
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
335PVOID
336NTAPI
338 PULONG RawOffset);
339
341NTAPI
344 BOOLEAN FromMdl);
345
346ULONG
347NTAPI
349 ULONG Target);
350
354 PULONG NrFreed);
unsigned char BOOLEAN
#define VOID
Definition: acefi.h:82
LONG NTSTATUS
Definition: precomp.h:26
return
Definition: dirsup.c:529
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:160
Definition: bufpool.h:45
Definition: File.h:16
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NTSTATUS
Definition: precomp.h:21
static UCHAR ReadStatus(_In_ PUCHAR ReadDataPort)
Definition: hardware.c:167
_Must_inspect_result_ _In_ USHORT NewSize
Definition: fltkernel.h:975
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:223
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
_Must_inspect_result_ _Outptr_ PVOID * SectionObject
Definition: fsrtlfuncs.h:860
BOOLEAN FASTCALL KeTryToAcquireGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:86
_In_ ULONG Mode
Definition: hubbusif.h:303
#define _Success_(expr)
Definition: ms_sal.h:259
#define _Inout_
Definition: ms_sal.h:378
#define _Post_notnull_
Definition: ms_sal.h:701
#define _At_(target, annos)
Definition: ms_sal.h:244
#define _When_(expr, annos)
Definition: ms_sal.h:254
#define _In_
Definition: ms_sal.h:308
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_opt_ PLARGE_INTEGER _In_ ULONG SectionPageProtection
Definition: mmfuncs.h:363
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ ULONG AllocationAttributes
Definition: mmfuncs.h:364
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
_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:410
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T ViewSize
Definition: mmfuncs.h:408
NTSTATUS NTAPI MmExtendCacheSection(PSECTION Section, PLARGE_INTEGER NewSize, BOOLEAN ExtendFile)
NTSTATUS NTAPI MmAccessFaultCacheSection(KPROCESSOR_MODE Mode, ULONG_PTR Address, BOOLEAN FromMdl)
NTSTATUS NTAPI MmCreateCacheSection(PSECTION *SectionObject, ACCESS_MASK DesiredAccess, POBJECT_ATTRIBUTES ObjectAttributes, PLARGE_INTEGER UMaximumSize, ULONG SectionPageProtection, ULONG AllocationAttributes, PFILE_OBJECT FileObject)
NTSTATUS MiRosTrimCache(ULONG Target, ULONG Priority, PULONG NrFreed)
Definition: swapout.c:633
VOID NTAPI MmFinalizeSegment(PMM_SECTION_SEGMENT Segment)
VOID NTAPI MmFreePageTablesSectionSegment(PMM_SECTION_SEGMENT Segment, FREE_SECTION_PAGE_FUN FreePage)
Definition: sptab.c:321
NTSTATUS NTAPI MmFinalizeSectionPageOut(PMM_SECTION_SEGMENT Segment, PLARGE_INTEGER FileOffset, PFN_NUMBER Page, BOOLEAN Dirty)
Definition: swapout.c:165
NTSTATUS(NTAPI * NotPresentFaultHandler)(PMMSUPPORT AddressSpace, struct _MEMORY_AREA *MemoryArea, PVOID Address, BOOLEAN Locked, struct _MM_REQUIRED_RESOURCES *Required)
Definition: newmm.h:40
VOID NTAPI MmFreeSectionSegments(PFILE_OBJECT FileObject)
struct _CACHE_SECTION_PAGE_TABLE CACHE_SECTION_PAGE_TABLE
NTSTATUS MmspWaitForFileLock(PFILE_OBJECT File)
Definition: section.c:907
_In_ PMEMORY_AREA _In_ PVOID _In_ BOOLEAN _Inout_ PMM_REQUIRED_RESOURCES Required
Definition: newmm.h:210
_In_ PMEMORY_AREA MemoryArea
Definition: newmm.h:207
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
ULONG NTAPI MiCacheEvictPages(PMM_SECTION_SEGMENT Segment, ULONG Target)
Definition: swapout.c:590
PFN_NUMBER NTAPI MmWithdrawSectionPage(PMM_SECTION_SEGMENT Segment, PLARGE_INTEGER FileOffset, BOOLEAN *Dirty)
Definition: swapout.c:87
_In_ PMEMORY_AREA _In_ PVOID Address
Definition: newmm.h:208
PVOID NTAPI MmGetSegmentRmap(PFN_NUMBER Page, PULONG RawOffset)
Definition: rmap.c:468
NTSTATUS NTAPI MmUnmapViewOfCacheSegment(PMMSUPPORT AddressSpace, PVOID BaseAddress)
VOID(NTAPI * FREE_SECTION_PAGE_FUN)(PMM_SECTION_SEGMENT Segment, PLARGE_INTEGER Offset)
Definition: newmm.h:98
NTSTATUS NTAPI MmUnmapCacheViewInSystemSpace(PVOID Address)
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)
NTSTATUS NTAPI MiReadFilePage(PMMSUPPORT AddressSpace, PMEMORY_AREA MemoryArea, PMM_REQUIRED_RESOURCES RequiredResources)
Definition: reqtools.c:133
NTSTATUS NTAPI _MiSimpleWrite(PFILE_OBJECT FileObject, PLARGE_INTEGER FileOffset, PVOID Buffer, ULONG Length, PIO_STATUS_BLOCK ReadStatus, const char *file, int line)
VOID NTAPI MmDeleteSectionAssociation(PFN_NUMBER Page)
Definition: rmap.c:506
FORCEINLINE BOOLEAN _MmTryToLockAddressSpace(IN PMMSUPPORT AddressSpace, const char *file, int line)
Definition: newmm.h:295
#define ENTRIES_PER_ELEMENT
Definition: newmm.h:21
_In_ PMEMORY_AREA _In_ PVOID _In_ BOOLEAN Locked
Definition: newmm.h:209
NTSTATUS NTAPI MmpPageOutPhysicalAddress(PFN_NUMBER Page)
Definition: swapout.c:345
NTSTATUS NTAPI MmNotPresentFaultCacheSection(KPROCESSOR_MODE Mode, ULONG_PTR Address, BOOLEAN FromMdl)
NTSTATUS NTAPI MmPageOutPageFileView(PMMSUPPORT AddressSpace, PMEMORY_AREA MemoryArea, PVOID Address, PMM_REQUIRED_RESOURCES Required)
struct _CACHE_SECTION_PAGE_TABLE * PCACHE_SECTION_PAGE_TABLE
NTSTATUS(NTAPI * FaultHandler)(PMMSUPPORT AddressSpace, struct _MEMORY_AREA *MemoryArea, PVOID Address, struct _MM_REQUIRED_RESOURCES *Required)
Definition: newmm.h:47
NTSTATUS NTAPI MiSimpleRead(PFILE_OBJECT FileObject, PLARGE_INTEGER FileOffset, PVOID Buffer, ULONG Length, BOOLEAN Paging, PIO_STATUS_BLOCK ReadStatus)
Definition: io.c:109
NTSTATUS NTAPI _MiWriteBackPage(PFILE_OBJECT FileObject, PLARGE_INTEGER Offset, ULONG Length, PFN_NUMBER Page, const char *File, int Line)
NTSTATUS NTAPI MiSwapInSectionPage(PMMSUPPORT AddressSpace, PMEMORY_AREA MemoryArea, PMM_REQUIRED_RESOURCES RequiredResources)
NTSTATUS NTAPI MmSetSectionAssociation(PFN_NUMBER Page, PMM_SECTION_SEGMENT Segment, PLARGE_INTEGER Offset)
Definition: sptab.c:400
NTSTATUS NTAPI MiGetOnePage(PMMSUPPORT AddressSpace, PMEMORY_AREA MemoryArea, PMM_REQUIRED_RESOURCES RequiredResources)
Definition: reqtools.c:83
NTSTATUS NTAPI _MiFlushMappedSection(PVOID BaseAddress, PLARGE_INTEGER BaseOffset, PLARGE_INTEGER FileSize, BOOLEAN Dirty, const char *File, int Line)
KEVENT MmWaitPageEvent
Definition: fault.c:461
NTSTATUS(NTAPI * AcquireResource)(PMMSUPPORT AddressSpace, struct _MEMORY_AREA *MemoryArea, struct _MM_REQUIRED_RESOURCES *Required)
Definition: newmm.h:35
struct _MM_REQUIRED_RESOURCES MM_REQUIRED_RESOURCES
NTSTATUS NTAPI MiWidenSegment(PMMSUPPORT AddressSpace, PMEMORY_AREA MemoryArea, PMM_REQUIRED_RESOURCES RequiredResources)
struct _MM_REQUIRED_RESOURCES * PMM_REQUIRED_RESOURCES
VOID MmPageOutDeleteMapping(PVOID Context, PEPROCESS Process, PVOID Address)
VOID MmFreeCacheSectionPage(PVOID Context, MEMORY_AREA *MemoryArea, PVOID Address, PFN_NUMBER Page, SWAPENTRY SwapEntry, BOOLEAN Dirty)
Definition: data.c:663
NTSTATUS NTAPI MiSwapInPage(PMMSUPPORT AddressSpace, PMEMORY_AREA MemoryArea, PMM_REQUIRED_RESOURCES RequiredResources)
Definition: reqtools.c:220
NTSTATUS NTAPI MiWriteSwapPage(PMMSUPPORT AddressSpace, PMEMORY_AREA MemoryArea, PMM_REQUIRED_RESOURCES Resources)
VOID NTAPI MiFreeSegmentPage(PMM_SECTION_SEGMENT Segment, PLARGE_INTEGER FileOffset)
Definition: data.c:617
VOID NTAPI MiInitializeSectionPageTable(PMM_SECTION_SEGMENT Segment)
Definition: sptab.c:165
ULONG ACCESS_MASK
Definition: nt_native.h:40
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
_In_ PVOID _Out_opt_ BOOLEAN _Out_opt_ PPFN_NUMBER Page
Definition: mm.h:1306
ULONG_PTR SWAPENTRY
Definition: mm.h:57
ULONG PFN_NUMBER
Definition: ke.h:9
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:68
Definition: ncftp.h:79
PMM_SECTION_SEGMENT Segment
Definition: newmm.h:28
LARGE_INTEGER FileOffset
Definition: newmm.h:27
ULONG_PTR PageEntries[ENTRIES_PER_ELEMENT]
Definition: newmm.h:30
SWAPENTRY SwapEntry
Definition: newmm.h:64
LARGE_INTEGER FileOffset
Definition: newmm.h:60
const char * File
Definition: newmm.h:65
PFN_NUMBER Page[2]
Definition: newmm.h:62
AcquireResource DoAcquisition
Definition: newmm.h:61
Definition: fci.c:127
Definition: parser.c:49
uint32_t * PULONG
Definition: typedefs.h:59
#define NTAPI
Definition: typedefs.h:36
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
_In_ WDFINTERRUPT _In_ WDF_INTERRUPT_POLICY _In_ WDF_INTERRUPT_PRIORITY Priority
Definition: wdfinterrupt.h:655
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306
#define FORCEINLINE
Definition: wdftypes.h:67
_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:409
_Inout_ PVOID Segment
Definition: exfuncs.h:1101
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG AddressSpace
Definition: iofuncs.h:2274
* PFILE_OBJECT
Definition: iotypes.h:1998
@ FreePage
Definition: ketypes.h:416
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
_Must_inspect_result_ _Outptr_result_bytebuffer_ ViewSize PVOID * MappedBase
Definition: mmfuncs.h:492
#define const
Definition: zconf.h:233
_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:221