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.

134 lines
2.9 KiB

  1. /*++
  2. Copyright (c) 1991, 1992, 1993 Microsoft Corporation
  3. Module Name:
  4. purge.c
  5. Abstract:
  6. This module contains the code that is very specific to purge
  7. operations in the serial driver
  8. Author:
  9. Anthony V. Ercolano 26-Sep-1991
  10. Environment:
  11. Kernel mode
  12. Revision History :
  13. --*/
  14. #include "precomp.h"
  15. #ifdef ALLOC_PRAGMA
  16. #endif
  17. NTSTATUS
  18. SerialStartPurge(IN PPORT_DEVICE_EXTENSION pPort)
  19. /*++
  20. Routine Description:
  21. Depending on the mask in the current irp, purge the interrupt
  22. buffer, the read queue, or the write queue, or all of the above.
  23. Arguments:
  24. Extension - Pointer to the device extension.
  25. Return Value:
  26. Will return STATUS_SUCCESS always. This is reasonable
  27. since the DPC completion code that calls this routine doesn't
  28. care and the purge request always goes through to completion
  29. once it's started.
  30. --*/
  31. {
  32. PIRP NewIrp;
  33. do
  34. {
  35. ULONG Mask;
  36. Mask = *((ULONG *)(pPort->CurrentPurgeIrp->AssociatedIrp.SystemBuffer));
  37. if(Mask & SERIAL_PURGE_TXABORT)
  38. {
  39. SerialKillAllReadsOrWrites(pPort->DeviceObject, &pPort->WriteQueue, &pPort->CurrentWriteIrp);
  40. SerialKillAllReadsOrWrites(pPort->DeviceObject, &pPort->WriteQueue, &pPort->CurrentXoffIrp);
  41. }
  42. if(Mask & SERIAL_PURGE_RXABORT)
  43. SerialKillAllReadsOrWrites(pPort->DeviceObject, &pPort->ReadQueue, &pPort->CurrentReadIrp);
  44. if(Mask & SERIAL_PURGE_RXCLEAR)
  45. {
  46. KIRQL OldIrql;
  47. // Clean out the interrupt buffer.
  48. //
  49. // Note that we do this under protection of the
  50. // the drivers control lock so that we don't hose
  51. // the pointers if there is currently a read that
  52. // is reading out of the buffer.
  53. KeAcquireSpinLock(&pPort->ControlLock, &OldIrql);
  54. KeSynchronizeExecution(pPort->Interrupt, SerialPurgeInterruptBuff, pPort);
  55. KeReleaseSpinLock(&pPort->ControlLock, OldIrql);
  56. }
  57. pPort->CurrentPurgeIrp->IoStatus.Status = STATUS_SUCCESS;
  58. pPort->CurrentPurgeIrp->IoStatus.Information = 0;
  59. SerialGetNextIrp(pPort, &pPort->CurrentPurgeIrp, &pPort->PurgeQueue, &NewIrp, TRUE);
  60. } while (NewIrp);
  61. return STATUS_SUCCESS;
  62. }
  63. BOOLEAN
  64. SerialPurgeInterruptBuff(IN PVOID Context)
  65. /*++
  66. Routine Description:
  67. This routine simply resets the interrupt (typeahead) buffer.
  68. NOTE: This routine is being called from KeSynchronizeExecution.
  69. Arguments:
  70. Context - Really a pointer to the device extension.
  71. Return Value:
  72. Always false.
  73. --*/
  74. {
  75. PPORT_DEVICE_EXTENSION pPort = Context;
  76. // Flush the IN buffer
  77. pPort->pUartLib->UL_BufferControl_XXXX(pPort->pUart, NULL, UL_BC_OP_FLUSH, UL_BC_BUFFER | UL_BC_IN);
  78. SerialHandleReducedIntBuffer(pPort);
  79. return FALSE;
  80. }