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.

111 lines
2.9 KiB

  1. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Copyright (c) 1991, 1992, 1993 Microsoft Corporation
  3. Module Name:
  4. flush.c
  5. Abstract:
  6. This module contains the code that is very specific to flush
  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. // Prototypes
  16. NTSTATUS SerialStartFlush(IN PPORT_DEVICE_EXTENSION pPort);
  17. // End of prototypes
  18. #ifdef ALLOC_PRAGMA
  19. #endif
  20. NTSTATUS
  21. SerialFlush(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
  22. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  23. Routine Description:
  24. This is the dispatch routine for flush. Flushing works by placing
  25. this request in the write queue. When this request reaches the
  26. front of the write queue we simply complete it since this implies
  27. that all previous writes have completed.
  28. Arguments:
  29. DeviceObject - Pointer to the device object for this device
  30. Irp - Pointer to the IRP for the current request
  31. Return Value:
  32. Could return status success, cancelled, or pending.
  33. -----------------------------------------------------------------------------*/
  34. {
  35. PPORT_DEVICE_EXTENSION pPort = DeviceObject->DeviceExtension;
  36. SerialDump(SERIRPPATH, ("Dispatch entry for: %x\n", Irp));
  37. SpxIRPCounter(pPort, Irp, IRP_SUBMITTED); // Increment counter for performance stats.
  38. Irp->IoStatus.Information = 0L;
  39. if(SerialCompleteIfError(DeviceObject, Irp) != STATUS_SUCCESS)
  40. return STATUS_CANCELLED;
  41. return SerialStartOrQueue(pPort, Irp, &pPort->WriteQueue, &pPort->CurrentWriteIrp, SerialStartFlush);
  42. }
  43. NTSTATUS
  44. SerialStartFlush(IN PPORT_DEVICE_EXTENSION pPort)
  45. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  46. Routine Description:
  47. This routine is called if there were no writes in the queue.
  48. The flush became the current write because there was nothing
  49. in the queue. Note however that does not mean there is
  50. nothing in the queue now! So, we will start off the write
  51. that might follow us.
  52. Arguments:
  53. Extension - Points to the serial device extension
  54. Return Value:
  55. This will always return STATUS_SUCCESS.
  56. -----------------------------------------------------------------------------*/
  57. {
  58. PIRP NewIrp;
  59. pPort->CurrentWriteIrp->IoStatus.Status = STATUS_SUCCESS;
  60. // The following call will actually complete the flush.
  61. SerialGetNextWrite(pPort, &pPort->CurrentWriteIrp, &pPort->WriteQueue, &NewIrp, TRUE);
  62. if(NewIrp)
  63. {
  64. ASSERT(NewIrp == pPort->CurrentWriteIrp);
  65. SerialStartWrite(pPort);
  66. }
  67. return STATUS_SUCCESS;
  68. }