From patchwork Wed Sep 8 15:35:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1525935 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=) 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 4H4R7W2GPwz9sW5 for ; Thu, 9 Sep 2021 01:36:23 +1000 (AEST) Received: from localhost ([::1]:50404 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNzcb-0003gX-2B for incoming@patchwork.ozlabs.org; Wed, 08 Sep 2021 11:36:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34692) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNzbq-0003fR-Rc for qemu-devel@nongnu.org; Wed, 08 Sep 2021 11:35:34 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:60635) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNzbo-0003nF-LX for qemu-devel@nongnu.org; Wed, 08 Sep 2021 11:35:34 -0400 Received: from quad ([82.142.27.6]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MMoXE-1mgcvG3ZaO-00Ik43; Wed, 08 Sep 2021 17:35:31 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 01/12] mac_via: introduce new VMStateDescription for q800 VIA1 and VIA2 Date: Wed, 8 Sep 2021 17:35:18 +0200 Message-Id: <20210908153529.453843-2-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210908153529.453843-1-laurent@vivier.eu> References: <20210908153529.453843-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:ZjXM0ztxe7yLULyrr/qGZRWI+M6B32nvq75cKi+4f4+Ke2YFzpj t+RO1zfKMXvcdcQHjWL2mIWcFGYmVrqoH841Nz86j+OaymmXS0Nt6AMMQiWBSBIY41jqcTu JZ30WJhDzbRwN0mmOkBxoq9WuB6YMibvME0YKusxvPbVLmVrRIKng4tbe5zv+RrpcP+R13c RPUTc7/KLOn/yDrS9iQag== X-UI-Out-Filterresults: notjunk:1;V03:K0:OZHWX7aRFfE=:YAWmzt2SXNPM8Dt5+1pjjH QS4v8E+6R1LlEOUEn1n9yG7yuYbMyAfJoskIY69TM4v9I4eSYpvob1sFEi8PC9XTCr3dQUTHf l1lkJoX+ZgzcqsNB9DZpsVXbHXehFb9QsMxOtfNsPtSUiAuVpwsHL89CmipMQKqg0eWNTnc7d AxfBip5Wy8IIn9X1IPcR5RU1s/E/VtW2v2GK1D/V7KNF8rlFGdyQ+gmozEZyXgeCDLQTM48lx w0ySkA6kJ7Wpx/fl22Xwl9Eo8bAVlLJzYzuJVQ4g8lsfeaS4Rqjwri7zB5RHG45cEBlI1bYnI MrqyMJeYt8yVrSemF6u/lP9p56Sq2VqzySKPZSDzWRZRjYJZLICW3tOrumoF3HGg0IkYj7FLe VLNupSe1980LGaX6iIWxMRf/TeHyQXwWA60J0ocL2lmt7uXfzZwqIfjANTrtxhmUDLSKZbfla m4emqpUQUJ+YHpnokeWBfWp6nRWNN8Q1gmtogzIfi12qpTFCnrkW0mnOvEc4OYH/NPWGWYrck CrMkLmAa/wChtAQXeewGHP5NaHRR4/rK0J22sXY6+W9vJhDQxVcSgp6SqvnyNGl7o8wpyAroj fEaTM3ZsKYcwPzk9n3kybmodsRlME7ElOU4Lj6bMT5aQgN/tWKiRBQjOTCgd2Yb483spkUiv4 NYj403RABJA/1BtAzrlcHHdF866KKpldSlLA6rahrWETRpwdsUa0TaE5WGTc+LIZIIxDjZ6Kk 5soVqAJSdFE4J98Rsjw1MsymjDjYi76YGosRng== Received-SPF: none client-ip=212.227.126.135; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Cave-Ayland , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Mark Cave-Ayland Move the parent mos6522 objects from vmstate_mac_via into the new VMStateDescription structures to begin the process of splitting MacVIAState into separate VIA1 and VIA2 devices. Signed-off-by: Mark Cave-Ayland Reviewed-by: Laurent Vivier Message-Id: <20210830102447.10806-2-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- hw/misc/mac_via.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/hw/misc/mac_via.c b/hw/misc/mac_via.c index ff0156db76f2..46e65058e029 100644 --- a/hw/misc/mac_via.c +++ b/hw/misc/mac_via.c @@ -1083,16 +1083,12 @@ static const VMStateDescription vmstate_mac_via = { .post_load = mac_via_post_load, .fields = (VMStateField[]) { /* VIAs */ - VMSTATE_STRUCT(mos6522_via1.parent_obj, MacVIAState, 0, vmstate_mos6522, - MOS6522State), VMSTATE_UINT8(mos6522_via1.last_b, MacVIAState), VMSTATE_BUFFER(mos6522_via1.PRAM, MacVIAState), VMSTATE_TIMER_PTR(mos6522_via1.one_second_timer, MacVIAState), VMSTATE_INT64(mos6522_via1.next_second, MacVIAState), VMSTATE_TIMER_PTR(mos6522_via1.sixty_hz_timer, MacVIAState), VMSTATE_INT64(mos6522_via1.next_sixty_hz, MacVIAState), - VMSTATE_STRUCT(mos6522_via2.parent_obj, MacVIAState, 0, vmstate_mos6522, - MOS6522State), /* RTC */ VMSTATE_UINT32(tick_offset, MacVIAState), VMSTATE_UINT8(data_out, MacVIAState), @@ -1156,11 +1152,23 @@ static void mos6522_q800_via1_init(Object *obj) VIA1_IRQ_NB); } +static const VMStateDescription vmstate_q800_via1 = { + .name = "q800-via1", + .version_id = 0, + .minimum_version_id = 0, + .fields = (VMStateField[]) { + VMSTATE_STRUCT(parent_obj, MOS6522Q800VIA1State, 0, vmstate_mos6522, + MOS6522State), + VMSTATE_END_OF_LIST() + } +}; + static void mos6522_q800_via1_class_init(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); dc->reset = mos6522_q800_via1_reset; + dc->vmsd = &vmstate_q800_via1; } static const TypeInfo mos6522_q800_via1_type_info = { @@ -1200,12 +1208,24 @@ static void mos6522_q800_via2_init(Object *obj) VIA2_IRQ_NB); } +static const VMStateDescription vmstate_q800_via2 = { + .name = "q800-via2", + .version_id = 0, + .minimum_version_id = 0, + .fields = (VMStateField[]) { + VMSTATE_STRUCT(parent_obj, MOS6522Q800VIA2State, 0, vmstate_mos6522, + MOS6522State), + VMSTATE_END_OF_LIST() + } +}; + static void mos6522_q800_via2_class_init(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); MOS6522DeviceClass *mdc = MOS6522_CLASS(oc); dc->reset = mos6522_q800_via2_reset; + dc->vmsd = &vmstate_q800_via2; mdc->portB_write = mos6522_q800_via2_portB_write; } From patchwork Wed Sep 8 15:35:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1525936 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=) 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 4H4R7X4dSXz9tD5 for ; Thu, 9 Sep 2021 01:36:24 +1000 (AEST) Received: from localhost ([::1]:50446 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNzcc-0003jq-DC for incoming@patchwork.ozlabs.org; Wed, 08 Sep 2021 11:36:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34712) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNzbs-0003g8-0z for qemu-devel@nongnu.org; Wed, 08 Sep 2021 11:35:36 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:33585) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNzbp-0003nJ-0V for qemu-devel@nongnu.org; Wed, 08 Sep 2021 11:35:35 -0400 Received: from quad ([82.142.27.6]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1M4Je5-1mOGiw16vZ-000OGc; Wed, 08 Sep 2021 17:35:31 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 02/12] mac_via: move last_b variable into q800 VIA1 VMStateDescription Date: Wed, 8 Sep 2021 17:35:19 +0200 Message-Id: <20210908153529.453843-3-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210908153529.453843-1-laurent@vivier.eu> References: <20210908153529.453843-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:xF590kpOC70RrIoDYCLhq6mtLt4v24IoTz3hRlqBHDI5ie6/JNL SgsVecf23ykYl/tyMGeUALN8Zl+KmGxowr6r5dt8wQt6zVDYgfeOkyGdWwWV3/1HOqGHrUK XXN3NiCg5szm9T29CD1pM9TihDRo2bZME4/yuSuwbHkSZpR2ESvGJtzPLIbwSm9rGuL3/UH v4RAhaeXINQyQU4nlnc1g== X-UI-Out-Filterresults: notjunk:1;V03:K0:mfpwD8it+Ks=:BF3BLLoWjgQP2fb1Ur3Zdl 8S99euW31qkJxbe5GTdB706+mgKSD8DKypmLDM4CuLorfDRhBTdI/ZKmrv3IhVKtpl519S6v+ cW9t1EHiwPGcTZRchCv49f8Gq6OXKRTIbjy/pJaYzlBJA4mzRYHKio/HPb6XUCSsc/jwR3+QM KLM6hJmFViHhB+2u6Xh1IeoekVGa721SzptIlAdF4wUY0e90ffY2VSVzwkp4WqZRLt4KyeGxg 3j+OiF3LVF7CwPQPVsMYX3VQOERAXfGja9sWzsyZmsgT0DSX1yj3aSRGUMZtfWrLizAnYV7/i iewAcwMqDjYJATJJgDl9VjDunfVSWtuKWzp4mmQPKQJk1B4+U3/9zbgXVR987ZiwKnjcK4kqL omKmh0WeeETKiMuW2W1LhHciomtQYiE9Rq9MeDXquBGxhJGxeZQDCvch/2hoyt0pOjED/Gq9k ddfFyeZJE3P74T7JLavBd0QwwF8OU4tthnmI3A1sk+HaxWFBkA8qllLjCRYqrykeg4gZnhb72 Kiesn56uvurUi/isYv9JVX94TefPfxK8VVFgvwWC38CDfW3CAGCOKrrSpRbVT+4PidGbSISKu Kv0I1z48tLhMdhDSlEzgfda54iAYRKZWJT+wzA+6VXS+SlSjdFjXl186YzclUnrNdKR0/gbi/ DMP1CpRHeOWK+Vld3moGeGaIwcOWkGqPZYS1rpwhxaBulACnVIGBZw0U6Sme3oP9nvNjbZxlC g4WOhC5tExUX/bRAU4Q6rH7oF3ijANO34MNZoQ== Received-SPF: none client-ip=212.227.126.187; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Cave-Ayland , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Mark Cave-Ayland This variable is already present in MOS6522Q800VIA1State and can be moved immediately into the q800 VIA1 VMStateDescription. Signed-off-by: Mark Cave-Ayland Reviewed-by: Laurent Vivier Message-Id: <20210830102447.10806-3-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- hw/misc/mac_via.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/misc/mac_via.c b/hw/misc/mac_via.c index 46e65058e029..6fb0b9391d92 100644 --- a/hw/misc/mac_via.c +++ b/hw/misc/mac_via.c @@ -1083,7 +1083,6 @@ static const VMStateDescription vmstate_mac_via = { .post_load = mac_via_post_load, .fields = (VMStateField[]) { /* VIAs */ - VMSTATE_UINT8(mos6522_via1.last_b, MacVIAState), VMSTATE_BUFFER(mos6522_via1.PRAM, MacVIAState), VMSTATE_TIMER_PTR(mos6522_via1.one_second_timer, MacVIAState), VMSTATE_INT64(mos6522_via1.next_second, MacVIAState), @@ -1159,6 +1158,7 @@ static const VMStateDescription vmstate_q800_via1 = { .fields = (VMStateField[]) { VMSTATE_STRUCT(parent_obj, MOS6522Q800VIA1State, 0, vmstate_mos6522, MOS6522State), + VMSTATE_UINT8(last_b, MOS6522Q800VIA1State), VMSTATE_END_OF_LIST() } }; From patchwork Wed Sep 8 15:35:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1525937 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=) 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 4H4R7d0dGTz9sW5 for ; Thu, 9 Sep 2021 01:36:29 +1000 (AEST) Received: from localhost ([::1]:50570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNzcg-0003qm-Ri for incoming@patchwork.ozlabs.org; Wed, 08 Sep 2021 11:36:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34742) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNzbt-0003jB-Ne for qemu-devel@nongnu.org; Wed, 08 Sep 2021 11:35:37 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:37645) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNzbp-0003nP-BS for qemu-devel@nongnu.org; Wed, 08 Sep 2021 11:35:37 -0400 Received: from quad ([82.142.27.6]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MORN0-1maYO52t6U-00Pu0X; Wed, 08 Sep 2021 17:35:31 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 03/12] mac_via: move PRAM contents and block backend to MOS6522Q800VIA1State Date: Wed, 8 Sep 2021 17:35:20 +0200 Message-Id: <20210908153529.453843-4-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210908153529.453843-1-laurent@vivier.eu> References: <20210908153529.453843-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:asRxnGSieoomuy4joh1+Ljuo0Ms2XJXShTNpfU9hAGAJ81SmmYC o7MklEEbEz4Z1aoRM/wn5ysus2SyhvBKzoaxMFmBkwYoJs1hEbaaf2bqStzvwIr85UTxq9t 11uj48/pAOLi1D+0kYbbf1w7KkQynxLl0yR7cwYtq/dn8HmQsyrAKgW1BtdJEq/AUPyVY4B n4zqamibwM0SXUjA20b9w== X-UI-Out-Filterresults: notjunk:1;V03:K0:/JpjD/oA8ho=:tH2Wgtb+o2J2vwFBO1FurE Tar5Kx4hAbR56BLyk2PG2n/HQLHWtnFkz3lIoNm6P7MDv5lx6gFDOMeF/1+pqo+2kyE4IZ8Py 4jqhFurzFLrJ6X05pQYwONOMWiiMVmUvVtrMJFrVqxKXUFWvmI6dCqoa8ylkcS19dzR7yc7iy yhBuxCYdY6GNAYUczpqBFQ5uD6LuM4K/T7lDBzqszDm9RlJ5lYk0jPoFkqBgiztuKNQRBr2qE 9DvKuFYyljK8zfG8IJ0QMX30z4sNHVpfyLqvkCCQ8usn6cKppEem0NDfQrwS/42++lH9nLca8 jqbhyTpWLfdBMei3wXIENfZ3N+6CUHZFXlLZhAG7hWR+fImPnLJdbebfyz6dBSHoZWtDr5yNF jhIIu24OrYit1dnJ3rjzflK6ZVJV878GizpYMzFue1ZRQAT0ierOskZMZcG/w2fi++QdeI55P wi6OzK1qqSQDBZwD4ss5XYYDI1BpAL6xXLfJcIZQDeNHDK27Mz7RX+O3krj4B4sTUV8fzYp7V lwkb1sj9pmnbI4ce+RQx7rqXF8Vij06YkuRDljcro6bRboisv6DMUGpwj46Ax14AyzjMhrKYK qgnneyZnrs9KxayYdntnKbNnTxjnxJZZKIEQ3vEoDxo3jDfBRF6wfe+MsExon8DPKivWHdrIZ SPwgTiHNektsWa/ZMQsnPdcVVzyCGwYM3RYm4+K0k6812qebemJ6CXI6ddcW7j93Dfbw3JIzE S0NDbyTiTD9pvdlOEeBee2ED08OKqdaJINmprQ== Received-SPF: none client-ip=212.227.126.133; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Cave-Ayland , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Mark Cave-Ayland The PRAM contents are accessed using clock and data pins on q800 VIA1 port B and so can be moved to MOS6522Q800VIA1State. Signed-off-by: Mark Cave-Ayland Reviewed-by: Laurent Vivier Message-Id: <20210830102447.10806-4-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- include/hw/misc/mac_via.h | 7 +++-- hw/misc/mac_via.c | 59 ++++++++++++++++++++------------------- 2 files changed, 34 insertions(+), 32 deletions(-) diff --git a/include/hw/misc/mac_via.h b/include/hw/misc/mac_via.h index 3058b30685ae..bd1c65d1b9c6 100644 --- a/include/hw/misc/mac_via.h +++ b/include/hw/misc/mac_via.h @@ -40,7 +40,11 @@ struct MOS6522Q800VIA1State { qemu_irq irqs[VIA1_IRQ_NB]; uint8_t last_b; + + /* RTC */ uint8_t PRAM[256]; + BlockBackend *blk; + VMChangeStateEntry *vmstate; /* external timers */ QEMUTimer *one_second_timer; @@ -80,8 +84,6 @@ OBJECT_DECLARE_SIMPLE_TYPE(MacVIAState, MAC_VIA) struct MacVIAState { SysBusDevice busdev; - VMChangeStateEntry *vmstate; - /* MMIO */ MemoryRegion mmio; MemoryRegion via1mem; @@ -101,7 +103,6 @@ struct MacVIAState { uint8_t cmd; int wprotect; int alt; - BlockBackend *blk; /* ADB */ ADBBusState adb_bus; diff --git a/hw/misc/mac_via.c b/hw/misc/mac_via.c index 6fb0b9391d92..abbe99af11f6 100644 --- a/hw/misc/mac_via.c +++ b/hw/misc/mac_via.c @@ -374,11 +374,10 @@ static void via2_irq_request(void *opaque, int irq, int level) } -static void pram_update(MacVIAState *m) +static void pram_update(MOS6522Q800VIA1State *v1s) { - if (m->blk) { - if (blk_pwrite(m->blk, 0, m->mos6522_via1.PRAM, - sizeof(m->mos6522_via1.PRAM), 0) < 0) { + if (v1s->blk) { + if (blk_pwrite(v1s->blk, 0, v1s->PRAM, sizeof(v1s->PRAM), 0) < 0) { qemu_log("pram_update: cannot write to file\n"); } } @@ -556,7 +555,7 @@ static void via1_rtc_update(MacVIAState *m) /* PRAM address 0x00 -> 0x13 */ trace_via1_rtc_cmd_pram_write(m->cmd - REG_PRAM_ADDR, m->data_out); v1s->PRAM[m->cmd - REG_PRAM_ADDR] = m->data_out; - pram_update(m); + pram_update(v1s); m->cmd = REG_EMPTY; break; case REG_PRAM_SECT...REG_PRAM_SECT_LAST: @@ -587,7 +586,7 @@ static void via1_rtc_update(MacVIAState *m) g_assert(REG_PRAM_SECT <= m->cmd && m->cmd <= REG_PRAM_SECT_LAST); sector = m->cmd - REG_PRAM_SECT; v1s->PRAM[sector * 32 + m->alt] = m->data_out; - pram_update(m); + pram_update(v1s); trace_via1_rtc_cmd_pram_sect_write(sector, m->alt, sector * 32 + m->alt, m->data_out); m->alt = REG_EMPTY; @@ -965,6 +964,7 @@ static void mac_via_reset(DeviceState *dev) static void mac_via_realize(DeviceState *dev, Error **errp) { MacVIAState *m = MAC_VIA(dev); + MOS6522Q800VIA1State *v1s = &m->mos6522_via1; MOS6522State *ms; ADBBusState *adb_bus = &m->adb_bus; struct tm tm; @@ -1009,23 +1009,22 @@ static void mac_via_realize(DeviceState *dev, Error **errp) m->adb_data_ready = qdev_get_gpio_in_named(dev, "via1-irq", VIA1_IRQ_ADB_READY_BIT); - if (m->blk) { - int64_t len = blk_getlength(m->blk); + if (v1s->blk) { + int64_t len = blk_getlength(v1s->blk); if (len < 0) { error_setg_errno(errp, -len, "could not get length of backing image"); return; } - ret = blk_set_perm(m->blk, + ret = blk_set_perm(v1s->blk, BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE, BLK_PERM_ALL, errp); if (ret < 0) { return; } - len = blk_pread(m->blk, 0, m->mos6522_via1.PRAM, - sizeof(m->mos6522_via1.PRAM)); - if (len != sizeof(m->mos6522_via1.PRAM)) { + len = blk_pread(v1s->blk, 0, v1s->PRAM, sizeof(v1s->PRAM)); + if (len != sizeof(v1s->PRAM)) { error_setg(errp, "can't read PRAM contents"); return; } @@ -1054,23 +1053,23 @@ static void mac_via_init(Object *obj) TYPE_ADB_BUS, DEVICE(obj), "adb.0"); } -static void postload_update_cb(void *opaque, bool running, RunState state) +static void via1_postload_update_cb(void *opaque, bool running, RunState state) { - MacVIAState *m = MAC_VIA(opaque); + MOS6522Q800VIA1State *v1s = MOS6522_Q800_VIA1(opaque); - qemu_del_vm_change_state_handler(m->vmstate); - m->vmstate = NULL; + qemu_del_vm_change_state_handler(v1s->vmstate); + v1s->vmstate = NULL; - pram_update(m); + pram_update(v1s); } -static int mac_via_post_load(void *opaque, int version_id) +static int via1_post_load(void *opaque, int version_id) { - MacVIAState *m = MAC_VIA(opaque); + MOS6522Q800VIA1State *v1s = MOS6522_Q800_VIA1(opaque); - if (m->blk) { - m->vmstate = qemu_add_vm_change_state_handler(postload_update_cb, - m); + if (v1s->blk) { + v1s->vmstate = qemu_add_vm_change_state_handler( + via1_postload_update_cb, v1s); } return 0; @@ -1080,7 +1079,6 @@ static const VMStateDescription vmstate_mac_via = { .name = "mac-via", .version_id = 2, .minimum_version_id = 2, - .post_load = mac_via_post_load, .fields = (VMStateField[]) { /* VIAs */ VMSTATE_BUFFER(mos6522_via1.PRAM, MacVIAState), @@ -1108,11 +1106,6 @@ static const VMStateDescription vmstate_mac_via = { } }; -static Property mac_via_properties[] = { - DEFINE_PROP_DRIVE("drive", MacVIAState, blk), - DEFINE_PROP_END_OF_LIST(), -}; - static void mac_via_class_init(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); @@ -1120,7 +1113,6 @@ static void mac_via_class_init(ObjectClass *oc, void *data) dc->realize = mac_via_realize; dc->reset = mac_via_reset; dc->vmsd = &vmstate_mac_via; - device_class_set_props(dc, mac_via_properties); } static TypeInfo mac_via_info = { @@ -1155,20 +1147,29 @@ static const VMStateDescription vmstate_q800_via1 = { .name = "q800-via1", .version_id = 0, .minimum_version_id = 0, + .post_load = via1_post_load, .fields = (VMStateField[]) { VMSTATE_STRUCT(parent_obj, MOS6522Q800VIA1State, 0, vmstate_mos6522, MOS6522State), VMSTATE_UINT8(last_b, MOS6522Q800VIA1State), + /* RTC */ + VMSTATE_BUFFER(PRAM, MOS6522Q800VIA1State), VMSTATE_END_OF_LIST() } }; +static Property mos6522_q800_via1_properties[] = { + DEFINE_PROP_DRIVE("drive", MOS6522Q800VIA1State, blk), + DEFINE_PROP_END_OF_LIST(), +}; + static void mos6522_q800_via1_class_init(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); dc->reset = mos6522_q800_via1_reset; dc->vmsd = &vmstate_q800_via1; + device_class_set_props(dc, mos6522_q800_via1_properties); } static const TypeInfo mos6522_q800_via1_type_info = { From patchwork Wed Sep 8 15:35:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1525947 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=) 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 4H4RLH60PDz9sW5 for ; Thu, 9 Sep 2021 01:45:43 +1000 (AEST) Received: from localhost ([::1]:52254 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNzld-00076G-J3 for incoming@patchwork.ozlabs.org; Wed, 08 Sep 2021 11:45:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34826) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNzc1-0004DV-QB for qemu-devel@nongnu.org; Wed, 08 Sep 2021 11:35:45 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:48129) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNzbz-0003vu-8r for qemu-devel@nongnu.org; Wed, 08 Sep 2021 11:35:45 -0400 Received: from quad ([82.142.27.6]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MatZr-1mvfnr1NoR-00cTAy; Wed, 08 Sep 2021 17:35:32 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 04/12] mac_via: move PRAM/RTC variables to MOS6522Q800VIA1State Date: Wed, 8 Sep 2021 17:35:21 +0200 Message-Id: <20210908153529.453843-5-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210908153529.453843-1-laurent@vivier.eu> References: <20210908153529.453843-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:8OEquTTRugy7GyWEDEAfrOoWRwEe+5Pmf/3Z80p/cLTMgAsHMFq 0AJTl89vkDcrY7XorlXvNFIwCmC7i+cS37ayHYy+mAlIvXICaRRPsNrKv0G9xYL1yHFplbG o911a5jXDVnjUH4NiiT2/FgsbvcXj6LVQzr5+Ydpv+/oAOWZc4O7Yaa9ZJfEqo46GLy850g dTvi37uel0SoBk90XQtzQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:dxUWszuQdkc=:pt3JYUzJeCiuE//GzFhm3v 5q4ZHeqNWrZWvQMAPCqU2iDUUzl6p+ERkhuzdfA4C2BalfMSaWkSBIhAFkJ0U+KiRafUyFCKk 27zw6FJ51aAIlniDN/CZXAh2vh8GOCZuhI+IADFAGkWjMiB7wP87JbAmlUN4MQG6OWpaycfsV GmFNAUQrc1v0oW7ypRV1cTbCjoNK20bda145JF/2/AdRMWVNTKW8wC5bpuBTuBC0NjVbYr5J6 vt07SjOK8TZJDUsjYEtICYR5OAyFIXrlGjIap51gVBOQSLkm560h/ht5fDjMbASlHksfh1dBe XGC1f8Oq2ebtWBohK2UCSinPyqNIs4kZCFqgQjP8hQ4N60bB6+SFCgjez4U+gUohC9Tpq2bia bgtZFxIQCdt1F/NUrQh8/0lWmvp6RU9REJJF5P84w0IrH1ATjhkRv9gALNd2jADbBa86LhvN7 nxXcUoHr6lMmcJy8WTIIYxGBWZsPQgZrjtRbkR7fsJaiC2NhHgm0K6P6rz6tLGmpzej6CdBVT PmWBhzJs4a58f84kGC7fcDQulV0lE24M2uoPMcjgsVE/jfMqesHbQowA9zXZU4AHn9kUUidoF lRn0uHqrPIdfUhRt8a3qZpIDfP5MdbwPdpDPf444GT/oxIvXHyw8zKIUAvgL5jM+Kms5dAGFn 8N64e/rvRUwsf//1o/YUqeyZefgGgxhhmbau30carsxHpubPTR4FyKhdNU6Fj0oAsaEq4LXMm /1akyez+ZvAEd+jhNLrNvUTLarRHorN79Bh/4g== Received-SPF: none client-ip=212.227.126.131; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Cave-Ayland , Laurent Vivier , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Mark Cave-Ayland The PRAM/RTC is accessed using clock and data pins on q800 VIA1 port B and so can be moved to MOS6522Q800VIA1State. Signed-off-by: Mark Cave-Ayland Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20210830102447.10806-5-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- include/hw/misc/mac_via.h | 21 +++--- hw/misc/mac_via.c | 135 +++++++++++++++++++------------------- 2 files changed, 77 insertions(+), 79 deletions(-) diff --git a/include/hw/misc/mac_via.h b/include/hw/misc/mac_via.h index bd1c65d1b9c6..b2c499ed6b5b 100644 --- a/include/hw/misc/mac_via.h +++ b/include/hw/misc/mac_via.h @@ -46,6 +46,16 @@ struct MOS6522Q800VIA1State { BlockBackend *blk; VMChangeStateEntry *vmstate; + uint32_t tick_offset; + + uint8_t data_out; + int data_out_cnt; + uint8_t data_in; + uint8_t data_in_cnt; + uint8_t cmd; + int wprotect; + int alt; + /* external timers */ QEMUTimer *one_second_timer; int64_t next_second; @@ -93,17 +103,6 @@ struct MacVIAState { MOS6522Q800VIA1State mos6522_via1; MOS6522Q800VIA2State mos6522_via2; - /* RTC */ - uint32_t tick_offset; - - uint8_t data_out; - int data_out_cnt; - uint8_t data_in; - uint8_t data_in_cnt; - uint8_t cmd; - int wprotect; - int alt; - /* ADB */ ADBBusState adb_bus; qemu_irq adb_data_ready; diff --git a/hw/misc/mac_via.c b/hw/misc/mac_via.c index abbe99af11f6..3978e6b44136 100644 --- a/hw/misc/mac_via.c +++ b/hw/misc/mac_via.c @@ -433,9 +433,8 @@ static int via1_rtc_compact_cmd(uint8_t value) return REG_INVALID; } -static void via1_rtc_update(MacVIAState *m) +static void via1_rtc_update(MOS6522Q800VIA1State *v1s) { - MOS6522Q800VIA1State *v1s = &m->mos6522_via1; MOS6522State *s = MOS6522(v1s); int cmd, sector, addr; uint32_t time; @@ -447,40 +446,40 @@ static void via1_rtc_update(MacVIAState *m) if (s->dirb & VIA1B_vRTCData) { /* send bits to the RTC */ if (!(v1s->last_b & VIA1B_vRTCClk) && (s->b & VIA1B_vRTCClk)) { - m->data_out <<= 1; - m->data_out |= s->b & VIA1B_vRTCData; - m->data_out_cnt++; + v1s->data_out <<= 1; + v1s->data_out |= s->b & VIA1B_vRTCData; + v1s->data_out_cnt++; } - trace_via1_rtc_update_data_out(m->data_out_cnt, m->data_out); + trace_via1_rtc_update_data_out(v1s->data_out_cnt, v1s->data_out); } else { - trace_via1_rtc_update_data_in(m->data_in_cnt, m->data_in); + trace_via1_rtc_update_data_in(v1s->data_in_cnt, v1s->data_in); /* receive bits from the RTC */ if ((v1s->last_b & VIA1B_vRTCClk) && !(s->b & VIA1B_vRTCClk) && - m->data_in_cnt) { + v1s->data_in_cnt) { s->b = (s->b & ~VIA1B_vRTCData) | - ((m->data_in >> 7) & VIA1B_vRTCData); - m->data_in <<= 1; - m->data_in_cnt--; + ((v1s->data_in >> 7) & VIA1B_vRTCData); + v1s->data_in <<= 1; + v1s->data_in_cnt--; } return; } - if (m->data_out_cnt != 8) { + if (v1s->data_out_cnt != 8) { return; } - m->data_out_cnt = 0; + v1s->data_out_cnt = 0; - trace_via1_rtc_internal_status(m->cmd, m->alt, m->data_out); + trace_via1_rtc_internal_status(v1s->cmd, v1s->alt, v1s->data_out); /* first byte: it's a command */ - if (m->cmd == REG_EMPTY) { + if (v1s->cmd == REG_EMPTY) { - cmd = via1_rtc_compact_cmd(m->data_out); + cmd = via1_rtc_compact_cmd(v1s->data_out); trace_via1_rtc_internal_cmd(cmd); if (cmd == REG_INVALID) { - trace_via1_rtc_cmd_invalid(m->data_out); + trace_via1_rtc_cmd_invalid(v1s->data_out); return; } @@ -492,20 +491,20 @@ static void via1_rtc_update(MacVIAState *m) * register 3 is highest-order byte */ - time = m->tick_offset + (qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + time = v1s->tick_offset + (qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) / NANOSECONDS_PER_SECOND); trace_via1_rtc_internal_time(time); - m->data_in = (time >> ((cmd & 0x03) << 3)) & 0xff; - m->data_in_cnt = 8; + v1s->data_in = (time >> ((cmd & 0x03) << 3)) & 0xff; + v1s->data_in_cnt = 8; trace_via1_rtc_cmd_seconds_read((cmd & 0x7f) - REG_0, - m->data_in); + v1s->data_in); break; case REG_PRAM_ADDR...REG_PRAM_ADDR_LAST: /* PRAM address 0x00 -> 0x13 */ - m->data_in = v1s->PRAM[(cmd & 0x7f) - REG_PRAM_ADDR]; - m->data_in_cnt = 8; + v1s->data_in = v1s->PRAM[(cmd & 0x7f) - REG_PRAM_ADDR]; + v1s->data_in_cnt = 8; trace_via1_rtc_cmd_pram_read((cmd & 0x7f) - REG_PRAM_ADDR, - m->data_in); + v1s->data_in); break; case REG_PRAM_SECT...REG_PRAM_SECT_LAST: /* @@ -513,7 +512,7 @@ static void via1_rtc_update(MacVIAState *m) * the only two-byte read command */ trace_via1_rtc_internal_set_cmd(cmd); - m->cmd = cmd; + v1s->cmd = cmd; break; default: g_assert_not_reached(); @@ -523,9 +522,9 @@ static void via1_rtc_update(MacVIAState *m) } /* this is a write command, needs a parameter */ - if (cmd == REG_WPROTECT || !m->wprotect) { + if (cmd == REG_WPROTECT || !v1s->wprotect) { trace_via1_rtc_internal_set_cmd(cmd); - m->cmd = cmd; + v1s->cmd = cmd; } else { trace_via1_rtc_internal_ignore_cmd(cmd); } @@ -533,46 +532,47 @@ static void via1_rtc_update(MacVIAState *m) } /* second byte: it's a parameter */ - if (m->alt == REG_EMPTY) { - switch (m->cmd & 0x7f) { + if (v1s->alt == REG_EMPTY) { + switch (v1s->cmd & 0x7f) { case REG_0...REG_3: /* seconds register */ /* FIXME */ - trace_via1_rtc_cmd_seconds_write(m->cmd - REG_0, m->data_out); - m->cmd = REG_EMPTY; + trace_via1_rtc_cmd_seconds_write(v1s->cmd - REG_0, v1s->data_out); + v1s->cmd = REG_EMPTY; break; case REG_TEST: /* device control: nothing to do */ - trace_via1_rtc_cmd_test_write(m->data_out); - m->cmd = REG_EMPTY; + trace_via1_rtc_cmd_test_write(v1s->data_out); + v1s->cmd = REG_EMPTY; break; case REG_WPROTECT: /* Write Protect register */ - trace_via1_rtc_cmd_wprotect_write(m->data_out); - m->wprotect = !!(m->data_out & 0x80); - m->cmd = REG_EMPTY; + trace_via1_rtc_cmd_wprotect_write(v1s->data_out); + v1s->wprotect = !!(v1s->data_out & 0x80); + v1s->cmd = REG_EMPTY; break; case REG_PRAM_ADDR...REG_PRAM_ADDR_LAST: /* PRAM address 0x00 -> 0x13 */ - trace_via1_rtc_cmd_pram_write(m->cmd - REG_PRAM_ADDR, m->data_out); - v1s->PRAM[m->cmd - REG_PRAM_ADDR] = m->data_out; + trace_via1_rtc_cmd_pram_write(v1s->cmd - REG_PRAM_ADDR, + v1s->data_out); + v1s->PRAM[v1s->cmd - REG_PRAM_ADDR] = v1s->data_out; pram_update(v1s); - m->cmd = REG_EMPTY; + v1s->cmd = REG_EMPTY; break; case REG_PRAM_SECT...REG_PRAM_SECT_LAST: - addr = (m->data_out >> 2) & 0x1f; - sector = (m->cmd & 0x7f) - REG_PRAM_SECT; - if (m->cmd & 0x80) { + addr = (v1s->data_out >> 2) & 0x1f; + sector = (v1s->cmd & 0x7f) - REG_PRAM_SECT; + if (v1s->cmd & 0x80) { /* it's a read */ - m->data_in = v1s->PRAM[sector * 32 + addr]; - m->data_in_cnt = 8; + v1s->data_in = v1s->PRAM[sector * 32 + addr]; + v1s->data_in_cnt = 8; trace_via1_rtc_cmd_pram_sect_read(sector, addr, sector * 32 + addr, - m->data_in); - m->cmd = REG_EMPTY; + v1s->data_in); + v1s->cmd = REG_EMPTY; } else { /* it's a write, we need one more parameter */ trace_via1_rtc_internal_set_alt(addr, sector, addr); - m->alt = addr; + v1s->alt = addr; } break; default: @@ -583,14 +583,14 @@ static void via1_rtc_update(MacVIAState *m) } /* third byte: it's the data of a REG_PRAM_SECT write */ - g_assert(REG_PRAM_SECT <= m->cmd && m->cmd <= REG_PRAM_SECT_LAST); - sector = m->cmd - REG_PRAM_SECT; - v1s->PRAM[sector * 32 + m->alt] = m->data_out; + g_assert(REG_PRAM_SECT <= v1s->cmd && v1s->cmd <= REG_PRAM_SECT_LAST); + sector = v1s->cmd - REG_PRAM_SECT; + v1s->PRAM[sector * 32 + v1s->alt] = v1s->data_out; pram_update(v1s); - trace_via1_rtc_cmd_pram_sect_write(sector, m->alt, sector * 32 + m->alt, - m->data_out); - m->alt = REG_EMPTY; - m->cmd = REG_EMPTY; + trace_via1_rtc_cmd_pram_sect_write(sector, v1s->alt, sector * 32 + v1s->alt, + v1s->data_out); + v1s->alt = REG_EMPTY; + v1s->cmd = REG_EMPTY; } static void adb_via_poll(void *opaque) @@ -903,7 +903,7 @@ static void mos6522_q800_via1_write(void *opaque, hwaddr addr, uint64_t val, switch (addr) { case VIA_REG_B: - via1_rtc_update(m); + via1_rtc_update(v1s); via1_adb_update(m); v1s->last_b = ms->b; @@ -953,12 +953,13 @@ static const MemoryRegionOps mos6522_q800_via2_ops = { static void mac_via_reset(DeviceState *dev) { MacVIAState *m = MAC_VIA(dev); + MOS6522Q800VIA1State *v1s = &m->mos6522_via1; ADBBusState *adb_bus = &m->adb_bus; adb_set_autopoll_enabled(adb_bus, true); - m->cmd = REG_EMPTY; - m->alt = REG_EMPTY; + v1s->cmd = REG_EMPTY; + v1s->alt = REG_EMPTY; } static void mac_via_realize(DeviceState *dev, Error **errp) @@ -1003,7 +1004,7 @@ static void mac_via_realize(DeviceState *dev, Error **errp) via1_sixty_hz_update(&m->mos6522_via1); qemu_get_timedate(&tm, 0); - m->tick_offset = (uint32_t)mktimegm(&tm) + RTC_OFFSET; + v1s->tick_offset = (uint32_t)mktimegm(&tm) + RTC_OFFSET; adb_register_autopoll_callback(adb_bus, adb_via_poll, m); m->adb_data_ready = qdev_get_gpio_in_named(dev, "via1-irq", @@ -1081,20 +1082,10 @@ static const VMStateDescription vmstate_mac_via = { .minimum_version_id = 2, .fields = (VMStateField[]) { /* VIAs */ - VMSTATE_BUFFER(mos6522_via1.PRAM, MacVIAState), VMSTATE_TIMER_PTR(mos6522_via1.one_second_timer, MacVIAState), VMSTATE_INT64(mos6522_via1.next_second, MacVIAState), VMSTATE_TIMER_PTR(mos6522_via1.sixty_hz_timer, MacVIAState), VMSTATE_INT64(mos6522_via1.next_sixty_hz, MacVIAState), - /* RTC */ - VMSTATE_UINT32(tick_offset, MacVIAState), - VMSTATE_UINT8(data_out, MacVIAState), - VMSTATE_INT32(data_out_cnt, MacVIAState), - VMSTATE_UINT8(data_in, MacVIAState), - VMSTATE_UINT8(data_in_cnt, MacVIAState), - VMSTATE_UINT8(cmd, MacVIAState), - VMSTATE_INT32(wprotect, MacVIAState), - VMSTATE_INT32(alt, MacVIAState), /* ADB */ VMSTATE_INT32(adb_data_in_size, MacVIAState), VMSTATE_INT32(adb_data_in_index, MacVIAState), @@ -1154,6 +1145,14 @@ static const VMStateDescription vmstate_q800_via1 = { VMSTATE_UINT8(last_b, MOS6522Q800VIA1State), /* RTC */ VMSTATE_BUFFER(PRAM, MOS6522Q800VIA1State), + VMSTATE_UINT32(tick_offset, MOS6522Q800VIA1State), + VMSTATE_UINT8(data_out, MOS6522Q800VIA1State), + VMSTATE_INT32(data_out_cnt, MOS6522Q800VIA1State), + VMSTATE_UINT8(data_in, MOS6522Q800VIA1State), + VMSTATE_UINT8(data_in_cnt, MOS6522Q800VIA1State), + VMSTATE_UINT8(cmd, MOS6522Q800VIA1State), + VMSTATE_INT32(wprotect, MOS6522Q800VIA1State), + VMSTATE_INT32(alt, MOS6522Q800VIA1State), VMSTATE_END_OF_LIST() } }; From patchwork Wed Sep 8 15:35:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1525951 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=) 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 4H4RPm415lz9sW5 for ; Thu, 9 Sep 2021 01:48:44 +1000 (AEST) Received: from localhost ([::1]:60580 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNzoY-0004Lx-CX for incoming@patchwork.ozlabs.org; Wed, 08 Sep 2021 11:48:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34834) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNzc2-0004FV-3b for qemu-devel@nongnu.org; Wed, 08 Sep 2021 11:35:46 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:57983) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNzbz-0003w7-CQ for qemu-devel@nongnu.org; Wed, 08 Sep 2021 11:35:45 -0400 Received: from quad ([82.142.27.6]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MFsdD-1mAXE341QF-00HPZ2; Wed, 08 Sep 2021 17:35:33 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 05/12] mac_via: move ADB variables to MOS6522Q800VIA1State Date: Wed, 8 Sep 2021 17:35:22 +0200 Message-Id: <20210908153529.453843-6-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210908153529.453843-1-laurent@vivier.eu> References: <20210908153529.453843-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:nHQmfAZUuZh7bO3TQBPyhqWl03kGc1Y0IWLugypBLoAiNjLrt/8 p5mUZj3UZ8k4dgHANYgf/Q7odrezL5z7gBzSsEKjqiWOTC/eBuMmFL2ADijQs+u6qUutefn DqdoySXIBHiTz0l0hJgwgD3pEBgPhacC9p2FcKFsLXjNCQv5NkHqtQnWIH8ox9A9W+9OtAJ rRg4VizsNYiX4NWqThXZw== X-UI-Out-Filterresults: notjunk:1;V03:K0:iyKBu01v1v4=:HHD3BTEX/GTsAs79ozzRLr 7rkVEMvgSF3MHeBb0KwS1as1Qn2kFM2n3qKxikPtc9kTBoYh8Ia66H/sqZxDkCX2BTyT4Tewz dR7ECrF+424V2QdSkpwfCgoK5hUArsorABCrklX1OjD7w3w/loMuCHnIx7Cx4YmxFdbmx1I4c PGHZ3f0/StlyvF//yagSInLlLlNMQ6omxe9MIgqiAmN6tsxOJZLFFlTzkRKcLfu4wC8YqLKBX AU5R9inuTOqdSfoT/Lo6KFiPiJ/cZJxoG8eZaloPW7aeRxWaKwWSjqjDZNralvxTwvD4YjpN+ i5p1a275sWRQLJlvJgD5UdVtHvl/mEGxQDyIpBcr7PYFch/ZtaRi1gWggnWIyXOWo4IvmWn5N cisbjKX9dyxvC/Qpx89DlZRV2s5WHojpVtqAaXkLSI/mJ50aOmhqqVJrciVNqNX+TZe46G3M6 E5tiZrvxrVqm81Xiv527nSxxRBwY8ecTecYcDZQhttSCGxx/r75emEW8SsNWIl08AyTV+S+Zz LJFusGfNetLITchud4Dpaoi3KFRGoH1YEiA5xnHL4UdFRu4aHxOtv97SjmegfRGIrm//aIbW0 /pJMcR1k5XnhieDbYWVZZsqa74uibAcSemB1Iju+RIifeYRPZNU1UxjpCizwxT6FcRt3I6MTX LQyv6HlhvoAJ1/B4tRuHan8CQQhcN6E426t96r87N2Iz7bYB1Ai1rKOoA5iz9vE6MSuFm55gD 8wq0XSebvqdFFbQOwytFVqIt4LItQDg0fuhnIQ== Received-SPF: none client-ip=212.227.126.134; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Cave-Ayland , Laurent Vivier , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Mark Cave-Ayland The ADB is accessed using clock and data pins on q800 VIA1 port B and so can be moved to MOS6522Q800VIA1State. Signed-off-by: Mark Cave-Ayland Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20210830102447.10806-6-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- include/hw/misc/mac_via.h | 20 ++--- hw/m68k/q800.c | 6 +- hw/misc/mac_via.c | 169 +++++++++++++++++++------------------- 3 files changed, 96 insertions(+), 99 deletions(-) diff --git a/include/hw/misc/mac_via.h b/include/hw/misc/mac_via.h index b2c499ed6b5b..182dcb742235 100644 --- a/include/hw/misc/mac_via.h +++ b/include/hw/misc/mac_via.h @@ -56,6 +56,16 @@ struct MOS6522Q800VIA1State { int wprotect; int alt; + /* ADB */ + ADBBusState adb_bus; + qemu_irq adb_data_ready; + int adb_data_in_size; + int adb_data_in_index; + int adb_data_out_index; + uint8_t adb_data_in[128]; + uint8_t adb_data_out[16]; + uint8_t adb_autopoll_cmd; + /* external timers */ QEMUTimer *one_second_timer; int64_t next_second; @@ -102,16 +112,6 @@ struct MacVIAState { /* VIAs */ MOS6522Q800VIA1State mos6522_via1; MOS6522Q800VIA2State mos6522_via2; - - /* ADB */ - ADBBusState adb_bus; - qemu_irq adb_data_ready; - int adb_data_in_size; - int adb_data_in_index; - int adb_data_out_index; - uint8_t adb_data_in[128]; - uint8_t adb_data_out[16]; - uint8_t adb_autopoll_cmd; }; #endif diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c index ac0a13060b4a..e14f68f19b13 100644 --- a/hw/m68k/q800.c +++ b/hw/m68k/q800.c @@ -225,7 +225,7 @@ static void q800_init(MachineState *machine) hwaddr parameters_base; CPUState *cs; DeviceState *dev; - DeviceState *via_dev; + DeviceState *via_dev, *via1_dev; DeviceState *escc_orgate; SysBusESPState *sysbus_esp; ESPState *esp; @@ -285,8 +285,8 @@ static void q800_init(MachineState *machine) qdev_connect_gpio_out_named(DEVICE(sysbus), "irq", 1, qdev_get_gpio_in(glue, 1)); - - adb_bus = qdev_get_child_bus(via_dev, "adb.0"); + via1_dev = DEVICE(MOS6522_Q800_VIA1(&MAC_VIA(via_dev)->mos6522_via1)); + adb_bus = qdev_get_child_bus(DEVICE(via1_dev), "adb.0"); dev = qdev_new(TYPE_ADB_KEYBOARD); qdev_realize_and_unref(dev, adb_bus, &error_fatal); dev = qdev_new(TYPE_ADB_MOUSE); diff --git a/hw/misc/mac_via.c b/hw/misc/mac_via.c index 3978e6b44136..b4a65480fdc8 100644 --- a/hw/misc/mac_via.c +++ b/hw/misc/mac_via.c @@ -595,10 +595,9 @@ static void via1_rtc_update(MOS6522Q800VIA1State *v1s) static void adb_via_poll(void *opaque) { - MacVIAState *m = opaque; - MOS6522Q800VIA1State *v1s = MOS6522_Q800_VIA1(&m->mos6522_via1); + MOS6522Q800VIA1State *v1s = MOS6522_Q800_VIA1(opaque); MOS6522State *s = MOS6522(v1s); - ADBBusState *adb_bus = &m->adb_bus; + ADBBusState *adb_bus = &v1s->adb_bus; uint8_t obuf[9]; uint8_t *data = &s->sr; int olen; @@ -610,50 +609,50 @@ static void adb_via_poll(void *opaque) */ adb_autopoll_block(adb_bus); - if (m->adb_data_in_size > 0 && m->adb_data_in_index == 0) { + if (v1s->adb_data_in_size > 0 && v1s->adb_data_in_index == 0) { /* * For older Linux kernels that switch to IDLE mode after sending the * ADB command, detect if there is an existing response and return that * as a a "fake" autopoll reply or bus timeout accordingly */ - *data = m->adb_data_out[0]; - olen = m->adb_data_in_size; + *data = v1s->adb_data_out[0]; + olen = v1s->adb_data_in_size; s->b &= ~VIA1B_vADBInt; - qemu_irq_raise(m->adb_data_ready); + qemu_irq_raise(v1s->adb_data_ready); } else { /* * Otherwise poll as normal */ - m->adb_data_in_index = 0; - m->adb_data_out_index = 0; + v1s->adb_data_in_index = 0; + v1s->adb_data_out_index = 0; olen = adb_poll(adb_bus, obuf, adb_bus->autopoll_mask); if (olen > 0) { /* Autopoll response */ *data = obuf[0]; olen--; - memcpy(m->adb_data_in, &obuf[1], olen); - m->adb_data_in_size = olen; + memcpy(v1s->adb_data_in, &obuf[1], olen); + v1s->adb_data_in_size = olen; s->b &= ~VIA1B_vADBInt; - qemu_irq_raise(m->adb_data_ready); + qemu_irq_raise(v1s->adb_data_ready); } else { - *data = m->adb_autopoll_cmd; + *data = v1s->adb_autopoll_cmd; obuf[0] = 0xff; obuf[1] = 0xff; olen = 2; - memcpy(m->adb_data_in, obuf, olen); - m->adb_data_in_size = olen; + memcpy(v1s->adb_data_in, obuf, olen); + v1s->adb_data_in_size = olen; s->b &= ~VIA1B_vADBInt; - qemu_irq_raise(m->adb_data_ready); + qemu_irq_raise(v1s->adb_data_ready); } } trace_via1_adb_poll(*data, (s->b & VIA1B_vADBInt) ? "+" : "-", - adb_bus->status, m->adb_data_in_index, olen); + adb_bus->status, v1s->adb_data_in_index, olen); } static int adb_via_send_len(uint8_t data) @@ -686,11 +685,10 @@ static int adb_via_send_len(uint8_t data) } } -static void adb_via_send(MacVIAState *s, int state, uint8_t data) +static void adb_via_send(MOS6522Q800VIA1State *v1s, int state, uint8_t data) { - MOS6522Q800VIA1State *v1s = MOS6522_Q800_VIA1(&s->mos6522_via1); MOS6522State *ms = MOS6522(v1s); - ADBBusState *adb_bus = &s->adb_bus; + ADBBusState *adb_bus = &v1s->adb_bus; uint16_t autopoll_mask; switch (state) { @@ -706,22 +704,22 @@ static void adb_via_send(MacVIAState *s, int state, uint8_t data) ms->b &= ~VIA1B_vADBInt; } else { ms->b |= VIA1B_vADBInt; - s->adb_data_out_index = 0; - s->adb_data_out[s->adb_data_out_index++] = data; + v1s->adb_data_out_index = 0; + v1s->adb_data_out[v1s->adb_data_out_index++] = data; } trace_via1_adb_send(" NEW", data, (ms->b & VIA1B_vADBInt) ? "+" : "-"); - qemu_irq_raise(s->adb_data_ready); + qemu_irq_raise(v1s->adb_data_ready); break; case ADB_STATE_EVEN: case ADB_STATE_ODD: ms->b |= VIA1B_vADBInt; - s->adb_data_out[s->adb_data_out_index++] = data; + v1s->adb_data_out[v1s->adb_data_out_index++] = data; trace_via1_adb_send(state == ADB_STATE_EVEN ? "EVEN" : " ODD", data, (ms->b & VIA1B_vADBInt) ? "+" : "-"); - qemu_irq_raise(s->adb_data_ready); + qemu_irq_raise(v1s->adb_data_ready); break; case ADB_STATE_IDLE: @@ -729,40 +727,39 @@ static void adb_via_send(MacVIAState *s, int state, uint8_t data) } /* If the command is complete, execute it */ - if (s->adb_data_out_index == adb_via_send_len(s->adb_data_out[0])) { - s->adb_data_in_size = adb_request(adb_bus, s->adb_data_in, - s->adb_data_out, - s->adb_data_out_index); - s->adb_data_in_index = 0; + if (v1s->adb_data_out_index == adb_via_send_len(v1s->adb_data_out[0])) { + v1s->adb_data_in_size = adb_request(adb_bus, v1s->adb_data_in, + v1s->adb_data_out, + v1s->adb_data_out_index); + v1s->adb_data_in_index = 0; if (adb_bus->status & ADB_STATUS_BUSTIMEOUT) { /* * Bus timeout (but allow first EVEN and ODD byte to indicate * timeout via vADBInt and SRQ status) */ - s->adb_data_in[0] = 0xff; - s->adb_data_in[1] = 0xff; - s->adb_data_in_size = 2; + v1s->adb_data_in[0] = 0xff; + v1s->adb_data_in[1] = 0xff; + v1s->adb_data_in_size = 2; } /* * If last command is TALK, store it for use by autopoll and adjust * the autopoll mask accordingly */ - if ((s->adb_data_out[0] & 0xc) == 0xc) { - s->adb_autopoll_cmd = s->adb_data_out[0]; + if ((v1s->adb_data_out[0] & 0xc) == 0xc) { + v1s->adb_autopoll_cmd = v1s->adb_data_out[0]; - autopoll_mask = 1 << (s->adb_autopoll_cmd >> 4); + autopoll_mask = 1 << (v1s->adb_autopoll_cmd >> 4); adb_set_autopoll_mask(adb_bus, autopoll_mask); } } } -static void adb_via_receive(MacVIAState *s, int state, uint8_t *data) +static void adb_via_receive(MOS6522Q800VIA1State *v1s, int state, uint8_t *data) { - MOS6522Q800VIA1State *v1s = MOS6522_Q800_VIA1(&s->mos6522_via1); MOS6522State *ms = MOS6522(v1s); - ADBBusState *adb_bus = &s->adb_bus; + ADBBusState *adb_bus = &v1s->adb_bus; uint16_t pending; switch (state) { @@ -776,16 +773,16 @@ static void adb_via_receive(MacVIAState *s, int state, uint8_t *data) trace_via1_adb_receive("IDLE", *data, (ms->b & VIA1B_vADBInt) ? "+" : "-", adb_bus->status, - s->adb_data_in_index, s->adb_data_in_size); + v1s->adb_data_in_index, v1s->adb_data_in_size); break; case ADB_STATE_EVEN: case ADB_STATE_ODD: - switch (s->adb_data_in_index) { + switch (v1s->adb_data_in_index) { case 0: /* First EVEN byte: vADBInt indicates bus timeout */ - *data = s->adb_data_in[s->adb_data_in_index]; + *data = v1s->adb_data_in[v1s->adb_data_in_index]; if (adb_bus->status & ADB_STATUS_BUSTIMEOUT) { ms->b &= ~VIA1B_vADBInt; } else { @@ -794,16 +791,16 @@ static void adb_via_receive(MacVIAState *s, int state, uint8_t *data) trace_via1_adb_receive(state == ADB_STATE_EVEN ? "EVEN" : " ODD", *data, (ms->b & VIA1B_vADBInt) ? "+" : "-", - adb_bus->status, s->adb_data_in_index, - s->adb_data_in_size); + adb_bus->status, v1s->adb_data_in_index, + v1s->adb_data_in_size); - s->adb_data_in_index++; + v1s->adb_data_in_index++; break; case 1: /* First ODD byte: vADBInt indicates SRQ */ - *data = s->adb_data_in[s->adb_data_in_index]; - pending = adb_bus->pending & ~(1 << (s->adb_autopoll_cmd >> 4)); + *data = v1s->adb_data_in[v1s->adb_data_in_index]; + pending = adb_bus->pending & ~(1 << (v1s->adb_autopoll_cmd >> 4)); if (pending) { ms->b &= ~VIA1B_vADBInt; } else { @@ -812,10 +809,10 @@ static void adb_via_receive(MacVIAState *s, int state, uint8_t *data) trace_via1_adb_receive(state == ADB_STATE_EVEN ? "EVEN" : " ODD", *data, (ms->b & VIA1B_vADBInt) ? "+" : "-", - adb_bus->status, s->adb_data_in_index, - s->adb_data_in_size); + adb_bus->status, v1s->adb_data_in_index, + v1s->adb_data_in_size); - s->adb_data_in_index++; + v1s->adb_data_in_index++; break; default: @@ -825,11 +822,11 @@ static void adb_via_receive(MacVIAState *s, int state, uint8_t *data) * end of the poll reply, so provide these extra bytes below to * keep it happy */ - if (s->adb_data_in_index < s->adb_data_in_size) { + if (v1s->adb_data_in_index < v1s->adb_data_in_size) { /* Next data byte */ - *data = s->adb_data_in[s->adb_data_in_index]; + *data = v1s->adb_data_in[v1s->adb_data_in_index]; ms->b |= VIA1B_vADBInt; - } else if (s->adb_data_in_index == s->adb_data_in_size) { + } else if (v1s->adb_data_in_index == v1s->adb_data_in_size) { if (adb_bus->status & ADB_STATUS_BUSTIMEOUT) { /* Bus timeout (no more data) */ *data = 0xff; @@ -848,23 +845,22 @@ static void adb_via_receive(MacVIAState *s, int state, uint8_t *data) trace_via1_adb_receive(state == ADB_STATE_EVEN ? "EVEN" : " ODD", *data, (ms->b & VIA1B_vADBInt) ? "+" : "-", - adb_bus->status, s->adb_data_in_index, - s->adb_data_in_size); + adb_bus->status, v1s->adb_data_in_index, + v1s->adb_data_in_size); - if (s->adb_data_in_index <= s->adb_data_in_size) { - s->adb_data_in_index++; + if (v1s->adb_data_in_index <= v1s->adb_data_in_size) { + v1s->adb_data_in_index++; } break; } - qemu_irq_raise(s->adb_data_ready); + qemu_irq_raise(v1s->adb_data_ready); break; } } -static void via1_adb_update(MacVIAState *m) +static void via1_adb_update(MOS6522Q800VIA1State *v1s) { - MOS6522Q800VIA1State *v1s = MOS6522_Q800_VIA1(&m->mos6522_via1); MOS6522State *s = MOS6522(v1s); int oldstate, state; @@ -874,10 +870,10 @@ static void via1_adb_update(MacVIAState *m) if (state != oldstate) { if (s->acr & VIA1ACR_vShiftOut) { /* output mode */ - adb_via_send(m, state, s->sr); + adb_via_send(v1s, state, s->sr); } else { /* input mode */ - adb_via_receive(m, state, &s->sr); + adb_via_receive(v1s, state, &s->sr); } } } @@ -895,7 +891,6 @@ static void mos6522_q800_via1_write(void *opaque, hwaddr addr, uint64_t val, unsigned size) { MOS6522Q800VIA1State *v1s = MOS6522_Q800_VIA1(opaque); - MacVIAState *m = container_of(v1s, MacVIAState, mos6522_via1); MOS6522State *ms = MOS6522(v1s); addr = (addr >> 9) & 0xf; @@ -904,7 +899,7 @@ static void mos6522_q800_via1_write(void *opaque, hwaddr addr, uint64_t val, switch (addr) { case VIA_REG_B: via1_rtc_update(v1s); - via1_adb_update(m); + via1_adb_update(v1s); v1s->last_b = ms->b; break; @@ -954,7 +949,7 @@ static void mac_via_reset(DeviceState *dev) { MacVIAState *m = MAC_VIA(dev); MOS6522Q800VIA1State *v1s = &m->mos6522_via1; - ADBBusState *adb_bus = &m->adb_bus; + ADBBusState *adb_bus = &v1s->adb_bus; adb_set_autopoll_enabled(adb_bus, true); @@ -967,17 +962,10 @@ static void mac_via_realize(DeviceState *dev, Error **errp) MacVIAState *m = MAC_VIA(dev); MOS6522Q800VIA1State *v1s = &m->mos6522_via1; MOS6522State *ms; - ADBBusState *adb_bus = &m->adb_bus; + ADBBusState *adb_bus = &v1s->adb_bus; struct tm tm; int ret; - /* Init VIAs 1 and 2 */ - object_initialize_child(OBJECT(dev), "via1", &m->mos6522_via1, - TYPE_MOS6522_Q800_VIA1); - - object_initialize_child(OBJECT(dev), "via2", &m->mos6522_via2, - TYPE_MOS6522_Q800_VIA2); - /* Pass through mos6522 output IRQs */ ms = MOS6522(&m->mos6522_via1); object_property_add_alias(OBJECT(dev), "irq[0]", OBJECT(ms), @@ -1006,9 +994,9 @@ static void mac_via_realize(DeviceState *dev, Error **errp) qemu_get_timedate(&tm, 0); v1s->tick_offset = (uint32_t)mktimegm(&tm) + RTC_OFFSET; - adb_register_autopoll_callback(adb_bus, adb_via_poll, m); - m->adb_data_ready = qdev_get_gpio_in_named(dev, "via1-irq", - VIA1_IRQ_ADB_READY_BIT); + adb_register_autopoll_callback(adb_bus, adb_via_poll, v1s); + v1s->adb_data_ready = qdev_get_gpio_in_named(dev, "via1-irq", + VIA1_IRQ_ADB_READY_BIT); if (v1s->blk) { int64_t len = blk_getlength(v1s->blk); @@ -1049,9 +1037,12 @@ static void mac_via_init(Object *obj) &m->mos6522_via2, "via2", VIA_SIZE); memory_region_add_subregion(&m->mmio, VIA_SIZE, &m->via2mem); - /* ADB */ - qbus_create_inplace((BusState *)&m->adb_bus, sizeof(m->adb_bus), - TYPE_ADB_BUS, DEVICE(obj), "adb.0"); + /* Init VIAs 1 and 2 */ + object_initialize_child(obj, "via1", &m->mos6522_via1, + TYPE_MOS6522_Q800_VIA1); + + object_initialize_child(obj, "via2", &m->mos6522_via2, + TYPE_MOS6522_Q800_VIA2); } static void via1_postload_update_cb(void *opaque, bool running, RunState state) @@ -1086,13 +1077,6 @@ static const VMStateDescription vmstate_mac_via = { VMSTATE_INT64(mos6522_via1.next_second, MacVIAState), VMSTATE_TIMER_PTR(mos6522_via1.sixty_hz_timer, MacVIAState), VMSTATE_INT64(mos6522_via1.next_sixty_hz, MacVIAState), - /* ADB */ - VMSTATE_INT32(adb_data_in_size, MacVIAState), - VMSTATE_INT32(adb_data_in_index, MacVIAState), - VMSTATE_INT32(adb_data_out_index, MacVIAState), - VMSTATE_BUFFER(adb_data_in, MacVIAState), - VMSTATE_BUFFER(adb_data_out, MacVIAState), - VMSTATE_UINT8(adb_autopoll_cmd, MacVIAState), VMSTATE_END_OF_LIST() } }; @@ -1130,6 +1114,12 @@ static void mos6522_q800_via1_reset(DeviceState *dev) static void mos6522_q800_via1_init(Object *obj) { + MOS6522Q800VIA1State *v1s = MOS6522_Q800_VIA1(obj); + + /* ADB */ + qbus_create_inplace((BusState *)&v1s->adb_bus, sizeof(v1s->adb_bus), + TYPE_ADB_BUS, DEVICE(v1s), "adb.0"); + qdev_init_gpio_in_named(DEVICE(obj), via1_irq_request, "via1-irq", VIA1_IRQ_NB); } @@ -1153,6 +1143,13 @@ static const VMStateDescription vmstate_q800_via1 = { VMSTATE_UINT8(cmd, MOS6522Q800VIA1State), VMSTATE_INT32(wprotect, MOS6522Q800VIA1State), VMSTATE_INT32(alt, MOS6522Q800VIA1State), + /* ADB */ + VMSTATE_INT32(adb_data_in_size, MOS6522Q800VIA1State), + VMSTATE_INT32(adb_data_in_index, MOS6522Q800VIA1State), + VMSTATE_INT32(adb_data_out_index, MOS6522Q800VIA1State), + VMSTATE_BUFFER(adb_data_in, MOS6522Q800VIA1State), + VMSTATE_BUFFER(adb_data_out, MOS6522Q800VIA1State), + VMSTATE_UINT8(adb_autopoll_cmd, MOS6522Q800VIA1State), VMSTATE_END_OF_LIST() } }; From patchwork Wed Sep 8 15:35:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1525940 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=) 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 4H4RB41ywRz9sW5 for ; Thu, 9 Sep 2021 01:38:36 +1000 (AEST) Received: from localhost ([::1]:58716 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNzek-0000vO-0Z for incoming@patchwork.ozlabs.org; Wed, 08 Sep 2021 11:38:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34752) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNzbu-0003jz-0I for qemu-devel@nongnu.org; Wed, 08 Sep 2021 11:35:38 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:45137) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNzbr-0003pJ-5q for qemu-devel@nongnu.org; Wed, 08 Sep 2021 11:35:37 -0400 Received: from quad ([82.142.27.6]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MLz3R-1mfnZk2X3J-00Hv7O; Wed, 08 Sep 2021 17:35:33 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 06/12] mac_via: move q800 VIA1 timer variables to q800 VIA1 VMStateDescription Date: Wed, 8 Sep 2021 17:35:23 +0200 Message-Id: <20210908153529.453843-7-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210908153529.453843-1-laurent@vivier.eu> References: <20210908153529.453843-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:ewZF2ORRbufnA7lHqAK+1c5tVQlQhRmIe4nNXrZEfdzOPuEPYMI 62oS8G+zPQwpHCsWjyTXI8RYDhfF474lBsKvYuveAGLCS42eWddMkvpm2K5ynchphqXY3yJ tqZ9J5aoeWqJv4LawoWSuDOWsMI7BcCPspTtYY5tmyaqAL6+86Dxn6w6R846DZs/jlwHFyF kut4eR0WyMFjm2ZOAHXDA== X-UI-Out-Filterresults: notjunk:1;V03:K0:/pOmEockyF4=:vsrI+kjJqAOxEoZPeJUvtm 2STzrWBEKALWbS9YiCrtOPZ8BnlooJa9oZtQZmqaEPBggegdq6wca4fr62DW/zgbmyiaDcSX8 bfd8Tzr9pi5nXAuiWONlKwE0p20n1CjhIzytLHvQpabdbFDgIUvDO6Pf0ZYagSfR+Dhl64B65 NNybuJGHMTBiZGrpxkwc6fFtA+naLkhSqt2H10C3pJ0jAbU6ijUaVZPTYDHBzOg3ML51p6d3D B5MDMQ6e0dkFC/ipA1mII4AUTHKymQTh0+I/81Am74t2aGvTulM94L/To8VcJ3gONa1UyDD4d JvZqm8IUxZq9QucCVczcJLt5DTLIqb1CJPy1/RVPirf1QlhPa7dG8/qxcE4b6JntxZPJJJJek 9Q5OZlKjTfQbWFoxedmGuzAiNiZ91cqb+PskmxTNm1axyxxKpjxa7MI3K1nmpooj13Hnm0EUs n3ih158L75elpxYLLmULtsdXPhr5sf7GMhmIdQiXR0taohHL/vVcg4OapEgfOlyXcmjBz22Uf BpQk5qrdCkT5eYPKlDdTelCeSNYx0UUjg5bmZ8FbL4+XiEqUn8lZK6c+mlJW5fEhx2/gK9Asp AC1mfbziV3lRYLf9u5SRRaqIeN9/xSowtQBbT1223zhn/sfBBdBM4mUl7wIUjzsDRM37TwvTl ll7lWvNecqFAArZHZKr9LiRLerz2wmT/GGRXwZlahWaNoA3Ih2a7L9pltdsAGHV/9Fg8SWw29 Wlxgvpx2aVIftqk095q3QX2ICae17WvsqQgxKA== Received-SPF: none client-ip=212.227.126.134; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Cave-Ayland , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Mark Cave-Ayland These variables are already present in MOS6522Q800VIA1State and so it is just the VMStateDescription move that is needed. With this change the mac_via VMStateDescription is now empty and can be removed completely. Signed-off-by: Mark Cave-Ayland Reviewed-by: Laurent Vivier Message-Id: <20210830102447.10806-7-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- hw/misc/mac_via.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/hw/misc/mac_via.c b/hw/misc/mac_via.c index b4a65480fdc8..47e221dd88cf 100644 --- a/hw/misc/mac_via.c +++ b/hw/misc/mac_via.c @@ -1067,27 +1067,12 @@ static int via1_post_load(void *opaque, int version_id) return 0; } -static const VMStateDescription vmstate_mac_via = { - .name = "mac-via", - .version_id = 2, - .minimum_version_id = 2, - .fields = (VMStateField[]) { - /* VIAs */ - VMSTATE_TIMER_PTR(mos6522_via1.one_second_timer, MacVIAState), - VMSTATE_INT64(mos6522_via1.next_second, MacVIAState), - VMSTATE_TIMER_PTR(mos6522_via1.sixty_hz_timer, MacVIAState), - VMSTATE_INT64(mos6522_via1.next_sixty_hz, MacVIAState), - VMSTATE_END_OF_LIST() - } -}; - static void mac_via_class_init(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); dc->realize = mac_via_realize; dc->reset = mac_via_reset; - dc->vmsd = &vmstate_mac_via; } static TypeInfo mac_via_info = { @@ -1150,6 +1135,11 @@ static const VMStateDescription vmstate_q800_via1 = { VMSTATE_BUFFER(adb_data_in, MOS6522Q800VIA1State), VMSTATE_BUFFER(adb_data_out, MOS6522Q800VIA1State), VMSTATE_UINT8(adb_autopoll_cmd, MOS6522Q800VIA1State), + /* Timers */ + VMSTATE_TIMER_PTR(one_second_timer, MOS6522Q800VIA1State), + VMSTATE_INT64(next_second, MOS6522Q800VIA1State), + VMSTATE_TIMER_PTR(sixty_hz_timer, MOS6522Q800VIA1State), + VMSTATE_INT64(next_sixty_hz, MOS6522Q800VIA1State), VMSTATE_END_OF_LIST() } }; From patchwork Wed Sep 8 15:35:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1525944 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=) 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 4H4RFd2nxhz9t9b for ; Thu, 9 Sep 2021 01:41:41 +1000 (AEST) Received: from localhost ([::1]:41640 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNzhj-0008OR-5U for incoming@patchwork.ozlabs.org; Wed, 08 Sep 2021 11:41:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34852) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNzc3-0004Ig-24 for qemu-devel@nongnu.org; Wed, 08 Sep 2021 11:35:47 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:43337) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNzbz-0003w6-DO for qemu-devel@nongnu.org; Wed, 08 Sep 2021 11:35:46 -0400 Received: from quad ([82.142.27.6]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MTznO-1mXJGW0HL8-00QxnB; Wed, 08 Sep 2021 17:35:34 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 07/12] mac_via: move VIA1 reset logic from mac_via_reset() to mos6522_q800_via1_reset() Date: Wed, 8 Sep 2021 17:35:24 +0200 Message-Id: <20210908153529.453843-8-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210908153529.453843-1-laurent@vivier.eu> References: <20210908153529.453843-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:mGRE4x8hf0sqPHDyJhnCWll5dtKJ6b1Ftu7E3x+HH70PeAAE2wH PXbHV9mXIFTWWsmZY6be1aAqyqBvugaXxNLO9JaehR1ChdelP4I8rPdwcRe9JFDbPWydFwf 6a+kKLQW2uadgSBEHhPVbmSsyWOc2peXlHwoCRW46faFvI9Mw6NuminTD068bt47ixmCkTu aOYkoTJtXaLV1FrXbg6qg== X-UI-Out-Filterresults: notjunk:1;V03:K0:lUCLxtEORvw=:UpoWr/uSNVl6L+HYOJuHQf hciQSfse7a2G11RpO4Pmy2So8VMm1YBIBBQdomA6rfawWc0bBeRt3GA5nkDAR3WSlEcV1ZtMR vv2UFg0GFBbsLrRQ+43UJ+YUrTst3kvP+74gr8bAKi0lefpK9f0AaCkj1gjjFvsVSb/x8Vs6j VgEbSJUib2P5D+q9gAB7+RnOqzWuZdC9fB7paLpMLO0XvglLXDVFiSgMYugFgyWsxuJu4rHuA LShH07EmZbM2o5oDSNzFWQnFWoFy3FJ+//CiFw0DkGpprAMR4yRHkjyigHX7YqS6qZ4VWz/Ti EB9+1/+RCXFeVjyy6BPQYhROoVqcxpDoypme62JX/iLo/BUSvU9+fBOpd0asA2f+cnFBKvHeo SoBFn67Y9QdesJp2wF/KIusDruxBJ9alMiNkt1O+6aztTF2WloRW8fJPBvZWSPdGtvUaqjJb2 fTbU0id9Dp+NTZ6zf1gyWzxVACYZOYMQEQLGpGV58isCqL38dpRj10UrFHfKDDfRxORfLbP0G /Bnm2iIWxRc6NSloQM2spa7zOOhYnD7haNh1I/7nUbm2PZbOeCxy+XAKUGSzpHmqSxLK33rhb fl5OFo2YAvo+T6bafb1q0Mze5Jo1sEzeeKyCmaBxerG7+d7RUNhUu00YU7eelup6YIIQe9qft vULlrBZFEDjmdX1h7R26vfTkFUZtl0IJ7MhCAppOYwaaInjwjnvKfLGBseCGn6+1sBIHBPdMD MZp5gPjU8vMjIT2t/3qs5YYw4lie5EPoNtl4Fg== Received-SPF: none client-ip=212.227.126.134; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Cave-Ayland , Laurent Vivier , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Mark Cave-Ayland After this change mac_via_reset() is now empty and can be removed. Signed-off-by: Mark Cave-Ayland Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20210830102447.10806-8-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- hw/misc/mac_via.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/hw/misc/mac_via.c b/hw/misc/mac_via.c index 47e221dd88cf..a2df17d9bed1 100644 --- a/hw/misc/mac_via.c +++ b/hw/misc/mac_via.c @@ -945,18 +945,6 @@ static const MemoryRegionOps mos6522_q800_via2_ops = { }, }; -static void mac_via_reset(DeviceState *dev) -{ - MacVIAState *m = MAC_VIA(dev); - MOS6522Q800VIA1State *v1s = &m->mos6522_via1; - ADBBusState *adb_bus = &v1s->adb_bus; - - adb_set_autopoll_enabled(adb_bus, true); - - v1s->cmd = REG_EMPTY; - v1s->alt = REG_EMPTY; -} - static void mac_via_realize(DeviceState *dev, Error **errp) { MacVIAState *m = MAC_VIA(dev); @@ -1072,7 +1060,6 @@ static void mac_via_class_init(ObjectClass *oc, void *data) DeviceClass *dc = DEVICE_CLASS(oc); dc->realize = mac_via_realize; - dc->reset = mac_via_reset; } static TypeInfo mac_via_info = { @@ -1086,8 +1073,10 @@ static TypeInfo mac_via_info = { /* VIA 1 */ static void mos6522_q800_via1_reset(DeviceState *dev) { - MOS6522State *ms = MOS6522(dev); + MOS6522Q800VIA1State *v1s = MOS6522_Q800_VIA1(dev); + MOS6522State *ms = MOS6522(v1s); MOS6522DeviceClass *mdc = MOS6522_GET_CLASS(ms); + ADBBusState *adb_bus = &v1s->adb_bus; mdc->parent_reset(dev); @@ -1095,6 +1084,11 @@ static void mos6522_q800_via1_reset(DeviceState *dev) ms->timers[1].frequency = VIA_TIMER_FREQ; ms->b = VIA1B_vADB_StateMask | VIA1B_vADBInt | VIA1B_vRTCEnb; + + /* ADB/RTC */ + adb_set_autopoll_enabled(adb_bus, true); + v1s->cmd = REG_EMPTY; + v1s->alt = REG_EMPTY; } static void mos6522_q800_via1_init(Object *obj) From patchwork Wed Sep 8 15:35:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1525943 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=) 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 4H4RF432rQz9sW5 for ; Thu, 9 Sep 2021 01:41:12 +1000 (AEST) Received: from localhost ([::1]:38918 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNzhG-0006XX-6V for incoming@patchwork.ozlabs.org; Wed, 08 Sep 2021 11:41:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34754) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNzbu-0003kt-6M for qemu-devel@nongnu.org; Wed, 08 Sep 2021 11:35:38 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:40939) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNzbs-0003q8-4D for qemu-devel@nongnu.org; Wed, 08 Sep 2021 11:35:37 -0400 Received: from quad ([82.142.27.6]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MxUfh-1n8EZz24ef-00xreI; Wed, 08 Sep 2021 17:35:34 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 08/12] mac_via: move VIA1 realize logic from mac_via_realize() to mos6522_q800_via1_realize() Date: Wed, 8 Sep 2021 17:35:25 +0200 Message-Id: <20210908153529.453843-9-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210908153529.453843-1-laurent@vivier.eu> References: <20210908153529.453843-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:gF3wVc60yiZCRKtUGU4kdPSajqNNqo0mj5HGty1wYg+6Awm54QN Kc/WcwGZMEgCCueQzSAtASP2IVI8smo+DFAy+Vj390Mwq3AZjg1nGxOE32jF0VOz7MLSlfa 68Z+Lv7YDYlVxIzDdJSOPtwJyQAHYxC5AQyYbo0lNgNxQnD5Z2PgPWBRjCwKjtGBWdMOyZu kuhnHgTZta79aQUHg6afA== X-UI-Out-Filterresults: notjunk:1;V03:K0:1ef+iBawsIg=:ZX1guOWXoMlfFMflLCo+X+ 3ocAyXRmDV1Va0gOBZTwi/yaKkSrMroJH+RenhRnCCkk3Lvst1VrZ4hu31Y72V3/sBbQGq4R1 D0ktLHuFVU2SttJzVaBpyoiK3n30/+nHqBFLVxGcBKtf+Fs83hBSkart4ufGHV4Bdf7itzpsD bCHjyry6/dAmXQomYuUQNAiNA4Ca7JLnhNVgtgkJI1rMQ6ZkmU5kY3uwR7N7d/f/vzS3Mi2Oq 3Uay+0LrWJsFKDeqLhzA/LtulMjWrQUsecMDodkR2gmpXfKIKsfLfN4hnx+ZxY/oQyLPLUTI/ B3770DyUd2MJQt0m5o5MUzOx7usBrM4wxyLPOVoBiP+duwEEDJvHVcbjQn9xPFzkUspjyy+Pa sh2poDgjo3gQa9n2jy2uukxFOiPk0PJ5Dk0zu9wxX0SuoKv9glSl3RonbmCngcfr7MnxkZG4i 5IODRPGIkYcgs3r8UeQFFE/kGScWI9RxgwdvEDGMCLDxdW6GT1wS+peOv71hupS3usHY8Sw0s SzD5JfEiUoRCyfKex5bTXZu/8hgTxZAi7hQWSU2P7Kf1kEGUdXuK9VOKQ0bnMsk+rah6MITMe oPz2UqqWb4Ve0vY/DNhCVeOc2K9Acvwdpnkn+7v7DGHfKjOkiMj53zeq3SmAcRTYDOzGnNU71 5pe6J/zqZHGSwx3uv0apU1kKMkBYCjDtX7znKW/9ZNvacPRAzWGIG0JHxgRWYDzG+ZehSy4lZ dj+iSksPi4eGY1YURM47EM+4DMohd5pyd+yvRQ== Received-SPF: none client-ip=212.227.126.133; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Cave-Ayland , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Mark Cave-Ayland Signed-off-by: Mark Cave-Ayland Reviewed-by: Laurent Vivier Message-Id: <20210830102447.10806-9-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- hw/misc/mac_via.c | 86 ++++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/hw/misc/mac_via.c b/hw/misc/mac_via.c index a2df17d9bed1..bb8d682ce98f 100644 --- a/hw/misc/mac_via.c +++ b/hw/misc/mac_via.c @@ -948,11 +948,7 @@ static const MemoryRegionOps mos6522_q800_via2_ops = { static void mac_via_realize(DeviceState *dev, Error **errp) { MacVIAState *m = MAC_VIA(dev); - MOS6522Q800VIA1State *v1s = &m->mos6522_via1; MOS6522State *ms; - ADBBusState *adb_bus = &v1s->adb_bus; - struct tm tm; - int ret; /* Pass through mos6522 output IRQs */ ms = MOS6522(&m->mos6522_via1); @@ -968,44 +964,6 @@ static void mac_via_realize(DeviceState *dev, Error **errp) /* Pass through mos6522 input IRQs */ qdev_pass_gpios(DEVICE(&m->mos6522_via1), dev, "via1-irq"); qdev_pass_gpios(DEVICE(&m->mos6522_via2), dev, "via2-irq"); - - /* VIA 1 */ - m->mos6522_via1.one_second_timer = timer_new_ms(QEMU_CLOCK_VIRTUAL, - via1_one_second, - &m->mos6522_via1); - via1_one_second_update(&m->mos6522_via1); - m->mos6522_via1.sixty_hz_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, - via1_sixty_hz, - &m->mos6522_via1); - via1_sixty_hz_update(&m->mos6522_via1); - - qemu_get_timedate(&tm, 0); - v1s->tick_offset = (uint32_t)mktimegm(&tm) + RTC_OFFSET; - - adb_register_autopoll_callback(adb_bus, adb_via_poll, v1s); - v1s->adb_data_ready = qdev_get_gpio_in_named(dev, "via1-irq", - VIA1_IRQ_ADB_READY_BIT); - - if (v1s->blk) { - int64_t len = blk_getlength(v1s->blk); - if (len < 0) { - error_setg_errno(errp, -len, - "could not get length of backing image"); - return; - } - ret = blk_set_perm(v1s->blk, - BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE, - BLK_PERM_ALL, errp); - if (ret < 0) { - return; - } - - len = blk_pread(v1s->blk, 0, v1s->PRAM, sizeof(v1s->PRAM)); - if (len != sizeof(v1s->PRAM)) { - error_setg(errp, "can't read PRAM contents"); - return; - } - } } static void mac_via_init(Object *obj) @@ -1091,6 +1049,49 @@ static void mos6522_q800_via1_reset(DeviceState *dev) v1s->alt = REG_EMPTY; } +static void mos6522_q800_via1_realize(DeviceState *dev, Error **errp) +{ + MOS6522Q800VIA1State *v1s = MOS6522_Q800_VIA1(dev); + ADBBusState *adb_bus = &v1s->adb_bus; + struct tm tm; + int ret; + + v1s->one_second_timer = timer_new_ms(QEMU_CLOCK_VIRTUAL, via1_one_second, + v1s); + via1_one_second_update(v1s); + v1s->sixty_hz_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, via1_sixty_hz, + v1s); + via1_sixty_hz_update(v1s); + + qemu_get_timedate(&tm, 0); + v1s->tick_offset = (uint32_t)mktimegm(&tm) + RTC_OFFSET; + + adb_register_autopoll_callback(adb_bus, adb_via_poll, v1s); + v1s->adb_data_ready = qdev_get_gpio_in_named(dev, "via1-irq", + VIA1_IRQ_ADB_READY_BIT); + + if (v1s->blk) { + int64_t len = blk_getlength(v1s->blk); + if (len < 0) { + error_setg_errno(errp, -len, + "could not get length of backing image"); + return; + } + ret = blk_set_perm(v1s->blk, + BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE, + BLK_PERM_ALL, errp); + if (ret < 0) { + return; + } + + len = blk_pread(v1s->blk, 0, v1s->PRAM, sizeof(v1s->PRAM)); + if (len != sizeof(v1s->PRAM)) { + error_setg(errp, "can't read PRAM contents"); + return; + } + } +} + static void mos6522_q800_via1_init(Object *obj) { MOS6522Q800VIA1State *v1s = MOS6522_Q800_VIA1(obj); @@ -1147,6 +1148,7 @@ static void mos6522_q800_via1_class_init(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); + dc->realize = mos6522_q800_via1_realize; dc->reset = mos6522_q800_via1_reset; dc->vmsd = &vmstate_q800_via1; device_class_set_props(dc, mos6522_q800_via1_properties); From patchwork Wed Sep 8 15:35:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1525942 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=) 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 4H4RC438Rjz9sW5 for ; Thu, 9 Sep 2021 01:39:28 +1000 (AEST) Received: from localhost ([::1]:33000 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNzfa-0002Zc-5N for incoming@patchwork.ozlabs.org; Wed, 08 Sep 2021 11:39:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34788) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNzbw-0003sv-Hd for qemu-devel@nongnu.org; Wed, 08 Sep 2021 11:35:40 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:46869) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNzbs-0003qE-Lr for qemu-devel@nongnu.org; Wed, 08 Sep 2021 11:35:40 -0400 Received: from quad ([82.142.27.6]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MhUDj-1mtSsf3oG3-00ehAS; Wed, 08 Sep 2021 17:35:35 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 09/12] mac_via: remove mac_via device Date: Wed, 8 Sep 2021 17:35:26 +0200 Message-Id: <20210908153529.453843-10-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210908153529.453843-1-laurent@vivier.eu> References: <20210908153529.453843-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:vLqwfzPmap4MTts7oEG5mkCRIXD2jFvQdhmqdoetcGDB7BWsCPL FZMDisLqZPDtxoBtMl/uB8X6M4pct3u/+kIA7r5HYz2TpFDy/xl7YUhLpEZAEU1ZlsGNI3J MVSzPZd7ssXe0Elu82LY/cyZr6BLPovtBdY8e9B9m+k3sH4biZ6wbmqpr/pJRGNvX0bQ+n3 5htBu0gVWHOKmSx42d3Fg== X-UI-Out-Filterresults: notjunk:1;V03:K0:ZzmpT9scicQ=:q/Ft2PsPwEg57UhMDGsapM uitPGAsEnD5iVooSIP8spGFINqWqWJ5n2jzrJT3IFAp7SA6nfDc1wLQgc9uZv9I+CkJyW2552 Wz0/E3fSUqonbawCyVp13I141p0h7N+vgP/ea+v90+8zxEmkRlFzJZqWqnVf2V23xNhJTiTwc LFV4nPwkXIUh0D6iiJxOHOZ5G3CHHFkGfaMKoKg4si1lsCDK3mPIOH+MVoDTSXrVkqpr+vu69 6Xwo9ODb+D3nGeHBa2BCe2co3RPP9tTN+ERTKMyvJ2HARCvB1Ipkj5ZG+9SmqX5/uxXfluWL4 UOzHEmv/jU2cQ1Ehbs/AXg98xmKAXEPZusvZueqZaXnAS8iV9uCH7qMwgWc3G99piYsFnltis JlcrzHcwrmhX66SDEAUS+OkJzyLKrqcOvp0vcj8buI3ISbCxol1J30Vc6P06aBulq/pnDwAyD p1Q/fFxxQgvP+d4F1iMxHAjPTjgvDVm2juaN7/ZQaASRMhvYnaZjhKv1+wtKaBCQkt7diJdzh WyyOid9qzgfPmif1j8OFi2HGCMqT8GODdOgUgJdKW7wYxfrzHQnDNSH7Y7dHND5T/L6/elhls 3bT1KyMXKOzjGFAjdHCRkXSzGRH0cWBNluK/aLCaJa0NgdzyctQ1Xatw/Gw47T/ZcnaLNz/Sq 5HX/o3KYUiyvDbtTK6yDgleF4Js8KZPYUh9tUfHUI0yVTyWNx0UtWlmPgFw0T0Z8Dzf82CASv zGEOHylr4yshHwxl9odfASnY+hqeKkbmwFZdZg== Received-SPF: none client-ip=212.227.126.131; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Cave-Ayland , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Mark Cave-Ayland Remove the mac_via device and wire up both q800 VIA1 and VIA2 directly for the m68k q800 machine. Signed-off-by: Mark Cave-Ayland Reviewed-by: Laurent Vivier Message-Id: <20210830102447.10806-10-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- include/hw/misc/mac_via.h | 21 +++-------- hw/m68k/q800.c | 34 +++++++++-------- hw/misc/mac_via.c | 78 +++++++-------------------------------- 3 files changed, 36 insertions(+), 97 deletions(-) diff --git a/include/hw/misc/mac_via.h b/include/hw/misc/mac_via.h index 182dcb742235..9a8bca056ef3 100644 --- a/include/hw/misc/mac_via.h +++ b/include/hw/misc/mac_via.h @@ -15,6 +15,8 @@ #include "qom/object.h" +#define VIA_SIZE 0x2000 + /* VIA 1 */ #define VIA1_IRQ_ONE_SECOND_BIT 0 #define VIA1_IRQ_60HZ_BIT 1 @@ -38,6 +40,8 @@ struct MOS6522Q800VIA1State { /*< private >*/ MOS6522State parent_obj; + MemoryRegion via_mem; + qemu_irq irqs[VIA1_IRQ_NB]; uint8_t last_b; @@ -95,23 +99,8 @@ OBJECT_DECLARE_SIMPLE_TYPE(MOS6522Q800VIA2State, MOS6522_Q800_VIA2) struct MOS6522Q800VIA2State { /*< private >*/ MOS6522State parent_obj; -}; - - -#define TYPE_MAC_VIA "mac_via" -OBJECT_DECLARE_SIMPLE_TYPE(MacVIAState, MAC_VIA) - -struct MacVIAState { - SysBusDevice busdev; - - /* MMIO */ - MemoryRegion mmio; - MemoryRegion via1mem; - MemoryRegion via2mem; - /* VIAs */ - MOS6522Q800VIA1State mos6522_via1; - MOS6522Q800VIA2State mos6522_via2; + MemoryRegion via_mem; }; #endif diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c index e14f68f19b13..ec28e69802bb 100644 --- a/hw/m68k/q800.c +++ b/hw/m68k/q800.c @@ -225,7 +225,7 @@ static void q800_init(MachineState *machine) hwaddr parameters_base; CPUState *cs; DeviceState *dev; - DeviceState *via_dev, *via1_dev; + DeviceState *via1_dev, *via2_dev; DeviceState *escc_orgate; SysBusESPState *sysbus_esp; ESPState *esp; @@ -270,28 +270,30 @@ static void q800_init(MachineState *machine) object_property_set_link(OBJECT(glue), "cpu", OBJECT(cpu), &error_abort); sysbus_realize_and_unref(SYS_BUS_DEVICE(glue), &error_fatal); - /* VIA */ - - via_dev = qdev_new(TYPE_MAC_VIA); + /* VIA 1 */ + via1_dev = qdev_new(TYPE_MOS6522_Q800_VIA1); dinfo = drive_get(IF_MTD, 0, 0); if (dinfo) { - qdev_prop_set_drive(via_dev, "drive", blk_by_legacy_dinfo(dinfo)); + qdev_prop_set_drive(via1_dev, "drive", blk_by_legacy_dinfo(dinfo)); } - sysbus = SYS_BUS_DEVICE(via_dev); + sysbus = SYS_BUS_DEVICE(via1_dev); sysbus_realize_and_unref(sysbus, &error_fatal); - sysbus_mmio_map(sysbus, 0, VIA_BASE); - qdev_connect_gpio_out_named(DEVICE(sysbus), "irq", 0, - qdev_get_gpio_in(glue, 0)); - qdev_connect_gpio_out_named(DEVICE(sysbus), "irq", 1, - qdev_get_gpio_in(glue, 1)); - - via1_dev = DEVICE(MOS6522_Q800_VIA1(&MAC_VIA(via_dev)->mos6522_via1)); - adb_bus = qdev_get_child_bus(DEVICE(via1_dev), "adb.0"); + sysbus_mmio_map(sysbus, 1, VIA_BASE); + sysbus_connect_irq(sysbus, 0, qdev_get_gpio_in(glue, 0)); + + adb_bus = qdev_get_child_bus(via1_dev, "adb.0"); dev = qdev_new(TYPE_ADB_KEYBOARD); qdev_realize_and_unref(dev, adb_bus, &error_fatal); dev = qdev_new(TYPE_ADB_MOUSE); qdev_realize_and_unref(dev, adb_bus, &error_fatal); + /* VIA 2 */ + via2_dev = qdev_new(TYPE_MOS6522_Q800_VIA2); + sysbus = SYS_BUS_DEVICE(via2_dev); + sysbus_realize_and_unref(sysbus, &error_fatal); + sysbus_mmio_map(sysbus, 1, VIA_BASE + VIA_SIZE); + sysbus_connect_irq(sysbus, 0, qdev_get_gpio_in(glue, 1)); + /* MACSONIC */ if (nb_nics > 1) { @@ -375,11 +377,11 @@ static void q800_init(MachineState *machine) sysbus = SYS_BUS_DEVICE(dev); sysbus_realize_and_unref(sysbus, &error_fatal); - sysbus_connect_irq(sysbus, 0, qdev_get_gpio_in_named(via_dev, + sysbus_connect_irq(sysbus, 0, qdev_get_gpio_in_named(via2_dev, "via2-irq", VIA2_IRQ_SCSI_BIT)); sysbus_connect_irq(sysbus, 1, - qdev_get_gpio_in_named(via_dev, "via2-irq", + qdev_get_gpio_in_named(via2_dev, "via2-irq", VIA2_IRQ_SCSI_DATA_BIT)); sysbus_mmio_map(sysbus, 0, ESP_BASE); sysbus_mmio_map(sysbus, 1, ESP_PDMA); diff --git a/hw/misc/mac_via.c b/hw/misc/mac_via.c index bb8d682ce98f..7b9f067e7104 100644 --- a/hw/misc/mac_via.c +++ b/hw/misc/mac_via.c @@ -34,11 +34,9 @@ #include "qemu/log.h" /* - * VIAs: There are two in every machine, + * VIAs: There are two in every machine */ -#define VIA_SIZE (0x2000) - /* * Not all of these are true post MacII I think. * CSA: probably the ones CHRP marks as 'unused' change purposes @@ -945,52 +943,6 @@ static const MemoryRegionOps mos6522_q800_via2_ops = { }, }; -static void mac_via_realize(DeviceState *dev, Error **errp) -{ - MacVIAState *m = MAC_VIA(dev); - MOS6522State *ms; - - /* Pass through mos6522 output IRQs */ - ms = MOS6522(&m->mos6522_via1); - object_property_add_alias(OBJECT(dev), "irq[0]", OBJECT(ms), - SYSBUS_DEVICE_GPIO_IRQ "[0]"); - ms = MOS6522(&m->mos6522_via2); - object_property_add_alias(OBJECT(dev), "irq[1]", OBJECT(ms), - SYSBUS_DEVICE_GPIO_IRQ "[0]"); - - sysbus_realize(SYS_BUS_DEVICE(&m->mos6522_via1), &error_abort); - sysbus_realize(SYS_BUS_DEVICE(&m->mos6522_via2), &error_abort); - - /* Pass through mos6522 input IRQs */ - qdev_pass_gpios(DEVICE(&m->mos6522_via1), dev, "via1-irq"); - qdev_pass_gpios(DEVICE(&m->mos6522_via2), dev, "via2-irq"); -} - -static void mac_via_init(Object *obj) -{ - SysBusDevice *sbd = SYS_BUS_DEVICE(obj); - MacVIAState *m = MAC_VIA(obj); - - /* MMIO */ - memory_region_init(&m->mmio, obj, "mac-via", 2 * VIA_SIZE); - sysbus_init_mmio(sbd, &m->mmio); - - memory_region_init_io(&m->via1mem, obj, &mos6522_q800_via1_ops, - &m->mos6522_via1, "via1", VIA_SIZE); - memory_region_add_subregion(&m->mmio, 0x0, &m->via1mem); - - memory_region_init_io(&m->via2mem, obj, &mos6522_q800_via2_ops, - &m->mos6522_via2, "via2", VIA_SIZE); - memory_region_add_subregion(&m->mmio, VIA_SIZE, &m->via2mem); - - /* Init VIAs 1 and 2 */ - object_initialize_child(obj, "via1", &m->mos6522_via1, - TYPE_MOS6522_Q800_VIA1); - - object_initialize_child(obj, "via2", &m->mos6522_via2, - TYPE_MOS6522_Q800_VIA2); -} - static void via1_postload_update_cb(void *opaque, bool running, RunState state) { MOS6522Q800VIA1State *v1s = MOS6522_Q800_VIA1(opaque); @@ -1013,21 +965,6 @@ static int via1_post_load(void *opaque, int version_id) return 0; } -static void mac_via_class_init(ObjectClass *oc, void *data) -{ - DeviceClass *dc = DEVICE_CLASS(oc); - - dc->realize = mac_via_realize; -} - -static TypeInfo mac_via_info = { - .name = TYPE_MAC_VIA, - .parent = TYPE_SYS_BUS_DEVICE, - .instance_size = sizeof(MacVIAState), - .instance_init = mac_via_init, - .class_init = mac_via_class_init, -}; - /* VIA 1 */ static void mos6522_q800_via1_reset(DeviceState *dev) { @@ -1095,6 +1032,11 @@ static void mos6522_q800_via1_realize(DeviceState *dev, Error **errp) static void mos6522_q800_via1_init(Object *obj) { MOS6522Q800VIA1State *v1s = MOS6522_Q800_VIA1(obj); + SysBusDevice *sbd = SYS_BUS_DEVICE(v1s); + + memory_region_init_io(&v1s->via_mem, obj, &mos6522_q800_via1_ops, v1s, + "via1", VIA_SIZE); + sysbus_init_mmio(sbd, &v1s->via_mem); /* ADB */ qbus_create_inplace((BusState *)&v1s->adb_bus, sizeof(v1s->adb_bus), @@ -1187,6 +1129,13 @@ static void mos6522_q800_via2_reset(DeviceState *dev) static void mos6522_q800_via2_init(Object *obj) { + MOS6522Q800VIA2State *v2s = MOS6522_Q800_VIA2(obj); + SysBusDevice *sbd = SYS_BUS_DEVICE(v2s); + + memory_region_init_io(&v2s->via_mem, obj, &mos6522_q800_via2_ops, v2s, + "via2", VIA_SIZE); + sysbus_init_mmio(sbd, &v2s->via_mem); + qdev_init_gpio_in_named(DEVICE(obj), via2_irq_request, "via2-irq", VIA2_IRQ_NB); } @@ -1224,7 +1173,6 @@ static void mac_via_register_types(void) { type_register_static(&mos6522_q800_via1_type_info); type_register_static(&mos6522_q800_via2_type_info); - type_register_static(&mac_via_info); } type_init(mac_via_register_types); From patchwork Wed Sep 8 15:35:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1525941 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=) 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 4H4RBN6Xr4z9t54 for ; Thu, 9 Sep 2021 01:38:52 +1000 (AEST) Received: from localhost ([::1]:59278 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNzf0-0001Ho-MN for incoming@patchwork.ozlabs.org; Wed, 08 Sep 2021 11:38:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34854) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNzc3-0004Jn-E6 for qemu-devel@nongnu.org; Wed, 08 Sep 2021 11:35:47 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:45503) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNzc1-0003xk-Ik for qemu-devel@nongnu.org; Wed, 08 Sep 2021 11:35:47 -0400 Received: from quad ([82.142.27.6]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1Md6V1-1mxsiy1qmR-00aHJc; Wed, 08 Sep 2021 17:35:35 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 10/12] mac_via: remove explicit viaN prefix from VIA IRQ gpios Date: Wed, 8 Sep 2021 17:35:27 +0200 Message-Id: <20210908153529.453843-11-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210908153529.453843-1-laurent@vivier.eu> References: <20210908153529.453843-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:yGzr/bd4a/VZgBiyAD73jzGd5CSekQCV4bxC8/VE6Rs/QdSo6Y1 pwOtMS2L+eFEI3J8k3C+anZVM8gDf1du7Z6dW3xpojEZQip0ZlN8ocrGyVfKbcgeY/QUZ7j ZuIlKXT/B1beCGXocSSRpdfoHJhlK03F9LfbSbSPrnmlyHjbsMaculs/NzHxo/oYTn9QyAA ACsMbRRpcBx4OH5hn28eg== X-UI-Out-Filterresults: notjunk:1;V03:K0:8Q40s29z0fc=:I4DN34RYyhnPCvcbbLpyjc vgtr3m5ETmQqcZKFoqiUew3uk8vv+W9gYlmODK5C6uWhjdwQKeHpeArwBrFvdngwmRSPvG7JE YhS2xordSyBfj3iemx50hyCt3TVDPAhZ+E5z/AirsE4E1C6isBLk/0+R9h+02TL9L/LntSrpL WFzOnNvlIgEnddcezmoKDamuR0KV/uNDtgVTGeey/aWBppiKWqqI0eN+XUxfOETCjAKtqB6Zv u8wL/HBGlh/JoSYSW2sR9CGVcAzCAl5frorC0owQEdi6pzVaaTSQJW86T2XuDhZALW97Ooi08 7pTNDZKaZsIOzN4lVtB8QqLpF6TnHRWoSj03AW/qaAP8R/rVAV0OAkQstqkGmox4dXp2K/aOi PTvUDLEJzWoNGvkd0hKxV1f7+coUStrl63Zj7RYYiAdvStDFsOv5y8dkGjIU9YrunaLWyFFqU 53z56ncObr2ehM95CXqHkTiq+aGEaHwnyBgqsh8emGDQAg9FoPUagZFXFz4/mapcry2Lbs0yK Nhub4tGpj8PSKJGWiI0Q31WFr1uErfwECp3T7UuziasjBkEOllh1ofOjs7XGo0cBfDu/QugeJ 5mDr2ESNG45/zuEXutwQn0nf8rAsTTilKW6566iMXi+NwMIy4qynM2EQ8atJsGHKmktS8VeRI bg3FtGtkoW3Z8zYlcUbVRg0WVhIQw52OhyB2hfsdSceeTfV4XVZVwJjQulpT99CXs7ph+xNR4 aB+rqAbDI+BPQi2NwStEDALo/judF8vbzp22rg== Received-SPF: none client-ip=212.227.126.131; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Cave-Ayland , Laurent Vivier , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Mark Cave-Ayland Now that q800 VIA1 and VIA2 are completely separate devices there is no need to add a specific device prefix to ensure that the IRQ lines remain separate. Signed-off-by: Mark Cave-Ayland Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20210830102447.10806-11-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- hw/m68k/q800.c | 10 ++++------ hw/misc/mac_via.c | 9 +++------ 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c index ec28e69802bb..5ba87f789c78 100644 --- a/hw/m68k/q800.c +++ b/hw/m68k/q800.c @@ -377,12 +377,10 @@ static void q800_init(MachineState *machine) sysbus = SYS_BUS_DEVICE(dev); sysbus_realize_and_unref(sysbus, &error_fatal); - sysbus_connect_irq(sysbus, 0, qdev_get_gpio_in_named(via2_dev, - "via2-irq", - VIA2_IRQ_SCSI_BIT)); - sysbus_connect_irq(sysbus, 1, - qdev_get_gpio_in_named(via2_dev, "via2-irq", - VIA2_IRQ_SCSI_DATA_BIT)); + sysbus_connect_irq(sysbus, 0, qdev_get_gpio_in(via2_dev, + VIA2_IRQ_SCSI_BIT)); + sysbus_connect_irq(sysbus, 1, qdev_get_gpio_in(via2_dev, + VIA2_IRQ_SCSI_DATA_BIT)); sysbus_mmio_map(sysbus, 0, ESP_BASE); sysbus_mmio_map(sysbus, 1, ESP_PDMA); diff --git a/hw/misc/mac_via.c b/hw/misc/mac_via.c index 7b9f067e7104..f093f7388e5c 100644 --- a/hw/misc/mac_via.c +++ b/hw/misc/mac_via.c @@ -1004,8 +1004,7 @@ static void mos6522_q800_via1_realize(DeviceState *dev, Error **errp) v1s->tick_offset = (uint32_t)mktimegm(&tm) + RTC_OFFSET; adb_register_autopoll_callback(adb_bus, adb_via_poll, v1s); - v1s->adb_data_ready = qdev_get_gpio_in_named(dev, "via1-irq", - VIA1_IRQ_ADB_READY_BIT); + v1s->adb_data_ready = qdev_get_gpio_in(dev, VIA1_IRQ_ADB_READY_BIT); if (v1s->blk) { int64_t len = blk_getlength(v1s->blk); @@ -1042,8 +1041,7 @@ static void mos6522_q800_via1_init(Object *obj) qbus_create_inplace((BusState *)&v1s->adb_bus, sizeof(v1s->adb_bus), TYPE_ADB_BUS, DEVICE(v1s), "adb.0"); - qdev_init_gpio_in_named(DEVICE(obj), via1_irq_request, "via1-irq", - VIA1_IRQ_NB); + qdev_init_gpio_in(DEVICE(obj), via1_irq_request, VIA1_IRQ_NB); } static const VMStateDescription vmstate_q800_via1 = { @@ -1136,8 +1134,7 @@ static void mos6522_q800_via2_init(Object *obj) "via2", VIA_SIZE); sysbus_init_mmio(sbd, &v2s->via_mem); - qdev_init_gpio_in_named(DEVICE(obj), via2_irq_request, "via2-irq", - VIA2_IRQ_NB); + qdev_init_gpio_in(DEVICE(obj), via2_irq_request, VIA2_IRQ_NB); } static const VMStateDescription vmstate_q800_via2 = { From patchwork Wed Sep 8 15:35:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1525945 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=) 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 4H4RHn4d2Cz9sW5 for ; Thu, 9 Sep 2021 01:43:33 +1000 (AEST) Received: from localhost ([::1]:46738 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNzjX-0003O5-Dm for incoming@patchwork.ozlabs.org; Wed, 08 Sep 2021 11:43:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34782) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNzbv-0003ow-Bx for qemu-devel@nongnu.org; Wed, 08 Sep 2021 11:35:39 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:56877) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNzbt-0003qz-Hz for qemu-devel@nongnu.org; Wed, 08 Sep 2021 11:35:39 -0400 Received: from quad ([82.142.27.6]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MMoXE-1mgcvD3ZO0-00Ik43; Wed, 08 Sep 2021 17:35:36 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 11/12] mac_via: rename VIA2_IRQ_SLOT_BIT to VIA2_IRQ_NUBUS_BIT Date: Wed, 8 Sep 2021 17:35:28 +0200 Message-Id: <20210908153529.453843-12-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210908153529.453843-1-laurent@vivier.eu> References: <20210908153529.453843-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:6oIF4ueHNEy+Azacv7N1qci0XtWUe4FQoC+HyElAtVu3OOYw/eb OCt0jraseRsQ5mtl6U42QN4RgESHiLwHOwtiIlMtKoDrDq+WcwCjz6xd4jRKFSWhy7fyG0D wKizku4/cZqLEQxGjelkqiwqS9n2c2/hm0RfOgu7TKKRh6D+Ig7BOp0tphy4PSZ64Awc3SF oT+I8kI+0o4X8If7PdsKA== X-UI-Out-Filterresults: notjunk:1;V03:K0:tb65/c0u5bY=:gZJZ6l76QXttJClfc/wBmF DG3hx1RkxJAj4mL2FAZNSdNFN6nha43DSS8OSUlVx+FxndI42owKzXpszXkdGclyptPpdFhpl 88mZT1sqrHM6CdvyAhh+H9393B+hEW00B2b45Emh3etiK57U8/v8IwzoMk7S+DqJjkVJ6Xg6w LVmAooyM9r8qqzs04EzcLuHb9FmF/pw0PrIaQvvo4qcDDMQGHRMAcJIqU8w78SalZD1CrKtHs qy60wXkwDegykT+UAY0Pe0WGqCEvnmjT5lzAbj2J9tDdo5+qX6YP6lGJqsG9vZ2yoWA9ATAzd qqOUV+m/nWLatSxN3FKJV4MsLJsa6PG+s5peaFf0WhgT1ad7lMhpuHGVXGRJqYKvwKSYpiWkX p4zbSjdkdzeN0MRLdXOL8faK1+FdAzfJJC3O4r8HejWsW+lZkVzl4bpvQ9pMgu272CI2srMzS OA79XkfzTR9wQTuGSpNI7ofd6xsrFjNCbp9qQLMzHqqgOeHC6I1JRAZOcZFiXeyZJBII5NifI QT/H+chu4gQvyBrcbH5uIAIaMSqhzkIszVRPboubqVCi2RDi145tMSee7Gf5gVvfOiRJMRL0N qu2V3P/A5jg+O42BTB/KXCvZjPdBmo/L6YQO7LCzZtXprH/rXCuwZhctgQpjzB685YZoOkL7y s/G7HHS31Dj2FOHcEdo47VJsx069pxTqYI8jc9v7qmdLq/OqxFYdoeqwDpQEXgKaKd/kfBaCK 1cz11pRPHgirQrANAgEp+WmdHWQUjkJW+aIYNQ== Received-SPF: none client-ip=212.227.126.187; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Cave-Ayland , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Mark Cave-Ayland Also improve the alignment of the shifted constants. Signed-off-by: Mark Cave-Ayland Reviewed-by: Laurent Vivier Message-Id: <20210830102447.10806-12-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- include/hw/misc/mac_via.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/include/hw/misc/mac_via.h b/include/hw/misc/mac_via.h index 9a8bca056ef3..5168e3ce665c 100644 --- a/include/hw/misc/mac_via.h +++ b/include/hw/misc/mac_via.h @@ -26,11 +26,11 @@ #define VIA1_IRQ_NB 8 -#define VIA1_IRQ_ONE_SECOND (1 << VIA1_IRQ_ONE_SECOND_BIT) -#define VIA1_IRQ_60HZ (1 << VIA1_IRQ_60HZ_BIT) -#define VIA1_IRQ_ADB_READY (1 << VIA1_IRQ_ADB_READY_BIT) -#define VIA1_IRQ_ADB_DATA (1 << VIA1_IRQ_ADB_DATA_BIT) -#define VIA1_IRQ_ADB_CLOCK (1 << VIA1_IRQ_ADB_CLOCK_BIT) +#define VIA1_IRQ_ONE_SECOND (1 << VIA1_IRQ_ONE_SECOND_BIT) +#define VIA1_IRQ_60HZ (1 << VIA1_IRQ_60HZ_BIT) +#define VIA1_IRQ_ADB_READY (1 << VIA1_IRQ_ADB_READY_BIT) +#define VIA1_IRQ_ADB_DATA (1 << VIA1_IRQ_ADB_DATA_BIT) +#define VIA1_IRQ_ADB_CLOCK (1 << VIA1_IRQ_ADB_CLOCK_BIT) #define TYPE_MOS6522_Q800_VIA1 "mos6522-q800-via1" @@ -80,18 +80,18 @@ struct MOS6522Q800VIA1State { /* VIA 2 */ #define VIA2_IRQ_SCSI_DATA_BIT 0 -#define VIA2_IRQ_SLOT_BIT 1 +#define VIA2_IRQ_NUBUS_BIT 1 #define VIA2_IRQ_UNUSED_BIT 2 #define VIA2_IRQ_SCSI_BIT 3 #define VIA2_IRQ_ASC_BIT 4 #define VIA2_IRQ_NB 8 -#define VIA2_IRQ_SCSI_DATA (1 << VIA2_IRQ_SCSI_DATA_BIT) -#define VIA2_IRQ_SLOT (1 << VIA2_IRQ_SLOT_BIT) -#define VIA2_IRQ_UNUSED (1 << VIA2_IRQ_SCSI_BIT) -#define VIA2_IRQ_SCSI (1 << VIA2_IRQ_UNUSED_BIT) -#define VIA2_IRQ_ASC (1 << VIA2_IRQ_ASC_BIT) +#define VIA2_IRQ_SCSI_DATA (1 << VIA2_IRQ_SCSI_DATA_BIT) +#define VIA2_IRQ_NUBUS (1 << VIA2_IRQ_NUBUS_BIT) +#define VIA2_IRQ_UNUSED (1 << VIA2_IRQ_SCSI_BIT) +#define VIA2_IRQ_SCSI (1 << VIA2_IRQ_UNUSED_BIT) +#define VIA2_IRQ_ASC (1 << VIA2_IRQ_ASC_BIT) #define TYPE_MOS6522_Q800_VIA2 "mos6522-q800-via2" OBJECT_DECLARE_SIMPLE_TYPE(MOS6522Q800VIA2State, MOS6522_Q800_VIA2) From patchwork Wed Sep 8 15:35:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1525938 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=) 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 4H4R7d2wS6z9t54 for ; Thu, 9 Sep 2021 01:36:29 +1000 (AEST) Received: from localhost ([::1]:50658 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNzch-0003vF-3z for incoming@patchwork.ozlabs.org; Wed, 08 Sep 2021 11:36:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34784) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNzbv-0003pW-JO for qemu-devel@nongnu.org; Wed, 08 Sep 2021 11:35:39 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:60567) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNzbt-0003rH-UN for qemu-devel@nongnu.org; Wed, 08 Sep 2021 11:35:39 -0400 Received: from quad ([82.142.27.6]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MzQbw-1nAAO014S0-00vOo3; Wed, 08 Sep 2021 17:35:36 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 12/12] mac_via: add qdev gpios for nubus slot interrupts to VIA2 Date: Wed, 8 Sep 2021 17:35:29 +0200 Message-Id: <20210908153529.453843-13-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210908153529.453843-1-laurent@vivier.eu> References: <20210908153529.453843-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:0QMuheZgK1nh6x6PizyvHG3uPoS/lIXTKnEnjcOnhOHn6WDGQcD rdBFX0jHR5TSh3hEfTBs25/s1Lz5qhZLrnmcZ1iQQsu9N4Znfip2xvD/EbiF4YIkNrKR/Vn rVTLatt5rHCCTreqIaEyUm1W6eHVldLvN3zxgyENQ3zX70ON3rqI6Lu8mkYqfNfjUgwVkRo 4yHWJbkOn7nfpXLJl9pqA== X-UI-Out-Filterresults: notjunk:1;V03:K0:hQJSBC2qClg=:gHSSLSJQ/JPEN5d+zVicS7 zIllxRFCqtR+2occhywOyMzuwMfqzk248RyFQdTC732uFjN75vDSUMwLchLXaazO5jUp8Gw2b fVIAWnqIzxRZxcbySAKR/HDoKqRYeYbQo4PbkhZVuiZjEmas3HMdlwJXbNjnsQplgBOPtuCWs DJkNACLmItPSrfC8ny/VZwG8WNB3InbrNYgm6OKXyk9/8lSa0PEyqK/rXVUSAqNcl2QEtvAvR 68JvGIA2sAIKXqSs8B4MzFzDQJG3FdKpsE/vOLGuNvupHhFnTcEbRZYRvbKeoZ3KJlRD/hAXv ckf5WRXolUOlv8Nt5yOUI3N82jU/bOJTV5093Q2bA4tm/094uCkWFFjPO6+M/rqBh/iIADOO6 ZQ33W1d+Jx2wGTSqXOWgVDja5gb/aQajICkT1S0awEsswzQM/Bs/hOJVpN7gEUXQNU8BtDzwm MniCE9q73kaw4sZb1m/29ohi6mzLrxSSWUVV97C360iFn1I/2x+ZToVl7WgM+azsS6WjPd3fG xz0/XU/HUOp3tNTl61kQFs44Y0SR3/0GBYv30CLqMlvDQtFZa0gGqULcy4vqM0sFKc861Fikk O0iFXKJh+8nEVzQqvwzLVu19ehaffshUr7u9+lNVLkGbgdGvqzIGL2+M/DuBlsgi/KZL2/HHo wOgw2GwiiZ4wo75gsklGc0r/P7YXaWac/lgiLjlfCBR6B7ysCvELoR0QOKHx/aVtqwRmbbjJA R4oafCAVEqJmYkh3jv/5jXNpzV6bwSpJ/UrXyw== Received-SPF: none client-ip=212.227.126.131; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Cave-Ayland , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Mark Cave-Ayland These will soon be required to enable nubus devices to support interrupts. Signed-off-by: Mark Cave-Ayland Reviewed-by: Laurent Vivier Message-Id: <20210830102447.10806-13-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- include/hw/misc/mac_via.h | 10 ++++++++++ hw/misc/mac_via.c | 23 +++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/include/hw/misc/mac_via.h b/include/hw/misc/mac_via.h index 5168e3ce665c..4506abe5d0e3 100644 --- a/include/hw/misc/mac_via.h +++ b/include/hw/misc/mac_via.h @@ -93,6 +93,16 @@ struct MOS6522Q800VIA1State { #define VIA2_IRQ_SCSI (1 << VIA2_IRQ_UNUSED_BIT) #define VIA2_IRQ_ASC (1 << VIA2_IRQ_ASC_BIT) +#define VIA2_NUBUS_IRQ_NB 7 + +#define VIA2_NUBUS_IRQ_9 0 +#define VIA2_NUBUS_IRQ_A 1 +#define VIA2_NUBUS_IRQ_B 2 +#define VIA2_NUBUS_IRQ_C 3 +#define VIA2_NUBUS_IRQ_D 4 +#define VIA2_NUBUS_IRQ_E 5 +#define VIA2_NUBUS_IRQ_INTVIDEO 6 + #define TYPE_MOS6522_Q800_VIA2 "mos6522-q800-via2" OBJECT_DECLARE_SIMPLE_TYPE(MOS6522Q800VIA2State, MOS6522_Q800_VIA2) diff --git a/hw/misc/mac_via.c b/hw/misc/mac_via.c index f093f7388e5c..d1abcd97b51d 100644 --- a/hw/misc/mac_via.c +++ b/hw/misc/mac_via.c @@ -1123,6 +1123,26 @@ static void mos6522_q800_via2_reset(DeviceState *dev) ms->dirb = 0; ms->b = 0; + ms->dira = 0; + ms->a = 0x7f; +} + +static void via2_nubus_irq_request(void *opaque, int irq, int level) +{ + MOS6522Q800VIA2State *v2s = opaque; + MOS6522State *s = MOS6522(v2s); + MOS6522DeviceClass *mdc = MOS6522_GET_CLASS(s); + + if (level) { + /* Port A nubus IRQ inputs are active LOW */ + s->a &= ~(1 << irq); + s->ifr |= 1 << VIA2_IRQ_NUBUS_BIT; + } else { + s->a |= (1 << irq); + s->ifr &= ~(1 << VIA2_IRQ_NUBUS_BIT); + } + + mdc->update_irq(s); } static void mos6522_q800_via2_init(Object *obj) @@ -1135,6 +1155,9 @@ static void mos6522_q800_via2_init(Object *obj) sysbus_init_mmio(sbd, &v2s->via_mem); qdev_init_gpio_in(DEVICE(obj), via2_irq_request, VIA2_IRQ_NB); + + qdev_init_gpio_in_named(DEVICE(obj), via2_nubus_irq_request, "nubus-irq", + VIA2_NUBUS_IRQ_NB); } static const VMStateDescription vmstate_q800_via2 = {