ReactOS 0.4.15-dev-7924-g5949c20
mmsup.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
#include <mm/ARM3/miarm.h>
Include dependency graph for mmsup.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define MODULE_INVOLVED_IN_ARM3
 

Functions

NTSTATUS NTAPI MmMapUserAddressesToPage (IN PVOID BaseAddress, IN SIZE_T NumberOfBytes, IN PVOID PageAddress)
 
NTSTATUS NTAPI MmAdjustWorkingSetSize (IN SIZE_T WorkingSetMinimumInBytes, IN SIZE_T WorkingSetMaximumInBytes, IN ULONG SystemCache, IN BOOLEAN IncreaseOkay)
 
BOOLEAN NTAPI MmSetAddressRangeModified (IN PVOID Address, IN SIZE_T Length)
 
BOOLEAN NTAPI MmIsAddressValid (IN PVOID VirtualAddress)
 
BOOLEAN NTAPI MmIsNonPagedSystemAddressValid (IN PVOID VirtualAddress)
 
NTSTATUS NTAPI MmSetBankedSection (IN HANDLE ProcessHandle, IN PVOID VirtualAddress, IN ULONG BankLength, IN BOOLEAN ReadWriteBank, IN PVOID BankRoutine, IN PVOID Context)
 
BOOLEAN NTAPI MmIsRecursiveIoFault (VOID)
 
BOOLEAN NTAPI MmIsThisAnNtAsSystem (VOID)
 
MM_SYSTEMSIZE NTAPI MmQuerySystemSize (VOID)
 
NTSTATUS NTAPI MmCreateMirror (VOID)
 

Variables

SIZE_T MmMinimumWorkingSetSize
 
SIZE_T MmMaximumWorkingSetSize
 
SIZE_T MmPagesAboveWsMinimum
 

Macro Definition Documentation

◆ MODULE_INVOLVED_IN_ARM3

#define MODULE_INVOLVED_IN_ARM3

Definition at line 15 of file mmsup.c.

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file mmsup.c.

Function Documentation

◆ MmAdjustWorkingSetSize()

NTSTATUS NTAPI MmAdjustWorkingSetSize ( IN SIZE_T  WorkingSetMinimumInBytes,
IN SIZE_T  WorkingSetMaximumInBytes,
IN ULONG  SystemCache,
IN BOOLEAN  IncreaseOkay 
)

Definition at line 44 of file mmsup.c.

