	IFND	XETEC_SCSI_I
XETEC_SCSI_I	SET	1
	IFND	EXEC_TYPES_I
	INCLUDE	"exec/types.i"
	ENDC
	IFND	EXEC_IO_I
	INCLUDE	"exec/io.i"
	ENDC
	IFND	EXEC_TASKS_I
	INCLUDE	"exec/tasks.i"
	ENDC
	IFND	EXEC_DEVICES_I
	INCLUDE	"exec/devices.i"
	ENDC

*****************************************************************
*         TM							*
* FastTrak       include file					*
*								*
* Marty Flickinger                              March 16, 1988  *
*								*
* Copyright (c) 1988, 1989  Xetec, Inc.				*
*****************************************************************


XETECDEVNAME	MACRO
	DC.B	'harddisk.device',0
	ENDM

MANUFAC		EQU	2022	;Xetec Manufacturer ID
FASTTRAK	EQU	1	;FastTrak/FastCard SCSI controller
FASTCARDPLUS	EQU	3	;FastCard plus SCSI controller


;------ SCSI bus command types

SCSI_TUR	EQU	$0
SCSI_Check	EQU	$3
SCSI_Read	EQU	$8
SCSI_Write	EQU	$A
SCSI_Seek	EQU	$B
SCSI_ExtRead	EQU	$28
SCSI_ExtWrite	EQU	$2A

MD_NUMUNITS	EQU	16	;Maximum number of units
MYPROCSTACKSIZE	EQU	$800	;Stack size

;-----------------------------------------------------------------------;
;									;
; Device command definitions                                            ;
;									;
;-----------------------------------------------------------------------;

    DEVINIT
	DEVCMD	CMD_MOTOR	 ;Control the disk's motor (NO-OP)
	DEVCMD	CMD_SEEK	 ;Explicit seek (NO-OP)
	DEVCMD	CMD_FORMAT	 ;Format disk - equated to WRITE for RAMDISK
	DEVCMD	CMD_REMOVE	 ;Notify when disk changes (NO-OP)
	DEVCMD	CMD_CHANGENUM	 ;Number of disk changes (always 0)
	DEVCMD	CMD_CHANGESTATE	 ;Is there a disk in the drive? (always TRUE)
	DEVCMD	CMD_PROTSTATUS	 ;Is the disk write protected? (always FALSE)
	DEVCMD	CMD_RAWREAD	 ;Not supported
	DEVCMD	CMD_RAWWRITE	 ;Not supported
	DEVCMD	CMD_GETDRIVETYPE ;Get drive type
	DEVCMD	CMD_GETNUMTRACKS ;Get number of tracks
	DEVCMD	CMD_ADDCHANGEINT ;Add disk change interrupt (NO-OP)
	DEVCMD	CMD_REMCHANGEINT ;Remove disk change interrupt ( NO-OP)
	DEVCMD	CMD_Undef1
	DEVCMD	CMD_Undef2
	DEVCMD	CMD_Undef3
	DEVCMD	CMD_SCSIFLAGS
	DEVCMD	CMD_REQSENSE	 ;Request Sense
	DEVCMD	CMD_TUR		 ;Test Unit Ready
	DEVCMD	CMD_SCSI	 ;Universal SCSI sender (see SCSIDISK.i)
	DEVCMD	MYDEV_END	 ;Place marker -- first illegal command #


;-----------------------------------------------------------------------;
;									;
; Device data structure                                                 ;
;									;
;-----------------------------------------------------------------------;


    STRUCTURE	XetecDevice,LIB_SIZE
	UBYTE	xd_Flags
	UBYTE	xd_SCSIid		;SCSI id (0 - 7)
	ULONG	xd_SysLib		;Exec Base
	ULONG	xd_SegList
	ULONG	xd_Base			;Base address of my host adaptor
	ULONG	xd_Base2		;Second Xetec host adaptor
	ULONG	xd_ConfigDev		;Next 4: local copy of CurrentBinding
	ULONG	xd_FileName
	ULONG	xd_ProductString
	ULONG	xd_ToolTypes
	STRUCT	xd_Units,MD_NUMUNITS*4
	ULONG	xd_UnitFlags
    LABEL	XetecDev_Sizeof


	IFND	DEVICES_SCSIDISK_I

    STRUCTURE	SCSICmd,0
	APTR	scsi_Data	;word aligned data for SCSI Data Phase
	ULONG	scsi_Length	;even length of Data area
	ULONG	scsi_Actual	;actual Data used
	APTR	scsi_Command	;SCSI Command (same options as scsi_Data)
	UWORD	scsi_CmdLength	;length of Command
	UWORD	scsi_CmdActual	;actual Command used
	UBYTE	scsi_Flags	;includes intended data direction
	UBYTE	scsi_Status	;SCSI status of command
	UBYTE	*scsi_SenseData		;Buffer for sense data
	UWORD	scsi_SenseLength	;And its size
	UWORD	scsi_SenseActual	;Actual read
    LABEL	scsi_SIZEOF

SCSIF_WRITE	EQU	0	;intended data direction is out
SCSIF_READ	EQU	1	;intended data direction is in

;------ IO_ERROR values ------
FTERR_SelfUnit		EQU	40	;cannot issue SCSI command to self
FTERR_DMA		EQU	41	;DMA error
FTERR_Phase		EQU	42	;illegal or unexpected SCSI phase
FTERR_Parity		EQU	43	;SCSI parity error
FTERR_SelTimeout	EQU	44	;Select timed out
FTERR_BadStatus		EQU	45	;status and/or sense error
FTERR_NoBoard		EQU	50	;Open failed for non-existant board

	ENDC

SENSEINFO_VALID	EQU	$80
SENSE_KEY_MASK	EQU	$0F

    STRUCTURE	SenseData,0
	UBYTE	error_code
	UBYTE	segment_num
	UBYTE	sense_key		;Sense key (AND w/SENSE_KEY_MASK)
	UBYTE	info_byte0
	UBYTE	info_byte1
	UBYTE	info_byte2
	UBYTE	info_byte3
	UBYTE	add_sense_length
	UBYTE	cyl_high
	UBYTE	cyl_low
	UBYTE	head
	UBYTE	sector
	UBYTE	add_sense_code
	UBYTE	reserved
	UBYTE	fru_failed
	UBYTE	flags
	UWORD	field_ptr
    LABEL	SenseData_SIZEOF


	ENDC
