Annotation of ntddk/src/scsi/qic117/writtape.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:     writtape.c
        !             9: 
        !            10: Abstract:
        !            11: 
        !            12:     Copies 'howmany' bytes of data from 'fromwhere' to track memory and
        !            13:     calls NewTrkBk when a track fills up.
        !            14: 
        !            15: Revision History:
        !            16: 
        !            17: 
        !            18: 
        !            19: 
        !            20: --*/
        !            21: 
        !            22: #include <ntddk.h>
        !            23: #include <ntddtape.h>
        !            24: #include "common.h"
        !            25: #include "q117.h"
        !            26: #include "protos.h"
        !            27: 
        !            28: 
        !            29: STATUS
        !            30: q117WriteTape(
        !            31:     IN PVOID FromWhere,
        !            32:     IN OUT ULONG HowMany,
        !            33:     IN OUT PQ117_CONTEXT Context
        !            34:     )
        !            35: 
        !            36: /*++
        !            37: 
        !            38: Routine Description:
        !            39: 
        !            40:     This routine disperses the incomming data into the segment buffers,
        !            41:     for storage on tape.
        !            42: 
        !            43: 
        !            44: Arguments:
        !            45: 
        !            46:     FromWhere - Pointer data to store on tape
        !            47: 
        !            48:     HowMany - Howmany bytes to store
        !            49: 
        !            50:     Context - Context of driver
        !            51: 
        !            52: Return Value:
        !            53: 
        !            54:     Any Driver error, NoErr, LinkBack.
        !            55: 
        !            56: --*/
        !            57: 
        !            58: {
        !            59:     STATUS retval;
        !            60: 
        !            61:     retval = NoErr;
        !            62: 
        !            63:     while (HowMany && retval == NoErr) {
        !            64: 
        !            65:         if (Context->CurrentOperation.SegmentBytesRemaining == 0) {
        !            66: 
        !            67:             //
        !            68:             // Any Driver error, NoErr, LinkBack.  Queue up data and set
        !            69:             // CurrentOperation.SegmentBytesRemaining and
        !            70:             // CurrentOperation.SegmentPointer to the next free buffer.
        !            71:             //
        !            72: 
        !            73:             retval = q117NewTrkBk(Context);
        !            74: 
        !            75:         }
        !            76: 
        !            77:         if (!retval) {
        !            78: 
        !            79:             if (HowMany >
        !            80:                     (ULONG)Context->CurrentOperation.SegmentBytesRemaining) {
        !            81: 
        !            82:                 if (FromWhere) {
        !            83: 
        !            84:                     RtlMoveMemory(
        !            85:                         Context->CurrentOperation.SegmentPointer,
        !            86:                         FromWhere,
        !            87:                         Context->CurrentOperation.SegmentBytesRemaining);
        !            88: 
        !            89:                     (PUCHAR)FromWhere +=
        !            90:                         Context->CurrentOperation.SegmentBytesRemaining;
        !            91: 
        !            92:                 }
        !            93: 
        !            94:                 HowMany -= Context->CurrentOperation.SegmentBytesRemaining;
        !            95: 
        !            96:                 Context->CurrentOperation.BytesOnTape +=
        !            97:                     Context->CurrentOperation.SegmentBytesRemaining;
        !            98: 
        !            99:                 Context->CurrentOperation.SegmentBytesRemaining = 0;
        !           100: 
        !           101:             } else {
        !           102: 
        !           103:                 if (FromWhere) {
        !           104: 
        !           105:                     RtlMoveMemory(
        !           106:                         Context->CurrentOperation.SegmentPointer,
        !           107:                         FromWhere,
        !           108:                         HowMany);
        !           109: 
        !           110:                 }
        !           111: 
        !           112:                 (PUCHAR)Context->CurrentOperation.SegmentPointer += HowMany;
        !           113: 
        !           114:                 Context->CurrentOperation.BytesOnTape += HowMany;
        !           115: 
        !           116:                 Context->CurrentOperation.SegmentBytesRemaining -=
        !           117:                     (USHORT)HowMany;
        !           118: 
        !           119:                 HowMany = 0;
        !           120:             }
        !           121:         }
        !           122:     }
        !           123: 
        !           124:     if (Context->CurrentOperation.CurrentSegment >=
        !           125:         (Context->CurrentOperation.LastSegment-SEGMENTS_OF_EARLY_WARNING) &&
        !           126:         retval == NoErr ) {
        !           127: 
        !           128:         //
        !           129:         // When early warning zone is reached,  return early warning error.
        !           130:         //
        !           131:         retval = EarlyWarning;
        !           132: 
        !           133:     }
        !           134: 
        !           135:     return(retval);
        !           136: }

unix.superglobalmegacorp.com

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