Explanation needed: How to issue ATAPI command to CD drive.
Posted: Tue May 03, 2011 10:37 am
I am reading from here http://wiki.osdev.org/ATAPI that:
Phase 1) How could I know what ATA IO port registers to use? Are they standized?
Phase 2) What is "a PIO data transfer"? How to do it?
Phase 3) How to wait for an IRQ? Do I have to implement and register some kind of interrupt handler? Does this mean I have to manipulate the IDT table in protected mode?
Could someone explain it a little? Some sample code in assembly language would be better...
Many thanks.
Questions:The ATA PACKET command works in three phases, in PIO mode.
Phase 1) Set up the standard ATA IO port registers with ATAPI specific values. Then Send the ATA PACKET command to the device exactly as you would with any other ATA command: outb (ATA Command Register, 0xA0)
Phase 2) Prepare to do a PIO data transfer, the normal way, to the device. When the device is ready (BSY clear, DRQ set) you send the ATAPI command string (like the one above) as a 6 word PIO transfer to the device.
Phase 3) Wait for an IRQ. When it arrives, you must read the LBA Mid and LBA High IO port registers. They tell you the packet byte count that the ATAPI drive will send to you, or must receive from you. In a loop, you transmit that number of bytes, then wait for the next IRQ.
In DMA mode, only the first two phases happen. The device handles the details of phase 3 itself, with the PCI drive controller.
Phase 1) How could I know what ATA IO port registers to use? Are they standized?
Phase 2) What is "a PIO data transfer"? How to do it?
Phase 3) How to wait for an IRQ? Do I have to implement and register some kind of interrupt handler? Does this mean I have to manipulate the IDT table in protected mode?
Could someone explain it a little? Some sample code in assembly language would be better...
Many thanks.