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.

194 lines
10 KiB

  1. <HTML>
  2. <HEAD>
  3. <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-
  4. 1252">
  5. <META NAME="Generator" CONTENT="Microsoft FrontPage 5.0">
  6. <TITLE>Selective Suspend</TITLE>
  7. </HEAD>
  8. <BODY LINK="#0000ff">
  9. <p><b><font face="Times New Roman">The Selective Suspend driver</font></b></p>
  10. <ul>
  11. <li><font face="Times New Roman">The selective suspend driver is a generic function driver based on the
  12. Windows Driver Model (WDM).</font></li>
  13. <li><font face="Times New Roman">Supports Plug and Play(PnP), Power
  14. Management(PM), Windows Management Instrumentation (WMI) and the Selective
  15. Suspend (SS) features.</font></li>
  16. <li><font face="Times New Roman">The support for PnP, PM and the WMI feature
  17. is essential for any driver based on the WDM model.</font></li>
  18. <li><font face="Times New Roman">The SS feature, described in detail later, is
  19. a new feature in the core USB stack.</font></li>
  20. </ul>
  21. <p><font face="Times New Roman"><b>Plug and Play</b></font></p>
  22. <ul>
  23. <li><font face="Times New Roman">The Plug and Play system allows for dynamic
  24. recognition of installed hardware and configuration of resources.</font></li>
  25. <li><font face="Times New Roman">The selective suspend driver (function
  26. driver) registers a dispatch routine to receive and process PnP requests
  27. from the PnP manager.</font></li>
  28. <li><font face="Times New Roman">In the dispatch routine, the driver examines
  29. the minor function of the PnP requests and delegates them for further
  30. processing. <br>
  31. Please refer the Windows XP DDK docs and the Toaster sample in the DDK to
  32. understand the kernel-driver responsibilities and handling of PnP requests.</font></li>
  33. <li><font face="Times New Roman">The selective suspend driver has the
  34. following delegate-routines to process the PnP requests.</font></li>
  35. </ul>
  36. <table border="1" width="65%">
  37. <tr>
  38. <td width="46%"><font face="Courier New">IRP_MN_START_DEVICE</font></td>
  39. <td width="54%"><font face="Courier New">HandleStartDevice()</font></td>
  40. </tr>
  41. <tr>
  42. <td width="46%"><font face="Courier New">IRP_MN_QUERY_STOP_DEVICE</font></td>
  43. <td width="54%"><font face="Courier New">HandleQueryStopDevice()</font></td>
  44. </tr>
  45. <tr>
  46. <td width="46%"><font face="Courier New">IRP_MN_CANCEL_STOP_DEVICE</font></td>
  47. <td width="54%"><font face="Courier New">HandleCancelStopDevice()</font></td>
  48. </tr>
  49. <tr>
  50. <td width="46%"><font face="Courier New">IRP_MN_STOP_DEVICE</font></td>
  51. <td width="54%"><font face="Courier New">HandleStopDevice()</font></td>
  52. </tr>
  53. <tr>
  54. <td width="46%"><font face="Courier New">IRP_MN_QUERY_REMOVE_DEVICE</font></td>
  55. <td width="54%"><font face="Courier New">HandleQueryRemoveDevice()</font></td>
  56. </tr>
  57. <tr>
  58. <td width="46%"><font face="Courier New">IRP_MN_CANCEL_REMOVE_DEVICE</font></td>
  59. <td width="54%"><font face="Courier New">HandleCancelRemoveDevice()</font></td>
  60. </tr>
  61. <tr>
  62. <td width="46%"><font face="Courier New">IRP_MN_SURPRISE_REMOVAL</font></td>
  63. <td width="54%"><font face="Courier New">HandleSurpriseRemoval()</font></td>
  64. </tr>
  65. <tr>
  66. <td width="46%"><font face="Courier New">IRP_MN_REMOVE_DEVICE</font></td>
  67. <td width="54%"><font face="Courier New">HandleRemoveDevice()</font></td>
  68. </tr>
  69. <tr>
  70. <td width="46%"><font face="Courier New">IRP_MN_QUERY_CAPABILITIES</font></td>
  71. <td width="54%"><font face="Courier New">HandleQueryCapabilities()</font></td>
  72. </tr>
  73. </table>
  74. <p><font face="Times New Roman"><b>Power Management</b></font></p>
  75. <ul>
  76. <li>The power manager is the global power-policy owner for the system and the
  77. devices.</li>
  78. <li>The selective suspend driver registers a dispatch routine to receive and
  79. process power requests.</li>
  80. <li>In the dispatch routine, the driver examines the minor function of the
  81. power requests and delegates them for further processing.</li>
  82. <li>Please refer the Windows XP DDK docs and the Toaster sample in the DDK to
  83. understand the kernel-driver responsibilities and handling of power requests.</li>
  84. </ul>
  85. <table border="1" width="64%">
  86. <tr>
  87. <td width="50%"><font face="Courier New">IRP_MN_QUERY_POWER(SystemPowerState)</font></td>
  88. <td width="50%"><font face="Courier New">HandleSystemQueryPower()</font></td>
  89. </tr>
  90. <tr>
  91. <td width="50%"><font face="Courier New">IRP_MN_QUERY_POWER(DevicePowerState)</font></td>
  92. <td width="50%"><font face="Courier New">HandleDeviceQueryPower()</font></td>
  93. </tr>
  94. <tr>
  95. <td width="50%"><font face="Courier New">IRP_MN_SET_POWER (DevicePowerState)</font></td>
  96. <td width="50%"><font face="Courier New">HandleDeviceSetPower()</font></td>
  97. </tr>
  98. <tr>
  99. <td width="50%"><font face="Courier New">IRP_MN_SET_POWER (SystemPowerState)</font></td>
  100. <td width="50%"><font face="Courier New">HandleSystemSetPower()</font></td>
  101. </tr>
  102. </table>
  103. <p><b>Remote Wakeup capability</b></p>
  104. <p>The selective suspend driver supports the remote wakeup capability. The
  105. routines which implement this capability are:<br>
  106. <font face="Courier New">IssueWaitWake()<br>
  107. WaitWakeCallback()<br>
  108. WaitWakeCompletionRoutine()</font></p>
  109. <ul>
  110. <li>After the device is configured and is in a D0 power state, the selective
  111. suspend driver requests an <font face="Courier New">IRP_MN_WAIT_WAKE</font>
  112. request for the device - <font face="Courier New">IssueWaitWake</font>. </li>
  113. <li>A pointer to the callback function in the driver, <font face="Courier New">WaitWakeCallback</font><font face="Times New Roman">,</font>
  114. is passed along this request. </li>
  115. <li>The wait-wake request is sent to the PDO for the driver. </li>
  116. <li>When this request is received by the selective
  117. suspend driver , the dispatch routine sets a completion routine, <font face="Courier New">WaitWakeCompletionRoutine</font><font face="Times New Roman">,
  118. for this request.</font></li>
  119. <li>The request is then passed down the stack.</li>
  120. <li>The request remains pending with the hub driver until completed by the hub
  121. driver.</li>
  122. <li>On resume signaling, the wait wake request is completed and the callback
  123. function is invoked. <br>
  124. The <font face="Courier New">WaitWakeCallback</font> routine powers up the
  125. device and issues a new wait-wake request for the device.</li>
  126. <li>The wait wake request should not be sent when the device is in a low power
  127. state.</li>
  128. </ul>
  129. <p><b>Selective Suspend feature</b></p>
  130. <p>The USB core stack supports a new feature called the selective suspend
  131. feature. This feature allows the driver to power down the device while the
  132. system remains in the S0 power state. </p>
  133. <ul>
  134. <li>The device driver &quot;observes&quot; that the device is idle and sends
  135. an idle request down the stack&nbsp; - <font face="Courier New">SubmitIdleRequestIrp.<br>
  136. </font> <font face="Times New Roman">The exact notion of the device in idle
  137. state is
  138. described in the selective suspend model section.</font></li>
  139. <li>A pointer to the callback function in the driver, <font face="Courier New">IdleNotificationCallback,</font>
  140. is passed along with it.</li>
  141. <li>The driver also sets a completion routine, <font face="Courier New">IdleNotificationRequestComplete
  142. </font><font face="Times New Roman">for this request</font>. </li>
  143. <li>The hub driver pends this idle request for the device.</li>
  144. <li>When the hub &quot;deems it appropriate&quot; to selectively suspend the
  145. device, the callback function <font face="Courier New">IdleNotificationCallback</font>
  146. is invoked.<br>
  147. This function powers down the device.&nbsp; The device is powered down to
  148. the <font face="Courier New">DeviceWake</font>
  149. state (initialized while handling the <font face="Courier New">IRP_MN_QUERY_CAPABILITIES</font>).
  150. <br>
  151. If the <font face="Courier New">DeviceWake</font> state is not known, then
  152. the device should power down to the D2 power state.</li>
  153. </ul>
  154. <p>Notes</p>
  155. <ul>
  156. <li>Since the hub invokes the callback function, <font face="Courier New">IdleNotificationCallback</font>,
  157. only when it deems appropriate, the function driver should never assume that
  158. the device will power down as soon as the idle request is sent down the
  159. stack. </li>
  160. <li>Since it is not appropriate to send requests down the stack when the
  161. device is in low power state,
  162. the function driver should send an idle request only when the device is in D0
  163. power state. </li>
  164. <li>As soon as the device is &quot;not idle&quot;, the driver should cancel
  165. the idle request - <font face="Courier New">CancelSelectSuspend</font>.</li>
  166. <li>No assumptions should be made on the completion of idle request. If the
  167. driver needs to pass requests (reads/writes/ioctls) down the stack, then the
  168. driver should wait for the idle request to complete before proceeding to
  169. submit one.</li>
  170. <li>If the idle request completes in error, the <font face="Courier New">IdleNotificationRequestComplete
  171. </font><font face="Times New Roman">powers
  172. up the device.</font></li>
  173. <li>Only one idle request can be pending for the device at any time.</li>
  174. </ul>
  175. <p>Selective Suspend model</p>
  176. <ul>
  177. <li>The selective suspend driver interprets the device as idle when<br>
  178. a) there are no open handles to the device and<br>
  179. b) no PnP requests are being processed. <br>
  180. This is a mere suggestion. A function driver may have a different
  181. interpretation of the idle state.<br>
  182. As an example, an open handle need not violate the idle state of the device
  183. if this does not cause any request to be sent down the stack.</li>
  184. <li>The selective suspend driver initializes a timer to fire at fixed
  185. intervals. </li>
  186. <li>The DPC associated with the timer checks the idle state of the device and
  187. queues a work item to submit an idle request for the device. </li>
  188. <li>The timer is cancelled when the idle request is passed down the stack. </li>
  189. <li>The timer is re-initialized when the idle request completes.</li>
  190. </ul>
  191. <p>Please refer the inline comments in the selSusp sample for implementation of
  192. the above suggestions.</p>
  193. </BODY>
  194. </HTML>