Can't find SATA controller.

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.
glauxosdev
Member
Member
Posts: 119
Joined: Tue Jan 20, 2015 9:01 am
Libera.chat IRC: glauxosdever

Re: Can't find SATA controller.

Post by glauxosdev »

Hi,
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:

Code: Select all

	;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?

Regards,
glauxosdev
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Can't find SATA controller.

Post by Brendan »

Hi,
glauxosdev wrote:
That's not even possible with EHCI.
My code is based on TatOS, and I found this snippet from usb/initehci.s:

Code: Select all

	;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.
glauxosdev
Member
Member
Posts: 119
Joined: Tue Jan 20, 2015 9:01 am
Libera.chat IRC: glauxosdever

Re: Can't find SATA controller.

Post by glauxosdev »

Hi,

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?

Regards,
glauxosdev
User avatar
iansjack
Member
Member
Posts: 4707
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Can't find SATA controller.

Post by iansjack »

glauxosdev
Member
Member
Posts: 119
Joined: Tue Jan 20, 2015 9:01 am
Libera.chat IRC: glauxosdever

Re: Can't find SATA controller.

Post by glauxosdev »

Hi,

Sorry, did you read my first sentence? I said that the factual accuracy of this article is disputed.

Regards,
glauxosdev
User avatar
iansjack
Member
Member
Posts: 4707
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Can't find SATA controller.

Post by iansjack »

For goodness sake! Don't you have enough independence of thought to read the article, try the code, read the commentary as to why it is disputed?
glauxosdev
Member
Member
Posts: 119
Joined: Tue Jan 20, 2015 9:01 am
Libera.chat IRC: glauxosdever

Re: Can't find SATA controller.

Post by glauxosdev »

Hi,

I have read the commentary, of course, but I don't know if there are also other things that are not correct.

Regards,
glauxosdev

Edit: I will try again after I have taken a break. By the way I have found one IDE controller.
glauxosdev
Member
Member
Posts: 119
Joined: Tue Jan 20, 2015 9:01 am
Libera.chat IRC: glauxosdever

Re: Can't find SATA controller.

Post by glauxosdev »

Hi,

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?

Regards,
glauxosdev
User avatar
SpyderTL
Member
Member
Posts: 1074
Joined: Sun Sep 19, 2010 10:05 pm

Re: Can't find SATA controller.

Post by SpyderTL »

You've got it, pretty much.

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
Post Reply