From patchwork Mon Dec 16 17:32:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1210691 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47c7qY5GQ6z9sPJ for ; Tue, 17 Dec 2019 04:41:29 +1100 (AEDT) Received: from localhost ([::1]:57922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iguN5-0005Wh-Ar for incoming@patchwork.ozlabs.org; Mon, 16 Dec 2019 12:41:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60956) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iguMT-0005Sd-9i for qemu-devel@nongnu.org; Mon, 16 Dec 2019 12:40:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iguMR-0007yf-TG for qemu-devel@nongnu.org; Mon, 16 Dec 2019 12:40:49 -0500 Received: from indium.canonical.com ([91.189.90.7]:58570) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iguMR-0007v9-MP for qemu-devel@nongnu.org; Mon, 16 Dec 2019 12:40:47 -0500 Received: from loganberry.canonical.com ([91.189.90.37]) by indium.canonical.com with esmtp (Exim 4.86_2 #2 (Debian)) id 1iguMQ-0002ty-3a for ; Mon, 16 Dec 2019 17:40:46 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id 13E0A2E80C3 for ; Mon, 16 Dec 2019 17:40:46 +0000 (UTC) MIME-Version: 1.0 Date: Mon, 16 Dec 2019 17:32:59 -0000 From: Laurent Vivier To: qemu-devel@nongnu.org X-Launchpad-Notification-Type: bug X-Launchpad-Bug: product=qemu; status=New; importance=Undecided; assignee=None; X-Launchpad-Bug-Tags: i2c m68k rtc X-Launchpad-Bug-Information-Type: Public X-Launchpad-Bug-Private: no X-Launchpad-Bug-Security-Vulnerability: no X-Launchpad-Bug-Commenters: dcb314 laurent-vivier philmd X-Launchpad-Bug-Reporter: dcb (dcb314) X-Launchpad-Bug-Modifier: Laurent Vivier (laurent-vivier) References: <157649490094.7480.17075229014510714852.malonedeb@soybean.canonical.com> Message-Id: <157651757955.14847.8048508132237247696.malone@wampee.canonical.com> Subject: [Bug 1856549] Re: qemu-4.2.0/hw/misc/mac_via.c: 2 * bad test ? X-Launchpad-Message-Rationale: Subscriber (QEMU) @qemu-devel-ml X-Launchpad-Message-For: qemu-devel-ml Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="bceb5ef013b87ef7aafe0755545ceb689ca7ac60"; Instance="production-secrets-lazr.conf" X-Launchpad-Hash: a8a7757917469be5290350ff8ee2eae15f0b7ba6 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 91.189.90.7 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Bug 1856549 <1856549@bugs.launchpad.net> Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" I think VIA RTC access method has been implemented earlier (Classic Mac, 1984-1989) than the I2C specification, so I'm not sure we can/should port this to an I2C bus. Specs are (from Apple Macintosh Family Hardware Reference Chapter 2, Classi Macitosh Processor and Control) z0000001 Seconds register 0 (lowest-order byte) z0000101 Seconds register 1 z0001001 Seconds register 2 z0001101 Seconds register 3 (highest-order byte) 00110001 Test register (write-only) 00110101 Write-Protect Register (write-only) z010aa01 RAM address 100aa ($10-$13) (first 20 bytes only) z1aaaa01 RAM address 0aaaa ($00-$0F) (first 20 bytes only) z0111aaa Extended memory designator and sector number (Macintohs 512K enhanced and Macintosh plus only) For a read request, z=1, for a write z=0 The letter a indicates bits whose value depend on what parameter RAM byte you want to address So I think the mask/values should be: diff --git a/hw/misc/mac_via.c b/hw/misc/mac_via.c index f3f130ad96cc..7402cf3f1ee8 100644 --- a/hw/misc/mac_via.c +++ b/hw/misc/mac_via.c @@ -414,7 +414,7 @@ static void via1_rtc_update(MacVIAState *m) int addr = (m->data_out >> 2) & 0x03; m->data_in = v1s->PRAM[addr]; m->data_in_cnt = 8; - } else if ((m->data_out & 0xf3) == 0xa1) { + } else if ((m->data_out & 0xc3) == 0xc1) { /* PRAM address 0x00 -> 0x0f */ int addr = (m->data_out >> 2) & 0x0f; m->data_in = v1s->PRAM[addr]; @@ -460,11 +460,11 @@ static void via1_rtc_update(MacVIAState *m) } else if (m->cmd == 0x35) { /* Write Protect register */ m->wprotect = m->data_out & 1; - } else if ((m->cmd & 0xf3) == 0xa1) { + } else if ((m->cmd & 0xf3) == 0x21) { /* PRAM address 0x10 -> 0x13 */ int addr = (m->cmd >> 2) & 0x03; v1s->PRAM[addr] = m->data_out; - } else if ((m->cmd & 0xf3) == 0xa1) { + } else if ((m->cmd & 0xc3) == 0x41) { /* PRAM address 0x00 -> 0x0f */ int addr = (m->cmd >> 2) & 0x0f; v1s->PRAM[addr] = m->data_out;