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.

176 lines
5.0 KiB

  1. //
  2. // AMDAGP8X.sys is a driver, make sure we get the appropriate linkage.
  3. //
  4. /*
  5. ******************************************************************************
  6. * Archive File : $Archive: /Drivers/OS/Hammer/AGP/XP/amdagp/Amdagp8x.h $
  7. *
  8. * $History: Amdagp8x.h $
  9. *
  10. *
  11. ******************************************************************************
  12. */
  13. //#define _NTDRIVER_
  14. #include <agp.h>
  15. //
  16. // Define the location of the GART aperture control registers
  17. //
  18. #define AGP_GART_BUS_ID 0
  19. #define VENDOR_AMD 0x1022
  20. #define DEVICE_LOKAR 0x7454
  21. #define DEVICE_HAMMER 0x1103
  22. #define VENDORID_MASK 0x0000FFFF
  23. #define DEVICEID_MASK 0xFFFF0000
  24. #define CHIPSET_ID_OFFSET 0x00 // Vendor/Device ID Register
  25. #define STATUS_CMD_OFFSET 0x04 // Status/Command Register
  26. #define CLASS_REV_OFFSET 0x08 // Class Code/Revision ID Register
  27. #define APBASE_OFFSET 0x10 // Aperture Base Address
  28. #define AMD_AGP_CONTROL_OFFSET 0xB0
  29. #define AMD_APERTURE_SIZE_OFFSET 0xB4
  30. #define AMD_GART_POINTER_LOW_OFFSET 0xB8
  31. #define AMD_GART_POINTER_HIGH_OFFSET 0xBC
  32. #define CAPPTR_OFFSET 0x34
  33. #define AGP_STATUS_OFFSET 0x04
  34. #define AGP_COMMAND_OFFSET 0x08
  35. #define AGP_SIZE_OFFSET 0x0C
  36. #define PAGE_VALID_BIT 1
  37. #define CACHE_INVALIDATE_BIT 1
  38. #define PTE_ERROR_BIT 2
  39. #define GART_ENABLE_BIT 1
  40. #define APBASE_64BIT_MASK 0x04
  41. #define APBASE_ADDRESS_MASK 0xFE000000
  42. #define APH_SIZE_MASK 0x0E
  43. #define APH_SIZE_32MB 0x00
  44. #define APH_SIZE_64MB 0x02
  45. #define APH_SIZE_128MB 0x04
  46. #define APH_SIZE_256MB 0x06
  47. #define APH_SIZE_512MB 0x08
  48. #define APH_SIZE_1024MB 0x0A
  49. #define APH_SIZE_2048MB 0x0C
  50. #define APL_SIZE_MASK 0x0738
  51. #define APL_SIZE_32MB 0x0738
  52. #define APL_SIZE_64MB 0x0730
  53. #define APL_SIZE_128MB 0x0720
  54. #define APL_SIZE_256MB 0x0700
  55. #define APL_SIZE_512MB 0x0600
  56. #define APL_SIZE_1024MB 0x0400
  57. #define APL_SIZE_2048MB 0x0000
  58. #define AP_SIZE_COUNT 7
  59. #define AP_MIN_SIZE (32 * 1024 * 1024)
  60. #define AP_MAX_SIZE (1024 * 1024 * 1024)
  61. // Hammer Configuration Registers
  62. #define GART_APSIZE_OFFSET 0x90
  63. #define GART_APBASE_OFFSET 0x94
  64. #define GART_TABLE_OFFSET 0x98
  65. #define GART_CONTROL_OFFSET 0x9C
  66. #define GART_APBASE_SHIFT 25
  67. //
  68. // Define macros to read/write PCI configuration space
  69. //
  70. #define ReadAMDConfig(_slot_,_buf_,_offset_,_size_) \
  71. { \
  72. ULONG _len_; \
  73. _len_ = HalGetBusDataByOffset(PCIConfiguration, \
  74. AGP_GART_BUS_ID, \
  75. (_slot_), \
  76. (_buf_), \
  77. (_offset_), \
  78. (_size_)); \
  79. }
  80. #define WriteAMDConfig(_slot_,_buf_,_offset_,_size_) \
  81. { \
  82. ULONG _len_; \
  83. _len_ = HalSetBusDataByOffset(PCIConfiguration, \
  84. AGP_GART_BUS_ID, \
  85. (_slot_), \
  86. (_buf_), \
  87. (_offset_), \
  88. (_size_)); \
  89. }
  90. //
  91. // Define the GART table entry.
  92. //
  93. typedef struct _GART_ENTRY_HW {
  94. ULONG Valid : 1;
  95. ULONG Coherent : 1;
  96. ULONG Reserved : 2;
  97. ULONG PageHigh : 8;
  98. ULONG PageLow : 20;
  99. } GART_ENTRY_HW, *PGART_ENTRY_HW;
  100. //
  101. // GART Entry states are defined so that all software-only states
  102. // have the Valid bit clear.
  103. //
  104. #define GART_ENTRY_VALID 1 // 001
  105. #define GART_ENTRY_FREE 0 // 000
  106. #define GART_ENTRY_COHERENT 2 // 010
  107. #define GART_ENTRY_WC 4 // 00100
  108. #define GART_ENTRY_UC 8 // 01000
  109. #define GART_ENTRY_CC 16 // 10000
  110. #define GART_ENTRY_RESERVED_WC GART_ENTRY_WC
  111. #define GART_ENTRY_RESERVED_UC GART_ENTRY_UC
  112. #define GART_ENTRY_RESERVED_CC GART_ENTRY_CC
  113. #define GART_ENTRY_VALID_WC (GART_ENTRY_VALID)
  114. #define GART_ENTRY_VALID_UC (GART_ENTRY_VALID)
  115. #define GART_ENTRY_VALID_CC (GART_ENTRY_VALID | GART_ENTRY_COHERENT)
  116. typedef struct _GART_ENTRY_SW {
  117. ULONG State : 5;
  118. ULONG Reserved : 27;
  119. } GART_ENTRY_SW, *PGART_ENTRY_SW;
  120. typedef struct _GART_PTE {
  121. union {
  122. GART_ENTRY_HW Hard;
  123. ULONG AsUlong;
  124. GART_ENTRY_SW Soft;
  125. };
  126. } GART_PTE, *PGART_PTE;
  127. #define TABLE_ENTRY_SIZE sizeof(GART_PTE)
  128. #define NUM_PAGE_ENTRIES_PER_PAGE (PAGE_SIZE/TABLE_ENTRY_SIZE)
  129. //
  130. // Define the AMD-specific extension
  131. //
  132. typedef struct _AGP_AMD_EXTENSION {
  133. PHYSICAL_ADDRESS ApertureStart;
  134. ULONG ApertureLength;
  135. PGART_PTE Gart;
  136. ULONG GartLength;
  137. PHYSICAL_ADDRESS GartPhysical;
  138. ULONGLONG SpecialTarget;
  139. } AGP_AMD_EXTENSION, *PAGP_AMD_EXTENSION;
  140. extern void DisplayStatus(UCHAR);