Annotation of ntddk/src/scsi/qic117/common.h, 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:    common.h
        !             9: 
        !            10: Abstract:
        !            11: 
        !            12:    Data structures shared by drivers q117 and q117i
        !            13: 
        !            14: Revision History:
        !            15: 
        !            16: --*/
        !            17: 
        !            18: #if DBG
        !            19: //
        !            20: // For checked kernels, define a macro to print out informational
        !            21: // messages.
        !            22: //
        !            23: // QIC117Debug is normally 0.  At compile-time or at run-time, it can be
        !            24: // set to some bit patter for increasingly detailed messages.
        !            25: //
        !            26: // Big, nasty errors are noted with DBGP.  Errors that might be
        !            27: // recoverable are handled by the WARN bit.  More information on
        !            28: // unusual but possibly normal happenings are handled by the INFO bit.
        !            29: // And finally, boring details such as routines entered and register
        !            30: // dumps are handled by the SHOW bit.
        !            31: //
        !            32: 
        !            33: #define QIC117DBGP              ((ULONG)0x00000001)
        !            34: #define QIC117WARN              ((ULONG)0x00000002)
        !            35: #define QIC117INFO              ((ULONG)0x00000004)
        !            36: #define QIC117SHOWTD            ((ULONG)0x00000008)
        !            37: #define QIC117SHOWQD            ((ULONG)0x00000010)
        !            38: #define QIC117SHOWPOLL          ((ULONG)0x00000020)
        !            39: #define QIC117STOP              ((ULONG)0x00000080)
        !            40: #define QIC117MAKEBAD           ((ULONG)0x00000100)
        !            41: #define QIC117SHOWBAD           ((ULONG)0x00000200)
        !            42: #define QIC117DRVSTAT           ((ULONG)0x00000400)
        !            43: #define QIC117SHOWINT           ((ULONG)0x00000800)
        !            44: 
        !            45: extern ULONG QIC117DebugLevel;
        !            46: 
        !            47: #define CheckedDump(LEVEL,STRING) \
        !            48:             if (QIC117DebugLevel & LEVEL) { \
        !            49:                DbgPrint STRING; \
        !            50:             }
        !            51: #else
        !            52: #define CheckedDump(LEVEL,STRING)
        !            53: #endif
        !            54: 
        !            55: 
        !            56: #define BUFFER_SPLIT
        !            57: 
        !            58: typedef unsigned char UBYTE;
        !            59: typedef unsigned short UWORD;
        !            60: typedef unsigned short SEGMENT;
        !            61: typedef unsigned long BLOCK;
        !            62: 
        !            63: #ifndef TRUE
        !            64: #define TRUE 1
        !            65: #endif
        !            66: 
        !            67: #ifndef NULL
        !            68: #define NULL 0
        !            69: #endif
        !            70: 
        !            71: #ifndef FALSE
        !            72: #define FALSE 0
        !            73: #endif
        !            74: 
        !            75: #define MAXLINE 100
        !            76: 
        !            77: #define D_250 1                 // 250Kb transfer rate
        !            78: #define D_500 2                 // 500Kb transfer rate
        !            79: 
        !            80: //
        !            81: // The following parameters are used to indicate the tape format code
        !            82: //
        !            83: #define QIC_FORMAT          2   // Indicates a standard or extended length tape
        !            84: #define QICEST_FORMAT       3   // Indicates a 1100 foot tape
        !            85: 
        !            86: //
        !            87: // Tape Types
        !            88: //
        !            89: typedef enum _TAPE_TYPE {
        !            90:    QIC40_SHORT,                // normal length cart (205 ft)
        !            91:    QIC40_LONG,                 // extended length cart (310 ft)
        !            92:    QICEST_40,                  // QIC-40 formatted tape (1100 ft)
        !            93:    QIC80_SHORT,                // QIC-80 format 205 ft tape
        !            94:    QIC80_LONG,                 // QIC-80 format 310 ft tape
        !            95:    QICEST_80,                  // QIC-80 formatted tape (1100 ft)
        !            96:    QIC500_SHORT,               // QIC-500 formatted tape
        !            97:    QICEST_500                  // QIC-500 formatted tape (1100 ft)
        !            98: } TAPE_TYPE;
        !            99: 
        !           100: //
        !           101: // Valid FDC types
        !           102: //
        !           103: typedef enum _FDC_TYPE {
        !           104:    FDC_UNKNOWN,
        !           105:    FDC_NORMAL,
        !           106:    FDC_ENHANCED,
        !           107:    FDC_82077,
        !           108:    FDC_82077AA,
        !           109:    FDC_82078_44,
        !           110:    FDC_82078_64,
        !           111:    FDC_NATIONAL
        !           112: } FDC_TYPE;
        !           113: 
        !           114: #define FDC_TDR_MASK        0x03        // mask for 82077aa tdr test
        !           115: #define FDC_REPEAT          0x04        // number of times to loop through the tdr test
        !           116: 
        !           117: #define MAX_SEGMENTS        4200        // maximum segments on any JUMBO drive
        !           118: 
        !           119: #define MAX_PASSWORD_SIZE   8           // max volume password size
        !           120: #define QIC_END             0xffea6dff  // 12-31-2097, 23:59:59 in qictime
        !           121: 
        !           122: typedef enum _STATUS {
        !           123: 
        !           124:    //
        !           125:    // If command completed successfully
        !           126:    //
        !           127:    NoErr,
        !           128: 
        !           129: //
        !           130: // Errors from the filer
        !           131: //
        !           132:    // There aren't enough good blocks before the 127th bad block on tape
        !           133:    // to equal the no. of blocks for the bad block list, the tape directory, and
        !           134:    // the redundancy needed to recover the bad block list
        !           135:    UnusTape,                 // 1
        !           136: 
        !           137:    BadTape,                  // 2 All copies of first block of bad block list bad on tape, cannot use this tape
        !           138:    FMemErr,                  // 3 Filer memory insufficient in size
        !           139:    TapeFull,                 // 4 Tape full
        !           140:    VolFull,                  // 5 Volume directory full
        !           141:    RdncUnsc,                 // 6 Redundancy unsuccessful in recovering block
        !           142:    EndOfVol,                 // 7 Returned if ReadFile() or ReadBlock() had no more data to send
        !           143:    FCodeErr,                 // 8 Filer code error.
        !           144:    UpdErr,                   // 9 error while updating header segments - tape corrupted
        !           145: 
        !           146:    InvalVol,                 // 10 Volume nonexistent
        !           147:    NoVols,                   // 11 No volumes on tape
        !           148:    Unformat,                 // 12 tape not formatted
        !           149:    UnknownFormat,            // 13 unknown tape format
        !           150: 
        !           151:    //
        !           152:    //  DRIVER ERRORS
        !           153:    //
        !           154: 
        !           155:    BadBlk,                   // 14 Bad block detected (unrecoverable read error)
        !           156:    EndTapeErr,               // 15 End of tape (end of tape when not expected)
        !           157:    DriveFlt,                 // 16 Command transmission unsuccessful
        !           158:    WProt,                    // 17 Write protected
        !           159:    NoTape,                   // 18 Reel not loaded
        !           160:    SeekErr,                  // 19 Seek error
        !           161:    NoDrive,                  // 20 No tape drive
        !           162:    InvalCmd,                 // 21 Invalid command
        !           163:    CodeErr,                  // 22 Requested data on a 64K boundry
        !           164:    NECFlt,                   // 23 NEC chip failed to respond
        !           165:    NoFDC,                    // 24 Can't access Floppy Disk Controller
        !           166:    BadFmt,                   // 25 Format of tape is unknown
        !           167:    CmdFlt,                   // 26 Command read-after-write error
        !           168:    BadNEC,                   // 27 NEC chip out of spec.
        !           169:    BadReq,                   // 28 Invalid logical sector specification in read/write
        !           170:    TooFast,                  // 29 Computer is too fast for current driver software
        !           171:    NoData,                   // 30 Tape appears to be unformatted
        !           172:    DAbort,                   // 31 ClearIO was called and the queue has been cleared
        !           173:    TapeFlt,                  // 32 Tape drive fault
        !           174:    UnspRate,                 // 33 speed sense failed (unsupported transfer rate
        !           175:    Already,                  // 34 Driver already installed in another task
        !           176:    TooNoisy,                 // 35 Environment too noisy
        !           177:    TimeOut,                  // 36 Time out error
        !           178:    BadMark,                  // 37 Deleted data address mark found
        !           179:    NewCart,                  // 38 New cartridge has been inserted
        !           180:    WrongFmt,                 // 39 Attempt to write on QIC40 formatted tape with QIC80 drive
        !           181:    FmtMisMatch,              // 40 Same as WrongFmt, except occurs on tape linking
        !           182:    IncompTapeFmt,            // 41 QIC80 formatted tape detected in a QIC40 drive
        !           183:    SCSIFmtMsmtch,            // 42 QIC350 Tape detected during a SCSI BACKUP
        !           184:    QIC40InEagle,             // 43 Set when a QIC40 formatted tape is detected in an Eagle
        !           185:    QIC80InEagle,             // 44 Set when a QIC80 formatted tape is detected in an Eagle
        !           186:    ControllerBusy,           // 45 Floppy controller is in use by another device
        !           187:    InQue,                    // 46 If request is currently queued to low-level driver
        !           188:    SplitRequests,            // 47 If request is split and queued
        !           189:    EarlyWarning,             // 48 returned when writing near end of tape
        !           190: #ifndef NO_MARKS
        !           191:    SetMark,                  // 49
        !           192:    FileMark,                 // 50
        !           193:    LongFileMark,             // 51
        !           194:    ShortFileMark,            // 52
        !           195: #endif
        !           196: 
        !           197:    MaxErrorVal               //
        !           198: 
        !           199: } STATUS;
        !           200: 
        !           201: // Command values passed to the driver
        !           202: typedef enum _DRIVER_COMMAND {
        !           203:    DNotUsed,           // 00 command not used
        !           204:    DRead,              // 01 Read from tape
        !           205:    DWrite,             // 02 Write to tape
        !           206:    DFmt,               // 03 Format tape
        !           207:    DEject,             // 04 Eject tape
        !           208:    DFast,              // 05 Run Fast (250 KB xfer rate)
        !           209:    DSlow,              // 06 Run Slow (500 KB xfer rate)
        !           210:    DIgnore,            // 07 Ignore Unlock Switch
        !           211:    DUseLock,           // 08 Use Unlock Switch
        !           212:    DSndWPro,           // 09 Send Write Protect
        !           213:    DSndReel,           // 0a Send Reel In
        !           214:    DGetRev,            // 0b Get Firmware Rev
        !           215:    DReten,             // 0c Retension Tape
        !           216:    DGetCap,            // 0d Get Tape Capacity
        !           217:    DVerify,            // 0e Read with no retries
        !           218:    DRetry,             // 0f Heroic retries
        !           219:    DChkDrv,            // 10 get drive type
        !           220:    DWriteBad,          // 11 write deleted address mark on tape
        !           221:    DGetCart,           // 12 get new cartridge flag status
        !           222:    DGetSpeed,          // 13 get the current processor and tape drive speed
        !           223:    DStatus,            // 14 Get status of tape (type of drive/tape stats.)
        !           224:    DSelPart,           // 15 Select data/directory partition (QFA)
        !           225:    DGetPos,            // 16 Get current block number (QFA)
        !           226:    DFndDrv,            // 17 Find drive (all other cmds return NoDrive until called)
        !           227:    DErase,             // 18 Erase tape
        !           228:    DSeekEOD,           // 19 Seek to end of data (QFA)
        !           229:    DReadBad,           // 1a Read the tape header sectors
        !           230:    DGetFDC,            // 1b Get the type of FDC
        !           231:    DGetDriveInfo,      // 1c Get the Miscellaneous Drive Train Info from the drive
        !           232:    DChkFmt,            // 1d Cross check the tape format with the drive type
        !           233:    DReportProtoVer,    // 1e Gets the Firmware prototype version
        !           234:    DLocateDrv,         // 0f Locates a tape drive at a given controller location
        !           235:    DDeselect,          // 20 Deselects the tape drive
        !           236:    DClearNewCart       // 21 Clears the persistent new cart flag
        !           237: } DRIVER_COMMAND;
        !           238: 
        !           239: //
        !           240: // Tape Constants
        !           241: //
        !           242: #define UNIX_MAXBFS     5               // max. data buffers supported in the UNIX kernel
        !           243: 
        !           244: #define MAGIC           0x636d  // "cm"
        !           245: 
        !           246: #define QIC40_DRIVE     0
        !           247: #define QIC80_DRIVE     1
        !           248: #define QIC500_DRIVE    2
        !           249: 
        !           250: //
        !           251: // Information about track buffers used by the system.
        !           252: //
        !           253: 
        !           254: typedef struct _SEGMENT_BUFFER {
        !           255:    PVOID logical;
        !           256: } SEGMENT_BUFFER, *PSEGMENT_BUFFER;
        !           257: 
        !           258: typedef struct _IO_REQUEST {
        !           259: 
        !           260:    PVOID  Data;                // Pointer to data buffer
        !           261:    DRIVER_COMMAND Command;     // command
        !           262:    STATUS Status;              // status of operation
        !           263:    USHORT FirmwareError;       // Tape fault error (when status = TapeFlt)
        !           264:    ULONG  BadList;             // blocks for which retry not successful
        !           265:    ULONG  RetryList;           // blocks for which retry was successful
        !           266:    BLOCK  Block;               // block number where data is to be put
        !           267:    UCHAR  Number;              // Number of blocks of 512 to xfer
        !           268:    struct _IO_REQUEST *Next;   // queue link (far pointer to next struct)
        !           269: 
        !           270: //
        !           271: // Upper driver (q117) specific information
        !           272: //
        !           273:    KEVENT DoneEvent;               // Event that IoCompleteReqeust will set
        !           274:    IO_STATUS_BLOCK IoStatus;       // Status of request
        !           275:    PSEGMENT_BUFFER BufferInfo;     // Buffer information
        !           276: 
        !           277: } IO_REQUEST, *PIO_REQUEST;
        !           278: 
        !           279: typedef struct _Q117_ADAPTER_INFO {
        !           280:    PADAPTER_OBJECT     AdapterObject;
        !           281:    ULONG               NumberOfMapRegisters;
        !           282: } Q117_ADAPTER_INFO, *PQ117_ADAPTER_INFO;
        !           283: 
        !           284: //
        !           285: // QIC117 device specific ioclt's.
        !           286: //
        !           287: 
        !           288: #define IOCTL_QIC117_BASE                 FILE_DEVICE_TAPE
        !           289: 
        !           290: 
        !           291: #define IOCTL_QIC117_DRIVE_REQUEST        CTL_CODE(IOCTL_QIC117_BASE, 0x0001, METHOD_NEITHER, FILE_ANY_ACCESS)
        !           292: #define IOCTL_QIC117_CLEAR_QUEUE          CTL_CODE(IOCTL_QIC117_BASE, 0x0002, METHOD_NEITHER, FILE_ANY_ACCESS)
        !           293: 
        !           294: //
        !           295: // structure returned by DStatus command
        !           296: //
        !           297: 
        !           298: struct S_O_DStatus {
        !           299:    unsigned int underruns;
        !           300:    unsigned int retries;
        !           301:    unsigned int reserved[18];
        !           302: };
        !           303: 
        !           304: 
        !           305: typedef struct S_O_DGetCap {
        !           306:    unsigned int SectsPerSegment;
        !           307:    unsigned int MaxFSector;
        !           308:    unsigned int FTrackPerFSide;
        !           309:    ULONG SegmentsPerTrack;
        !           310:    ULONG SegmentsPerFTrack;
        !           311:    ULONG TracksPerTape;
        !           312:    unsigned char referenced;           /* 0 = unformatted,  >0 == formatted */
        !           313:    unsigned char drive_type;
        !           314:    USHORT TapeFormatCode;
        !           315:    unsigned int FormattableSegments;   /* number of segments to be formatted
        !           316:                                           (based on the num_tracks entry in the
        !           317:                                           tape.cfg file) */
        !           318: } DRIVE_CAPACITY, *PDRIVE_CAPACITY;
        !           319: 
        !           320: struct S_O_DGetPos {
        !           321:    union {
        !           322:       struct {
        !           323:             ULONG block:20;
        !           324:             ULONG controll:4;
        !           325:             ULONG track:8;
        !           326:       } x;
        !           327:       long block;
        !           328:    } x;
        !           329: };
        !           330: 
        !           331: 
        !           332: struct S_O_DGetSpeed {
        !           333:    unsigned int CurSpeed;
        !           334:    unsigned int FmtSpeed;
        !           335: };
        !           336: 
        !           337: struct S_O_DSector_Id {
        !           338:    UBYTE track;
        !           339:    UBYTE cylinder;                             /* floppy cylinder, head and sector */
        !           340:    UBYTE head;                                 /* information */
        !           341:    UBYTE sector;
        !           342: };
        !           343: 
        !           344: //
        !           345: // Structure for storing the Miscellaneous Drive Informatiom                |
        !           346: //
        !           347: 
        !           348: struct S_O_DMiscInfo {
        !           349:    char    drive_type;      /* Drive Type: QIC40 or QIC80 */
        !           350:    UBYTE   ROM_Version;     /* Version of the drive's ROM */
        !           351:    char    info_exists;     /* Indicates the existance of the drive train info */
        !           352:    UBYTE   serial_number[4];/* a four byte array used to store the drive's serial number */
        !           353:    UBYTE   man_date[2];     /* A two byte array used to store the drive's manufacturing date */
        !           354:    char    oem[20];         /* A 20 byte array used to store the drive's OEM name */
        !           355: };
        !           356: 
        !           357: //
        !           358: // Prototypes for common functions
        !           359: //
        !           360: 
        !           361: VOID
        !           362: q117LogError(
        !           363:    IN PDEVICE_OBJECT DeviceObject,
        !           364:    IN ULONG SequenceNumber,
        !           365:    IN UCHAR MajorFunctionCode,
        !           366:    IN UCHAR RetryCount,
        !           367:    IN ULONG UniqueErrorValue,
        !           368:    IN NTSTATUS FinalStatus,
        !           369:    IN NTSTATUS SpecificIOStatus
        !           370:    );
        !           371: 
        !           372: NTSTATUS q117MapStatus(
        !           373:     IN STATUS Status
        !           374:     );
        !           375: 

unix.superglobalmegacorp.com

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