ReactOS  0.4.15-dev-2996-gf777e6b
shutdown.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Kernel
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: ntoskrnl/mm/shutdown.c
5  * PURPOSE: Memory Manager Shutdown
6  * PROGRAMMERS:
7  */
8 
9 /* INCLUDES ******************************************************************/
10 
11 #include <ntoskrnl.h>
12 #define NDEBUG
13 #include <debug.h>
14 
15 #define MODULE_INVOLVED_IN_ARM3
16 #include "ARM3/miarm.h"
17 
18 /* PRIVATE FUNCTIONS *********************************************************/
19 
20 VOID
22 {
23  ULONG i;
25  BOOLEAN Dirty;
26 
27  /* Loop through all the paging files */
28  for (i = 0; i < MmNumberOfPagingFiles; i++)
29  {
30  /* Free page file name */
31  ASSERT(MmPagingFile[i]->PageFileName.Buffer != NULL);
32  ExFreePoolWithTag(MmPagingFile[i]->PageFileName.Buffer, TAG_MM);
34 
35  /* And close them */
37  }
38 
39  /* Loop through all the pages owned by the legacy Mm and page them out, if needed. */
40  /* We do it as long as there are dirty pages, since flushing can cause the FS to dirtify new ones. */
41  do
42  {
43  Dirty = FALSE;
44 
46  while (Page)
47  {
48  LARGE_INTEGER SegmentOffset;
50 
51  if (Segment)
52  {
53  if ((*Segment->Flags) & MM_DATAFILE_SEGMENT)
54  {
56 
58 
60  {
61  Dirty = TRUE;
62  MmCheckDirtySegment(Segment, &SegmentOffset, FALSE, TRUE);
63  }
64 
66  }
67 
68  MmDereferenceSegment(Segment);
69  }
70 
72  }
73  } while (Dirty);
74 }
75 
76 VOID
78 {
79  if (Phase == 0)
80  {
82  }
83  else if (Phase == 1)
84  {
85  ULONG i;
86 
87  /* Loop through all the paging files */
88  for (i = 0; i < MmNumberOfPagingFiles; i++)
89  {
90  /* And dereference them */
92  }
93  }
94  else
95  {
96  ASSERT(Phase == 2);
97 
99  }
100 }
#define IN
Definition: typedefs.h:39
#define MmGetPageEntrySectionSegment(S, O)
Definition: mm.h:1538
VOID MmShutdownSystem(IN ULONG Phase)
Definition: shutdown.c:77
#define TRUE
Definition: types.h:120
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
VOID MiShutdownSystem(VOID)
Definition: shutdown.c:21
BOOLEAN NTAPI MmCheckDirtySegment(PMM_SECTION_SEGMENT Segment, PLARGE_INTEGER Offset, BOOLEAN ForceDirty, BOOLEAN PageOut)
#define MmLockSectionSegment(x)
Definition: mm.h:1333
uint32_t ULONG_PTR
Definition: typedefs.h:65
HANDLE FileHandle
Definition: stats.c:38
ULONG PFN_NUMBER
Definition: ke.h:9
PFN_NUMBER NTAPI MmGetLRUNextUserPage(PFN_NUMBER PreviousPage, BOOLEAN MoveToLast)
Definition: freelist.c:125
#define TAG_MM
Definition: tag.h:136
#define IS_DIRTY_SSE(E)
Definition: mm.h:1313
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
PFN_NUMBER Page
Definition: section.c:4888
#define MmUnlockSectionSegment(x)
Definition: mm.h:1341
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
UNICODE_STRING PageFileName
Definition: mm.h:496
_Inout_ PVOID Segment
Definition: exfuncs.h:1101
#define ASSERT(a)
Definition: mode.c:44
PMM_SECTION_SEGMENT NTAPI MmGetSectionAssociation(PFN_NUMBER Page, PLARGE_INTEGER Offset)
Definition: sptab.c:360
#define ObDereferenceObject
Definition: obfuncs.h:203
#define MM_DATAFILE_SEGMENT
Definition: mm.h:227
PMMPAGING_FILE MmPagingFile[MAX_PAGING_FILES]
Definition: pagefile.c:40
PFN_NUMBER NTAPI MmGetLRUFirstUserPage(VOID)
Definition: freelist.c:45
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 const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define IS_SWAP_FROM_SSE(E)
Definition: mm.h:1305
#define NULL
Definition: types.h:112
ULONG MmNumberOfPagingFiles
Definition: pagefile.c:46
unsigned int ULONG
Definition: retypes.h:1
#define UNIMPLEMENTED
Definition: debug.h:115
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
base of all file and directory entries
Definition: entries.h:82