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.

189 lines
3.6 KiB

  1. /*++
  2. #include "intelcopy.h"
  3. Module Name:
  4. mimisc.c
  5. Abstract:
  6. This module contains miscellaneous IA64 specific memory management routines.
  7. Author:
  8. ky 28-Jun-96
  9. Revision History:
  10. --*/
  11. #include "mi.h"
  12. #if 0
  13. //
  14. // memory types
  15. //
  16. typedef enum _MEM_TYPES {
  17. RegularMemory,
  18. MemoryMappedIo,
  19. VideoDisplayBuffer,
  20. IoPort,
  21. RomMemory
  22. } MEM_TYPES;
  23. typedef struct _CACHE_ATTRIBUTE_DESCRIPTOR {
  24. LIST_ENTRY ListEntry;
  25. MEM_TYPES MemTypes;
  26. ULONG CacheAttribute;
  27. PFN_NUMBER BasePage;
  28. PFN_NUMBER PageCount;
  29. } CACHE_ATTRIBUTE_DESCRIPTOR, *PCACHE_ATTRIBUTE_DESCRIPTOR;
  30. LIST_ENTRY MmCacheAttributeDescriptorListHead;
  31. //
  32. // default memory cache attributes set in the PTE.
  33. //
  34. ULONG MmDefaultCacheAttribute = MM_PTE_MA_WBU; // cacheable, write-back, unordered
  35. ULONG
  36. MiCheckMemoryAttribute (
  37. IN PFN_NUMBER PageFrameNumber
  38. )
  39. /*++
  40. Routine Descrition:
  41. This function examines the physical address which is given
  42. by the physical page frame number, and returns the cache
  43. attributes type for that page. The returned value is used to specify
  44. the MemoryAttribute field in the HARDWARE_PTE structure to map
  45. that page.
  46. This function searches the cache descriptor attribute link
  47. lists to see if the specific cache attribute is defined for
  48. that physical address range.
  49. If the physical address range is not defined in the cache
  50. descriptor attribute link lists, the default memory attribute is returned.
  51. Arguments:
  52. PageFrameIndex - Supplies the physical page frame number to be
  53. examined for the cache attribute.
  54. Return Value:
  55. Returns a cache attribute type for the supplied physical page
  56. frame number.
  57. Environment:
  58. Kernel Mode Only.
  59. --*/
  60. {
  61. PLIST_ENTRY NextMd;
  62. NextMd = MmCacheAttributeDescriptorListHead.Flink;
  63. While (NextMd != MmCacheAttributeDescriptorListHead) {
  64. CacheAttributeDescriptor = CONTAINING_RECORD(NextMd,
  65. CACHE_ATTRIBUTE_DESCRIPTOR,
  66. ListEntry);
  67. if ((PageFrameNumber >= CacheAttributeDescriptor.BasePage) &&
  68. (PageFrameNumber < CacheAttributeDescriptor.BasePage + CacheAttributeDescriptor.PageCount)) {
  69. return CacheAttributeDescriptor.CacheAttribute;
  70. }
  71. NextMd = CacheAttributeDescriptor->ListEntry.Flink;
  72. }
  73. //
  74. // If the cache memory descriptor is not found,
  75. // return the default cache attribute, MmDefaultCacheAttribute.
  76. //
  77. return MmDefaultCacheAttribute;
  78. }
  79. //
  80. // MmDisableCache yields 0 if cachable, 1 if uncachable.
  81. //
  82. UCHAR MmDisableCache[16] = {0, 0, 0, 0, 0, 0, 0, 0
  83. 1, 1, 0, 1, 0, 1, 0, 0};
  84. MiDisableCaching (
  85. IN PMMPTE PointerPte
  86. )
  87. /*++
  88. Routine Description:
  89. This macro takes a valid PTE and sets the caching state to be
  90. disabled.
  91. Arguments
  92. PTE - Supplies a pointer to the valid PTE.
  93. Return Value:
  94. None.
  95. Environment:
  96. Kernel mode
  97. --*/
  98. {
  99. ULONG CacheAttribute;
  100. CacheAttribute = MiCheckMemoryAttribute(TempPte.u.Hard.PageFrameNumber);
  101. if (MmDisableCache[CacheAttribute]) {
  102. //
  103. // The returned CacheAttributes indicate uncachable.
  104. //
  105. PointerPte->u.Hard.MemAttribute = CacheAttribute;
  106. } else {
  107. //
  108. // Set the most conservative cache memory attribute,
  109. // UCO (Uncachable, Non-coalescing, Sequential & Non-
  110. // speculative and Ordered.
  111. //
  112. PointerPte->u.Hard.MemAttribute = MM_PTE_MA_UCO;
  113. }
  114. }
  115. #endif