ASPI programming in Win32
Recommended SCSI hw & books from Amazon
C++ programming
This section is C++ specific. For general information about ASPI
programming please read the ASPI general
information first. Topics covered:
Always include into your projects both WNASPI32.H
and SCSIDEFS.H. These headers contain all the
typedefs, constants and structures needed for ASPI/SCSI2 programming.
The function provided in the sample code can be
called to initialize ASPI at the beginning of an application program. The
code is self explanatory.
The function provided in the sample code can be
used to scan the SCSI2 bus. The code is self explanatory. You will notice
that the IDE/EIDE controller in the PC motherboard is recognized just as
if it were a SCSI2 device.
Actually IDE/EIDE family members are the poor relatives of SCSI2 devices.
I have no experience in dealing with IDE/EIDE devices. There should be
very good sites around the web talking about this subject.
The HA_num variable in the outermost "for" cycle in the provided sample code:
for ( BYTE HA_num = 0; HA_num < HA_Count; HA_num++ )
starts from zero and goes up to HA_Count, scanning each host adapter found,
IDE/EIDE controller included. Please note that the value of HA_num
is the host adapter card number, an unique identifier assigned by
the ASPI manager. I don't know how does the ASPI manager assign these
numbers to the installed host adapters, but as soon as your SCSI2 host
adapter card gets one assigned, it should be always passed in the SRB_HaId
member of the SRB for the commands to reach the desired host adapter. A
wrong number would make the application program appear to do nothing.
Summarizing the general discussion about ASPI programming it comes that to send a SCSI2 command
to a SCSI2 device it is necessary to execute an Exec SCSI2 command
ASPI command or, in other words, to call SendASPI32Command with a
SC_EXEC_SCSI_CMD command code. The SRB corresponding to SC_EXEC_SCSI_CMD
(i.e.: SRB_ExecSCSICmd) should be prepared for this purpose.
The SRB_ExecSCSICmd structure accomodates the SCSI2 command description
in its members. Furthermore accomodates a "sense area", see below.
The good new with the Exec SCSI2 command ASPI command is that, in
case the SCSI2 command fails, a RequestSense SCSI2 command is
automatically sent to the target device to retrieve the sense data. So if
the returned ASPI status byte is not SS_COMP the programmer automatically
finds the sense data into the sense area of SRB_ExecSCSICmd.
The function provided in the sample code can be
used to send a Test Unit Ready SCSI2 command to any SCSI2 device. The code
is commented.
Any other SCSI2 command can be sent to any SCSI2 device in a similar fashion.
It can be useful to reset the a SCSI target in some circumstances. For example
when an experimental SCSI command sequence is wrong and the target appears
to be busy forever. Here you will find the
sample code to perform this simple operation.
Thanks Tony for pointing out that the proposed code does reset an individual
target and not the whole bus.
There is nothing to stop when you are finished using ASPI support: just free
the DLL and delete the event object. This is the sample
code.
Working with SCSI ? This is the book to buy: | |
|