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.

3111 lines
73 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. mi386.h
  5. Abstract:
  6. This module contains the private data structures and procedure
  7. prototypes for the hardware dependent portion of the
  8. memory management system.
  9. This module is specifically tailored for the x86.
  10. Author:
  11. Lou Perazzoli (loup) 6-Jan-1990
  12. Landy Wang (landyw) 02-June-1997
  13. Revision History:
  14. --*/
  15. /*++
  16. Virtual Memory Layout on x86 is:
  17. +------------------------------------+
  18. 00000000 | |
  19. | |
  20. | |
  21. | User Mode Addresses |
  22. | |
  23. | All pages within this range |
  24. | are potentially accessible while |
  25. | the CPU is in USER mode. |
  26. | |
  27. | |
  28. +------------------------------------+
  29. 7ffff000 | 64k No Access Area |
  30. +------------------------------------+
  31. 80000000 | |
  32. | NTLDR loads the kernel, HAL and |
  33. | boot drivers here. The kernel |
  34. | then relocates the drivers to the |
  35. | system PTE area. |
  36. | |
  37. | Kernel mode access only. |
  38. | |
  39. | When possible, the PFN database & |
  40. | initial non paged pool is built |
  41. | here using large page mappings. |
  42. | |
  43. +------------------------------------+
  44. | |
  45. | Additional system PTEs, system |
  46. | cache or special pooling |
  47. | |
  48. +------------------------------------+
  49. | |
  50. | System mapped views. |
  51. | |
  52. +------------------------------------+
  53. | |
  54. | Session space. |
  55. | |
  56. +------------------------------------+
  57. C0000000 | Page Table Pages mapped through |
  58. | this 4mb region |
  59. | Kernel mode access only. |
  60. | |
  61. +------------------------------------+
  62. C0400000 | HyperSpace - working set lists |
  63. | and per process memory management |
  64. | structures mapped in this 4mb |
  65. | region. |
  66. | Kernel mode access only. |
  67. +------------------------------------+
  68. C0800000 | NO ACCESS AREA (4MB) |
  69. | |
  70. +------------------------------------+
  71. C0C00000 | System Cache Structures |
  72. | reside in this 4mb region |
  73. | Kernel mode access only. |
  74. +------------------------------------+
  75. C1000000 | System cache resides here. |
  76. | Kernel mode access only. |
  77. | |
  78. | |
  79. +------------------------------------+
  80. E1000000 | Start of paged system area |
  81. | Kernel mode access only. |
  82. | |
  83. | |
  84. +------------------------------------+
  85. | |
  86. | System PTE area - for mapping |
  87. | kernel thread stacks and MDLs |
  88. | that require system VAs. |
  89. | Kernel mode access only. |
  90. | |
  91. +------------------------------------+
  92. | |
  93. | NonPaged System area |
  94. | Kernel mode access only. |
  95. | |
  96. +------------------------------------+
  97. FFBE0000 | Crash Dump Driver area |
  98. | Kernel mode access only. |
  99. +------------------------------------+
  100. FFC00000 | Last 4mb reserved for HAL usage |
  101. +------------------------------------+
  102. --*/
  103. #define _MI_PAGING_LEVELS 2
  104. #define IMAGE_FILE_MACHINE_NATIVE IMAGE_FILE_MACHINE_I386
  105. #if !defined(_X86PAE_)
  106. //
  107. // Define empty list markers.
  108. //
  109. #define MM_EMPTY_LIST ((ULONG)0xFFFFFFFF) //
  110. #define MM_EMPTY_PTE_LIST ((ULONG)0xFFFFF) // N.B. tied to MMPTE definition
  111. #define MI_PTE_BASE_FOR_LOWEST_KERNEL_ADDRESS (MiGetPteAddress (0x00000000))
  112. #define MM_SESSION_SPACE_DEFAULT (0xA0000000)
  113. #define MM_SESSION_SPACE_DEFAULT_END (0xC0000000)
  114. //
  115. // This is the size of the region used by the loader.
  116. //
  117. extern ULONG_PTR MmBootImageSize;
  118. //
  119. // PAGE_SIZE for x86 is 4k, virtual page is 20 bits with a PAGE_SHIFT
  120. // byte offset.
  121. //
  122. #define MM_VIRTUAL_PAGE_FILLER 0
  123. #define MM_VIRTUAL_PAGE_SIZE 20
  124. //
  125. // Address space layout definitions.
  126. //
  127. #define MM_KSEG0_BASE ((ULONG)0x80000000)
  128. #define MM_KSEG2_BASE ((ULONG)0xA0000000)
  129. #define MM_PAGES_IN_KSEG0 ((MM_KSEG2_BASE - MM_KSEG0_BASE) >> PAGE_SHIFT)
  130. #define CODE_START MM_KSEG0_BASE
  131. #define CODE_END MM_KSEG2_BASE
  132. #define MM_SYSTEM_SPACE_START (0xC0800000)
  133. #define MM_SYSTEM_SPACE_END (0xFFFFFFFF)
  134. #define HYPER_SPACE ((PVOID)0xC0400000)
  135. #define HYPER_SPACE_END (0xC07fffff)
  136. #define MM_SYSTEM_VIEW_START (0xA0000000)
  137. #define MM_SYSTEM_VIEW_SIZE (16*1024*1024)
  138. #define MM_LOWEST_4MB_START ((32*1024*1024)/PAGE_SIZE) //32mb
  139. #define MM_DEFAULT_4MB_START (((1024*1024)/PAGE_SIZE)*4096) //4gb
  140. #define MM_HIGHEST_4MB_START (((1024*1024)/PAGE_SIZE)*4096) //4gb
  141. #define MM_USER_ADDRESS_RANGE_LIMIT 0xFFFFFFFF // user address range limit
  142. #define MM_MAXIMUM_ZERO_BITS 21 // maximum number of zero bits
  143. //
  144. // Define the start and maximum size for the system cache.
  145. // Maximum size is normally 512MB, but can be up to 512MB + 448MB = 960MB for
  146. // large system cache machines.
  147. //
  148. #define MM_SYSTEM_CACHE_WORKING_SET (0xC0C00000)
  149. #define MM_SYSTEM_CACHE_START (0xC1000000)
  150. #define MM_SYSTEM_CACHE_END (0xE1000000)
  151. //
  152. // Various resources like additional system PTEs or system cache views, etc,
  153. // can be allocated out of this virtual address range.
  154. //
  155. extern ULONG MiExtraResourceStart;
  156. extern ULONG MiExtraResourceEnd;
  157. extern ULONG_PTR MiUseMaximumSystemSpace;
  158. extern ULONG_PTR MiUseMaximumSystemSpaceEnd;
  159. extern ULONG MiNumberOfExtraSystemPdes;
  160. extern ULONG MiNumberOfExtraSystemPdes3;
  161. extern ULONG MiMaximumSystemExtraSystemPdes;
  162. extern ULONG MiMaximumSystemCacheSizeExtra;
  163. extern PVOID MiSystemCacheStartExtra;
  164. extern PVOID MiSystemCacheEndExtra;
  165. #define MM_SYSTEM_CACHE_END_EXTRA (0xC0000000)
  166. #define MM_PAGED_POOL_START (MmPagedPoolStart)
  167. #define MM_DEFAULT_PAGED_POOL_START (0xE1000000)
  168. #define MM_LOWEST_NONPAGED_SYSTEM_START ((PVOID)(0xEB000000))
  169. #define MmProtopte_Base ((ULONG)MmPagedPoolStart)
  170. #define MM_NONPAGED_POOL_END ((PVOID)(0xFFBE0000))
  171. #define MM_CRASH_DUMP_VA ((PVOID)(0xFFBE0000))
  172. #define MM_DEBUG_VA ((PVOID)0xFFBFF000)
  173. #define NON_PAGED_SYSTEM_END ((ULONG)0xFFFFFFF0) //quadword aligned.
  174. extern BOOLEAN MiWriteCombiningPtes;
  175. LOGICAL
  176. MiRecoverExtraPtes (
  177. VOID
  178. );
  179. //
  180. // Define absolute minimum and maximum count for system PTEs.
  181. //
  182. #define MM_MINIMUM_SYSTEM_PTES 7000
  183. #define MM_MAXIMUM_SYSTEM_PTES 50000
  184. #define MM_DEFAULT_SYSTEM_PTES 11000
  185. //
  186. // Pool limits
  187. //
  188. //
  189. // The maximum amount of nonpaged pool that can be initially created.
  190. //
  191. #define MM_MAX_INITIAL_NONPAGED_POOL ((ULONG)(128*1024*1024))
  192. //
  193. // The total amount of nonpaged pool (initial pool + expansion).
  194. //
  195. #define MM_MAX_ADDITIONAL_NONPAGED_POOL ((ULONG)(128*1024*1024))
  196. //
  197. // The maximum amount of paged pool that can be created.
  198. //
  199. #define MM_MAX_PAGED_POOL ((ULONG)MM_NONPAGED_POOL_END - (ULONG)MM_PAGED_POOL_START)
  200. #define MM_MAX_TOTAL_POOL (((ULONG)MM_NONPAGED_POOL_END) - ((ULONG)(MM_PAGED_POOL_START)))
  201. //
  202. // Structure layout definitions.
  203. //
  204. #define MM_PROTO_PTE_ALIGNMENT ((ULONG)PAGE_SIZE)
  205. #define PAGE_DIRECTORY_MASK ((ULONG)0x003FFFFF)
  206. #define MM_VA_MAPPED_BY_PDE (0x400000)
  207. #define MM_MINIMUM_VA_FOR_LARGE_PAGE MM_VA_MAPPED_BY_PDE
  208. #define LOWEST_IO_ADDRESS 0xa0000
  209. #define PTE_SHIFT 2
  210. //
  211. // The number of bits in a physical address.
  212. //
  213. #define PHYSICAL_ADDRESS_BITS 32
  214. #define MM_MAXIMUM_NUMBER_OF_COLORS (1)
  215. //
  216. // i386 does not require support for colored pages.
  217. //
  218. #define MM_NUMBER_OF_COLORS (1)
  219. //
  220. // Mask for obtaining color from a physical page number.
  221. //
  222. #define MM_COLOR_MASK (0)
  223. //
  224. // Boundary for aligned pages of like color upon.
  225. //
  226. #define MM_COLOR_ALIGNMENT (0)
  227. //
  228. // Mask for isolating color from virtual address.
  229. //
  230. #define MM_COLOR_MASK_VIRTUAL (0)
  231. //
  232. // Define 256k worth of secondary colors.
  233. //
  234. #define MM_SECONDARY_COLORS_DEFAULT (64)
  235. #define MM_SECONDARY_COLORS_MIN (2)
  236. #define MM_SECONDARY_COLORS_MAX (1024)
  237. //
  238. // Maximum number of paging files.
  239. //
  240. #define MAX_PAGE_FILES 16
  241. //
  242. // Hyper space definitions.
  243. //
  244. #define FIRST_MAPPING_PTE ((ULONG)0xC0400000)
  245. #define NUMBER_OF_MAPPING_PTES 255
  246. #define LAST_MAPPING_PTE \
  247. ((ULONG)((ULONG)FIRST_MAPPING_PTE + (NUMBER_OF_MAPPING_PTES * PAGE_SIZE)))
  248. #define COMPRESSION_MAPPING_PTE ((PMMPTE)((ULONG)LAST_MAPPING_PTE + PAGE_SIZE))
  249. #define IMAGE_MAPPING_PTE ((PMMPTE)((ULONG)COMPRESSION_MAPPING_PTE + PAGE_SIZE))
  250. #define NUMBER_OF_ZEROING_PTES 32
  251. //
  252. // This bitmap consumes 4K when booted /2GB and 6K when booted /3GB, thus
  253. // the working set list start is variable.
  254. //
  255. #define VAD_BITMAP_SPACE ((PVOID)((ULONG)IMAGE_MAPPING_PTE + PAGE_SIZE))
  256. #define WORKING_SET_LIST MmWorkingSetList
  257. #define MM_MAXIMUM_WORKING_SET MiMaximumWorkingSet
  258. extern ULONG MiMaximumWorkingSet;
  259. #define MmWsle ((PMMWSLE)((PUCHAR)WORKING_SET_LIST + sizeof(MMWSL)))
  260. #define MM_WORKING_SET_END ((ULONG)0xC07FF000)
  261. //
  262. // Define masks for fields within the PTE.
  263. ///
  264. #define MM_PTE_VALID_MASK 0x1
  265. #if defined(NT_UP)
  266. #define MM_PTE_WRITE_MASK 0x2
  267. #else
  268. #define MM_PTE_WRITE_MASK 0x800
  269. #endif
  270. #define MM_PTE_OWNER_MASK 0x4
  271. #define MM_PTE_WRITE_THROUGH_MASK 0x8
  272. #define MM_PTE_CACHE_DISABLE_MASK 0x10
  273. #define MM_PTE_ACCESS_MASK 0x20
  274. #if defined(NT_UP)
  275. #define MM_PTE_DIRTY_MASK 0x40
  276. #else
  277. #define MM_PTE_DIRTY_MASK 0x42
  278. #endif
  279. #define MM_PTE_LARGE_PAGE_MASK 0x80
  280. #define MM_PTE_GLOBAL_MASK 0x100
  281. #define MM_PTE_COPY_ON_WRITE_MASK 0x200
  282. #define MM_PTE_PROTOTYPE_MASK 0x400
  283. #define MM_PTE_TRANSITION_MASK 0x800
  284. //
  285. // Bit fields to or into PTE to make a PTE valid based on the
  286. // protection field of the invalid PTE.
  287. //
  288. #define MM_PTE_NOACCESS 0x0 // not expressable on i386
  289. #define MM_PTE_READONLY 0x0
  290. #define MM_PTE_READWRITE MM_PTE_WRITE_MASK
  291. #define MM_PTE_WRITECOPY 0x200 // read-only copy on write bit set.
  292. #define MM_PTE_EXECUTE 0x0 // read-only on i386
  293. #define MM_PTE_EXECUTE_READ 0x0
  294. #define MM_PTE_EXECUTE_READWRITE MM_PTE_WRITE_MASK
  295. #define MM_PTE_EXECUTE_WRITECOPY 0x200 // read-only copy on write bit set.
  296. #define MM_PTE_NOCACHE 0x010
  297. #define MM_PTE_GUARD 0x0 // not expressable on i386
  298. #define MM_PTE_CACHE 0x0
  299. #define MM_PROTECT_FIELD_SHIFT 5
  300. //
  301. // Bits available for the software working set index within the hardware PTE.
  302. //
  303. #define MI_MAXIMUM_PTE_WORKING_SET_INDEX 0
  304. //
  305. // Zero PTE
  306. //
  307. #define MM_ZERO_PTE 0
  308. //
  309. // Zero Kernel PTE
  310. //
  311. #define MM_ZERO_KERNEL_PTE 0
  312. //
  313. // A demand zero PTE with a protection or PAGE_READWRITE.
  314. //
  315. #define MM_DEMAND_ZERO_WRITE_PTE (MM_READWRITE << MM_PROTECT_FIELD_SHIFT)
  316. //
  317. // A demand zero PTE with a protection or PAGE_READWRITE for system space.
  318. //
  319. #define MM_KERNEL_DEMAND_ZERO_PTE (MM_READWRITE << MM_PROTECT_FIELD_SHIFT)
  320. //
  321. // A no access PTE for system space.
  322. //
  323. #define MM_KERNEL_NOACCESS_PTE (MM_NOACCESS << MM_PROTECT_FIELD_SHIFT)
  324. //
  325. // Kernel stack alignment requirements.
  326. //
  327. #define MM_STACK_ALIGNMENT 0x0
  328. #define MM_STACK_OFFSET 0x0
  329. //
  330. // System process definitions
  331. //
  332. #define PDE_PER_PAGE ((ULONG)1024)
  333. #define PTE_PER_PAGE ((ULONG)1024)
  334. #define PD_PER_SYSTEM ((ULONG)1)
  335. //
  336. // Number of page table pages for user addresses.
  337. //
  338. #define MM_USER_PAGE_TABLE_PAGES (768)
  339. //++
  340. //VOID
  341. //MI_MAKE_VALID_PTE (
  342. // OUT OUTPTE,
  343. // IN FRAME,
  344. // IN PMASK,
  345. // IN PPTE
  346. // );
  347. //
  348. // Routine Description:
  349. //
  350. // This macro makes a valid PTE from a page frame number, protection mask,
  351. // and owner.
  352. //
  353. // Arguments
  354. //
  355. // OUTPTE - Supplies the PTE in which to build the transition PTE.
  356. //
  357. // FRAME - Supplies the page frame number for the PTE.
  358. //
  359. // PMASK - Supplies the protection to set in the transition PTE.
  360. //
  361. // PPTE - Supplies a pointer to the PTE which is being made valid.
  362. // For prototype PTEs NULL should be specified.
  363. //
  364. // Return Value:
  365. //
  366. // None.
  367. //
  368. //--
  369. #define MI_MAKE_VALID_PTE(OUTPTE,FRAME,PMASK,PPTE) \
  370. (OUTPTE).u.Long = ((FRAME << 12) | \
  371. (MmProtectToPteMask[PMASK]) | \
  372. MiDetermineUserGlobalPteMask ((PMMPTE)PPTE));
  373. //++
  374. //VOID
  375. //MI_MAKE_VALID_PTE_TRANSITION (
  376. // IN OUT OUTPTE
  377. // IN PROTECT
  378. // );
  379. //
  380. // Routine Description:
  381. //
  382. // This macro takes a valid pte and turns it into a transition PTE.
  383. //
  384. // Arguments
  385. //
  386. // OUTPTE - Supplies the current valid PTE. This PTE is then
  387. // modified to become a transition PTE.
  388. //
  389. // PROTECT - Supplies the protection to set in the transition PTE.
  390. //
  391. // Return Value:
  392. //
  393. // None.
  394. //
  395. //--
  396. #define MI_MAKE_VALID_PTE_TRANSITION(OUTPTE,PROTECT) \
  397. (OUTPTE).u.Soft.Transition = 1; \
  398. (OUTPTE).u.Soft.Valid = 0; \
  399. (OUTPTE).u.Soft.Prototype = 0; \
  400. (OUTPTE).u.Soft.Protection = PROTECT;
  401. //++
  402. //VOID
  403. //MI_MAKE_TRANSITION_PTE (
  404. // OUT OUTPTE,
  405. // IN PAGE,
  406. // IN PROTECT,
  407. // IN PPTE
  408. // );
  409. //
  410. // Routine Description:
  411. //
  412. // This macro takes a valid pte and turns it into a transition PTE.
  413. //
  414. // Arguments
  415. //
  416. // OUTPTE - Supplies the PTE in which to build the transition PTE.
  417. //
  418. // PAGE - Supplies the page frame number for the PTE.
  419. //
  420. // PROTECT - Supplies the protection to set in the transition PTE.
  421. //
  422. // PPTE - Supplies a pointer to the PTE, this is used to determine
  423. // the owner of the PTE.
  424. //
  425. // Return Value:
  426. //
  427. // None.
  428. //
  429. //--
  430. #define MI_MAKE_TRANSITION_PTE(OUTPTE,PAGE,PROTECT,PPTE) \
  431. (OUTPTE).u.Long = 0; \
  432. (OUTPTE).u.Trans.PageFrameNumber = PAGE; \
  433. (OUTPTE).u.Trans.Transition = 1; \
  434. (OUTPTE).u.Trans.Protection = PROTECT; \
  435. (OUTPTE).u.Trans.Owner = MI_DETERMINE_OWNER(PPTE);
  436. //++
  437. //VOID
  438. //MI_MAKE_TRANSITION_PTE_VALID (
  439. // OUT OUTPTE,
  440. // IN PPTE
  441. // );
  442. //
  443. // Routine Description:
  444. //
  445. // This macro takes a transition pte and makes it a valid PTE.
  446. //
  447. // Arguments
  448. //
  449. // OUTPTE - Supplies the PTE in which to build the valid PTE.
  450. //
  451. // PPTE - Supplies a pointer to the transition PTE.
  452. //
  453. // Return Value:
  454. //
  455. // None.
  456. //
  457. //--
  458. #define MI_MAKE_TRANSITION_PTE_VALID(OUTPTE,PPTE) \
  459. ASSERT (((PPTE)->u.Hard.Valid == 0) && \
  460. ((PPTE)->u.Trans.Prototype == 0) && \
  461. ((PPTE)->u.Trans.Transition == 1)); \
  462. (OUTPTE).u.Long = (((PPTE)->u.Long & ~0xFFF) | \
  463. (MmProtectToPteMask[(PPTE)->u.Trans.Protection]) | \
  464. MiDetermineUserGlobalPteMask ((PMMPTE)PPTE));
  465. //++
  466. //VOID
  467. //MI_MAKE_TRANSITION_PROTOPTE_VALID (
  468. // OUT OUTPTE,
  469. // IN PPTE
  470. // );
  471. //
  472. // Routine Description:
  473. //
  474. // This macro takes a transition prototype PTE (in paged pool) and
  475. // makes it a valid PTE. Because we know this is a prototype PTE and
  476. // not a pagetable PTE, this can directly or in the global bit. This
  477. // makes a measurable performance gain since every instruction counts
  478. // when holding the PFN lock.
  479. //
  480. // Arguments
  481. //
  482. // OUTPTE - Supplies the PTE in which to build the valid PTE.
  483. //
  484. // PPTE - Supplies a pointer to the transition PTE.
  485. //
  486. // Return Value:
  487. //
  488. // None.
  489. //
  490. //--
  491. #define MI_MAKE_TRANSITION_PROTOPTE_VALID(OUTPTE,PPTE) \
  492. ASSERT (((PPTE)->u.Hard.Valid == 0) && \
  493. ((PPTE)->u.Trans.Prototype == 0) && \
  494. ((PPTE)->u.Trans.Transition == 1)); \
  495. (OUTPTE).u.Long = (((PPTE)->u.Long & ~0xFFF) | \
  496. (MmProtectToPteMask[(PPTE)->u.Trans.Protection]) | \
  497. (MmPteGlobal.u.Long)); \
  498. (OUTPTE).u.Hard.Valid = 1; \
  499. (OUTPTE).u.Hard.Accessed = 1;
  500. #define MI_FAULT_STATUS_INDICATES_EXECUTION(_FaultStatus) 0
  501. #define MI_FAULT_STATUS_INDICATES_WRITE(_FaultStatus) (_FaultStatus & 0x1)
  502. #define MI_CLEAR_FAULT_STATUS(_FaultStatus) (_FaultStatus = 0)
  503. #define MI_IS_PTE_EXECUTABLE(_TempPte) (1)
  504. //++
  505. //++
  506. //VOID
  507. //MI_SET_PTE_IN_WORKING_SET (
  508. // OUT PMMPTE PTE,
  509. // IN ULONG WSINDEX
  510. // );
  511. //
  512. // Routine Description:
  513. //
  514. // This macro inserts the specified working set index into the argument PTE.
  515. // Since the i386 PTE has no free bits nothing needs to be done on this
  516. // architecture.
  517. //
  518. // Arguments
  519. //
  520. // OUTPTE - Supplies the PTE in which to insert the working set index.
  521. //
  522. // WSINDEX - Supplies the working set index for the PTE.
  523. //
  524. // Return Value:
  525. //
  526. // None.
  527. //
  528. //--
  529. #define MI_SET_PTE_IN_WORKING_SET(PTE, WSINDEX)
  530. //++
  531. //ULONG WsIndex
  532. //MI_GET_WORKING_SET_FROM_PTE(
  533. // IN PMMPTE PTE
  534. // );
  535. //
  536. // Routine Description:
  537. //
  538. // This macro returns the working set index from the argument PTE.
  539. // Since the i386 PTE has no free bits nothing needs to be done on this
  540. // architecture.
  541. //
  542. // Arguments
  543. //
  544. // PTE - Supplies the PTE to extract the working set index from.
  545. //
  546. // Return Value:
  547. //
  548. // This macro returns the working set index for the argument PTE.
  549. //
  550. //--
  551. #define MI_GET_WORKING_SET_FROM_PTE(PTE) 0
  552. //++
  553. //VOID
  554. //MI_SET_PTE_WRITE_COMBINE (
  555. // IN MMPTE PTE
  556. // );
  557. //
  558. // Routine Description:
  559. //
  560. // This macro takes a valid PTE and enables WriteCombining as the
  561. // caching state. Note that the PTE bits may only be set this way
  562. // if the Page Attribute Table is present and the PAT has been
  563. // initialized to provide Write Combining.
  564. //
  565. // If either of the above conditions is not satisfied, then
  566. // the macro enables WEAK UC (PCD = 1, PWT = 0) in the PTE.
  567. //
  568. // Arguments
  569. //
  570. // PTE - Supplies a valid PTE.
  571. //
  572. // Return Value:
  573. //
  574. // None.
  575. //
  576. //--
  577. //
  578. #define MI_SET_PTE_WRITE_COMBINE(PTE) \
  579. { \
  580. if (MiWriteCombiningPtes == TRUE) { \
  581. ((PTE).u.Hard.CacheDisable = 0); \
  582. ((PTE).u.Hard.WriteThrough = 1); \
  583. } else { \
  584. ((PTE).u.Hard.CacheDisable = 1); \
  585. ((PTE).u.Hard.WriteThrough = 0); \
  586. } \
  587. }
  588. #define MI_SET_LARGE_PTE_WRITE_COMBINE(PTE) MI_SET_PTE_WRITE_COMBINE(PTE)
  589. //++
  590. //VOID
  591. //MI_PREPARE_FOR_NONCACHED (
  592. // IN MI_PFN_CACHE_ATTRIBUTE CacheAttribute
  593. // );
  594. //
  595. // Routine Description:
  596. //
  597. // This macro prepares the system prior to noncached PTEs being created.
  598. //
  599. // Note the entire TB must be flushed on all processors because there may
  600. // be stale system PTE (or hyperspace or zeropage) mappings in the TB which
  601. // may refer to the same physical page but with a different cache attribute.
  602. //
  603. // Arguments
  604. //
  605. // CacheAttribute - Supplies the cache attribute the PTEs will be filled
  606. // with.
  607. //
  608. // Return Value:
  609. //
  610. // None.
  611. //
  612. //--
  613. #define MI_PREPARE_FOR_NONCACHED(_CacheAttribute) \
  614. if (_CacheAttribute != MiCached) { \
  615. KeFlushEntireTb (FALSE, TRUE); \
  616. KeInvalidateAllCaches (); \
  617. }
  618. //++
  619. //VOID
  620. //MI_SWEEP_CACHE (
  621. // IN MI_PFN_CACHE_ATTRIBUTE CacheAttribute,
  622. // IN PVOID StartVa,
  623. // IN ULONG NumberOfBytes
  624. // );
  625. //
  626. // Routine Description:
  627. //
  628. // This macro prepares the system prior to noncached PTEs being created.
  629. // This does nothing on x86.
  630. //
  631. // Arguments
  632. //
  633. // CacheAttribute - Supplies the cache attribute the new PTEs were filled
  634. // with.
  635. //
  636. // StartVa - Supplies the starting address that's been mapped.
  637. //
  638. // NumberOfBytes - Supplies the number of bytes that have been mapped.
  639. //
  640. // Return Value:
  641. //
  642. // None.
  643. //
  644. //--
  645. #define MI_SWEEP_CACHE(_CacheAttribute,_StartVa,_NumberOfBytes)
  646. //++
  647. //VOID
  648. //MI_SET_PTE_DIRTY (
  649. // IN MMPTE PTE
  650. // );
  651. //
  652. // Routine Description:
  653. //
  654. // This macro sets the dirty bit(s) in the specified PTE.
  655. //
  656. // Arguments
  657. //
  658. // PTE - Supplies the PTE to set dirty.
  659. //
  660. // Return Value:
  661. //
  662. // None.
  663. //
  664. //--
  665. #define MI_SET_PTE_DIRTY(PTE) (PTE).u.Long |= HARDWARE_PTE_DIRTY_MASK
  666. //++
  667. //VOID
  668. //MI_SET_PTE_CLEAN (
  669. // IN MMPTE PTE
  670. // );
  671. //
  672. // Routine Description:
  673. //
  674. // This macro clears the dirty bit(s) in the specified PTE.
  675. //
  676. // Arguments
  677. //
  678. // PTE - Supplies the PTE to set clear.
  679. //
  680. // Return Value:
  681. //
  682. // None.
  683. //
  684. //--
  685. #define MI_SET_PTE_CLEAN(PTE) (PTE).u.Long &= ~HARDWARE_PTE_DIRTY_MASK
  686. //++
  687. //VOID
  688. //MI_IS_PTE_DIRTY (
  689. // IN MMPTE PTE
  690. // );
  691. //
  692. // Routine Description:
  693. //
  694. // This macro checks the dirty bit(s) in the specified PTE.
  695. //
  696. // Arguments
  697. //
  698. // PTE - Supplies the PTE to check.
  699. //
  700. // Return Value:
  701. //
  702. // TRUE if the page is dirty (modified), FALSE otherwise.
  703. //
  704. //--
  705. #define MI_IS_PTE_DIRTY(PTE) ((PTE).u.Hard.Dirty != 0)
  706. //++
  707. //VOID
  708. //MI_SET_GLOBAL_BIT_IF_SYSTEM (
  709. // OUT OUTPTE,
  710. // IN PPTE
  711. // );
  712. //
  713. // Routine Description:
  714. //
  715. // This macro sets the global bit if the pointer PTE is within
  716. // system space.
  717. //
  718. // Arguments
  719. //
  720. // OUTPTE - Supplies the PTE in which to build the valid PTE.
  721. //
  722. // PPTE - Supplies a pointer to the PTE becoming valid.
  723. //
  724. // Return Value:
  725. //
  726. // None.
  727. //
  728. //--
  729. #define MI_SET_GLOBAL_BIT_IF_SYSTEM(OUTPTE,PPTE) \
  730. if ((((PMMPTE)PPTE) > MiHighestUserPte) && \
  731. ((((PMMPTE)PPTE) <= MiGetPteAddress (PTE_BASE)) || \
  732. (((PMMPTE)PPTE) >= MiGetPteAddress (MM_SYSTEM_CACHE_WORKING_SET)))) { \
  733. (OUTPTE).u.Long |= MmPteGlobal.u.Long; \
  734. } \
  735. else { \
  736. (OUTPTE).u.Long &= ~MmPteGlobal.u.Long; \
  737. }
  738. //++
  739. //VOID
  740. //MI_SET_GLOBAL_STATE (
  741. // IN MMPTE PTE,
  742. // IN ULONG STATE
  743. // );
  744. //
  745. // Routine Description:
  746. //
  747. // This macro sets the global bit in the PTE. if the pointer PTE is within
  748. //
  749. // Arguments
  750. //
  751. // PTE - Supplies the PTE to set global state into.
  752. //
  753. // STATE - Supplies 1 if global, 0 if not.
  754. //
  755. // Return Value:
  756. //
  757. // None.
  758. //
  759. //--
  760. #define MI_SET_GLOBAL_STATE(PTE,STATE) \
  761. if (STATE) { \
  762. (PTE).u.Long |= MmPteGlobal.u.Long; \
  763. } \
  764. else { \
  765. (PTE).u.Long &= ~MmPteGlobal.u.Long; \
  766. }
  767. //++
  768. //VOID
  769. //MI_ENABLE_CACHING (
  770. // IN MMPTE PTE
  771. // );
  772. //
  773. // Routine Description:
  774. //
  775. // This macro takes a valid PTE and sets the caching state to be
  776. // enabled. This is performed by clearing the PCD and PWT bits in the PTE.
  777. //
  778. // Semantics of the overlap between PCD, PWT, and the
  779. // USWC memory type in the MTRR are:
  780. //
  781. // PCD PWT Mtrr Mem Type Effective Memory Type
  782. // 1 0 USWC USWC
  783. // 1 1 USWC UC
  784. //
  785. // Arguments
  786. //
  787. // PTE - Supplies a valid PTE.
  788. //
  789. // Return Value:
  790. //
  791. // None.
  792. //
  793. //--
  794. #define MI_ENABLE_CACHING(PTE) \
  795. { \
  796. ((PTE).u.Hard.CacheDisable = 0); \
  797. ((PTE).u.Hard.WriteThrough = 0); \
  798. }
  799. //++
  800. //VOID
  801. //MI_DISABLE_CACHING (
  802. // IN MMPTE PTE
  803. // );
  804. //
  805. // Routine Description:
  806. //
  807. // This macro takes a valid PTE and sets the caching state to be
  808. // disabled. This is performed by setting the PCD and PWT bits in the PTE.
  809. //
  810. // Semantics of the overlap between PCD, PWT, and the
  811. // USWC memory type in the MTRR are:
  812. //
  813. // PCD PWT Mtrr Mem Type Effective Memory Type
  814. // 1 0 USWC USWC
  815. // 1 1 USWC UC
  816. //
  817. // Since an effective memory type of UC is desired here,
  818. // the WT bit is set.
  819. //
  820. // Arguments
  821. //
  822. // PTE - Supplies a pointer to the valid PTE.
  823. //
  824. // Return Value:
  825. //
  826. // None.
  827. //
  828. //--
  829. #define MI_DISABLE_CACHING(PTE) \
  830. { \
  831. ((PTE).u.Hard.CacheDisable = 1); \
  832. ((PTE).u.Hard.WriteThrough = 1); \
  833. }
  834. #define MI_DISABLE_LARGE_PTE_CACHING(PTE) MI_DISABLE_CACHING(PTE)
  835. //++
  836. //BOOLEAN
  837. //MI_IS_CACHING_DISABLED (
  838. // IN PMMPTE PPTE
  839. // );
  840. //
  841. // Routine Description:
  842. //
  843. // This macro takes a valid PTE and returns TRUE if caching is
  844. // disabled.
  845. //
  846. // Arguments
  847. //
  848. // PPTE - Supplies a pointer to the valid PTE.
  849. //
  850. // Return Value:
  851. //
  852. // TRUE if caching is disabled, FALSE if it is enabled.
  853. //
  854. //--
  855. #define MI_IS_CACHING_DISABLED(PPTE) \
  856. ((PPTE)->u.Hard.CacheDisable == 1)
  857. //++
  858. //VOID
  859. //MI_SET_PFN_DELETED (
  860. // IN PMMPFN PPFN
  861. // );
  862. //
  863. // Routine Description:
  864. //
  865. // This macro takes a pointer to a PFN element and indicates that
  866. // the PFN is no longer in use.
  867. //
  868. // Arguments
  869. //
  870. // PPTE - Supplies a pointer to the PFN element.
  871. //
  872. // Return Value:
  873. //
  874. // none.
  875. //
  876. //--
  877. #define MI_SET_PFN_DELETED(PPFN) \
  878. PPFN->PteAddress = (PMMPTE)(((ULONG_PTR)(PPFN->PteAddress)) | 0x1);
  879. //++
  880. //VOID
  881. //MI_MARK_PFN_UNDELETED (
  882. // IN PMMPFN PPFN
  883. // );
  884. //
  885. // Routine Description:
  886. //
  887. // This macro takes a pointer to a deleted PFN element and mark that
  888. // the PFN is not deleted.
  889. //
  890. // Arguments
  891. //
  892. // PPTE - Supplies a pointer to the PFN element.
  893. //
  894. // Return Value:
  895. //
  896. // none.
  897. //
  898. //--
  899. #define MI_MARK_PFN_UNDELETED(PPFN) \
  900. PPFN->PteAddress = (PMMPTE)((ULONG_PTR)PPFN->PteAddress & ~0x1);
  901. //++
  902. //BOOLEAN
  903. //MI_IS_PFN_DELETED (
  904. // IN PMMPFN PPFN
  905. // );
  906. //
  907. // Routine Description:
  908. //
  909. // This macro takes a pointer to a PFN element and determines if
  910. // the PFN is no longer in use.
  911. //
  912. // Arguments
  913. //
  914. // PPTE - Supplies a pointer to the PFN element.
  915. //
  916. // Return Value:
  917. //
  918. // TRUE if PFN is no longer used, FALSE if it is still being used.
  919. //
  920. //--
  921. #define MI_IS_PFN_DELETED(PPFN) \
  922. ((ULONG_PTR)(PPFN)->PteAddress & 0x1)
  923. //++
  924. //VOID
  925. //MI_CHECK_PAGE_ALIGNMENT (
  926. // IN ULONG PAGE,
  927. // IN PMMPTE PPTE
  928. // );
  929. //
  930. // Routine Description:
  931. //
  932. // This macro takes a PFN element number (Page) and checks to see
  933. // if the virtual alignment for the previous address of the page
  934. // is compatible with the new address of the page. If they are
  935. // not compatible, the D cache is flushed.
  936. //
  937. // Arguments
  938. //
  939. // PAGE - Supplies the PFN element.
  940. // PPTE - Supplies a pointer to the new PTE which will contain the page.
  941. //
  942. // Return Value:
  943. //
  944. // none.
  945. //
  946. //--
  947. // does nothing on i386.
  948. #define MI_CHECK_PAGE_ALIGNMENT(PAGE,PPTE)
  949. //++
  950. //VOID
  951. //MI_INITIALIZE_HYPERSPACE_MAP (
  952. // VOID
  953. // );
  954. //
  955. // Routine Description:
  956. //
  957. // This macro initializes the PTEs reserved for double mapping within
  958. // hyperspace.
  959. //
  960. // Arguments
  961. //
  962. // None.
  963. //
  964. // Return Value:
  965. //
  966. // None.
  967. //
  968. //--
  969. // does nothing on i386.
  970. #define MI_INITIALIZE_HYPERSPACE_MAP(INDEX)
  971. //++
  972. //ULONG
  973. //MI_GET_PAGE_COLOR_FROM_PTE (
  974. // IN PMMPTE PTEADDRESS
  975. // );
  976. //
  977. // Routine Description:
  978. //
  979. // This macro determines the page's color based on the PTE address
  980. // that maps the page.
  981. //
  982. // Arguments
  983. //
  984. // PTEADDRESS - Supplies the PTE address the page is (or was) mapped at.
  985. //
  986. // Return Value:
  987. //
  988. // The page's color.
  989. //
  990. //--
  991. #define MI_GET_PAGE_COLOR_FROM_PTE(PTEADDRESS) \
  992. ((ULONG)((MI_SYSTEM_PAGE_COLOR++) & MmSecondaryColorMask))
  993. //++
  994. //ULONG
  995. //MI_GET_PAGE_COLOR_FROM_VA (
  996. // IN PVOID ADDRESS
  997. // );
  998. //
  999. // Routine Description:
  1000. //
  1001. // This macro determines the page's color based on the PTE address
  1002. // that maps the page.
  1003. //
  1004. // Arguments
  1005. //
  1006. // ADDRESS - Supplies the address the page is (or was) mapped at.
  1007. //
  1008. // Return Value:
  1009. //
  1010. // The page's color.
  1011. //
  1012. //--
  1013. #define MI_GET_PAGE_COLOR_FROM_VA(ADDRESS) \
  1014. ((ULONG)((MI_SYSTEM_PAGE_COLOR++) & MmSecondaryColorMask))
  1015. //++
  1016. //ULONG
  1017. //MI_GET_PAGE_COLOR_FROM_SESSION (
  1018. // IN PMM_SESSION_SPACE SessionSpace
  1019. // );
  1020. //
  1021. // Routine Description:
  1022. //
  1023. // This macro determines the page's color based on the PTE address
  1024. // that maps the page.
  1025. //
  1026. // Arguments
  1027. //
  1028. // SessionSpace - Supplies the session space the page will be mapped into.
  1029. //
  1030. // Return Value:
  1031. //
  1032. // The page's color.
  1033. //
  1034. //--
  1035. #define MI_GET_PAGE_COLOR_FROM_SESSION(_SessionSpace) \
  1036. ((ULONG)((_SessionSpace->Color++) & MmSecondaryColorMask))
  1037. //++
  1038. //ULONG
  1039. //MI_PAGE_COLOR_PTE_PROCESS (
  1040. // IN PMMPTE PTE,
  1041. // IN PUSHORT COLOR
  1042. // );
  1043. //
  1044. // Routine Description:
  1045. //
  1046. // Select page color for this process.
  1047. //
  1048. // Arguments
  1049. //
  1050. // PTE Not used.
  1051. // COLOR Value from which color is determined. This
  1052. // variable is incremented.
  1053. //
  1054. // Return Value:
  1055. //
  1056. // Page color.
  1057. //
  1058. //--
  1059. #define MI_PAGE_COLOR_PTE_PROCESS(PTE,COLOR) \
  1060. ((ULONG)((*(COLOR))++) & MmSecondaryColorMask)
  1061. //++
  1062. //ULONG
  1063. //MI_PAGE_COLOR_VA_PROCESS (
  1064. // IN PVOID ADDRESS,
  1065. // IN PEPROCESS COLOR
  1066. // );
  1067. //
  1068. // Routine Description:
  1069. //
  1070. // This macro determines the page's color based on the PTE address
  1071. // that maps the page.
  1072. //
  1073. // Arguments
  1074. //
  1075. // ADDRESS - Supplies the address the page is (or was) mapped at.
  1076. //
  1077. // Return Value:
  1078. //
  1079. // The page's color.
  1080. //
  1081. //--
  1082. #define MI_PAGE_COLOR_VA_PROCESS(ADDRESS,COLOR) \
  1083. ((ULONG)((*(COLOR))++) & MmSecondaryColorMask)
  1084. //++
  1085. //ULONG
  1086. //MI_GET_NEXT_COLOR (
  1087. // IN ULONG COLOR
  1088. // );
  1089. //
  1090. // Routine Description:
  1091. //
  1092. // This macro returns the next color in the sequence.
  1093. //
  1094. // Arguments
  1095. //
  1096. // COLOR - Supplies the color to return the next of.
  1097. //
  1098. // Return Value:
  1099. //
  1100. // Next color in sequence.
  1101. //
  1102. //--
  1103. #define MI_GET_NEXT_COLOR(COLOR) ((COLOR + 1) & MM_COLOR_MASK)
  1104. //++
  1105. //ULONG
  1106. //MI_GET_PREVIOUS_COLOR (
  1107. // IN ULONG COLOR
  1108. // );
  1109. //
  1110. // Routine Description:
  1111. //
  1112. // This macro returns the previous color in the sequence.
  1113. //
  1114. // Arguments
  1115. //
  1116. // COLOR - Supplies the color to return the previous of.
  1117. //
  1118. // Return Value:
  1119. //
  1120. // Previous color in sequence.
  1121. //
  1122. //--
  1123. #define MI_GET_PREVIOUS_COLOR(COLOR) (0)
  1124. #define MI_GET_SECONDARY_COLOR(PAGE,PFN) (PAGE & MmSecondaryColorMask)
  1125. #define MI_GET_COLOR_FROM_SECONDARY(SECONDARY_COLOR) (0)
  1126. //++
  1127. //VOID
  1128. //MI_GET_MODIFIED_PAGE_BY_COLOR (
  1129. // OUT ULONG PAGE,
  1130. // IN ULONG COLOR
  1131. // );
  1132. //
  1133. // Routine Description:
  1134. //
  1135. // This macro returns the first page destined for a paging
  1136. // file with the desired color. It does NOT remove the page
  1137. // from its list.
  1138. //
  1139. // Arguments
  1140. //
  1141. // PAGE - Returns the page located, the value MM_EMPTY_LIST is
  1142. // returned if there is no page of the specified color.
  1143. //
  1144. // COLOR - Supplies the color of page to locate.
  1145. //
  1146. // Return Value:
  1147. //
  1148. // none.
  1149. //
  1150. //--
  1151. #define MI_GET_MODIFIED_PAGE_BY_COLOR(PAGE,COLOR) \
  1152. PAGE = MmModifiedPageListByColor[COLOR].Flink
  1153. //++
  1154. //VOID
  1155. //MI_GET_MODIFIED_PAGE_ANY_COLOR (
  1156. // OUT ULONG PAGE,
  1157. // IN OUT ULONG COLOR
  1158. // );
  1159. //
  1160. // Routine Description:
  1161. //
  1162. // This macro returns the first page destined for a paging
  1163. // file with the desired color. If not page of the desired
  1164. // color exists, all colored lists are searched for a page.
  1165. // It does NOT remove the page from its list.
  1166. //
  1167. // Arguments
  1168. //
  1169. // PAGE - Returns the page located, the value MM_EMPTY_LIST is
  1170. // returned if there is no page of the specified color.
  1171. //
  1172. // COLOR - Supplies the color of page to locate and returns the
  1173. // color of the page located.
  1174. //
  1175. // Return Value:
  1176. //
  1177. // none.
  1178. //
  1179. //--
  1180. #define MI_GET_MODIFIED_PAGE_ANY_COLOR(PAGE,COLOR) \
  1181. { \
  1182. if (MmTotalPagesForPagingFile == 0) { \
  1183. PAGE = MM_EMPTY_LIST; \
  1184. } else { \
  1185. PAGE = MmModifiedPageListByColor[COLOR].Flink; \
  1186. } \
  1187. }
  1188. //++
  1189. //VOID
  1190. //MI_MAKE_VALID_PTE_WRITE_COPY (
  1191. // IN OUT PMMPTE PTE
  1192. // );
  1193. //
  1194. // Routine Description:
  1195. //
  1196. // This macro checks to see if the PTE indicates that the
  1197. // page is writable and if so it clears the write bit and
  1198. // sets the copy-on-write bit.
  1199. //
  1200. // Arguments
  1201. //
  1202. // PTE - Supplies the PTE to operate upon.
  1203. //
  1204. // Return Value:
  1205. //
  1206. // None.
  1207. //
  1208. //--
  1209. #if defined(NT_UP)
  1210. #define MI_MAKE_VALID_PTE_WRITE_COPY(PPTE) \
  1211. if ((PPTE)->u.Hard.Write == 1) { \
  1212. (PPTE)->u.Hard.CopyOnWrite = 1; \
  1213. (PPTE)->u.Hard.Write = 0; \
  1214. }
  1215. #else
  1216. #define MI_MAKE_VALID_PTE_WRITE_COPY(PPTE) \
  1217. if ((PPTE)->u.Hard.Write == 1) { \
  1218. (PPTE)->u.Hard.CopyOnWrite = 1; \
  1219. (PPTE)->u.Hard.Write = 0; \
  1220. (PPTE)->u.Hard.Writable = 0; \
  1221. }
  1222. #endif
  1223. #define MI_PTE_OWNER_USER 1
  1224. #define MI_PTE_OWNER_KERNEL 0
  1225. //++
  1226. //ULONG
  1227. //MI_DETERMINE_OWNER (
  1228. // IN MMPTE PPTE
  1229. // );
  1230. //
  1231. // Routine Description:
  1232. //
  1233. // This macro examines the virtual address of the PTE and determines
  1234. // if the PTE resides in system space or user space.
  1235. //
  1236. // Arguments
  1237. //
  1238. // PTE - Supplies the PTE to operate upon.
  1239. //
  1240. // Return Value:
  1241. //
  1242. // 1 if the owner is USER_MODE, 0 if the owner is KERNEL_MODE.
  1243. //
  1244. //--
  1245. #define MI_DETERMINE_OWNER(PPTE) \
  1246. ((((PPTE) <= MiHighestUserPte) || \
  1247. ((PPTE) >= MiGetPdeAddress(NULL) && \
  1248. ((PPTE) <= MiHighestUserPde))) ? MI_PTE_OWNER_USER : MI_PTE_OWNER_KERNEL)
  1249. //++
  1250. //VOID
  1251. //MI_SET_ACCESSED_IN_PTE (
  1252. // IN OUT MMPTE PPTE,
  1253. // IN ULONG ACCESSED
  1254. // );
  1255. //
  1256. // Routine Description:
  1257. //
  1258. // This macro sets the ACCESSED field in the PTE.
  1259. //
  1260. // Arguments
  1261. //
  1262. // PTE - Supplies the PTE to operate upon.
  1263. //
  1264. // Return Value:
  1265. //
  1266. // None
  1267. //
  1268. //--
  1269. #define MI_SET_ACCESSED_IN_PTE(PPTE,ACCESSED) \
  1270. ((PPTE)->u.Hard.Accessed = ACCESSED)
  1271. //++
  1272. //ULONG
  1273. //MI_GET_ACCESSED_IN_PTE (
  1274. // IN OUT MMPTE PPTE
  1275. // );
  1276. //
  1277. // Routine Description:
  1278. //
  1279. // This macro returns the state of the ACCESSED field in the PTE.
  1280. //
  1281. // Arguments
  1282. //
  1283. // PTE - Supplies the PTE to operate upon.
  1284. //
  1285. // Return Value:
  1286. //
  1287. // The state of the ACCESSED field.
  1288. //
  1289. //--
  1290. #define MI_GET_ACCESSED_IN_PTE(PPTE) ((PPTE)->u.Hard.Accessed)
  1291. //++
  1292. //VOID
  1293. //MI_SET_OWNER_IN_PTE (
  1294. // IN PMMPTE PPTE
  1295. // IN ULONG OWNER
  1296. // );
  1297. //
  1298. // Routine Description:
  1299. //
  1300. // This macro sets the owner field in the PTE.
  1301. //
  1302. // Arguments
  1303. //
  1304. // PTE - Supplies the PTE to operate upon.
  1305. //
  1306. // Return Value:
  1307. //
  1308. // None.
  1309. //
  1310. //--
  1311. #define MI_SET_OWNER_IN_PTE(PPTE,OWNER) ((PPTE)->u.Hard.Owner = OWNER)
  1312. //
  1313. // bit mask to clear out fields in a PTE to or in prototype pte offset.
  1314. //
  1315. #define CLEAR_FOR_PROTO_PTE_ADDRESS ((ULONG)0x701)
  1316. //
  1317. // bit mask to clear out fields in a PTE to or in paging file location.
  1318. //
  1319. #define CLEAR_FOR_PAGE_FILE 0x000003E0
  1320. //++
  1321. //VOID
  1322. //MI_SET_PAGING_FILE_INFO (
  1323. // OUT MMPTE OUTPTE,
  1324. // IN MMPTE PPTE,
  1325. // IN ULONG FILEINFO,
  1326. // IN ULONG OFFSET
  1327. // );
  1328. //
  1329. // Routine Description:
  1330. //
  1331. // This macro sets into the specified PTE the supplied information
  1332. // to indicate where the backing store for the page is located.
  1333. //
  1334. // Arguments
  1335. //
  1336. // OUTPTE - Supplies the PTE in which to store the result.
  1337. //
  1338. // PTE - Supplies the PTE to operate upon.
  1339. //
  1340. // FILEINFO - Supplies the number of the paging file.
  1341. //
  1342. // OFFSET - Supplies the offset into the paging file.
  1343. //
  1344. // Return Value:
  1345. //
  1346. // None.
  1347. //
  1348. //--
  1349. #define MI_SET_PAGING_FILE_INFO(OUTPTE,PPTE,FILEINFO,OFFSET) \
  1350. (OUTPTE).u.Long = (PPTE).u.Long; \
  1351. (OUTPTE).u.Long &= CLEAR_FOR_PAGE_FILE; \
  1352. (OUTPTE).u.Long |= ((FILEINFO << 1) | (OFFSET << 12));
  1353. //++
  1354. //PMMPTE
  1355. //MiPteToProto (
  1356. // IN OUT MMPTE PPTE,
  1357. // IN ULONG FILEINFO,
  1358. // IN ULONG OFFSET
  1359. // );
  1360. //
  1361. // Routine Description:
  1362. //
  1363. // This macro returns the address of the corresponding prototype which
  1364. // was encoded earlier into the supplied PTE.
  1365. //
  1366. // NOTE THAT A PROTOPTE CAN ONLY RESIDE IN PAGED POOL!!!!!!
  1367. //
  1368. // MAX SIZE = 2^(2+7+21) = 2^30 = 1GB.
  1369. //
  1370. // NOTE that the valid bit must be zero!
  1371. //
  1372. // Arguments
  1373. //
  1374. // lpte - Supplies the PTE to operate upon.
  1375. //
  1376. // Return Value:
  1377. //
  1378. // Pointer to the prototype PTE that backs this PTE.
  1379. //
  1380. //--
  1381. #define MiPteToProto(lpte) (PMMPTE)((PMMPTE)(((((lpte)->u.Long) >> 11) << 9) + \
  1382. (((((lpte)->u.Long)) << 24) >> 23) + \
  1383. MmProtopte_Base))
  1384. //++
  1385. //ULONG
  1386. //MiProtoAddressForPte (
  1387. // IN PMMPTE proto_va
  1388. // );
  1389. //
  1390. // Routine Description:
  1391. //
  1392. // This macro sets into the specified PTE the supplied information
  1393. // to indicate where the backing store for the page is located.
  1394. // MiProtoAddressForPte returns the bit field to OR into the PTE to
  1395. // reference a prototype PTE. And set the protoPTE bit,
  1396. // MM_PTE_PROTOTYPE_MASK.
  1397. //
  1398. // Arguments
  1399. //
  1400. // proto_va - Supplies the address of the prototype PTE.
  1401. //
  1402. // Return Value:
  1403. //
  1404. // Mask to set into the PTE.
  1405. //
  1406. //--
  1407. #define MiProtoAddressForPte(proto_va) \
  1408. ((((((ULONG)proto_va - MmProtopte_Base) >> 1) & (ULONG)0x000000FE) | \
  1409. (((((ULONG)proto_va - MmProtopte_Base) << 2) & (ULONG)0xfffff800))) | \
  1410. MM_PTE_PROTOTYPE_MASK)
  1411. //++
  1412. //ULONG
  1413. //MiProtoAddressForKernelPte (
  1414. // IN PMMPTE proto_va
  1415. // );
  1416. //
  1417. // Routine Description:
  1418. //
  1419. // This macro sets into the specified PTE the supplied information
  1420. // to indicate where the backing store for the page is located.
  1421. // MiProtoAddressForPte returns the bit field to OR into the PTE to
  1422. // reference a prototype PTE. And set the protoPTE bit,
  1423. // MM_PTE_PROTOTYPE_MASK.
  1424. //
  1425. // This macro also sets any other information (such as global bits)
  1426. // required for kernel mode PTEs.
  1427. //
  1428. // Arguments
  1429. //
  1430. // proto_va - Supplies the address of the prototype PTE.
  1431. //
  1432. // Return Value:
  1433. //
  1434. // Mask to set into the PTE.
  1435. //
  1436. //--
  1437. // not different on x86.
  1438. #define MiProtoAddressForKernelPte(proto_va) MiProtoAddressForPte(proto_va)
  1439. //++
  1440. //PSUBSECTION
  1441. //MiGetSubsectionAddress (
  1442. // IN PMMPTE lpte
  1443. // );
  1444. //
  1445. // Routine Description:
  1446. //
  1447. // This macro takes a PTE and returns the address of the subsection that
  1448. // the PTE refers to. Subsections are quadword structures allocated
  1449. // from nonpaged pool.
  1450. //
  1451. // NOTE THIS MACRO LIMITS THE SIZE OF NONPAGED POOL!
  1452. // MAXIMUM NONPAGED POOL = 2^(3+4+21) = 2^28 = 256mb.
  1453. //
  1454. //
  1455. // Arguments
  1456. //
  1457. // lpte - Supplies the PTE to operate upon.
  1458. //
  1459. // Return Value:
  1460. //
  1461. // A pointer to the subsection referred to by the supplied PTE.
  1462. //
  1463. //--
  1464. #define MiGetSubsectionAddress(lpte) \
  1465. (((lpte)->u.Long & 0x80000000) ? \
  1466. ((PSUBSECTION)((PCHAR)MmSubsectionBase + \
  1467. ((((lpte)->u.Long & 0x7ffff800) >> 4) | \
  1468. (((lpte)->u.Long<<2) & 0x78)))) \
  1469. : \
  1470. ((PSUBSECTION)((PCHAR)MmNonPagedPoolEnd - \
  1471. (((((lpte)->u.Long)>>11)<<7) | \
  1472. (((lpte)->u.Long<<2) & 0x78)))))
  1473. //++
  1474. //ULONG
  1475. //MiGetSubsectionAddressForPte (
  1476. // IN PSUBSECTION VA
  1477. // );
  1478. //
  1479. // Routine Description:
  1480. //
  1481. // This macro takes the address of a subsection and encodes it for use
  1482. // in a PTE.
  1483. //
  1484. // NOTE - THE SUBSECTION ADDRESS MUST BE QUADWORD ALIGNED!
  1485. //
  1486. // Arguments
  1487. //
  1488. // VA - Supplies a pointer to the subsection to encode.
  1489. //
  1490. // Return Value:
  1491. //
  1492. // The mask to set into the PTE to make it reference the supplied
  1493. // subsection.
  1494. //
  1495. //--
  1496. #define MiGetSubsectionAddressForPte(VA) \
  1497. (((ULONG)(VA) < (ULONG)MmSubsectionBase + 128*1024*1024) ? \
  1498. (((((ULONG)VA - (ULONG)MmSubsectionBase)>>2) & (ULONG)0x0000001E) | \
  1499. ((((((ULONG)VA - (ULONG)MmSubsectionBase)<<4) & (ULONG)0x7ffff800)))| \
  1500. 0x80000000) \
  1501. : \
  1502. (((((ULONG)MmNonPagedPoolEnd - (ULONG)VA)>>2) & (ULONG)0x0000001E) | \
  1503. ((((((ULONG)MmNonPagedPoolEnd - (ULONG)VA)<<4) & (ULONG)0x7ffff800)))))
  1504. //++
  1505. //PMMPTE
  1506. //MiGetPdeAddress (
  1507. // IN PVOID va
  1508. // );
  1509. //
  1510. // Routine Description:
  1511. //
  1512. // MiGetPdeAddress returns the address of the PDE which maps the
  1513. // given virtual address.
  1514. //
  1515. // Arguments
  1516. //
  1517. // Va - Supplies the virtual address to locate the PDE for.
  1518. //
  1519. // Return Value:
  1520. //
  1521. // The address of the PDE.
  1522. //
  1523. //--
  1524. #define MiGetPdeAddress(va) ((PMMPTE)(((((ULONG)(va)) >> 22) << 2) + PDE_BASE))
  1525. //++
  1526. //PMMPTE
  1527. //MiGetPteAddress (
  1528. // IN PVOID va
  1529. // );
  1530. //
  1531. // Routine Description:
  1532. //
  1533. // MiGetPteAddress returns the address of the PTE which maps the
  1534. // given virtual address.
  1535. //
  1536. // Arguments
  1537. //
  1538. // Va - Supplies the virtual address to locate the PTE for.
  1539. //
  1540. // Return Value:
  1541. //
  1542. // The address of the PTE.
  1543. //
  1544. //--
  1545. #define MiGetPteAddress(va) ((PMMPTE)(((((ULONG)(va)) >> 12) << 2) + PTE_BASE))
  1546. //++
  1547. //ULONG
  1548. //MiGetPpeOffset (
  1549. // IN PVOID va
  1550. // );
  1551. //
  1552. // Routine Description:
  1553. //
  1554. // MiGetPpeOffset returns the offset into a page root
  1555. // for a given virtual address.
  1556. //
  1557. // Arguments
  1558. //
  1559. // Va - Supplies the virtual address to locate the offset for.
  1560. //
  1561. // Return Value:
  1562. //
  1563. // The offset into the page root table the corresponding PPE is at.
  1564. //
  1565. //--
  1566. #define MiGetPpeOffset(va) (0)
  1567. //++
  1568. //ULONG
  1569. //MiGetPdeOffset (
  1570. // IN PVOID va
  1571. // );
  1572. //
  1573. // Routine Description:
  1574. //
  1575. // MiGetPdeOffset returns the offset into a page directory
  1576. // for a given virtual address.
  1577. //
  1578. // Arguments
  1579. //
  1580. // Va - Supplies the virtual address to locate the offset for.
  1581. //
  1582. // Return Value:
  1583. //
  1584. // The offset into the page directory table the corresponding PDE is at.
  1585. //
  1586. //--
  1587. #define MiGetPdeOffset(va) (((ULONG)(va)) >> 22)
  1588. //++
  1589. //ULONG
  1590. //MiGetPdeIndex (
  1591. // IN PVOID va
  1592. // );
  1593. //
  1594. // Routine Description:
  1595. //
  1596. // MiGetPdeIndex returns the page directory index
  1597. // for a given virtual address.
  1598. //
  1599. // Arguments
  1600. //
  1601. // Va - Supplies the virtual address to locate the offset for.
  1602. //
  1603. // Return Value:
  1604. //
  1605. // The index into the page directory - ie: the virtual page table number.
  1606. // This is different from the page directory offset because this spans
  1607. // page directories on supported platforms.
  1608. //
  1609. //--
  1610. #define MiGetPdeIndex MiGetPdeOffset
  1611. //++
  1612. //ULONG
  1613. //MiGetPteOffset (
  1614. // IN PVOID va
  1615. // );
  1616. //
  1617. // Routine Description:
  1618. //
  1619. // MiGetPteOffset returns the offset into a page table page
  1620. // for a given virtual address.
  1621. //
  1622. // Arguments
  1623. //
  1624. // Va - Supplies the virtual address to locate the offset for.
  1625. //
  1626. // Return Value:
  1627. //
  1628. // The offset into the page table page table the corresponding PTE is at.
  1629. //
  1630. //--
  1631. #define MiGetPteOffset(va) ((((ULONG)(va)) << 10) >> 22)
  1632. //++
  1633. //PVOID
  1634. //MiGetVirtualAddressMappedByPpe (
  1635. // IN PMMPTE PTE
  1636. // );
  1637. //
  1638. // Routine Description:
  1639. //
  1640. // MiGetVirtualAddressMappedByPpe returns the virtual address
  1641. // which is mapped by a given PPE address.
  1642. //
  1643. // Arguments
  1644. //
  1645. // PPE - Supplies the PPE to get the virtual address for.
  1646. //
  1647. // Return Value:
  1648. //
  1649. // Virtual address mapped by the PPE.
  1650. //
  1651. //--
  1652. #define MiGetVirtualAddressMappedByPpe(PPE) (NULL)
  1653. //++
  1654. //PVOID
  1655. //MiGetVirtualAddressMappedByPde (
  1656. // IN PMMPTE PTE
  1657. // );
  1658. //
  1659. // Routine Description:
  1660. //
  1661. // MiGetVirtualAddressMappedByPde returns the virtual address
  1662. // which is mapped by a given PDE address.
  1663. //
  1664. // Arguments
  1665. //
  1666. // PDE - Supplies the PDE to get the virtual address for.
  1667. //
  1668. // Return Value:
  1669. //
  1670. // Virtual address mapped by the PDE.
  1671. //
  1672. //--
  1673. #define MiGetVirtualAddressMappedByPde(PDE) ((PVOID)((ULONG)(PDE) << 20))
  1674. //++
  1675. //PVOID
  1676. //MiGetVirtualAddressMappedByPte (
  1677. // IN PMMPTE PTE
  1678. // );
  1679. //
  1680. // Routine Description:
  1681. //
  1682. // MiGetVirtualAddressMappedByPte returns the virtual address
  1683. // which is mapped by a given PTE address.
  1684. //
  1685. // Arguments
  1686. //
  1687. // PTE - Supplies the PTE to get the virtual address for.
  1688. //
  1689. // Return Value:
  1690. //
  1691. // Virtual address mapped by the PTE.
  1692. //
  1693. //--
  1694. #define MiGetVirtualAddressMappedByPte(PTE) ((PVOID)((ULONG)(PTE) << 10))
  1695. //++
  1696. //LOGICAL
  1697. //MiIsVirtualAddressOnPpeBoundary (
  1698. // IN PVOID VA
  1699. // );
  1700. //
  1701. // Routine Description:
  1702. //
  1703. // MiIsVirtualAddressOnPpeBoundary returns TRUE if the virtual address is
  1704. // on a page directory entry boundary.
  1705. //
  1706. // Arguments
  1707. //
  1708. // VA - Supplies the virtual address to check.
  1709. //
  1710. // Return Value:
  1711. //
  1712. // TRUE if on a boundary, FALSE if not.
  1713. //
  1714. //--
  1715. #define MiIsVirtualAddressOnPpeBoundary(VA) (FALSE)
  1716. //++
  1717. //LOGICAL
  1718. //MiIsVirtualAddressOnPdeBoundary (
  1719. // IN PVOID VA
  1720. // );
  1721. //
  1722. // Routine Description:
  1723. //
  1724. // MiIsVirtualAddressOnPdeBoundary returns TRUE if the virtual address is
  1725. // on a page directory entry boundary.
  1726. //
  1727. // Arguments
  1728. //
  1729. // VA - Supplies the virtual address to check.
  1730. //
  1731. // Return Value:
  1732. //
  1733. // TRUE if on a 4MB PDE boundary, FALSE if not.
  1734. //
  1735. //--
  1736. #define MiIsVirtualAddressOnPdeBoundary(VA) (((ULONG_PTR)(VA) & PAGE_DIRECTORY_MASK) == 0)
  1737. //++
  1738. //LOGICAL
  1739. //MiIsPteOnPdeBoundary (
  1740. // IN PVOID PTE
  1741. // );
  1742. //
  1743. // Routine Description:
  1744. //
  1745. // MiIsPteOnPdeBoundary returns TRUE if the PTE is
  1746. // on a page directory entry boundary.
  1747. //
  1748. // Arguments
  1749. //
  1750. // PTE - Supplies the PTE to check.
  1751. //
  1752. // Return Value:
  1753. //
  1754. // TRUE if on a 4MB PDE boundary, FALSE if not.
  1755. //
  1756. //--
  1757. #define MiIsPteOnPdeBoundary(PTE) (((ULONG_PTR)(PTE) & (PAGE_SIZE - 1)) == 0)
  1758. //++
  1759. //ULONG
  1760. //GET_PAGING_FILE_NUMBER (
  1761. // IN MMPTE PTE
  1762. // );
  1763. //
  1764. // Routine Description:
  1765. //
  1766. // This macro extracts the paging file number from a PTE.
  1767. //
  1768. // Arguments
  1769. //
  1770. // PTE - Supplies the PTE to operate upon.
  1771. //
  1772. // Return Value:
  1773. //
  1774. // The paging file number.
  1775. //
  1776. //--
  1777. #define GET_PAGING_FILE_NUMBER(PTE) ((((PTE).u.Long) >> 1) & 0x0000000F)
  1778. //++
  1779. //ULONG
  1780. //GET_PAGING_FILE_OFFSET (
  1781. // IN MMPTE PTE
  1782. // );
  1783. //
  1784. // Routine Description:
  1785. //
  1786. // This macro extracts the offset into the paging file from a PTE.
  1787. //
  1788. // Arguments
  1789. //
  1790. // PTE - Supplies the PTE to operate upon.
  1791. //
  1792. // Return Value:
  1793. //
  1794. // The paging file offset.
  1795. //
  1796. //--
  1797. #define GET_PAGING_FILE_OFFSET(PTE) ((((PTE).u.Long) >> 12) & 0x000FFFFF)
  1798. //++
  1799. //ULONG
  1800. //IS_PTE_NOT_DEMAND_ZERO (
  1801. // IN PMMPTE PPTE
  1802. // );
  1803. //
  1804. // Routine Description:
  1805. //
  1806. // This macro checks to see if a given PTE is NOT a demand zero PTE.
  1807. //
  1808. // Arguments
  1809. //
  1810. // PTE - Supplies the PTE to operate upon.
  1811. //
  1812. // Return Value:
  1813. //
  1814. // Returns 0 if the PTE is demand zero, non-zero otherwise.
  1815. //
  1816. //--
  1817. #define IS_PTE_NOT_DEMAND_ZERO(PTE) ((PTE).u.Long & (ULONG)0xFFFFFC01)
  1818. //++
  1819. //VOID
  1820. //MI_MAKING_VALID_PTE_INVALID(
  1821. // IN PMMPTE PPTE
  1822. // );
  1823. //
  1824. // Routine Description:
  1825. //
  1826. // Prepare to make a single valid PTE invalid.
  1827. // No action is required on x86.
  1828. //
  1829. // Arguments
  1830. //
  1831. // SYSTEM_WIDE - Supplies TRUE if this will happen on all processors.
  1832. //
  1833. // Return Value:
  1834. //
  1835. // None.
  1836. //
  1837. //--
  1838. #define MI_MAKING_VALID_PTE_INVALID(SYSTEM_WIDE)
  1839. //++
  1840. //VOID
  1841. //MI_MAKING_VALID_MULTIPLE_PTES_INVALID(
  1842. // IN PMMPTE PPTE
  1843. // );
  1844. //
  1845. // Routine Description:
  1846. //
  1847. // Prepare to make multiple valid PTEs invalid.
  1848. // No action is required on x86.
  1849. //
  1850. // Arguments
  1851. //
  1852. // SYSTEM_WIDE - Supplies TRUE if this will happen on all processors.
  1853. //
  1854. // Return Value:
  1855. //
  1856. // None.
  1857. //
  1858. //--
  1859. #define MI_MAKING_MULTIPLE_PTES_INVALID(SYSTEM_WIDE)
  1860. //++
  1861. //VOID
  1862. //MI_MAKE_PROTECT_WRITE_COPY (
  1863. // IN OUT MMPTE PPTE
  1864. // );
  1865. //
  1866. // Routine Description:
  1867. //
  1868. // This macro makes a writable PTE a writable-copy PTE.
  1869. //
  1870. // Arguments
  1871. //
  1872. // PTE - Supplies the PTE to operate upon.
  1873. //
  1874. // Return Value:
  1875. //
  1876. // NONE
  1877. //
  1878. //--
  1879. #define MI_MAKE_PROTECT_WRITE_COPY(PTE) \
  1880. if ((PTE).u.Soft.Protection & MM_PROTECTION_WRITE_MASK) { \
  1881. (PTE).u.Long |= MM_PROTECTION_COPY_MASK << MM_PROTECT_FIELD_SHIFT; \
  1882. }
  1883. //++
  1884. //VOID
  1885. //MI_SET_PAGE_DIRTY(
  1886. // IN PMMPTE PPTE,
  1887. // IN PVOID VA,
  1888. // IN PVOID PFNHELD
  1889. // );
  1890. //
  1891. // Routine Description:
  1892. //
  1893. // This macro sets the dirty bit (and release page file space).
  1894. //
  1895. // Arguments
  1896. //
  1897. // TEMP - Supplies a temporary for usage.
  1898. //
  1899. // PPTE - Supplies a pointer to the PTE that corresponds to VA.
  1900. //
  1901. // VA - Supplies a the virtual address of the page fault.
  1902. //
  1903. // PFNHELD - Supplies TRUE if the PFN lock is held.
  1904. //
  1905. // Return Value:
  1906. //
  1907. // None.
  1908. //
  1909. //--
  1910. #if defined(NT_UP)
  1911. #define MI_SET_PAGE_DIRTY(PPTE,VA,PFNHELD)
  1912. #else
  1913. #define MI_SET_PAGE_DIRTY(PPTE,VA,PFNHELD) \
  1914. if ((PPTE)->u.Hard.Dirty == 1) { \
  1915. MiSetDirtyBit ((VA),(PPTE),(PFNHELD)); \
  1916. }
  1917. #endif
  1918. //++
  1919. //VOID
  1920. //MI_NO_FAULT_FOUND(
  1921. // IN FAULTSTATUS,
  1922. // IN PMMPTE PPTE,
  1923. // IN PVOID VA,
  1924. // IN PVOID PFNHELD
  1925. // );
  1926. //
  1927. // Routine Description:
  1928. //
  1929. // This macro handles the case when a page fault is taken and no
  1930. // PTE with the valid bit clear is found.
  1931. //
  1932. // Arguments
  1933. //
  1934. // FAULTSTATUS - Supplies the fault status.
  1935. //
  1936. // PPTE - Supplies a pointer to the PTE that corresponds to VA.
  1937. //
  1938. // VA - Supplies a the virtual address of the page fault.
  1939. //
  1940. // PFNHELD - Supplies TRUE if the PFN lock is held.
  1941. //
  1942. // Return Value:
  1943. //
  1944. // None.
  1945. //
  1946. //--
  1947. #if defined(NT_UP)
  1948. #define MI_NO_FAULT_FOUND(FAULTSTATUS,PPTE,VA,PFNHELD)
  1949. #else
  1950. #define MI_NO_FAULT_FOUND(FAULTSTATUS,PPTE,VA,PFNHELD) \
  1951. if ((MI_FAULT_STATUS_INDICATES_WRITE(FAULTSTATUS)) && ((PPTE)->u.Hard.Dirty == 0)) { \
  1952. MiSetDirtyBit ((VA),(PPTE),(PFNHELD)); \
  1953. }
  1954. #endif
  1955. //++
  1956. //ULONG
  1957. //MI_CAPTURE_DIRTY_BIT_TO_PFN (
  1958. // IN PMMPTE PPTE,
  1959. // IN PMMPFN PPFN
  1960. // );
  1961. //
  1962. // Routine Description:
  1963. //
  1964. // This macro gets captures the state of the dirty bit to the PFN
  1965. // and frees any associated page file space if the PTE has been
  1966. // modified element.
  1967. //
  1968. // NOTE - THE PFN LOCK MUST BE HELD!
  1969. //
  1970. // Arguments
  1971. //
  1972. // PPTE - Supplies the PTE to operate upon.
  1973. //
  1974. // PPFN - Supplies a pointer to the PFN database element that corresponds
  1975. // to the page mapped by the PTE.
  1976. //
  1977. // Return Value:
  1978. //
  1979. // None.
  1980. //
  1981. //--
  1982. #define MI_CAPTURE_DIRTY_BIT_TO_PFN(PPTE,PPFN) \
  1983. ASSERT (KeGetCurrentIrql() > APC_LEVEL); \
  1984. if (((PPFN)->u3.e1.Modified == 0) && \
  1985. ((PPTE)->u.Hard.Dirty != 0)) { \
  1986. MI_SET_MODIFIED (PPFN, 1, 0x18); \
  1987. if (((PPFN)->OriginalPte.u.Soft.Prototype == 0) && \
  1988. ((PPFN)->u3.e1.WriteInProgress == 0)) { \
  1989. MiReleasePageFileSpace ((PPFN)->OriginalPte); \
  1990. (PPFN)->OriginalPte.u.Soft.PageFileHigh = 0; \
  1991. } \
  1992. }
  1993. //++
  1994. //BOOLEAN
  1995. //MI_IS_PHYSICAL_ADDRESS (
  1996. // IN PVOID VA
  1997. // );
  1998. //
  1999. // Routine Description:
  2000. //
  2001. // This macro determines if a given virtual address is really a
  2002. // physical address.
  2003. //
  2004. // Arguments
  2005. //
  2006. // VA - Supplies the virtual address.
  2007. //
  2008. // Return Value:
  2009. //
  2010. // FALSE if it is not a physical address, TRUE if it is.
  2011. //
  2012. //--
  2013. #define MI_IS_PHYSICAL_ADDRESS(Va) \
  2014. ((MiGetPdeAddress(Va)->u.Long & 0x81) == 0x81)
  2015. //++
  2016. //ULONG
  2017. //MI_CONVERT_PHYSICAL_TO_PFN (
  2018. // IN PVOID VA
  2019. // );
  2020. //
  2021. // Routine Description:
  2022. //
  2023. // This macro converts a physical address (see MI_IS_PHYSICAL_ADDRESS)
  2024. // to its corresponding physical frame number.
  2025. //
  2026. // Arguments
  2027. //
  2028. // VA - Supplies a pointer to the physical address.
  2029. //
  2030. // Return Value:
  2031. //
  2032. // Returns the PFN for the page.
  2033. //
  2034. //--
  2035. #define MI_CONVERT_PHYSICAL_TO_PFN(Va) \
  2036. ((PFN_NUMBER)(MiGetPdeAddress(Va)->u.Hard.PageFrameNumber) + (MiGetPteOffset((ULONG)Va)))
  2037. typedef struct _MMCOLOR_TABLES {
  2038. PFN_NUMBER Flink;
  2039. PVOID Blink;
  2040. PFN_NUMBER Count;
  2041. } MMCOLOR_TABLES, *PMMCOLOR_TABLES;
  2042. extern PMMCOLOR_TABLES MmFreePagesByColor[2];
  2043. extern ULONG MmTotalPagesForPagingFile;
  2044. //
  2045. // A VALID Page Table Entry on the x86 has the following definition.
  2046. //
  2047. #define MI_MAXIMUM_PAGEFILE_SIZE (((UINT64)1 * 1024 * 1024 - 1) * PAGE_SIZE)
  2048. #define MI_PTE_LOOKUP_NEEDED (0xfffff)
  2049. typedef struct _MMPTE_SOFTWARE {
  2050. ULONG Valid : 1;
  2051. ULONG PageFileLow : 4;
  2052. ULONG Protection : 5;
  2053. ULONG Prototype : 1;
  2054. ULONG Transition : 1;
  2055. ULONG PageFileHigh : 20;
  2056. } MMPTE_SOFTWARE;
  2057. typedef struct _MMPTE_TRANSITION {
  2058. ULONG Valid : 1;
  2059. ULONG Write : 1;
  2060. ULONG Owner : 1;
  2061. ULONG WriteThrough : 1;
  2062. ULONG CacheDisable : 1;
  2063. ULONG Protection : 5;
  2064. ULONG Prototype : 1;
  2065. ULONG Transition : 1;
  2066. ULONG PageFrameNumber : 20;
  2067. } MMPTE_TRANSITION;
  2068. typedef struct _MMPTE_PROTOTYPE {
  2069. ULONG Valid : 1;
  2070. ULONG ProtoAddressLow : 7;
  2071. ULONG ReadOnly : 1; // if set allow read only access.
  2072. ULONG WhichPool : 1;
  2073. ULONG Prototype : 1;
  2074. ULONG ProtoAddressHigh : 21;
  2075. } MMPTE_PROTOTYPE;
  2076. typedef struct _MMPTE_SUBSECTION {
  2077. ULONG Valid : 1;
  2078. ULONG SubsectionAddressLow : 4;
  2079. ULONG Protection : 5;
  2080. ULONG Prototype : 1;
  2081. ULONG SubsectionAddressHigh : 20;
  2082. ULONG WhichPool : 1;
  2083. } MMPTE_SUBSECTION;
  2084. typedef struct _MMPTE_LIST {
  2085. ULONG Valid : 1;
  2086. ULONG OneEntry : 1;
  2087. ULONG filler0 : 8;
  2088. //
  2089. // Note the Prototype bit must not be used for lists like freed nonpaged
  2090. // pool because lookaside pops can legitimately reference bogus addresses
  2091. // (since the pop is unsynchronized) and the fault handler must be able to
  2092. // distinguish lists from protos so a retry status can be returned (vs a
  2093. // fatal bugcheck).
  2094. //
  2095. ULONG Prototype : 1; // MUST BE ZERO as per above comment.
  2096. ULONG filler1 : 1;
  2097. ULONG NextEntry : 20;
  2098. } MMPTE_LIST;
  2099. //
  2100. // A Page Table Entry on the x86 has the following definition.
  2101. // Note the MP version is to avoid stalls when flushing TBs across processors.
  2102. //
  2103. typedef struct _MMPTE_HARDWARE {
  2104. ULONG Valid : 1;
  2105. #if defined(NT_UP)
  2106. ULONG Write : 1; // UP version
  2107. #else
  2108. ULONG Writable : 1; // changed for MP version
  2109. #endif
  2110. ULONG Owner : 1;
  2111. ULONG WriteThrough : 1;
  2112. ULONG CacheDisable : 1;
  2113. ULONG Accessed : 1;
  2114. ULONG Dirty : 1;
  2115. ULONG LargePage : 1;
  2116. ULONG Global : 1;
  2117. ULONG CopyOnWrite : 1; // software field
  2118. ULONG Prototype : 1; // software field
  2119. #if defined(NT_UP)
  2120. ULONG reserved : 1; // software field
  2121. #else
  2122. ULONG Write : 1; // software field - MP change
  2123. #endif
  2124. ULONG PageFrameNumber : 20;
  2125. } MMPTE_HARDWARE, *PMMPTE_HARDWARE;
  2126. #if defined(NT_UP)
  2127. #define HARDWARE_PTE_DIRTY_MASK 0x40
  2128. #else
  2129. #define HARDWARE_PTE_DIRTY_MASK 0x42
  2130. #endif
  2131. #define MI_PDE_MAPS_LARGE_PAGE(PDE) ((PDE)->u.Hard.LargePage == 1)
  2132. #define MI_MAKE_PDE_MAP_LARGE_PAGE(PDE) ((PDE)->u.Hard.LargePage = 1)
  2133. #define MI_GET_PAGE_FRAME_FROM_PTE(PTE) ((PTE)->u.Hard.PageFrameNumber)
  2134. #define MI_GET_PAGE_FRAME_FROM_TRANSITION_PTE(PTE) ((PTE)->u.Trans.PageFrameNumber)
  2135. #define MI_GET_PROTECTION_FROM_SOFT_PTE(PTE) ((PTE)->u.Soft.Protection)
  2136. #define MI_GET_PROTECTION_FROM_TRANSITION_PTE(PTE) ((PTE)->u.Trans.Protection)
  2137. typedef struct _MMPTE {
  2138. union {
  2139. ULONG Long;
  2140. HARDWARE_PTE Flush;
  2141. MMPTE_HARDWARE Hard;
  2142. MMPTE_PROTOTYPE Proto;
  2143. MMPTE_SOFTWARE Soft;
  2144. MMPTE_TRANSITION Trans;
  2145. MMPTE_SUBSECTION Subsect;
  2146. MMPTE_LIST List;
  2147. } u;
  2148. } MMPTE;
  2149. typedef MMPTE *PMMPTE;
  2150. extern MMPTE MmPteGlobal; // Set if processor supports Global Page, else zero.
  2151. extern PMMPTE MiFirstReservedZeroingPte;
  2152. #define InterlockedCompareExchangePte(_PointerPte, _NewContents, _OldContents) \
  2153. InterlockedCompareExchange ((PLONG)(_PointerPte), _NewContents, _OldContents)
  2154. #define InterlockedExchangePte(_PointerPte, _NewContents) InterlockedExchange((PLONG)(_PointerPte), _NewContents)
  2155. //++
  2156. //VOID
  2157. //MI_WRITE_VALID_PTE (
  2158. // IN PMMPTE PointerPte,
  2159. // IN MMPTE PteContents
  2160. // );
  2161. //
  2162. // Routine Description:
  2163. //
  2164. // MI_WRITE_VALID_PTE fills in the specified PTE making it valid with the
  2165. // specified contents.
  2166. //
  2167. // Arguments
  2168. //
  2169. // PointerPte - Supplies a PTE to fill.
  2170. //
  2171. // PteContents - Supplies the contents to put in the PTE.
  2172. //
  2173. // Return Value:
  2174. //
  2175. // None.
  2176. //
  2177. //--
  2178. #define MI_WRITE_VALID_PTE(_PointerPte, _PteContents) \
  2179. ASSERT ((_PointerPte)->u.Hard.Valid == 0); \
  2180. ASSERT ((_PteContents).u.Hard.Valid == 1); \
  2181. MI_LOG_PTE_CHANGE (_PointerPte, _PteContents); \
  2182. (*(_PointerPte) = (_PteContents))
  2183. //++
  2184. //VOID
  2185. //MI_WRITE_INVALID_PTE (
  2186. // IN PMMPTE PointerPte,
  2187. // IN MMPTE PteContents
  2188. // );
  2189. //
  2190. // Routine Description:
  2191. //
  2192. // MI_WRITE_INVALID_PTE fills in the specified PTE making it invalid with the
  2193. // specified contents.
  2194. //
  2195. // Arguments
  2196. //
  2197. // PointerPte - Supplies a PTE to fill.
  2198. //
  2199. // PteContents - Supplies the contents to put in the PTE.
  2200. //
  2201. // Return Value:
  2202. //
  2203. // None.
  2204. //
  2205. //--
  2206. #define MI_WRITE_INVALID_PTE(_PointerPte, _PteContents) \
  2207. ASSERT ((_PteContents).u.Hard.Valid == 0); \
  2208. MI_LOG_PTE_CHANGE (_PointerPte, _PteContents); \
  2209. (*(_PointerPte) = (_PteContents))
  2210. //++
  2211. //VOID
  2212. //MI_WRITE_VALID_PTE_NEW_PROTECTION (
  2213. // IN PMMPTE PointerPte,
  2214. // IN MMPTE PteContents
  2215. // );
  2216. //
  2217. // Routine Description:
  2218. //
  2219. // MI_WRITE_VALID_PTE_NEW_PROTECTION fills in the specified PTE (which was
  2220. // already valid) changing only the protection or the dirty bit.
  2221. //
  2222. // Arguments
  2223. //
  2224. // PointerPte - Supplies a PTE to fill.
  2225. //
  2226. // PteContents - Supplies the contents to put in the PTE.
  2227. //
  2228. // Return Value:
  2229. //
  2230. // None.
  2231. //
  2232. //--
  2233. #define MI_WRITE_VALID_PTE_NEW_PROTECTION(_PointerPte, _PteContents) \
  2234. ASSERT ((_PointerPte)->u.Hard.Valid == 1); \
  2235. ASSERT ((_PteContents).u.Hard.Valid == 1); \
  2236. ASSERT ((_PointerPte)->u.Hard.PageFrameNumber == (_PteContents).u.Hard.PageFrameNumber); \
  2237. MI_LOG_PTE_CHANGE (_PointerPte, _PteContents); \
  2238. (*(_PointerPte) = (_PteContents))
  2239. //++
  2240. //VOID
  2241. //MI_WRITE_VALID_PTE_NEW_PAGE (
  2242. // IN PMMPTE PointerPte,
  2243. // IN MMPTE PteContents
  2244. // );
  2245. //
  2246. // Routine Description:
  2247. //
  2248. // MI_WRITE_VALID_PTE_NEW_PAGE fills in the specified PTE (which was
  2249. // already valid) changing the page and the protection.
  2250. // Note that the contents are very carefully written.
  2251. //
  2252. // Arguments
  2253. //
  2254. // PointerPte - Supplies a PTE to fill.
  2255. //
  2256. // PteContents - Supplies the contents to put in the PTE.
  2257. //
  2258. // Return Value:
  2259. //
  2260. // None.
  2261. //
  2262. //--
  2263. #define MI_WRITE_VALID_PTE_NEW_PAGE(_PointerPte, _PteContents) \
  2264. ASSERT ((_PointerPte)->u.Hard.Valid == 1); \
  2265. ASSERT ((_PteContents).u.Hard.Valid == 1); \
  2266. ASSERT ((_PointerPte)->u.Hard.PageFrameNumber != (_PteContents).u.Hard.PageFrameNumber); \
  2267. MI_LOG_PTE_CHANGE (_PointerPte, _PteContents); \
  2268. (*(_PointerPte) = (_PteContents))
  2269. //++
  2270. //VOID
  2271. //MiFillMemoryPte (
  2272. // IN PMMPTE Destination,
  2273. // IN ULONG NumberOfPtes,
  2274. // IN MMPTE Pattern,
  2275. // };
  2276. //
  2277. // Routine Description:
  2278. //
  2279. // This function fills memory with the specified PTE pattern.
  2280. //
  2281. // Arguments
  2282. //
  2283. // Destination - Supplies a pointer to the memory to fill.
  2284. //
  2285. // NumberOfPtes - Supplies the number of PTEs (not bytes!) to be filled.
  2286. //
  2287. // Pattern - Supplies the PTE fill pattern.
  2288. //
  2289. // Return Value:
  2290. //
  2291. // None.
  2292. //
  2293. //--
  2294. #define MiFillMemoryPte(Destination, Length, Pattern) \
  2295. RtlFillMemoryUlong ((Destination), (Length) * sizeof (MMPTE), (Pattern))
  2296. #define MiZeroMemoryPte(Destination, Length) \
  2297. RtlZeroMemory ((Destination), (Length) * sizeof (MMPTE))
  2298. ULONG
  2299. FASTCALL
  2300. MiDetermineUserGlobalPteMask (
  2301. IN PMMPTE Pte
  2302. );
  2303. //++
  2304. //BOOLEAN
  2305. //MI_IS_PAGE_TABLE_ADDRESS (
  2306. // IN PVOID VA
  2307. // );
  2308. //
  2309. // Routine Description:
  2310. //
  2311. // This macro takes a virtual address and determines if
  2312. // it is a page table address.
  2313. //
  2314. // Arguments
  2315. //
  2316. // VA - Supplies a virtual address.
  2317. //
  2318. // Return Value:
  2319. //
  2320. // TRUE if the address is a page table address, FALSE if not.
  2321. //
  2322. //--
  2323. #define MI_IS_PAGE_TABLE_ADDRESS(VA) \
  2324. ((PVOID)(VA) >= (PVOID)PTE_BASE && (PVOID)(VA) <= (PVOID)PTE_TOP)
  2325. //++
  2326. //BOOLEAN
  2327. //MI_IS_PAGE_TABLE_OR_HYPER_ADDRESS (
  2328. // IN PVOID VA
  2329. // );
  2330. //
  2331. // Routine Description:
  2332. //
  2333. // This macro takes a virtual address and determines if
  2334. // it is a page table or hyperspace address.
  2335. //
  2336. // Arguments
  2337. //
  2338. // VA - Supplies a virtual address.
  2339. //
  2340. // Return Value:
  2341. //
  2342. // TRUE if the address is a page table or hyperspace address, FALSE if not.
  2343. //
  2344. //--
  2345. #define MI_IS_PAGE_TABLE_OR_HYPER_ADDRESS(VA) \
  2346. ((PVOID)(VA) >= (PVOID)PTE_BASE && (PVOID)(VA) <= (PVOID)HYPER_SPACE_END)
  2347. //++
  2348. //BOOLEAN
  2349. //MI_IS_KERNEL_PAGE_TABLE_ADDRESS (
  2350. // IN PVOID VA
  2351. // );
  2352. //
  2353. // Routine Description:
  2354. //
  2355. // This macro takes a virtual address and determines if
  2356. // it is a page table address for a kernel address.
  2357. //
  2358. // Arguments
  2359. //
  2360. // VA - Supplies a virtual address.
  2361. //
  2362. // Return Value:
  2363. //
  2364. // TRUE if the address is a kernel page table address, FALSE if not.
  2365. //
  2366. //--
  2367. #define MI_IS_KERNEL_PAGE_TABLE_ADDRESS(VA) \
  2368. ((PVOID)(VA) >= (PVOID)MiGetPteAddress(MmSystemRangeStart) && (PVOID)(VA) <= (PVOID)PTE_TOP)
  2369. //++
  2370. //BOOLEAN
  2371. //MI_IS_PAGE_DIRECTORY_ADDRESS (
  2372. // IN PVOID VA
  2373. // );
  2374. //
  2375. // Routine Description:
  2376. //
  2377. // This macro takes a virtual address and determines if
  2378. // it is a page directory address.
  2379. //
  2380. // Arguments
  2381. //
  2382. // VA - Supplies a virtual address.
  2383. //
  2384. // Return Value:
  2385. //
  2386. // TRUE if the address is a page directory address, FALSE if not.
  2387. //
  2388. //--
  2389. #define MI_IS_PAGE_DIRECTORY_ADDRESS(VA) \
  2390. ((PVOID)(VA) >= (PVOID)PDE_BASE && (PVOID)(VA) <= (PVOID)PDE_TOP)
  2391. //++
  2392. //BOOLEAN
  2393. //MI_IS_HYPER_SPACE_ADDRESS (
  2394. // IN PVOID VA
  2395. // );
  2396. //
  2397. // Routine Description:
  2398. //
  2399. // This macro takes a virtual address and determines if
  2400. // it is a hyper space address.
  2401. //
  2402. // Arguments
  2403. //
  2404. // VA - Supplies a virtual address.
  2405. //
  2406. // Return Value:
  2407. //
  2408. // TRUE if the address is a hyper space address, FALSE if not.
  2409. //
  2410. //--
  2411. #define MI_IS_HYPER_SPACE_ADDRESS(VA) \
  2412. ((PVOID)(VA) >= (PVOID)HYPER_SPACE && (PVOID)(VA) <= (PVOID)HYPER_SPACE_END)
  2413. //++
  2414. //BOOLEAN
  2415. //MI_IS_PROCESS_SPACE_ADDRESS (
  2416. // IN PVOID VA
  2417. // );
  2418. //
  2419. // Routine Description:
  2420. //
  2421. // This macro takes a virtual address and determines if
  2422. // it is a process-specific address. This is an address in user space
  2423. // or page table pages or hyper space.
  2424. //
  2425. // Arguments
  2426. //
  2427. // VA - Supplies a virtual address.
  2428. //
  2429. // Return Value:
  2430. //
  2431. // TRUE if the address is a process-specific address, FALSE if not.
  2432. //
  2433. //--
  2434. #define MI_IS_PROCESS_SPACE_ADDRESS(VA) \
  2435. (((PVOID)(VA) <= (PVOID)MM_HIGHEST_USER_ADDRESS) || \
  2436. ((PVOID)(VA) >= (PVOID)PTE_BASE && (PVOID)(VA) <= (PVOID)HYPER_SPACE_END))
  2437. //++
  2438. //BOOLEAN
  2439. //MI_IS_PTE_PROTOTYPE (
  2440. // IN PMMPTE PTE
  2441. // );
  2442. //
  2443. // Routine Description:
  2444. //
  2445. // This macro takes a PTE address and determines if it is a prototype PTE.
  2446. //
  2447. // Arguments
  2448. //
  2449. // PTE - Supplies the virtual address of the PTE to check.
  2450. //
  2451. // Return Value:
  2452. //
  2453. // TRUE if the PTE is in a segment (ie, a prototype PTE), FALSE if not.
  2454. //
  2455. //--
  2456. #define MI_IS_PTE_PROTOTYPE(PTE) \
  2457. ((PTE) > (PMMPTE)PTE_TOP)
  2458. //++
  2459. //BOOLEAN
  2460. //MI_IS_SYSTEM_CACHE_ADDRESS (
  2461. // IN PVOID VA
  2462. // );
  2463. //
  2464. // Routine Description:
  2465. //
  2466. // This macro takes a virtual address and determines if
  2467. // it is a system cache address.
  2468. //
  2469. // Arguments
  2470. //
  2471. // VA - Supplies a virtual address.
  2472. //
  2473. // Return Value:
  2474. //
  2475. // TRUE if the address is in the system cache, FALSE if not.
  2476. //
  2477. //--
  2478. #define MI_IS_SYSTEM_CACHE_ADDRESS(VA) \
  2479. (((PVOID)(VA) >= (PVOID)MmSystemCacheStart && \
  2480. (PVOID)(VA) <= (PVOID)MmSystemCacheEnd) || \
  2481. ((PVOID)(VA) >= (PVOID)MiSystemCacheStartExtra && \
  2482. (PVOID)(VA) <= (PVOID)MiSystemCacheEndExtra))
  2483. //++
  2484. //VOID
  2485. //MI_BARRIER_SYNCHRONIZE (
  2486. // IN ULONG TimeStamp
  2487. // );
  2488. //
  2489. // Routine Description:
  2490. //
  2491. // MI_BARRIER_SYNCHRONIZE compares the argument timestamp against the
  2492. // current IPI barrier sequence stamp. When equal, all processors will
  2493. // issue memory barriers to ensure that newly created pages remain coherent.
  2494. //
  2495. // When a page is put in the zeroed or free page list the current
  2496. // barrier sequence stamp is read (interlocked - this is necessary
  2497. // to get the correct value - memory barriers won't do the trick)
  2498. // and stored in the pfn entry for the page. The current barrier
  2499. // sequence stamp is maintained by the IPI send logic and is
  2500. // incremented (interlocked) when the target set of an IPI send
  2501. // includes all processors, but the one doing the send. When a page
  2502. // is needed its sequence number is compared against the current
  2503. // barrier sequence number. If it is equal, then the contents of
  2504. // the page may not be coherent on all processors, and an IPI must
  2505. // be sent to all processors to ensure a memory barrier is
  2506. // executed (generic call can be used for this). Sending the IPI
  2507. // automatically updates the barrier sequence number. The compare
  2508. // is for equality as this is the only value that requires the IPI
  2509. // (i.e., the sequence number wraps, values in both directions are
  2510. // older). When a page is removed in this fashion and either found
  2511. // to be coherent or made coherent, it cannot be modified between
  2512. // that time and writing the PTE. If the page is modified between
  2513. // these times, then an IPI must be sent.
  2514. //
  2515. // Arguments
  2516. //
  2517. // TimeStamp - Supplies the timestamp at the time when the page was zeroed.
  2518. //
  2519. // Return Value:
  2520. //
  2521. // None.
  2522. //
  2523. //--
  2524. // does nothing on i386.
  2525. #define MI_BARRIER_SYNCHRONIZE(TimeStamp)
  2526. //++
  2527. //VOID
  2528. //MI_BARRIER_STAMP_ZEROED_PAGE (
  2529. // IN PULONG PointerTimeStamp
  2530. // );
  2531. //
  2532. // Routine Description:
  2533. //
  2534. // MI_BARRIER_STAMP_ZEROED_PAGE issues an interlocked read to get the
  2535. // current IPI barrier sequence stamp. This is called AFTER a page is
  2536. // zeroed.
  2537. //
  2538. // Arguments
  2539. //
  2540. // PointerTimeStamp - Supplies a timestamp pointer to fill with the
  2541. // current IPI barrier sequence stamp.
  2542. //
  2543. // Return Value:
  2544. //
  2545. // None.
  2546. //
  2547. //--
  2548. // does nothing on i386.
  2549. #define MI_BARRIER_STAMP_ZEROED_PAGE(PointerTimeStamp)
  2550. //++
  2551. //VOID
  2552. //MI_FLUSH_SINGLE_SESSION_TB (
  2553. // IN PVOID Virtual
  2554. // );
  2555. //
  2556. // Routine Description:
  2557. //
  2558. // MI_FLUSH_SINGLE_SESSION_TB flushes the requested single address
  2559. // translation from the TB.
  2560. //
  2561. // Since there are no ASNs on the x86, this routine becomes a single
  2562. // TB invalidate.
  2563. //
  2564. // Arguments
  2565. //
  2566. // Virtual - Supplies the virtual address to invalidate.
  2567. //
  2568. // Return Value:
  2569. //
  2570. // None.
  2571. //
  2572. //--
  2573. #define MI_FLUSH_SINGLE_SESSION_TB(Virtual) \
  2574. KeFlushSingleTb (Virtual, TRUE);
  2575. //++
  2576. //VOID
  2577. //MI_FLUSH_ENTIRE_SESSION_TB (
  2578. // IN ULONG Invalid,
  2579. // IN LOGICAL AllProcessors
  2580. // );
  2581. //
  2582. // Routine Description:
  2583. //
  2584. // MI_FLUSH_ENTIRE_SESSION_TB flushes the entire TB on processors which
  2585. // support ASNs.
  2586. //
  2587. // Since there are no ASNs on the x86, this routine does nothing.
  2588. //
  2589. // Arguments
  2590. //
  2591. // Invalid - TRUE if invalidating.
  2592. //
  2593. // AllProcessors - TRUE if all processors need to be IPI'd.
  2594. //
  2595. // Return Value:
  2596. //
  2597. // None.
  2598. //
  2599. #define MI_FLUSH_ENTIRE_SESSION_TB(Invalid, AllProcessors) \
  2600. NOTHING;
  2601. //++
  2602. //LOGICAL
  2603. //MI_RESERVED_BITS_CANONICAL (
  2604. // IN PVOID VirtualAddress
  2605. // );
  2606. //
  2607. // Routine Description:
  2608. //
  2609. // This routine checks whether all of the reserved bits are correct.
  2610. //
  2611. // This does nothing on the x86.
  2612. //
  2613. // Arguments
  2614. //
  2615. // VirtualAddress - Supplies the virtual address to check.
  2616. //
  2617. // Return Value:
  2618. //
  2619. // None.
  2620. //
  2621. #define MI_RESERVED_BITS_CANONICAL(VirtualAddress) TRUE
  2622. //++
  2623. //VOID
  2624. //MI_DISPLAY_TRAP_INFORMATION (
  2625. // IN PVOID TrapInformation
  2626. // );
  2627. //
  2628. // Routine Description:
  2629. //
  2630. // Display any relevant trap information to aid debugging.
  2631. //
  2632. // Arguments
  2633. //
  2634. // TrapInformation - Supplies a pointer to a trap frame.
  2635. //
  2636. // Return Value:
  2637. //
  2638. // None.
  2639. //
  2640. #define MI_DISPLAY_TRAP_INFORMATION(TrapInformation) \
  2641. KdPrint(("MM:***EIP %p, EFL %p\n", \
  2642. ((PKTRAP_FRAME) (TrapInformation))->Eip, \
  2643. ((PKTRAP_FRAME) (TrapInformation))->EFlags)); \
  2644. KdPrint(("MM:***EAX %p, ECX %p EDX %p\n", \
  2645. ((PKTRAP_FRAME) (TrapInformation))->Eax, \
  2646. ((PKTRAP_FRAME) (TrapInformation))->Ecx, \
  2647. ((PKTRAP_FRAME) (TrapInformation))->Edx)); \
  2648. KdPrint(("MM:***EBX %p, ESI %p EDI %p\n", \
  2649. ((PKTRAP_FRAME) (TrapInformation))->Ebx, \
  2650. ((PKTRAP_FRAME) (TrapInformation))->Esi, \
  2651. ((PKTRAP_FRAME) (TrapInformation))->Edi));
  2652. #else
  2653. #include "i386\mipae.h"
  2654. #endif