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.

254 lines
5.8 KiB

  1. /*++
  2. Copyright (c) 1996-1999 Microsoft Corporation
  3. Module Name:
  4. pstub.c
  5. Abstract:
  6. Stubs for protocol routines
  7. Author:
  8. Charlie Wickham (charlwi) 22-Apr-1996
  9. Rajesh Sundaram (rajeshsu) 01-Aug-1998.
  10. Environment:
  11. Kernel Mode
  12. Revision History:
  13. --*/
  14. #include "psched.h"
  15. #pragma hdrstop
  16. /* External */
  17. /* Static */
  18. /* Forward */ /* Generated by Emacs 19.17.0 on Wed May 08 10:48:06 1996 */
  19. VOID
  20. ClResetComplete(
  21. IN NDIS_HANDLE ProtocolBindingContext,
  22. IN NDIS_STATUS Status
  23. );
  24. /* End Forward */
  25. NDIS_STATUS
  26. ClPnPEventHandler(
  27. IN NDIS_HANDLE Handle,
  28. IN PNET_PNP_EVENT NetPnPEvent
  29. )
  30. {
  31. PADAPTER Adapter = (PADAPTER) Handle;
  32. PNDIS_DEVICE_POWER_STATE DeviceState = (PNDIS_DEVICE_POWER_STATE) (NetPnPEvent->Buffer);
  33. NDIS_DEVICE_POWER_STATE PrevDeviceState;
  34. NDIS_STATUS PnPStatus, Status;
  35. ULONG Count;
  36. PnPStatus = NDIS_STATUS_SUCCESS;
  37. switch(NetPnPEvent->NetEvent)
  38. {
  39. case NetEventSetPower:
  40. PsStructAssert(Adapter);
  41. PrevDeviceState = Adapter->PTDeviceState;
  42. Adapter->PTDeviceState = *DeviceState;
  43. //
  44. // if we are being sent to standby, block outstanding requests and sends
  45. //
  46. if(*DeviceState > NdisDeviceStateD0)
  47. {
  48. //
  49. // For state transistion to > D0, we have to pass the request up before doing anything.
  50. //
  51. if(Adapter->PsNdisHandle)
  52. {
  53. PnPStatus = NdisIMNotifyPnPEvent(Adapter->PsNdisHandle, NetPnPEvent);
  54. }
  55. //
  56. // If the physical miniport is going to standby, fail all incoming requests.
  57. //
  58. if(PrevDeviceState == NdisDeviceStateD0)
  59. {
  60. Adapter->StandingBy = TRUE;
  61. }
  62. //
  63. // Wait till Oustanding IO on the binding completes.
  64. //
  65. do
  66. {
  67. Status = NdisQueryPendingIOCount(Adapter->LowerMpHandle, &Count);
  68. if(Status == NDIS_STATUS_SUCCESS && Count != 0)
  69. {
  70. NdisMSleep(10);
  71. }
  72. else
  73. {
  74. break;
  75. }
  76. } while(TRUE);
  77. PsAssert(Adapter->OutstandingNdisRequests == 0);
  78. }
  79. else
  80. {
  81. //
  82. // If the physical miniport is powering up (from low power state to D0), clear the flag.
  83. //
  84. if(PrevDeviceState > NdisDeviceStateD0)
  85. {
  86. Adapter->StandingBy = FALSE;
  87. }
  88. // This is where we originate the pended ndis requests.
  89. if(Adapter->PendedNdisRequest)
  90. {
  91. PNDIS_REQUEST PendedRequest = (PNDIS_REQUEST) Adapter->PendedNdisRequest;
  92. Adapter->PendedNdisRequest = NULL;
  93. NdisRequest(&Status, Adapter->LowerMpHandle, PendedRequest);
  94. if(NDIS_STATUS_PENDING != Status)
  95. {
  96. ClRequestComplete(Adapter, PendedRequest, Status);
  97. }
  98. }
  99. // Update link speed.
  100. if(IsDeviceStateOn(Adapter))
  101. {
  102. PsGetLinkSpeed(Adapter);
  103. }
  104. //
  105. // For state transistion to D0, we have to pass the request after doing our work.
  106. //
  107. if(Adapter->PsNdisHandle)
  108. {
  109. PnPStatus = NdisIMNotifyPnPEvent(Adapter->PsNdisHandle, NetPnPEvent);
  110. }
  111. }
  112. break;
  113. case NetEventReconfigure:
  114. if(Adapter == NULL)
  115. {
  116. NdisReEnumerateProtocolBindings(ClientProtocolHandle);
  117. }
  118. else
  119. {
  120. //
  121. // For all other events, pass the request before doing anything.
  122. //
  123. if(Adapter->PsNdisHandle)
  124. {
  125. PnPStatus = NdisIMNotifyPnPEvent(Adapter->PsNdisHandle, NetPnPEvent);
  126. }
  127. }
  128. break;
  129. default:
  130. //
  131. // For all other events, pass the request before doing anything.
  132. //
  133. if(Adapter && Adapter->PsNdisHandle)
  134. {
  135. PnPStatus = NdisIMNotifyPnPEvent(Adapter->PsNdisHandle, NetPnPEvent);
  136. }
  137. break;
  138. }
  139. return(PnPStatus);
  140. }
  141. VOID
  142. ClResetComplete(
  143. IN NDIS_HANDLE ProtocolBindingContext,
  144. IN NDIS_STATUS Status
  145. )
  146. /*++
  147. Routine Description:
  148. Completion routine for NdisReset
  149. Arguments:
  150. See the DDK...
  151. Return Values:
  152. None
  153. --*/
  154. {
  155. PADAPTER Adapter = (PADAPTER)ProtocolBindingContext;
  156. PsStructAssert( Adapter );
  157. PsDbgOut(DBG_TRACE, DBG_PROTOCOL, ("(%08X) ClResetComplete: Status = %08x\n",
  158. Adapter, Status));
  159. }
  160. VOID
  161. ClCoStatus(
  162. IN NDIS_HANDLE ProtocolBindingContext,
  163. IN NDIS_HANDLE ProtocolVcContext OPTIONAL,
  164. IN NDIS_STATUS GeneralStatus,
  165. IN PVOID StatusBuffer,
  166. IN UINT StatusBufferSize
  167. )
  168. {
  169. PsDbgOut(DBG_TRACE,
  170. DBG_PROTOCOL,
  171. ("(%08X) PcStatusIndication: %08X\n",
  172. ProtocolBindingContext, GeneralStatus));
  173. return;
  174. }
  175. VOID
  176. ClCoAfRegisterNotifyHandler(
  177. IN NDIS_HANDLE ProtocolBindingContext,
  178. IN PCO_ADDRESS_FAMILY AddressFamily
  179. )
  180. {
  181. PADAPTER Adapter = (PADAPTER)ProtocolBindingContext;
  182. PsStructAssert( Adapter );
  183. if(AddressFamily->AddressFamily == CO_ADDRESS_FAMILY_PPP)
  184. {
  185. OpenWanAddressFamily(Adapter, AddressFamily);
  186. }
  187. }
  188. /* end pstub.c */