ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

newmm.h
Go to the documentation of this file.
00001 #pragma once
00002 
00003 #include <internal/arch/mm.h>
00004 
00005 /* TYPES *********************************************************************/
00006 
00007 #define MM_WAIT_ENTRY            0x7ffffc00
00008 #define PFN_FROM_SSE(E)          ((PFN_NUMBER)((E) >> PAGE_SHIFT))
00009 #define IS_SWAP_FROM_SSE(E)      ((E) & 0x00000001)
00010 #define MM_IS_WAIT_PTE(E)        \
00011     (IS_SWAP_FROM_SSE(E) && SWAPENTRY_FROM_SSE(E) == MM_WAIT_ENTRY)
00012 #define MAKE_PFN_SSE(P)          ((ULONG_PTR)((P) << PAGE_SHIFT))
00013 #define SWAPENTRY_FROM_SSE(E)    ((E) >> 1)
00014 #define MAKE_SWAP_SSE(S)         (((ULONG_PTR)(S) << 1) | 0x1)
00015 #define DIRTY_SSE(E)             ((E) | 2)
00016 #define CLEAN_SSE(E)             ((E) & ~2)
00017 #define IS_DIRTY_SSE(E)          ((E) & 2)
00018 #define PAGE_FROM_SSE(E)         ((E) & 0xFFFFF000)
00019 #define SHARE_COUNT_FROM_SSE(E)  (((E) & 0x00000FFC) >> 2)
00020 #define MAX_SHARE_COUNT          0x3FF
00021 #define MAKE_SSE(P, C)           ((ULONG_PTR)((P) | ((C) << 2)))
00022 
00023 #define MM_SEGMENT_FINALIZE (0x40000000)
00024 
00025 #define RMAP_SEGMENT_MASK ~((ULONG_PTR)0xff)
00026 #define RMAP_IS_SEGMENT(x) (((ULONG_PTR)(x) & RMAP_SEGMENT_MASK) == RMAP_SEGMENT_MASK)
00027 
00028 #define MIN(x,y) (((x)<(y))?(x):(y))
00029 #define MAX(x,y) (((x)>(y))?(x):(y))
00030 
00031 /* Determine what's needed to make paged pool fit in this category.
00032  * it seems that something more is required to satisfy arm3. */
00033 #define BALANCER_CAN_EVICT(Consumer) \
00034     (((Consumer) == MC_USER) || \
00035      ((Consumer) == MC_CACHE))
00036 
00037 #define SEC_CACHE                           (0x20000000)
00038 
00039 #define MiWaitForPageEvent(Process,Address) do {                         \
00040     DPRINT("MiWaitForPageEvent %x:%x #\n", Process, Address);            \
00041     KeWaitForSingleObject(&MmWaitPageEvent, 0, KernelMode, FALSE, NULL); \
00042 } while(0)
00043 
00044 #define MiSetPageEvent(Process,Address) do {              \
00045     DPRINT("MiSetPageEvent %x:%x #\n",Process, Address);  \
00046     KeSetEvent(&MmWaitPageEvent, IO_NO_INCREMENT, FALSE); \
00047 } while(0)
00048 
00049 /* We store 8 bits of location with a page association */
00050 #define ENTRIES_PER_ELEMENT 256
00051 
00052 extern KEVENT MmWaitPageEvent;
00053 
00054 typedef struct _CACHE_SECTION_PAGE_TABLE
00055 {
00056     LARGE_INTEGER FileOffset;
00057     PMM_SECTION_SEGMENT Segment;
00058     ULONG Refcount;
00059     ULONG_PTR PageEntries[ENTRIES_PER_ELEMENT];
00060 } CACHE_SECTION_PAGE_TABLE, *PCACHE_SECTION_PAGE_TABLE;
00061 
00062 struct _MM_REQUIRED_RESOURCES;
00063 
00064 typedef NTSTATUS (NTAPI * AcquireResource)(
00065      PMMSUPPORT AddressSpace,
00066      struct _MEMORY_AREA *MemoryArea,
00067      struct _MM_REQUIRED_RESOURCES *Required);
00068 
00069 typedef NTSTATUS (NTAPI * NotPresentFaultHandler)(
00070     PMMSUPPORT AddressSpace,
00071     struct _MEMORY_AREA *MemoryArea,
00072     PVOID Address,
00073     BOOLEAN Locked,
00074     struct _MM_REQUIRED_RESOURCES *Required);
00075 
00076 typedef NTSTATUS (NTAPI * FaultHandler)(
00077     PMMSUPPORT AddressSpace,
00078     struct _MEMORY_AREA *MemoryArea,
00079     PVOID Address,
00080     struct _MM_REQUIRED_RESOURCES *Required);
00081 
00082 typedef struct _MM_REQUIRED_RESOURCES
00083 {
00084     ULONG Consumer;
00085     ULONG Amount;
00086     ULONG Offset;
00087     ULONG State;
00088     PVOID Context;
00089     LARGE_INTEGER FileOffset;
00090     AcquireResource DoAcquisition;
00091     PFN_NUMBER Page[2];
00092     PVOID Buffer[2];
00093     SWAPENTRY SwapEntry;
00094     const char *File;
00095     int Line;
00096 } MM_REQUIRED_RESOURCES, *PMM_REQUIRED_RESOURCES;
00097 
00098 NTSTATUS
00099 NTAPI
00100 MmCreateCacheSection(PROS_SECTION_OBJECT *SectionObject,
00101                      ACCESS_MASK DesiredAccess,
00102                      POBJECT_ATTRIBUTES ObjectAttributes,
00103                      PLARGE_INTEGER UMaximumSize,
00104                      ULONG SectionPageProtection,
00105                      ULONG AllocationAttributes,
00106                      PFILE_OBJECT FileObject);
00107 
00108 PFN_NUMBER
00109 NTAPI
00110 MmWithdrawSectionPage(PMM_SECTION_SEGMENT Segment,
00111                       PLARGE_INTEGER FileOffset,
00112                       BOOLEAN *Dirty);
00113 
00114 NTSTATUS
00115 NTAPI
00116 MmFinalizeSectionPageOut(PMM_SECTION_SEGMENT Segment,
00117                          PLARGE_INTEGER FileOffset,
00118                          PFN_NUMBER Page,
00119                          BOOLEAN Dirty);
00120 
00121 /* sptab.c *******************************************************************/
00122 
00123 VOID
00124 NTAPI
00125 MiInitializeSectionPageTable(PMM_SECTION_SEGMENT Segment);
00126 
00127 NTSTATUS
00128 NTAPI
00129 _MmSetPageEntrySectionSegment(PMM_SECTION_SEGMENT Segment,
00130                               PLARGE_INTEGER Offset,
00131                               ULONG_PTR Entry,
00132                               const char *file,
00133                               int line);
00134 
00135 ULONG_PTR
00136 NTAPI
00137 _MmGetPageEntrySectionSegment(PMM_SECTION_SEGMENT Segment,
00138                               PLARGE_INTEGER Offset,
00139                               const char *file,
00140                               int line);
00141 
00142 #define MmSetPageEntrySectionSegment(S,O,E) _MmSetPageEntrySectionSegment(S,O,E,__FILE__,__LINE__)
00143 
00144 #define MmGetPageEntrySectionSegment(S,O) _MmGetPageEntrySectionSegment(S,O,__FILE__,__LINE__)
00145 
00146 typedef VOID (NTAPI *FREE_SECTION_PAGE_FUN)(
00147     PMM_SECTION_SEGMENT Segment,
00148     PLARGE_INTEGER Offset);
00149 
00150 VOID
00151 NTAPI
00152 MmFreePageTablesSectionSegment(PMM_SECTION_SEGMENT Segment,
00153                                FREE_SECTION_PAGE_FUN FreePage);
00154 
00155 /* Yields a lock */
00156 PMM_SECTION_SEGMENT
00157 NTAPI
00158 MmGetSectionAssociation(PFN_NUMBER Page,
00159                         PLARGE_INTEGER Offset);
00160 
00161 NTSTATUS
00162 NTAPI
00163 MmSetSectionAssociation(PFN_NUMBER Page,
00164                         PMM_SECTION_SEGMENT Segment,
00165                         PLARGE_INTEGER Offset);
00166 
00167 VOID
00168 NTAPI
00169 MmDeleteSectionAssociation(PFN_NUMBER Page);
00170 
00171 NTSTATUS
00172 NTAPI
00173 MmpPageOutPhysicalAddress(PFN_NUMBER Page);
00174 
00175 /* io.c **********************************************************************/
00176 
00177 NTSTATUS
00178 MmspWaitForFileLock(PFILE_OBJECT File);
00179 
00180 NTSTATUS
00181 NTAPI
00182 MiSimpleRead(PFILE_OBJECT FileObject,
00183              PLARGE_INTEGER FileOffset,
00184              PVOID Buffer,
00185              ULONG Length,
00186              BOOLEAN Paging,
00187              PIO_STATUS_BLOCK ReadStatus);
00188 
00189 NTSTATUS
00190 NTAPI
00191 _MiSimpleWrite(PFILE_OBJECT FileObject,
00192                PLARGE_INTEGER FileOffset,
00193                PVOID Buffer,
00194                ULONG Length,
00195                PIO_STATUS_BLOCK ReadStatus,
00196                const char *file,
00197                int line);
00198 
00199 #define MiSimpleWrite(F,O,B,L,R) _MiSimpleWrite(F,O,B,L,R,__FILE__,__LINE__)
00200 
00201 NTSTATUS
00202 NTAPI
00203 _MiWriteBackPage(PFILE_OBJECT FileObject,
00204                  PLARGE_INTEGER Offset,
00205                  ULONG Length,
00206                  PFN_NUMBER Page,
00207                  const char *File,
00208                  int Line);
00209 
00210 #define MiWriteBackPage(F,O,L,P) _MiWriteBackPage(F,O,L,P,__FILE__,__LINE__)
00211 
00212 /* section.c *****************************************************************/
00213 
00214 NTSTATUS
00215 NTAPI
00216 MmAccessFaultCacheSection(KPROCESSOR_MODE Mode,
00217                           ULONG_PTR Address,
00218                           BOOLEAN FromMdl);
00219 
00220 NTSTATUS
00221 NTAPI
00222 MiReadFilePage(PMMSUPPORT AddressSpace,
00223                PMEMORY_AREA MemoryArea,
00224                PMM_REQUIRED_RESOURCES RequiredResources);
00225 
00226 NTSTATUS
00227 NTAPI
00228 MiGetOnePage(PMMSUPPORT AddressSpace,
00229              PMEMORY_AREA MemoryArea,
00230              PMM_REQUIRED_RESOURCES RequiredResources);
00231 
00232 NTSTATUS
00233 NTAPI
00234 MiSwapInPage(PMMSUPPORT AddressSpace,
00235              PMEMORY_AREA MemoryArea,
00236              PMM_REQUIRED_RESOURCES RequiredResources);
00237 
00238 NTSTATUS
00239 NTAPI
00240 MiWriteSwapPage(PMMSUPPORT AddressSpace,
00241                 PMEMORY_AREA MemoryArea,
00242                 PMM_REQUIRED_RESOURCES Resources);
00243 
00244 NTSTATUS
00245 NTAPI
00246 MiWriteFilePage(PMMSUPPORT AddressSpace,
00247                 PMEMORY_AREA MemoryArea,
00248                 PMM_REQUIRED_RESOURCES Resources);
00249 
00250 VOID
00251 NTAPI
00252 MiFreeSegmentPage(PMM_SECTION_SEGMENT Segment,
00253                   PLARGE_INTEGER FileOffset);
00254 
00255 NTSTATUS
00256 NTAPI
00257 MiCowCacheSectionPage(PMMSUPPORT AddressSpace,
00258                       PMEMORY_AREA MemoryArea,
00259                       PVOID Address,
00260                       BOOLEAN Locked,
00261                       PMM_REQUIRED_RESOURCES Required);
00262 
00263 NTSTATUS
00264 NTAPI
00265 MiZeroFillSection(PVOID Address,
00266                   PLARGE_INTEGER FileOffsetPtr,
00267                   ULONG Length);
00268 
00269 VOID
00270 MmPageOutDeleteMapping(PVOID Context,
00271                        PEPROCESS Process,
00272                        PVOID Address);
00273 
00274 VOID
00275 NTAPI
00276 _MmLockSectionSegment(PMM_SECTION_SEGMENT Segment,
00277                       const char *file,
00278                       int line);
00279 
00280 #define MmLockSectionSegment(x) _MmLockSectionSegment(x,__FILE__,__LINE__)
00281 
00282 VOID
00283 NTAPI
00284 _MmUnlockSectionSegment(PMM_SECTION_SEGMENT Segment,
00285                         const char *file,
00286                         int line);
00287 
00288 #define MmUnlockSectionSegment(x) _MmUnlockSectionSegment(x,__FILE__,__LINE__)
00289 
00290 VOID
00291 MmFreeCacheSectionPage(PVOID Context,
00292                        MEMORY_AREA* MemoryArea,
00293                        PVOID Address,
00294                        PFN_NUMBER Page,
00295                        SWAPENTRY SwapEntry,
00296                        BOOLEAN Dirty);
00297 
00298 NTSTATUS
00299 NTAPI
00300 _MiFlushMappedSection(PVOID BaseAddress,
00301                       PLARGE_INTEGER BaseOffset,
00302                       PLARGE_INTEGER FileSize,
00303                       BOOLEAN Dirty,
00304                       const char *File,
00305                       int Line);
00306 
00307 #define MiFlushMappedSection(A,O,S,D) _MiFlushMappedSection(A,O,S,D,__FILE__,__LINE__)
00308 
00309 VOID
00310 NTAPI
00311 MmFinalizeSegment(PMM_SECTION_SEGMENT Segment);
00312 
00313 VOID
00314 NTAPI
00315 MmFreeSectionSegments(PFILE_OBJECT FileObject);
00316 
00317 NTSTATUS
00318 NTAPI
00319 MmMapCacheViewInSystemSpaceAtOffset(IN PMM_SECTION_SEGMENT Segment,
00320                                     OUT PVOID* MappedBase,
00321                                     IN PLARGE_INTEGER ViewOffset,
00322                                     IN OUT PULONG ViewSize);
00323 
00324 NTSTATUS
00325 NTAPI
00326 _MiMapViewOfSegment(PMMSUPPORT AddressSpace,
00327                     PMM_SECTION_SEGMENT Segment,
00328                     PVOID* BaseAddress,
00329                     SIZE_T ViewSize,
00330                     ULONG Protect,
00331                     PLARGE_INTEGER ViewOffset,
00332                     ULONG AllocationType,
00333                     const char *file,
00334                     int line);
00335 
00336 #define MiMapViewOfSegment(AddressSpace,Segment,BaseAddress,ViewSize,Protect,ViewOffset,AllocationType) \
00337     _MiMapViewOfSegment(AddressSpace,Segment,BaseAddress,ViewSize,Protect,ViewOffset,AllocationType,__FILE__,__LINE__)
00338 
00339 NTSTATUS
00340 NTAPI
00341 MmUnmapViewOfCacheSegment(PMMSUPPORT AddressSpace,
00342                           PVOID BaseAddress);
00343 
00344 NTSTATUS
00345 NTAPI
00346 MmUnmapCacheViewInSystemSpace(PVOID Address);
00347 
00348 NTSTATUS
00349 NTAPI
00350 MmNotPresentFaultCachePage(PMMSUPPORT AddressSpace,
00351                            PMEMORY_AREA MemoryArea,
00352                            PVOID Address,
00353                            BOOLEAN Locked,
00354                            PMM_REQUIRED_RESOURCES Required);
00355 
00356 NTSTATUS
00357 NTAPI
00358 MmPageOutPageFileView(PMMSUPPORT AddressSpace,
00359                       PMEMORY_AREA MemoryArea,
00360                       PVOID Address,
00361                       PMM_REQUIRED_RESOURCES Required);
00362 
00363 FORCEINLINE
00364 BOOLEAN
00365 _MmTryToLockAddressSpace(IN PMMSUPPORT AddressSpace,
00366                          const char *file,
00367                          int line)
00368 {
00369     BOOLEAN Result = KeTryToAcquireGuardedMutex(&CONTAINING_RECORD(AddressSpace, EPROCESS, Vm)->AddressCreationLock);
00370     //DbgPrint("(%s:%d) Try Lock Address Space %x -> %s\n", file, line, AddressSpace, Result ? "true" : "false");
00371     return Result;
00372 }
00373 
00374 #define MmTryToLockAddressSpace(x) _MmTryToLockAddressSpace(x,__FILE__,__LINE__)
00375 
00376 NTSTATUS
00377 NTAPI
00378 MiWidenSegment(PMMSUPPORT AddressSpace,
00379                PMEMORY_AREA MemoryArea,
00380                PMM_REQUIRED_RESOURCES RequiredResources);
00381 
00382 NTSTATUS
00383 NTAPI
00384 MiSwapInSectionPage(PMMSUPPORT AddressSpace,
00385                     PMEMORY_AREA MemoryArea,
00386                     PMM_REQUIRED_RESOURCES RequiredResources);
00387 
00388 NTSTATUS
00389 NTAPI
00390 MmExtendCacheSection(PROS_SECTION_OBJECT Section,
00391                      PLARGE_INTEGER NewSize,
00392                      BOOLEAN ExtendFile);
00393 
00394 NTSTATUS
00395 NTAPI
00396 _MiFlushMappedSection(PVOID BaseAddress,
00397                       PLARGE_INTEGER BaseOffset,
00398                       PLARGE_INTEGER FileSize,
00399                       BOOLEAN Dirty,
00400                       const char *File,
00401                       int Line);
00402 
00403 #define MiFlushMappedSection(A,O,S,D) _MiFlushMappedSection(A,O,S,D,__FILE__,__LINE__)
00404 
00405 PVOID
00406 NTAPI
00407 MmGetSegmentRmap(PFN_NUMBER Page,
00408                  PULONG RawOffset);
00409 
00410 NTSTATUS
00411 NTAPI
00412 MmNotPresentFaultCacheSection(KPROCESSOR_MODE Mode,
00413                               ULONG_PTR Address,
00414                               BOOLEAN FromMdl);
00415 
00416 ULONG
00417 NTAPI
00418 MiCacheEvictPages(PMM_SECTION_SEGMENT Segment,
00419                   ULONG Target);
00420 
00421 NTSTATUS
00422 MiRosTrimCache(ULONG Target,
00423                ULONG Priority,
00424                PULONG NrFreed);

Generated on Sat May 26 2012 04:35:56 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.