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.

273 lines
4.7 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. agp.h
  5. Abstract:
  6. Header file for common AGP library
  7. Author:
  8. John Vert (jvert) 10/22/1997
  9. Revision History:
  10. --*/
  11. //
  12. // AGP is a driver, make sure we get the appropriate linkage.
  13. //
  14. #define _NTDRIVER_
  15. #include "ntddk.h"
  16. #include "ntagp.h"
  17. //
  18. // regstr.h uses things of type WORD, which isn't around in kernel mode.
  19. //
  20. #define _IN_KERNEL_
  21. #include "regstr.h"
  22. //
  23. // Handy debugging and logging macros
  24. //
  25. //
  26. // Always turned on for now
  27. //
  28. #if DEVL
  29. #define AGP_ALWAYS 0
  30. #define AGP_CRITICAL 1
  31. #define AGP_WARNING 2
  32. #define AGP_IRPTRACE 3
  33. #define AGP_NOISE 4
  34. extern ULONG AgpLogLevel;
  35. extern ULONG AgpStopLevel;
  36. #define AGPLOG(_level_,_x_) if ((_level_) <= AgpLogLevel) DbgPrint _x_; \
  37. if ((_level_) <= AgpStopLevel) { DbgBreakPoint();}
  38. #else
  39. #define AGPLOG(_level_,_x_)
  40. #endif
  41. //
  42. // Functions provided by AGPLIB for use by chipset-specific code
  43. //
  44. //
  45. // Helper routines for manipulating AGP Capabilities registers
  46. //
  47. typedef
  48. NTSTATUS
  49. (*PAGP_GETSET_CONFIG_SPACE)(
  50. IN PVOID Context,
  51. IN BOOLEAN Read,
  52. IN PVOID Buffer,
  53. IN ULONG Offset,
  54. IN ULONG Length
  55. );
  56. NTSTATUS
  57. AgpLibGetAgpCapability(
  58. IN PAGP_GETSET_CONFIG_SPACE pConfigFn,
  59. IN PVOID Context,
  60. IN BOOLEAN DoSpecial,
  61. OUT PPCI_AGP_CAPABILITY Capability
  62. );
  63. NTSTATUS
  64. AgpLibGetTargetCapability(
  65. IN PVOID AgpExtension,
  66. OUT PPCI_AGP_CAPABILITY Capability
  67. );
  68. NTSTATUS
  69. AgpLibGetMasterDeviceId(
  70. IN PVOID AgpExtension,
  71. OUT PULONG DeviceId
  72. );
  73. NTSTATUS
  74. AgpLibGetMasterCapability(
  75. IN PVOID AgpExtension,
  76. OUT PPCI_AGP_CAPABILITY Capability
  77. );
  78. NTSTATUS
  79. AgpLibGetPciDeviceCapability(
  80. IN ULONG BusId,
  81. IN ULONG SlotId,
  82. OUT PPCI_AGP_CAPABILITY Capability
  83. );
  84. NTSTATUS
  85. AgpLibSetAgpCapability(
  86. IN PAGP_GETSET_CONFIG_SPACE pConfigFn,
  87. IN PVOID Context,
  88. IN PPCI_AGP_CAPABILITY Capability
  89. );
  90. NTSTATUS
  91. AgpLibSetTargetCapability(
  92. IN PVOID AgpExtension,
  93. IN PPCI_AGP_CAPABILITY Capability
  94. );
  95. NTSTATUS
  96. AgpLibSetMasterCapability(
  97. IN PVOID AgpExtension,
  98. IN PPCI_AGP_CAPABILITY Capability
  99. );
  100. NTSTATUS
  101. AgpLibSetPciDeviceCapability(
  102. IN ULONG BusId,
  103. IN ULONG SlotId,
  104. IN PPCI_AGP_CAPABILITY Capability
  105. );
  106. PVOID
  107. AgpLibAllocateMappedPhysicalMemory(
  108. IN PVOID AgpContext,
  109. IN ULONG TotalBytes);
  110. //
  111. // Functions implemented by the chipset-specific code
  112. //
  113. typedef struct _AGP_RANGE {
  114. PHYSICAL_ADDRESS MemoryBase;
  115. ULONG NumberOfPages;
  116. MEMORY_CACHING_TYPE Type;
  117. PVOID Context;
  118. ULONG CommittedPages;
  119. } AGP_RANGE, *PAGP_RANGE;
  120. //
  121. // These flags have been reserved under AGP_FLAG_SPECIAL_RESERVE
  122. // defined in regstr.h
  123. //
  124. // AGP_FLAG_SPECIAL_RESERVE 0x000F0000
  125. //
  126. #define AGP_FLAG_SET_RATE_1X 0x00010000
  127. #define AGP_FLAG_SET_RATE_2X 0x00020000
  128. #define AGP_FLAG_SET_RATE_4X 0x00040000
  129. #define AGP_FLAG_SET_RATE_8X 0x00080000
  130. #define AGP_FLAG_SET_RATE_SHIFT 0x00000010
  131. NTSTATUS
  132. AgpSpecialTarget(
  133. IN PVOID AgpContext,
  134. IN ULONGLONG DeviceFlags
  135. );
  136. NTSTATUS
  137. AgpInitializeTarget(
  138. IN PVOID AgpExtension
  139. );
  140. NTSTATUS
  141. AgpInitializeMaster(
  142. IN PVOID AgpExtension,
  143. OUT ULONG *AgpCapabilities
  144. );
  145. NTSTATUS
  146. AgpQueryAperture(
  147. IN PVOID AgpContext,
  148. OUT PHYSICAL_ADDRESS *CurrentBase,
  149. OUT ULONG *CurrentSizeInPages,
  150. OUT OPTIONAL PIO_RESOURCE_LIST *ApertureRequirements
  151. );
  152. NTSTATUS
  153. AgpSetAperture(
  154. IN PVOID AgpContext,
  155. IN PHYSICAL_ADDRESS NewBase,
  156. OUT ULONG NewSizeInPages
  157. );
  158. VOID
  159. AgpDisableAperture(
  160. IN PVOID AgpContext
  161. );
  162. NTSTATUS
  163. AgpReserveMemory(
  164. IN PVOID AgpContext,
  165. IN OUT AGP_RANGE *AgpRange
  166. );
  167. NTSTATUS
  168. AgpReleaseMemory(
  169. IN PVOID AgpContext,
  170. IN PAGP_RANGE AgpRange
  171. );
  172. VOID
  173. AgpFindFreeRun(
  174. IN PVOID AgpContext,
  175. IN PAGP_RANGE AgpRange,
  176. IN ULONG NumberOfPages,
  177. IN ULONG OffsetInPages,
  178. OUT ULONG *FreePages,
  179. OUT ULONG *FreeOffset
  180. );
  181. VOID
  182. AgpGetMappedPages(
  183. IN PVOID AgpContext,
  184. IN PAGP_RANGE AgpRange,
  185. IN ULONG NumberOfPages,
  186. IN ULONG OffsetInPages,
  187. OUT PMDL Mdl
  188. );
  189. NTSTATUS
  190. AgpMapMemory(
  191. IN PVOID AgpContext,
  192. IN PAGP_RANGE AgpRange,
  193. IN PMDL Mdl,
  194. IN ULONG OffsetInPages,
  195. OUT PHYSICAL_ADDRESS *MemoryBase
  196. );
  197. NTSTATUS
  198. AgpUnMapMemory(
  199. IN PVOID AgpContext,
  200. IN PAGP_RANGE AgpRange,
  201. IN ULONG NumberOfPages,
  202. IN ULONG OffsetInPages
  203. );
  204. typedef
  205. NTSTATUS
  206. (*PAGP_FLUSH_PAGES)(
  207. IN PVOID AgpContext,
  208. IN PMDL Mdl
  209. );
  210. //
  211. // Globals defined by the chipset-specific code
  212. //
  213. extern ULONG AgpExtensionSize;
  214. extern PAGP_FLUSH_PAGES AgpFlushPages;
  215. //
  216. // AGP Pool tag definitions
  217. //
  218. #ifdef POOL_TAGGING
  219. #undef ExAllocatePool
  220. #undef ExAllocatePoolWithQuota
  221. #define ExAllocatePool(_type_,_size_) ExAllocatePoolWithTag(_type_,_size_,' PGA')
  222. #endif