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.

233 lines
5.0 KiB

  1. /*++
  2. Copyright (c) 2002 Microsoft Corporation
  3. Module Name:
  4. workeng.h
  5. Abstract:
  6. External definitions for intermodule functions.
  7. Revision History:
  8. --*/
  9. #ifndef _SDBUS_WORKENG_H_
  10. #define _SDBUS_WORKENG_H_
  11. typedef
  12. VOID
  13. (*PSDBUS_WORKPACKET_COMPLETION_ROUTINE) (
  14. IN struct _SD_WORK_PACKET *WorkPacket,
  15. IN NTSTATUS status
  16. );
  17. typedef
  18. NTSTATUS
  19. (*PSDBUS_WORKER_MINIPROC) (
  20. IN struct _SD_WORK_PACKET *WorkPacket
  21. );
  22. //
  23. // IO worker structures
  24. //
  25. typedef struct _SD_WORK_PACKET {
  26. //
  27. // Routine to call on completion of work packet
  28. //
  29. PSDBUS_WORKPACKET_COMPLETION_ROUTINE CompletionRoutine;
  30. PVOID CompletionContext;
  31. //
  32. // List entry chain for work packets
  33. //
  34. LIST_ENTRY WorkPacketQueue;
  35. //
  36. // Next workpacket in chain for an atomic workpacket sequence
  37. //
  38. struct _SD_WORK_PACKET *NextWorkPacketInChain;
  39. NTSTATUS ChainedStatus;
  40. //
  41. // Function this work packet will perform
  42. //
  43. UCHAR Function;
  44. PSDBUS_WORKER_MINIPROC WorkerMiniProc;
  45. //
  46. // Current phase of function
  47. //
  48. UCHAR FunctionPhase;
  49. //
  50. // Engine will switch to this phase if non-zero when an
  51. // error is detected.
  52. //
  53. UCHAR FunctionPhaseOnError;
  54. //
  55. // Delay in usec till next operation in function
  56. //
  57. ULONG DelayTime;
  58. //
  59. // Indicates the type of event that just occurred
  60. //
  61. ULONG EventStatus;
  62. //
  63. // Indicates the type of event that indicates success for the
  64. // current operation.
  65. //
  66. ULONG RequiredEvent;
  67. //
  68. // Set to TRUE if no card events are expected for this packet
  69. //
  70. BOOLEAN DisableCardEvents;
  71. //
  72. // Indicates whether initialization has been run for this packet
  73. //
  74. BOOLEAN PacketStarted;
  75. //
  76. // Used for timeouts during packet processing
  77. //
  78. UCHAR Retries;
  79. //
  80. // scratch value used during reset
  81. //
  82. ULONG TempCtl;
  83. ULONG ResetCount;
  84. //
  85. // block operation variables
  86. //
  87. ULONG BlockCount;
  88. ULONG LastBlockLength;
  89. ULONG CurrentBlockLength;
  90. //
  91. // result of operation
  92. //
  93. ULONG_PTR Information;
  94. //
  95. // FdoExtension target of operation
  96. //
  97. struct _FDO_EXTENSION *FdoExtension;
  98. //
  99. // PdoExtension target of operation
  100. //
  101. struct _PDO_EXTENSION *PdoExtension;
  102. //
  103. // parameters
  104. //
  105. union {
  106. struct {
  107. PUCHAR Buffer;
  108. ULONG Length;
  109. ULONGLONG ByteOffset;
  110. } ReadBlock;
  111. struct {
  112. PUCHAR Buffer;
  113. ULONG Length;
  114. ULONGLONG ByteOffset;
  115. } WriteBlock;
  116. struct {
  117. PUCHAR Buffer;
  118. ULONG Length;
  119. ULONG Offset;
  120. } ReadIo;
  121. struct {
  122. PUCHAR Buffer;
  123. ULONG Length;
  124. ULONG Offset;
  125. UCHAR Data;
  126. } WriteIo;
  127. } Parameters;
  128. //
  129. // Current SD Command
  130. //
  131. BOOLEAN ExecutingSDCommand;
  132. UCHAR Cmd;
  133. UCHAR CmdPhase;
  134. UCHAR ResponseType;
  135. ULONG Argument;
  136. ULONG Flags;
  137. //
  138. // response from card
  139. //
  140. ULONG ResponseBuffer[4];
  141. #define SDBUS_RESPONSE_BUFFER_LENGTH 16
  142. } SD_WORK_PACKET, *PSD_WORK_PACKET;
  143. //
  144. // Work packet type defines in which queue the workpacket will be placed
  145. //
  146. #define WP_TYPE_SYSTEM 1
  147. #define WP_TYPE_SYSTEM_PRIORITY 2
  148. #define WP_TYPE_IO 3
  149. //
  150. // Set Cmd Parameters for ASYNC calls
  151. //
  152. #define SET_CMD_PARAMETERS(xWorkPacket, xCmd, xResponseType, xArgument, xFlags) { \
  153. xWorkPacket->ExecutingSDCommand = TRUE; \
  154. xWorkPacket->Cmd = xCmd; \
  155. xWorkPacket->ResponseType = xResponseType; \
  156. xWorkPacket->Argument = xArgument; \
  157. xWorkPacket->Flags = xFlags; \
  158. xWorkPacket->CmdPhase = 0; }
  159. //
  160. // Work Engine routines
  161. //
  162. VOID
  163. SdbusQueueWorkPacket(
  164. IN PFDO_EXTENSION FdoExtension,
  165. IN PSD_WORK_PACKET WorkPacket,
  166. IN UCHAR WorkPacketType
  167. );
  168. VOID
  169. SdbusPushWorkerEvent(
  170. IN PFDO_EXTENSION FdoExtension,
  171. IN ULONG EventStatus
  172. );
  173. VOID
  174. SdbusWorkerTimeoutDpc(
  175. IN PKDPC Dpc,
  176. IN PFDO_EXTENSION FdoExtension,
  177. IN PVOID SystemContext1,
  178. IN PVOID SystemContext2
  179. );
  180. VOID
  181. SdbusWorkerDpc(
  182. IN PKDPC Dpc,
  183. IN PFDO_EXTENSION FdoExtension,
  184. IN PVOID SystemContext1,
  185. IN PVOID SystemContext2
  186. );
  187. NTSTATUS
  188. SdbusSendCmdSynchronous(
  189. IN PFDO_EXTENSION FdoExtension,
  190. UCHAR Cmd,
  191. UCHAR ResponseType,
  192. ULONG Argument,
  193. ULONG Flags,
  194. PVOID Response,
  195. ULONG ResponseLength
  196. );
  197. #endif // _SDBUS_WORKENG_H_