From patchwork Thu Jul 11 17:01:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 258603 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4E6C52C0359 for ; Fri, 12 Jul 2013 04:39:16 +1000 (EST) Received: from localhost ([::1]:35534 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UxKMd-0000jd-E2 for incoming@patchwork.ozlabs.org; Thu, 11 Jul 2013 13:09:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42765) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UxKFJ-0001BF-Vj for qemu-devel@nongnu.org; Thu, 11 Jul 2013 13:01:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UxKFE-0001PD-Gz for qemu-devel@nongnu.org; Thu, 11 Jul 2013 13:01:33 -0400 Received: from cantor2.suse.de ([195.135.220.15]:54967 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UxKFE-0001Od-9u; Thu, 11 Jul 2013 13:01:28 -0400 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 8EEABA5464; Thu, 11 Jul 2013 19:01:26 +0200 (CEST) From: Alexander Graf To: qemu-devel@nongnu.org Date: Thu, 11 Jul 2013 19:01:24 +0200 Message-Id: <1373562085-29728-22-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1373562085-29728-1-git-send-email-agraf@suse.de> References: <1373562085-29728-1-git-send-email-agraf@suse.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 195.135.220.15 Cc: Blue Swirl , qemu-ppc@nongnu.org, Aurelien Jarno Subject: [Qemu-devel] [PATCH 21/22] PPC: Add timer handler for newworld mac-io X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Mac OS X accesses fancy timer registers inside of the mac-io on bootup. These really should be ticking at the mac-io bus frequency, but I don't see anyone upset when we just make them as fast as we want to. With this patch on top of my previous patch queue and latest OpenBIOS I am able to boot Mac OS X 10.4 with -M mac99. Signed-off-by: Alexander Graf --- hw/misc/macio/macio.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/hw/misc/macio/macio.c b/hw/misc/macio/macio.c index 6459bc1..c0d0bf7 100644 --- a/hw/misc/macio/macio.c +++ b/hw/misc/macio/macio.c @@ -234,11 +234,39 @@ static void macio_oldworld_init(Object *obj) } } +static void timer_write(void *opaque, hwaddr addr, uint64_t value, + unsigned size) +{ +} + +static uint64_t timer_read(void *opaque, hwaddr addr, unsigned size) +{ + uint32_t value = 0; + + switch (addr) { + case 0x38: + value = qemu_get_clock_ns(vm_clock); + break; + case 0x3c: + value = qemu_get_clock_ns(vm_clock) >> 32; + break; + } + + return value; +} + +static const MemoryRegionOps timer_ops = { + .read = timer_read, + .write = timer_write, + .endianness = DEVICE_NATIVE_ENDIAN, +}; + static int macio_newworld_initfn(PCIDevice *d) { MacIOState *s = MACIO(d); NewWorldMacIOState *ns = NEWWORLD_MACIO(d); SysBusDevice *sysbus_dev; + MemoryRegion *timer_memory = g_new(MemoryRegion, 1); int i; int cur_irq = 0; int ret = macio_common_initfn(d); @@ -265,6 +293,11 @@ static int macio_newworld_initfn(PCIDevice *d) } } + /* Timer */ + memory_region_init_io(timer_memory, OBJECT(s), &timer_ops, NULL, "timer", + 0x1000); + memory_region_add_subregion(&s->bar, 0x15000, timer_memory); + return 0; }