diff options
author | Edgar E. Iglesias <edgar.iglesias@gmail.com> | 2009-05-16 01:40:46 +0200 |
---|---|---|
committer | Edgar E. Iglesias <edgar.iglesias@gmail.com> | 2009-05-16 02:13:49 +0200 |
commit | 4b816985b8622473afbe3e1bbe066a961661a5da (patch) | |
tree | 3b0ed9c13607a5390b2ec99dd3cbf9ee070f0095 /hw/etraxfs_ser.c | |
parent | 73cfd29fb34568f926386c2f43811362f2c22154 (diff) |
ETRAX-SER: qdevify.
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Diffstat (limited to 'hw/etraxfs_ser.c')
-rw-r--r-- | hw/etraxfs_ser.c | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/hw/etraxfs_ser.c b/hw/etraxfs_ser.c index 80091d5719..105b510025 100644 --- a/hw/etraxfs_ser.c +++ b/hw/etraxfs_ser.c @@ -22,11 +22,8 @@ * THE SOFTWARE. */ -#include <stdio.h> -#include <ctype.h> -#include "hw.h" +#include "sysbus.h" #include "qemu-char.h" -#include "etraxfs.h" #define D(x) @@ -48,9 +45,9 @@ struct etrax_serial { - CPUState *env; + SysBusDevice busdev; CharDriverState *chr; - qemu_irq *irq; + qemu_irq irq; /* This pending thing is a hack. */ int pending_tx; @@ -64,7 +61,7 @@ static void ser_update_irq(struct etrax_serial *s) s->regs[R_INTR] &= ~(s->regs[RW_ACK_INTR]); s->regs[R_MASKED_INTR] = s->regs[R_INTR] & s->regs[RW_INTR_MASK]; - qemu_set_irq(s->irq[0], !!s->regs[R_MASKED_INTR]); + qemu_set_irq(s->irq, !!s->regs[R_MASKED_INTR]); s->regs[RW_ACK_INTR] = 0; } @@ -164,25 +161,29 @@ static void serial_event(void *opaque, int event) } -void etraxfs_ser_init(CPUState *env, qemu_irq *irq, CharDriverState *chr, - target_phys_addr_t base) +static void etraxfs_ser_init(SysBusDevice *dev) { - struct etrax_serial *s; + struct etrax_serial *s = FROM_SYSBUS(typeof (*s), dev); int ser_regs; - s = qemu_mallocz(sizeof *s); - - s->env = env; - s->irq = irq; - s->chr = chr; - /* transmitter begins ready and idle. */ s->regs[RS_STAT_DIN] |= (1 << STAT_TR_RDY); s->regs[RS_STAT_DIN] |= (1 << STAT_TR_IDLE); - qemu_chr_add_handlers(chr, serial_can_receive, serial_receive, - serial_event, s); - + sysbus_init_irq(dev, &s->irq); ser_regs = cpu_register_io_memory(0, ser_read, ser_write, s); - cpu_register_physical_memory (base, R_MAX * 4, ser_regs); + sysbus_init_mmio(dev, R_MAX * 4, ser_regs); + s->chr = qdev_init_chardev(&dev->qdev); + if (s->chr) + qemu_chr_add_handlers(s->chr, + serial_can_receive, serial_receive, + serial_event, s); } + +static void etraxfs_serial_register(void) +{ + sysbus_register_dev("etraxfs,serial", sizeof (struct etrax_serial), + etraxfs_ser_init); +} + +device_init(etraxfs_serial_register) |