Different transfer type using uhci

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
BenLunt
Member
Member
Posts: 941
Joined: Sat Nov 22, 2014 6:33 pm
Location: USA
Contact:

Re: Different transfer type using uhci

Post by BenLunt »

Bonfra wrote:Sorry i didn't specify, the OS only knows how to read from sata ahci drives for the moment.
anyway the USB thing should happen before it tries to load the init process (actually even before the successfully booted message), so something more should appear if a controller with something attached is found
That makes sense. Okay, I will have a look and see what I can find.
User avatar
Bonfra
Member
Member
Posts: 270
Joined: Wed Feb 19, 2020 1:08 pm
Libera.chat IRC: Bonfra
Location: Italy

Re: Different transfer type using uhci

Post by Bonfra »

Thanks a lot! I really appreciate what you are doing for me :)
Just don't get too busy with this rn, it still is Christmas XP
Regards, Bonfra.
User avatar
BenLunt
Member
Member
Posts: 941
Joined: Sat Nov 22, 2014 6:33 pm
Location: USA
Contact:

Re: Different transfer type using uhci

Post by BenLunt »

Bonfra wrote:Thanks a lot! I really appreciate what you are doing for me :)
Just don't get too busy with this rn, it still is Christmas XP
Indeed, and a Merry Christmas to you as well.

I spent a few minutes and was able to run your image through my USB Test Suite after finding a few errors.

1) The read at:
https://github.com/Bonfra04/BonsOS/blob ... uhci.c#L51
is trying to read a WORD when the register is a BYTE. QEMU seems to allow it, Bochs does not. Your UHCI code returned 'UHCI not detected' and did nothing more.

2) When setting the interface, you need to use USB_REQUEST_RECP_INTERFACE as well
https://github.com/Bonfra04/BonsOS/blob ... uest.c#L75
(For now, you can ignore setting the interface. When you find a device that supports more than one interface (BBB and UASP for example), you will then need to set the interface)

3) Unlike IN packets, when sending OUT packets (Bulk or otherwise), you should send the count of bytes being sent, not the max count.
https://github.com/Bonfra04/BonsOS/blob ... sfer.c#L80
All but that last packet should have a count of MAX_PACKET, then the last packet has the remaining. Since your first try is a CBW, it is only one packet with 31 bytes. You currently tell it you are sending 64. It will STALL.

Your code should be something like:

Code: Select all

  packets[pid].maxlen = (size > MAX_PACKET) ? MAX_PACKET : size;
  size -= MAX_PACKET;
of course paying attention to negative numbers in 'size' and setting MAX_PACKET to the size returned in the endpoint descriptor for this device.

After modifying my test suite to allow these errors, I got your code to retrieve 36 bytes of Inquiry data (though I did not verify that it was correct data) and retrieve a 13-byte CSW.

Again, Merry Christmas to you and everyone here.
Ben
User avatar
Bonfra
Member
Member
Posts: 270
Joined: Wed Feb 19, 2020 1:08 pm
Libera.chat IRC: Bonfra
Location: Italy

Re: Different transfer type using uhci

Post by Bonfra »

It works awesomely! The SCSI output is correct and I can successfully read from the drive. Thanks a lot!
Now I'm having some troubles making this work on real hw, but it's a problem for another day, I'm happy with these results. Thanks again and merry Christmas :)
Regards, Bonfra.
Post Reply