Annotation of ntddk/src/scsi/qic117/receive.c, revision 1.1.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:     receive.c
                      9: 
                     10: Abstract:
                     11: 
                     12:     Recieve qic117 data bytes. 
                     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: Q117iReceiveByte(
                     37:     IN PTAPE_EXTENSION TapeExtension,
                     38:     IN SHORT ReceiveLength,
                     39:     OUT USHORT *ReceiveData
                     40:     )
                     41: 
                     42: /*++
                     43: 
                     44: Routine Description:
                     45: 
                     46:     Read a byte/word of response data from the FDC.  Response data can
                     47:     be drive error/status information or drive configuration information.
                     48: 
                     49:         Wait for Track 0 from the tape drive to go active.  This indicates
                     50:         that the drive is ready to start sending data.
                     51: 
                     52:         Alternate sending Report Next Bit commands to the tape drive and
                     53:         sampling Track 0 (response data) from the tape drive until the
                     54:         proper number of response data bits have been read.
                     55: 
                     56:         Read one final data bit from the tape drive which is the confirmation
                     57:         bit.  This bit must be a 1 to confirm the transmission.
                     58: 
                     59: Arguments:
                     60: 
                     61:         TapeExtension -
                     62: 
                     63:         ReceiveLength - Type short used to indicate the desired data length
                     64: 
                     65:         RecieveData - Type unsigned short pointer used to return the received
                     66:         data.
                     67: 
                     68: Return Value:
                     69: 
                     70: 
                     71: 
                     72: --*/
                     73: 
                     74: {
                     75:     STATUS retval = 0;
                     76:     CHAR i = 0;
                     77:     UCHAR stat3;
                     78:     USHORT fdcData= 0;
                     79: #if DBG
                     80:     BOOLEAN save;
                     81: 
                     82:     // Lockout commands used to receive the status
                     83:     save = TapeExtension->DbgLockout;
                     84:     TapeExtension->DbgLockout = TRUE;
                     85: #endif
                     86: 
                     87:     if((retval = Q117iWaitActive(TapeExtension)) != NoErr) {
                     88: 
                     89:         return(retval);
                     90: 
                     91:     }
                     92: 
                     93:     do {
                     94: 
                     95:         if((retval = Q117iSendByte(TapeExtension, Rpt_Next_Bit)) != NoErr) {
                     96: 
                     97:             return(retval);
                     98: 
                     99:         }
                    100: 
                    101:         Q117iSleep(TapeExtension,
                    102:                    mt_wt2ticks,
                    103:                    FALSE
                    104:                    );
                    105: 
                    106: 
                    107:         if((retval = Q117iGetStatus(TapeExtension, &stat3)) != NoErr) {
                    108: 
                    109:             return(retval);
                    110: 
                    111:         }
                    112: 
                    113:         fdcData >>= 1;
                    114:         if (stat3 & ST3_T0) {
                    115: 
                    116:             fdcData |= 0x8000;
                    117: 
                    118:         }
                    119: 
                    120:         i++;
                    121: 
                    122:     } while (i < ReceiveLength);
                    123: 
                    124:     //
                    125:     // If the received data is only one byte wide, then shift data to the low
                    126:     // byte of fdcData.
                    127:     //
                    128: 
                    129:     if (ReceiveLength == READ_BYTE) {
                    130: 
                    131:         fdcData >>= READ_BYTE;
                    132: 
                    133:     }
                    134: 
                    135:     //
                    136:     // Return the low byte to the caller.
                    137:     //
                    138: 
                    139:     ((UCHAR *)ReceiveData)[LOW_BYTE] =
                    140:         ((UCHAR *)&fdcData)[LOW_BYTE];
                    141: 
                    142:     //
                    143:     // If the FDC data is a word, then return it to the caller.
                    144:     //
                    145: 
                    146:     if (ReceiveLength == READ_WORD) {
                    147: 
                    148:         ((UCHAR *)ReceiveData)[HI_BYTE] =
                    149:             ((UCHAR *)&fdcData)[HI_BYTE];
                    150: 
                    151:     }
                    152: 
                    153:     if((retval = Q117iSendByte(TapeExtension, Rpt_Next_Bit)) != NoErr) {
                    154: 
                    155:         return(retval);
                    156: 
                    157:     }
                    158: 
                    159:     Q117iSleep(TapeExtension, mt_wt2ticks, FALSE);
                    160: 
                    161:     if((retval = Q117iGetStatus(TapeExtension, &stat3)) != NoErr) {
                    162: 
                    163:         return(retval);
                    164: 
                    165:     }
                    166: 
                    167:     if(!(stat3 & (UCHAR)ST3_T0)) {
                    168: 
                    169:         TapeExtension->FirmwareError = Xmit_Overrun;
                    170:         return(TapeFlt);
                    171: 
                    172:     }
                    173: 
                    174: #if DBG
                    175:     TapeExtension->DbgLockout = save;
                    176:     DbgAddEntry(0x1234567c);
                    177:     DbgAddEntry(fdcData);
                    178: #endif
                    179: 
                    180:     return(retval);
                    181: }
                    182: 
                    183: STATUS
                    184: Q117iWaitActive(
                    185:     IN PTAPE_EXTENSION TapeExtension
                    186:     )
                    187: 
                    188: /*++
                    189: 
                    190: Routine Description:
                    191: 
                    192:     Wait up to 10ms for tape drive's TRK0 line to go active.  10 ms plus
                    193:     the 5 ms at the end of the Report command (in send_byte) is the
                    194:     specified 15 ms delay for this parameter.
                    195: 
                    196: Arguments:
                    197: 
                    198:     TapeExtension -
                    199: 
                    200: Return Value:
                    201: 
                    202: 
                    203: 
                    204: --*/
                    205: 
                    206: 
                    207: {
                    208:     STATUS retval;
                    209:     UCHAR stat3;
                    210: 
                    211:     Q117iSleep(TapeExtension, mt_wt2ticks , FALSE);
                    212: 
                    213:     if ((retval = Q117iGetStatus(TapeExtension, &stat3)) != NoErr) {
                    214: 
                    215:         return(retval);
                    216: 
                    217:     }
                    218: 
                    219:     if (!(stat3 & ST3_T0)) {
                    220: 
                    221:         CheckedDump(QIC117WARN,( "Wait active drive fault...\n" ));
                    222:         retval = DriveFlt;
                    223: 
                    224:     }
                    225: 
                    226:     return(retval);
                    227: }

unix.superglobalmegacorp.com

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