Patchwork [2/4] Registered timer reset handler

login
register
mail settings
Submitter Bharat Bhushan
Date June 28, 2012, 5:39 a.m.
Message ID <1340861999-31281-2-git-send-email-Bharat.Bhushan@freescale.com>
Download mbox | patch
Permalink /patch/167792/
State New
Headers show

Comments

Bharat Bhushan - June 28, 2012, 5:39 a.m.
Reset qemu timers when guest reset.

Signed-off-by: Bharat Bhushan <bharat.bhushan@freescale.com>
---
 hw/ppc_booke.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

Patch

diff --git a/hw/ppc_booke.c b/hw/ppc_booke.c
index d51e7fa..837a5b6 100644
--- a/hw/ppc_booke.c
+++ b/hw/ppc_booke.c
@@ -231,6 +231,16 @@  void store_booke_tcr(CPUPPCState *env, target_ulong val)
 
 }
 
+static void ppc_booke_timer_reset_handle(void *opaque)
+{
+    CPUPPCState *env = opaque;
+
+    env->spr[SPR_BOOKE_TSR] = 0;
+    env->spr[SPR_BOOKE_TCR] = 0;
+
+    booke_update_irq(env);
+}
+
 void ppc_booke_timers_init(CPUPPCState *env, uint32_t freq, uint32_t flags)
 {
     ppc_tb_t *tb_env;
@@ -251,4 +261,6 @@  void ppc_booke_timers_init(CPUPPCState *env, uint32_t freq, uint32_t flags)
         qemu_new_timer_ns(vm_clock, &booke_fit_cb, env);
     booke_timer->wdt_timer =
         qemu_new_timer_ns(vm_clock, &booke_wdt_cb, env);
+
+    qemu_register_reset(ppc_booke_timer_reset_handle, env);
 }