Why can't I read CD with ATAPI?

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
windows8
Member
Member
Posts: 33
Joined: Sat Feb 23, 2013 3:52 am

Why can't I read CD with ATAPI?

Post 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!
User avatar
brain
Member
Member
Posts: 234
Joined: Thu Nov 05, 2009 5:04 pm
Location: UK
Contact:

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

Post 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?
Post Reply