OHCI: relink root hub port index to existing device ID

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.
Post Reply
sounds
Member
Member
Posts: 121
Joined: Sat Feb 04, 2012 5:03 pm

OHCI: relink root hub port index to existing device ID

Post by sounds »

Playing around with my OHCI driver, and had a fun idea pop into my head

What if instead of resetting the host controller, it were possible to disable the control list and periodic list, then move all the data to memory I control, leaving the devices as set up by the bios?

I wouldn't need to peek at any BIOS tables, except for one thing. If a device is disconnected from the root hub, I'll only get the port index where it was. Leaving off downstream hubs for now, as they are a simpler problem.

The BIOS of course knew the mapping from that port index to the device ID. How can I find that same mapping later? Ideally without having to do a port reset, because it's already been done by the bios and it takes for... ever... by which I mean about 1 second.

All of this assumes the bios keeps the OHCI controller operational for whatever reason, SMM emulating a PS/2 keyboard, handling disk read requests from real mode int 13h, etc.

I can't think of a way to do it. Looking for ideas.
sounds
Member
Member
Posts: 121
Joined: Sat Feb 04, 2012 5:03 pm

Re: OHCI: relink root hub port index to existing device ID

Post by sounds »

One I came up with is to assume all USB devices that came from the BIOS have disconnected, and then do a proof by contradiction.

Send some benign request to each device, and if they respond, they are still connected.
User avatar
BenLunt
Member
Member
Posts: 957
Joined: Sat Nov 22, 2014 6:33 pm
Location: USA
Contact:

Re: OHCI: relink root hub port index to existing device ID

Post by BenLunt »

Hi,

In theory this would work.

However, for an example of why you shouldn't, what if the BIOS set up a thumb drive as a floppy drive because the first 2880 sectors resembled a floppy disk? Without changing a few things, you will still see it as a floppy disk, possibly the BIOS returned 2879 as the last accessible sector. Could still work, but don't you want access to the whole drive?

Second, and this one is a better reason to not, what if you have a game mouse with more than three buttons and two axis? The BIOS will most likely show a two/possible three button mouse with only X and Y axis. It will have already set the mouse to send this type of packet. You will need to reset the mouse to be able to use all of the buttons and the Z axis as well.

Again, in theory, your idea would work, but it won't give you full access to all of the device(s). However, thinking outside the box is a good thing, yes?

Ben
sounds
Member
Member
Posts: 121
Joined: Sat Feb 04, 2012 5:03 pm

Re: OHCI: relink root hub port index to existing device ID

Post by sounds »

I was thinking more of what if the BIOS entered SMM in the middle of my moving the data structures to a new location. I'll have to think carefully about it. I haven't found a BIOS that left its OHCI in the Operational mode anyway.
Post Reply