|
|
1.1 ! root 1: /*++ ! 2: ! 3: Copyright (c) 1993 - Colorado Memory Systems, Inc. ! 4: All Rights Reserved ! 5: ! 6: Module Name: ! 7: ! 8: config.c ! 9: ! 10: Abstract: ! 11: ! 12: configures the FDC and drive to the correct speed. ! 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: STATUS ! 36: Q117iConfigureDrive( ! 37: IN PTAPE_EXTENSION TapeExtension ! 38: ) ! 39: ! 40: /*++ ! 41: ! 42: Routine Description: ! 43: ! 44: Configure the tape drive with a pre-defined state. ! 45: ! 46: Put the tape drive into the Primary mode. This command should work ! 47: regardless of the current state of the drive. ! 48: ! 49: Set or determine the tape speed depending upon whether or not the ! 50: tape drive is a CMS drive. ! 51: ! 52: Read the current track or set the current track to 0 also depending ! 53: upon whether or not the tape drive is a CMS drive. ! 54: ! 55: Arguments: ! 56: ! 57: TapeExtension - ! 58: ! 59: Return Value: ! 60: ! 61: ! 62: ! 63: --*/ ! 64: ! 65: { ! 66: STATUS retval = NoErr; // return value ! 67: CHAR newSpeed; // tape drive transfer rate ! 68: ! 69: // ! 70: // Make sure that the tape drive is out there. ! 71: // ! 72: ! 73: retval = Q117iGetDriveError(TapeExtension); ! 74: ! 75: if (retval && retval != NoTape) { ! 76: ! 77: return(retval); ! 78: ! 79: } ! 80: ! 81: // ! 82: // We will only configure (set the transfer rate) the tape drive if we ! 83: // know that it is ours. This is because we assume that our drive is ! 84: // the only variable speed drive available. ! 85: // ! 86: ! 87: if (TapeExtension->SpeedChangeOK) { ! 88: ! 89: // ! 90: // Send the Select_Speed command to the tape drive. This ommand is sent ! 91: // in 2 parts (cmd - arg) and we must be sure that the drive is ready to ! 92: // receive the argument before sending it. The drive is ready either when ! 93: // it starts generating index pusles or after approximately 20 ms. ! 94: // ! 95: ! 96: if ((retval = Q117iSendByte(TapeExtension, Select_Speed)) != NoErr) { ! 97: ! 98: return(retval); ! 99: ! 100: } ! 101: ! 102: Q117iSleep(TapeExtension, mt_wt2ticks, FALSE); ! 103: ! 104: if (TapeExtension->XferRate.XferRate == FAST) { ! 105: ! 106: newSpeed = TapeExtension->XferRate.TapeFast + 2; ! 107: ! 108: } else { ! 109: ! 110: newSpeed = TapeExtension->XferRate.TapeSlow + 2; ! 111: ! 112: } ! 113: ! 114: if ((retval = Q117iSendByte(TapeExtension, newSpeed)) != NoErr) { ! 115: ! 116: return(retval); ! 117: ! 118: } ! 119: ! 120: // ! 121: // Wait for the drive to become ready again. Specified time is 10 ! 122: // secs. ! 123: // ! 124: ! 125: retval = Q117iWaitCommandComplete(TapeExtension, mt_wt010s); ! 126: ! 127: if (retval && retval != NoTape) { ! 128: ! 129: return(retval); ! 130: ! 131: } ! 132: ! 133: // ! 134: // Set the current track indicator to an unknow position. This will ! 135: // force a track change command on the first read write to the tape. ! 136: // ! 137: ! 138: TapeExtension->TapePosition.C_Track = -1; ! 139: } ! 140: ! 141: return(NoErr); ! 142: } ! 143: ! 144: ! 145: STATUS ! 146: Q117iConfigureFDC( ! 147: IN PTAPE_EXTENSION TapeExtension ! 148: ) ! 149: ! 150: /*++ ! 151: ! 152: Routine Description: ! 153: ! 154: To configure the floppy controller chip according to the current ! 155: FDC parameters. ! 156: ! 157: Arguments: ! 158: ! 159: TapeExtension - ! 160: ! 161: Return Value: ! 162: ! 163: ! 164: --*/ ! 165: ! 166: { ! 167: STATUS retval; ! 168: CHAR fdcType; // flag to indicate an 82077 FDC ! 169: struct specify_cmd setup_N; ! 170: struct config_cmd configure; ! 171: ! 172: if (TapeExtension->XferRate.XferRate == FAST) { ! 173: ! 174: Q117iDCR_Out(TapeExtension, TapeExtension->XferRate.FDC_Fast); ! 175: ! 176: } else { ! 177: ! 178: Q117iDCR_Out(TapeExtension, TapeExtension->XferRate.FDC_Slow); ! 179: ! 180: } ! 181: ! 182: ! 183: // Determine if the FDC is an 82077 ! 184: ! 185: if ((retval = Q117iDGetFDC(TapeExtension, (PUCHAR)&fdcType)) != NoErr) { ! 186: ! 187: return(retval); ! 188: ! 189: } ! 190: ! 191: if (fdcType == FDC_82077 || ! 192: fdcType == FDC_82077AA || ! 193: fdcType == FDC_82078_44 || ! 194: fdcType == FDC_82078_64 || ! 195: fdcType == FDC_NATIONAL) { ! 196: ! 197: WRITE_CONTROLLER(&TapeExtension->QControllerData->FDC_Addr->tdr, ! 198: curu); ! 199: ! 200: if (TapeExtension->XferRate.XferRate == FAST) { ! 201: ! 202: WRITE_CONTROLLER(&TapeExtension->QControllerData->FDC_Addr->MSDSR.dsr, ! 203: TapeExtension->XferRate.FDC_Fast); ! 204: ! 205: if (TapeExtension->XferRate.FDC_Fast == FDC_500Kbps) { ! 206: ! 207: WRITE_CONTROLLER(&TapeExtension->QControllerData->FDC_Addr->tdr, ! 208: curb); ! 209: ! 210: } ! 211: ! 212: } else { ! 213: ! 214: WRITE_CONTROLLER( ! 215: &TapeExtension->QControllerData->FDC_Addr->MSDSR.dsr, ! 216: TapeExtension->XferRate.FDC_Slow); ! 217: ! 218: if (TapeExtension->XferRate.FDC_Slow == FDC_250Kbps) { ! 219: ! 220: WRITE_CONTROLLER( ! 221: &TapeExtension->QControllerData->FDC_Addr->tdr, ! 222: curb); ! 223: } ! 224: ! 225: if (TapeExtension->XferRate.FDC_Slow == FDC_500Kbps) { ! 226: ! 227: WRITE_CONTROLLER( ! 228: &TapeExtension->QControllerData->FDC_Addr->tdr, ! 229: curb); ! 230: ! 231: } ! 232: } ! 233: ! 234: configure.cmd = FDC_CONFIG; ! 235: configure.czero = 0; ! 236: configure.FIFOTHR = FDC_FIFO; ! 237: configure.POLL = 0; ! 238: configure.EFIFO = 0; ! 239: configure.EIS = 0; ! 240: configure.reserved = 0; ! 241: configure.PRETRK = 0x00; ! 242: ! 243: if (retval = Q117iProgramFDC(TapeExtension, ! 244: (CHAR *)&configure, ! 245: sizeof(configure), ! 246: FALSE)) { ! 247: ! 248: return(retval); ! 249: ! 250: } ! 251: } ! 252: ! 253: setup_N.command = FDC_SPECIFY; ! 254: setup_N.SRT_HUT = TapeExtension->XferRate.XferRate ? ! 255: TapeExtension->XferRate.SRT_Fast : ! 256: TapeExtension->XferRate.SRT_Slow; ! 257: setup_N.HLT_ND = 0x02; ! 258: retval = Q117iProgramFDC(TapeExtension, ! 259: (CHAR *)&setup_N, ! 260: sizeof(setup_N), ! 261: FALSE); ! 262: ! 263: return(retval); ! 264: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.