SCSIReset

You can use the SCSIReset function to reset all devices on the SCSI bus.
FUNCTION SCSIReset: OSErr;

DESCRIPTION
The SCSIReset function directs the SCSI controller chip (or equivalent
hardware) in the Macintosh computer to assert the SCSI bus reset signal.
The reset signal causes all devices on the bus to clear pending I/O and
forces the bus into the bus free phase.

WARNING
The SCSIReset function interrupts SCSI communications and can cause data
loss. Use this function only in exceptional circumstances.

ASSEMBLY-LANGUAGE INFORMATION
The trap macro and routine selector for SCSIReset are
Trap macro	Selector	
_SCSIDispatch	$0000	

RESULT CODES
noErr      0       No error
scCommErr  2       Communications error, operation timeout 

SEE ALSO
See "SCSI Bus Signals," beginning on page 3-4, and "SCSI Bus Phases,"
beginning on page 3-5, for more information about the reset signal and
the bus free phase.


SCSIGet

You use the SCSIGet function to arbitrate for control of the SCSI bus.
FUNCTION SCSIGet: OSErr;

DESCRIPTION
The SCSIGet function prepares the SCSI Manager to initiate the arbitration
sequence. If the SCSI Manager is busy with another operation, this function
returns the scMgrBusyErr result. If arbitration failed because the bus was
busy, the function returns the scArbNBErr result.

IMPORTANT
The operation of the SCSIGet function varies on different Macintosh models
and does not necessarily initiate the SCSI bus arbitration phase. In some
Macintosh models, the arbitration phase does not occur until your program
calls the SCSISelect function. However, your program must always call the
SCSIGet function before calling SCSISelect.

ASSEMBLY-LANGUAGE INFORMATION
The trap macro and routine selector for SCSIGet are
Trap macro	Selector	
_SCSIDispatch	$0001	

RESULT CODES
noErr        0       No error
scCommErr    2       Communications error, operation timeout 
scArbNBErr   3       Bus busy, arbitration timeout 
scMgrBusyErr 7       SCSI Manager busy 

SEE ALSO
See "SCSI Bus Phases," beginning on page 3-5, for a description of the
arbitration phase.


SCSISelect

You use SCSISelect function to select a SCSI device for a subsequent
operation.

FUNCTION SCSISelect (targetID: Integer): OSErr;
targetID - The SCSI ID of the target device, with a value from 0 to 7.

DESCRIPTION
The SCSISelect function selects the SCSI device identified by the targetID
value.

IMPORTANT
You must call the SCSIGet function before calling SCSISelect.

ASSEMBLY-LANGUAGE INFORMATION
The trap macro and routine selector for SCSISelect are
Trap macro	Selector	
_SCSIDispatch	$0002	

RESULT CODES
noErr           0       No error
scCommErr	2	Communications error, operation timeout	
scArbNBErr	3	Bus busy, arbitration timeout	
scSequenceErr	8	Attempted operation is out of sequence	

SEE ALSO
See "SCSI Bus Phases," beginning on page 3-5, for a description of the
selection phase.


SCSISelAtn

You can use the SCSISelAtn function to select a SCSI device and at the same
time to assert the attention (/ATN) bus signal.

FUNCTION SCSISelAtn (targetID: Integer): OSErr;
targetID - The SCSI ID of the target device, with a value from 0 to 6.

DESCRIPTION
The SCSISelAtn function is identical to the SCSISelect function except that
this function asserts the /ATN signal during selection. The /ATN signal
informs the target that the initiator wants to send a message. The SCSISelAtn
function must be followed by a call to the SCSIMsgOut function to send the
message to the target device.

ASSEMBLY-LANGUAGE INFORMATION
The trap macro and routine selector for SCSISelAtn are
Trap macro	Selector	
_SCSIDispatch	$000B	

RESULT CODES
noErr           0       No error
scCommErr	2	Communications error, operation timeout	

