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.

314 lines
5.9 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. #define AGP_DEBUGGING_OKAY() \
  35. (KeGetCurrentIrql() < IPI_LEVEL)
  36. #define AGP_ASSERT \
  37. if (AGP_DEBUGGING_OKAY()) ASSERT
  38. extern ULONG AgpLogLevel;
  39. extern ULONG AgpStopLevel;
  40. #define AGPLOG(_level_,_x_) if (((_level_) <= AgpLogLevel) && \
  41. AGP_DEBUGGING_OKAY()) DbgPrint _x_; \
  42. if (((_level_) <= AgpStopLevel) && \
  43. AGP_DEBUGGING_OKAY()) { DbgBreakPoint(); }
  44. #else
  45. #define AGPLOG(_level_,_x_)
  46. #endif
  47. //
  48. // Functions provided by AGPLIB for use by chipset-specific code
  49. //
  50. //
  51. // Helper routines for manipulating AGP Capabilities registers
  52. //
  53. typedef
  54. NTSTATUS
  55. (*PAGP_GETSET_CONFIG_SPACE)(
  56. IN PVOID Context,
  57. IN BOOLEAN Read,
  58. IN PVOID Buffer,
  59. IN ULONG Offset,
  60. IN ULONG Length
  61. );
  62. NTSTATUS
  63. AgpLibGetAgpCapability(
  64. IN PAGP_GETSET_CONFIG_SPACE pConfigFn,
  65. IN PVOID Context,
  66. IN BOOLEAN DoSpecial,
  67. OUT PPCI_AGP_CAPABILITY Capability
  68. );
  69. NTSTATUS
  70. AgpLibGetTargetCapability(
  71. IN PVOID AgpExtension,
  72. OUT PPCI_AGP_CAPABILITY Capability
  73. );
  74. NTSTATUS
  75. AgpLibGetExtendedTargetCapability(
  76. IN PVOID AgpExtension,
  77. IN EXTENDED_AGP_REGISTER RegSelect,
  78. OUT PVOID ExtCapReg
  79. );
  80. NTSTATUS
  81. AgpLibGetMasterDeviceId(
  82. IN PVOID AgpExtension,
  83. OUT PULONG DeviceId
  84. );
  85. NTSTATUS
  86. AgpLibGetMasterCapability(
  87. IN PVOID AgpExtension,
  88. OUT PPCI_AGP_CAPABILITY Capability
  89. );
  90. NTSTATUS
  91. AgpLibGetExtendedMasterCapability(
  92. IN PVOID AgpExtension,
  93. OUT PPCI_AGP_ISOCH_STATUS IsochStat
  94. );
  95. VOID
  96. AgpLibReadAgpTargetConfig(
  97. IN PVOID AgpExtension,
  98. OUT PVOID Buffer,
  99. IN ULONG Offset,
  100. IN ULONG Size
  101. );
  102. VOID
  103. AgpLibWriteAgpTargetConfig(
  104. IN PVOID AgpExtension,
  105. IN PVOID Buffer,
  106. IN ULONG Offset,
  107. IN ULONG Size
  108. );
  109. NTSTATUS
  110. AgpLibSetAgpCapability(
  111. IN PAGP_GETSET_CONFIG_SPACE pConfigFn,
  112. IN PVOID Context,
  113. IN PPCI_AGP_CAPABILITY Capability
  114. );
  115. NTSTATUS
  116. AgpLibSetTargetCapability(
  117. IN PVOID AgpExtension,
  118. IN PPCI_AGP_CAPABILITY Capability
  119. );
  120. NTSTATUS
  121. AgpLibSetExtendedTargetCapability(
  122. IN PVOID AgpExtension,
  123. IN EXTENDED_AGP_REGISTER RegSelect,
  124. IN PVOID ExtCapReg
  125. );
  126. NTSTATUS
  127. AgpLibSetMasterCapability(
  128. IN PVOID AgpExtension,
  129. IN PPCI_AGP_CAPABILITY Capability
  130. );
  131. NTSTATUS
  132. AgpLibSetExtendedMasterCapability(
  133. IN PVOID AgpExtension,
  134. IN PPCI_AGP_ISOCH_COMMAND IsochCmd
  135. );
  136. PVOID
  137. AgpLibAllocateMappedPhysicalMemory(
  138. IN PVOID AgpContext,
  139. IN ULONG TotalBytes);
  140. VOID
  141. AgpLibFreeMappedPhysicalMemory(
  142. IN PVOID Addr,
  143. IN ULONG Length
  144. );
  145. //
  146. // Functions implemented by the chipset-specific code
  147. //
  148. typedef struct _AGP_RANGE {
  149. PHYSICAL_ADDRESS MemoryBase;
  150. ULONG NumberOfPages;
  151. MEMORY_CACHING_TYPE Type;
  152. PVOID Context;
  153. ULONG CommittedPages;
  154. } AGP_RANGE, *PAGP_RANGE;
  155. //
  156. // These flags have been reserved under AGP_FLAG_SPECIAL_RESERVE
  157. // defined in regstr.h
  158. //
  159. // AGP_FLAG_SPECIAL_RESERVE 0x000F0000
  160. //
  161. #define AGP_FLAG_SET_RATE_1X 0x00010000
  162. #define AGP_FLAG_SET_RATE_2X 0x00020000
  163. #define AGP_FLAG_SET_RATE_4X 0x00040000
  164. #define AGP_FLAG_SET_RATE_8X 0x00080000
  165. #define AGP_FLAG_SET_RATE_SHIFT 0x00000010
  166. NTSTATUS
  167. AgpSpecialTarget(
  168. IN PVOID AgpContext,
  169. IN ULONGLONG DeviceFlags
  170. );
  171. NTSTATUS
  172. AgpInitializeTarget(
  173. IN PVOID AgpExtension
  174. );
  175. NTSTATUS
  176. AgpInitializeMaster(
  177. IN PVOID AgpExtension,
  178. OUT ULONG *AgpCapabilities
  179. );
  180. NTSTATUS
  181. AgpQueryAperture(
  182. IN PVOID AgpContext,
  183. OUT PHYSICAL_ADDRESS *CurrentBase,
  184. OUT ULONG *CurrentSizeInPages,
  185. OUT OPTIONAL PIO_RESOURCE_LIST *ApertureRequirements
  186. );
  187. NTSTATUS
  188. AgpSetAperture(
  189. IN PVOID AgpContext,
  190. IN PHYSICAL_ADDRESS NewBase,
  191. OUT ULONG NewSizeInPages
  192. );
  193. VOID
  194. AgpDisableAperture(
  195. IN PVOID AgpContext
  196. );
  197. NTSTATUS
  198. AgpReserveMemory(
  199. IN PVOID AgpContext,
  200. IN OUT AGP_RANGE *AgpRange
  201. );
  202. NTSTATUS
  203. AgpReleaseMemory(
  204. IN PVOID AgpContext,
  205. IN PAGP_RANGE AgpRange
  206. );
  207. VOID
  208. AgpFindFreeRun(
  209. IN PVOID AgpContext,
  210. IN PAGP_RANGE AgpRange,
  211. IN ULONG NumberOfPages,
  212. IN ULONG OffsetInPages,
  213. OUT ULONG *FreePages,
  214. OUT ULONG *FreeOffset
  215. );
  216. VOID
  217. AgpGetMappedPages(
  218. IN PVOID AgpContext,
  219. IN PAGP_RANGE AgpRange,
  220. IN ULONG NumberOfPages,
  221. IN ULONG OffsetInPages,
  222. OUT PMDL Mdl
  223. );
  224. NTSTATUS
  225. AgpMapMemory(
  226. IN PVOID AgpContext,
  227. IN PAGP_RANGE AgpRange,
  228. IN PMDL Mdl,
  229. IN ULONG OffsetInPages,
  230. OUT PHYSICAL_ADDRESS *MemoryBase
  231. );
  232. NTSTATUS
  233. AgpUnMapMemory(
  234. IN PVOID AgpContext,
  235. IN PAGP_RANGE AgpRange,
  236. IN ULONG NumberOfPages,
  237. IN ULONG OffsetInPages
  238. );
  239. typedef
  240. NTSTATUS
  241. (*PAGP_FLUSH_PAGES)(
  242. IN PVOID AgpContext,
  243. IN PMDL Mdl
  244. );
  245. //
  246. // Globals defined by the chipset-specific code
  247. //
  248. extern ULONG AgpExtensionSize;
  249. extern PAGP_FLUSH_PAGES AgpFlushPages;
  250. //
  251. // AGP Pool tag definitions
  252. //
  253. #ifdef POOL_TAGGING
  254. #undef ExAllocatePool
  255. #undef ExAllocatePoolWithQuota
  256. #define ExAllocatePool(_type_,_size_) ExAllocatePoolWithTag(_type_,_size_,' PGA')
  257. #endif