qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: qemu-ppc@nongnu.org
Cc: programmingkidx@gmail.com, mark.cave-ayland@ilande.co.uk,
	qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 1/5] PPC: mac99: Fix core99 timer frequency
Date: Sun, 13 Jul 2014 18:17:29 +0200	[thread overview]
Message-ID: <1405268253-33465-2-git-send-email-agraf@suse.de> (raw)
In-Reply-To: <1405268253-33465-1-git-send-email-agraf@suse.de>

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>
---
 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

  reply	other threads:[~2014-07-13 16:17 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-13 16:17 [Qemu-devel] [PATCH 0/5] PPC: Mac99 emulation fixes Alexander Graf
2014-07-13 16:17 ` Alexander Graf [this message]
2014-07-13 16:17 ` [Qemu-devel] [PATCH 2/5] PPC: mac_nvram: Remove unused functions Alexander Graf
2014-07-13 16:17 ` [Qemu-devel] [PATCH 3/5] PPC: mac_nvram: Allow 2 and 4 byte accesses Alexander Graf
2014-07-14  6:41   ` Paolo Bonzini
2014-07-14 10:32     ` Alexander Graf
2014-07-14 10:37     ` [Qemu-devel] [PATCH v2 " Alexander Graf
2014-07-13 16:17 ` [Qemu-devel] [PATCH 4/5] PPC: mac_nvram: Split NVRAM into OF and OSX parts Alexander Graf
2014-07-13 16:17 ` [Qemu-devel] [PATCH 5/5] PPC: mac99: Expose NVRAM linearly Alexander Graf
2014-07-13 17:51 ` [Qemu-devel] [PATCH 0/5] PPC: Mac99 emulation fixes Programmingkid
2014-07-13 18:01   ` Alexander Graf
2014-07-14 13:58 ` Mark Cave-Ayland
2014-07-14 14:00   ` Alexander Graf
2014-07-14 14:07     ` Mark Cave-Ayland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1405268253-33465-2-git-send-email-agraf@suse.de \
    --to=agraf@suse.de \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=programmingkidx@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).