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.

197 lines
4.1 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. _write.c
  5. Abstract:
  6. This is the main file for the AsyncMAC Driver for the Remote Access
  7. Service. This driver conforms to the NDIS 3.0 interface.
  8. Author:
  9. Thomas J. Dimitri (TommyD) 08-May-1992
  10. Environment:
  11. Kernel Mode - Or whatever is the equivalent on OS/2 and DOS.
  12. Revision History:
  13. Ray Patch (raypa) 04/13/94 Modified for new WAN wrapper.
  14. --*/
  15. #define RAISEIRQL
  16. #include "asyncall.h"
  17. #if DBG
  18. ULONG UlFramesOut = 0;
  19. #define __FILE_SIG__ 'tirW'
  20. #endif
  21. // asyncmac.c will define the global parameters.
  22. ULONG GlobalXmitCameBack = 0;
  23. ULONG GlobalXmitCameBack2 = 0;
  24. ULONG GlobalXmitCameBack3 = 0;
  25. //
  26. // The assemble frame routine is specific for RAS 1.0 and 2.0
  27. // frame formats. It uses a 16 byte CRC at the end.
  28. //
  29. VOID
  30. AsyncFrameRASXonXoff(
  31. PUCHAR pStartOfFrame,
  32. postamble *pPostamble,
  33. PASYNC_FRAME pFrame,
  34. UCHAR controlCastByte);
  35. VOID
  36. AsyncFrameRASNormal(
  37. PUCHAR pStartOfFrame,
  38. postamble *pPostamble,
  39. PASYNC_FRAME pFrame,
  40. UCHAR controlCastByte);
  41. NTSTATUS
  42. AsyncWriteCompletionRoutine(
  43. IN PDEVICE_OBJECT DeviceObject, //... Our device object.
  44. IN PIRP Irp, //... I/O request packet.
  45. IN PNDIS_WAN_PACKET WanPacket //... Completion context.
  46. )
  47. /*++
  48. This is the IO Completion routine for WriteFrame.
  49. It is called when an I/O Write request has completed.
  50. --*/
  51. {
  52. NTSTATUS Status;
  53. NTSTATUS PacketStatus;
  54. PASYNC_INFO AsyncInfo;
  55. //
  56. // Make the compiler happy.
  57. //
  58. UNREFERENCED_PARAMETER(DeviceObject);
  59. //
  60. // Initialize locals.
  61. //
  62. AsyncInfo = WanPacket->MacReserved1;
  63. PacketStatus = NDIS_STATUS_FAILURE;
  64. Status = Irp->IoStatus.Status;
  65. //
  66. // Free the irp used to send the packt to the serial driver
  67. //
  68. IoFreeIrp(Irp);
  69. //
  70. // What was the outcome of the IRP.
  71. //
  72. switch ( Status ) {
  73. case STATUS_SUCCESS:
  74. PacketStatus = NDIS_STATUS_SUCCESS;
  75. break;
  76. case STATUS_TIMEOUT:
  77. DbgTracef(-2,("ASYNC: Status TIMEOUT on write\n"));
  78. break;
  79. case STATUS_CANCELLED:
  80. DbgTracef(-2,("ASYNC: Status CANCELLED on write\n"));
  81. break;
  82. case STATUS_PENDING:
  83. DbgTracef(0,("ASYNC: Status PENDING on write\n"));
  84. break;
  85. default:
  86. DbgTracef(-2,("ASYNC: Unknown status 0x%.8x on write", Status));
  87. break;
  88. }
  89. //
  90. // Count this packet completion.
  91. //
  92. AsyncInfo->Out++;
  93. //
  94. // Tell the Wrapper that we have finally the packet has been sent
  95. //
  96. NdisMWanSendComplete(
  97. AsyncInfo->Adapter->MiniportHandle,
  98. WanPacket,
  99. PacketStatus);
  100. //
  101. // We return STATUS_MORE_PROCESSING_REQUIRED so that the
  102. // IoCompletionRoutine will stop working on the IRP.
  103. //
  104. AsyncInfo->Flags &= ~(ASYNC_FLAG_SEND_PACKET);
  105. DEREF_ASYNCINFO(AsyncInfo, Irp);
  106. return STATUS_MORE_PROCESSING_REQUIRED;
  107. }
  108. NTSTATUS
  109. AsyncGetFrameFromPool(
  110. IN PASYNC_INFO Info,
  111. OUT PASYNC_FRAME *NewFrame )
  112. /*++
  113. --*/
  114. {
  115. PASYNC_ADAPTER Adapter=Info->Adapter;
  116. PASYNC_FRAME pFrame;
  117. pFrame = (ASYNC_FRAME*)
  118. ExAllocateFromNPagedLookasideList(&Adapter->AsyncFrameList);
  119. if (pFrame == NULL) {
  120. *NewFrame = NULL;
  121. return NDIS_STATUS_RESOURCES;
  122. }
  123. //
  124. // increase by 16 for frame runover padding when we have to resync
  125. //
  126. pFrame->Frame =
  127. (PUCHAR)pFrame + sizeof(ASYNC_FRAME) + sizeof(PVOID);
  128. (ULONG_PTR)pFrame->Frame &= ~((ULONG_PTR)(sizeof(PVOID)-1));
  129. pFrame->FrameLength = Adapter->MaxFrameSize;
  130. // assign back ptr from frame to adapter
  131. pFrame->Adapter=Adapter;
  132. // setup another back ptr
  133. pFrame->Info=Info;
  134. *NewFrame = pFrame;
  135. return(NDIS_STATUS_SUCCESS);
  136. }