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.
Specifically; find all devices on the PCI bus that the OS supports (e.g. IDE controllers, USB controllers, etc) and load drivers for them, then use those drivers to find whatever devices are connected to them (e.g. disk drives, USB flash, USB sound card, etc) and load drivers for them; then use those drivers to find whatever is connected to those devices (e.g. use the USB sound card driver to determine if there's speakers/microphones connected to the USB sound card); and so on until there's nothing left to find.
Thank you, I will finally go this way.
That's not even possible with EHCI.
My code is based on TatOS, and I found this snippet from usb/initehci.s:
;CONFIGFLAG
;00=port routing to classic controller
;01=port routing to EHCI controller
;note on disconnect all ports revert to ehci
STDCALL usbinitstr24,putscroll
mov esi,[EHCIOPERBASE]
mov eax,[esi+40h]
or eax,1 ;set bit0, all ports belong to EHCI
mov [esi+40h],eax
;CONFIGFLAG
;00=port routing to classic controller
;01=port routing to EHCI controller
;note on disconnect all ports revert to ehci
STDCALL usbinitstr24,putscroll
mov esi,[EHCIOPERBASE]
mov eax,[esi+40h]
or eax,1 ;set bit0, all ports belong to EHCI
mov [esi+40h],eax
So have I misunderstood something?
Their "00=port routing to classic controller" is what I was talking about when I said "routed to the companion controller".
Basically, when they invented EHCI they couldn't be bothered with low speed devices, so they just glued a OHCI or UHCI chip on it and let you switch the port from one to the other. As a side-effect, it means that if you've got an old OS that doesn't support EHCI (but does support OHCI and UHCI) the BIOS can just configure it so everything goes to the companion controller and the USB devices and USB ports still work (any high speed devices would just end up using low speed instead).
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
I tried to read the IDE wiki page, but the factual accuracy of this article is disputed, as it says. I have also taken a look at ATAPI, ATA PIO mode and some others articles.
For a start I think my code should learn to detect my hard drive. What should I read? What is your advice?
As far as I understand it after I have found the IDE controller I have to detect devices connected to it. I don't plan to support CD disks, or more than one hard disk, so I have to find the hard disk and select it. Then I have to get its capabilities and only now read sectors from it? Or did I mess this up?
You can just assume that there is a hard drive on channel 0, for now. And you can assume that it is large enough to hold your OS and anything else you'll need for quite a while.
However, at some point, you'll need to be able to enumerate the connected devices and detect their type, because the code to read from and write to a hard drive is significantly different from a CD-ROM.
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott