Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

144 lines
2.8 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. setmodfy.c
  5. Abstract:
  6. This module contains the setting modify bit routine for memory management.
  7. i386 specific.
  8. Author:
  9. 10-Apr-1989
  10. Revision History:
  11. --*/
  12. #include "mi.h"
  13. VOID
  14. MiSetModifyBit (
  15. IN PMMPFN Pfn
  16. )
  17. /*++
  18. Routine Description:
  19. This routine sets the modify bit in the specified PFN element
  20. and deallocates any allocated page file space.
  21. Arguments:
  22. Pfn - Supplies the pointer to the PFN element to update.
  23. Return Value:
  24. None.
  25. Environment:
  26. Kernel mode, APCs disabled, Working set mutex held and PFN lock held.
  27. --*/
  28. {
  29. //
  30. // Set the modified field in the PFN database, also, if the physical
  31. // page is currently in a paging file, free up the page file space
  32. // as the contents are now worthless.
  33. //
  34. MI_SET_MODIFIED (Pfn, 1, 0x16);
  35. if (Pfn->OriginalPte.u.Soft.Prototype == 0) {
  36. //
  37. // This page is in page file format, deallocate the page file space.
  38. //
  39. MiReleasePageFileSpace (Pfn->OriginalPte);
  40. //
  41. // Change original PTE to indicate no page file space is reserved,
  42. // otherwise the space will be deallocated when the PTE is
  43. // deleted.
  44. //
  45. Pfn->OriginalPte.u.Soft.PageFileHigh = 0;
  46. }
  47. return;
  48. }
  49. ULONG
  50. FASTCALL
  51. MiDetermineUserGlobalPteMask (
  52. IN PMMPTE Pte
  53. )
  54. /*++
  55. Routine Description:
  56. Builds a mask to OR with the PTE frame field.
  57. This mask has the valid and access bits set and
  58. has the global and owner bits set based on the
  59. address of the PTE.
  60. ******************* NOTE *********************************************
  61. THIS ROUTINE DOES NOT CHECK FOR PDEs WHICH NEED TO BE
  62. SET GLOBAL AS IT ASSUMES PDEs FOR SYSTEM SPACE ARE
  63. PROPERLY SET AT INITIALIZATION TIME!
  64. Arguments:
  65. Pte - Supplies a pointer to the PTE in which to fill.
  66. Return Value:
  67. Mask to OR into the frame to make a valid PTE.
  68. Environment:
  69. Kernel mode, 386 specific.
  70. --*/
  71. {
  72. MMPTE Mask;
  73. Mask.u.Long = 0;
  74. Mask.u.Hard.Valid = 1;
  75. Mask.u.Hard.Accessed = 1;
  76. if (Pte <= MiHighestUserPte) {
  77. Mask.u.Hard.Owner = 1;
  78. } else if ((Pte < MiGetPteAddress (PTE_BASE)) ||
  79. (Pte >= MiGetPteAddress (MM_SYSTEM_CACHE_WORKING_SET))) {
  80. if (MI_IS_SESSION_PTE (Pte) == FALSE) {
  81. #if defined (_X86PAE_)
  82. if ((Pte < (PMMPTE)PDE_BASE) || (Pte > (PMMPTE)PDE_TOP))
  83. #endif
  84. Mask.u.Long |= MmPteGlobal.u.Long;
  85. }
  86. } else if ((Pte >= MiGetPdeAddress (NULL)) && (Pte <= MiHighestUserPde)) {
  87. Mask.u.Hard.Owner = 1;
  88. }
  89. //
  90. // Since the valid, accessed, global and owner bits are always in the
  91. // low dword of the PTE, returning a ULONG is ok.
  92. //
  93. return (ULONG)Mask.u.Long;
  94. }