Leaked source code of windows server 2003
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.

251 lines
8.7 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. dataia64.c
  5. Abstract:
  6. This module contains the private hardware specific global storage for
  7. the memory management subsystem.
  8. Author:
  9. Lou Perazzoli (loup) 22-Jan-1990
  10. Revision History:
  11. Koichi Yamada (kyamada) 9-Jan-1996 : IA64 version based on i386 version
  12. --*/
  13. #include "mi.h"
  14. //
  15. // A zero Pte.
  16. //
  17. const MMPTE ZeroPte = { 0 };
  18. //
  19. // A kernel zero PTE.
  20. //
  21. const MMPTE ZeroKernelPte = {0x0};
  22. MMPTE ValidKernelPte = { MM_PTE_VALID_MASK |
  23. MM_PTE_CACHE |
  24. MM_PTE_WRITE_MASK |
  25. MM_PTE_EXECUTE_MASK |
  26. MM_PTE_ACCESS_MASK |
  27. MM_PTE_DIRTY_MASK |
  28. MM_PTE_EXC_DEFER};
  29. const MMPTE ValidKernelPteLocal = { MM_PTE_VALID_MASK |
  30. MM_PTE_CACHE |
  31. MM_PTE_WRITE_MASK |
  32. MM_PTE_ACCESS_MASK |
  33. MM_PTE_DIRTY_MASK |
  34. MM_PTE_EXC_DEFER};
  35. const MMPTE ValidUserPte = { MM_PTE_VALID_MASK |
  36. MM_PTE_CACHE |
  37. MM_PTE_WRITE_MASK |
  38. MM_PTE_OWNER_MASK |
  39. MM_PTE_ACCESS_MASK |
  40. MM_PTE_DIRTY_MASK |
  41. MM_PTE_EXC_DEFER};
  42. const MMPTE ValidPtePte = { MM_PTE_VALID_MASK |
  43. MM_PTE_CACHE |
  44. MM_PTE_WRITE_MASK |
  45. MM_PTE_ACCESS_MASK |
  46. MM_PTE_DIRTY_MASK };
  47. const MMPTE ValidPdePde = { MM_PTE_VALID_MASK |
  48. MM_PTE_CACHE |
  49. MM_PTE_WRITE_MASK |
  50. MM_PTE_ACCESS_MASK |
  51. MM_PTE_DIRTY_MASK };
  52. MMPTE ValidKernelPde = { MM_PTE_VALID_MASK |
  53. MM_PTE_CACHE |
  54. MM_PTE_WRITE_MASK |
  55. MM_PTE_ACCESS_MASK |
  56. MM_PTE_DIRTY_MASK };
  57. const MMPTE ValidKernelPdeLocal = { MM_PTE_VALID_MASK |
  58. MM_PTE_CACHE |
  59. MM_PTE_WRITE_MASK |
  60. MM_PTE_ACCESS_MASK |
  61. MM_PTE_DIRTY_MASK };
  62. MMPTE ValidPpePte = { MM_PTE_VALID_MASK |
  63. MM_PTE_CACHE |
  64. MM_PTE_WRITE_MASK |
  65. MM_PTE_ACCESS_MASK |
  66. MM_PTE_DIRTY_MASK };
  67. MMPTE DemandZeroPde = { MM_READWRITE << MM_PROTECT_FIELD_SHIFT };
  68. const MMPTE DemandZeroPte = { MM_READWRITE << MM_PROTECT_FIELD_SHIFT };
  69. const MMPTE TransitionPde = { MM_PTE_TRANSITION_MASK |
  70. MM_READWRITE << MM_PROTECT_FIELD_SHIFT };
  71. MMPTE PrototypePte = { MI_PTE_LOOKUP_NEEDED << 32 |
  72. MM_PTE_PROTOTYPE_MASK |
  73. MM_READWRITE << MM_PROTECT_FIELD_SHIFT };
  74. //
  75. // PTE which generates an access violation when referenced.
  76. //
  77. const MMPTE NoAccessPte = {MM_NOACCESS << MM_PROTECT_FIELD_SHIFT};
  78. //
  79. // Pool start and end.
  80. //
  81. PVOID MmNonPagedPoolStart;
  82. PVOID MmNonPagedPoolEnd = (PVOID)MM_NONPAGED_POOL_END;
  83. PVOID MmPagedPoolStart = (PVOID)MM_PAGED_POOL_START;
  84. PVOID MmPagedPoolEnd;
  85. //
  86. // Color tables for free and zeroed pages.
  87. //
  88. #if MM_MAXIMUM_NUMBER_OF_COLORS > 1
  89. MMPFNLIST MmFreePagesByPrimaryColor[2][MM_MAXIMUM_NUMBER_OF_COLORS];
  90. #endif
  91. PMMCOLOR_TABLES MmFreePagesByColor[2];
  92. //
  93. // Color tables for modified pages destined for the paging file.
  94. //
  95. MMPFNLIST MmModifiedPageListByColor[MM_MAXIMUM_NUMBER_OF_COLORS] = {
  96. 0, ModifiedPageList, MM_EMPTY_LIST, MM_EMPTY_LIST};
  97. //
  98. // Count of the number of modified pages destined for the paging file.
  99. //
  100. PFN_NUMBER MmTotalPagesForPagingFile = 0;
  101. //
  102. // Pte reserved for mapping pages for the debugger.
  103. //
  104. PMMPTE MmDebugPte;
  105. //
  106. // 16 PTEs reserved for mapping MDLs (64k max).
  107. //
  108. PMMPTE MmCrashDumpPte;
  109. //
  110. // Maximum size of system cache
  111. //
  112. ULONG MiMaximumSystemCacheSize;
  113. #if defined(_MIALT4K_)
  114. //
  115. // Map a IA32 compatible PTE protection from Pte.Protect field
  116. //
  117. ULONG MmProtectToPteMaskForIA32[32] = {
  118. MM_PTE_NOACCESS,
  119. MM_PTE_EXECUTE_READ | MM_PTE_CACHE,
  120. MM_PTE_EXECUTE_READ | MM_PTE_CACHE,
  121. MM_PTE_EXECUTE_READ | MM_PTE_CACHE,
  122. MM_PTE_EXECUTE_READWRITE | MM_PTE_CACHE,
  123. MM_PTE_EXECUTE_WRITECOPY | MM_PTE_CACHE,
  124. MM_PTE_EXECUTE_READWRITE | MM_PTE_CACHE,
  125. MM_PTE_EXECUTE_WRITECOPY | MM_PTE_CACHE,
  126. MM_PTE_NOACCESS,
  127. MM_PTE_NOCACHE | MM_PTE_EXECUTE_READ,
  128. MM_PTE_NOCACHE | MM_PTE_EXECUTE_READ,
  129. MM_PTE_NOCACHE | MM_PTE_EXECUTE_READ,
  130. MM_PTE_NOCACHE | MM_PTE_EXECUTE_READWRITE,
  131. MM_PTE_NOCACHE | MM_PTE_EXECUTE_WRITECOPY,
  132. MM_PTE_NOCACHE | MM_PTE_EXECUTE_READWRITE,
  133. MM_PTE_NOCACHE | MM_PTE_EXECUTE_WRITECOPY,
  134. MM_PTE_NOACCESS,
  135. MM_PTE_GUARD | MM_PTE_EXECUTE_READ | MM_PTE_CACHE,
  136. MM_PTE_GUARD | MM_PTE_EXECUTE_READ | MM_PTE_CACHE,
  137. MM_PTE_GUARD | MM_PTE_EXECUTE_READ | MM_PTE_CACHE,
  138. MM_PTE_GUARD | MM_PTE_EXECUTE_READWRITE | MM_PTE_CACHE,
  139. MM_PTE_GUARD | MM_PTE_EXECUTE_WRITECOPY | MM_PTE_CACHE,
  140. MM_PTE_GUARD | MM_PTE_EXECUTE_READWRITE | MM_PTE_CACHE,
  141. MM_PTE_GUARD | MM_PTE_EXECUTE_WRITECOPY | MM_PTE_CACHE,
  142. MM_PTE_NOACCESS,
  143. MM_PTE_NOCACHE | MM_PTE_GUARD | MM_PTE_EXECUTE_READ,
  144. MM_PTE_NOCACHE | MM_PTE_GUARD | MM_PTE_EXECUTE_READ,
  145. MM_PTE_NOCACHE | MM_PTE_GUARD | MM_PTE_EXECUTE_READ,
  146. MM_PTE_NOCACHE | MM_PTE_GUARD | MM_PTE_EXECUTE_READWRITE,
  147. MM_PTE_NOCACHE | MM_PTE_GUARD | MM_PTE_EXECUTE_WRITECOPY,
  148. MM_PTE_NOCACHE | MM_PTE_GUARD | MM_PTE_EXECUTE_READWRITE,
  149. MM_PTE_NOCACHE | MM_PTE_GUARD | MM_PTE_EXECUTE_WRITECOPY
  150. };
  151. ULONG MmProtectToPteMaskForSplit[32] = {
  152. MM_PTE_NOACCESS,
  153. MM_PTE_EXECUTE_READ | MM_PTE_CACHE,
  154. MM_PTE_EXECUTE_READ | MM_PTE_CACHE,
  155. MM_PTE_EXECUTE_READ | MM_PTE_CACHE,
  156. MM_PTE_EXECUTE_READ | MM_PTE_CACHE,
  157. MM_PTE_EXECUTE_WRITECOPY | MM_PTE_CACHE,
  158. MM_PTE_EXECUTE_READ | MM_PTE_CACHE,
  159. MM_PTE_EXECUTE_WRITECOPY | MM_PTE_CACHE,
  160. MM_PTE_NOACCESS,
  161. MM_PTE_NOCACHE | MM_PTE_EXECUTE_READ,
  162. MM_PTE_NOCACHE | MM_PTE_EXECUTE_READ,
  163. MM_PTE_NOCACHE | MM_PTE_EXECUTE_READ,
  164. MM_PTE_NOCACHE | MM_PTE_EXECUTE_READ,
  165. MM_PTE_NOCACHE | MM_PTE_EXECUTE_WRITECOPY,
  166. MM_PTE_NOCACHE | MM_PTE_EXECUTE_READWRITE,
  167. MM_PTE_NOCACHE | MM_PTE_EXECUTE_WRITECOPY,
  168. MM_PTE_NOACCESS,
  169. MM_PTE_GUARD | MM_PTE_EXECUTE_READ | MM_PTE_CACHE,
  170. MM_PTE_GUARD | MM_PTE_EXECUTE_READ | MM_PTE_CACHE,
  171. MM_PTE_GUARD | MM_PTE_EXECUTE_READ | MM_PTE_CACHE,
  172. MM_PTE_GUARD | MM_PTE_EXECUTE_READ | MM_PTE_CACHE,
  173. MM_PTE_GUARD | MM_PTE_EXECUTE_WRITECOPY | MM_PTE_CACHE,
  174. MM_PTE_GUARD | MM_PTE_EXECUTE_READ | MM_PTE_CACHE,
  175. MM_PTE_GUARD | MM_PTE_EXECUTE_WRITECOPY | MM_PTE_CACHE,
  176. MM_PTE_NOACCESS,
  177. MM_PTE_NOCACHE | MM_PTE_GUARD | MM_PTE_EXECUTE_READ,
  178. MM_PTE_NOCACHE | MM_PTE_GUARD | MM_PTE_EXECUTE_READ,
  179. MM_PTE_NOCACHE | MM_PTE_GUARD | MM_PTE_EXECUTE_READ,
  180. MM_PTE_NOCACHE | MM_PTE_GUARD | MM_PTE_EXECUTE_READ,
  181. MM_PTE_NOCACHE | MM_PTE_GUARD | MM_PTE_EXECUTE_WRITECOPY,
  182. MM_PTE_NOCACHE | MM_PTE_GUARD | MM_PTE_EXECUTE_READ,
  183. MM_PTE_NOCACHE | MM_PTE_GUARD | MM_PTE_EXECUTE_WRITECOPY
  184. };
  185. #endif