X-Git-Url: http://git.maemo.org/git/?p=qemu;a=blobdiff_plain;f=hw%2Ftc6393xb.c;fp=hw%2Ftc6393xb.c;h=9b0c75272345e5ae870d2bf5529222b958660699;hp=56fd1eec920ecf79143dd0cf9fedf3bd3d572c0e;hb=a03c3bde4e288e790eccfb8cd45abd8ecbf467dc;hpb=e2ffa1bf065fa199f27d661d495573e9d6059bf1 diff --git a/hw/tc6393xb.c b/hw/tc6393xb.c index 56fd1ee..9b0c752 100644 --- a/hw/tc6393xb.c +++ b/hw/tc6393xb.c @@ -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 @@ -78,7 +79,7 @@ #define NAND_MODE_ECC_READ 0x40 #define NAND_MODE_ECC_RST 0x60 -struct tc6393xb_s { +struct TC6393xbState { qemu_irq irq; qemu_irq *sub_irqs; struct { @@ -118,8 +119,8 @@ struct tc6393xb_s { } nand; int nand_enable; uint32_t nand_phys; - struct nand_flash_s *flash; - struct ecc_state_s ecc; + NANDFlashState *flash; + ECCState ecc; DisplayState *ds; ram_addr_t vram_addr; @@ -130,14 +131,14 @@ struct tc6393xb_s { blanked : 1; }; -qemu_irq *tc6393xb_gpio_in_get(struct tc6393xb_s *s) +qemu_irq *tc6393xb_gpio_in_get(TC6393xbState *s) { return s->gpio_in; } static void tc6393xb_gpio_set(void *opaque, int line, int level) { -// struct tc6393xb_s *s = opaque; +// TC6393xbState *s = opaque; if (line > TC6393XB_GPIOS) { printf("%s: No GPIO pin %i\n", __FUNCTION__, line); @@ -147,7 +148,7 @@ static void tc6393xb_gpio_set(void *opaque, int line, int level) // FIXME: how does the chip reflect the GPIO input level change? } -void tc6393xb_gpio_out_set(struct tc6393xb_s *s, int line, +void tc6393xb_gpio_out_set(TC6393xbState *s, int line, qemu_irq handler) { if (line >= TC6393XB_GPIOS) { @@ -158,7 +159,7 @@ void tc6393xb_gpio_out_set(struct tc6393xb_s *s, int line, s->handler[line] = handler; } -static void tc6393xb_gpio_handler_update(struct tc6393xb_s *s) +static void tc6393xb_gpio_handler_update(TC6393xbState *s) { uint32_t level, diff; int bit; @@ -173,20 +174,20 @@ static void tc6393xb_gpio_handler_update(struct tc6393xb_s *s) s->prev_level = level; } -qemu_irq tc6393xb_l3v_get(struct tc6393xb_s *s) +qemu_irq tc6393xb_l3v_get(TC6393xbState *s) { return s->l3v; } static void tc6393xb_l3v(void *opaque, int line, int level) { - struct tc6393xb_s *s = opaque; + TC6393xbState *s = opaque; s->blank = !level; fprintf(stderr, "L3V: %d\n", level); } static void tc6393xb_sub_irq(void *opaque, int line, int level) { - struct tc6393xb_s *s = opaque; + TC6393xbState *s = opaque; uint8_t isr = s->scr.ISR; if (level) isr |= 1 << line; @@ -211,7 +212,7 @@ static void tc6393xb_sub_irq(void *opaque, int line, int level) { case SCR_ ##N(1): return s->scr.N[1]; \ case SCR_ ##N(2): return s->scr.N[2] -static uint32_t tc6393xb_scr_readb(struct tc6393xb_s *s, target_phys_addr_t addr) +static uint32_t tc6393xb_scr_readb(TC6393xbState *s, target_phys_addr_t addr) { switch (addr) { case SCR_REVID: @@ -272,7 +273,7 @@ static uint32_t tc6393xb_scr_readb(struct tc6393xb_s *s, target_phys_addr_t addr case SCR_ ##N(1): s->scr.N[1] = value; return; \ case SCR_ ##N(2): s->scr.N[2] = value; return -static void tc6393xb_scr_writeb(struct tc6393xb_s *s, target_phys_addr_t addr, uint32_t value) +static void tc6393xb_scr_writeb(TC6393xbState *s, target_phys_addr_t addr, uint32_t value) { switch (addr) { SCR_REG_B(ISR); @@ -318,12 +319,12 @@ static void tc6393xb_scr_writeb(struct tc6393xb_s *s, target_phys_addr_t addr, u #undef SCR_REG_L #undef SCR_REG_A -static void tc6393xb_nand_irq(struct tc6393xb_s *s) { +static void tc6393xb_nand_irq(TC6393xbState *s) { qemu_set_irq(s->sub_irqs[IRQ_TC6393_NAND], (s->nand.imr & 0x80) && (s->nand.imr & s->nand.isr)); } -static uint32_t tc6393xb_nand_cfg_readb(struct tc6393xb_s *s, target_phys_addr_t addr) { +static uint32_t tc6393xb_nand_cfg_readb(TC6393xbState *s, target_phys_addr_t addr) { switch (addr) { case NAND_CFG_COMMAND: return s->nand_enable ? 2 : 0; @@ -336,7 +337,7 @@ static uint32_t tc6393xb_nand_cfg_readb(struct tc6393xb_s *s, target_phys_addr_t fprintf(stderr, "tc6393xb_nand_cfg: unhandled read at %08x\n", (uint32_t) addr); return 0; } -static void tc6393xb_nand_cfg_writeb(struct tc6393xb_s *s, target_phys_addr_t addr, uint32_t value) { +static void tc6393xb_nand_cfg_writeb(TC6393xbState *s, target_phys_addr_t addr, uint32_t value) { switch (addr) { case NAND_CFG_COMMAND: s->nand_enable = (value & 0x2); @@ -353,7 +354,7 @@ static void tc6393xb_nand_cfg_writeb(struct tc6393xb_s *s, target_phys_addr_t ad (uint32_t) addr, value & 0xff); } -static uint32_t tc6393xb_nand_readb(struct tc6393xb_s *s, target_phys_addr_t addr) { +static uint32_t tc6393xb_nand_readb(TC6393xbState *s, target_phys_addr_t addr) { switch (addr) { case NAND_DATA + 0: case NAND_DATA + 1: @@ -372,7 +373,7 @@ static uint32_t tc6393xb_nand_readb(struct tc6393xb_s *s, target_phys_addr_t add fprintf(stderr, "tc6393xb_nand: unhandled read at %08x\n", (uint32_t) addr); return 0; } -static void tc6393xb_nand_writeb(struct tc6393xb_s *s, target_phys_addr_t addr, uint32_t value) { +static void tc6393xb_nand_writeb(TC6393xbState *s, target_phys_addr_t addr, uint32_t value) { // fprintf(stderr, "tc6393xb_nand: write at %08x: %02x\n", // (uint32_t) addr, value & 0xff); switch (addr) { @@ -427,7 +428,7 @@ static void tc6393xb_nand_writeb(struct tc6393xb_s *s, target_phys_addr_t addr, #define BITS 32 #include "tc6393xb_template.h" -static void tc6393xb_draw_graphic(struct tc6393xb_s *s, int full_update) +static void tc6393xb_draw_graphic(TC6393xbState *s, int full_update) { switch (ds_get_bits_per_pixel(s->ds)) { case 8: @@ -453,7 +454,7 @@ static void tc6393xb_draw_graphic(struct tc6393xb_s *s, int full_update) dpy_update(s->ds, 0, 0, s->scr_width, s->scr_height); } -static void tc6393xb_draw_blank(struct tc6393xb_s *s, int full_update) +static void tc6393xb_draw_blank(TC6393xbState *s, int full_update) { int i, w; uint8_t *d; @@ -473,7 +474,7 @@ static void tc6393xb_draw_blank(struct tc6393xb_s *s, int full_update) static void tc6393xb_update_display(void *opaque) { - struct tc6393xb_s *s = opaque; + TC6393xbState *s = opaque; int full_update; if (s->scr_width == 0 || s->scr_height == 0) @@ -496,7 +497,7 @@ static void tc6393xb_update_display(void *opaque) static uint32_t tc6393xb_readb(void *opaque, target_phys_addr_t addr) { - struct tc6393xb_s *s = opaque; + TC6393xbState *s = opaque; switch (addr >> 8) { case 0: @@ -517,7 +518,7 @@ static uint32_t tc6393xb_readb(void *opaque, target_phys_addr_t addr) { } static void tc6393xb_writeb(void *opaque, target_phys_addr_t addr, uint32_t value) { - struct tc6393xb_s *s = opaque; + TC6393xbState *s = opaque; switch (addr >> 8) { case 0: @@ -563,10 +564,10 @@ static void tc6393xb_writel(void *opaque, target_phys_addr_t addr, uint32_t valu tc6393xb_writeb(opaque, addr + 3, value >> 24); } -struct tc6393xb_s *tc6393xb_init(uint32_t base, qemu_irq irq) +TC6393xbState *tc6393xb_init(uint32_t base, qemu_irq irq) { int iomemtype; - struct tc6393xb_s *s; + TC6393xbState *s; CPUReadMemoryFunc *tc6393xb_readfn[] = { tc6393xb_readb, tc6393xb_readw, @@ -578,7 +579,7 @@ struct tc6393xb_s *tc6393xb_init(uint32_t base, qemu_irq irq) tc6393xb_writel, }; - s = (struct tc6393xb_s *) qemu_mallocz(sizeof(struct tc6393xb_s)); + s = (TC6393xbState *) qemu_mallocz(sizeof(TC6393xbState)); s->irq = irq; s->gpio_in = qemu_allocate_irqs(tc6393xb_gpio_set, s, TC6393XB_GPIOS); @@ -587,7 +588,11 @@ struct tc6393xb_s *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);