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.

178 lines
4.0 KiB

  1. /*++
  2. Copyright (c) 2002 Microsoft Corporation
  3. Module Name:
  4. hammernb.h
  5. Abstract:
  6. Definitions used to relocate physical memory on Hammer MP machines.
  7. Author:
  8. Forrest Foltz (forrestf) 07/18/2002
  9. Environment:
  10. Kernel mode only.
  11. Revision History:
  12. --*/
  13. #if !defined(_HAMMERNB_H_)
  14. #define _HAMMERNB_H_
  15. #include "pci.h"
  16. //
  17. // Structures and definitions used to manipulate the variable MTRR ranges
  18. //
  19. #define MTRR_MSR_CAPABILITIES 0x0fe
  20. #define MTRR_MSR_DEFAULT 0x2ff
  21. #define MTRR_MSR_VARIABLE_BASE 0x200
  22. #define MTRR_MSR_VARIABLE_MASK (MTRR_MSR_VARIABLE_BASE+1)
  23. #define _40_MASK (((ULONG64)1 << 41) - 1)
  24. typedef union _MTRR_VARIABLE_BASE {
  25. struct {
  26. ULONG64 Type:8;
  27. ULONG64 Reserved0:4;
  28. ULONG64 Base:40;
  29. };
  30. ULONG64 QuadPart;
  31. } MTRR_VARIABLE_BASE, *PMTRR_VARIABLE_BASE;
  32. typedef union _MTRR_VARIABLE_MASK {
  33. struct {
  34. ULONG64 Reserved1:11;
  35. ULONG64 Valid:1;
  36. ULONG64 Mask:40;
  37. };
  38. ULONG64 QuadPart;
  39. } MTRR_VARIABLE_MASK, *PMTRR_VARIABLE_MASK;
  40. typedef union _MTRR_CAPABILITIES {
  41. struct {
  42. ULONG64 Vcnt:8;
  43. ULONG64 Fix:1;
  44. ULONG64 Reserved:1;
  45. ULONG64 WC:1;
  46. };
  47. ULONG64 QuadPart;
  48. } MTRR_CAPABILITIES, *PMTRR_CAPABILITIES;
  49. //
  50. // Structures and definitions used to manipulate the northbridge physical
  51. // memory map and MMIO map
  52. //
  53. #define MSR_SYSCFG 0xc0010010
  54. #define MSR_TOP_MEM 0xc001001a
  55. #define MSR_TOP_MEM_2 0xc001001d
  56. #define SYSCFG_MTRRTOM2EN ((ULONG64)1 << 21)
  57. #define MSR_TOP_MEM_MASK (((1UI64 << (39-23+1))-1) << 23)
  58. //
  59. // Northbridge devices start here
  60. //
  61. #define NB_DEVICE_BASE 0x18
  62. typedef struct _AMD_NB_DRAM_MAP {
  63. ULONG ReadEnable : 1;
  64. ULONG WriteEnable : 1;
  65. ULONG Reserved1 : 6;
  66. ULONG InterleaveEnable : 3;
  67. ULONG Reserved2 : 5;
  68. ULONG Base : 16;
  69. ULONG DestinationNode : 3;
  70. ULONG Reserved3 : 5;
  71. ULONG InterleaveSelect : 3;
  72. ULONG Reserved4 : 5;
  73. ULONG Limit : 16;
  74. } AMD_NB_DRAM_MAP, *PAMD_NB_DRAM_MAP;
  75. typedef struct _AMD_NB_MMIO_MAP {
  76. ULONG ReadEnable : 1;
  77. ULONG WriteEnable : 1;
  78. ULONG CpuDisable : 1;
  79. ULONG Lock : 1;
  80. ULONG Reserved1 : 4;
  81. ULONG Base : 24;
  82. ULONG DstNode : 3;
  83. ULONG Reserved2 : 1;
  84. ULONG DstLink : 2;
  85. ULONG Reserved3 : 1;
  86. ULONG NonPosted : 1;
  87. ULONG Limit : 24;
  88. } AMD_NB_MMIO_MAP, *PAMD_NB_MMIO_MAP;
  89. typedef struct _AMD_NB_FUNC1_CONFIG {
  90. USHORT VendorID;
  91. USHORT DeviceID;
  92. USHORT Command;
  93. USHORT Status;
  94. UCHAR RevisionID;
  95. UCHAR ProgramInterface;
  96. UCHAR SubClassCode;
  97. UCHAR BaseClassCode;
  98. UCHAR Reserved1[0x34];
  99. AMD_NB_DRAM_MAP DRAMMap[8];
  100. AMD_NB_MMIO_MAP MMIOMap[8];
  101. } AMD_NB_FUNC1_CONFIG, *PAMD_NB_FUNC1_CONFIG;
  102. C_ASSERT(FIELD_OFFSET(AMD_NB_FUNC1_CONFIG,DRAMMap) == 0x40);
  103. C_ASSERT(FIELD_OFFSET(AMD_NB_FUNC1_CONFIG,MMIOMap) == 0x80);
  104. BOOLEAN
  105. __inline
  106. BlAmd64ValidateBridgeDevice (
  107. IN PAMD_NB_FUNC1_CONFIG NodeConfig
  108. )
  109. /*++
  110. Routine Description:
  111. This routine verifies that the supplied PCI device configuration
  112. represents a Hammer northbridge address map function.
  113. Arguments:
  114. NodeConfig - Supplies a pointer to the configuration data read
  115. from a possible Hammer northbridge address map function.
  116. Return Value:
  117. Returns TRUE if the configuration data matches that of a Hammer northbridge
  118. address map function, FALSE otherwise.
  119. --*/
  120. {
  121. if (NodeConfig->VendorID == 0x1022 &&
  122. NodeConfig->DeviceID == 0x1101 &&
  123. NodeConfig->ProgramInterface == 0x00 &&
  124. NodeConfig->SubClassCode == PCI_SUBCLASS_BR_HOST &&
  125. NodeConfig->BaseClassCode == PCI_CLASS_BRIDGE_DEV) {
  126. return TRUE;
  127. } else {
  128. return FALSE;
  129. }
  130. }
  131. #endif // _HAMMERNB_H_