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.

164 lines
3.1 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. NTSTATUS
  16. SerialStartFlush(
  17. IN PSERIAL_DEVICE_EXTENSION Extension
  18. );
  19. #ifdef ALLOC_PRAGMA
  20. #pragma alloc_text(PAGESRP0,SerialFlush)
  21. #pragma alloc_text(PAGESRP0,SerialStartFlush)
  22. #endif
  23. NTSTATUS
  24. SerialFlush(
  25. IN PDEVICE_OBJECT DeviceObject,
  26. IN PIRP Irp
  27. )
  28. /*++
  29. Routine Description:
  30. This is the dispatch routine for flush. Flushing works by placing
  31. this request in the write queue. When this request reaches the
  32. front of the write queue we simply complete it since this implies
  33. that all previous writes have completed.
  34. Arguments:
  35. DeviceObject - Pointer to the device object for this device
  36. Irp - Pointer to the IRP for the current request
  37. Return Value:
  38. Could return status success, cancelled, or pending.
  39. --*/
  40. {
  41. PSERIAL_DEVICE_EXTENSION Extension = DeviceObject->DeviceExtension;
  42. NTSTATUS status;
  43. PAGED_CODE();
  44. SerialDump(
  45. SERIRPPATH,
  46. ("SERIAL: Dispatch entry for: %x\n",Irp)
  47. );
  48. SerialDump(SERTRACECALLS, ("SERIAL: Entering SerialFlush\n"));
  49. Irp->IoStatus.Information = 0L;
  50. if ((status = SerialIRPPrologue(Irp, Extension)) == STATUS_SUCCESS) {
  51. if (SerialCompleteIfError(DeviceObject, Irp) != STATUS_SUCCESS) {
  52. SerialDump(SERTRACECALLS, ("SERIAL: Leaving SerialFlush (1)\n"));
  53. return STATUS_CANCELLED;
  54. }
  55. SerialDump(SERTRACECALLS, ("SERIAL: Leaving SerialFlush (2)\n"));
  56. return SerialStartOrQueue(Extension, Irp, &Extension->WriteQueue,
  57. &Extension->CurrentWriteIrp, SerialStartFlush);
  58. } else {
  59. Irp->IoStatus.Status = status;
  60. if (!NT_SUCCESS(status)) {
  61. SerialCompleteRequest(Extension, Irp, IO_NO_INCREMENT);
  62. }
  63. SerialDump(SERTRACECALLS, ("SERIAL: Leaving SerialFlush (3)\n"));
  64. return status;
  65. }
  66. }
  67. NTSTATUS
  68. SerialStartFlush(
  69. IN PSERIAL_DEVICE_EXTENSION Extension
  70. )
  71. /*++
  72. Routine Description:
  73. This routine is called if there were no writes in the queue.
  74. The flush became the current write because there was nothing
  75. in the queue. Note however that does not mean there is
  76. nothing in the queue now! So, we will start off the write
  77. that might follow us.
  78. Arguments:
  79. Extension - Points to the serial device extension
  80. Return Value:
  81. This will always return STATUS_SUCCESS.
  82. --*/
  83. {
  84. PIRP NewIrp;
  85. PAGED_CODE();
  86. Extension->CurrentWriteIrp->IoStatus.Status = STATUS_SUCCESS;
  87. //
  88. // The following call will actually complete the flush.
  89. //
  90. SerialGetNextWrite(
  91. &Extension->CurrentWriteIrp,
  92. &Extension->WriteQueue,
  93. &NewIrp,
  94. TRUE,
  95. Extension
  96. );
  97. if (NewIrp) {
  98. ASSERT(NewIrp == Extension->CurrentWriteIrp);
  99. SerialStartWrite(Extension);
  100. }
  101. return STATUS_SUCCESS;
  102. }