Annotation of ntddk/src/scsi/qic117/newtrkbk.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:     newtrkbk.c
                      9: 
                     10: Abstract:
                     11: 
                     12:     These routines handle streaming during write.
                     13: 
                     14: Revision History:
                     15: 
                     16: 
                     17: 
                     18: 
                     19: --*/
                     20: 
                     21: #include <ntddk.h>
                     22: #include <ntddtape.h>
                     23: #include "common.h"
                     24: #include "q117.h"
                     25: #include "protos.h"
                     26: 
                     27: 
                     28: STATUS
                     29: q117NewTrkBk(
                     30:     PQ117_CONTEXT Context
                     31:     )
                     32: 
                     33: /*++
                     34: 
                     35: Routine Description:
                     36: 
                     37:     This routine queues up the current buffer,  and then
                     38:     waits for an empty queue to continue operations.
                     39: 
                     40: Arguments:
                     41: 
                     42:     Context - Context of the current operation.
                     43: 
                     44: Return Value:
                     45: 
                     46: --*/
                     47: 
                     48: {
                     49:     STATUS ret;
                     50:     BOOLEAN mapBad;
                     51:     USHORT remainder;
                     52:     PIO_REQUEST ioreq;
                     53: 
                     54:     ret = 0;
                     55:     do {
                     56: 
                     57:         //
                     58:         // do we need to go to a new tape (EndBack will write out current
                     59:         // data segment)
                     60:         //
                     61: 
                     62:         if (Context->CurrentOperation.CurrentSegment ==
                     63:             Context->CurrentOperation.LastSegment) {
                     64: 
                     65:             ret = TapeFull;
                     66: 
                     67:         } else {
                     68: 
                     69:             //
                     70:             // write current data segment out
                     71:             //
                     72: 
                     73:             if (ret=q117IssIOReq(
                     74:                         (PVOID)NULL,
                     75:                         DWrite,
                     76:                         (LONG)Context->CurrentOperation.CurrentSegment *
                     77:                             BLOCKS_PER_SEGMENT,
                     78:                         NULL,
                     79:                         Context)) {
                     80: 
                     81:                 return(ret);
                     82: 
                     83:             }
                     84: 
                     85:             //
                     86:             // increment current block information
                     87:             //
                     88: 
                     89:             ++Context->CurrentOperation.CurrentSegment;
                     90:         }
                     91: 
                     92:         //
                     93:         // if the queue is full we need to empty one out
                     94:         //
                     95: 
                     96:         mapBad = FALSE;
                     97:         if (q117QueueFull(Context)) {
                     98: 
                     99:             ioreq = q117Dequeue(WaitForItem,Context);
                    100: 
                    101:             if (ioreq->Status && ioreq->Status != BadBlk) {
                    102: 
                    103:                 return(ioreq->Status);
                    104: 
                    105:             }
                    106: 
                    107:             if (ioreq->Status == BadBlk) {
                    108: 
                    109:                 if (ret = q117MapBadBlock(
                    110:                         ioreq,
                    111:                         &Context->CurrentOperation.SegmentPointer,
                    112:                         &Context->CurrentOperation.SegmentBytesRemaining,
                    113:                         &Context->CurrentOperation.CurrentSegment,
                    114:                         &remainder,
                    115:                         Context)) {
                    116: 
                    117:                     return(ret);
                    118: 
                    119:                 }
                    120:                 mapBad = TRUE;
                    121:             }
                    122:         }
                    123: 
                    124:         if (!mapBad) {
                    125: 
                    126:             Context->CurrentOperation.SegmentPointer =
                    127:                 q117GetFreeBuffer(NULL,Context);
                    128: 
                    129:             //
                    130:             // We need to skip segments with no data area (less than
                    131:             // 4 good segments)
                    132:             //
                    133: 
                    134:             while ((Context->CurrentOperation.SegmentBytesRemaining =
                    135:                      q117GoodDataBytes(
                    136:                         Context->CurrentOperation.CurrentSegment,Context)
                    137:                      ) <= 0) {
                    138: 
                    139:                 ++Context->CurrentOperation.CurrentSegment;
                    140: 
                    141:             }
                    142:         }
                    143: 
                    144:     //
                    145:     // CurrentOperation.SegmentBytesRemaining should only be zero
                    146:     // if we mapped out some sectors
                    147:     //
                    148: 
                    149:     } while (Context->CurrentOperation.SegmentBytesRemaining == 0);
                    150: 
                    151:     return(ret);
                    152: }
                    153: 

unix.superglobalmegacorp.com

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