NT4/private/ntos/dd/qic117/writtape.c
2020-09-30 17:12:29 +02:00

138 lines
2.9 KiB
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*++
Copyright (c) 1993 - Colorado Memory Systems, Inc.
All Rights Reserved
Module Name:
writtape.c
Abstract:
Copies 'howmany' bytes of data from 'fromwhere' to track memory and
calls NewTrkBk when a track fills up.
Revision History:
--*/
#include <ntddk.h>
#include <ntddtape.h>
#include "common.h"
#include "q117.h"
#include "protos.h"
#define FCT_ID 0x0125
dStatus
q117WriteTape(
IN PVOID FromWhere,
IN OUT ULONG HowMany,
IN OUT PQ117_CONTEXT Context
)
/*++
Routine Description:
This routine disperses the incomming data into the segment buffers,
for storage on tape.
Arguments:
FromWhere - Pointer data to store on tape
HowMany - Howmany bytes to store
Context - Context of driver
Return Value:
Any Driver error, ERR_NO_ERR, LinkBack.
--*/
{
dStatus retval;
retval = ERR_NO_ERR;
while (HowMany && retval == ERR_NO_ERR) {
if (Context->CurrentOperation.SegmentBytesRemaining == 0) {
//
// Any Driver error, ERR_NO_ERR, LinkBack. Queue up data and set
// CurrentOperation.SegmentBytesRemaining and
// CurrentOperation.SegmentPointer to the next free buffer.
//
retval = q117NewTrkBk(Context);
}
if (!retval) {
if (HowMany >
(ULONG)Context->CurrentOperation.SegmentBytesRemaining) {
if (FromWhere) {
RtlMoveMemory(
Context->CurrentOperation.SegmentPointer,
FromWhere,
Context->CurrentOperation.SegmentBytesRemaining);
(PUCHAR)FromWhere +=
Context->CurrentOperation.SegmentBytesRemaining;
}
HowMany -= Context->CurrentOperation.SegmentBytesRemaining;
Context->CurrentOperation.BytesOnTape +=
Context->CurrentOperation.SegmentBytesRemaining;
Context->CurrentOperation.SegmentBytesRemaining = 0;
} else {
if (FromWhere) {
RtlMoveMemory(
Context->CurrentOperation.SegmentPointer,
FromWhere,
HowMany);
}
(PUCHAR)Context->CurrentOperation.SegmentPointer += HowMany;
Context->CurrentOperation.BytesOnTape += HowMany;
Context->CurrentOperation.SegmentBytesRemaining -=
(USHORT)HowMany;
HowMany = 0;
}
}
}
if (Context->CurrentOperation.CurrentSegment >=
(Context->CurrentOperation.LastSegment-SEGMENTS_OF_EARLY_WARNING) &&
retval == ERR_NO_ERR ) {
//
// When early warning zone is reached, return early warning error.
//
retval = ERROR_ENCODE(ERR_EARLY_WARNING,FCT_ID, 1);
}
return(retval);
}