Page 2 of 2

Re: ATAPI Doesn't fire IRQ

Posted: Sun Apr 05, 2020 4:53 pm
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.

Re: ATAPI Doesn't fire IRQ

Posted: Sun Apr 05, 2020 5:56 pm
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

Re: ATAPI Doesn't fire IRQ

Posted: Sun Apr 05, 2020 6:41 pm
by ishidex2
Hmm yeah that sends data I need, for some reason still no response form IDE controller

Re: ATAPI Doesn't fire IRQ

Posted: Mon Apr 06, 2020 2:29 pm
by ishidex2
Ok here's a thing I've noticed, it actually works in virutalbox, but it doesn't in qemu

Re: ATAPI Doesn't fire IRQ

Posted: Wed Apr 08, 2020 7:24 am
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.