qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [Patch][Fix win2k install] Add delay between dma issue & re


From: Dor Laor
Subject: [Qemu-devel] [Patch][Fix win2k install] Add delay between dma issue & result.
Date: Wed, 07 Nov 2007 18:48:33 +0200
User-agent: Thunderbird 2.0.0.6 (Windows/20070728)

Fix win2k install] Add delay between dma issue & result.
Using synchonous io leads the guest to unexplored places:
   If it issues a dma command, it goes to qemu and executed
   synchrnously and return with irq for data ready.
   This is not real world scenario and happens when not using asyncio.
   This fix adds a delay of 1msec once every 8 dma writes.
Signed-off-by: Dor Laor <address@hidden>

btw: It also applies against qemu cvs head.

diff --git a/qemu/hw/ide.c b/qemu/hw/ide.c
index 329d053..da972c8 100644
--- a/qemu/hw/ide.c
+++ b/qemu/hw/ide.c
@@ -366,6 +366,8 @@ typedef struct IDEState {
    uint32_t mdata_size;
    uint8_t *mdata_storage;
    int media_changed;
+
+    QEMUTimer *dma_write_timer; /* only used for win2k instal hack */
} IDEState;

#define BM_STATUS_DMAING 0x01
@@ -862,9 +864,21 @@ static void ide_sector_read_dma(IDEState *s)
static void ide_sector_write_timer_cb(void *opaque)
{
    IDEState *s = opaque;
+
    ide_set_irq(s);
}

+static void ide_write_dma_cb(void *opaque, int ret);
+static void ide_dma_write_timer_cb(void *opaque)
+{
+      IDEState *s = opaque;
+ + s->status = READY_STAT | SEEK_STAT | DRQ_STAT | BUSY_STAT;
+      s->io_buffer_index = 0;
+      s->io_buffer_size = 0;
+      ide_dma_start(s, ide_write_dma_cb);
+}
+
static void ide_sector_write_aio_cb(void *opaque, int ret)
{
    BMDMAState *bm = opaque;
@@ -975,10 +989,19 @@ static void ide_write_dma_cb(void *opaque, int ret)

static void ide_sector_write_dma(IDEState *s)
{
-    s->status = READY_STAT | SEEK_STAT | DRQ_STAT | BUSY_STAT;
-    s->io_buffer_index = 0;
-    s->io_buffer_size = 0;
-    ide_dma_start(s, ide_write_dma_cb);
+    #ifdef TARGET_I386
+        if (win2k_install_hack && ((++s->irq_count % 8) == 0)) {
+        /* It seems there is a bug in the Windows 2000 installer HDD
+           IDE driver which fills the disk with empty logs when the
+           IDE write IRQ comes too early. This hack tries to correct
+           that at the expense of slower write performances. Use this
+           option _only_ to install Windows 2000. You must disable it
+           for normal use. */
+           qemu_mod_timer(s->dma_write_timer,
+ qemu_get_clock(vm_clock) + (ticks_per_sec / 1000));
+        } else
+    #endif
+        ide_dma_write_timer_cb(s);
}

static void ide_atapi_cmd_ok(IDEState *s)
@@ -2497,6 +2520,8 @@ static void ide_init2(IDEState *ide_state,
        s->irq = irq;
        s->sector_write_timer = qemu_new_timer(vm_clock,
ide_sector_write_timer_cb, s);
+        s->dma_write_timer = qemu_new_timer(vm_clock,
+                                               ide_dma_write_timer_cb, s);
        ide_reset(s);
    }
}





reply via email to

[Prev in Thread] Current Thread [Next in Thread]