In a previous blog post "about building DOS under the programming platform," The introduction of a DOS Drive USB drive method, we have a general review. By adding two drivers to the Config.sys, you can drive a USB flash drive:
device = Aspiohci.sys
Device=di1000dd.sys
These two drivers are available for download in the above blog post.
If you read my article about USB carefully, it should not be unfamiliar to ohci this thing, in the USB series of articles, with a lot of space to introduce the OHCI, This is because OHCI this USB1.1 controller in use than UHCI to be common, and now the only USB2.0 specification EHCI and OHCI compatible, that is OHCI drive can drive EHCI, but performance does not come out. We look back at the above two drivers, the first driver file filename is: Aspiohci.sys, this time I specifically OHCI this four letter capital to emphasize, this shows that this driver is a driver for OHC, then perhaps we have to ask, the front of the ASPI what is the meaning of it? It does make a lot of sense, this article will briefly introduce this ASPI.
ASPI is the abbreviation of Advanced SCSI programming interface, may be unified translation called: High-level SCSI programming interface, SCSI the word should not be unfamiliar, in addition to the computer industry is often encountered outside, in my USB series of articles also mentioned repeatedly, First, in the USB series three: Read more from your USB drive, it is mentioned that if the interface class field of the USB device interface descriptor is 8, this is a mass Storage Device, and if the Sub class field is 6, This mass Storage device executes the SCSI command, in fact, the USB stick in my hand is the SCSI command, in this blog post, we even give the SCSI two important specifications of the download, SPC-3 and SBC-2, in the back of the blog post regardless of the read sector, Write the sector, or read the USB flash drive capacity, check the device ready, and so on, are actually using the SCSI command structure (I think this is a serious reader of the USB series of articles should have a good experience), then now there is this ASPI, is not the use of this interface can also complete the drive of U disk? Sure, and it will look easier than DOSUSB.
In the next 3 articles (which could be 4), you plan to complete the introduction and testing of ASPI in 2 articles and complete a ASPI-based USB drive driver in the 3rd article.
First, we give the ASPI for DOS specification download (this specification has been hard to find, but ASPI for Win32 is easy to find):
Http://blog.hengch.com/specification/aspi_for_dos.pdf
Second, all of our articles will use the following ASPI driver to accomplish the task:
Aspiohci.sys Download: Http://blog.hengch.com/software/aspiohci.sys
Please load this driver in Config.sys, otherwise we will not be able to run the program later.
This driver will add a character device called "scsimgr$" to the DOS device driver chain, and before invoking the function of ASPI, it needs to find its entry address first and then call it via a remote call to far. on page 4th of ASPI for DOS, there is a program that shows you how to get the ASPI entry address, and the method to call ASPI, and note that you need to fill out a SRB (SCSI Request Block) table before calling ASPI. And to first put the segment address and offset address of this table into the stack, and then call ASPI, which is why the call ASPI after the sp+4 reason, because the call before the press into the two words of the content.
Call ASPI,SRB This thing is very important, must carefully understand the specification of the content, because he is variable length, different commands, field meaning is not the same, we will combine the following demo program as far as possible to do a description.
Demo Program: Testing ASPI Commands
Http://blog.hengch.com/source/aspitest.zip
This program mainly tests ASPI's commands, and in ASPI for DOS, ASPI provides 7 commands, namely:
Command code Description
------------ --------------------------- ------------
00 Host Adapter Inquiry Command
01 Get Device Type Command
02 Execute SCSI I/o Command
03 Abort SCSI I/o Command
04 Reset SCSI Device Command
05 Set Host Adapter Parameters Command
06 Get Disk Drive information Command
We wrote this program to test 4 of these commands, command code is 00, 01, 06, and 04,02 commands we will test in the next article, 05 command We do not use, 03 command to test some of the difficulty.
Below we combine the source program to do a simple explanation.
The Public.mac file defines 4 macros, namely: Pusha, Popa, Printstr, Getch, and Callaspi, in the source program if you see these four macros can go to Public.mac to see the source code.
The SRB (SCSI Request Block) in the ASPI is defined in the Aspi.inc, when it is seen in the source program such as SRB.SRB ... When such a variable, you can go to this file to find out what is the definition of this file, you need to combine ASPI for DOS document, otherwise unintelligible.
The key part of course in the Aspitest.asm, the mainstream section has more detailed comments, but some places also explain.
In my environment, the following results are displayed after running the Aspitest program:
ASPI Test Program v1.xx. Open SCSIMRG Success! ASPI entry:0786: 6a5c Show INQUIRY result Command Status: onRequest signature:55aa Extended buffer length:0002Number of Host Adapter: onHost Adapter SCSI ID: -SCSI Manager id:ohci10 USB ASPI Host Adapter identifier:supported Extensions:0002Show Device Type Host Adapter Number:xxTarget ID:xxCommand Status: onPeripheral Device Type:xxShow Disk Drive information Command status: onDrive Flag:xxInt 13h Drive:xxPreferred Head Translation:xxPreferred Sector Translation:xxShow Reset Result Command Status:xx
1. After inquiry command, command Status = 01 Indicates the execution of commands;
Request Signature becomes 55aah (pre-call 0aa55h) description supports some extension request mechanisms (Extended request mechanism), specifically support those to see Supported extensions fields, In this case 0002h, from the ASPI for DOS documentation, this indicates support for the remaining byte-length reporting function, that is, when we need ASPI to transmit data to us, we send the request, such as set 10 bytes, when the transmission is complete if only 8 bytes transmitted, Then the remaining 2 bytes it will be reported to you, in the execution of this command we can also see this function, we can see the source program, before calling ASPI Execute Inquiry command, we put extended Buffer length This field is set to 4, required to transmit 4 bytes to us, The result is only 2 bytes passed back (that is, a word in the Supported extensions field), so after the command is executed, the Extended Buffer length field becomes 2, which can be seen in the result display;
Number of host Adapter refers to the amount of host Adapter, in this case 1, indicating that only if the host Adapter is valid for 0, the other is invalid;
The Host Adapter SCSI ID actually returns the value of the maximum available SCSI ID, which is now 7, and does not mean that 0-7 has 8 SCSI devices available, and the specific one that is valid needs to be judged below.
2, when executing the Get Device type command, we made a loop to make a scan of all possible SCSI devices, according to the documentation, when command status returns 82H, the SCSI device is not installed, only when we scan to a legitimate SCSI device, We only show the device Type of this equipment, in my environment, the scan results show that only if the host Adapter Number=0,scsi id=0 is the device valid, the rest is invalid;
Our device type=00, check SPC-3 (this document was introduced in previous articles, there are download links), this is a direct access block device.
3, reset This command when I do the test, command status returned 0, the description has not been completed, according to the document, wait a few hours after the command status should be able to become 1, but the actual situation is not, which may be related to the single-task characteristics of DOS, But it is also possible that the reset command has actually been completed, but the state cannot be returned, in short, be careful when using this command, especially not wait for the state, if the reader in the use of this command is different from my hope to tell me, e-mail address: [email protected]
The next article on ASPI will be dedicated to testing the implementation of SCSI commands to read and write sector operations on the USB drive.
USB Series Seven: ASPI Introduction and command testing