Source code of Windows XP (NT5)
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
3.8 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. #endif
  20. // asyncmac.c will define the global parameters.
  21. ULONG GlobalXmitCameBack = 0;
  22. ULONG GlobalXmitCameBack2 = 0;
  23. ULONG GlobalXmitCameBack3 = 0;
  24. //
  25. // The assemble frame routine is specific for RAS 1.0 and 2.0
  26. // frame formats. It uses a 16 byte CRC at the end.
  27. //
  28. VOID
  29. AsyncFrameRASXonXoff(
  30. PUCHAR pStartOfFrame,
  31. postamble *pPostamble,
  32. PASYNC_FRAME pFrame,
  33. UCHAR controlCastByte);
  34. VOID
  35. AsyncFrameRASNormal(
  36. PUCHAR pStartOfFrame,
  37. postamble *pPostamble,
  38. PASYNC_FRAME pFrame,
  39. UCHAR controlCastByte);
  40. NTSTATUS
  41. AsyncWriteCompletionRoutine(
  42. IN PDEVICE_OBJECT DeviceObject, //... Our device object.
  43. IN PIRP Irp, //... I/O request packet.
  44. IN PNDIS_WAN_PACKET WanPacket //... Completion context.
  45. )
  46. /*++
  47. This is the IO Completion routine for WriteFrame.
  48. It is called when an I/O Write request has completed.
  49. --*/
  50. {
  51. NTSTATUS Status;
  52. NTSTATUS PacketStatus;
  53. PASYNC_INFO AsyncInfo;
  54. //
  55. // Make the compiler happy.
  56. //
  57. UNREFERENCED_PARAMETER(DeviceObject);
  58. //
  59. // Initialize locals.
  60. //
  61. AsyncInfo = WanPacket->MacReserved1;
  62. PacketStatus = NDIS_STATUS_FAILURE;
  63. Status = Irp->IoStatus.Status;
  64. //
  65. // Free the irp used to send the packt to the serial driver
  66. //
  67. IoFreeIrp(Irp);
  68. //
  69. // What was the outcome of the IRP.
  70. //
  71. switch ( Status ) {
  72. case STATUS_SUCCESS:
  73. PacketStatus = NDIS_STATUS_SUCCESS;
  74. break;
  75. case STATUS_TIMEOUT:
  76. DbgTracef(-2,("ASYNC: Status TIMEOUT on write\n"));
  77. break;
  78. case STATUS_CANCELLED:
  79. DbgTracef(-2,("ASYNC: Status CANCELLED on write\n"));
  80. break;
  81. case STATUS_PENDING:
  82. DbgTracef(0,("ASYNC: Status PENDING on write\n"));
  83. break;
  84. default:
  85. DbgTracef(-2,("ASYNC: Unknown status 0x%.8x on write", Status));
  86. break;
  87. }
  88. //
  89. // Count this packet completion.
  90. //
  91. AsyncInfo->Out++;
  92. //
  93. // Tell the Wrapper that we have finally the packet has been sent
  94. //
  95. NdisMWanSendComplete(
  96. AsyncInfo->Adapter->MiniportHandle,
  97. WanPacket,
  98. PacketStatus);
  99. //
  100. // We return STATUS_MORE_PROCESSING_REQUIRED so that the
  101. // IoCompletionRoutine will stop working on the IRP.
  102. //
  103. return STATUS_MORE_PROCESSING_REQUIRED;
  104. }
  105. NTSTATUS
  106. AsyncGetFrameFromPool(
  107. IN PASYNC_INFO Info,
  108. OUT PASYNC_FRAME *NewFrame )
  109. /*++
  110. --*/
  111. {
  112. PASYNC_ADAPTER Adapter=Info->Adapter;
  113. PASYNC_FRAME pFrame;
  114. pFrame = (ASYNC_FRAME*)
  115. ExAllocateFromNPagedLookasideList(&Adapter->AsyncFrameList);
  116. if (pFrame == NULL) {
  117. *NewFrame = NULL;
  118. return NDIS_STATUS_RESOURCES;
  119. }
  120. //
  121. // increase by 16 for frame runover padding when we have to resync
  122. //
  123. pFrame->Frame =
  124. (PUCHAR)pFrame + sizeof(ASYNC_FRAME) + sizeof(PVOID);
  125. (ULONG_PTR)pFrame->Frame &= ~((ULONG_PTR)(sizeof(PVOID)-1));
  126. pFrame->FrameLength = Adapter->MaxFrameSize;
  127. // assign back ptr from frame to adapter
  128. pFrame->Adapter=Adapter;
  129. // setup another back ptr
  130. pFrame->Info=Info;
  131. *NewFrame = pFrame;
  132. return(NDIS_STATUS_SUCCESS);
  133. }