//
// TapeSCSI -- support for Tape Devices
//
// Copyright (C) 1992 by Jiro Nakamura
//
// Original Author:	Jiro Nakamura 
// Created:		October 19, 1991
// Last Modified:	October 19, 1991
//
// RCS Information
// Revision Number->	$Revision: 1.1 $
// Last Revised->	$Date: 92/05/16 15:35:47 $
//

static char rcsid[]="$Id: TapeSCSI.m,v 1.1 92/05/16 15:35:47 jiro Exp Locker: jiro $";
static char copyrightid[]="Copyright (C) 1992 by Jiro Nakamura and The Shaman Group";

#import "TapeSCSI.h"
#import <stdio.h>
#import <libc.h>

@implementation TapeSCSI

- (int) readBlockLimits: (struct blockLimitsData *) r
{
	int tmp;
	if( scsiOpen)
		return [self readBlockLimitsSCSI: r];
	else
		{
		if([self openSCSI] )
			{
			sprintf(errorString,"Can't open SCSI driver");
			return -1;
			}
		tmp = [self readBlockLimitsSCSI: r];
		[self closeSCSI];
		return( tmp);
		}
}

- (int) readBlockLimitsSCSI: (struct blockLimitsData *) r
{	
	struct cdb_6 *cdbp = &sr.sr_cdb.cdb_c6;

	[SCSI clearCommandBlock: (union cdb *) cdbp];
	cdbp->c6_opcode = C6OP_READBLOCKLIMITS;
	cdbp->c6_lun    = lun;
#ifdef __LITTLE_ENDIAN__
	cdbp->c6_lba0 = cdbp->c6_lba1 = cdbp->c6_lba2 = 0;
#else
	cdbp->c6_lba	= 0;
#endif

	cdbp->c6_len 	= 0;
	sr.sr_dma_dir	= SR_DMA_RD;
	sr.sr_addr	= (char *) r;	
	sr.sr_dma_max   = 6;
	sr.sr_ioto	= 10;

	return [self performSCSIRequest];
}


@end
