MrLolthe1st wrote:
(sorry for code style and comments: i'm debbuging it 3 days without a sleep)
https://github.com/MrLolthe1st/butterflyos/blob/master/sources/usb/ehci.cppI quickly looked over your code and nothing jumped out at me.
I suggest that you create a dump function wrapped around some #define's so that you can "turn on" debug mode with a simple re-build.
The following is the output of mine for the transaction to get the first 8 bytes of the device's descriptor. This dump happens for every transaction when in DEBUG mode. i.e.: For every transfer, descriptor request, Control request, Bulk request, whatever, this sequence gets printed to the log file.
Code:
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
EHCI Dump Core: 0xF0405000
EHC_CAPS_CapLength: 0x01000020
EHC_CAPS_HCSParams: 0x0000000C
EHC_CAPS_HCCParams: 0x00000084
EHC_CAPS_HCSPPortRoute: 0x00000000
EHC_OPS_USBCommand: 0x00080031
EHC_OPS_USBStatus: 0x0000C008
EHC_OPS_USBInterrupt: 0x00000016
EHC_OPS_FrameIndex: 0x000007B0
EHC_OPS_CtrlDSSegemnt: 0x00000000
EHC_OPS_PeriodicListBase: 0x03200000
EHC_OPS_AsyncListBase: 0x043E3000
EHC_OPS_ConfigFlag: 0x00000001
EHC_OPS_PortStatus[0]: 0x00001005
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Async List vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
000: 0x043E3000
horz_ptr = 0x043E3080, typ = 1 (QH), T = 0
cur_qTD_ptr = 0x00000000
next_qTD_ptr = 0x00000000, T = 1
alt_next_qTD_ptr = 0x00000000, T = 1
001: 0x043E3080
horz_ptr = 0x043E5000, typ = 1 (QH), T = 0
cur_qTD_ptr = 0x00000000
next_qTD_ptr = 0x00000000, T = 1
alt_next_qTD_ptr = 0x00000000, T = 1
002: 0x043E5000
horz_ptr = 0x043E3000, typ = 1 (QH), T = 0
cur_qTD_ptr = 0x043E5080
next_qTD_ptr = 0x00000000, T = 1
alt_next_qTD_ptr = 0x00000000, T = 1
Async List ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>>>> Before >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
USB_CONTROL_IN:
> Queue: Links to: 0x043E3000 (0)
> Control = 0, mps = 64, H = 0, eps = 2 (hs), endpt = 0x00, addr = 0
> Mult = 1, port = 0, Hub Addr = 0
> qTD #0 (0x043E5080)
> Links to: 0x043E50C0 (0)
> (alt) Links to: 0x00000000 (1)
> toggle: 1
> count: 0
> ioc: 0
> cpage: 0
> cerr: 3
> pid: 2 (setup)
> status: 0x00
> buffer: 0x047A0500
> qTD #1 (0x043E50C0)
> Links to: 0x00000000 (1)
> (alt) Links to: 0x00000000 (1)
> toggle: 0
> count: 0
> ioc: 0
> cpage: 0
> cerr: 3
> pid: 1 (in)
> status: 0x00
> buffer: 0x03A3009F
<<<<< After <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
USB_CONTROL_IN:
< Queue: Links to: 0x043E3000 (0)
< Control = 0, mps = 64, H = 0, eps = 2 (hs), endpt = 0x00, addr = 0
< Mult = 1, port = 0, Hub Addr = 0
< qTD #0 (0x043E5080)
< Links to: 0x043E50C0 (0)
< (alt) Links to: 0x00000000 (1)
< toggle: 1
< count: 0
< ioc: 0
< cpage: 0
< cerr: 3
< pid: 2 (setup)
< status: 0x00
< buffer: 0x047A0500
< qTD #1 (0x043E50C0)
< Links to: 0x00000000 (1)
< (alt) Links to: 0x00000000 (1)
< toggle: 0
< count: 0
< ioc: 0
< cpage: 0
< cerr: 3
< pid: 1 (in)
< status: 0x00
< buffer: 0x03A3009F
>>>>> Before >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
USB_CONTROL_IN:
> Queue: Links to: 0x00000000 (0)
> Control = 0, mps = 64, H = 0, eps = 2 (hs), endpt = 0x00, addr = 0
> Mult = 1, port = 0, Hub Addr = 0
> qTD #0 (0x043E5080)
> Links to: 0x00000000 (1)
> (alt) Links to: 0x00000000 (1)
> toggle: 1
> count: 0
> ioc: 0
> cpage: 0
> cerr: 3
> pid: 0 (out)
> status: 0x80
> buffer: 0x00000000
<<<<< After <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
USB_CONTROL_IN:
< Queue: Links to: 0x043E3000 (0)
< Control = 0, mps = 64, H = 0, eps = 2 (hs), endpt = 0x00, addr = 0
< Mult = 1, port = 0, Hub Addr = 0
< qTD #0 (0x043E5080)
< Links to: 0x00000000 (1)
< (alt) Links to: 0x00000000 (1)
< toggle: 1
< count: 0
< ioc: 0
< cpage: 0
< cerr: 3
< pid: 0 (out)
< status: 0x00
< buffer: 0x00000000
First eight bytes of descriptor
03A3009F 12 01 00 02 00 00 00 40 .......@
The "Before" is before I send it to the controller. i.e.: Just before it is inserted into the Queue. The "After" is after the interrupt has either fired, or I receive a timeout.
This shows everything that is sent to the controller and allows me to see what gets changed, if anything, as well as if the interrupt fires, etc....
My bug was found in one of the Async listings:
Code:
...
xxx: 0x0xxxxxxxx
horz_ptr = 0x0xxxxxxxx, typ = 0 (iTD), T = 0 <------- This showed that I was indicating an iTD when it should have been a QH.
cur_qTD_ptr = 0x00000000
next_qTD_ptr = 0x00000000, T = 1
alt_next_qTD_ptr = 0x00000000, T = 1
...
I suggest that you do something like this and I guarantee that you will find the error.
Ben
-
http://www.fysnet.net/the_universal_serial_bus.htm