SEE ALSO
See "SCSI Bus Signals," beginning on page 3-4, and "SCSI Bus Phases,"
beginning on page 3-5, for more information about the attention signal and
the selection phase.


SCSICmd

You use the SCSICmd function to send a SCSI command to a SCSI device.

FUNCTION SCSICmd (buffer: Ptr; count: Integer): OSErr;
buffer - A pointer to a buffer containing the SCSI command descriptor block.
count  - The size of the command descriptor block, in bytes.

DESCRIPTION
The SCSICmd function sends a SCSI command to the previously selected target
device. The command code and other parameters are contained in a command
descriptor block (CDB) data structure pointed to by the buffer parameter.
The count parameter specifies the size of the CDB structure, which can be 6,
10, or 12 bytes.

The SCSI specification describes the CDB data structure and lists the
standard SCSI commands that all devices must support. Devices may support
additional commands not defined by the SCSI specification.

ASSEMBLY-LANGUAGE INFORMATION
The trap macro and routine selector for SCSICmd are
Trap macro	Selector	
_SCSIDispatch	$0003	

RESULT CODES
noErr           0       No error
scCommErr	2	Communications error, operation timeout	
scPhaseErr	5	Phase error on the SCSI bus	

SEE ALSO
See "SCSI Commands," beginning on page 3-7, for an overview of SCSI commands.
Refer to the SCSI specification for detailed information about SCSI commands.


SCSIMsgIn

You can use the SCSIMsgIn function to receive a message from a SCSI device.

FUNCTION SCSIMsgIn (VAR message: Integer): OSErr;
message	The low-order byte contains the message from the target device.

DESCRIPTION
The SCSIMsgIn function receives a SCSI message from the previously selected
target device. The message is returned in the low-order byte of the message
parameter. See the SCSI specification for information about the types of
messages that can be sent from a target to an initiator.

The SCSIMsgIn function leaves the attention bus signal undisturbed if it is
already asserted.

ASSEMBLY-LANGUAGE INFORMATION
The trap macro and routine selector for SCSIMsgIn are
Trap macro	Selector	
_SCSIDispatch	$000C	

RESULT CODES
noErr           0       No error
scCommErr	2	Communications error, operation timeout	
scPhaseErr	5	Phase error on the SCSI bus	

SEE ALSO
See "SCSI Messages," beginning on page 3-7, for an overview of SCSI messages.
Refer to the SCSI specification for detailed information about SCSI messages.


SCSIMsgOut

You can use the SCSIMsgOut function to send a message to a SCSI device.

FUNCTION SCSIMsgOut (message: Integer): OSErr;
message	The low-order byte contains the message to be sent to the target
device.

DESCRIPTION
The SCSIMsgOut function sends a SCSI message to the previously selected target
device. The message is contained in the low-order byte of the message parameter.
See the SCSI specification for information about the types of messages that
can be sent from an initiator to a target.

ASSEMBLY-LANGUAGE INFORMATION
The trap macro and routine selector for SCSIMsgOut are
Trap macro	Selector	
_SCSIDispatch	$000D	

RESULT CODES
noErr           0       No error
scCommErr	2	Communications error, operation timeout	
scPhaseErr	5	Phase error on the SCSI bus	

SEE ALSO
See "SCSI Messages," beginning on page 3-7, for an overview of SCSI messages.
Refer to the SCSI specification for detailed information about SCSI messages.


SCSIRead

You can use the SCSIRead function to read data from a SCSI device using a
polled transfer.

FUNCTION SCSIRead (tibPtr: Ptr): OSErr;
tibPtr	A pointer to an array of TIB instructions.

DESCRIPTION
The SCSIRead function reads data from the previously selected target device.
The data transfer instructions are specified by the TIB array pointed to by
the tibPtr parameter.

ASSEMBLY-LANGUAGE INFORMATION
The trap macro and routine selector for SCSIRead are
Trap macro	Selector	
_SCSIDispatch	$0005	

RESULT CODES
noErr           0       No error
scCommErr	2	Communications error, operation timeout	
scBadParmsErr	4	Unrecognized TIB instruction	
scPhaseErr	5	Phase error on the SCSI bus	
scCompareErr	6	Comparison error from scComp instruction	

SEE ALSO
See "Using CDB and TIB Structures," beginning on page 3-17, for information
about using TIB instructions. See "SCSI Manager TIB Instructions," beginning
on page 3-27, for details of the TIB instruction set.


SCSIRBlind

You can use the SCSIRBlind function to read data from a SCSI device using a
blind transfer.

FUNCTION SCSIRBlind (tibPtr: Ptr): OSErr;
tibPtr	A pointer to an array of TIB instructions.

DESCRIPTION
The SCSIRBlind function is identical to the SCSIRead function but does not
poll the SCSI controller before transferring each byte of data. The SCSI
controller is polled only for the first byte transferred by each scInc,
scNoInc, or scComp TIB instruction.

SPECIAL CONSIDERATIONS
You should use this function only if the device you are reading from is
capable of transferring data fast enough to avoid timeout errors from the
SCSI controller.

ASSEMBLY-LANGUAGE INFORMATION
The trap macro and routine selector for SCSIRBlind are
Trap macro	Selector	
_SCSIDispatch	$0008	

RESULT CODES
noErr           0       No error
scCommErr	2	Communications error, operation timeout	
scBadParmsErr	4	Unrecognized TIB instruction	
scPhaseErr	5	Phase error on the SCSI bus	
scCompareErr	6	Comparison error from scComp instruction	
scBusTOErr	9	Bus timeout during blind transfer	

SEE ALSO
See the description of the SCSIRead function on page 3-36 for information
about performing a polled transfer. See "Choosing Polled or Blind Transfers,"
beginning on page 3-22, for additional information.


SCSIWrite

You can use the SCSIWrite function to write to a SCSI device using a polled
transfer.

FUNCTION SCSIWrite (tibPtr: Ptr): OSErr;
tibPtr	A pointer to an array of TIB instructions.

DESCRIPTION
The SCSIWrite function transfers data to the previously selected target device.
The data transfer instructions are specified by the TIB array pointed to by
the tibPtr parameter.

ASSEMBLY-LANGUAGE INFORMATION
The trap macro and routine selector for SCSIWrite are
Trap macro	Selector	
_SCSIDispatch	$0006	

RESULT CODES
noErr           0       No error
scCommErr	2	Communications error, operation timeout	
scBadParmsErr	4	Unrecognized TIB instruction	
scPhaseErr	5	Phase error on the SCSI bus	

SEE ALSO
See "Using CDB and TIB Structures," beginning on page 3-17, for information
about using TIB instructions. See "SCSI Manager TIB Instructions," beginning
on page 3-27, for details of the TIB instruction set.


SCSIWBlind

You can use the SCSIWBlind function to write to a SCSI device using a blind
transfer.

FUNCTION SCSIWBlind (tibPtr: Ptr): OSErr;
tibPtr	A pointer to an array of TIB instructions.

DESCRIPTION
The SCSIWBlind function is identical to the SCSIWrite function but does not
poll the SCSI controller before transferring each byte of data. The SCSI
controller is polled only for the first byte transferred by each scInc,
scNoInc, or scComp TIB instruction.

SPECIAL CONSIDERATIONS
You should use this function only if the device you are writing to is capable
of accepting data fast enough to avoid timeout errors from the SCSI controller.

ASSEMBLY-LANGUAGE INFORMATION
The trap macro and routine selector for SCSIWBlind are
Trap macro	Selector	
_SCSIDispatch	$0009	

RESULT CODES
noErr           0       No error
scCommErr	2	Communications error, operation timeout	
scBadParmsErr	4	Unrecognized TIB instruction	
scPhaseErr	5	Phase error on the SCSI bus	
scBusTOErr	9	Bus timeout during blind transfer	

