First, thank to all of you for this site, it's really great!
Here is my problem :
for sometime now, i have been trying to write a simple ATAPI driver but i can't get IDENTIFY DEVICE to work!!!!
i have been searching on the wiki, forums and source and tried a few things, but it still doesn t work, so in last resort i just ask : WTF is wrong with my code???
here is the code :
Code: Select all
BYTE ATAPI_CMD_IDENTIFY[12] = {0xA1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
DWORD ata_wait_bsy(DWORD drivenb)
{
DWORD status;
while(1)
{
status = inb(drivenb+ATA_REG_CMD);
if(status&ATA_STATUS_ERR)
return 1;
if(!(status&ATA_STATUS_BSY))
return 0;
}
}
DWORD atapi_send_cmd(PDISK disk, BYTE* cmd)
{
ata_wait_bsy(disk->baseport);
outb (disk->baseport+ATA_REG_FLAGS, disk->slave<<4);
ata_wait_bsy(disk->baseport);
outb(disk->baseport+ATA_REG_CMD, 0xA0);
inb(disk->baseport+ATA_REG_CMD);
inb(disk->baseport+ATA_REG_CMD);
inb(disk->baseport+ATA_REG_CMD);
inb(disk->baseport+ATA_REG_CMD);
inb(disk->baseport+ATA_REG_CMD);//*/
ata_wait_drq(disk->baseport);
for(int i=0;i<6;i++)
{
outw(disk->baseport, (WORD)cmd[i*2]);
//inb(0x3f6);
}
return 0;
}
identify func :
{
...
tested being atapi
...
atapi_send_cmd(disk, ATAPI_CMD_IDENTIFY);
ata_wait_drq(disk->baseport);
for(int i=0;i<0x100;i++)
disk->params.ataid.words[i] = inw(disk->baseport);
...
}