[SOLVED] ATAPI Doesn't fire IRQ

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.
ishidex2
Posts: 12
Joined: Tue Mar 31, 2020 10:18 am

Re: ATAPI Doesn't fire IRQ

Post by ishidex2 »

Looks like it helped a bit, though when I'm sending data, nothing happens, I've captured those logs from qemu

Code: Select all

Beginning to transfer ATAPI Packet =====================
[email protected]:ide_data_writew IDE PIO wr @ 0x170 (Data: Word); val 0x00a8; bus 0x55d903cddb80; IDEState 0x55d903cddbf8
[email protected]:ide_data_writew IDE PIO wr @ 0x170 (Data: Word); val 0x0000; bus 0x55d903cddb80; IDEState 0x55d903cddbf8
[email protected]:ide_data_writew IDE PIO wr @ 0x170 (Data: Word); val 0x0000; bus 0x55d903cddb80; IDEState 0x55d903cddbf8
[email protected]:ide_data_writew IDE PIO wr @ 0x170 (Data: Word); val 0x0000; bus 0x55d903cddb80; IDEState 0x55d903cddbf8
[email protected]:ide_data_writew IDE PIO wr @ 0x170 (Data: Word); val 0x0100; bus 0x55d903cddb80; IDEState 0x55d903cddbf8
[email protected]:ide_data_writew IDE PIO wr @ 0x170 (Data: Word); val 0x0000; bus 0x55d903cddb80; IDEState 0x55d903cddbf8

Code: Select all

    s2_OutW(dev->channel->base, 0x00a8);
    s2_OutW(dev->channel->base, 0x0000);
    s2_OutW(dev->channel->base, 0x0000);
    s2_OutW(dev->channel->base, 0x0000);
    s2_OutW(dev->channel->base, 0x0100);
    s2_OutW(dev->channel->base, 0x0000);
I've read from another forum topic that I have to reverse bytes, so its 0x00a8. Reversing back (0xa800) doesn't really help much.
User avatar
BenLunt
Member
Member
Posts: 941
Joined: Sat Nov 22, 2014 6:33 pm
Location: USA
Contact:

Re: ATAPI Doesn't fire IRQ

Post by BenLunt »

ishidex2 wrote:I've read from another forum topic that I have to reverse bytes, so its 0x00a8. Reversing back (0xa800) doesn't really help much.
It depends on how you look at it, reversing the bytes.

You really don't reverse the bytes. What really happens is that you write 16-bit WORDs in little-endian format. Least significant byte first.

Therefore, let's say you have a packet of (in hex bytes):

Code: Select all

01 23 45 67 89 AB CD EF 01 23 45 67 89 AB CD EF
You send them as 16-bit little-endian words.

Code: Select all

2301 6745 AB89 EFCD 2301 6745 AB89 EFCD
A very simple way to do this is:

Code: Select all

// packet points to a 16-byte packet full of byte data.
bit16u *p = (bit16u *) packet;
write_word(p[0]);
write_word(p[1]);
  ...
write_word(p[7]);
You aren't reversing the bytes, you are simply reading them as words and allowing the hardware to write them as little-endian words (i.e: reversed).

Granted, this all assumes you are on a little-endian machine. For big-endian machines, you would have to "reverse" the bytes.

Ben
ishidex2
Posts: 12
Joined: Tue Mar 31, 2020 10:18 am

Re: ATAPI Doesn't fire IRQ

Post by ishidex2 »

Hmm yeah that sends data I need, for some reason still no response form IDE controller
ishidex2
Posts: 12
Joined: Tue Mar 31, 2020 10:18 am

Re: ATAPI Doesn't fire IRQ

Post by ishidex2 »

Ok here's a thing I've noticed, it actually works in virutalbox, but it doesn't in qemu
ishidex2
Posts: 12
Joined: Tue Mar 31, 2020 10:18 am

Re: ATAPI Doesn't fire IRQ

Post by ishidex2 »

I fixed it, turns out you have to read first 256 words of data register in identify function, that made it work in qemu.
Post Reply