ATA not detecting!

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.
Post Reply
MrLolthe1st
Member
Member
Posts: 90
Joined: Sat Sep 24, 2016 12:06 am

ATA not detecting!

Post by MrLolthe1st »

Hi all, have a good day. Im tested my os in qemu, virtualbox, bochs, but on real hardware my detecting procedure says, that i haven't any ATA devices. On PC all, may be ok, not tested for read/write, but on notebook function 'detect' returns 0xFF and 0xFFFF 256 times info. Any ideas?
that my code:

Code: Select all

 //Выбераем диск
    outportb(port + 6, 0xA0 | slavebit);
    //Кол-во секторов 0
    outportb(port + 2, 0);
    //LBA 0
    outportb(port + 3, 0);
    outportb(port + 4, 0);
    outportb(port + 5, 0);
    //IDENTIFY command
    outportb(port + 7, 0xEC);
    char x = inportb(port + 7);
    while (x & 0x80) {
        x = inportb(port + 7);
        if (x & 1) break;
    }
    if (x == 0 || x & 1) {
        //Диска нету/ошибка
        return;
    }
    unsigned short u = inportw(port);
		kprintf("\n");
    returned[0] = u;
	kprintf("%x ",returned[0]);
    for (int i = 1; i < 256; i++)
    {
		returned[i] = inportw(port);
		kprintf("%x ",returned[i]);
	}
	while(getKey()==0);
    ATADevices[deviceCount].port = port;
    ATADevices[deviceCount].slavebit = slavebit;
    if (returned[83] & 1 << 10 != 0) {
        ATADevices[deviceCount].isLBA48Supported = 1;
        ATADevices[deviceCount].LBA48 = (returned[103] << 48) + (returned[102] << 32) + (returned[101] << 16) + returned[100];
        diskDevices[dcount].sectorsCount = ATADevices[deviceCount].LBA48;
        diskDevices[dcount].readSectors = & ReadController;
        diskDevices[dcount].writeSectors = & WriteController;
        diskDevices[dcount].ataNo = deviceCount;
        diskDevices[dcount].type = DISK_TYPE_ATA;
        if (ATADevices[deviceCount].LBA48 == 0)
            return;
    } else {
        ATADevices[deviceCount].isLBA48Supported = 0;
        ATADevices[deviceCount].LBA28 = returned[61] << 16 + returned[60];
        diskDevices[dcount].sectorsCount = ATADevices[deviceCount].LBA28;
        diskDevices[dcount].readSectors = & ReadController;
        diskDevices[dcount].writeSectors = & WriteController;
        diskDevices[dcount].ataNo = deviceCount;
        diskDevices[dcount].type = DISK_TYPE_ATA;
        if (ATADevices[deviceCount].LBA28 == 0)
            return;
    }
    dcount++;
    deviceCount++;
Cheers,
Aleksandr
Octocontrabass
Member
Member
Posts: 5586
Joined: Mon Mar 25, 2013 7:01 pm

Re: ATA not detecting!

Post by Octocontrabass »

MrLolthe1st wrote:on notebook function 'detect' returns 0xFF and 0xFFFF 256 times info.
Does your notebook have an IDE-compatible HBA? Most SATA HBAs can be configured for IDE compatibility in the BIOS setup.

Are you accessing the HBA on the correct ports? Modern HBAs don't always use port 0x1F0-0x1F7.
Post Reply