Klakap wrote:
Quote:
port[1].sig = ffffffff
Signature of hard disk is 0x00000101. You are probably reading from non exiting device.
I too thought the signature was odd, but I feel like I've been over that code so many times.
If I don't try to read from the disk, here is the full startup list:
Quote:
Intel ICH9 controller found (bus=0, slot=3, func=0, abar=0xfebf1000)
HBA in legacy mode
SATA device detected:
port[1].sig = ffffffff
ipm=0, spd=0, det=3
rebasing port...DONE
SATA device detected:
port[16].sig = f0458b48
ipm=0, spd=8, det=3
rebasing port...FAILED
SATA device detected:
port[27].sig = d0014804
ipm=1, spd=8, det=1
rebasing port...FAILED
SATA device detected:
port[31].sig = e47589e8
ipm=5, spd=8, det=3
rebasing port...FAILED
As you can see, none of the other devices either have a signature of 0x101, nor do they succeed in rebasing.
My probing logic is here:
Code:
void ahci_try_setup_known_device(char *dev_name, uint64 ahci_base_mem, uint16 bus, uint16 slot, uint16 func) {
cprintf("%s controller found (bus=%d, slot=%d, func=%d, abar=0x%x)\n", dev_name, bus, slot, func, ahci_base_mem);
HBA_MEM *ptr = (HBA_MEM *)&ahci_base_mem;
cprintf(" HBA in ");
if(ptr->ghc == 0x0) {
cprintf("legacy mode\n");
}else{
cprintf("AHCI-only mode\n");
}
uint64 pi = ptr->pi;
for(int i = 0; (i != 32); i++) {
uint64 port_mask = 1 << i;
if((pi & port_mask) == 0x0) {
continue;
}
HBA_PORT *hba_port = (HBA_PORT *) &ptr->ports[i];
if(hba_port->sig != SATA_SIG_ATAPI && hba_port->sig != SATA_SIG_SEMB && hba_port->sig != SATA_SIG_PM) {
//we may have found a SATA device, but what is the status of this device?
uint64 ssts = hba_port->ssts;
uint8 ipm = (ssts >> 8) & 0x0F;
uint8 spd = (ssts >> 4) & 0x0F;
uint8 det = ssts & 0x7; //the Device Detection (DET) flags are the bottom 3 bits
if (det != HBA_PORT_DET_PRESENT && ipm != HBA_PORT_IPM_ACTIVE) {
//nope
}else if(hba_port->sig==SATA_SIG_ATAPI) {
//ATAPI device
}else if(hba_port->sig==SATA_SIG_SEMB) {
}else if(hba_port->sig==SATA_SIG_PM) {
//port multiplier detected
}else{
cprintf("SATA device detected:\n");
cprintf(" port[%d].sig = %x\n", i, hba_port->sig);
cprintf(" ipm=%x, spd=%x, det=%x\n", ipm, spd, det);
ahci_sata_init(hba_port, i);
}
}
}
}
I'd appreciate any concrete tips on where you think that might be wrong, but again I've read the spec up and down and fail to see how the probing could be wrong. I hope I'm incorrect.