Advanced SCSI Programming Interface

Download Report

Transcript Advanced SCSI Programming Interface

Advanced SCSI
Programming Interface
A few notes about ‘ASPI for Win32’
Some “FINE” Print: DISCLAIMER:
This information is intended ONLY as an overview and introduction to ASPI and is NOT a specification of
any kind. GUSTECH, Solution Technology Inc., and the instructor make no warranty and assume no liability
arising from the application or use of any information described herein, and assume no responsibility for errors
appearing in this document or for any claims that the concepts or details discussed or disclosed in these
materials are proprietary to any person or company. Students are strongly urged to clear any designs proposed
for products with their patent and copyright council. Note: company, brand, product, trade, and other names
used in this document are trademarks of their respective holders.
ASPI for Win32

Brief Synopsis
SCSI-2 Host’s System Model

ASPI Overview

ASPI Manager & Module(s)

To use ASPI: call 5 Functions
SCSI I/O Requests (SRBs)

–
with some details concerning:
–
(SendASPI32Command)
(Execute SCSI I/O Command)
–
29 May 2000
Developed by GUSTECH
2
29 May 2000
Developed by GUSTECH
Results from HAB
-Adapter & Driver
Dependent
Results from
Device Driver
-OS Dependent
Results from
Operating
System
-OS Dependent
Host
Adapter:
SCSI Results:
-Status
-Sense Data
NOTE: SCSI bus not shown
SCSI Request includes:
-Starting Block
-Number of Blocks
-Pointers to Data Area
ASPI Manager: Host Adapter Driver
ASPI
ASPI Modules: Peripheral Interfaces
Device
Driver:
SCSI Request includes:
-ASPI command, CDB
-Starting Block
-Number of Blocks
-Pointers to Data Areas
Application:
Operating
System:
Block Request built:
-Starting Block
-Number of Blocks
-Pointers to Memory
File Request includes:
-File Name
-Length of transfer
-Offset in Data Area
SCSI-2 Host’s System Model
3
ASPI Overview

Abstraction Layer created to insulate developers
from tedious details of the host adapter hardware

Defines a protocol for SCSI Device Driver and
programs to submit I/O requests to a host adapter

Designed to increase compatibility and simplify
the connection of SCSI peripheral devices

Developed by Adaptec & first completed around
1984
29 May 2000
Developed by GUSTECH
4
ASPI Overview




ASPI supports re-entry. Up to 255 commands
may be queued. ASPI will return from a request
immediately, as the request is queued for
execution by the manager. There is also support
for multi-threaded I/O.
ASPI does NOT support Asynchronous Event
Notification (or Reporting).
ASPI supports any length SCSI CDB size.
ASPI does NOT support message phase control
29 May 2000
Developed by GUSTECH
5
ASPI Overview






ASPI does NOT support tag queuing control
ASPI does NOT support disconnect/reconnect
control
ASPI does NOT support narrow/wide negotiation
ASPI does NOT support synchronous negotiation
ASPI supports messages; it does NOT allow you
to control the setup of these SCSI features.
If a message feature is not used, ASPI is not
responsible for the non-use.
29 May 2000
Developed by GUSTECH
6
ASPI Overview




ASPI does NOT support command linking
ASPI does NOT support SCSI Bus resets, but it
does support Device Resets (message out).
Most current version of ASPI is version 4.57,
build 1008.
As this material is for reference only, always go to
Adaptec for the latest, ‘official’ information:
www.adaptec.com
29 May 2000
Developed by GUSTECH
7
ASPI Manager Overview


Operating System and HAB Hardware Dependent;
therefore, separate manager for each HAB family
Written to manage Host Adapter Board Resources

Implemented as a Dynamic Link Library
wnaspi32.dll

Is the single operating system “device” driver

Accepts I/O requests from ASPI Modules

Scans SCSI bus for devices and builds table for
Module’s information
29 May 2000
Developed by GUSTECH
8
ASPI Module(s) Overview

SCSI “client” application programs

Submits I/O requests to the ASPI Manager &
receives status via “function calls”

Tailored to each peripheral type’s unique SCSI
Command Set (disk, tape, printer, scanner, etc.)

Integrate each type of SCSI device into the
Operating System through ASPI

Does NOT scan the SCSI bus for device info.

