[hatari-devel] IDE HD emulation error handling

Eero Tamminen eerot at users.berlios.de
Wed Jan 20 21:41:05 CET 2010


Hi,

On Wednesday 20 January 2010, Thomas Huth wrote:
> > > > > Looks like bad error handling. Feel free to fix it!
> > > >
> > > > Problem is that not being familar with IDE, I'm not sure how it
> > > > should be handled. :-)
> > >
> > > Me neither, I just ported the code from qemu to Hatari :-)
> >
> > Oh, in that case, let's just ignore it.  I assume my disk image was
> > broken. :-)
>
> You could also have a look at the latest qemu source code:
>
> http://git.savannah.gnu.org/cgit/qemu.git/tree/hw/ide/core.c
>
> Looks like they fixed the return value checking there...

The change for read & write is this:
--------
                ret = bdrv_read(s->bs, sector_num, s->io_buffer, n);
+        if (ret != 0) {
+            if (ide_handle_rw_error(s, -ret,
+                BM_STATUS_PIO_RETRY | BM_STATUS_RETRY_READ))
+            {
+                return;
+            }
+        }
--------

It calls new function:
+static int ide_handle_rw_error(IDEState *s, int error, int op)
+{
+    int is_read = (op & BM_STATUS_RETRY_READ);
+    BlockInterfaceErrorAction action = drive_get_on_error(s->bs, is_read);
+
+    if (action == BLOCK_ERR_IGNORE)
+        return 0;
+
+    if ((error == ENOSPC && action == BLOCK_ERR_STOP_ENOSPC)
+            || action == BLOCK_ERR_STOP_ANY) {
+        s->bus->bmdma->unit = s->unit;
+        s->bus->bmdma->status |= op;
+        vm_stop(0);
+    } else {
+        if (op & BM_STATUS_DMA_RETRY) {
+            dma_buf_commit(s, 0);
+            ide_dma_error(s);
+        } else {
+            ide_abort_command(s);
+            ide_set_irq(s->bus);
+        }
+    }
+    return 1;
+}

I guess the things with "dma" in their name are not relevant as current
Hatari code doesn't seem to support IDE DMA.  What about the block error
modes?   Does Atari have those?


	- Eero

PS. There's a lot of stuff supporting extra features like:
- More complete ATAPI
- DVD-ROM
- CF disk
- SMART
- DMA-mode

Is any of this relevant or Atari & copyable as is from Qemu?
(The DMA stuff seems to permeat a lot of it.)

Attached is a list of some random differences that may be potentially 
useful.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ide-qmu.diff
Type: text/x-diff
Size: 13950 bytes
Desc: not available
URL: <https://lists.berlios.de/pipermail/hatari-devel/attachments/20100120/fd68cd4c/attachment.diff>


More information about the hatari-devel mailing list