@ GNU AS assembler header file for SCSI
@ Written by DefMod (Dec  9 2012) on Sun Dec  9 15:49:36 2012
@ Jonathan Coxhead, jonathan@doves.demon.co.uk, 27 June 1995

@ OSLib---efficient, type-safe, transparent, extensible,
@ register-safe API coverage of RISC OS
@ 
@ Copyright (c) 1994-2012 Jonathan Coxhead and OSLib maintainers
@ 
@ Licence:
@ 
@    OSLib is free software; you can redistribute it and/or modify
@ it under the terms of the GNU General Public License as published by
@ the Free Software Foundation; either version 1, or (at your option)
@ any later version - and this with the following clarification and
@ special exception:
@ 
@    Linking this library statically or dynamically with other modules
@ is making a combined work based on this library. Thus, the terms
@ and conditions of the GNU General Public License cover the whole
@ combination.
@ 
@    As a special exception, the copyright holders of this library
@ give you permission to link this library with independent modules
@ to produce an executable, regardless of the license terms of these
@ independent modules, and to copy and distribute the resulting
@ executable under terms of your choice, provided that you also meet,
@ for each linked independent module, the terms and conditions of the
@ license of that module. An independent module is a module which is
@ not derived from or based on this library. If you modify this
@ library, you may extend this exception to your version of the library,
@ but you are not obliged to do so. If you do not wish to do so, delete
@ this exception statement from your version.
@ 
@    OSLib is distributed in the hope that it will be useful,
@ but WITHOUT ANY WARRANTY; without even the implied warranty of
@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
@ GNU General Public License for more details.
@ 
@    You should have received a copy of the GNU General Public License
@ along with this programme; if not, write to the Free Software
@ Foundation, Inc, 675 Mass Ave, Cambridge, MA 02139, USA.

#ifndef SCSI_Hdr
#  define SCSI_Hdr

#  ifndef Get_Types
#    define Get_Types
#    include "oslib/Types.Hdr"
#  endif

#  ifndef Get_OS
#    define Get_OS
#    include "oslib/OS.Hdr"
#  endif

@Symbols for constants
#  define SCSI_CheckNoChange 0xffffffff
#  define SCSI_CheckError 0x0
#  define SCSI_CheckSense 0x1
#  define SCSI_CheckRetry 0x2
#  define SCSI_BehaviourNoChange 0xffffffff
#  define SCSI_BehaviourWait 0x0
#  define SCSI_BehaviourAwaitQueue 0x1
#  define SCSI_BehaviourAwaitDevice 0x2
#  define SCSI_BehaviourAwaitCard 0x3
#  define SCSI_DisconnectNoChange 0xffffffff
#  define SCSI_DisconnectAllowed 0x0
#  define SCSI_DisconnectInhibitedByBlocking 0x1
#  define SCSI_DisconnectInhibited 0x2
#  define SCSI_DeviceStatusIdle 0x1
#  define SCSI_DeviceStatusBusy 0x2

@Symbols for structure offsets and sizes
        .struct 0
        .skip   Bits
SCSI_SoftwareFeatures          : 

        .struct 0
        .skip   Bits
SCSI_HardwareFeatures          : 

        .struct 0
        .skip   Byte
SCSI_DeviceType                : 

        .struct 0
        .skip   Byte
SCSI_DeviceFlags               : 

        .struct 0
        .skip   Byte
SCSI_DeviceVersion             : 

        .struct 0
SCSI_DeviceDescription_type    : .skip   SCSI_DeviceType
SCSI_DeviceDescription_flags   : .skip   SCSI_DeviceFlags
SCSI_DeviceDescription_version : .skip   SCSI_DeviceVersion
SCSI_DeviceDescription_reserved0: .skip   Byte
SCSI_DeviceDescription_length  : .skip   Byte
SCSI_DeviceDescription_reserved1: .skip   Byte
SCSI_DeviceDescription_reserved2: .skip   Byte
SCSI_DeviceDescription_reserved3: .skip   Byte
SCSI_DeviceDescription_block_count: .skip   Int
SCSI_DeviceDescription_block_size: .skip   Int
SCSI_DeviceDescription         : 

        .struct 0
        .skip   Int
SCSI_ErrorResponseLevel        : 

        .struct 0
        .skip   Int
SCSI_QueueBehaviour            : 

        .struct 0
        .skip   Int
SCSI_Disconnection             : 

        .struct 0
SCSI_OpBlock_o                 : .skip   Int
SCSI_OpBlock                   : 

        .struct 0
        .skip   Int
SCSI_DeviceStatus              : 

        .struct 0
SCSI_CardAddressList_addr      : .skip   Ptr
SCSI_CardAddressList           : 


