Skip to content

Commit

Permalink
PPC: mac99: Fix core99 timer frequency
Browse files Browse the repository at this point in the history
There is a special timer in the mac99 machine that we recently started
to emulate. Unfortunately we emulated it in the wrong frequency.

This patch adapts the frequency Mac OS X uses to evaluate results from
this timer, making calculations it bases off of it work.

Signed-off-by: Alexander Graf <agraf@suse.de>
  • Loading branch information
agraf committed Sep 8, 2014
1 parent 6fd33a7 commit d696760
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions hw/misc/macio/macio.c
Expand Up @@ -243,13 +243,18 @@ static void timer_write(void *opaque, hwaddr addr, uint64_t value,
static uint64_t timer_read(void *opaque, hwaddr addr, unsigned size)
{
uint32_t value = 0;
uint64_t systime = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
uint64_t kltime;

kltime = muldiv64(systime, 4194300, get_ticks_per_sec() * 4);
kltime = muldiv64(kltime, 18432000, 1048575);

switch (addr) {
case 0x38:
value = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
value = kltime;
break;
case 0x3c:
value = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) >> 32;
value = kltime >> 32;
break;
}

Expand Down

0 comments on commit d696760

Please sign in to comment.