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.

149 lines
4.2 KiB

  1. /*--------------------------------------------------------------------------
  2. *
  3. * Copyright (C) Cyclades Corporation, 1997-2001.
  4. * All rights reserved.
  5. *
  6. * Cyclades-Z Port Driver
  7. *
  8. * This file: cyzflush.c
  9. *
  10. * Description: This module contains the code related to flush
  11. * operations in the Cyclades-Z Port driver.
  12. *
  13. * Notes: This code supports Windows 2000 and Windows XP,
  14. * x86 and IA64 processors.
  15. *
  16. * Complies with Cyclades SW Coding Standard rev 1.3.
  17. *
  18. *--------------------------------------------------------------------------
  19. */
  20. /*-------------------------------------------------------------------------
  21. *
  22. * Change History
  23. *
  24. *--------------------------------------------------------------------------
  25. *
  26. *
  27. *--------------------------------------------------------------------------
  28. */
  29. #include "precomp.h"
  30. NTSTATUS
  31. CyzStartFlush(
  32. IN PCYZ_DEVICE_EXTENSION Extension
  33. );
  34. #ifdef ALLOC_PRAGMA
  35. #pragma alloc_text(PAGESRP0,CyzFlush)
  36. #pragma alloc_text(PAGESRP0,CyzStartFlush)
  37. #endif
  38. NTSTATUS
  39. CyzFlush(
  40. IN PDEVICE_OBJECT DeviceObject,
  41. IN PIRP Irp
  42. )
  43. /*--------------------------------------------------------------------------
  44. CyzFlush()
  45. Routine Description: This is the dispatch routine for flush. Flushing
  46. works by placing this request in the write queue. When this request
  47. reaches the front of the write queue we simply complete it since this
  48. implies that all previous writes have completed.
  49. Arguments:
  50. DeviceObject - Pointer to the device object for this device
  51. Irp - Pointer to the IRP for the current request
  52. Return Value: Could return status success, cancelled, or pending.
  53. --------------------------------------------------------------------------*/
  54. {
  55. PCYZ_DEVICE_EXTENSION Extension = DeviceObject->DeviceExtension;
  56. NTSTATUS status;
  57. PAGED_CODE();
  58. CyzDbgPrintEx(CYZIRPPATH, "Dispatch entry for: %x\n", Irp);
  59. CyzDbgPrintEx(DPFLTR_TRACE_LEVEL, ">CyzFlush(%X, %X)\n",
  60. DeviceObject, Irp);
  61. Irp->IoStatus.Information = 0L;
  62. if ((status = CyzIRPPrologue(Irp, Extension)) == STATUS_SUCCESS) {
  63. if (CyzCompleteIfError(DeviceObject,Irp) != STATUS_SUCCESS) {
  64. CyzDbgPrintEx(DPFLTR_TRACE_LEVEL, "<CyzFlush (1) %X\n",
  65. STATUS_CANCELLED);
  66. return STATUS_CANCELLED;
  67. }
  68. status = CyzStartOrQueue(Extension, Irp, &Extension->WriteQueue,
  69. &Extension->CurrentWriteIrp,
  70. CyzStartFlush);
  71. CyzDbgPrintEx(DPFLTR_TRACE_LEVEL, "<CyzFlush (2) %X\n", status);
  72. return status;
  73. } else {
  74. Irp->IoStatus.Status = status;
  75. if (!NT_SUCCESS(status)) {
  76. CyzCompleteRequest(Extension, Irp, IO_NO_INCREMENT);
  77. }
  78. CyzDbgPrintEx(DPFLTR_TRACE_LEVEL, "<CyzFlush (3) %X\n", status);
  79. return status;
  80. }
  81. }
  82. NTSTATUS
  83. CyzStartFlush(
  84. IN PCYZ_DEVICE_EXTENSION Extension
  85. )
  86. /*--------------------------------------------------------------------------
  87. CyzStartFlush()
  88. Routine Description: This routine is called if there were no writes in
  89. the queue. The flush became the current write because there was nothing
  90. in the queue. Note however that does not mean there is nothing in the
  91. queue now! So, we will start off the write that might follow us.
  92. Arguments:
  93. Extension - Points to the serial device extension
  94. Return Value: This will always return STATUS_SUCCESS.
  95. --------------------------------------------------------------------------*/
  96. {
  97. PIRP NewIrp;
  98. PAGED_CODE();
  99. Extension->CurrentWriteIrp->IoStatus.Status = STATUS_SUCCESS;
  100. // The following call will actually complete the flush.
  101. CyzGetNextWrite(
  102. &Extension->CurrentWriteIrp,
  103. &Extension->WriteQueue,
  104. &NewIrp,
  105. TRUE,
  106. Extension
  107. );
  108. if (NewIrp) {
  109. ASSERT(NewIrp == Extension->CurrentWriteIrp);
  110. CyzStartWrite(Extension);
  111. }
  112. return STATUS_SUCCESS;
  113. }
  114.