#ifndef ALF_DEVICE_H
#define ALF_DEVICE_H

/*******************************************************************************
                         _                 ____    ___
                        / \      |        |           |
                       /___\     |        |--      ---
                      /     \ o  |____ o  |  o    |___

                            Amiga Loads Faster 2

                      §name:ALF.device.h§
                      §date:05 Aug 1989§
                      §time:16:22:53§

              copyright 1989 Elaborate Bytes, Oliver Kastl

*******************************************************************************/

#ifndef SOFTSCSIRES_H
#include <SoftSCSIRes.h>
#endif

#ifndef ALF_H
#include <ALF.h>
#endif

/*
One additional error is supported by ALF software. Actually this is a bit which
is ored together with the real IO_ERROR. If the requested unit is not installed
yet and it is a st412 drive this bit is returned set. The command is processed
anyway.
*/

#define ALFERR_NotInstalled 128

/*
This is the device base.
*/

	struct ALFBase
		{
		struct Library ab_Library;
		struct SoftSCSIResource *ab_SoftSCSIResource; /* A pointer to the resource
			which connects us to the SoftSCSI's. */
		};

/*
We send SCSI commands to a SoftSCSI_#?.device. We fix on the following sizes for
commands and sense:
*/

#define COMMANDSIZE 6
#define SENSESIZE 4

/*
Some SoftSCSIs support additional commands. These are mainly required for non
SCSIs to emulate SCSI. The command SSD_SETCHAR can be used to set the drive
characteristics for a XTC. This is needed if the drive doesn't contain proper
RDSK information yet but needs to be accessed. After the command has been
completed the drive should be accessible. The command takes a pointer to a
PhysDriveChar structure in IO_DATA and sizeof(PhysDriveChar) in IO_LENGTH. Look
here:
*/

#define SSD_SETCHAR 32

	struct PhysDriveChar
		{
		ULONG pdc_Cylinders;
		ULONG pdc_Sectors;
		ULONG pdc_Heads;
		ULONG pdc_Interleave;
		ULONG pdc_Park;
		LONG pdc_Reserved2[3];
		ULONG pdc_WritePreComp;
		ULONG pdc_ReducedWrite;
		ULONG pdc_StepRate;
		LONG pdc_Reserved3[5];
		};

/*
Another command used by XTC SoftSCSIs is actually a possibility to access the
XTC directly. You supply a SCSICmd structure with the following entries:
scsi_Data points to your data area; scsi_Length should contain the size of the
data area; scsi_Command points to your XTC CDB; scsi_CmdLength should contain
the size of the CDB. scsi_Status takes the XTC status byte. All other fields
respectively.
*/

#define SSD_XTCCMD 33

/*
Each Open() of the device creates a new unit structure. This is different to the
way unit structures are usually handled but is perfectly OK.
*/

	struct ALFUnit
		{
		struct MsgPort au_ReplyPort; /* This is the reply port for the I/O
			request we send to the SoftSCSI. */
		struct IOStdReq au_IOReq; /* This is our I/O request we send of to the
			SoftSCSI. The request should be returned to the above. Note: We only
			use quick I/O to speed things up, so we wouldn't need a port to reply
			to, this is just for future expansion. */
		UBYTE au_Sense[SENSESIZE]; /* Space to take up SCSI sense information.
			This is only used when SCSIF_AUTOSENSE is set. */
		UBYTE au_Command[COMMANDSIZE]; /* Space where we create our SCSI command.
			We can only create 6 byte commands. */
		ULONG au_UnitNum; /* This is our 3 decimal digit unit number. */
		ULONG au_Board;
		ULONG au_SCSIUnitNum;
		};

#endif
