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.

124 lines
3.4 KiB

  1. #include "agp.h"
  2. //
  3. // Define the location of the GART aperture control registers
  4. //
  5. //
  6. // The GART registers on the 440 live in the host-PCI bridge.
  7. // This is unfortunate, since the AGP driver attaches to the PCI-PCI (AGP)
  8. // bridge. So we have to get to the host-PCI bridge config space
  9. // and this is only possible because we KNOW this is bus 0, slot 0.
  10. //
  11. #define AGP_440_GART_BUS_ID 0
  12. #define AGP_440_GART_SLOT_ID 0
  13. #define AGP_440LX_IDENTIFIER 0x71808086
  14. #define AGP_440LX2_IDENTIFIER 0x71828086
  15. #define AGP_440BX_IDENTIFIER 0x71908086
  16. #define AGP_815_IDENTIFIER 0x11308086
  17. #define APBASE_OFFSET 0x10 // Aperture Base Address
  18. #define APSIZE_OFFSET 0xB4 // Aperture Size Register
  19. #define PACCFG_OFFSET 0x50 // PAC Configuration Register
  20. #define AGPCTRL_OFFSET 0xB0 // AGP Control Register
  21. #define ATTBASE_OFFSET 0xB8 // Aperture Translation Table Base
  22. #define READ_SYNC_ENABLE 0x2000
  23. //
  24. // Conversions from APSIZE encoding to MB
  25. //
  26. // 0x3F (b 11 1111) = 4MB
  27. // 0x3E (b 11 1110) = 8MB
  28. // 0x3C (b 11 1100) = 16MB
  29. // 0x38 (b 11 1000) = 32MB
  30. // 0x30 (b 11 0000) = 64MB
  31. // 0x20 (b 10 0000) = 128MB
  32. // 0x00 (b 00 0000) = 256MB
  33. #define AP_SIZE_4MB 0x3F
  34. #define AP_SIZE_8MB 0x3E
  35. #define AP_SIZE_16MB 0x3C
  36. #define AP_SIZE_32MB 0x38
  37. #define AP_SIZE_64MB 0x30
  38. #define AP_SIZE_128MB 0x20
  39. #define AP_SIZE_256MB 0x00
  40. #define AP_SIZE_COUNT 7
  41. #define AP_MIN_SIZE (4 * 1024 * 1024)
  42. #define AP_MAX_SIZE (256 * 1024 * 1024)
  43. #define AP_815_SIZE_COUNT 2
  44. #define AP_815_MAX_SIZE (64 * 1024 * 1024)
  45. //
  46. // Define the GART table entry.
  47. //
  48. typedef struct _GART_ENTRY_HW {
  49. ULONG Valid : 1;
  50. ULONG Reserved : 11;
  51. ULONG Page : 20;
  52. } GART_ENTRY_HW, *PGART_ENTRY_HW;
  53. //
  54. // GART Entry states are defined so that all software-only states
  55. // have the Valid bit clear.
  56. //
  57. #define GART_ENTRY_VALID 1 // 001
  58. #define GART_ENTRY_FREE 0 // 000
  59. #define GART_ENTRY_WC 2 // 010
  60. #define GART_ENTRY_UC 4 // 100
  61. #define GART_ENTRY_RESERVED_WC GART_ENTRY_WC
  62. #define GART_ENTRY_RESERVED_UC GART_ENTRY_UC
  63. #define GART_ENTRY_VALID_WC (GART_ENTRY_VALID)
  64. #define GART_ENTRY_VALID_UC (GART_ENTRY_VALID)
  65. typedef struct _GART_ENTRY_SW {
  66. ULONG State : 3;
  67. ULONG Reserved : 29;
  68. } GART_ENTRY_SW, *PGART_ENTRY_SW;
  69. typedef struct _GART_PTE {
  70. union {
  71. GART_ENTRY_HW Hard;
  72. ULONG AsUlong;
  73. GART_ENTRY_SW Soft;
  74. };
  75. } GART_PTE, *PGART_PTE;
  76. //
  77. // Define the layout of the hardware registers
  78. //
  79. typedef struct _AGPCTRL {
  80. ULONG Reserved1 : 7;
  81. ULONG GTLB_Enable : 1;
  82. ULONG Reserved2 : 24;
  83. } AGPCTRL, *PAGPCTRL;
  84. typedef struct _PACCFG {
  85. USHORT Reserved1 : 9;
  86. USHORT GlobalEnable : 1;
  87. USHORT PCIEnable : 1;
  88. USHORT Reserved2 : 5;
  89. } PACCFG, *PPACCFG;
  90. //
  91. // Define the 440-specific extension
  92. //
  93. typedef struct _AGP440_EXTENSION {
  94. BOOLEAN GlobalEnable;
  95. BOOLEAN PCIEnable;
  96. PHYSICAL_ADDRESS ApertureStart;
  97. ULONG ApertureLength;
  98. PGART_PTE Gart;
  99. ULONG GartLength;
  100. PHYSICAL_ADDRESS GartPhysical;
  101. ULONGLONG SpecialTarget;
  102. } AGP440_EXTENSION, *PAGP440_EXTENSION;