提交 d8052a2e 编写于 作者: P Peter Maydell

hw/arm/musicpal.c: Switch to transaction-based ptimer API

Switch the musicpal code away from bottom-half based ptimers to
the new transaction-based ptimer API.  This just requires adding
begin/commit calls around the various places that modify the ptimer
state, and using the new ptimer_init() function to create the timer.
Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
Reviewed-by: NRichard Henderson <richard.henderson@linaro.org>
Message-id: 20191008171740.9679-6-peter.maydell@linaro.org
上级 5a65f7b5
...@@ -843,13 +843,10 @@ static void mv88w8618_timer_tick(void *opaque) ...@@ -843,13 +843,10 @@ static void mv88w8618_timer_tick(void *opaque)
static void mv88w8618_timer_init(SysBusDevice *dev, mv88w8618_timer_state *s, static void mv88w8618_timer_init(SysBusDevice *dev, mv88w8618_timer_state *s,
uint32_t freq) uint32_t freq)
{ {
QEMUBH *bh;
sysbus_init_irq(dev, &s->irq); sysbus_init_irq(dev, &s->irq);
s->freq = freq; s->freq = freq;
bh = qemu_bh_new(mv88w8618_timer_tick, s); s->ptimer = ptimer_init(mv88w8618_timer_tick, s, PTIMER_POLICY_DEFAULT);
s->ptimer = ptimer_init_with_bh(bh, PTIMER_POLICY_DEFAULT);
} }
static uint64_t mv88w8618_pit_read(void *opaque, hwaddr offset, static uint64_t mv88w8618_pit_read(void *opaque, hwaddr offset,
...@@ -879,16 +876,19 @@ static void mv88w8618_pit_write(void *opaque, hwaddr offset, ...@@ -879,16 +876,19 @@ static void mv88w8618_pit_write(void *opaque, hwaddr offset,
case MP_PIT_TIMER1_LENGTH ... MP_PIT_TIMER4_LENGTH: case MP_PIT_TIMER1_LENGTH ... MP_PIT_TIMER4_LENGTH:
t = &s->timer[offset >> 2]; t = &s->timer[offset >> 2];
t->limit = value; t->limit = value;
ptimer_transaction_begin(t->ptimer);
if (t->limit > 0) { if (t->limit > 0) {
ptimer_set_limit(t->ptimer, t->limit, 1); ptimer_set_limit(t->ptimer, t->limit, 1);
} else { } else {
ptimer_stop(t->ptimer); ptimer_stop(t->ptimer);
} }
ptimer_transaction_commit(t->ptimer);
break; break;
case MP_PIT_CONTROL: case MP_PIT_CONTROL:
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
t = &s->timer[i]; t = &s->timer[i];
ptimer_transaction_begin(t->ptimer);
if (value & 0xf && t->limit > 0) { if (value & 0xf && t->limit > 0) {
ptimer_set_limit(t->ptimer, t->limit, 0); ptimer_set_limit(t->ptimer, t->limit, 0);
ptimer_set_freq(t->ptimer, t->freq); ptimer_set_freq(t->ptimer, t->freq);
...@@ -896,6 +896,7 @@ static void mv88w8618_pit_write(void *opaque, hwaddr offset, ...@@ -896,6 +896,7 @@ static void mv88w8618_pit_write(void *opaque, hwaddr offset,
} else { } else {
ptimer_stop(t->ptimer); ptimer_stop(t->ptimer);
} }
ptimer_transaction_commit(t->ptimer);
value >>= 4; value >>= 4;
} }
break; break;
...@@ -914,8 +915,11 @@ static void mv88w8618_pit_reset(DeviceState *d) ...@@ -914,8 +915,11 @@ static void mv88w8618_pit_reset(DeviceState *d)
int i; int i;
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
ptimer_stop(s->timer[i].ptimer); mv88w8618_timer_state *t = &s->timer[i];
s->timer[i].limit = 0; ptimer_transaction_begin(t->ptimer);
ptimer_stop(t->ptimer);
ptimer_transaction_commit(t->ptimer);
t->limit = 0;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册