Structured as SCSI Request Blocks (SRB’s)
29 May 2000
Developed by GUSTECH
9
to use ASPI...

the following five functions interact with
wnaspi32.dll with these entry points
(using ‘C’ calling convention like “___cdecl”) :
–
GetASPI32SupportInfo

–
Returns the number of host adapters installed and other
miscellaneous information. Should call this function to make
sure that ASPI is properly initialized before calling:
SendASPI32Command will show more details

Handles all SCSI I/O requests
–
–
–
29 May 2000
A command code specifies the type of I/O
Is called with a pointer to the SCSI Request Block
SRB structure is ASPI Command Code dependent
Developed by GUSTECH
10
to use ASPI…(continued)

the last three (of five) functions interact with
wnaspi32.dll with these entry points:
–
GetASPI32Buffer

Allocates buffers which meet Win95/WinNT large transfer
requirements
–
–
FreeASPI32Buffer

–
Releases buffers previously allocated with GetASPI32Buffer
TranslateASPI32Address

Translates ASPI HA/ID/LUN address triples to/from Win95
DEVNODEs.
–
29 May 2000
up to 512KBytes with “safe” physical continuity
to associate ASPI target addresses with Plug and Play capability
Developed by GUSTECH
11
SendASPI32Command details




Handles all SCSI I/O requests, and
Each is handled through a SCSI Request Block
Each SRB defines the exact ASPI operation
All SRBs have a standard header containing:
–
–
–
–
–

SRB_CMD = command code byte
SRB_Status = command status byte (return values)
SRB_HaId = host adapter number byte
SRB_Flags = request flags byte
SRB_Hdr_Rsvd = Reserved, Must = 0, Double Word
All SRBs have a body that is SRB unique, having
some or all of: Target ID, LUN, Data pointer & length,
Sense Data & CDB length, and Status for HA & Target
29 May 2000
Developed by GUSTECH
12
SRB_Cmd codes:

SC_HA_INQUIRY = 0x00 = Queries ASPI for
information on specific host adapters

SC_GET_DEV_TYPE = 0x01 = Requests the
SCSI device type for a specific SCSI target

SC_EXEC_SCSI_CMD = 0x02 = Sends a SCSI
command (arbitrary CDB) to a SCSI target will look
at in detail later

SC_ABORT_SRB = 0x03 = Requests that ASPI
cancel a previously submitted request
29 May 2000
Developed by GUSTECH
13
SRB_Cmd codes: (continued)

SC_RESET_DEV = 0x04 = Sends a BUS
DEVICE RESET message to a SCSI target

SC_GET_DISK_INFO = 0x06 = Returns BIOS
information for a SCSI target (Win95 only)

SC_RESCAN_SCSI_BUS = 0x07 = Requests a
rescan of a host adapter’s SCSI bus

SC_GETSET_TIMEOUTS = 0x08 = Sets SRB
timeouts for specific SCSI targets
29 May 2000
Developed by GUSTECH
14
Execute SCSI I/O Command: detail











SRB_Cmd = 02h @ offset = 00h
Command Status returned (1 of 11) @ offset = 01h
Host Adapter Number @ offset = 02h
SCSI Request Flags (any 3 of 5) @ offset = 03h
Reserved double-word = 0 @ offset = 04h
Target ID @ offset = 08h
Logic Unit Number @ offset = 09h
Reserved word = 0 for alignment @ offset = 0Ah
Buffer Data Allocation Length (r/w) @ offset = 0Ch
Data Buffer Pointer @ offset = 10h
Sense Allocation Length (see 40h) @ offset = 14h
29 May 2000
Developed by GUSTECH
15
Execute SCSI I/O Command:







(continued)
SCSI CDB Length in bytes (see 30h) @ offset = 15h
Host Adapter Status (1 of 11) @ offset = 16h
Target Status (per SCSI Spec) @ offset = 17h
Post Routine Address (if Posting, is pointer to
Function; if Event_Notify, is handle to an event on
completion of ASPI request) @ offset = 18h
Reserved ‘20hex’ bytes = 0 @ offset = 1Ch
SCSI Command Descriptor Block (16 bytes
allowed, actual length is per “CDB Length” value
see 15h) @ offset = 30h
Sense (data buffer) Allocation Area (CAC
Request Sense sense data see 14h) @ offset = 40h
29 May 2000
Developed by GUSTECH
16