Annotation of ntddk/src/scsi/qic117/geterror.c, revision 1.1

1.1     ! root        1: /*++
        !             2: 
        !             3: Copyright (c) 1993 - Colorado Memory Systems, Inc.
        !             4: All Rights Reserved
        !             5: 
        !             6: Module Name:
        !             7: 
        !             8:     geterror.c
        !             9: 
        !            10: Abstract:
        !            11: 
        !            12:     Converts QIC117 firmware errors.
        !            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: Q117iConvertFirmwareError(
        !            37:     IN FIRMWARE_ERROR FirmwareError
        !            38:     )
        !            39: 
        !            40: /*++
        !            41: 
        !            42: Routine Description:
        !            43: 
        !            44: Arguments:
        !            45: 
        !            46:     FirmwareError -
        !            47: 
        !            48: Return Value:
        !            49: 
        !            50: --*/
        !            51: 
        !            52: {
        !            53:     CheckedDump(QIC117INFO,( "Q117i - Firmware error %d (decimal)\n", FirmwareError ));
        !            54: 
        !            55:     switch (FirmwareError) {
        !            56: 
        !            57:     case 0:                  // 0 - no error
        !            58:         return(NoErr);
        !            59:         break;
        !            60: 
        !            61:     case 1:                 // 1 - command receive while drive not ready
        !            62:         return(InvalCmd);
        !            63:         break;
        !            64: 
        !            65:     case 2:                 // 2 - cartridge not present or removed
        !            66:         return(NoTape);
        !            67:         break;
        !            68: 
        !            69:     case 3:                 // 3 - motor speed error
        !            70:     case 4:                 // 4 - motor speed anomaly (motor jammed or gross speed error)
        !            71:         return(TapeFlt);
        !            72:         break;
        !            73: 
        !            74:     case 5:                 // 5 - cartridge write protected
        !            75:         return(WProt);
        !            76:         break;
        !            77: 
        !            78:     case 6:                 // 6 - undefined or reserved command code
        !            79:         return(InvalCmd);
        !            80:         break;
        !            81: 
        !            82:     case 7:                 // 7 - illegal track address specified for Seek
        !            83:         CheckedDump(QIC117WARN,( "SeekErr - illegal track address specified for Seek\n" ));
        !            84:         return(SeekErr);
        !            85:         break;
        !            86: 
        !            87:     case 8:                 // 8 - illegal command in report subcontext
        !            88:     case 9:                 // 9 - illegal entry attempt into a diagnostic mode
        !            89:         return(InvalCmd);
        !            90:         break;
        !            91: 
        !            92:     case 10:                // 10 - broken tape detected (based on hole and motor sensors)
        !            93:     case 11:                // 11 - Warning -- read gain setting error
        !            94:         return(TapeFlt);
        !            95:         break;
        !            96: 
        !            97:     case 12:                // 12 - command Received while error status pending
        !            98:     case 13:                // 13 - command received while new cartridge pending
        !            99:     case 14:                // 14 - command illegal or undefined in primary mode
        !           100:     case 15:                // 15 - command illegal or undefined in format mode
        !           101:     case 16:                // 16 - command illegal or undefined in verify mode
        !           102:         return(InvalCmd);
        !           103:         break;
        !           104: 
        !           105:     case 17:                // 17 - logical forward not a logical BOT in format mode
        !           106:         CheckedDump(QIC117WARN,( "SeekErr - logical forward not a logical BOT in format mode\n" ));
        !           107:         return(SeekErr);
        !           108:         break;
        !           109: 
        !           110:     case 18:                // 18 - logical EOT before all segments generated -- format mode
        !           111:         return(EndTapeErr);
        !           112:         break;
        !           113: 
        !           114:     case 19:                // 19 - command illegal when cartridge not referenced
        !           115:         return(InvalCmd);
        !           116:         break;
        !           117: 
        !           118:     case 20:                // 20 - self-diagnostic failed -- NOTE: this error CANNOT BE CLEARED
        !           119:     case 21:                // 21 - Warning -- EEPROM not initialized default settings in effect
        !           120:     case 22:                // 22 - EEPROM contents corrupted or EEPROM hardware malfunction
        !           121:     case 23:                // 23 - tape motion timeout (max EOT-to-BOT time exceeded)
        !           122:     case 24:                // 24 - data segment too long -- logical forward or pause
        !           123:     case 25:                // 25 - command transmit overrun (usually a firmware bug)
        !           124:     case 26:                // 26 - power on reset occurred
        !           125:     case 27:                // 27 - software initiated reset occurred
        !           126:     case 28:                // 28 - model-dependant diagnostic error
        !           127:     case 29:                // 29 - model-independant diagnostic error
        !           128:         return(TapeFlt);
        !           129:         break;
        !           130: 
        !           131:     case 30:                // 30 - command received during non-interruptible process
        !           132:         return(InvalCmd);
        !           133:         break;
        !           134: 
        !           135:     case 31:                // 31 - speed selection requested is not available on this drive
        !           136:         return(UnspRate);
        !           137:         break;
        !           138: 
        !           139:     case 32:                // 32 - command illegal while in high speed mode
        !           140:         return(InvalCmd);
        !           141:         break;
        !           142: 
        !           143:     case 33:                // 33 - illegal segment specified for Seek
        !           144:         CheckedDump(QIC117WARN,( "SeekErr - illegal segment specified for Seek\n" ));
        !           145:         return(SeekErr);
        !           146:         break;
        !           147: 
        !           148:     case 34:                // 34 - invalid tape media
        !           149:     case 35:                // 35 - head reference failure
        !           150:     case 36:                // 36 - edge seek error
        !           151:     case 37:                // 37 - Missing Training Table
        !           152:     case 38:                // 38 - Invalid Format
        !           153:     case 39:                // 39 - EOT/BOT Sensor Failure
        !           154:     case 40:                // 40 - Training Table Checksum Error
        !           155:     case 41:                // 41 - Watchdog Timer Reset Occurred
        !           156:     case 42:                // 42 - Illegal Error Number
        !           157:         return(TapeFlt);
        !           158:         break;
        !           159: 
        !           160:     default:
        !           161:         return(TapeFlt);
        !           162: 
        !           163:     }
        !           164: }
        !           165: 
        !           166: 
        !           167: STATUS
        !           168: Q117iGetDriveError(
        !           169:     IN PTAPE_EXTENSION TapeExtension
        !           170:     )
        !           171: /*++
        !           172: 
        !           173: Routine Description:
        !           174: 
        !           175:     Read the tape drive Status byte and, if necessary, the tape drive
        !           176:     Error information.
        !           177: 
        !           178:         Read the Drive Status byte from the tape drive.
        !           179: 
        !           180:         If the drive status indicates that the tape drive has an error to
        !           181:         report, read the error information which includes both the error
        !           182:         code and the command that was being executed when the error occurred.
        !           183: 
        !           184: Arguments:
        !           185: 
        !           186:     TapeExtension -
        !           187: 
        !           188: Return Value:
        !           189: 
        !           190: --*/
        !           191: 
        !           192: {
        !           193:     STATUS retval = 0;
        !           194:     struct DriveStatus drvStat;
        !           195:     USHORT drvErr;
        !           196:     BOOLEAN repeatReport;
        !           197:     BOOLEAN newCart;
        !           198:     BOOLEAN ESD_Retry = FALSE;
        !           199: 
        !           200:     TapeExtension->FirmwareError = NoErr;
        !           201:     newCart = FALSE;
        !           202: 
        !           203:     do {
        !           204: 
        !           205:     repeatReport = FALSE;
        !           206: 
        !           207:         if ((retval = Q117iReport(TapeExtension,
        !           208:                                 Report_Status,
        !           209:                                 (USHORT *)&drvStat,
        !           210:                                 READ_BYTE,
        !           211:                                 &ESD_Retry)) != NoErr) {
        !           212: 
        !           213:             return(retval);
        !           214: 
        !           215:         }
        !           216: 
        !           217:         CheckedDump(QIC117DRVSTAT,( "QIC117: Drv status = %02x\n",drvStat ));
        !           218: 
        !           219:         TapeExtension->DriveParms.Status = drvStat;
        !           220: 
        !           221:         if (!drvStat.Ready) {
        !           222: 
        !           223:             return(NotRdy);
        !           224: 
        !           225:         }
        !           226: 
        !           227:         if (!drvStat.CartPresent) {
        !           228: 
        !           229:             TapeExtension->NoCart = TRUE;
        !           230:             TapeExtension->PersistentNewCart = FALSE;
        !           231: 
        !           232:         }
        !           233: 
        !           234:         if (TapeExtension->DriveParms.Flavor == IOMEGA) {
        !           235: 
        !           236:             if (drvStat.CartPresent &&
        !           237:                 TapeExtension->NoCart) {
        !           238: 
        !           239:                 newCart = TRUE;
        !           240:                 TapeExtension->NewCart = TRUE;
        !           241:                 TapeExtension->NoCart = FALSE;
        !           242: 
        !           243:             }
        !           244: 
        !           245:         }
        !           246: 
        !           247:         if (drvStat.NewCart) {
        !           248: 
        !           249:             newCart = TRUE;
        !           250:             TapeExtension->NewCart = TRUE;
        !           251: 
        !           252:         }
        !           253: 
        !           254:         if (drvStat.NewCart || drvStat.Error) {
        !           255: 
        !           256:             if((retval = Q117iReport(TapeExtension,
        !           257:                                     Report_Error,
        !           258:                                     &drvErr,
        !           259:                                     READ_WORD,
        !           260:                                     &ESD_Retry)) != NoErr) {
        !           261: 
        !           262:                 return(retval);
        !           263: 
        !           264:             }
        !           265: 
        !           266:             CheckedDump(QIC117DRVSTAT,( "QIC117: Drv error  = 0x%02x\n",drvErr ));
        !           267: 
        !           268:             if (drvStat.Error) {
        !           269: 
        !           270:                 TapeExtension->FirmwareError = (UCHAR)drvErr;
        !           271: 
        !           272:                 if (TapeExtension->FirmwareError == Cmd_on_New_Cart) {
        !           273: 
        !           274:                     newCart = TRUE;
        !           275:                     TapeExtension->NewCart = TRUE;
        !           276: 
        !           277:                 }
        !           278: 
        !           279:             } else {
        !           280: 
        !           281:                 TapeExtension->FirmwareError = NoErr;
        !           282: 
        !           283:             }
        !           284: 
        !           285:             if (TapeExtension->FirmwareError) {
        !           286: 
        !           287:                 if ((TapeExtension->FirmwareError == Cmd_in_Rpt) &&
        !           288:                     ESD_Retry) {
        !           289: 
        !           290:                     ESD_Retry = FALSE;
        !           291:                     repeatReport = TRUE;
        !           292: 
        !           293:                 } else {
        !           294: 
        !           295:                     return(Q117iConvertFirmwareError(
        !           296:                                 TapeExtension->FirmwareError));
        !           297: 
        !           298:                 }
        !           299:             }
        !           300:         }
        !           301: 
        !           302:     } while (repeatReport);
        !           303: 
        !           304:     if (newCart) {
        !           305: 
        !           306:         TapeExtension->PersistentNewCart = TRUE;
        !           307: 
        !           308:     }
        !           309: 
        !           310: 
        !           311:         if (TapeExtension->Found) {
        !           312: 
        !           313:         if (!drvStat.CartPresent) {
        !           314: 
        !           315:             return(NoTape);
        !           316: 
        !           317:         }
        !           318: 
        !           319:         if (newCart) {
        !           320: 
        !           321:             return(NewCart);
        !           322: 
        !           323:         }
        !           324:     }
        !           325: 
        !           326:     return(retval);
        !           327: }
        !           328: 
        !           329: 
        !           330: STATUS
        !           331: Q117iReport(
        !           332:     IN OUT PTAPE_EXTENSION TapeExtension,
        !           333:     IN CHAR Command,
        !           334:     IN USHORT *ReportData,
        !           335:     IN SHORT ReportSize,
        !           336:     IN OUT CHAR *EsdRetry
        !           337:     )
        !           338: 
        !           339: /*++
        !           340: 
        !           341: Routine Description:
        !           342: 
        !           343:     Send a report command to the tape drive and get the response data.  If
        !           344:     a communication failure occurs, then we assume that it is a result of
        !           345:     an ESD hit and retry the communication.
        !           346: 
        !           347: Arguments:
        !           348: 
        !           349: TapeExtension -
        !           350: 
        !           351: Command -
        !           352: 
        !           353: ReportData -
        !           354: 
        !           355: ReportSize -
        !           356: 
        !           357: EsdRetry -
        !           358: 
        !           359: Return Value:
        !           360: 
        !           361: --*/
        !           362: 
        !           363: {
        !           364:     SHORT i = 0;
        !           365:     STATUS ret;
        !           366:     STATUS ret1 = NoErr;
        !           367: 
        !           368:     do {
        !           369: 
        !           370:         if (TapeExtension->QControllerData->EndFormatMode) {
        !           371: 
        !           372:             TapeExtension->QControllerData->EndFormatMode = FALSE;
        !           373:             ret = NoErr;
        !           374: 
        !           375:         } else {
        !           376: 
        !           377:             ret = Q117iSendByte(TapeExtension, Command);
        !           378: 
        !           379:         }
        !           380: 
        !           381:         if (ret == NoErr) {
        !           382: 
        !           383:             if ((ret = Q117iReceiveByte(TapeExtension, ReportSize, ReportData))
        !           384:                 != NoErr) {
        !           385: 
        !           386:                 if ((ret == DriveFlt) ||
        !           387:                 (TapeExtension->FirmwareError == Xmit_Overrun)) {
        !           388: 
        !           389:                     if (EsdRetry != NULL) {
        !           390: 
        !           391:                         *EsdRetry = TRUE;
        !           392:                         ret1 = Q117iSelectDrive(TapeExtension);
        !           393: 
        !           394:                     }
        !           395:                 }
        !           396:             }
        !           397:         }
        !           398: 
        !           399:     } while (++i < REPORT_RPT && ret != NoErr && ret1 == NoErr);
        !           400: 
        !           401:     if (ret1 != NoErr) {
        !           402: 
        !           403:         return(ret1);
        !           404: 
        !           405:     } else {
        !           406: 
        !           407:         return(ret);
        !           408: 
        !           409:     }
        !           410: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.