S
S
Semyon Prikhodko2013-06-20 18:18:45
Do it yourself
Semyon Prikhodko, 2013-06-20 18:18:45

AHCI: Problem recognizing SATA drives?

I haven't been able to write a sane drive recognition code for almost a week now. Using the guide wiki.osdev.org/AHCI , I take the following steps:
1. Find the AHCI HBA as a PCI device
2. Read it BAR5 and get the address of the controller registers
3. Check GHC.HR (hardware reset bit), it needs to be 0, otherwise controller in hung or locked state
4. For each bit set in PI (ports implemented), I check DET, IPM and SIG
This approach works in old KVM/QEMU and VirtualBox. But in Parallels Desktop 6, having GHC.HR=0 for all implemented ports DET=0 and SIG=0xFFFFFFFF, despite the fact that one disk is connected and recognized by Linux. Besides, in new KVM/QEMU, as well as on real hardware (HP Compaq 8200) GHC.HR=1, well, the same situation with ports (again, the drive is definitely installed).
It is not possible to get the controller out of GHC.HR=1 by manually setting the unit (according to the specification, it should reset to zero in a maximum of a second). The controller is in power state D0, PCI bits CMD.MSE and CMD.BME are set. So I have no idea what needs to be done here to get the controller to start.
Maybe someone had experience writing AHCI drivers, well, or is familiar with this kind of code? Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2013-06-21
@ababo

Check the status of GHC.AE.
In qemu, you can enable DEBUG_AHCI in the hw/ide/ahci.c file, which will dump everything that happens to the device to stderr.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question