@Symbols for SWI's and SWI reason codes
.set XSCSI_Version,0x603c0
.set SCSI_Version,0x403c0
   @Exit
   @  R0 = software_version (Bits)
   @  R1 = software_features (SCSI_SoftwareFeatures)
   @  R2 = hardware_version (Bits)
   @  R3 = hardware_features (SCSI_HardwareFeatures)

.set XSCSI_Initialise,0x603c1
.set SCSI_Initialise,0x403c1

#  define SCSIInitialise_ResetBus 0x0
   @Entry
   @  R0 = &0
   @  R1 = host_id (Int)

#  define SCSIInitialise_ResetDevice 0x1
   @Entry
   @  R0 = &1
   @  R1 = device_id (Int)
   @  R8 = access_key (Int)

#  define SCSIInitialise_DetermineDevice 0x2
   @Entry
   @  R0 = &2
   @  R1 = device_id (Int)
   @  R2 = description (pointer to SCSI_DeviceDescription)

#  define SCSIInitialise_EnumerateDevice 0x3
   @Entry
   @  R0 = &3
   @  R1 = device_id (Int)
   @  R2 = description (pointer to String)
   @  R3 = size (Int)

.set XSCSI_Control,0x603c2
.set SCSI_Control,0x403c2

#  define SCSIControl_AbortDevice 0x0
   @Entry
   @  R0 = &0
   @  R1 = device_id (Int)
   @  R8 = access_key (Int)

#  define SCSIControl_AbortOp 0x1
   @Entry
   @  R0 = &1
   @  R1 = device_id (Int)
   @  R2 = op_id (Int)
   @  R8 = access_key (Int)

#  define SCSIControl_SetTimeout 0x3
   @Entry
   @  R0 = &3
   @  R1 = device_id (Int)
   @  R2 = timeout (Int)
   @  R8 = access_key (Int)
   @Exit
   @  R2 = old_timeout (Int)

#  define SCSIControl_SetErrorResponse 0x4
   @Entry
   @  R0 = &4
   @  R1 = device_id (Int)
   @  R2 = level (SCSI_ErrorResponseLevel)
   @  R8 = access_key (Int)
   @Exit
   @  R2 = old_level (Int)

#  define SCSIControl_SetQueueBehaviour 0x5
   @Entry
   @  R0 = &5
   @  R1 = device_id (Int)
   @  R2 = behaviour (SCSI_QueueBehaviour)
   @  R8 = access_key (Int)
   @Exit
   @  R2 = old_level (Int)

#  define SCSIControl_Disconnect 0x6
   @Entry
   @  R0 = &6
   @  R1 = device_id (Int)
   @  R2 = disconnection (SCSI_Disconnection)
   @Exit
   @  R2 = old_disconnection (Int)
   @  R8 = access_key (Int)

.set XSCSI_Op,0x603c3
.set SCSI_Op,0x403c3
   @Entry
   @  R0 = op (Bits)
   @  R1 = block_size (Int)
   @  R2 -> block (SCSI_OpBlock)
   @  R3 = start_addr (pointer to data)
   @  R4 = length (Int)
   @  R5 = timeout (Int)
   @  R6 = callback_code (pointer to code)
   @  R7 = workspace (pointer to Void)
   @  R8 = access_key (Int)
   @Exit
   @  R0 = op_id (Int)
   @  R3 = next_addr (pointer to data)
   @  R4 = undone (Int)

.set XSCSI_Status,0x603c4
.set SCSI_Status,0x403c4

#  define SCSIStatus_CheckDevice 0x0
   @Entry
   @  R0 = &0
   @  R1 = device_id (Int)
   @Exit
   @  R0 = status (SCSI_DeviceStatus)

.set XSCSI_Reserve,0x603c7
.set SCSI_Reserve,0x403c7

#  define SCSIReserve_Claim 0x0
   @Entry
   @  R0 = &0
   @  R1 = device_id (Int)
   @  R2 = release_code (pointer to code)
   @  R3 = workspace (pointer to Void)
   @  R8 = access_key (Int)

#  define SCSIReserve_ForceClaim 0x1
   @Entry
   @  R0 = &1
   @  R1 = device_id (Int)
   @  R2 = release_code (pointer to code)
   @  R3 = workspace (pointer to Void)
   @  R8 = access_key (Int)

#  define SCSIReserve_Release 0x2
   @Entry
   @  R0 = &2
   @  R1 = device_id (Int)
   @  R8 = access_key (Int)

.set XSCSI_List,0x603c8
.set SCSI_List,0x403c8
   @Entry
   @  R0 -> list (SCSI_CardAddressList)

.set XSCSI_TargetControl,0x603c9
.set SCSI_TargetControl,0x403c9

#endif
