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.

138 lines
2.4 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. pat.c
  5. Abstract:
  6. WinDbg Extension Api
  7. Author:
  8. Shivnandan Kaushik Aug 1997
  9. Environment:
  10. User Mode.
  11. Revision History:
  12. --*/
  13. #include "precomp.h"
  14. #include "i386.h"
  15. #pragma hdrstop
  16. //
  17. // PAT MSR architecture definitions
  18. //
  19. //
  20. // PAT model specific register
  21. //
  22. #define PAT_MSR 0x277
  23. //
  24. // PAT memory attributes
  25. //
  26. #define PAT_TYPE_STRONG_UC 0 // corresponds to PPro PCD=1,PWT=1
  27. #define PAT_TYPE_USWC 1
  28. #define PAT_TYPE_WT 4
  29. #define PAT_TYPE_WP 5
  30. #define PAT_TYPE_WB 6
  31. #define PAT_TYPE_WEAK_UC 7 // corresponds to PPro PCD=1,PWT=0
  32. #define PAT_TYPE_MAX 8
  33. #include "pshpack1.h"
  34. typedef union _PAT {
  35. struct {
  36. UCHAR Pat[8];
  37. } hw;
  38. ULONGLONG QuadPart;
  39. } PAT, *PPAT;
  40. #include "poppack.h"
  41. //
  42. // ----------------------------------------------------------------
  43. //
  44. DECLARE_API( pat )
  45. /*++
  46. Routine Description:
  47. Dumps processors pat
  48. Arguments:
  49. args - none
  50. Return Value:
  51. None
  52. --*/
  53. {
  54. static PUCHAR Type[] = {
  55. // 0 1 2 3 4
  56. "STRONG_UC","USWC ","???? ","???? ","WT ",
  57. // 5 6 7
  58. "WP ","WB ","WEAK_UC "};
  59. PAT Attributes;
  60. ULONG i;
  61. PUCHAR p;
  62. ULONG fb;
  63. ULONG Index;
  64. //
  65. // Quick sanity check
  66. //
  67. // X86_ONLY_API
  68. if (TargetMachine != IMAGE_FILE_MACHINE_I386) {
  69. dprintf("!pat is X86 only API.\n");
  70. return E_INVALIDARG;
  71. }
  72. i = (ULONG) GetExpression(args);
  73. if (i != 1) {
  74. i = (ULONG) GetExpression("KeFeatureBits");
  75. if (!i) {
  76. dprintf ("KeFeatureBits not found\n");
  77. return E_INVALIDARG;
  78. }
  79. fb = 0;
  80. ReadMemory(i, &fb, sizeof(i), &i);
  81. if (fb == -1 || !(fb & KF_PAT_X86)) {
  82. dprintf ("PAT feature not present\n");
  83. return E_INVALIDARG;
  84. }
  85. }
  86. //
  87. // Dump PAT
  88. //
  89. ReadMsr(PAT_MSR, &Attributes.QuadPart);
  90. dprintf("PAT_Index PCD PWT Memory Type\n");
  91. for (Index = 0; Index < 8; Index++) {
  92. p = "????";
  93. if (Attributes.hw.Pat[Index] < PAT_TYPE_MAX) {
  94. p = Type[Attributes.hw.Pat[Index]];
  95. }
  96. dprintf("%d %d %d %s\n",(Index/4)%2,
  97. (Index/2)%2,Index%2,p);
  98. }
  99. return S_OK;
  100. }