nand emulation fixes
[qemu] / hw / tc6393xb.c
index 7803a4c..9b0c752 100644 (file)
@@ -13,6 +13,7 @@
 #include "flash.h"
 #include "console.h"
 #include "pixel_ops.h"
+#include "sysemu.h"
 
 #define IRQ_TC6393_NAND                0
 #define IRQ_TC6393_MMC         1
@@ -587,7 +588,11 @@ TC6393xbState *tc6393xb_init(uint32_t base, qemu_irq irq)
 
     s->sub_irqs = qemu_allocate_irqs(tc6393xb_sub_irq, s, TC6393XB_NR_IRQS);
 
-    s->flash = nand_init(NAND_MFR_TOSHIBA, 0x76);
+    BlockDriverState *bdrv = NULL;
+    if (drive_get_index(IF_MTD, 0, 0) >= 0) {
+        bdrv = drives_table[drive_get_index(IF_MTD, 0, 0)].bdrv;
+    }
+    s->flash = nand_init(NAND_MFR_TOSHIBA, 0x76, bdrv);
 
     iomemtype = cpu_register_io_memory(0, tc6393xb_readfn,
                     tc6393xb_writefn, s);