diff options
author | Igor V. Kovalenko <igor.v.kovalenko@gmail.com> | 2010-01-28 00:00:53 +0300 |
---|---|---|
committer | Blue Swirl <blauwirbel@gmail.com> | 2010-01-27 21:21:57 +0000 |
commit | 8f4efc55887957f7ca7d87d4a6b58463cfc9d0d6 (patch) | |
tree | cac494047ad326969d34cf031df75df424561c1c /target-sparc | |
parent | 4f690853bb3053acc6de034b15170894afd9da4e (diff) |
sparc64: reimplement tick timers v4
sparc64 timer has tick counter which can be set and read,
and tick compare value used as deadline to fire timer interrupt.
The timer is not used as periodic timer, instead deadline
is set each time new timer interrupt is needed.
v3 -> v4:
- coding style
v2 -> v3:
- added missing timer debug output macro
- CPUTimer struct and typedef moved to cpu.h
- change CPU_SAVE_VERSION to 6, older save formats not supported
v1 -> v2:
- new conversion helpers cpu_to_timer_ticks and timer_to_cpu_ticks
- save offset from clock source to implement cpu_tick_set_count
- renamed struct sun4u_timer to CPUTimer
- load and save cpu timers
v0 -> v1:
- coding style
Signed-off-by: Igor V. Kovalenko <igor.v.kovalenko@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'target-sparc')
-rw-r--r-- | target-sparc/cpu.h | 28 | ||||
-rw-r--r-- | target-sparc/machine.c | 14 |
2 files changed, 29 insertions, 13 deletions
diff --git a/target-sparc/cpu.h b/target-sparc/cpu.h index 842a2f444..5980deb6a 100644 --- a/target-sparc/cpu.h +++ b/target-sparc/cpu.h @@ -292,6 +292,22 @@ typedef struct SparcTLBEntry { uint64_t tte; } SparcTLBEntry; +struct CPUTimer +{ + const char *name; + uint32_t frequency; + uint32_t disabled; + uint64_t disabled_mask; + int64_t clock_offset; + struct QEMUTimer *qtimer; +}; + +typedef struct CPUTimer CPUTimer; + +struct QEMUFile; +void cpu_put_timer(struct QEMUFile *f, CPUTimer *s); +void cpu_get_timer(struct QEMUFile *f, CPUTimer *s); + typedef struct CPUSPARCState { target_ulong gregs[8]; /* general registers */ target_ulong *regwptr; /* pointer to current register window */ @@ -393,14 +409,14 @@ typedef struct CPUSPARCState { uint64_t mgregs[8]; /* mmu general registers */ uint64_t fprs; uint64_t tick_cmpr, stick_cmpr; - void *tick, *stick; + CPUTimer *tick, *stick; #define TICK_NPT_MASK 0x8000000000000000ULL #define TICK_INT_DIS 0x8000000000000000ULL uint64_t gsr; uint32_t gl; // UA2005 /* UA 2005 hyperprivileged registers */ uint64_t hpstate, htstate[MAXTL_MAX], hintp, htba, hver, hstick_cmpr, ssr; - void *hstick; // UA 2005 + CPUTimer *hstick; // UA 2005 uint32_t softint; #define SOFTINT_TIMER 1 #define SOFTINT_STIMER (1 << 16) @@ -536,7 +552,7 @@ int cpu_sparc_signal_handler(int host_signum, void *pinfo, void *puc); #define cpu_signal_handler cpu_sparc_signal_handler #define cpu_list sparc_cpu_list -#define CPU_SAVE_VERSION 5 +#define CPU_SAVE_VERSION 6 /* MMU modes definitions */ #define MMU_MODE0_SUFFIX _user @@ -615,9 +631,9 @@ static inline void cpu_clone_regs(CPUState *env, target_ulong newsp) #ifdef TARGET_SPARC64 /* sun4u.c */ -void cpu_tick_set_count(void *opaque, uint64_t count); -uint64_t cpu_tick_get_count(void *opaque); -void cpu_tick_set_limit(void *opaque, uint64_t limit); +void cpu_tick_set_count(CPUTimer *timer, uint64_t count); +uint64_t cpu_tick_get_count(CPUTimer *timer); +void cpu_tick_set_limit(CPUTimer *timer, uint64_t limit); trap_state* cpu_tsptr(CPUState* env); #endif diff --git a/target-sparc/machine.c b/target-sparc/machine.c index c7c03b63c..4b87ec6d9 100644 --- a/target-sparc/machine.c +++ b/target-sparc/machine.c @@ -84,8 +84,8 @@ void cpu_save(QEMUFile *f, void *opaque) qemu_put_be64s(f, &env->fprs); qemu_put_be64s(f, &env->tick_cmpr); qemu_put_be64s(f, &env->stick_cmpr); - qemu_put_ptimer(f, env->tick); - qemu_put_ptimer(f, env->stick); + cpu_put_timer(f, env->tick); + cpu_put_timer(f, env->stick); qemu_put_be64s(f, &env->gsr); qemu_put_be32s(f, &env->gl); qemu_put_be64s(f, &env->hpstate); @@ -96,7 +96,7 @@ void cpu_save(QEMUFile *f, void *opaque) qemu_put_be64s(f, &env->hver); qemu_put_be64s(f, &env->hstick_cmpr); qemu_put_be64s(f, &env->ssr); - qemu_put_ptimer(f, env->hstick); + cpu_put_timer(f, env->hstick); #endif } @@ -106,7 +106,7 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id) int i; uint32_t tmp; - if (version_id != 5) + if (version_id < 6) return -EINVAL; for(i = 0; i < 8; i++) qemu_get_betls(f, &env->gregs[i]); @@ -180,8 +180,8 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id) qemu_get_be64s(f, &env->fprs); qemu_get_be64s(f, &env->tick_cmpr); qemu_get_be64s(f, &env->stick_cmpr); - qemu_get_ptimer(f, env->tick); - qemu_get_ptimer(f, env->stick); + cpu_get_timer(f, env->tick); + cpu_get_timer(f, env->stick); qemu_get_be64s(f, &env->gsr); qemu_get_be32s(f, &env->gl); qemu_get_be64s(f, &env->hpstate); @@ -192,7 +192,7 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id) qemu_get_be64s(f, &env->hver); qemu_get_be64s(f, &env->hstick_cmpr); qemu_get_be64s(f, &env->ssr); - qemu_get_ptimer(f, env->hstick); + cpu_get_timer(f, env->hstick); #endif tlb_flush(env, 1); return 0; |