Page 1 of 1

Why can't I read CD with ATAPI?

Posted: Tue Mar 12, 2013 10:56 pm
by windows8
I need read CD in Protected Mode,so I use ATAPI.
I read http://wiki.osdev.org/ATAPI ,then I write the code:

Code: Select all

void readCD()
{
    u8 cmd[12] = {0xBE,0,0,0,0,0,0,0,0,0,0,0};
    u8 status;
    out_byte(0x1F6,0);
    in_byte(0x1F0 + 0x206);
    in_byte(0x1F0 + 0x206);
    in_byte(0x1F0 + 0x206);
    in_byte(0x1F0 + 0x206);
    out_byte(0x1F1,0);
    out_byte(0x1F4,2048 & 0xFF);
    out_byte(0x1F5,2048 >> 8);
    out_byte(0x1F7,0xA0);
    while ((status = in_byte (0x1F7)) & 0x80);
    while (!((status = in_byte (0x1F7)) & 0x8) && !(status & 0x1));
    cmd[5] = 25;//LBA:low 0-8
    cmd[9] = 1;//1 sector
    //cmd[10] = 16;
    write_port(0x1F0,cmd,6);
    wait_irq();//stop here,why?
    //...
}
After "write_port(0x1F0,cmd,6);",the irq didn't arrive,what's the reson?
Thank you very much!

Re: Why can't I read CD with ATAPI?

Posted: Tue Mar 26, 2013 6:56 am
by brain
did you set up the IDT and IDE interrupts, and point a handler at them?
Can you prove they work by putting debug output in the handler and initating an interrupt by requesting sectors?
Do other interrupts work?
Did you enumerate the IDE devices first to check that the device you are sending the request to exists and is an ATAPI device?