|
|
1.1 ! root 1: /*++ ! 2: ! 3: Copyright (c) 1993 - Colorado Memory Systems, Inc. ! 4: All Rights Reserved ! 5: ! 6: Module Name: ! 7: ! 8: process.c ! 9: ! 10: Abstract: ! 11: ! 12: Processes one low-level request. ! 13: ! 14: Revision History: ! 15: ! 16: ! 17: ! 18: ! 19: --*/ ! 20: ! 21: // ! 22: // include files ! 23: // ! 24: ! 25: #include <ntddk.h> // various NT definitions ! 26: #include <ntdddisk.h> // disk device driver I/O control codes ! 27: #include <ntiologc.h> ! 28: #include "common.h" ! 29: #include "drvtask.h" // this driver's data declarations ! 30: #include "mt1defs.h" // this driver's data declarations ! 31: #include "mt1strc.h" // this driver's data declarations ! 32: #include "q117data.h" // this driver's data declarations ! 33: ! 34: ! 35: ! 36: NTSTATUS ! 37: Q117iProcessItem( ! 38: IN OUT PIRP Irp ! 39: ) ! 40: ! 41: /*++ ! 42: ! 43: Routine Description: ! 44: ! 45: Determine type of I/O operation being requested, Call appropriate ! 46: subroutines. ! 47: ! 48: In block mode operation this routine returns when done processing ! 49: the queue. However, in concurrent operation (task switching or ! 50: non-block mode) the routine NEVER returns. Therefore, it is up ! 51: to ClearIO to stop the task. ! 52: ! 53: Arguments: ! 54: ! 55: Irp - ! 56: ! 57: Return Value: ! 58: ! 59: ! 60: ! 61: --*/ ! 62: ! 63: { ! 64: PTAPE_EXTENSION tapeExtension; ! 65: STATUS retval = NoErr; ! 66: PIO_REQUEST Item; ! 67: PIO_STACK_LOCATION irpStack = IoGetCurrentIrpStackLocation(Irp); ! 68: ! 69: ! 70: tapeExtension = irpStack->DeviceObject->DeviceExtension; ! 71: tapeExtension->QDeviceObject = irpStack->DeviceObject; ! 72: tapeExtension->NoPause = FALSE; ! 73: Item = irpStack->Parameters.DeviceIoControl.Type3InputBuffer; ! 74: ! 75: if ((tapeExtension->QControllerData->DriveSelect.Selected == FALSE) && ! 76: tapeExtension->QControllerData->CurrentInterrupt && ! 77: tapeExtension->Found) { ! 78: ! 79: retval = Q117iSelectDrive(tapeExtension); ! 80: ! 81: } ! 82: ! 83: if (retval == NoErr) { ! 84: ! 85: switch (Item->Command) { ! 86: ! 87: case DFmt: ! 88: retval = Q117iSetDriveMode(tapeExtension, FORMAT_MODE); ! 89: break; ! 90: ! 91: case DVerify: ! 92: retval = Q117iSetDriveMode(tapeExtension, VERIFY_MODE); ! 93: break; ! 94: ! 95: default: ! 96: retval = Q117iSetDriveMode(tapeExtension, PRIMARY_MODE); ! 97: ! 98: } ! 99: ! 100: if (retval == NoErr) { ! 101: ! 102: retval = Q117iTapeCommands(tapeExtension, Item, Irp); ! 103: ! 104: } ! 105: ! 106: Item->FirmwareError = tapeExtension->FirmwareError; ! 107: ! 108: if (tapeExtension->QControllerData->QueueEmpty) { ! 109: ! 110: if (tapeExtension->NoPause == FALSE) { ! 111: ! 112: if (Q117iGetDriveError(tapeExtension) == NotRdy) { ! 113: ! 114: Q117iPauseTape(tapeExtension); ! 115: ! 116: } ! 117: } ! 118: ! 119: if (tapeExtension->NewCart) { ! 120: ! 121: Q117iNewTape(tapeExtension); ! 122: ! 123: } ! 124: } ! 125: } ! 126: ! 127: Item->Status = retval; ! 128: ! 129: #if DBG ! 130: #define TapeExtension tapeExtension ! 131: DbgAddEntry(0x1234567d); ! 132: DbgAddEntry(Item->Command); ! 133: DbgAddEntry(Item->Status); ! 134: TapeExtension->DbgLockout = FALSE; ! 135: #endif ! 136: ! 137: return Q117iTranslateError(tapeExtension->QDeviceObject, retval); ! 138: } ! 139: ! 140: STATUS ! 141: Q117iSetDriveMode( ! 142: IN PTAPE_EXTENSION TapeExtension, ! 143: CHAR Mode ! 144: ) ! 145: ! 146: /*++ ! 147: ! 148: Routine Description: ! 149: ! 150: Set the mode of the tape drive according to the command to the ! 151: driver. ! 152: ! 153: Arguments: ! 154: ! 155: TapeExtension - ! 156: ! 157: Mode - ! 158: ! 159: Return Value: ! 160: ! 161: ! 162: ! 163: --*/ ! 164: ! 165: { ! 166: STATUS retval = 0; ! 167: UCHAR modeCmd; ! 168: ! 169: if (Mode == TapeExtension->DriveParms.Mode) { ! 170: ! 171: return(NoErr); ! 172: ! 173: } ! 174: ! 175: if (TapeExtension->DriveParms.Mode == PRIMARY_MODE || ! 176: TapeExtension->DriveParms.Mode == VERIFY_MODE || ! 177: TapeExtension->DriveParms.Mode == FORMAT_MODE) { ! 178: ! 179: retval = Q117iStopTape(TapeExtension); ! 180: ! 181: if (retval != NoErr && retval != NoTape) { ! 182: ! 183: return(retval); ! 184: ! 185: } ! 186: } ! 187: ! 188: switch (Mode) { ! 189: ! 190: case PRIMARY_MODE: ! 191: modeCmd = Primary_Mode; ! 192: break; ! 193: ! 194: case VERIFY_MODE: ! 195: modeCmd = Verify_Mode; ! 196: break; ! 197: ! 198: case FORMAT_MODE: ! 199: modeCmd = Format_Mode; ! 200: break; ! 201: ! 202: case DIAGNOSTIC_1_MODE: ! 203: modeCmd = Diag_1_Mode; ! 204: break; ! 205: ! 206: case DIAGNOSTIC_2_MODE: ! 207: modeCmd = Diag_2_Mode; ! 208: break; ! 209: ! 210: default: ! 211: return(InvalCmd); ! 212: ! 213: } ! 214: ! 215: if ((retval = Q117iSendByte(TapeExtension, modeCmd)) != NoErr) { ! 216: ! 217: return(retval); ! 218: ! 219: } ! 220: ! 221: Q117iSleep(TapeExtension, mt_wt2ticks, FALSE); ! 222: ! 223: if (Mode == DIAGNOSTIC_1_MODE || Mode == DIAGNOSTIC_2_MODE) { ! 224: ! 225: if ((retval = Q117iSendByte(TapeExtension, modeCmd)) != NoErr) { ! 226: ! 227: return(retval); ! 228: ! 229: } ! 230: ! 231: Q117iSleep(TapeExtension, mt_wt2ticks, FALSE); ! 232: ! 233: } else { ! 234: ! 235: if ((retval = Q117iGetDriveError(TapeExtension)) == NotRdy) { ! 236: ! 237: retval = DriveFlt; ! 238: ! 239: } ! 240: } ! 241: ! 242: TapeExtension->DriveParms.Mode = Mode; ! 243: return(retval); ! 244: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.