diff options
author | Anthony Liguori <aliguori@us.ibm.com> | 2013-07-29 14:39:49 -0500 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2013-07-29 14:39:49 -0500 |
commit | 6a4992d0bdeb38a57314d731d9846063b2057e6c (patch) | |
tree | 10d359f7bec5918dd1fc6d9a445213f3019d1929 /hw/timer/etraxfs_timer.c | |
parent | eddbf0ab9db8385d7cb57e23891c1d41488b303e (diff) | |
parent | b67964d70219a864ec427e727754a205475c7d6c (diff) | |
download | hqemu-6a4992d0bdeb38a57314d731d9846063b2057e6c.zip hqemu-6a4992d0bdeb38a57314d731d9846063b2057e6c.tar.gz |
Merge remote-tracking branch 'afaerber/tags/qom-devices-for-anthony' into staging
QOM device refactorings
* Replace all uses of FROM_SYSBUS() macro with QOM cast macros
i) "QOM cast cleanup for X"
Indicates a mechanical 1:1 between TYPE_* and *State.
ii) "QOM'ify X and Y"
Indicates abstract types may have been inserted or similar changes
to type hierarchy.
ii) Renames
Coding Style fixes such as CamelCase have been applied in some cases.
* Fix for sparc floppy - cf. ii) above
* Change PCI type hierarchy to provide PCI_BRIDGE() casts
* In doing so, prepare for adopting QOM realize
# gpg: Signature made Mon 29 Jul 2013 02:15:22 PM CDT using RSA key ID 3E7E013F
# gpg: Can't check signature: public key not found
# By Andreas Färber (171) and others
# Via Andreas Färber
* afaerber/tags/qom-devices-for-anthony: (173 commits)
sysbus: QOM parent field cleanup for SysBusDevice
spapr_pci: QOM cast cleanup
ioapic: QOM cast cleanup
kvm/ioapic: QOM cast cleanup
kvmvapic: QOM cast cleanup
mipsnet: QOM cast cleanup
opencores_eth: QOM cast cleanup
exynos4210_i2c: QOM cast cleanup
sysbus: Remove unused sysbus_new() prototype
sysbus: Drop FROM_SYSBUS()
xilinx_timer: QOM cast cleanup
tusb6010: QOM cast cleanup
slavio_timer: QOM cast cleanup
pxa2xx_timer: QOM'ify pxa25x-timer and pxa27x-timer
puv3_ost: QOM cast cleanup
pl031: QOM cast cleanup
pl031: Rename pl031_state to PL031State
milkymist-sysctl: QOM cast cleanup
m48t59: QOM cast cleanup for M48t59SysBusState
lm32_timer: QOM cast cleanup
...
Diffstat (limited to 'hw/timer/etraxfs_timer.c')
-rw-r--r-- | hw/timer/etraxfs_timer.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/hw/timer/etraxfs_timer.c b/hw/timer/etraxfs_timer.c index 6dd1072..a38d9e4 100644 --- a/hw/timer/etraxfs_timer.c +++ b/hw/timer/etraxfs_timer.c @@ -42,8 +42,13 @@ #define R_INTR 0x50 #define R_MASKED_INTR 0x54 -struct etrax_timer { - SysBusDevice busdev; +#define TYPE_ETRAX_FS_TIMER "etraxfs,timer" +#define ETRAX_TIMER(obj) \ + OBJECT_CHECK(ETRAXTimerState, (obj), TYPE_ETRAX_FS_TIMER) + +typedef struct ETRAXTimerState { + SysBusDevice parent_obj; + MemoryRegion mmio; qemu_irq irq; qemu_irq nmi; @@ -72,12 +77,12 @@ struct etrax_timer { uint32_t rw_ack_intr; uint32_t r_intr; uint32_t r_masked_intr; -}; +} ETRAXTimerState; static uint64_t timer_read(void *opaque, hwaddr addr, unsigned int size) { - struct etrax_timer *t = opaque; + ETRAXTimerState *t = opaque; uint32_t r = 0; switch (addr) { @@ -103,7 +108,7 @@ timer_read(void *opaque, hwaddr addr, unsigned int size) return r; } -static void update_ctrl(struct etrax_timer *t, int tnum) +static void update_ctrl(ETRAXTimerState *t, int tnum) { unsigned int op; unsigned int freq; @@ -167,7 +172,7 @@ static void update_ctrl(struct etrax_timer *t, int tnum) } } -static void timer_update_irq(struct etrax_timer *t) +static void timer_update_irq(ETRAXTimerState *t) { t->r_intr &= ~(t->rw_ack_intr); t->r_masked_intr = t->r_intr & t->rw_intr_mask; @@ -178,21 +183,21 @@ static void timer_update_irq(struct etrax_timer *t) static void timer0_hit(void *opaque) { - struct etrax_timer *t = opaque; + ETRAXTimerState *t = opaque; t->r_intr |= 1; timer_update_irq(t); } static void timer1_hit(void *opaque) { - struct etrax_timer *t = opaque; + ETRAXTimerState *t = opaque; t->r_intr |= 2; timer_update_irq(t); } static void watchdog_hit(void *opaque) { - struct etrax_timer *t = opaque; + ETRAXTimerState *t = opaque; if (t->wd_hits == 0) { /* real hw gives a single tick before reseting but we are a bit friendlier to compensate for our slower execution. */ @@ -206,7 +211,7 @@ static void watchdog_hit(void *opaque) t->wd_hits++; } -static inline void timer_watchdog_update(struct etrax_timer *t, uint32_t value) +static inline void timer_watchdog_update(ETRAXTimerState *t, uint32_t value) { unsigned int wd_en = t->rw_wd_ctrl & (1 << 8); unsigned int wd_key = t->rw_wd_ctrl >> 9; @@ -245,7 +250,7 @@ static void timer_write(void *opaque, hwaddr addr, uint64_t val64, unsigned int size) { - struct etrax_timer *t = opaque; + ETRAXTimerState *t = opaque; uint32_t value = val64; switch (addr) @@ -298,7 +303,7 @@ static const MemoryRegionOps timer_ops = { static void etraxfs_timer_reset(void *opaque) { - struct etrax_timer *t = opaque; + ETRAXTimerState *t = opaque; ptimer_stop(t->ptimer_t0); ptimer_stop(t->ptimer_t1); @@ -311,7 +316,7 @@ static void etraxfs_timer_reset(void *opaque) static int etraxfs_timer_init(SysBusDevice *dev) { - struct etrax_timer *t = FROM_SYSBUS(typeof (*t), dev); + ETRAXTimerState *t = ETRAX_TIMER(dev); t->bh_t0 = qemu_bh_new(timer0_hit, t); t->bh_t1 = qemu_bh_new(timer1_hit, t); @@ -338,9 +343,9 @@ static void etraxfs_timer_class_init(ObjectClass *klass, void *data) } static const TypeInfo etraxfs_timer_info = { - .name = "etraxfs,timer", + .name = TYPE_ETRAX_FS_TIMER, .parent = TYPE_SYS_BUS_DEVICE, - .instance_size = sizeof (struct etrax_timer), + .instance_size = sizeof(ETRAXTimerState), .class_init = etraxfs_timer_class_init, }; |