48{
49 SIZE_T MinimumWorkingSetSize, MaximumWorkingSetSize;
51 PMMSUPPORT Ws;
53
54 /* Check for special case: empty the working set */
55 if ((WorkingSetMinimumInBytes == -1) &&
56 (WorkingSetMaximumInBytes == -1))
57 {
60 }
61
62 /* Assume success */
64
65 /* Get the working set and lock it */
66 Ws = &PsGetCurrentProcess()->Vm;
68
69 /* Calculate the actual minimum and maximum working set size to set */
70 MinimumWorkingSetSize = (WorkingSetMinimumInBytes != 0) ?
71 (WorkingSetMinimumInBytes / PAGE_SIZE) : Ws->MinimumWorkingSetSize;
72 MaximumWorkingSetSize = (WorkingSetMaximumInBytes != 0) ?
73 (WorkingSetMaximumInBytes / PAGE_SIZE) : Ws->MaximumWorkingSetSize;
74
75 /* Check if the new maximum exceeds the global maximum */
76 if (MaximumWorkingSetSize > MmMaximumWorkingSetSize)
77 {
78 MaximumWorkingSetSize = MmMaximumWorkingSetSize;
80 }
81
82 /* Check if the new minimum is below the global minimum */
83 if (MinimumWorkingSetSize < MmMinimumWorkingSetSize)
84 {
85 MinimumWorkingSetSize = MmMinimumWorkingSetSize;
87 }
88
89 /* Check if the new minimum exceeds the new maximum */
90 if (MinimumWorkingSetSize > MaximumWorkingSetSize)
91 {
92 DPRINT1("MinimumWorkingSetSize (%lu) > MaximumWorkingSetSize (%lu)\n",
93 MinimumWorkingSetSize, MaximumWorkingSetSize);
95 goto Cleanup;
96 }
97
98 /* Calculate the minimum WS size adjustment and check if we increase */
99 Delta = MinimumWorkingSetSize - Ws->MinimumWorkingSetSize;
100 if (Delta > 0)
101 {
102 /* Is increasing ok? */
103 if (!IncreaseOkay)
104 {
105 DPRINT1("Privilege for WS size increase not held\n");
107 goto Cleanup;
108 }
109
110 /* Check if the number of available pages is large enough */
111 if (((SIZE_T)Delta / 1024) > (MmAvailablePages - 128))
112 {
113 DPRINT1("Not enough available pages\n");
115 goto Cleanup;
116 }
117
118 /* Check if there are enough resident available pages */
119 if ((SIZE_T)Delta >
121 {
122 DPRINT1("Not enough resident pages\n");
124 goto Cleanup;
125 }
126 }
127
128 /* Update resident available pages */
129 if (Delta != 0)
130 {
132 }
133
134 /* Calculate new pages above minimum WS size */
135 Delta += max((SSIZE_T)Ws->WorkingSetSize - MinimumWorkingSetSize, 0);
136
137 /* Subtract old pages above minimum WS size */
139
140 /* If it changed, add it to the global variable */
141 if (Delta != 0)
142 {
144 }
145
146 /* Set the new working set size */
147 Ws->MinimumWorkingSetSize = MinimumWorkingSetSize;
148 Ws->MaximumWorkingSetSize = MaximumWorkingSetSize;
149
150Cleanup:
151
152 /* Unlock the working set and return the status */
154 return Status;
155}
#define STATUS_PRIVILEGE_NOT_HELD
Definition: DriverTester.h:9
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
LONG_PTR SSIZE_T
Definition: basetsd.h:181
#define UNIMPLEMENTED
Definition: debug.h:115
static const WCHAR Cleanup[]
Definition: register.c:80
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
#define PAGE_SIZE
Definition: env_spec_w32.h:49
Status
Definition: gdiplustypes.h:25
#define InterlockedExchangeAddSizeT(a, b)
Definition: interlocked.h:196
FORCEINLINE VOID MiLockWorkingSet(IN PETHREAD Thread, IN PMMSUPPORT WorkingSet)
Definition: miarm.h:1265
FORCEINLINE VOID MiUnlockWorkingSet(IN PETHREAD Thread, IN PMMSUPPORT WorkingSet)
Definition: miarm.h:1351
SIZE_T MmSystemLockPagesCount
Definition: mdlsup.c:22
SIZE_T MmPagesAboveWsMinimum
Definition: mmsup.c:22
SIZE_T MmMinimumWorkingSetSize
Definition: mmsup.c:20
SIZE_T MmMaximumWorkingSetSize
Definition: mmsup.c:21
PFN_NUMBER MmResidentAvailablePages
Definition: freelist.c:27
PFN_NUMBER MmAvailablePages
Definition: freelist.c:26
#define STATUS_WORKING_SET_LIMIT_RANGE
Definition: ntstatus.h:116
#define STATUS_BAD_WORKING_SET_LIMIT
Definition: ntstatus.h:312
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
#define STATUS_SUCCESS
Definition: shellext.h:65
ULONG WorkingSetSize
Definition: mmtypes.h:957
ULONG MinimumWorkingSetSize
Definition: mmtypes.h:941
ULONG MaximumWorkingSetSize
Definition: mmtypes.h:942
#define max(a, b)
Definition: svc.c:63
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
static ULONG Delta
Definition: xboxvideo.c:33
#define PsGetCurrentProcess
Definition: psfuncs.h:17

Referenced by PspSetQuotaLimits().

◆ MmCreateMirror()

NTSTATUS NTAPI MmCreateMirror ( VOID  )

Definition at line 265 of file mmsup.c.

266{
269}

◆ MmIsAddressValid()

BOOLEAN NTAPI MmIsAddressValid ( IN PVOID  VirtualAddress)

Definition at line 174 of file mmsup.c.

175{
176#if _MI_PAGING_LEVELS >= 4
177 /* Check if the PXE is valid */
178 if (MiAddressToPxe(VirtualAddress)->u.Hard.Valid == 0) return FALSE;
179#endif
180
181#if _MI_PAGING_LEVELS >= 3
182 /* Check if the PPE is valid */
183 if (MiAddressToPpe(VirtualAddress)->u.Hard.Valid == 0) return FALSE;
184#endif
185
186#if _MI_PAGING_LEVELS >= 2
187 /* Check if the PDE is valid */
188 if (MiAddressToPde(VirtualAddress)->u.Hard.Valid == 0) return FALSE;
189#endif
190
191 /* Check if the PTE is valid */
192 if (MiAddressToPte(VirtualAddress)->u.Hard.Valid == 0) return FALSE;
193
194 /* This address is valid now, but it will only stay so if the caller holds
195 * the PFN lock */
196 return TRUE;
197}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
#define MiAddressToPte(x)
Definition: mmx86.c:19
#define MiAddressToPde(x)
Definition: mmx86.c:20
FORCEINLINE PMMPTE MiAddressToPpe(PVOID Address)
Definition: mm.h:161
FORCEINLINE PMMPTE MiAddressToPxe(PVOID Address)
Definition: mm.h:171
_Must_inspect_result_ _In_ WDFDMATRANSACTION _In_ PFN_WDF_PROGRAM_DMA _In_ WDF_DMA_DIRECTION _In_ PMDL _In_ PVOID VirtualAddress

Referenced by KdbCommand_Gdi_dumpht(), KdbCommand_Gdi_entry(), KdbCommand_Gdi_handle(), KdbIsMemoryValid(), marshal_nfs41_header(), marshal_nfs41_mount(), MiBuildPfnDatabaseFromPages(), MiDbgUnTranslatePhysicalAddress(), MiMakeSystemAddressValid(), MiMakeSystemAddressValidPfn(), MiSessionAddProcess(), MiSessionCreateInternal(), MiSessionRemoveProcess(), MiSetupPfnForPageTable(), MmCommitSessionMappedView(), MmDbgCopyMemory(), MmIsNonPagedSystemAddressValid(), MmMapViewInSessionSpace(), MmTrimUserMemory(), MmUnmapViewInSessionSpace(), and nfs41_invalidate_cache().

◆ MmIsNonPagedSystemAddressValid()

BOOLEAN NTAPI MmIsNonPagedSystemAddressValid ( IN PVOID  VirtualAddress)

Definition at line 204 of file mmsup.c.

205{
206 DPRINT1("WARNING: %s returns bogus result\n", __FUNCTION__);
208}
#define __FUNCTION__
Definition: types.h:116
BOOLEAN NTAPI MmIsAddressValid(IN PVOID VirtualAddress)
Definition: mmsup.c:174

Referenced by Ext2CreateMdl().

◆ MmIsRecursiveIoFault()

BOOLEAN NTAPI MmIsRecursiveIoFault ( VOID  )

Definition at line 231 of file mmsup.c.

232{
234
235 //
236 // If any of these is true, this is a recursive fault
237 //
238 return ((Thread->DisablePageFaultClustering) | (Thread->ForwardClusterOnly));
239}
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
UCHAR DisablePageFaultClustering
Definition: pstypes.h:1242

◆ MmIsThisAnNtAsSystem()

BOOLEAN NTAPI MmIsThisAnNtAsSystem ( VOID  )

Definition at line 246 of file mmsup.c.

247{
248 /* Return if this is a server system */
249 return MmProductType & 0xFF;
250}
ULONG MmProductType
Definition: mminit.c:325

Referenced by FsRtlInitializeTunnels(), PsChangeQuantumTable(), and UDFInitializeZones().

◆ MmMapUserAddressesToPage()

NTSTATUS NTAPI MmMapUserAddressesToPage ( IN PVOID  BaseAddress,
IN SIZE_T  NumberOfBytes,
IN PVOID  PageAddress 
)

Definition at line 31 of file mmsup.c.

34{
37}

◆ MmQuerySystemSize()

MM_SYSTEMSIZE NTAPI MmQuerySystemSize ( VOID  )

Definition at line 257 of file mmsup.c.

258{
259 /* Return the low, medium or high memory system type */
260 return MmSystemSize;
261}
MM_SYSTEMSIZE MmSystemSize
Definition: mminit.c:326

Referenced by CcInitializeCacheManager(), CdInitializeGlobalData(), DriverEntry(), PspInitPhase0(), RxInitializeWorkQueueDispatcher(), and UDFInitializeZones().

◆ MmSetAddressRangeModified()

BOOLEAN NTAPI MmSetAddressRangeModified ( IN PVOID  Address,
IN SIZE_T  Length 
)

Definition at line 162 of file mmsup.c.

164{
166 return FALSE;
167}

◆ MmSetBankedSection()

NTSTATUS NTAPI MmSetBankedSection ( IN HANDLE  ProcessHandle,
IN PVOID  VirtualAddress,
IN ULONG  BankLength,
IN BOOLEAN  ReadWriteBank,
IN PVOID  BankRoutine,
IN PVOID  Context 
)

Definition at line 215 of file mmsup.c.

221{
224}

Variable Documentation

◆ MmMaximumWorkingSetSize

SIZE_T MmMaximumWorkingSetSize

Definition at line 21 of file mmsup.c.

Referenced by MmAdjustWorkingSetSize().

◆ MmMinimumWorkingSetSize

SIZE_T MmMinimumWorkingSetSize

Definition at line 20 of file mmsup.c.

Referenced by MmAdjustWorkingSetSize().

◆ MmPagesAboveWsMinimum

SIZE_T MmPagesAboveWsMinimum

Definition at line 22 of file mmsup.c.

Referenced by MmAdjustWorkingSetSize().