Page 1 of 1

ATA Controllers detection

Posted: Wed Sep 30, 2009 4:10 am
by AlfaOmega08
On the wiki I read that one of the ways to check wheter a controller exists or not is to write a value to two of the ports 0x1F2-0x1F5 and 0x172-0x175 and to read the values again and check if they're equal.
This method works on Bochs, Qemu and VMWare. But doesn't on VirtualBox and on (my) real hardware.

Code: Select all

int ata_check_controller(word port) {
	byte data;

	outportb(port + 2, 0xBE);
	outportb(port + 3, 0xEF);
	if ((inportb(port + 2 != 0xBE) || (inportb(port + 2) != 0xEF)) {
		printf("ATAcontroller at 0x%04x\n", port);
		return -ENODEV;
	}
	return 0;
}
On my motherboard I've 6 SATA ports (ASUS Rampage II Extreme), but 0 controllers are detected... How's it possible? I would need at least 3 controllers.
How will I detect other controllers than the primary and secondary (do I need a PIIX driver... whatever it is)? And how will I fix that code?

Re: ATA Controllers detection

Posted: Wed Sep 30, 2009 5:05 am
by ~
Here you have something brief about SATA:

http://forum.osdev.org/viewtopic.php?f=1&t=20886

Maybe you could check the specifications and eventually put some sample code. I think that there are links to them in the wiki or searching with Google.


I have very well managed to detect standard ATA/ATAPI devices attached, you can read about the methods used here along with source code (watch mainly for the last posts which actually solve the issue):

http://forum.osdev.org/viewtopic.php?f=1&t=20690

Re: ATA Controllers detection

Posted: Thu Oct 01, 2009 5:40 am
by AlfaOmega08
I found ADVDRVR on ata-atapi.com, and now HD and CD detection works on any emulator. I didn't try VPC however. It still doesn't on my PC. I have a SATA HD and a IDE DVD drive. I expected at least the DVD drive to be detected. However I found in lspci:

Code: Select all

05:00.0 SATA controller: JMicron Technologies, Inc. JMicron 20360/20363 AHCI Controller (rev 03)
05:00.1 IDE interface: JMicron Technologies, Inc. JMicron 20360/20363 AHCI Controller (rev 03)
Do I need driver for those devices?

Re: ATA Controllers detection

Posted: Thu Oct 01, 2009 9:34 am
by Brynet-Inc
OpenBSD has a special driver for a few (..older?) JMicron SATA/PATA host controllers, it acts as some sort of pass through device for pciide/ahci drivers.

SATA controllers should offer PCI IDE compatibility.. but this one might only support AHCI (Which is good, you'll get things like NCQ and device hot plugging).

Good luck.

EDIT: Try looking in your BIOS for a setting related to your SATA controller, perhaps you can force it into PCI IDE mode.