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.

151 lines
3.5 KiB

  1. #ifndef _KDEXTS_AMD64_H_
  2. #define _KDEXTS_AMD64_H_
  3. /*++
  4. Copyright (c) 1999 Microsoft Corporation
  5. Module Name:
  6. amd64.h
  7. Abstract:
  8. This file contains definitions which are specific to amd64 platforms.
  9. Author:
  10. Forrest Foltz (forrestf)
  11. Environment:
  12. User Mode.
  13. Revision History:
  14. --*/
  15. //
  16. // MM constants.
  17. //
  18. #define PXE_BASE_AMD64 0xFFFFF6FB7DBED000UI64
  19. #define PPE_BASE_AMD64 0xFFFFF6FB7DA00000UI64
  20. #define PDE_BASE_AMD64 0xFFFFF6FB40000000UI64
  21. #define PTE_BASE_AMD64 0xFFFFF68000000000UI64
  22. #define PXE_TOP_AMD64 0xFFFFF6FB7DBEDFFFUI64
  23. #define PPE_TOP_AMD64 0xFFFFF6FB7DBFFFFFUI64
  24. #define PDE_TOP_AMD64 0xFFFFF6FB7FFFFFFFUI64
  25. #define PTE_TOP_AMD64 0xFFFFF6FFFFFFFFFFUI64
  26. #define MM_SESSION_SPACE_DEFAULT_AMD64 0xFFFFF90000000000UI64
  27. //
  28. // Each of the four levels of an AMD64 machine decode 9 bits of address space.
  29. //
  30. #define TABLE_DECODE_BITS_AMD64 9
  31. //
  32. // Standard page is 4K, or 12 bits
  33. //
  34. #define PAGE_SHIFT_AMD64 12
  35. #define PAGE_MASK_AMD64 (((ULONG64)1 << PAGE_SHIFT_AMD64) - 1)
  36. //
  37. // Large page is 2GB, or 21 bits
  38. //
  39. #define LARGE_PAGE_SHIFT_AMD64 21
  40. #define LARGE_PAGE_MASK_AMD64 (((ULONG64)1 << LARGE_PAGE_SHIFT_AMD64) - 1)
  41. //
  42. // Number of bits required to shift a VA in order to right-justify the
  43. // decode bits associated with a particular level of mapping.
  44. //
  45. #define PTI_SHIFT_AMD64 (PAGE_SHIFT_AMD64 + TABLE_DECODE_BITS_AMD64 * 0)
  46. #define PDI_SHIFT_AMD64 (PAGE_SHIFT_AMD64 + TABLE_DECODE_BITS_AMD64 * 1)
  47. #define PPI_SHIFT_AMD64 (PAGE_SHIFT_AMD64 + TABLE_DECODE_BITS_AMD64 * 2)
  48. #define PXI_SHIFT_AMD64 (PAGE_SHIFT_AMD64 + TABLE_DECODE_BITS_AMD64 * 3)
  49. #define PTE_SHIFT_AMD64 3
  50. //
  51. // The AMD64 architecture can decode up to 52 bits of physical address
  52. // space. The following masks are used to isolate those bits within a PTE
  53. // associated with a physical address.
  54. //
  55. #define PTE_PHYSICAL_BITS_AMD64 ((((ULONG64)1 << 52) - 1) & ~PAGE_MASK_AMD64)
  56. #define PTE_LARGE_PHYSICAL_BITS_AMD64 ((((ULONG64)1 << 52) - 1) & ~LARGE_PAGE_MASK_AMD64)
  57. //
  58. // The AMD64 architecture supports 48 bits of VA.
  59. //
  60. #define AMD64_VA_BITS 48
  61. #define AMD64_VA_HIGH_BIT ((ULONG64)1 << (AMD64_VA_BITS - 1))
  62. #define AMD64_VA_MASK (((ULONG64)1 << AMD64_VA_BITS) - 1)
  63. #define AMD64_VA_SHIFT (63 - 47) // address sign extend shift count
  64. //
  65. // Inline used to sign extend a 48-bit value
  66. //
  67. ULONG64
  68. __inline
  69. VA_SIGN_EXTEND_AMD64 (
  70. IN ULONG64 Va
  71. )
  72. {
  73. if ((Va & AMD64_VA_HIGH_BIT) != 0) {
  74. //
  75. // The highest VA bit is set, so sign-extend it
  76. //
  77. Va |= ((ULONG64)-1 ^ AMD64_VA_MASK);
  78. }
  79. return Va;
  80. }
  81. //
  82. // Flags in a HARDWARE_PTE
  83. //
  84. #define MM_PTE_VALID_MASK_AMD64 0x1
  85. #if defined(NT_UP)
  86. #define MM_PTE_WRITE_MASK_AMD64 0x2
  87. #else
  88. #define MM_PTE_WRITE_MASK_AMD64 0x800
  89. #endif
  90. #define MM_PTE_OWNER_MASK_AMD64 0x4
  91. #define MM_PTE_WRITE_THROUGH_MASK_AMD64 0x8
  92. #define MM_PTE_CACHE_DISABLE_MASK_AMD64 0x10
  93. #define MM_PTE_ACCESS_MASK_AMD64 0x20
  94. #if defined(NT_UP)
  95. #define MM_PTE_DIRTY_MASK_AMD64 0x40
  96. #else
  97. #define MM_PTE_DIRTY_MASK_AMD64 0x42
  98. #endif
  99. #define MM_PTE_LARGE_PAGE_MASK_AMD64 0x80
  100. #define MM_PTE_GLOBAL_MASK_AMD64 0x100
  101. #define MM_PTE_COPY_ON_WRITE_MASK_AMD64 0x200
  102. #define MM_PTE_PROTOTYPE_MASK_AMD64 0x400
  103. #define MM_PTE_TRANSITION_MASK_AMD64 0x800
  104. #define MM_PTE_PROTECTION_MASK_AMD64 0x3e0
  105. #define MM_PTE_PAGEFILE_MASK_AMD64 0x01e
  106. #define MI_PTE_LOOKUP_NEEDED_AMD64 (0xFFFFFFFF)
  107. #endif // _KDEXTS_AMD64_H_