From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55189) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X6MTA-0005Xw-PV for qemu-devel@nongnu.org; Sun, 13 Jul 2014 12:17:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X6MT3-0006N5-8Q for qemu-devel@nongnu.org; Sun, 13 Jul 2014 12:17:44 -0400 From: Alexander Graf Date: Sun, 13 Jul 2014 18:17:29 +0200 Message-Id: <1405268253-33465-2-git-send-email-agraf@suse.de> In-Reply-To: <1405268253-33465-1-git-send-email-agraf@suse.de> References: <1405268253-33465-1-git-send-email-agraf@suse.de> Subject: [Qemu-devel] [PATCH 1/5] PPC: mac99: Fix core99 timer frequency List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-ppc@nongnu.org Cc: programmingkidx@gmail.com, mark.cave-ayland@ilande.co.uk, qemu-devel@nongnu.org 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 --- hw/misc/macio/macio.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/misc/macio/macio.c b/hw/misc/macio/macio.c index 47f45f5..35eaa00 100644 --- a/hw/misc/macio/macio.c +++ b/hw/misc/macio/macio.c @@ -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; } -- 1.8.1.4