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.

206 lines
5.4 KiB

  1. /*++
  2. Copyright (c) 1998-2000 Microsoft Corporation
  3. Module Name:
  4. drdevasc
  5. Abstract:
  6. This module contains an (async) subclass of W32DrDev that uses a
  7. thread pool for implementations of read, write, and IOCTL handlers.
  8. Author:
  9. Tad Brockway 3/23/99
  10. Revision History:
  11. --*/
  12. #ifndef __DRDEVASC_H__
  13. #define __DRDEVASC_H__
  14. #include "w32drdev.h"
  15. #include "thrpool.h"
  16. ///////////////////////////////////////////////////////////////
  17. //
  18. // _W32DRDEV_ASYNCIO_PARAMS
  19. //
  20. // Async IO Parameters
  21. //
  22. class W32DrDeviceAsync;
  23. class W32DRDEV_ASYNCIO_PARAMS : public DrObject
  24. {
  25. public:
  26. #ifdef DC_DEBUG
  27. ULONG magicNo;
  28. #endif
  29. W32DrDeviceAsync *pObject;
  30. PRDPDR_IOREQUEST_PACKET pIoRequestPacket;
  31. PRDPDR_IOCOMPLETION_PACKET pIoReplyPacket;
  32. ULONG IoReplyPacketSize;
  33. HANDLE completionEvent;
  34. ThreadPoolRequest thrPoolReq;
  35. //
  36. // Constructor/Destructor
  37. //
  38. W32DRDEV_ASYNCIO_PARAMS(W32DrDeviceAsync *pObj, PRDPDR_IOREQUEST_PACKET pIOP) {
  39. pIoRequestPacket = pIOP;
  40. pObject = pObj;
  41. pIoReplyPacket = NULL;
  42. IoReplyPacketSize = 0;
  43. #if DBG
  44. magicNo = GOODMEMMAGICNUMBER;
  45. #endif
  46. completionEvent = NULL;
  47. thrPoolReq = INVALID_THREADPOOLREQUEST;
  48. }
  49. ~W32DRDEV_ASYNCIO_PARAMS() {
  50. DC_BEGIN_FN("~W32DRDEV_ASYNCIO_PARAMS");
  51. #if DBG
  52. ASSERT(magicNo == GOODMEMMAGICNUMBER);
  53. #endif
  54. ASSERT(thrPoolReq == INVALID_THREADPOOLREQUEST);
  55. ASSERT(completionEvent == NULL);
  56. ASSERT(pIoRequestPacket == NULL);
  57. ASSERT(pIoReplyPacket == NULL);
  58. #if DBG
  59. memset(&magicNo, DRBADMEM, sizeof(magicNo));
  60. #endif
  61. DC_END_FN();
  62. }
  63. //
  64. // Return the class name.
  65. //
  66. virtual DRSTRING ClassName() { return TEXT("W32DRDEV_ASYNCIO_PARAMS"); };
  67. };
  68. ///////////////////////////////////////////////////////////////
  69. //
  70. // W32DrDeviceAsync
  71. //
  72. class W32DrDeviceAsync : public W32DrDevice
  73. {
  74. protected:
  75. //
  76. // Pointer to the thread pool.
  77. //
  78. ThreadPool *_threadPool;
  79. //
  80. // Handles Read and Write IO requests.
  81. //
  82. VOID MsgIrpReadWrite(IN PRDPDR_IOREQUEST_PACKET pIoRequestPacket,
  83. IN UINT32 packetLen);
  84. //
  85. // IO Processing Functions
  86. //
  87. // This subclass of DrDevice handles the following IO requests. These
  88. // functions may be overridden in a subclass.
  89. //
  90. // pIoRequestPacket - Request packet received from server.
  91. // packetLen - Length of the packet
  92. //
  93. //
  94. virtual VOID MsgIrpCreate(
  95. IN PRDPDR_IOREQUEST_PACKET pIoRequestPacket,
  96. IN UINT32 packetLen
  97. );
  98. // Read and Writes are handled uniformly.
  99. virtual VOID MsgIrpRead(
  100. IN PRDPDR_IOREQUEST_PACKET pIoRequestPacket,
  101. IN UINT32 packetLen
  102. ) {
  103. DC_BEGIN_FN("W32DrDevice::MsgIrpRead");
  104. MsgIrpReadWrite(pIoRequestPacket, packetLen);
  105. DC_END_FN();
  106. }
  107. virtual VOID MsgIrpWrite(
  108. IN PRDPDR_IOREQUEST_PACKET pIoRequestPacket,
  109. IN UINT32 packetLen
  110. ) {
  111. DC_BEGIN_FN("W32DrDevice::MsgIrpWrite");
  112. MsgIrpReadWrite(pIoRequestPacket, packetLen);
  113. DC_END_FN();
  114. }
  115. //
  116. // Async IO Management Functions
  117. //
  118. virtual HANDLE StartIOFunc(W32DRDEV_ASYNCIO_PARAMS *params,
  119. DWORD *status);
  120. static HANDLE _StartIOFunc(W32DRDEV_ASYNCIO_PARAMS *params,
  121. DWORD *status);
  122. virtual VOID CancelIOFunc(W32DRDEV_ASYNCIO_PARAMS *params);
  123. static VOID _CancelIOFunc(PVOID params);
  124. virtual VOID CompleteIOFunc(W32DRDEV_ASYNCIO_PARAMS *params,
  125. DWORD status);
  126. static VOID _CompleteIOFunc(W32DRDEV_ASYNCIO_PARAMS *params,
  127. DWORD status);
  128. virtual DWORD AsyncIOCTLFunc(W32DRDEV_ASYNCIO_PARAMS *params);
  129. static _ThreadPoolFunc _AsyncIOCTLFunc;
  130. virtual DWORD AsyncReadIOFunc(W32DRDEV_ASYNCIO_PARAMS *params);
  131. static _ThreadPoolFunc _AsyncReadIOFunc;
  132. virtual DWORD AsyncWriteIOFunc(W32DRDEV_ASYNCIO_PARAMS *params);
  133. static _ThreadPoolFunc _AsyncWriteIOFunc;
  134. virtual DWORD AsyncMsgIrpCloseFunc(W32DRDEV_ASYNCIO_PARAMS *params);
  135. static _ThreadPoolFunc _AsyncMsgIrpCloseFunc;
  136. virtual DWORD AsyncMsgIrpCreateFunc(W32DRDEV_ASYNCIO_PARAMS *params);
  137. static _ThreadPoolFunc _AsyncMsgIrpCreateFunc;
  138. //
  139. // Dispatch an IOCTL directly to the device driver. This will
  140. // likely not work for platforms that don't match the server
  141. // platform.
  142. //
  143. VOID DispatchIOCTLDirectlyToDriver(
  144. IN PRDPDR_IOREQUEST_PACKET pIoRequestPacket
  145. );
  146. public:
  147. //
  148. // Public Methods
  149. //
  150. // Constructor
  151. W32DrDeviceAsync(ProcObj *processObject, ULONG deviceID,
  152. const TCHAR *devicePath);
  153. // Return the class name.
  154. virtual DRSTRING ClassName() { return TEXT("W32DrDeviceAsync"); }
  155. };
  156. #endif