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.

352 lines
7.7 KiB

  1. /*++
  2. Copyright (c) 2002 Microsoft Corporation
  3. Module Name:
  4. ntddsd.h
  5. Abstract:
  6. This is the include file that defines all constants and types for
  7. interfacing to the SD bus driver.
  8. Author:
  9. Neil Sandlin (neilsa) 01/01/2002
  10. --*/
  11. #ifndef _NTDDSDH_
  12. #define _NTDDSDH_
  13. #if _MSC_VER > 1000
  14. #pragma once
  15. #endif
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. //
  20. // Use this version in the interface_data structure
  21. //
  22. #define SDBUS_INTERFACE_VERSION 0x101
  23. //
  24. // Prototype of the callback routine which is called for SDIO
  25. // devices to reflect device interrupts.
  26. //
  27. typedef
  28. BOOLEAN
  29. (*PSDBUS_CALLBACK_ROUTINE) (
  30. IN PVOID Context,
  31. IN ULONG InterruptType
  32. );
  33. #define SDBUS_INTTYPE_DEVICE 0
  34. //
  35. // Interface Data structure used in the SdBusOpenInterface call
  36. //
  37. typedef struct _SDBUS_INTERFACE_DATA {
  38. USHORT Size;
  39. USHORT Version;
  40. //
  41. // This value should be the next lower device object in the
  42. // device stack.
  43. //
  44. PDEVICE_OBJECT TargetObject;
  45. //
  46. // This flag indicates whether the caller expects any device
  47. // interrupts from the device.
  48. //
  49. BOOLEAN DeviceGeneratesInterrupts;
  50. //
  51. // The caller can specify here the IRQL at which the callback
  52. // function is entered. If this value is TRUE, the callback will
  53. // be entered at DPC level. If this value is FALSE, the callback
  54. // will be entered at passive level.
  55. //
  56. // Specifying TRUE will generally lower latency time of the interrupt
  57. // delivery, at the cost of complicating the device driver, which
  58. // must then deal with running at different IRQLs.
  59. //
  60. BOOLEAN CallbackAtDpcLevel;
  61. //
  62. // When an IO device interrupts, the SD bus driver will generate a
  63. // callback to this routine.
  64. //
  65. PSDBUS_CALLBACK_ROUTINE CallbackRoutine;
  66. //
  67. // The caller can specify here a context value which will be passed
  68. // to the device interrupt callback routine.
  69. //
  70. PVOID CallbackRoutineContext;
  71. } SDBUS_INTERFACE_DATA, *PSDBUS_INTERFACE_DATA;
  72. //
  73. // SdBusOpenInterface()
  74. //
  75. // This routine establishes a connection to the SD bus driver.
  76. // It should be called in the AddDevice routine with the FDO for
  77. // the device stack is created.
  78. //
  79. // The Context pointer returned by this function must be used in
  80. // all other SD bus driver calls.
  81. //
  82. // Callers must be running at IRQL < DISPATCH_LEVEL.
  83. //
  84. NTSTATUS
  85. SdBusOpenInterface(
  86. IN PSDBUS_INTERFACE_DATA InterfaceData,
  87. IN PVOID *pContext
  88. );
  89. //
  90. // SdBusCloseInterface()
  91. //
  92. // This routine cleans up the SD bus driver interface. It should be
  93. // called when the caller's device object is deleted.
  94. //
  95. // Callers must be running at IRQL < DISPATCH_LEVEL.
  96. //
  97. NTSTATUS
  98. SdBusCloseInterface(
  99. IN PVOID Context
  100. );
  101. //
  102. // Data structures for request packets
  103. //
  104. typedef struct _SDBUS_REQUEST_PACKET;
  105. typedef
  106. VOID
  107. (*PSDBUS_REQUEST_COMPLETION_ROUTINE) (
  108. IN struct _SDBUS_REQUEST_PACKET *SdRp
  109. );
  110. typedef enum {
  111. SDRP_READ_BLOCK,
  112. SDRP_WRITE_BLOCK,
  113. SDRP_READ_IO,
  114. SDRP_READ_IO_EXTENDED,
  115. SDRP_WRITE_IO,
  116. SDRP_WRITE_IO_EXTENDED,
  117. SDRP_ACKNOWLEDGE_INTERRUPT
  118. } SDRP_FUNCTION;
  119. typedef struct _SDBUS_REQUEST_PACKET {
  120. //
  121. // Function specifies which operation to perform
  122. //
  123. SDRP_FUNCTION Function;
  124. //
  125. // The completion routine is called when the request completes.
  126. //
  127. PSDBUS_REQUEST_COMPLETION_ROUTINE CompletionRoutine;
  128. //
  129. // This member of the structure is available for the caller to
  130. // use as needed. It is not referenced or used by SdBusSubmitRequest().
  131. //
  132. PVOID UserContext;
  133. //
  134. // Status from operation set at completion
  135. //
  136. NTSTATUS Status;
  137. //
  138. // information from operation
  139. //
  140. ULONG_PTR Information;
  141. //
  142. // Parameters to the individual functions
  143. //
  144. union {
  145. struct {
  146. PUCHAR Buffer;
  147. ULONG Length;
  148. ULONGLONG ByteOffset;
  149. } ReadBlock;
  150. struct {
  151. PUCHAR Buffer;
  152. ULONG Length;
  153. ULONGLONG ByteOffset;
  154. } WriteBlock;
  155. struct {
  156. PUCHAR Buffer;
  157. ULONG Offset;
  158. } ReadIo;
  159. struct {
  160. UCHAR Data;
  161. ULONG Offset;
  162. } WriteIo;
  163. struct {
  164. PUCHAR Buffer;
  165. ULONG Length;
  166. ULONG Offset;
  167. } ReadIoExtended;
  168. struct {
  169. PUCHAR Buffer;
  170. ULONG Length;
  171. ULONG Offset;
  172. } WriteIoExtended;
  173. } Parameters;
  174. } SDBUS_REQUEST_PACKET, *PSDBUS_REQUEST_PACKET;
  175. //
  176. // SdBusSubmitRequest()
  177. //
  178. // This is the "core" routine for submitting requests.
  179. //
  180. // Callers of SdBusSubmitRequest must be running at IRQL <= DISPATCH_LEVEL.
  181. //
  182. NTSTATUS
  183. SdBusSubmitRequest(
  184. IN PVOID InterfaceContext,
  185. IN PSDBUS_REQUEST_PACKET SdRp
  186. );
  187. //
  188. // Device Parameters structure
  189. // NOTE: currently only memory attributes now, IO attributes will be
  190. // added as needed
  191. //
  192. typedef struct _SDBUS_DEVICE_PARAMETERS {
  193. USHORT Size;
  194. USHORT Version;
  195. ULONGLONG Capacity;
  196. BOOLEAN WriteProtected;
  197. } SDBUS_DEVICE_PARAMETERS, *PSDBUS_DEVICE_PARAMETERS;
  198. //
  199. // SdBusReadMemory()
  200. // SdBusWriteMemory()
  201. //
  202. // These routines read and write blocks on an SD storage device.
  203. //
  204. // Callers must be running at IRQL < DISPATCH_LEVEL.
  205. //
  206. NTSTATUS
  207. SdBusReadMemory(
  208. IN PVOID Context,
  209. IN ULONGLONG Offset,
  210. IN PVOID Buffer,
  211. IN ULONG Length,
  212. IN ULONG *LengthRead
  213. );
  214. NTSTATUS
  215. SdBusWriteMemory(
  216. IN PVOID Context,
  217. IN ULONGLONG Offset,
  218. IN PVOID Buffer,
  219. IN ULONG Length,
  220. IN ULONG *LengthWritten
  221. );
  222. //
  223. // SdBusReadIo()
  224. // SdBusWriteIo()
  225. //
  226. // These routines read and write data to an SD IO device.
  227. //
  228. // NOTE: CmdType should contain either 52 or 53, depending on which
  229. // SD IO operation is required.
  230. //
  231. // Callers must be running at IRQL < DISPATCH_LEVEL.
  232. //
  233. NTSTATUS
  234. SdBusReadIo(
  235. IN PVOID Context,
  236. IN UCHAR CmdType,
  237. IN ULONG Offset,
  238. IN PVOID Buffer,
  239. IN ULONG Length,
  240. IN ULONG *LengthRead
  241. );
  242. NTSTATUS
  243. SdBusWriteIo(
  244. IN PVOID Context,
  245. IN UCHAR CmdType,
  246. IN ULONG Offset,
  247. IN PVOID Buffer,
  248. IN ULONG Length,
  249. IN ULONG *LengthRead
  250. );
  251. //
  252. // SdBusGetDeviceParameters
  253. //
  254. // This routine is used to get information about the SD device.
  255. //
  256. // NOTE: Currently only implemented for SD storage devices.
  257. //
  258. // Callers must be running at IRQL < DISPATCH_LEVEL.
  259. //
  260. NTSTATUS
  261. SdBusGetDeviceParameters(
  262. IN PVOID Context,
  263. IN PSDBUS_DEVICE_PARAMETERS pDeviceParameters,
  264. IN ULONG Length
  265. );
  266. //
  267. // SdBusAcknowledgeCardInterrupt
  268. //
  269. // This routine is used to signal the end of processing for the
  270. // callback routine defined in SDBUS_INTERFACE_DATA. When an IO function
  271. // of an SD device asserts an interrupt, the bus driver will disable
  272. // that interrupt to allow I/O operations to be sent to the device at
  273. // a reasonable IRQL (that is, <=DISPATCH_LEVEL).
  274. //
  275. // When the function driver's callback routine, which is equivalent to
  276. // an ISR, is done clearing the function's interrupt, this routine should
  277. // be called to re-enable the IRQ for card interrupts.
  278. //
  279. // Callers must be running at IRQL <= DISPATCH_LEVEL.
  280. //
  281. NTSTATUS
  282. SdBusAcknowledgeCardInterrupt(
  283. IN PVOID Context
  284. );
  285. #ifdef __cplusplus
  286. }
  287. #endif
  288. #endif