OSDev.org
https://forum.osdev.org/

ATA not detecting!
https://forum.osdev.org/viewtopic.php?f=1&t=32932
Page 1 of 1

Author:  MrLolthe1st [ Sun May 13, 2018 11:54 am ]
Post subject:  ATA not detecting!

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:
//Выбераем диск
    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

Author:  Octocontrabass [ Tue May 15, 2018 9:36 am ]
Post subject:  Re: ATA not detecting!

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.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/