I was able to locate the ABAR by scanning PCIE device for "ClassCode = 0x01" and "SubClass = 0x06", with the offset "0x24" as follow:
Code: Select all
if(BaseClass == 0x01 && SubClass == 0x06){//AHCI controller
AHCI.ABAR = (HBA_MEM *)((unsigned long)PCI_CONF_Read(bus, device, function, 0x24) + PAGE_OFFSET);
}
Code: Select all
unsigned int PCI_CONF_Read(unsigned int bus, unsigned int slot, unsigned int func, unsigned int offset)
{
unsigned int address;
unsigned int tmp = 0, i;
if(ACPI.PCI_CONF_BASE){
for(i=0;i<ACPI.No_PCI_Base;i++){
if(ACPI.PCI_CONF_BASE[i].Start_Bus <= bus && ACPI.PCI_CONF_BASE[i].End_Bus){
tmp = *(unsigned int *)((ACPI.PCI_CONF_BASE[i].Base_Addr + PAGE_OFFSET) +
((bus - ACPI.PCI_CONF_BASE[i].Start_Bus)<<20 | slot << 15 | func << 12 | (offset & 0xfc)));
}
}
}else{
address = (unsigned int)((bus << 16) | (slot << 11) | (func << 8) | (offset & 0xfc) | ((unsigned int)0x80000000));
io_out32(0xCF8, address);
tmp = io_in32(0xCFC);
}
return (tmp);
}
However, when I trying to retrieve information from the address it does not follow the tutorial.
As told, the first 4 byte should be HBA_MEM.cap which "must be within 1 and 32", but the first 4 byte I got is "0xC0141F05".
So I would like to ask if it is some kind of mistake or not. Thanks a lot!!!
My platform:
Qemu 4.2.0-1
Manjaro 18
gcc 9.2.0