X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=hw%2Fmips_timer.c;h=b295bdbfeb812bc1d98df2b3c723b68fbc59ab73;hb=cd346349b45ef056f138a184f660b8c34c3213cc;hp=9128cbff7d7dacd840ad4df759c0e83b8f322c70;hpb=3529b538ce91df31b7300ce2fbd838a2ca36e1fc;p=qemu diff --git a/hw/mips_timer.c b/hw/mips_timer.c index 9128cbf..b295bdb 100644 --- a/hw/mips_timer.c +++ b/hw/mips_timer.c @@ -10,16 +10,19 @@ uint32_t cpu_mips_get_random (CPUState *env) static uint32_t seed = 0; uint32_t idx; seed = seed * 314159 + 1; - idx = (seed >> 16) % (MIPS_TLB_NB - env->CP0_Wired) + env->CP0_Wired; + idx = (seed >> 16) % (env->tlb->nb_tlb - env->CP0_Wired) + env->CP0_Wired; return idx; } /* MIPS R4K timer */ uint32_t cpu_mips_get_count (CPUState *env) { - return env->CP0_Count + - (uint32_t)muldiv64(qemu_get_clock(vm_clock), - 100 * 1000 * 1000, ticks_per_sec); + if (env->CP0_Cause & (1 << CP0Ca_DC)) + return env->CP0_Count; + else + return env->CP0_Count + + (uint32_t)muldiv64(qemu_get_clock(vm_clock), + 100 * 1000 * 1000, ticks_per_sec); } void cpu_mips_store_count (CPUState *env, uint32_t count) @@ -63,7 +66,19 @@ void cpu_mips_store_compare (CPUState *env, uint32_t value) cpu_mips_update_count(env, cpu_mips_get_count(env)); if ((env->CP0_Config0 & (0x7 << CP0C0_AR)) == (1 << CP0C0_AR)) env->CP0_Cause &= ~(1 << CP0Ca_TI); - cpu_mips_irq_request(env, 7, 0); + qemu_irq_lower(env->irq[(env->CP0_IntCtl >> CP0IntCtl_IPTI) & 0x7]); +} + +void cpu_mips_start_count(CPUState *env) +{ + cpu_mips_store_count(env, env->CP0_Count); +} + +void cpu_mips_stop_count(CPUState *env) +{ + /* Store the current value */ + env->CP0_Count += (uint32_t)muldiv64(qemu_get_clock(vm_clock), + 100 * 1000 * 1000, ticks_per_sec); } static void mips_timer_cb (void *opaque) @@ -76,10 +91,14 @@ static void mips_timer_cb (void *opaque) fprintf(logfile, "%s\n", __func__); } #endif + + if (env->CP0_Cause & (1 << CP0Ca_DC)) + return; + cpu_mips_update_count(env, cpu_mips_get_count(env)); if ((env->CP0_Config0 & (0x7 << CP0C0_AR)) == (1 << CP0C0_AR)) env->CP0_Cause |= 1 << CP0Ca_TI; - cpu_mips_irq_request(env, 7, 1); + qemu_irq_raise(env->irq[(env->CP0_IntCtl >> CP0IntCtl_IPTI) & 0x7]); } void cpu_mips_clock_init (CPUState *env)