Usb troubles with MSD (scsi reads)
Posted: Fri Nov 17, 2017 2:16 am
My problem is that I'm having some issues with bulk transfers (not in general, but specific data transfers when using the scsi protocol). I send the SCSI_READ_10 command to the MSD device, and I can see from the bochs logs that it correctly recognizes the command:
We then move on, and queue up some bulk-in td's for 512 bytes in total + 13 bytes for the CSW. So that is 9 td's in total. This is where it gets a little bit iffy, as I can see the behaviour is that bochs 'defer' my tds, I then inspected the source code of bochs and found that it does this to simulate the seek delay of a disk drive. It fires an interrupt in spite of not having transfered any data yet. I don't do anything, and my Td's are untouched (still active, ioc bit still set), so I leave them there for now. I can then see it keeps trying to handle my td's untill data is ready:
Now here comes my issue, it seems that now that the data is ready, it then tries to handle my Td's again, but it still does not transfer any data untill it encounters my CSW td, if you notice the <r_actlen = 0x000D r_maxlen = 0x000D>, this means the td is actually being executed. Why does it never execute my data td's asking for the 512 bytes of data? But only handles my CSW td?
Code: Select all
00197650000d[UHCI ] Frame: 0485 (0x01E5)
00197650000d[UHCI ] QH003:TD found at address: 0x014E57A0
00197650000d[UHCI ] 00000001 19800000 03C102E1 01693FD8
00197650000d[USBMSD] packet hexdump (31 bytes)
00197650000d[USBMSD] 55 53 42 43 28 1E 0B B0 00 02 00 00 80 00 0A 28
00197650000d[USBMSD] 00 00 00 00 01 00 00 01 00 00 00 00 00 00 00
00197650000d[USBMSD] command on LUN 0
00197650000d[USBMSD] command tag 0xB00B1E28 flags 00000080 len 10 data 512
00197650000d[SCSIHD] command: lun=0 tag=0xb00b1e28 data=0x28
00197650000d[SCSIHD] Read (sector 1, count 1)
00197650000d[SCSIHD] read sector_count=1
00197650000d[UHCI ] r_actlen = 0x001F r_maxlen = 0x001F
00197650000d[UHCI ] [IOC] We want it to fire here (Frame: 0485)
Code: Select all
00197700000d[UHCI ] Frame: 0486 (0x01E6)
00197700000d[UHCI ] QH004:TD found at address: 0x014E57A0
00197700000d[UHCI ] 014E57C4 38800000 07E88269 01694000
00197700000d[USBMSD] data in 64/512
00197700000d[USBMSD] deferring packet 02AE08E0
00197700000d[UHCI ] Async packet deferred
00197700000d[UHCI ] Frame: 0486 (0x01E6)
00197700000d[UHCI ] QH004:TD found at address: 0x014E57C0
00197700000d[UHCI ] 014E57E4 38800000 07E08269 01694040
00197700000d[USBMSD] data in 64/512
00197700000d[USBMSD] deferring packet 02AE0920
00197700000d[UHCI ] Async packet deferred
00197700000d[UHCI ] Frame: 0486 (0x01E6)
00197700000d[UHCI ] QH004:TD found at address: 0x014E57E0
00197700000d[UHCI ] 014E5804 38800000 07E88269 01694080
00197700000d[USBMSD] data in 64/512
00197700000d[USBMSD] deferring packet 02AE0A60
00197700000d[UHCI ] Async packet deferred
00197700000d[UHCI ] Frame: 0486 (0x01E6)
00197700000d[UHCI ] QH004:TD found at address: 0x014E5800
00197700000d[UHCI ] 014E5824 38800000 07E08269 016940C0
00197700000d[USBMSD] data in 64/512
00197700000d[USBMSD] deferring packet 02AE0AA0
00197700000d[UHCI ] Async packet deferred
00197700000d[UHCI ] Frame: 0486 (0x01E6)
00197700000d[UHCI ] QH004:TD found at address: 0x014E5820
00197700000d[UHCI ] 014E5844 38800000 07E88269 01694100
00197700000d[USBMSD] data in 64/512
00197700000d[USBMSD] deferring packet 02AE0720
00197700000d[UHCI ] Async packet deferred
00197700000d[UHCI ] Frame: 0486 (0x01E6)
00197700000d[UHCI ] QH004:TD found at address: 0x014E5840
00197700000d[UHCI ] 014E5864 38800000 07E08269 01694140
00197700000d[USBMSD] data in 64/512
00197700000d[USBMSD] deferring packet 02AE0760
00197700000d[UHCI ] Async packet deferred
00197700000d[UHCI ] Frame: 0486 (0x01E6)
00197700000d[UHCI ] QH004:TD found at address: 0x014E5860
00197700000d[UHCI ] 014E5884 38800000 07E88269 01694180
00197700000d[USBMSD] data in 64/512
00197700000d[USBMSD] deferring packet 02AE0AE0
00197700000d[UHCI ] Async packet deferred
00197700000d[UHCI ] Frame: 0486 (0x01E6)
00197700000d[UHCI ] QH004:TD found at address: 0x014E5880
00197700000d[UHCI ] 014E58A4 38800000 07E08269 016941C0
00197700000d[USBMSD] data in 64/512
00197700000d[USBMSD] deferring packet 02AE0B60
00197700000d[UHCI ] Async packet deferred
00197700000d[UHCI ] Frame: 0486 (0x01E6)
00197700000d[UHCI ] QH004:TD found at address: 0x014E58A0
00197700000d[UHCI ] 00000001 39800000 01888269 01693FC0
00197700000d[USBMSD] data in 13/512
00197700000d[USBMSD] deferring packet 02AE0BA0
00197700000d[UHCI ] Async packet deferred
00197700000d[UHCI ] [IOC] We want it to fire here (Frame: 0486)
Code: Select all
00198099950d[SCSIHD] data ready tag=0xb00b1e28 len=512
00198099950d[USBMSD] packet hexdump (13 bytes)
00198099950d[USBMSD] E9 C9 11 50 53 88 E3 C0 E3 04 24 0F 08
00198099950d[USBMSD] packet complete 02AE0BA0
00198099950d[UHCI ] Async packet completion
00198100000d[UHCI ] Frame: 0494 (0x01EE)
00198100000d[UHCI ] QH004:TD found at address: 0x014E57A0
00198100000d[UHCI ] 014E57C4 38800000 07E88269 01694000
00198100000d[UHCI ] Frame: 0494 (0x01EE)
00198100000d[UHCI ] QH004:TD found at address: 0x014E57C0
00198100000d[UHCI ] 014E57E4 38800000 07E08269 01694040
00198100000d[UHCI ] Frame: 0494 (0x01EE)
00198100000d[UHCI ] QH004:TD found at address: 0x014E57E0
00198100000d[UHCI ] 014E5804 38800000 07E88269 01694080
00198100000d[UHCI ] Frame: 0494 (0x01EE)
00198100000d[UHCI ] QH004:TD found at address: 0x014E5800
00198100000d[UHCI ] 014E5824 38800000 07E08269 016940C0
00198100000d[UHCI ] Frame: 0494 (0x01EE)
00198100000d[UHCI ] QH004:TD found at address: 0x014E5820
00198100000d[UHCI ] 014E5844 38800000 07E88269 01694100
00198100000d[UHCI ] Frame: 0494 (0x01EE)
00198100000d[UHCI ] QH004:TD found at address: 0x014E5840
00198100000d[UHCI ] 014E5864 38800000 07E08269 01694140
00198100000d[UHCI ] Frame: 0494 (0x01EE)
00198100000d[UHCI ] QH004:TD found at address: 0x014E5860
00198100000d[UHCI ] 014E5884 38800000 07E88269 01694180
00198100000d[UHCI ] Frame: 0494 (0x01EE)
00198100000d[UHCI ] QH004:TD found at address: 0x014E5880
00198100000d[UHCI ] 014E58A4 38800000 07E08269 016941C0
00198100000d[UHCI ] Frame: 0494 (0x01EE)
00198100000d[UHCI ] QH004:TD found at address: 0x014E58A0
00198100000d[UHCI ] 00000001 39800000 01888269 01693FC0
00198100000d[UHCI ] r_actlen = 0x000D r_maxlen = 0x000D
00198100000d[UHCI ] [IOC] We want it to fire here (Frame: 0494)