SEE ALSO
See the description of the SCSIWrite function on page 3-38 for information
about performing a polled transfer. See "Choosing Polled or Blind Transfers,"
beginning on page 3-22, for additional information.


SCSIComplete

You use the SCSIComplete function to complete a SCSI transaction.
FUNCTION SCSIComplete (VAR stat: Integer; VAR message: Integer;
                       wait: LongInt): OSErr;

stat    - The low-order byte contains the status byte from the target device.
message - The low-order byte contains the message byte from the target device.
wait    - The number of ticks to wait for the command to complete.

DESCRIPTION
The SCSIComplete function performs the tasks necessary to properly complete
the current SCSI transaction and leave the bus in the bus free phase. This
function must be called at the end of each SCSI transaction, even if the
transaction does not complete successfully.

The SCSIComplete function waits for the transaction to complete, and then
returns one byte of status information and one byte of message information.
If the transaction fails to complete within the number of ticks specified by
the wait parameter, the scCommErr result is returned.

The SCSIComplete function uses a number of strategies to correct anomalous
conditions on the SCSI bus and restore the bus into a known state. These
include accepting arbitrary amounts of data sent by the target (and throwing
this data away), and sending arbitrary data (bytes with the value of $EE) as
requested by the target. The function returns the scComplPhaseErr result if
either of these steps were necessary.

ASSEMBLY-LANGUAGE INFORMATION
The trap macro and routine selector for SCSIComplete are
Trap macro	Selector	
_SCSIDispatch	$0004	

RESULT CODES
noErr           0       No error
scCommErr	2	Communications error, operation timeout	
scPhaseErr	5	Phase error on the SCSI bus	
scComplPhaseErr	10	SCSI bus was not in status phase on entry to
                        SCSIComplete

SEE ALSO
See "Using the SCSIComplete Function," beginning on page 3-21, for more
information about this function.


SCSIStat

You can use the SCSIStat function to obtain status information from the SCSI
Manager.

FUNCTION SCSIStat: Integer;
DESCRIPTION

The SCSIStat function returns a 16-bit value containing status information.
This information includes the state of all SCSI bus control signals as well
as the status of the NCR 5380 SCSI controller chip (or equivalent hardware).
In Macintosh models that use other SCSI controller hardware, the status
information conforms to the 5380 format, but may not represent the actual
state of the hardware.

IMPORTANT
Because hardware differences make it difficult to accurately interpret the
status information, use of this function is not recommended.

Bits 0 through 9 represent the state of the SCSI bus signals, and bits 10
through 15 report status information from the SCSI controller hardware. The
status bits have these meanings:

Bit	Name	Meaning
0	DBP	Data parity signal	
1	/SEL	Select signal	
2	/I/O	I/O signal	
3	/C/D	Command/Data signal	
4	/MSG	Message signal	
5	/REQ	Request signal	
6	/BSY	Busy signal	
7	/RST	Reset signal	
8	/ACK	Acknowledge signal	
9	/ATN	Attention signal	
10	BSY ERR	Busy error	
11	PHS MAT	Phase match	
12	INT REQ	Interrupt request	
13	PTY ERR	Parity error	
14	DMA REQ	Direct memory access request	
15	END DMA	Direct memory access complete	

Note
The SCSI bus control signals are active low; therefore, the status bits
represent the complement of the bus signals.

ASSEMBLY-LANGUAGE INFORMATION
The trap macro and routine selector for SCSIStat are
Trap macro	Selector	
_SCSIDispatch	$000A	

RESULT CODES
noErr           0       No error
scCommErr	2	Communications error, operation timeout	
scPhaseErr      5       Phase error on the SCSI bus

SEE ALSO
See "SCSI Bus Signals," beginning on page 3-4, for an overview of SCSI bus
signals. Refer to the SCSI specification for detailed information about SCSI
bus signals. Refer to the NCR 5380 SCSI controller specification for
information about that device.
