⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dosusb.htm

📁 DOS下的USB驱动源码,包括UHCI
💻 HTM
📖 第 1 页 / 共 3 页
字号:
The OHCI controller returns different completion codes than the UHCI<br>
controller. To simplify driver development, the DOSUSB driver translates the<br>
OHCI completion codes to UHCI status codes. However, in the dosusb.log file<br>
the OHCI codes are specified.<br>
OHCI completion code 1 is translated to 44h, 2 to 42h, 3 to 44h, 4 to 40h,<br>
5,6 and 7 to 44h, 8 to 50h, 9 to 00h, 12 to 20h, 13 to A0h and 14 to 88h.</font></p>
<p><font face="Arial"><br>
</font><font face="Arial"><b>transaction_flags</b></font></p>
<p><font face="Arial">this element is currently not used</font></p>
<p><font face="Arial"><br>
</font><font face="Arial"><b>buffer_off / buffer_seg</b></font></p>
<p><font face="Arial">enter a pointer to a buffer here, where either the data 
to be<br>
send by an out transaction or the data to be returned by an in or<br>
control transaction shall be placed</font></p>
<p><font face="Arial"><br>
</font><font face="Arial"><b>buffer_length</b></font></p>
<p><font face="Arial">specify either the length of the out buffer or the expected<br>
length of the data to be returned by an in or control transaction<br>
here.<br>
If you set buffer_length greater than actual_length<br>
(maximum length) DosUSB will schedule the number of in<br>
transactions required to retrieve the amount of data specified in<br>
buffer_length. DosUSB accepts a buffer_length up to 1024 bytes.<br>
In the current version I recommend to specify up to the actual_length.</font></p>
<p><font face="Arial"><br>
</font><font face="Arial"><b>actual_length</b></font></p>
<p><font face="Arial">to schedule a transaction, enter the maximum length supported 
by<br>
the addressed endpoint here. After the transaction is completed<br>
this element will have the number of bytes returned. </font></p>
<p><font face="Arial">This number is given as returned by the UHCI controller, 
so 7FFh<br>
means zero bytes, 0 means one byte, 1 means two bytes and so on.<br>
The maximum length, however, needs to be entered as 8 for 8<br>
bytes, which will be returned as the number 7.</font></p>
<p><font face="Arial">For an OHCI controller, the number is the real length 
in bytes.</font></p>
<p><font face="Arial"><br>
</font><font face="Arial"><b>setup_buffer_off / setup_buffer_seg &nbsp;</b></font></p>
<p><font face="Arial">for control transactions, enter a pointer to the request 
here.<br>
This can e.g. be a device descriptor request</font></p>
<p><font face="Arial"><br>
</font><font face="Arial"><b>nr_of_packets </b></font></p>
<p><font face="Arial">if this element has a value greater zero, DosUSB will 
schedule a<br>
transaction for isochronous traffic.<br>
Isochronous support is not yet implemented for OHCI!</font></p>
<p><font face="Arial"><br>
</font><font face="Arial"><b>error_count</b></font></p>
<p><font face="Arial">this instructs the UHCI controller to retry unsuccessful 
transactions.<br>
Valid values are: 0 - default (3 retries), 1 - 1 retry, 2 - 2 retries,<br>
3 - 3 retries. For OHCI this is set to three and cannot be modified.<br>
DosUSB will not have the host controller retry if a NAK is received.<br>
These transactions are terminated with 88h in the status element and have<br>
to be retried by the application.</font></p>
<p><font face="Arial">All other elements are currently unused. They are provided 
so a<br>
device driver that is written for the current version of DosUSB<br>
will run without changes with future versions too.</font></p>
<p><font face="Arial"><br>
</font><font face="Arial" size="4"><b>3.2. Scheduling control transactions</b></font></p>
<p><font face="Arial">In the case of a control transaction DosUSB will return 
the<br>
input in the buffer pointed to buffer_seg and buffer_off, if buffer_seg<br>
and buffer_off are not zero and buffer_length is greater than zero.</font></p>
<p><font face="Arial">For a control transaction such as a device descriptor 
request<br>
DosUSB will return the device descriptor in buffer and<br>
acknowledge the receipt to the device with a zero out<br>
transaction. In this case the actual_length field has to be equal<br>
to the maximum packet length and buffer_length has to specify the<br>
requested length of the descriptor which shall be returned.</font></p>
<p><font face="Arial">If buffer_length is set to zero, DosUSB will do an in<br>
transaction but no out transaction. So for a set configuration<br>
transaction you have to set buffer_length to zero since this<br>
transaction does not return data from the device and therefore<br>
requires no out transaction.</font></p>
<p><font face="Arial">If you set buffer_seg and buffer_off to zero, DosUSB will 
just<br>
do an control transaction. The driver calling DosUSB can then<br>
request the in and out transactions required following the control<br>
transaction.</font></p>
<p><font face="Arial"><br>
</font><font face="Arial"><b>3.3. Calling DosUSB to execute the URB</b></font></p>
<p><font face="Arial">To have DosUSB execute the transaction defined by the 
URB, you<br>
have to place a pointer to the URB in the DS:DX registers and<br>
call interrupt 65h.<br>
The DS register has to contain the segment part of the pointer<br>
and the DX register the offset part of it.</font></p>
<p><font face="Arial">With the /I commandline parameter you can specify a different<br>
interrupt to be used by DosUSB. For example /I64 will ask<br>
DosUSB to use interrupt 64h. Use the range 60h-67h.</font></p>
<p><font face="Arial">Using the URB you can only schedule a transaction to a 
single<br>
device specified by the device address. So you can send and<br>
receive data from a mass storage device or send data to a<br>
printer. If you have a camera, which sends a constant stream of<br>
data or a mouse, DosUSB will not be able to retrieve that data<br>
while it is executing a transaction to e.g. a printer.</font></p>
<p><font face="Arial"><br>
</font><font face="Arial" size="4"><b>4. Commands to DosUSB</b></font></p>
<p><font face="Arial">If you enter FFh as the transaction type, you can specify 
in the<br>
ax register the following commands:</font></p>
<p><font face="Arial">ax=1: If dev_add is zero, DosUSB will reset all devices 
and enumerate<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;them again. It will not enumerate new devices 
and thus all devices<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;keep their address. If dev_add is greater 
than zero, DosUSB will<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;just reset and enumerate the device with 
that address. It will not<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;output anything to screen in that case. 
Instead, if the enumeration<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;was successful DosUSB will return a 0 or 
30h, if it failed, it will<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return a 1 or 31h in the transaction_type 
field of the urb.<br>
ax=2: enables debug output &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
ax=3: disables debug output<br>
ax=4: displays the URB received from a device driver. You also have to<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;specify a valid device address in the URB 
here.<br>
ax=5: set data toggle to zero, e.g. after a clear_feature(endpoint_halt)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;command. You also have to specify the device 
address and&nbsp;endpoint<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;in the URB here.<br>
ax=6: allows to check if DosUSB is installed. Will return &quot;G&quot; or 47h 
in<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;the transaction type field of the URB. See 
the icheck.bas sample.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Check if the interrupt is initialized first 
before using this.<br>
ax=7: allows to check whether a UHCI or OHCI controller is installed.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Will return in the transaction type field 
of the URB a &quot;U&quot; or 55h<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if UHCI and an &quot;O&quot; or 4Fh if OHCI 
has been determined by DosUSB.<br>
ax=8: DosUSB will check all ports for devices connected and reset and<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;enumerate all devices it finds. If there 
are any additional devices<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;or devices have been removed, all devices 
may receive a new address.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The device on port zero of the first controller 
will get address number<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;one and so forth. If this device has not 
changed, it will keep its<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;address. However, if there has been no device 
on that port before, all<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;devices will get a new address.<br>
ax=9: allows to determine the type of USB controller installed. Will return<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;the PCI vendor ID in the field next_urb_off 
of the URB and the PCI<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;device ID in the field next_urb_seg.<br>
&nbsp;</font></p>
<p><font face="Arial" size="4"><b>5. Commandline options</b></font></p>
<p><font face="Arial">DosUSB currently supports the following command line options:<br>
/D write debug output to dosusb.log file<br>
/I change interrupt to call DosUSB URB<br>
/X exclude controller</font></p>
<p><font face="Arial">The /X option allows to exclude a USB controller, which 
will not be used by<br>
DosUSB. E.g. /XEC00 will exclude the controller at I/O address EC00 hex.<br>
If you want a USB mouse or keyboard to be controlled by the BIOS while using<br>
DosUSB to communicate with another device at a different controller, you<br>
can use this command to exclude the controller where the mouse and keyboard<br>
are connected.<br>
&nbsp;</font></p>
<p><font face="Arial" size="4"><b>6. Debug mode</b></font></p>
<p><font face="Arial">DosUSB offers a trace of the transactions performed via 
the UHCI<br>
or OHCI interface. This allows to monitor whether the scheduled<br>
transactions where successful.</font></p>
<p><font face="Arial">If DosUSB is called with the /D command line, the debug 
output<br>
is written into the dosusb.log file while DosUSB is running. </font></p>
<p><font face="Arial">Using the transaction descriptor FF hex and the command 
02 you<br>
can turn on the trace any time and using the command 03 you can<br>
turn it off again. In this case, the debug output is written to<br>
the screen.<br>
After each transaction the trace stops and asks for a keypress.<br>
If you enter &quot;c&quot; here, the screen will be cleared.</font></p>
<p><font face="Arial">For each UHCI transaction the trace contains the following 
lines:</font></p>
<p><font face="Arial">a) the bytes which make up the transaction descriptor 
as it is<br>
returned by the UHCI interface. There are two differences of this<br>
transaction descriptor to the one written to the UHCI interface:<br>
the status byte has been updated by the controller and DosUHCI<br>
puts the value 500h into the actual length field to check if it<br>
has been updated by the controller. Following the transaction<br>
descriptor the transaction type is given (IN, OUT or CTRL), the<br>
bits set (LS=low speed, SPD=short packet detect, IOS=isochronous<br>
traffic , IOC=interupt on complete) and the error limit<br>
specified, usually three errors.</font></p>
<p><font face="Arial">Above the transaction descriptor there are numbers which 
shall<br>
allow to locate the bytes in the descriptor or AL for actual<br>
length, ST for status, PI for PID and AD for device address.</font></p>
<p><font face="Arial">b) Then the result of the transaction(s) is displayed.<br>
Following this there are specified: the device address, the<br>
endpoint, the data toggle bit and the maximum packet length.</font></p>
<p><font face="Arial">If buffer_length is greater than actual_length (maximum 
length),<br>
there will be buffer_length divided by actual_length number of<br>
transactions. These will be displayed beneath each other here.</font></p>
<p><font face="Arial">c) The final line shows the bytes in hexadecimal of the 
data sent<br>
or returned by this transaction.</font></p>
<p><font face="Arial">For control transactions, the request is also displayed 
at the<br>
beginning of the transaction.</font></p>
<p><font face="Arial">For OHCI transactions the trace is set up differently.</font></p>
<p><font face="Arial">For control transactions, the request is also displayed 
at the<br>
beginning of the transaction.</font></p>
<p><font face="Arial">An OHCI transaction is set up by an endpoint descriptor 
(ED:) and an<br>
transaction descriptor (TD:). The trace will list both after the transaction.</font></p>
<p><font face="Arial">It will also show the TC field of the endpoint descriptor, 
the value in<br>
the toggle field of the transaction descriptor and the completion code in<br>
numeric and text form followed by the number of bytes transfered.</font></p>
<p><font face="Arial"><br>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -