qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] macio: handle non-block ATAPI DMA transfers
@ 2014-05-18 12:20 Mark Cave-Ayland
  2014-05-19  9:18 ` Alexander Graf
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Cave-Ayland @ 2014-05-18 12:20 UTC (permalink / raw)
  To: qemu-devel, qemu-ppc, agraf

Currently the macio DMA routines assume that all DMA requests are for read/write
block transfers. This is not always the case for ATAPI, for example when
requesting a TOC where the response is generated directly in the IDE buffer.

Detect these non-block ATAPI DMA transfers (where no lba is specified in the
command) and copy the results directly into RAM as indicated by the DBDMA
descriptor. This fixes CDROM access under MorphOS.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/ide/macio.c |   21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/hw/ide/macio.c b/hw/ide/macio.c
index 1c20616..af57168 100644
--- a/hw/ide/macio.c
+++ b/hw/ide/macio.c
@@ -337,6 +337,27 @@ static void pmac_ide_transfer(DBDMA_io *io)
 
     s->io_buffer_size = 0;
     if (s->drive_kind == IDE_CD) {
+
+        /* Handle non-block ATAPI DMA transfers */
+        if (s->lba == -1) {
+            s->io_buffer_size = MIN(io->len, s->packet_transfer_size);
+            bdrv_acct_start(s->bs, &s->acct, s->io_buffer_size,
+                            BDRV_ACCT_READ);
+            MACIO_DPRINTF("non-block ATAPI DMA transfer size: %d\n",
+                          s->io_buffer_size);
+
+            /* Copy ATAPI buffer directly to RAM and finish */
+            cpu_physical_memory_write(io->addr, s->io_buffer,
+                                      s->io_buffer_size);
+            ide_atapi_cmd_ok(s);
+            m->dma_active = false;
+
+            MACIO_DPRINTF("end of non-block ATAPI DMA transfer\n");
+            bdrv_acct_done(s->bs, &s->acct);
+            io->dma_end(io);
+            return;
+        }
+
         bdrv_acct_start(s->bs, &s->acct, io->len, BDRV_ACCT_READ);
         pmac_ide_atapi_transfer_cb(io, 0);
         return;
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] macio: handle non-block ATAPI DMA transfers
  2014-05-18 12:20 [Qemu-devel] [PATCH] macio: handle non-block ATAPI DMA transfers Mark Cave-Ayland
@ 2014-05-19  9:18 ` Alexander Graf
  0 siblings, 0 replies; 2+ messages in thread
From: Alexander Graf @ 2014-05-19  9:18 UTC (permalink / raw)
  To: Mark Cave-Ayland, qemu-devel, qemu-ppc


On 18.05.14 14:20, Mark Cave-Ayland wrote:
> Currently the macio DMA routines assume that all DMA requests are for read/write
> block transfers. This is not always the case for ATAPI, for example when
> requesting a TOC where the response is generated directly in the IDE buffer.
>
> Detect these non-block ATAPI DMA transfers (where no lba is specified in the
> command) and copy the results directly into RAM as indicated by the DBDMA
> descriptor. This fixes CDROM access under MorphOS.
>
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>

Thanks, applied to ppc-next.


Alex

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-05-19  9:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-18 12:20 [Qemu-devel] [PATCH] macio: handle non-block ATAPI DMA transfers Mark Cave-Ayland
2014-05-19  9:18 ` Alexander Graf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).