Hi people,

>> Hard Disk -- USB (4K sectors) -- DOS with "usbaspi.sys" (ASPI
>> manager) -- "didd1000.sys" (ASPI to DOS converter)

Adaptec ASPIDISK is less than 8 kB, much smaller than DI1000 the
2001 Novac Ninja ASPI disk driver 2.00 which made some FreeDOS
developers write angry comments about compat in our source ;-)

> There's no opensource ASPI/SCSI controller driver yet in DOS, be it
> for ATA, SCSI, FireWire or USB (and soon Thunderbolt I guess). Also
> no open source disk or CD driver that can hook into ASPI. An ASPI
> driver I sometimes use is the one by Oak Technology, to burn a disk
> on IDE DVD-drive, found at [ http://bootcd.narod.ru/index_e.htm ]

Details? Size, abilities, license, author?

>> ... in vague terms, that most stringent "anti
>> reverse engineering" laws allow for independent fixes
>> and enhancements to IP protected code, but IANAL.

You can manipulate software to fix interoperability bugs afair.

> usually the cleanest way of writing another implementation of some
> piece of software is to use "cleanroom reverse-engineering": * 1st
> team studies/disassembles/debugs and documents the program into a 
> specification. * 2nd team creates a piece of software out of this
> specification

A much more clean idea: Just read the specs and start programming
based on those. No reverse engineering, no voodoo to keep nonfree
code out of your driver, because you will simply not touch any :-p

ftp://ftp.isu.edu.tw/Hardware/ADAPTEC/adaptec/aspi_dos.ps

This (book chapter?) document of only 16 pages describes a list of
IOCTLs for ASPI support. Open SCSIMGR$, ioctl read using int 21
function 4402, cx=4, dsdx=pointer to your 4 byte buffer, bx=handle
and receive a far pointer to ASPI. To close ASPI, simply close the
SCSIMGR$ handle again.

To call ASPI, push a far pointer to a 58 byte data block, call far
the driver, add 4 to SP on return. The data block, a SCSI request
block, contains: a command byte, a status byte (set on return), a
host adapter byte (0-based controller number), a request flag byte
and 4 reserved bytes. Data at offset 8 and later depends on which
command you are using. Possible commands are:

0 host adapter inquiry
1 get device type
2 execute SCSI command
3 abort SCSI command
4 reset SCSI device
5 set host adapter parameters
6 get drive information

Possible status values are: 0 request in progress, 1 request did
complete okay, 2 aborted by host, 4 completed WITH error, 80 (hex)
invalid request, 81 no such host adapter, 82 no such device.



For the host adapter inquiry, set the reserved bytes to 55 aa 04
00 (request 4 bytes of extra data) and receive aa 55 04 00 back
(confirmed, got 4 bytes). Returned data at offset 8 and later is:

08 byte number of host adapters
09 byte scsi id of inquired host adapter
0a string of 16 bytes length describing the driver
1a string of 16 bytes length describing the host adapter
2a vendor specific block of 16 bytes of data
3a word flags, bits: 1 "residual byte length supported", 2 wide
   scsi 16bit, 3 wide scsi 32bit (bits 0, 4..15 are reserved)

Residual byte length is about buffers larger than the I/O (?).



For the get device type command 1, e.g. to scan LUNs, use: Flag
byte set to 0, reserved dword 0, send as data at offset 8 and 9
the target SCSI ID byte and target LUN byte and receive at the
offset 0a the device type according to SCSI specifications.



For the SCSI I/O command 2, set the reserved dword to 0 and flag
byte as follows: bit 0 "enable posting", 1 "enable linking" (set
to 0 for scather/gather), 2 "enable residual byte length report"
and bit 4+3 "00 direction automatic, 01 from SCSI target to host,
10 from host to SCSI target, 11 no data transfer" other bits 0.
The non-automatic directions also check your transfer length. At
offset 8 etc, send:

08 target ID byte, 09 device LUN byte
0a dword transfer length (0 if none) If residual... is on, this
   field tells the number of bytes that did not fit, on return.
0e sense allocation length byte, how many bytes at the end of
   this SRB (SCSI request block) can be used for "sense" data.
0f far pointer to I/O buffer, DOS style segment:offset one.
13 far pointer to next SRB if you use linking of multiple I/O.
17 byte length of SCSI command descriptor block CDB
18 RETURNED host adapter status: 0 okay, 11 select timeout, 12
   data overrun or underrun, 13 unexpected bus free, 14 target
   bus phase sequence error
19 RETURNED target status: 0 none, 2 check with "sense" data,
   8 specified target/LUN is busy, 18 reservation conflict
1a far pointer to post routine address
1e reserved scratch area
40 your command descriptor block, see offset 17, followed by
   the sense allocation area, max as much as you allow at 0e.
   The CDB is from you, RETURNED sense data from the driver.

For linking, set the linking flag and make a chain of SRBs.
Do not forget to also set the linking flag in the CDB. The
driver stops at the first chained command that fails. Note:
The PostScript document recommends to NOT use linking...

For posting, set the post flag. The driver will then do a
far call to your callback routine when your request is done,
with a far pointer to the completed SRB on the stack. Your
callback has to preserve all registers, for example like in:

push bp / mov bp,sp / pusha + segs / use pointer ss:[bp+6],
do stuff... / pop segs + a / pop bp / retf

Your callback can issue ASPI commands itself, EXCEPT abort,
but should not poll for things or otherwise waste time.



The abort command 3 takes a far pointer to the to-be-aborted
SRB at offset 8 from you, flags and reserved fields should
be 0. You do have to set the host adapter number. Only the
status byte at offset 1 is returned.



The reset SCSI device command 4 takes a host adapter number,
request flags (only the "posting" bit is used) and returns a
status. You also have to send at offsets: 08 target ID byte,
09 target LUN byte, 1a if posting: callback far DOS pointer.

Reserved fields (set to 0) are: offset 04 dword, offset 0a
dword. Offset 1e has a scratch word. RETURNED are two bytes:
Offset 18 host adapter status, 19 target status.



The set host adapter parameters command 5 takes host adapter
number, request flags and, at offset 08, sixteen bytes of
vendor specific parameters. Returns the usual status byte.



The get disk drive command 6 returns an interesting status:
Always 1 (okay) or 80 (not) depending on whether the driver
supports it... You send the host adapter number, zero flags,
zero reserved field. Also send the target ID and LUN bytes,
at offset 8 and 9. You RECEIVE: Offset 0a flag byte with 2
lower bits meaning: 00 non-int13 drive, 01 int13 drive, 10
int13 drive NOT used by DOS, 11 invalid. Bits 7-2 reserved.
Offset 0b byte int13 drive number, 0c byte preferred number
of heads*, 0d byte preferred number of sectors*, 0e sixteen
reserved bytes. * Note that CHS is just a translation and a
geometry of ? * 64 * 32 is common.



The last two pages of the document are about Windows 3.x
and DPMI access to ASPI plus one and a half empty pages :-)

Regards, Eric


------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Freedos-user mailing list
Freedos-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-user

Reply via email to