File:  [WindowsNT SDKs] / ntddk / src / scsi / qic117 / settpst.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Thu Aug 9 18:31:12 2018 UTC (7 years, 9 months ago) by root
Branches: msft, MAIN
CVS tags: ntddk-nov-1993, HEAD
Microsoft Windows NT Build 511 (DDK SDK) 11-01-1993

/*++

Copyright (c) 1993 - Colorado Memory Systems, Inc.
All Rights Reserved

Module Name:

    settpst.c

Abstract:

    Calculates the number of bytes of data available on the tape (accounting
    for bad sectors)

Revision History:




--*/


//
// include files
//

#include <ntddk.h>
#include <ntddtape.h>
#include "common.h"
#include "q117.h"
#include "protos.h"


VOID
q117SetTpSt(
    PQ117_CONTEXT Context
    )

/*++

Routine Description:

    Uses the globals CurrentOperation.EndOfUsedTape,
    and CurrentTape.BadSectors to set the
    Media Parameters.

Arguments:

    Context -

Return Value:

    None

--*/

{
    ULONG numgood,numbad;
    SEGMENT segmentIndex;
    SEGMENT lastSegment;
    ULONG BytesUsed;

    //
    // If we have read to the end of the volume segment
    //

    if (Context->CurrentOperation.EndOfUsedTape) {

        //
        // Count the number of used sectors
        //

        lastSegment = Context->CurrentOperation.EndOfUsedTape;

        numgood = 0;

        for (segmentIndex = 0 ; segmentIndex <= lastSegment ; ++segmentIndex) {

            numbad = q117CountBits(Context, segmentIndex, 0l);

            if (BLOCKS_PER_SEGMENT-ECC_BLOCKS_PER_SEGMENT-numbad > 0 &&
                    segmentIndex > Context->CurrentTape.VolumeSegment) {

                numgood += BLOCKS_PER_SEGMENT-ECC_BLOCKS_PER_SEGMENT-numbad;

            }
        }

        BytesUsed = numgood * BYTES_PER_SECTOR;

        numgood = 0;

        lastSegment = Context->CurrentTape.LastSegment;

        for (;segmentIndex<=lastSegment;++segmentIndex) {

            numbad = q117CountBits(Context, segmentIndex, 0l);

            if (BLOCKS_PER_SEGMENT-ECC_BLOCKS_PER_SEGMENT-numbad > 0) {

                numgood += BLOCKS_PER_SEGMENT-ECC_BLOCKS_PER_SEGMENT-numbad;

            }
        }

        Context->CurrentTape.MediaInfo->Remaining.LowPart =
            numgood * BYTES_PER_SECTOR;

        Context->CurrentTape.MediaInfo->Remaining.HighPart = 0;

        Context->CurrentTape.MediaInfo->Capacity.LowPart =
            Context->CurrentTape.MediaInfo->Remaining.LowPart + BytesUsed;

        Context->CurrentTape.MediaInfo->Capacity.HighPart = 0;
        Context->CurrentTape.MediaInfo->BlockSize = BYTES_PER_SECTOR;
        Context->CurrentTape.MediaInfo->PartitionCount = 0;

    } else {

        CheckedDump(QIC117INFO,("q117SetTpSt: endblock not set\n"));

    }
}

unix.superglobalmegacorp.com

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