|
|
1.1 ! root 1: /*++ ! 2: ! 3: Copyright (c) 1991, 1992, 1993 Microsoft Corporation ! 4: ! 5: Module Name: ! 6: ! 7: purge.c ! 8: ! 9: Abstract: ! 10: ! 11: This module contains the code that is very specific to purge ! 12: operations in the serial driver ! 13: ! 14: Author: ! 15: ! 16: Anthony V. Ercolano 26-Sep-1991 ! 17: ! 18: Environment: ! 19: ! 20: Kernel mode ! 21: ! 22: Revision History : ! 23: ! 24: --*/ ! 25: ! 26: #include <stddef.h> ! 27: #include "ntddk.h" ! 28: #include "ntddser.h" ! 29: #include "serial.h" ! 30: #include "serialp.h" ! 31: ! 32: ! 33: NTSTATUS ! 34: SerialStartPurge( ! 35: IN PSERIAL_DEVICE_EXTENSION Extension ! 36: ) ! 37: ! 38: /*++ ! 39: ! 40: Routine Description: ! 41: ! 42: Depending on the mask in the current irp, purge the interrupt ! 43: buffer, the read queue, or the write queue, or all of the above. ! 44: ! 45: Arguments: ! 46: ! 47: Extension - Pointer to the device extension. ! 48: ! 49: Return Value: ! 50: ! 51: Will return STATUS_SUCCESS always. This is reasonable ! 52: since the DPC completion code that calls this routine doesn't ! 53: care and the purge request always goes through to completion ! 54: once it's started. ! 55: ! 56: --*/ ! 57: ! 58: { ! 59: ! 60: PIRP NewIrp; ! 61: ! 62: do { ! 63: ! 64: ULONG Mask; ! 65: ! 66: Mask = *((ULONG *) ! 67: (Extension->CurrentPurgeIrp->AssociatedIrp.SystemBuffer)); ! 68: ! 69: if (Mask & SERIAL_PURGE_TXABORT) { ! 70: ! 71: SerialKillAllReadsOrWrites( ! 72: Extension->DeviceObject, ! 73: &Extension->WriteQueue, ! 74: &Extension->CurrentWriteIrp ! 75: ); ! 76: ! 77: SerialKillAllReadsOrWrites( ! 78: Extension->DeviceObject, ! 79: &Extension->WriteQueue, ! 80: &Extension->CurrentXoffIrp ! 81: ); ! 82: ! 83: } ! 84: ! 85: if (Mask & SERIAL_PURGE_RXABORT) { ! 86: ! 87: SerialKillAllReadsOrWrites( ! 88: Extension->DeviceObject, ! 89: &Extension->ReadQueue, ! 90: &Extension->CurrentReadIrp ! 91: ); ! 92: ! 93: } ! 94: ! 95: if (Mask & SERIAL_PURGE_RXCLEAR) { ! 96: ! 97: KIRQL OldIrql; ! 98: ! 99: // ! 100: // Clean out the interrupt buffer. ! 101: // ! 102: // Note that we do this under protection of the ! 103: // the drivers control lock so that we don't hose ! 104: // the pointers if there is currently a read that ! 105: // is reading out of the buffer. ! 106: // ! 107: ! 108: KeAcquireSpinLock( ! 109: &Extension->ControlLock, ! 110: &OldIrql ! 111: ); ! 112: ! 113: KeSynchronizeExecution( ! 114: Extension->Interrupt, ! 115: SerialPurgeInterruptBuff, ! 116: Extension ! 117: ); ! 118: ! 119: KeReleaseSpinLock( ! 120: &Extension->ControlLock, ! 121: OldIrql ! 122: ); ! 123: ! 124: } ! 125: ! 126: Extension->CurrentPurgeIrp->IoStatus.Status = STATUS_SUCCESS; ! 127: Extension->CurrentPurgeIrp->IoStatus.Information = 0; ! 128: ! 129: SerialGetNextIrp( ! 130: &Extension->CurrentPurgeIrp, ! 131: &Extension->PurgeQueue, ! 132: &NewIrp, ! 133: TRUE ! 134: ); ! 135: ! 136: } while (NewIrp); ! 137: ! 138: return STATUS_SUCCESS; ! 139: ! 140: } ! 141: ! 142: BOOLEAN ! 143: SerialPurgeInterruptBuff( ! 144: IN PVOID Context ! 145: ) ! 146: ! 147: /*++ ! 148: ! 149: Routine Description: ! 150: ! 151: This routine simply resets the interrupt (typeahead) buffer. ! 152: ! 153: NOTE: This routine is being called from KeSynchronizeExecution. ! 154: ! 155: Arguments: ! 156: ! 157: Context - Really a pointer to the device extension. ! 158: ! 159: Return Value: ! 160: ! 161: Always false. ! 162: ! 163: --*/ ! 164: ! 165: { ! 166: ! 167: PSERIAL_DEVICE_EXTENSION Extension = Context; ! 168: ! 169: // ! 170: // The typeahead buffer is by definition empty if there ! 171: // currently is a read owned by the isr. ! 172: // ! 173: ! 174: ! 175: if (Extension->ReadBufferBase == Extension->InterruptReadBuffer) { ! 176: ! 177: Extension->CurrentCharSlot = Extension->InterruptReadBuffer; ! 178: Extension->FirstReadableChar = Extension->InterruptReadBuffer; ! 179: Extension->LastCharSlot = Extension->InterruptReadBuffer + ! 180: (Extension->BufferSize - 1); ! 181: Extension->CharsInInterruptBuffer = 0; ! 182: ! 183: SerialHandleReducedIntBuffer(Extension); ! 184: ! 185: } ! 186: ! 187: return FALSE; ! 188: ! 189: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.