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.

303 lines
5.6 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. AgpLibGetMasterDeviceId(
  76. IN PVOID AgpExtension,
  77. OUT PULONG DeviceId
  78. );
  79. NTSTATUS
  80. AgpLibGetMasterCapability(
  81. IN PVOID AgpExtension,
  82. OUT PPCI_AGP_CAPABILITY Capability
  83. );
  84. NTSTATUS
  85. AgpLibReadAgpDeviceConfig(
  86. IN PVOID AgpExtension,
  87. OUT PVOID Buffer,
  88. IN ULONG Offset,
  89. IN ULONG Size
  90. );
  91. NTSTATUS
  92. AgpLibWriteAgpDeviceConfig(
  93. IN PVOID AgpExtension,
  94. IN PVOID Buffer,
  95. IN ULONG Offset,
  96. IN ULONG Size
  97. );
  98. NTSTATUS
  99. AgpLibGetPciDeviceCapability(
  100. IN ULONG BusId,
  101. IN ULONG SlotId,
  102. OUT PPCI_AGP_CAPABILITY Capability
  103. );
  104. NTSTATUS
  105. AgpLibSetAgpCapability(
  106. IN PAGP_GETSET_CONFIG_SPACE pConfigFn,
  107. IN PVOID Context,
  108. IN PPCI_AGP_CAPABILITY Capability
  109. );
  110. NTSTATUS
  111. AgpLibSetTargetCapability(
  112. IN PVOID AgpExtension,
  113. IN PPCI_AGP_CAPABILITY Capability
  114. );
  115. NTSTATUS
  116. AgpLibSetMasterCapability(
  117. IN PVOID AgpExtension,
  118. IN PPCI_AGP_CAPABILITY Capability
  119. );
  120. NTSTATUS
  121. AgpLibSetPciDeviceCapability(
  122. IN ULONG BusId,
  123. IN ULONG SlotId,
  124. IN PPCI_AGP_CAPABILITY Capability
  125. );
  126. PVOID
  127. AgpLibAllocateMappedPhysicalMemory(
  128. IN PVOID AgpContext,
  129. IN ULONG TotalBytes);
  130. VOID
  131. AgpLibFreeMappedPhysicalMemory(
  132. IN PVOID Addr,
  133. IN ULONG Length
  134. );
  135. //
  136. // Functions implemented by the chipset-specific code
  137. //
  138. typedef struct _AGP_RANGE {
  139. PHYSICAL_ADDRESS MemoryBase;
  140. ULONG NumberOfPages;
  141. MEMORY_CACHING_TYPE Type;
  142. PVOID Context;
  143. ULONG CommittedPages;
  144. } AGP_RANGE, *PAGP_RANGE;
  145. //
  146. // These flags have been reserved under AGP_FLAG_SPECIAL_RESERVE
  147. // defined in regstr.h
  148. //
  149. // AGP_FLAG_SPECIAL_RESERVE 0x000F0000
  150. //
  151. #define AGP_FLAG_SET_RATE_1X 0x00010000
  152. #define AGP_FLAG_SET_RATE_2X 0x00020000
  153. #define AGP_FLAG_SET_RATE_4X 0x00040000
  154. #define AGP_FLAG_SET_RATE_8X 0x00080000
  155. #define AGP_FLAG_SET_RATE_SHIFT 0x00000010
  156. NTSTATUS
  157. AgpSpecialTarget(
  158. IN PVOID AgpContext,
  159. IN ULONGLONG DeviceFlags
  160. );
  161. NTSTATUS
  162. AgpInitializeTarget(
  163. IN PVOID AgpExtension
  164. );
  165. NTSTATUS
  166. AgpInitializeMaster(
  167. IN PVOID AgpExtension,
  168. OUT ULONG *AgpCapabilities
  169. );
  170. NTSTATUS
  171. AgpQueryAperture(
  172. IN PVOID AgpContext,
  173. OUT PHYSICAL_ADDRESS *CurrentBase,
  174. OUT ULONG *CurrentSizeInPages,
  175. OUT OPTIONAL PIO_RESOURCE_LIST *ApertureRequirements
  176. );
  177. NTSTATUS
  178. AgpSetAperture(
  179. IN PVOID AgpContext,
  180. IN PHYSICAL_ADDRESS NewBase,
  181. OUT ULONG NewSizeInPages
  182. );
  183. VOID
  184. AgpDisableAperture(
  185. IN PVOID AgpContext
  186. );
  187. NTSTATUS
  188. AgpReserveMemory(
  189. IN PVOID AgpContext,
  190. IN OUT AGP_RANGE *AgpRange
  191. );
  192. NTSTATUS
  193. AgpReleaseMemory(
  194. IN PVOID AgpContext,
  195. IN PAGP_RANGE AgpRange
  196. );
  197. VOID
  198. AgpFindFreeRun(
  199. IN PVOID AgpContext,
  200. IN PAGP_RANGE AgpRange,
  201. IN ULONG NumberOfPages,
  202. IN ULONG OffsetInPages,
  203. OUT ULONG *FreePages,
  204. OUT ULONG *FreeOffset
  205. );
  206. VOID
  207. AgpGetMappedPages(
  208. IN PVOID AgpContext,
  209. IN PAGP_RANGE AgpRange,
  210. IN ULONG NumberOfPages,
  211. IN ULONG OffsetInPages,
  212. OUT PMDL Mdl
  213. );
  214. NTSTATUS
  215. AgpMapMemory(
  216. IN PVOID AgpContext,
  217. IN PAGP_RANGE AgpRange,
  218. IN PMDL Mdl,
  219. IN ULONG OffsetInPages,
  220. OUT PHYSICAL_ADDRESS *MemoryBase
  221. );
  222. NTSTATUS
  223. AgpUnMapMemory(
  224. IN PVOID AgpContext,
  225. IN PAGP_RANGE AgpRange,
  226. IN ULONG NumberOfPages,
  227. IN ULONG OffsetInPages
  228. );
  229. typedef
  230. NTSTATUS
  231. (*PAGP_FLUSH_PAGES)(
  232. IN PVOID AgpContext,
  233. IN PMDL Mdl
  234. );
  235. //
  236. // Globals defined by the chipset-specific code
  237. //
  238. extern ULONG AgpExtensionSize;
  239. extern PAGP_FLUSH_PAGES AgpFlushPages;
  240. //
  241. // AGP Pool tag definitions
  242. //
  243. #ifdef POOL_TAGGING
  244. #undef ExAllocatePool
  245. #undef ExAllocatePoolWithQuota
  246. #define ExAllocatePool(_type_,_size_) ExAllocatePoolWithTag(_type_,_size_,' PGA')
  247. #endif