Flirting & love
Now available for free: Free Report Online Profits

ASPI programming in Win32

Recommended SCSI hw & books from Amazon

Win32asm programming

This section is win32asm specific. For general information about ASPI programming please read the ASPI general information first. Topics covered:
  • Win32asm specific information
  • Initializing ASPI
  • Scanning the SCSI2 bus
  • Executing SCSI2 commands
  • Test unit ready command example
  • Stopping ASPI
  • Win32asm specific information

    Specific to ASPI programming in assembly is the circumstance that some include files are required. These files are the asm version of the corresponding headers used in C++ programming.

    Since I couldn't find them anywhere, I converted myself the original headers from the Adaptec's SDK, and now I am releasing them here for you to enjoy (although I don't think that many other programmers in the world are interested in...).

    The include files are WNASPI32.INC and SCSIDEFS.INC. If you download them remember to change the file extension from TXT to INC.

    IMPORTANT: in this page some example code is provided. All the code comes from a code segment, whereas many of the contained symbols are defined in the data segment. Here you can find the declarations of those symbols in the data segment, common to all the example code provided in this page.

    Initializing ASPI

    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.

    Scanning the SCSI2 bus

    The function provided in the sample code can be used to scan the SCSI2 bus. The code is commented. You will notice that the IDE/EIDE controller in the PC motherboard is recognized just as if it were a SCSI2 device.

    Three for/next nested cycles are implemented in asm. The doubleword interested are: HA_num, SCSI_Id, and SCSI_Lun. These cycles are easy to recognize within the listing.

    HA_num is the variable in the outermost for/next cycle (see the provided sample code). It starts from zero and goes up to HA_Count, scanning each host adapter found, IDE/EIDE controller included.

    SCSI_Id and SCSI_Lun go from 0 to 7.

    Executing SCSI2 commands

    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.

    Test unit ready command example

    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 too simple to be commented. A WaitForSingleObject is used to wait for the SCSI2 command completion.

    Stopping ASPI

    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: