From patchwork Fri Oct 8 11:45:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1538322 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HQmfy4XQ3z9sP7 for ; Fri, 8 Oct 2021 22:48:42 +1100 (AEDT) Received: from localhost ([::1]:49228 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYoMi-0007nT-Do for incoming@patchwork.ozlabs.org; Fri, 08 Oct 2021 07:48:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50334) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYoJa-0006FK-1f for qemu-devel@nongnu.org; Fri, 08 Oct 2021 07:45:26 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:41899) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYoJW-0006vb-E0 for qemu-devel@nongnu.org; Fri, 08 Oct 2021 07:45:24 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MXGes-1mGhLC0TCY-00Ykf6; Fri, 08 Oct 2021 13:45:20 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 01/13] macfb: handle errors that occur during realize Date: Fri, 8 Oct 2021 13:45:06 +0200 Message-Id: <20211008114518.757615-2-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211008114518.757615-1-laurent@vivier.eu> References: <20211008114518.757615-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:jXSR2tl6XeQCaVMLGmYv7eIEdZkbzU6Prx4qMAgHWjReKdBO37M YWmv2u/D0AdBOFQxF4m183JKJ31a+tiugi/WpafU5R5ndum4+G/pzHdO+BKcOU9qCv1E9Tr RU0hh/XMvhQyzLUX8jjh2CB1+jX7tQgPxhkEZYtwANIihnWYypl6xh32RxLvrSToZ+ABVH0 71BGtJjZ8ilwiuQTD9YEg== X-UI-Out-Filterresults: notjunk:1;V03:K0:hWsWAxG7GyA=:ZAIvpSRbFRvHW9GqGtUyZe Oie3lfRleuXCD/pE0sEc8eRCL0pP+fFSSbErHJ8CKu49bPuaCbn7kZkpvMTG1qAJfBjO8TpO9 aYjp070AWDelEgKNAtLtcHvUiUfyVy2WNCNKensBKG3tZ7oZAaSuo0UsZJZ1STrb1sPZP5HCe YvHkcz/d9N4qio4PkmSipb55tU1OxZeb+ORLjyO+KPUSVSAFR8SUYof+MViKqDupaY2GLV8wt MLw2aKS2c62EepwpfYXpDzvgApKsUWLeqFKFK7A9Abo8Fy6Cv8YStQDDyaZUEHkl8w6hLH94X LXC1LckZo7jsJ48EiWgzWCcq6UKYlqijTnBo6/fflHXwRq9G2LbDUU0VOkx/iR7GpK5wwHj5R YaI4qozqiyEBs79nUBSiBxsUEicrmcnRI3ZZTNQ78B85f1tz6M8KstYaUC5cQr0U8rIneIfw4 8WsjHAjbFV3lPQjgcWA9ItR6ZTIcUDFYWlYh5wqyKbAaRv1YJXXW/hD68BsdQyKAWGor2nBAI 8FTOo5caD0zrED4jmoeqMRvYDuEq20T3UXeV3uBbDG4pGxIF4PEm7rT342CUgJsyOkIR/z9dk Rz13eoqwYUOlU/kP2FshXoZQtm3PGicxu3fMrB+fIfweYkkZgoDGUowxFEkDpb8bP5x8V8U6u uai33MUJr2DsqzmFqE1dlLIhS7lmX2gRpXfQBIqt2iXPqiEmaZuzszxd0nlISlVVqKtf8EnRm Pb5EWd4Kvsy70fBvhK4StgRGqRb+7NjcUckg/Q== 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 Make sure any errors that occur within the macfb realize chain are detected and handled correctly to prevent crashes and to ensure that error messages are reported back to the user. Signed-off-by: Mark Cave-Ayland Reviewed-by: BALATON Zoltan Reviewed-by: Laurent Vivier Message-Id: <20211007221253.29024-2-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- hw/display/macfb.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hw/display/macfb.c b/hw/display/macfb.c index 76808b69ccc8..2b747a8de8a1 100644 --- a/hw/display/macfb.c +++ b/hw/display/macfb.c @@ -379,6 +379,10 @@ static void macfb_sysbus_realize(DeviceState *dev, Error **errp) MacfbState *ms = &s->macfb; macfb_common_realize(dev, ms, errp); + if (*errp) { + return; + } + sysbus_init_mmio(SYS_BUS_DEVICE(s), &ms->mem_ctrl); sysbus_init_mmio(SYS_BUS_DEVICE(s), &ms->mem_vram); } @@ -391,8 +395,15 @@ static void macfb_nubus_realize(DeviceState *dev, Error **errp) MacfbState *ms = &s->macfb; ndc->parent_realize(dev, errp); + if (*errp) { + return; + } macfb_common_realize(dev, ms, errp); + if (*errp) { + return; + } + memory_region_add_subregion(&nd->slot_mem, DAFB_BASE, &ms->mem_ctrl); memory_region_add_subregion(&nd->slot_mem, VIDEO_BASE, &ms->mem_vram); } From patchwork Fri Oct 8 11:45:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1538327 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HQml26THzz9sP7 for ; Fri, 8 Oct 2021 22:52:14 +1100 (AEDT) Received: from localhost ([::1]:58004 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYoQ8-0005XV-BM for incoming@patchwork.ozlabs.org; Fri, 08 Oct 2021 07:52:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50336) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYoJc-0006GD-85 for qemu-devel@nongnu.org; Fri, 08 Oct 2021 07:45:29 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:55705) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYoJW-0006vT-E1 for qemu-devel@nongnu.org; Fri, 08 Oct 2021 07:45:25 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MV5rK-1mA5dW2WnO-00SB52; Fri, 08 Oct 2021 13:45:20 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 02/13] macfb: update macfb.c to use the Error API best practices Date: Fri, 8 Oct 2021 13:45:07 +0200 Message-Id: <20211008114518.757615-3-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211008114518.757615-1-laurent@vivier.eu> References: <20211008114518.757615-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:1GT30kE0iunnH0/coSR3T5rY2VuRR8bjAiXqHi5G/E/lzhRGZ+e nwJD2vcDa8mTHPOye5q1lmhvo7C6W+3izNmDiwC+cPVu0PxAzZvVVWmDYRDn3VvKF/ogXIJ +PEVfNF/rsWte3P09lFG67i/Qaddg4wsdEK+gOJx1wHYkeCcRhyukbkQHjrDVfcOzmuQrBd sGukoCdtCKn4ErRP36nFw== X-UI-Out-Filterresults: notjunk:1;V03:K0:hiA/1KaLx34=:vwIpio/B+8OzxejmNWQWbA UBJuRszeTqybQCE7X2+NqiXeBun11RJAIc+6AAE28UT6bdrkrErjmBLW/+00b2bHIjBRiDm5d XfQZRwsVaKKd8X/XLCM5ICFxxfUsdPd+u1+cwHKd/kMUvu+AB81hhDVXuWgnXCaNwm3PQ1Q48 Zv4dXKAn1pArdOHO6LoHEvna/HCWEDGbpOxVFfPNKyp0TB9Ml1ltafOd+gLR+ey3GpORo4Lwi sUmDPyuTFyLxZ/+obQFzW82dkvWMLJyd4+kG3rpPXml8rWXaYM83DcHaePPlMKQwc/vUMeSwJ Oiyyq3aiB6GKRops7bNB/kIbCXijP5OuB89W8/vaRLx4DISVYj+IJHQh+/Xazs/v+einAepui HKk1bV3PbEbTfHVMe0LUtDoP58TZ8qDYXwoX0MFTwcalxVPJvsHLg/8BVXxQNxg4vKqYfFniY uFtaKv69Aj/Xey2SUNM2bPfH7sDYpt2/dWcQE2WMBUYrtjB29K+qHk/3HOHiVzzFR7v/asEdd 0mYuQCJJqHamfpx5ZsKmpkwxmjLyAXnwmfvJ5lKYPMFoOLabyiZgU9vYM2XD3tiX57/cAlxRe xiNiINXP5UPF0pPt6Zav073Ob6XkIt4grMOBkKIbp50qfMNLKVVShW9EuCxXrT0P2v7pF8+OC 1Bm3cSfo0Fb9WWPaubyo9jsN+tBO2Hz5YEOb6mkTDrdttHPwsK6d9cBNK3Sgv0Nte/DGEMeOr iuADvWAsw6Y69bX6vMwkjNmvL3mCgsmDwCIlNw== Received-SPF: none client-ip=212.227.126.133; 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 As per the current Error API best practices, change macfb_commom_realize() to return a boolean indicating success to reduce errp boiler-plate handling code. Note that memory_region_init_ram_nomigrate() is also updated to use &error_abort to indicate a non-recoverable error, matching the behaviour recommended after similar discussions on memory API failures for the recent nubus changes. Signed-off-by: Mark Cave-Ayland Reviewed-by: Laurent Vivier Message-Id: <20211007221253.29024-3-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- hw/display/macfb.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/hw/display/macfb.c b/hw/display/macfb.c index 2b747a8de8a1..2ec25c5d6f7a 100644 --- a/hw/display/macfb.c +++ b/hw/display/macfb.c @@ -343,14 +343,14 @@ static const GraphicHwOps macfb_ops = { .gfx_update = macfb_update_display, }; -static void macfb_common_realize(DeviceState *dev, MacfbState *s, Error **errp) +static bool macfb_common_realize(DeviceState *dev, MacfbState *s, Error **errp) { DisplaySurface *surface; if (s->depth != 1 && s->depth != 2 && s->depth != 4 && s->depth != 8 && s->depth != 16 && s->depth != 24) { error_setg(errp, "unknown guest depth %d", s->depth); - return; + return false; } s->con = graphic_console_init(dev, 0, &macfb_ops, s); @@ -359,18 +359,20 @@ static void macfb_common_realize(DeviceState *dev, MacfbState *s, Error **errp) if (surface_bits_per_pixel(surface) != 32) { error_setg(errp, "unknown host depth %d", surface_bits_per_pixel(surface)); - return; + return false; } memory_region_init_io(&s->mem_ctrl, OBJECT(dev), &macfb_ctrl_ops, s, "macfb-ctrl", 0x1000); memory_region_init_ram_nomigrate(&s->mem_vram, OBJECT(s), "macfb-vram", - MACFB_VRAM_SIZE, errp); + MACFB_VRAM_SIZE, &error_abort); s->vram = memory_region_get_ram_ptr(&s->mem_vram); s->vram_bit_mask = MACFB_VRAM_SIZE - 1; vmstate_register_ram(&s->mem_vram, dev); memory_region_set_coalescing(&s->mem_vram); + + return true; } static void macfb_sysbus_realize(DeviceState *dev, Error **errp) @@ -378,8 +380,7 @@ static void macfb_sysbus_realize(DeviceState *dev, Error **errp) MacfbSysBusState *s = MACFB(dev); MacfbState *ms = &s->macfb; - macfb_common_realize(dev, ms, errp); - if (*errp) { + if (!macfb_common_realize(dev, ms, errp)) { return; } @@ -399,8 +400,7 @@ static void macfb_nubus_realize(DeviceState *dev, Error **errp) return; } - macfb_common_realize(dev, ms, errp); - if (*errp) { + if (!macfb_common_realize(dev, ms, errp)) { return; } From patchwork Fri Oct 8 11:45:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1538337 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HQmrb61gjz9sR4 for ; Fri, 8 Oct 2021 22:57:02 +1100 (AEDT) Received: from localhost ([::1]:43036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYoUk-0005zl-T3 for incoming@patchwork.ozlabs.org; Fri, 08 Oct 2021 07:56:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50488) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYoJo-0006PM-Pr for qemu-devel@nongnu.org; Fri, 08 Oct 2021 07:45:40 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:45323) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYoJi-00072i-7n for qemu-devel@nongnu.org; Fri, 08 Oct 2021 07:45:40 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1N2lzA-1ml4Ll0joS-0139jC; Fri, 08 Oct 2021 13:45:21 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 03/13] macfb: fix invalid object reference in macfb_common_realize() Date: Fri, 8 Oct 2021 13:45:08 +0200 Message-Id: <20211008114518.757615-4-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211008114518.757615-1-laurent@vivier.eu> References: <20211008114518.757615-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:ZHt51d+LxgmjezZkjI8FOq+6UScoPtk0HBv16HnD30+HDt6jLrW Nw+54Je/+eoATco1G/jG8ifvirUppYM2opqhZVtF/DOhYT8tHxCf1W5WGoY2SXQAtI/U5qR EeIGxlS7iFAyx9MkhzERV6uxA1s8LKHhILdd5AqV7tw6FAS2tAnlZUjmMZLBqJO0ZPnwFBN CG0jaeId5j/3nitQ4JVdg== X-UI-Out-Filterresults: notjunk:1;V03:K0:tpyvMbSZOrw=:2u3IvYVpNyfShpWhpFxWP9 VEVlJELHeUSlCPq2jQoJJAhgoLIqVFtszzZSiBVQVUAMTaTliL5DK4RRWBgf7el6KwjkUkAgd up7H43uhCc/Ffd0AWo0Wa9J9PvF4Mo/qDtMzunpBC5x6Qf3/2TNASnGSo51NHSgT18g0bNOyI asiRlz0o5TNue+eyJfjvGPpzMsjohhEO+iZAnjT+nDALJ5/vPIbLV2FXufkexbw9RP9ayh3sz oHR8JirPt1Edc88dWa6aOwMLxnoH6pt2s5YX4mvmVT70N2y5l+e5u6NCsFjLwK78dD52vbkri 3hhsONQ49WQsuLUR4qwADWmSxKQ6JkdHMa4Kkk6XWS9uJmsNIlPVG1A17VHThAaVAbTSYBUV5 QDe3JxRR9BSpVLl/uojY6JhQltA/ymZFWko7ihBumxXxttjSMkvOniDdiXxnhlXAMF7KBkYLA 04Fyem9I45lf6+DvaZK6DI7PsfIVkF1IzyXqtWsEAAvoYlOfgAcV3rwvnHMQpEHMEEiHCMi/r yYsySjMJ0oJOTGBs+c8ukVQIxf/1+HWY4R3eNUNSNzQgmMCAh3yPiFfZHc8+FYaJM+kHlrSU8 clXXpf6Ci6W28hNYTIUwqUErm0ChzbYl5I+28Jd76d1Y7XCawOCyuPtjNnuncHUAnlmb8bAM4 9M/ErC64H9+OXyCmfQ68Te3Eqs31TnaB2+BhiUVTuJKbLdRw6j4T3Gmi78rM5xhIGU+FzYIY8 azolPjhOEDRx01ZxV6EkNPtuk9bCxymJpCGLzQ== 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Mark Cave-Ayland During realize memory_region_init_ram_nomigrate() is used to initialise the RAM memory region used for the framebuffer but the owner object reference is incorrect since MacFbState is a typedef and not a QOM type. Change the memory region owner to be the corresponding DeviceState to fix the issue and prevent random crashes during macfb_common_realize(). Signed-off-by: Mark Cave-Ayland Fixes: 8ac919a0654 ("hw/m68k: add Nubus macfb video card") Reviewed-by: BALATON Zoltan Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Laurent Vivier Message-Id: <20211007221253.29024-4-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- hw/display/macfb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/display/macfb.c b/hw/display/macfb.c index 2ec25c5d6f7a..b363bab8896a 100644 --- a/hw/display/macfb.c +++ b/hw/display/macfb.c @@ -365,7 +365,7 @@ static bool macfb_common_realize(DeviceState *dev, MacfbState *s, Error **errp) memory_region_init_io(&s->mem_ctrl, OBJECT(dev), &macfb_ctrl_ops, s, "macfb-ctrl", 0x1000); - memory_region_init_ram_nomigrate(&s->mem_vram, OBJECT(s), "macfb-vram", + memory_region_init_ram_nomigrate(&s->mem_vram, OBJECT(dev), "macfb-vram", MACFB_VRAM_SIZE, &error_abort); s->vram = memory_region_get_ram_ptr(&s->mem_vram); s->vram_bit_mask = MACFB_VRAM_SIZE - 1; From patchwork Fri Oct 8 11:45:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1538326 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HQmkF17chz9sP7 for ; Fri, 8 Oct 2021 22:51:33 +1100 (AEDT) Received: from localhost ([::1]:55564 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYoPS-0003qf-TE for incoming@patchwork.ozlabs.org; Fri, 08 Oct 2021 07:51:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50338) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYoJc-0006GE-8w for qemu-devel@nongnu.org; Fri, 08 Oct 2021 07:45:29 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:35291) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYoJX-0006wo-Rq for qemu-devel@nongnu.org; Fri, 08 Oct 2021 07:45:26 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MFKX3-1mWrJQ2ZmT-00FiNH; Fri, 08 Oct 2021 13:45:21 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 04/13] macfb: fix overflow of color_palette array Date: Fri, 8 Oct 2021 13:45:09 +0200 Message-Id: <20211008114518.757615-5-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211008114518.757615-1-laurent@vivier.eu> References: <20211008114518.757615-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:2zNOwlwd1PfnPqmBw8BdLlZtUT2N/oR9KExfZH28VwiF6v/OUxx qgRYJFwYIBptn23TvYgj2hWq2zivPRC2haM61MN6XMqX9nUneLoGwwwwjusqDpbCujW/Or8 CcRqSdVofZUM0WunmhVrPb8XOUGDm5xyvSEcb8vvA6Meyz1SqYfEiB3ll6JRyuRoZZuRb8S d5cv6O4oxzcj9ZsZjV75Q== X-UI-Out-Filterresults: notjunk:1;V03:K0:I3aqEsHuMEM=:esJOlYJFBp4TxBV0+wt7X3 Wt3KtKV4QoAicfczlWzIl/zi08UB2DeJ6a91vJmbUhG2PWRGJpIC074UGOm3mduSxYfdsPquq M5HbHrbBE8sgDKcILVY6roxRlK3Uuzfcw+oWM4fECxZcqH7szmInRxFfWBCUeSN+YVb2VUxgo 6jKAQ1eYaxS6YujgQ2V8TMG5sUrSOIllZDoQYzEGLmSJR736y0SLDs2vc23Bwi6oEHMjq0gfZ dUrMAH1/8uKM36AvOk/9k7sJ5lLFrUosSCY+5lQFPVE4XsM6LOZVyrxDtoqG/UUme2tK6ciRt paBJ1BHsEKE6/DDAWpZ4qBCiVLEqpLDevdRzlKbSLRywQj6qYThGDq7MutEoEo9zkGtizcFXW IdXMVPg4LNGZcGeq2PG897hKHVj1M3WdtZzS2GCksssNDHJS9gUgCuiQPJx4/6uJ/a5FD/RlU 0wnCIxgPfsC7LTuLU7SvIXLwcjEj/h8nJc0QrWyJ0/ZQ5AOHTkYG4VpoMRD//EMTZS7TSaflb fbivH4ZrQpVajsXnBravfawGpfbbL1PDACxhKSNonzdkLPgfG96M2qpptvkzIVskB/sk2DSOj XZ8eHk7e8niTwpW6SJ3xqfrgnKOcNugdeyGE3+eiL4D0DMOci37PgQ5Jx+11AUBxFz4jQAGhx J73OlmjcWrQhylEdSiOUDuL2dnEHdwSBM30rItfyGU0WMWXKX+3iGU16OGkPIfsyF3tFYYPcl cYb8nIyO4gvBhXmoK4PF2q2cfgH0rOFg48nYCw== 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 The palette_current index counter has a maximum size of 256 * 3 to cover a full color palette of 256 RGB entries. Linux assumes that the palette_current index wraps back around to zero after writing 256 RGB entries so ensure that palette_current is reset at this point to prevent data corruption within MacfbState. Signed-off-by: Mark Cave-Ayland Reviewed-by: Laurent Vivier Message-Id: <20211007221253.29024-5-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- hw/display/macfb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/display/macfb.c b/hw/display/macfb.c index b363bab8896a..39dab49026c3 100644 --- a/hw/display/macfb.c +++ b/hw/display/macfb.c @@ -303,7 +303,9 @@ static void macfb_ctrl_write(void *opaque, s->palette_current = 0; break; case DAFB_LUT: - s->color_palette[s->palette_current++] = val; + s->color_palette[s->palette_current] = val; + s->palette_current = (s->palette_current + 1) % + ARRAY_SIZE(s->color_palette); if (s->palette_current % 3) { macfb_invalidate_display(s); } From patchwork Fri Oct 8 11:45:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1538341 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HQmzx37mfz9sR4 for ; Fri, 8 Oct 2021 23:03:24 +1100 (AEDT) Received: from localhost ([::1]:53594 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYoau-0004ox-Ou for incoming@patchwork.ozlabs.org; Fri, 08 Oct 2021 08:03:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50480) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYoJo-0006Oy-L3 for qemu-devel@nongnu.org; Fri, 08 Oct 2021 07:45:40 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:40743) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYoJi-00072W-7O for qemu-devel@nongnu.org; Fri, 08 Oct 2021 07:45:40 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1N5FtF-1mj9TL0qP7-011Eql; Fri, 08 Oct 2021 13:45:22 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 05/13] macfb: use memory_region_init_ram() in macfb_common_realize() for the framebuffer Date: Fri, 8 Oct 2021 13:45:10 +0200 Message-Id: <20211008114518.757615-6-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211008114518.757615-1-laurent@vivier.eu> References: <20211008114518.757615-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:+YOIURghBOvBiZDnikeXkHAk2nh7Ga+lhIfGKTQ1jKRM9+tJycR 2oqu8aFdxZDYJ+ORc8jG7prLB6K5IN8UplkQSRlft8NlQMwoqBFY1YeWmuWdXehzbQfONvj +jl5IVk4T0zZshi6qQyDQKmf8WwyW7vMTCgE7/jKptSRZaiAORz5lQFXJ/1rY6390ggEo5u NVyGFW9A+o6l/GpjkBGWw== X-UI-Out-Filterresults: notjunk:1;V03:K0:aDxXFUAJIzo=:EyUtUzsAGN2S3Z7jty80n3 VG4jSDhLynyvQn5++ty/63mxa4U4wV41R1L1z1KtLlU/tCJgXu8GK9skhZHPYHzMN3FMVmRL6 nmqKE5SSCm9kMevnvDo7NrGRzAqHAxRft8hHPPPbajMxYAGLkQucm12MSoUTItvAdnJ8hNeTs bzdLMo7PK7daeIMKL5hjpVoI0COX2SqQKEvHdV9iziqRPD2RCF++bAWNa/2h6BaDrAxnpBgsA /M9BGwM/A+5L7St5OKAu8sLsncW/K2xuCYk0Xk70zQJoSHBNk+By1rEBnpnoJe0C2iasBnmHa s6/tgB2mPtKguFxOLDGtnRnVIHdSDrmVYtKuB+whb8WGLwiI/xinTtpV6BNTmPEgleQlTRrn0 u3zNQBd3oaYnJauajtx0/JX/d+30FQZz46iUCHBWaSgjKl9XjTGvxCqvzyN9e5M0MYRsam7KE b2VKOVhgnprqRievf1tyiG2rodI22oVi/jJ0MCq84rqxYzSR3C2aR/ieCzEYaMfCn/kkfabJz 44TL4GF4fsan7kFgE4BZyGOh18nbBHUaoPt4VUllHJtvCxySk0JH8DACcPFQ8h89Su0LUfnvf FFbp5a+Ltg3rlh4vv43HceBsKEqHMTKeRKhSiGwzo0689v1pwEE9PKqyxmq10q3WpHf0V/ZUc E3q7f00Ym39zABAr4pMPG/HGIEBjyByPV0/EsZeLRTd0Y3EADcDTxFXlxd/wxjwwKA8LIVoBQ 1NbcQpYq9ojtTj9rCDPqTKwra+pgCqp6ejlfvw== Received-SPF: none client-ip=212.227.126.130; 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mark Cave-Ayland , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Mark Cave-Ayland Currently macfb_common_realize() defines the framebuffer RAM memory region as being non-migrateable but then immediately registers it for migration. Replace memory_region_init_ram_nomigrate() with memory_region_init_ram() which is clearer and does exactly the same thing. Signed-off-by: Mark Cave-Ayland Reviewed-by: BALATON Zoltan Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Laurent Vivier Message-Id: <20211007221253.29024-6-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- hw/display/macfb.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/display/macfb.c b/hw/display/macfb.c index 39dab49026c3..f88f5a652394 100644 --- a/hw/display/macfb.c +++ b/hw/display/macfb.c @@ -367,11 +367,10 @@ static bool macfb_common_realize(DeviceState *dev, MacfbState *s, Error **errp) memory_region_init_io(&s->mem_ctrl, OBJECT(dev), &macfb_ctrl_ops, s, "macfb-ctrl", 0x1000); - memory_region_init_ram_nomigrate(&s->mem_vram, OBJECT(dev), "macfb-vram", - MACFB_VRAM_SIZE, &error_abort); + memory_region_init_ram(&s->mem_vram, OBJECT(dev), "macfb-vram", + MACFB_VRAM_SIZE, &error_abort); s->vram = memory_region_get_ram_ptr(&s->mem_vram); s->vram_bit_mask = MACFB_VRAM_SIZE - 1; - vmstate_register_ram(&s->mem_vram, dev); memory_region_set_coalescing(&s->mem_vram); return true; From patchwork Fri Oct 8 11:45:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1538330 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HQmn92ym1z9sP7 for ; Fri, 8 Oct 2021 22:54:05 +1100 (AEDT) Received: from localhost ([::1]:34448 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYoRv-0000EN-4q for incoming@patchwork.ozlabs.org; Fri, 08 Oct 2021 07:54:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50470) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYoJo-0006O1-Cx for qemu-devel@nongnu.org; Fri, 08 Oct 2021 07:45:40 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:37159) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYoJi-00072V-7B for qemu-devel@nongnu.org; Fri, 08 Oct 2021 07:45:40 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MyK1E-1myJsk3ANw-00yhlG; Fri, 08 Oct 2021 13:45:22 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 06/13] macfb: add trace events for reading and writing the control registers Date: Fri, 8 Oct 2021 13:45:11 +0200 Message-Id: <20211008114518.757615-7-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211008114518.757615-1-laurent@vivier.eu> References: <20211008114518.757615-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:SN2TGNsFluwGTy6ubeUfM+EB+euKKMcxROCHud8xn1fOyb4BiYy wAFzbm++AUcPwh8N+SlPt0A+cpaobQKSZCtzwxXbpCxk/JSefySb3NXJofoXJrUD223CuPz 8PJAST32w3flHBSZnImrg7GFr1Vh4xstElRPIjEm9TRqja8l7mQY9udIciGF9vWIL2/4aoz ZSZUM5R3oIlqnm5SbquUA== X-UI-Out-Filterresults: notjunk:1;V03:K0:TxUD7p9s7qg=:GWoxo3Uj+fEs4w8DmGzc5D G7yUHUGMORhxiaTpVA9uViB/YLqFliB7wO4nS9rNxQ7PI0yL2C5X6hpWGHzOdNkrC7etJVHZ7 gDoykkvhEv/2y/I1KfrcYutDNkatdjegZnulA3AAbdjMEkxtlgpXvEzeVYvbwJy0RLAZtjHpT vSCjnDwFRh1uWfh1/ydL0WvtD4B22O3hr7SbL6qEXliJY+2FWEPVelQQ69+lYOdGeODnJuCpz zmbGnEtmyEl/UfF4AsKVOm1N0D/KYMGCNPpsQInNclCqSqcwKX/lkQIPyTkeNiqGnLGIATKyv SpQFLJaWXAGGDHbiS2ZHPA/760lJTF5/ib9Qxd0W27UdJcdDJ7EqVgcuUkR15jQbCjwIJX91Q ihUDmJxlyPHW2Gm65vpDvBxWmgn4Q6zEDwAYKaGLw45tDesHl4kSXNIBF12LGqUblbIbIPZEj b02Mk/gDew9/S31oMcKE26jX7cxvEW13fFz91VUOcW3X7UOK92/krU8Ya7lEUDYfFyYgIrvJ8 eaBIMSymYEV8gZ2KfV4SKA1yhk00pAqeT/m96jICz88//nJVOMN9eLcmBcXRxcHpFKOH+b4cB 93fGQbImjpcLN+bp/iF9iFcSzprZPcC+yrRuEBndErEqkD3E7opPFbHcST3tTTyVEW4KyMi6C hFzSYyHNt7eNUdJy62D8eFcEu+K8wgX5VFN/1RyVDQv9+eaqtGN/uH+j+xryU1YeYzUrsIQYj ypat47VNpGNGTQMhUxw1B6FBbM+dTaZ5qADBUw== 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 , =?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 Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Laurent Vivier Message-Id: <20211007221253.29024-7-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- hw/display/macfb.c | 8 +++++++- hw/display/trace-events | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/hw/display/macfb.c b/hw/display/macfb.c index f88f5a652394..1128a51c9836 100644 --- a/hw/display/macfb.c +++ b/hw/display/macfb.c @@ -20,6 +20,7 @@ #include "qapi/error.h" #include "hw/qdev-properties.h" #include "migration/vmstate.h" +#include "trace.h" #define VIDEO_BASE 0x00001000 #define DAFB_BASE 0x00800000 @@ -289,7 +290,10 @@ static uint64_t macfb_ctrl_read(void *opaque, hwaddr addr, unsigned int size) { - return 0; + uint64_t val = 0; + + trace_macfb_ctrl_read(addr, val, size); + return val; } static void macfb_ctrl_write(void *opaque, @@ -311,6 +315,8 @@ static void macfb_ctrl_write(void *opaque, } break; } + + trace_macfb_ctrl_write(addr, val, size); } static const MemoryRegionOps macfb_ctrl_ops = { diff --git a/hw/display/trace-events b/hw/display/trace-events index f03f6655bcb7..f227de1bb96b 100644 --- a/hw/display/trace-events +++ b/hw/display/trace-events @@ -167,3 +167,7 @@ sm501_disp_ctrl_read(uint32_t addr, uint32_t val) "addr=0x%x, val=0x%x" sm501_disp_ctrl_write(uint32_t addr, uint32_t val) "addr=0x%x, val=0x%x" sm501_2d_engine_read(uint32_t addr, uint32_t val) "addr=0x%x, val=0x%x" sm501_2d_engine_write(uint32_t addr, uint32_t val) "addr=0x%x, val=0x%x" + +# macfb.c +macfb_ctrl_read(uint64_t addr, uint64_t value, unsigned int size) "addr 0x%"PRIx64 " value 0x%"PRIx64 " size %u" +macfb_ctrl_write(uint64_t addr, uint64_t value, unsigned int size) "addr 0x%"PRIx64 " value 0x%"PRIx64 " size %u" From patchwork Fri Oct 8 11:45:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1538324 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HQmgV05mdz9sP7 for ; Fri, 8 Oct 2021 22:49:10 +1100 (AEDT) Received: from localhost ([::1]:50758 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYoN9-0000Tw-NV for incoming@patchwork.ozlabs.org; Fri, 08 Oct 2021 07:49:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50454) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYoJn-0006Lv-NV for qemu-devel@nongnu.org; Fri, 08 Oct 2021 07:45:39 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:57365) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYoJb-0006yy-Vr for qemu-devel@nongnu.org; Fri, 08 Oct 2021 07:45:37 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MHXSD-1mUfS60wcL-00DWVv; Fri, 08 Oct 2021 13:45:23 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 07/13] macfb: implement mode sense to allow display type to be detected Date: Fri, 8 Oct 2021 13:45:12 +0200 Message-Id: <20211008114518.757615-8-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211008114518.757615-1-laurent@vivier.eu> References: <20211008114518.757615-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:DJw3w7G8u4yZR6E2YDxIn2sqKos4lWSSFP78yyZwkeREytUQTNm DUp+pfsR8JC/wzb/cFLaOcf/gGFl2sNfSLcZ/kYqUoGggeud0mR5Qwr7YRAMjIgdn4Mzkq9 P1k5veG3GoY8WT1hESsEOJ+EK8XesUeMRfSoS4vogcwc7hX4nEuFTyvbZFilAU+Er/8vYDb zG06U+mq5UcMOzQJtc22w== X-UI-Out-Filterresults: notjunk:1;V03:K0:6JCrKgzlO9g=:AqK6dQesI6KCforDNNLxpj hL0CggQqsGEzL0iuwQegQCpdgUmL+upgWtZu2C+rgEVw0tYHR8IB4uzYMciNuYlfaxHFjM4n5 syxRiN39nYp2hfED+cDQSQiI8YBfCOiRxlHN7Drg8ZbIuRhjMylHDJTnMhsCvaQ//j9pdXvO2 WVH6wV87vcgvNcOEKG1j2Czu1uSToC2xQoCaycdiNj1UwIVO9zdFIH8TToSod86u6zd1g/K4h 4kpIhHlCvKrcp9tgs1Gosm+RPJFH4yjaopodrr2wAIsEfcRGQ/tXH5kttJb+FunBHwvRQPJv3 OD+zKxek1mvCWF+nl+maTdU8aFdMMZ+jkIpxvapxrEwQVVT14Plm/cppY4YWjNBJKwA4QM6Hb 8twPjbgrcdpeLsMLWw6woGTdpfq93I+Q/BuK/La7BMap7p9Opu8OpjEIiYVVaXvSVqet2grYP BpRsGxlYozWL9W5AoHvQ0cRm2EadtW7KwwHFnOaamIoDJQM527GQJxx9NehvoxK1wkWztByz9 ccESKiLL4oJQLj/5qHJ/CAj3bPGyQD+aVXIhCMpU+qci6RrgEg05K+yID/6IslF4Dtstny597 3XOeUlVjyi6AkO7yYhQmaIHnqd97xYlpi8zqYt0AD18KrfR+xAcCnP4OFpMf66uwsyqg2fJSG ExGCbbjGhP54ghYhtFsR4SNhxZ3Xb/Jg6HsrR6PPS/so+P5SYNtTqhO8rBMNFZ0NNN26bgBV9 bC2aNTK7CK9iFr57y1atJO5hZIgu9liC5wegFQ== 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_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 The MacOS toolbox ROM uses the monitor sense to detect the display type and then offer a fixed set of resolutions and colour depths accordingly. Implement the monitor sense using information found in Apple Technical Note HW26: "Macintosh Quadra Built-In Video" along with some local experiments. Since the default configuration is 640 x 480 with 8-bit colour then hardcode the sense register to return MACFB_DISPLAY_VGA for now. Signed-off-by: Mark Cave-Ayland Reviewed-by: Laurent Vivier Message-Id: <20211007221253.29024-8-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- include/hw/display/macfb.h | 20 +++++++ hw/display/macfb.c | 117 ++++++++++++++++++++++++++++++++++++- hw/display/trace-events | 2 + 3 files changed, 137 insertions(+), 2 deletions(-) diff --git a/include/hw/display/macfb.h b/include/hw/display/macfb.h index 80806b0306a9..febf4ce0e843 100644 --- a/include/hw/display/macfb.h +++ b/include/hw/display/macfb.h @@ -17,6 +17,24 @@ #include "ui/console.h" #include "qom/object.h" +typedef enum { + MACFB_DISPLAY_APPLE_21_COLOR = 0, + MACFB_DISPLAY_APPLE_PORTRAIT = 1, + MACFB_DISPLAY_APPLE_12_RGB = 2, + MACFB_DISPLAY_APPLE_2PAGE_MONO = 3, + MACFB_DISPLAY_NTSC_UNDERSCAN = 4, + MACFB_DISPLAY_NTSC_OVERSCAN = 5, + MACFB_DISPLAY_APPLE_12_MONO = 6, + MACFB_DISPLAY_APPLE_13_RGB = 7, + MACFB_DISPLAY_16_COLOR = 8, + MACFB_DISPLAY_PAL1_UNDERSCAN = 9, + MACFB_DISPLAY_PAL1_OVERSCAN = 10, + MACFB_DISPLAY_PAL2_UNDERSCAN = 11, + MACFB_DISPLAY_PAL2_OVERSCAN = 12, + MACFB_DISPLAY_VGA = 13, + MACFB_DISPLAY_SVGA = 14, +} MacfbDisplayType; + typedef struct MacfbState { MemoryRegion mem_vram; MemoryRegion mem_ctrl; @@ -28,6 +46,8 @@ typedef struct MacfbState { uint8_t color_palette[256 * 3]; uint32_t width, height; /* in pixels */ uint8_t depth; + + uint32_t sense; } MacfbState; #define TYPE_MACFB "sysbus-macfb" diff --git a/hw/display/macfb.c b/hw/display/macfb.c index 1128a51c9836..6e485d7aef90 100644 --- a/hw/display/macfb.c +++ b/hw/display/macfb.c @@ -28,8 +28,66 @@ #define MACFB_PAGE_SIZE 4096 #define MACFB_VRAM_SIZE (4 * MiB) -#define DAFB_RESET 0x200 -#define DAFB_LUT 0x213 +#define DAFB_MODE_SENSE 0x1c +#define DAFB_RESET 0x200 +#define DAFB_LUT 0x213 + + +/* + * Quadra sense codes taken from Apple Technical Note HW26: + * "Macintosh Quadra Built-In Video". The sense codes and + * extended sense codes have different meanings: + * + * Sense: + * bit 2: SENSE2 (pin 10) + * bit 1: SENSE1 (pin 7) + * bit 0: SENSE0 (pin 4) + * + * 0 = pin tied to ground + * 1 = pin unconnected + * + * Extended Sense: + * bit 2: pins 4-10 + * bit 1: pins 10-7 + * bit 0: pins 7-4 + * + * 0 = pins tied together + * 1 = pins unconnected + * + * Reads from the sense register appear to be active low, i.e. a 1 indicates + * that the pin is tied to ground, a 0 indicates the pin is disconnected. + * + * Writes to the sense register appear to activate pulldowns i.e. a 1 enables + * a pulldown on a particular pin. + * + * The MacOS toolbox appears to use a series of reads and writes to first + * determine if extended sense is to be used, and then check which pins are + * tied together in order to determine the display type. + */ + +typedef struct MacFbSense { + uint8_t type; + uint8_t sense; + uint8_t ext_sense; +} MacFbSense; + +static MacFbSense macfb_sense_table[] = { + { MACFB_DISPLAY_APPLE_21_COLOR, 0x0, 0 }, + { MACFB_DISPLAY_APPLE_PORTRAIT, 0x1, 0 }, + { MACFB_DISPLAY_APPLE_12_RGB, 0x2, 0 }, + { MACFB_DISPLAY_APPLE_2PAGE_MONO, 0x3, 0 }, + { MACFB_DISPLAY_NTSC_UNDERSCAN, 0x4, 0 }, + { MACFB_DISPLAY_NTSC_OVERSCAN, 0x4, 0 }, + { MACFB_DISPLAY_APPLE_12_MONO, 0x6, 0 }, + { MACFB_DISPLAY_APPLE_13_RGB, 0x6, 0 }, + { MACFB_DISPLAY_16_COLOR, 0x7, 0x3 }, + { MACFB_DISPLAY_PAL1_UNDERSCAN, 0x7, 0x0 }, + { MACFB_DISPLAY_PAL1_OVERSCAN, 0x7, 0x0 }, + { MACFB_DISPLAY_PAL2_UNDERSCAN, 0x7, 0x6 }, + { MACFB_DISPLAY_PAL2_OVERSCAN, 0x7, 0x6 }, + { MACFB_DISPLAY_VGA, 0x7, 0x5 }, + { MACFB_DISPLAY_SVGA, 0x7, 0x5 }, +}; typedef void macfb_draw_line_func(MacfbState *s, uint8_t *d, uint32_t addr, @@ -253,6 +311,50 @@ static void macfb_invalidate_display(void *opaque) memory_region_set_dirty(&s->mem_vram, 0, MACFB_VRAM_SIZE); } +static uint32_t macfb_sense_read(MacfbState *s) +{ + MacFbSense *macfb_sense; + uint8_t sense; + + macfb_sense = &macfb_sense_table[MACFB_DISPLAY_VGA]; + if (macfb_sense->sense == 0x7) { + /* Extended sense */ + sense = 0; + if (!(macfb_sense->ext_sense & 1)) { + /* Pins 7-4 together */ + if (~s->sense & 3) { + sense = (~s->sense & 7) | 3; + } + } + if (!(macfb_sense->ext_sense & 2)) { + /* Pins 10-7 together */ + if (~s->sense & 6) { + sense = (~s->sense & 7) | 6; + } + } + if (!(macfb_sense->ext_sense & 4)) { + /* Pins 4-10 together */ + if (~s->sense & 5) { + sense = (~s->sense & 7) | 5; + } + } + } else { + /* Normal sense */ + sense = (~macfb_sense->sense & 7) | (~s->sense & 7); + } + + trace_macfb_sense_read(sense); + return sense; +} + +static void macfb_sense_write(MacfbState *s, uint32_t val) +{ + s->sense = val; + + trace_macfb_sense_write(val); + return; +} + static void macfb_update_display(void *opaque) { MacfbState *s = opaque; @@ -290,8 +392,15 @@ static uint64_t macfb_ctrl_read(void *opaque, hwaddr addr, unsigned int size) { + MacfbState *s = opaque; uint64_t val = 0; + switch (addr) { + case DAFB_MODE_SENSE: + val = macfb_sense_read(s); + break; + } + trace_macfb_ctrl_read(addr, val, size); return val; } @@ -303,6 +412,9 @@ static void macfb_ctrl_write(void *opaque, { MacfbState *s = opaque; switch (addr) { + case DAFB_MODE_SENSE: + macfb_sense_write(s, val); + break; case DAFB_RESET: s->palette_current = 0; break; @@ -342,6 +454,7 @@ static const VMStateDescription vmstate_macfb = { .fields = (VMStateField[]) { VMSTATE_UINT8_ARRAY(color_palette, MacfbState, 256 * 3), VMSTATE_UINT32(palette_current, MacfbState), + VMSTATE_UINT32(sense, MacfbState), VMSTATE_END_OF_LIST() } }; diff --git a/hw/display/trace-events b/hw/display/trace-events index f227de1bb96b..30cb460e4d1b 100644 --- a/hw/display/trace-events +++ b/hw/display/trace-events @@ -171,3 +171,5 @@ sm501_2d_engine_write(uint32_t addr, uint32_t val) "addr=0x%x, val=0x%x" # macfb.c macfb_ctrl_read(uint64_t addr, uint64_t value, unsigned int size) "addr 0x%"PRIx64 " value 0x%"PRIx64 " size %u" macfb_ctrl_write(uint64_t addr, uint64_t value, unsigned int size) "addr 0x%"PRIx64 " value 0x%"PRIx64 " size %u" +macfb_sense_read(uint32_t value) "video sense: 0x%"PRIx32 +macfb_sense_write(uint32_t value) "video sense: 0x%"PRIx32 From patchwork Fri Oct 8 11:45:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1538328 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HQmlb53xTz9sP7 for ; Fri, 8 Oct 2021 22:52:43 +1100 (AEDT) Received: from localhost ([::1]:59274 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYoQb-0006OM-ES for incoming@patchwork.ozlabs.org; Fri, 08 Oct 2021 07:52:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50514) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYoJp-0006Si-Pe for qemu-devel@nongnu.org; Fri, 08 Oct 2021 07:45:41 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:49631) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYoJi-00072o-7M for qemu-devel@nongnu.org; Fri, 08 Oct 2021 07:45:41 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MNtGq-1mNt8N39Q0-00OH50; Fri, 08 Oct 2021 13:45:24 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 08/13] macfb: add qdev property to specify display type Date: Fri, 8 Oct 2021 13:45:13 +0200 Message-Id: <20211008114518.757615-9-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211008114518.757615-1-laurent@vivier.eu> References: <20211008114518.757615-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:lo76DOm9QLp+EsrAabaM2vPa23U0emVhihPVU8hr3vPiRRfytZy pXTD2AqroGfHeMNJLGqm8M+gkCWeQHgIkAimYp+IdvPwmesTBfNZr4fc48HYBEbRd/tbRqb Ba0yom42p9ofRnp2UoqCSLj7Xn21k28GvIdPqLPwt9EO+ipn+U1i5dSWIyrwYlZDO9K+9wc IzhWwpgSqqkka3MJ0fyoQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:ZqeySFZM2DA=:SeqNzLBzgUlFfy5+/21EAY PS6L9XfhrzzMeGmRqnQ3TMB/iV6ivdkcM8Mb6pb8BbcF5jUbDXHPBZ3NxxDOp0WE6d21jgHrE /8tKoAp47xAvk4TsvETT72cwwyccjB0Ds+Rxy/UdNy9cIGurVTVcslWnkq5T2dfP/zWtilbEs +u9kjNVCkAoMkq2yZYTJvoZiKAKAKWrXiJE4EFQAlyN3ngpHEnZPDSPl0HQI6bZtT9J373xdF KiLhBj1phA3IvL0VoBfCyevBt5ZRGP5tht/PkuSgzKhLJzLJGPDVV0gYLyYWGpfXwZrPD9tQN EEMyN8aM22j94JSrwjABrw4LbmUljbgxf4ImKjHIV5wXvD3tWgBTcFpsAHV76pmtPM5+tZ0EF arybXiVXIfKyon8J+mf1xwh/X6YvCGUW+tX4PWj8IjwN63gVIZpY9+ugcBPNDlpgw4AlYLdI8 j06QwO9ARtFPljTG/fnroZJb5Dg7z1TYyPM1/BaMouqZNl+mzuQJeRgLNQxiUEyjXL0UdYWfD +TOb26GN6zg0OMuT5LOPvPc004afRU7LU0k+CSd9A1D1faSVY2i2ifU0lv6pnRB0sVSJtNTrT ZGBD4fJ8TfHhLCEL6YCogFztiZ3XHVbnp/dxM+ypkHKJrE6aUQ3ypRGxXv9bme7nxn37nkvn7 eps2292JWw+Xu7f7unUQ6ft99Mm9CjW6jjNa7lQm9fGv1ZtnETETgFzgWKzK37EW+ms8QzGhb hO+EkZ7VH/NpFepW4rsgBtIjD/3RdLra1SDqXg== 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 , =?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 Since the available resolutions and colour depths are determined by the attached display type, add a qdev property to allow the display type to be specified. The main resolutions of interest are high resolution 1152x870 with 8-bit colour and SVGA resolution up to 800x600 with 24-bit colour so update the q800 machine to allow high resolution mode if specified and otherwise fall back to SVGA. Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Laurent Vivier Message-Id: <20211007221253.29024-9-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- include/hw/display/macfb.h | 1 + hw/display/macfb.c | 7 ++++++- hw/m68k/q800.c | 5 +++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/include/hw/display/macfb.h b/include/hw/display/macfb.h index febf4ce0e843..e95a97ebdcda 100644 --- a/include/hw/display/macfb.h +++ b/include/hw/display/macfb.h @@ -46,6 +46,7 @@ typedef struct MacfbState { uint8_t color_palette[256 * 3]; uint32_t width, height; /* in pixels */ uint8_t depth; + uint8_t type; uint32_t sense; } MacfbState; diff --git a/hw/display/macfb.c b/hw/display/macfb.c index 6e485d7aef90..f98bcdec2dc6 100644 --- a/hw/display/macfb.c +++ b/hw/display/macfb.c @@ -316,7 +316,8 @@ static uint32_t macfb_sense_read(MacfbState *s) MacFbSense *macfb_sense; uint8_t sense; - macfb_sense = &macfb_sense_table[MACFB_DISPLAY_VGA]; + assert(s->type < ARRAY_SIZE(macfb_sense_table)); + macfb_sense = &macfb_sense_table[s->type]; if (macfb_sense->sense == 0x7) { /* Extended sense */ sense = 0; @@ -544,6 +545,8 @@ static Property macfb_sysbus_properties[] = { DEFINE_PROP_UINT32("width", MacfbSysBusState, macfb.width, 640), DEFINE_PROP_UINT32("height", MacfbSysBusState, macfb.height, 480), DEFINE_PROP_UINT8("depth", MacfbSysBusState, macfb.depth, 8), + DEFINE_PROP_UINT8("display", MacfbSysBusState, macfb.type, + MACFB_DISPLAY_VGA), DEFINE_PROP_END_OF_LIST(), }; @@ -551,6 +554,8 @@ static Property macfb_nubus_properties[] = { DEFINE_PROP_UINT32("width", MacfbNubusState, macfb.width, 640), DEFINE_PROP_UINT32("height", MacfbNubusState, macfb.height, 480), DEFINE_PROP_UINT8("depth", MacfbNubusState, macfb.depth, 8), + DEFINE_PROP_UINT8("display", MacfbNubusState, macfb.type, + MACFB_DISPLAY_VGA), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c index 09b336602482..5223b880bc2d 100644 --- a/hw/m68k/q800.c +++ b/hw/m68k/q800.c @@ -421,6 +421,11 @@ static void q800_init(MachineState *machine) qdev_prop_set_uint32(dev, "width", graphic_width); qdev_prop_set_uint32(dev, "height", graphic_height); qdev_prop_set_uint8(dev, "depth", graphic_depth); + if (graphic_width == 1152 && graphic_height == 870 && graphic_depth == 8) { + qdev_prop_set_uint8(dev, "display", MACFB_DISPLAY_APPLE_21_COLOR); + } else { + qdev_prop_set_uint8(dev, "display", MACFB_DISPLAY_VGA); + } qdev_realize_and_unref(dev, BUS(nubus), &error_fatal); cs = CPU(cpu); From patchwork Fri Oct 8 11:45:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1538334 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HQmp256CNz9sP7 for ; Fri, 8 Oct 2021 22:54:50 +1100 (AEDT) Received: from localhost ([::1]:38490 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYoSe-0002va-FN for incoming@patchwork.ozlabs.org; Fri, 08 Oct 2021 07:54:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50418) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYoJj-0006Ix-Ce for qemu-devel@nongnu.org; Fri, 08 Oct 2021 07:45:35 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:58665) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYoJb-0006yk-VI for qemu-devel@nongnu.org; Fri, 08 Oct 2021 07:45:34 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MEmIl-1mXPHL10DT-00GGL3; Fri, 08 Oct 2021 13:45:24 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 09/13] macfb: add common monitor modes supported by the MacOS toolbox ROM Date: Fri, 8 Oct 2021 13:45:14 +0200 Message-Id: <20211008114518.757615-10-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211008114518.757615-1-laurent@vivier.eu> References: <20211008114518.757615-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:H13Xp2T9dxvsvX7ucsMAvlqvyR8qrrSJW89PAQ2cL1gzbAwgGDL I9LQ/++S96qOEvYNO+GUxQoMtEewO3EZs6akDZnfL8RPtxfJLIwR99JcpeM4YxaEXlToHWd lPbVO1Zl7NWebWnDpvFnQEi8ERnWzhAY/vWZB5TT2JUFvTz3DfNQ4ek6gcwxrNp8Pcslivd 0xYcK1Qe6rYd9Y4qSobhA== X-UI-Out-Filterresults: notjunk:1;V03:K0:2vFseOhnQnk=:e/nQGh6jdXpnTK41DC2uz4 ngL2wzM9f+RMLgqg1QPYJHpOwg9k9KMHpmBCY1YxglEyTbb8pEBzbBUBf+wUEznH8ju4nLd+Z gsBsER4qR8UeNGcupHd0iRnu49moxkhVYwwhnL8ZKbuIk0rsXVpXhs3Z+qQYu0CLJztwX1uhX L8VbsBs3YDoYwnjrgXPtWkE21134H8chjGFreul4N0lbe9Pq8TvFZJD52TcFn2nQ+CwhhQc2w SyIgTYaDqP1WwO588my9POKXRBPVPm3HFbb6vVyvcgJHxd/v5aziWIwfW9MiqO5+YAQenHPov 1gX4Y7M98y0dEG6sBk6/xKILixwk1hJ5NIyQCAV1gTCT/xOgXDi/OxF3OHAMX+nqTFznac1ue czMBSw7w6Xub7K5dz0lF+XlVrwIwi5hJOwWwx+YOjgpNKfIxIKOpA15QASSx1fPGyqWG08237 jp2DZpw6FhucY6pCcw+oOBUBObfMm1qz2zl93ZYzjVdA+vpsh7cCBkhGJLxcEsbTBQNmJu0lr 2F4XYpWakkOjmFS2IeQk4OwnSgv/z6gYlxK+/mszpmi+RVX2V027lfnKZoLUiTrfUufrpFZ4C Etvl3A9JvgCBUejMqSE5RU+FHuTqiZFCLA9I2NoXmn7G+WjvHwoRWm5UU6BCb/XNL+juCz/x2 39Bo2+jLqhchCdTuBPacV1SfXaX7wmqJ5u8NJjI1InpbPPjlQGn3fPLuenXUogJ7Tyg/7xzvP G+hW66Z6Dzu65enQKJi/+hTQ6gle825/GsxViQ== 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 The monitor modes table is found by experimenting with the Monitors Control Panel in MacOS and analysing the reads/writes. From this it can be found that the mode is controlled by writes to the DAFB_MODE_CTRL1 and DAFB_MODE_CTRL2 registers. Implement the first block of DAFB registers as a register array including the existing sense register, the newly discovered control registers above, and also the DAFB_MODE_VADDR1 and DAFB_MODE_VADDR2 registers which are used by NetBSD to determine the current video mode. These experiments also show that the offset of the start of video RAM and the stride can change depending upon the monitor mode, so update macfb_draw_graphic() and both the BI_MAC_VADDR and BI_MAC_VROW bootinfo for the q800 machine accordingly. Finally update macfb_common_realize() so that only the resolution and depth supported by the display type can be specified on the command line, and add an error hint showing the list of supported resolutions and depths if the user tries to specify an invalid display mode. Signed-off-by: Mark Cave-Ayland Reviewed-by: Laurent Vivier Message-Id: <20211007221253.29024-10-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- include/hw/display/macfb.h | 16 +++- hw/display/macfb.c | 149 +++++++++++++++++++++++++++++++++---- hw/m68k/q800.c | 11 ++- hw/display/trace-events | 1 + 4 files changed, 156 insertions(+), 21 deletions(-) diff --git a/include/hw/display/macfb.h b/include/hw/display/macfb.h index e95a97ebdcda..0aff0d84d2af 100644 --- a/include/hw/display/macfb.h +++ b/include/hw/display/macfb.h @@ -35,6 +35,19 @@ typedef enum { MACFB_DISPLAY_SVGA = 14, } MacfbDisplayType; +typedef struct MacFbMode { + uint8_t type; + uint8_t depth; + uint32_t mode_ctrl1; + uint32_t mode_ctrl2; + uint32_t width; + uint32_t height; + uint32_t stride; + uint32_t offset; +} MacFbMode; + +#define MACFB_NUM_REGS 8 + typedef struct MacfbState { MemoryRegion mem_vram; MemoryRegion mem_ctrl; @@ -48,7 +61,8 @@ typedef struct MacfbState { uint8_t depth; uint8_t type; - uint32_t sense; + uint32_t regs[MACFB_NUM_REGS]; + MacFbMode *mode; } MacfbState; #define TYPE_MACFB "sysbus-macfb" diff --git a/hw/display/macfb.c b/hw/display/macfb.c index f98bcdec2dc6..2759fb5e34d1 100644 --- a/hw/display/macfb.c +++ b/hw/display/macfb.c @@ -22,12 +22,16 @@ #include "migration/vmstate.h" #include "trace.h" -#define VIDEO_BASE 0x00001000 +#define VIDEO_BASE 0x0 #define DAFB_BASE 0x00800000 #define MACFB_PAGE_SIZE 4096 #define MACFB_VRAM_SIZE (4 * MiB) +#define DAFB_MODE_VADDR1 0x0 +#define DAFB_MODE_VADDR2 0x4 +#define DAFB_MODE_CTRL1 0x8 +#define DAFB_MODE_CTRL2 0xc #define DAFB_MODE_SENSE 0x1c #define DAFB_RESET 0x200 #define DAFB_LUT 0x213 @@ -89,6 +93,22 @@ static MacFbSense macfb_sense_table[] = { { MACFB_DISPLAY_SVGA, 0x7, 0x5 }, }; +static MacFbMode macfb_mode_table[] = { + { MACFB_DISPLAY_VGA, 1, 0x100, 0x71e, 640, 480, 0x400, 0x1000 }, + { MACFB_DISPLAY_VGA, 2, 0x100, 0x70e, 640, 480, 0x400, 0x1000 }, + { MACFB_DISPLAY_VGA, 4, 0x100, 0x706, 640, 480, 0x400, 0x1000 }, + { MACFB_DISPLAY_VGA, 8, 0x100, 0x702, 640, 480, 0x400, 0x1000 }, + { MACFB_DISPLAY_VGA, 24, 0x100, 0x7ff, 640, 480, 0x1000, 0x1000 }, + { MACFB_DISPLAY_VGA, 1, 0xd0 , 0x70e, 800, 600, 0x340, 0xe00 }, + { MACFB_DISPLAY_VGA, 2, 0xd0 , 0x706, 800, 600, 0x340, 0xe00 }, + { MACFB_DISPLAY_VGA, 4, 0xd0 , 0x702, 800, 600, 0x340, 0xe00 }, + { MACFB_DISPLAY_VGA, 8, 0xd0, 0x700, 800, 600, 0x340, 0xe00 }, + { MACFB_DISPLAY_VGA, 24, 0x340, 0x100, 800, 600, 0xd00, 0xe00 }, + { MACFB_DISPLAY_APPLE_21_COLOR, 1, 0x90, 0x506, 1152, 870, 0x240, 0x80 }, + { MACFB_DISPLAY_APPLE_21_COLOR, 2, 0x90, 0x502, 1152, 870, 0x240, 0x80 }, + { MACFB_DISPLAY_APPLE_21_COLOR, 4, 0x90, 0x500, 1152, 870, 0x240, 0x80 }, + { MACFB_DISPLAY_APPLE_21_COLOR, 8, 0x120, 0x5ff, 1152, 870, 0x480, 0x80 }, +}; typedef void macfb_draw_line_func(MacfbState *s, uint8_t *d, uint32_t addr, int width); @@ -246,7 +266,7 @@ static void macfb_draw_graphic(MacfbState *s) ram_addr_t page; uint32_t v = 0; int y, ymin; - int macfb_stride = (s->depth * s->width + 7) / 8; + int macfb_stride = s->mode->stride; macfb_draw_line_func *macfb_draw_line; switch (s->depth) { @@ -278,7 +298,7 @@ static void macfb_draw_graphic(MacfbState *s) DIRTY_MEMORY_VGA); ymin = -1; - page = 0; + page = s->mode->offset; for (y = 0; y < s->height; y++, page += macfb_stride) { if (macfb_check_dirty(s, snap, page, macfb_stride)) { uint8_t *data_display; @@ -323,25 +343,26 @@ static uint32_t macfb_sense_read(MacfbState *s) sense = 0; if (!(macfb_sense->ext_sense & 1)) { /* Pins 7-4 together */ - if (~s->sense & 3) { - sense = (~s->sense & 7) | 3; + if (~s->regs[DAFB_MODE_SENSE >> 2] & 3) { + sense = (~s->regs[DAFB_MODE_SENSE >> 2] & 7) | 3; } } if (!(macfb_sense->ext_sense & 2)) { /* Pins 10-7 together */ - if (~s->sense & 6) { - sense = (~s->sense & 7) | 6; + if (~s->regs[DAFB_MODE_SENSE >> 2] & 6) { + sense = (~s->regs[DAFB_MODE_SENSE >> 2] & 7) | 6; } } if (!(macfb_sense->ext_sense & 4)) { /* Pins 4-10 together */ - if (~s->sense & 5) { - sense = (~s->sense & 7) | 5; + if (~s->regs[DAFB_MODE_SENSE >> 2] & 5) { + sense = (~s->regs[DAFB_MODE_SENSE >> 2] & 7) | 5; } } } else { /* Normal sense */ - sense = (~macfb_sense->sense & 7) | (~s->sense & 7); + sense = (~macfb_sense->sense & 7) | + (~s->regs[DAFB_MODE_SENSE >> 2] & 7); } trace_macfb_sense_read(sense); @@ -350,12 +371,84 @@ static uint32_t macfb_sense_read(MacfbState *s) static void macfb_sense_write(MacfbState *s, uint32_t val) { - s->sense = val; + s->regs[DAFB_MODE_SENSE >> 2] = val; trace_macfb_sense_write(val); return; } +static void macfb_update_mode(MacfbState *s) +{ + s->width = s->mode->width; + s->height = s->mode->height; + s->depth = s->mode->depth; + + trace_macfb_update_mode(s->width, s->height, s->depth); + macfb_invalidate_display(s); +} + +static void macfb_mode_write(MacfbState *s) +{ + MacFbMode *macfb_mode; + int i; + + for (i = 0; i < ARRAY_SIZE(macfb_mode_table); i++) { + macfb_mode = &macfb_mode_table[i]; + + if (s->type != macfb_mode->type) { + continue; + } + + if ((s->regs[DAFB_MODE_CTRL1 >> 2] & 0xff) == + (macfb_mode->mode_ctrl1 & 0xff) && + (s->regs[DAFB_MODE_CTRL2 >> 2] & 0xff) == + (macfb_mode->mode_ctrl2 & 0xff)) { + s->mode = macfb_mode; + macfb_update_mode(s); + break; + } + } +} + +static MacFbMode *macfb_find_mode(MacfbDisplayType display_type, + uint16_t width, uint16_t height, + uint8_t depth) +{ + MacFbMode *macfb_mode; + int i; + + for (i = 0; i < ARRAY_SIZE(macfb_mode_table); i++) { + macfb_mode = &macfb_mode_table[i]; + + if (display_type == macfb_mode->type && width == macfb_mode->width && + height == macfb_mode->height && depth == macfb_mode->depth) { + return macfb_mode; + } + } + + return NULL; +} + +static gchar *macfb_mode_list(void) +{ + gchar *list = NULL; + gchar *mode; + MacFbMode *macfb_mode; + int i; + + for (i = 0; i < ARRAY_SIZE(macfb_mode_table); i++) { + macfb_mode = &macfb_mode_table[i]; + + mode = g_strdup_printf(" %dx%dx%d\n", macfb_mode->width, + macfb_mode->height, macfb_mode->depth); + list = g_strconcat(mode, list, NULL); + g_free(mode); + } + + return list; +} + + static void macfb_update_display(void *opaque) { MacfbState *s = opaque; @@ -397,6 +490,12 @@ static uint64_t macfb_ctrl_read(void *opaque, uint64_t val = 0; switch (addr) { + case DAFB_MODE_VADDR1: + case DAFB_MODE_VADDR2: + case DAFB_MODE_CTRL1: + case DAFB_MODE_CTRL2: + val = s->regs[addr >> 2]; + break; case DAFB_MODE_SENSE: val = macfb_sense_read(s); break; @@ -413,6 +512,17 @@ static void macfb_ctrl_write(void *opaque, { MacfbState *s = opaque; switch (addr) { + case DAFB_MODE_VADDR1: + case DAFB_MODE_VADDR2: + s->regs[addr >> 2] = val; + break; + case DAFB_MODE_CTRL1 ... DAFB_MODE_CTRL1 + 3: + case DAFB_MODE_CTRL2 ... DAFB_MODE_CTRL2 + 3: + s->regs[addr >> 2] = val; + if (val) { + macfb_mode_write(s); + } + break; case DAFB_MODE_SENSE: macfb_sense_write(s, val); break; @@ -442,7 +552,7 @@ static const MemoryRegionOps macfb_ctrl_ops = { static int macfb_post_load(void *opaque, int version_id) { - macfb_invalidate_display(opaque); + macfb_mode_write(opaque); return 0; } @@ -455,7 +565,7 @@ static const VMStateDescription vmstate_macfb = { .fields = (VMStateField[]) { VMSTATE_UINT8_ARRAY(color_palette, MacfbState, 256 * 3), VMSTATE_UINT32(palette_current, MacfbState), - VMSTATE_UINT32(sense, MacfbState), + VMSTATE_UINT32_ARRAY(regs, MacfbState, MACFB_NUM_REGS), VMSTATE_END_OF_LIST() } }; @@ -469,9 +579,15 @@ static bool macfb_common_realize(DeviceState *dev, MacfbState *s, Error **errp) { DisplaySurface *surface; - if (s->depth != 1 && s->depth != 2 && s->depth != 4 && s->depth != 8 && - s->depth != 16 && s->depth != 24) { - error_setg(errp, "unknown guest depth %d", s->depth); + s->mode = macfb_find_mode(s->type, s->width, s->height, s->depth); + if (!s->mode) { + gchar *list; + error_setg(errp, "unknown display mode: width %d, height %d, depth %d", + s->width, s->height, s->depth); + list = macfb_mode_list(); + error_append_hint(errp, "Available modes:\n%s", list); + g_free(list); + return false; } @@ -493,6 +609,7 @@ static bool macfb_common_realize(DeviceState *dev, MacfbState *s, Error **errp) s->vram_bit_mask = MACFB_VRAM_SIZE - 1; memory_region_set_coalescing(&s->mem_vram); + macfb_update_mode(s); return true; } diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c index 5223b880bc2d..df3fd3711e6e 100644 --- a/hw/m68k/q800.c +++ b/hw/m68k/q800.c @@ -74,7 +74,7 @@ * is needed by the kernel to have early display and * thus provided by the bootloader */ -#define VIDEO_BASE 0xf9001000 +#define VIDEO_BASE 0xf9000000 #define MAC_CLOCK 3686418 @@ -221,6 +221,7 @@ static void q800_init(MachineState *machine) uint8_t *prom; const int io_slice_nb = (IO_SIZE / IO_SLICE) - 1; int i, checksum; + MacFbMode *macfb_mode; ram_addr_t ram_size = machine->ram_size; const char *kernel_filename = machine->kernel_filename; const char *initrd_filename = machine->initrd_filename; @@ -428,6 +429,8 @@ static void q800_init(MachineState *machine) } qdev_realize_and_unref(dev, BUS(nubus), &error_fatal); + macfb_mode = (NUBUS_MACFB(dev)->macfb).mode; + cs = CPU(cpu); if (linux_boot) { uint64_t high; @@ -450,12 +453,12 @@ static void q800_init(MachineState *machine) BOOTINFO1(cs->as, parameters_base, BI_MAC_MEMSIZE, ram_size >> 20); /* in MB */ BOOTINFO2(cs->as, parameters_base, BI_MEMCHUNK, 0, ram_size); - BOOTINFO1(cs->as, parameters_base, BI_MAC_VADDR, VIDEO_BASE); + BOOTINFO1(cs->as, parameters_base, BI_MAC_VADDR, + VIDEO_BASE + macfb_mode->offset); BOOTINFO1(cs->as, parameters_base, BI_MAC_VDEPTH, graphic_depth); BOOTINFO1(cs->as, parameters_base, BI_MAC_VDIM, (graphic_height << 16) | graphic_width); - BOOTINFO1(cs->as, parameters_base, BI_MAC_VROW, - (graphic_width * graphic_depth + 7) / 8); + BOOTINFO1(cs->as, parameters_base, BI_MAC_VROW, macfb_mode->stride); BOOTINFO1(cs->as, parameters_base, BI_MAC_SCCBASE, SCC_BASE); rom = g_malloc(sizeof(*rom)); diff --git a/hw/display/trace-events b/hw/display/trace-events index 30cb460e4d1b..3a7a2c957f4f 100644 --- a/hw/display/trace-events +++ b/hw/display/trace-events @@ -173,3 +173,4 @@ macfb_ctrl_read(uint64_t addr, uint64_t value, unsigned int size) "addr 0x%"PRIx macfb_ctrl_write(uint64_t addr, uint64_t value, unsigned int size) "addr 0x%"PRIx64 " value 0x%"PRIx64 " size %u" macfb_sense_read(uint32_t value) "video sense: 0x%"PRIx32 macfb_sense_write(uint32_t value) "video sense: 0x%"PRIx32 +macfb_update_mode(uint32_t width, uint32_t height, uint8_t depth) "setting mode to width %"PRId32 " height %"PRId32 " size %d" From patchwork Fri Oct 8 11:45:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1538325 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HQmjw3TwNz9sP7 for ; Fri, 8 Oct 2021 22:51:14 +1100 (AEDT) Received: from localhost ([::1]:54118 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYoP9-0002q9-Et for incoming@patchwork.ozlabs.org; Fri, 08 Oct 2021 07:51:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50452) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYoJn-0006Lu-N3 for qemu-devel@nongnu.org; Fri, 08 Oct 2021 07:45:39 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:41009) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYoJb-0006zB-Vi for qemu-devel@nongnu.org; Fri, 08 Oct 2021 07:45:37 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1M5fdC-1mfxz43XRa-0079fU; Fri, 08 Oct 2021 13:45:25 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 10/13] macfb: fix up 1-bit pixel encoding Date: Fri, 8 Oct 2021 13:45:15 +0200 Message-Id: <20211008114518.757615-11-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211008114518.757615-1-laurent@vivier.eu> References: <20211008114518.757615-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:NYhvQT87mPicdZtbQdoA4RbkTTDMXxrw3ilKComPyspDR7+INo4 hAe8bx13olRboGH41jGpr8aWEKeAPmxsfwJh+RdJsAxaDP7fV7OOr84dSJHVw+HgdDonmC1 eYWgVGZsUHQ0YSpoQCNNkoRCZsUheyrN7PXsvunyGOPy+0wb0AFdarAwGxTSDPQVRLI/sSv UbYUEgJuRk/1oeT8bTuBQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:OIkROugdI1Q=:J6+RR8OJ831ca3DKOoI0j+ 1AvmDfaTL5XJ+oPdPMsVP3mi1ieCS+ABGfaeg9rSUYo/nROq8M7XTYFlHQMGgmqrCjadiKws5 Esto5PhCZpdvq9k/KZ7Q3sY/gA+z7nYx44VHgPwaa0lNobkmh5o6R3rUVaIRDu43FeHprcpmS DxL0qVsUKfNu/GjOoGsYoSVPS5arBFjJBm0msKPrHIG46dzfbGcimDZF0rKN9cGWYm2IFa3ji xptUyhhC7m8FnQpGBDEvaE4/Czi0O2us1fRGfR9wvkBAGMi9PKjgfumK2cgKf91XMvr6KolyS UxlpIJV9engmGmsxRSDAnrqkcTH7DKR8gul+PXz0QcMt+1KNcsgD4bC8UgfBchMXoYDfq6zWb uc3ix0AP6AHe8L6XEg3n39fAtNIh5+x8obhwR4ky9H2YCneRQYGrVhIVyqAE5WcCBtnIE0wBa yRKignMj9ytKJwA8ZDWSUIPEzGYmJrfOAxavfO+62s2/on7NqZJwqR6yV3hDfiKkSHkpzPdP1 3BSFCxfdcyyHEk9+xEK9dP3DRiDCeoooy2+AqZeiPmx2FXoN5NJc9tBRwsF0AJVyMUhOAosH5 yMx/sW+ARZUik4BhYHnxiKHX2Xqcj59HxzUKnECZvFP/iO4RQ+d+PMlJY97dlyat8M/74mjO1 rSn6byEB6awDFXB79ZoANbD7OI+lnWZm2MtFQ28+O09gT7j6nOLZV5qXhC0R8jD8fgte4/+FR K8GTJQdV4gN0kginnNuPoQAT8mttdTfZeXq0BQ== 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_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 The MacOS driver expects the RGB values for the pixel to be in entries 0 and 1 of the colour palette. Signed-off-by: Mark Cave-Ayland Reviewed-by: Laurent Vivier Message-Id: <20211007221253.29024-11-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- hw/display/macfb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/display/macfb.c b/hw/display/macfb.c index 2759fb5e34d1..e49c8b6f4b52 100644 --- a/hw/display/macfb.c +++ b/hw/display/macfb.c @@ -128,7 +128,9 @@ static void macfb_draw_line1(MacfbState *s, uint8_t *d, uint32_t addr, for (x = 0; x < width; x++) { int bit = x & 7; int idx = (macfb_read_byte(s, addr) >> (7 - bit)) & 1; - r = g = b = ((1 - idx) << 7); + r = s->color_palette[idx * 3]; + g = s->color_palette[idx * 3 + 1]; + b = s->color_palette[idx * 3 + 2]; addr += (bit == 7); *(uint32_t *)d = rgb_to_pixel32(r, g, b); From patchwork Fri Oct 8 11:45:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1538331 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HQmnR36Zpz9sP7 for ; Fri, 8 Oct 2021 22:54:19 +1100 (AEDT) Received: from localhost ([::1]:35968 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYoS9-0001GD-5I for incoming@patchwork.ozlabs.org; Fri, 08 Oct 2021 07:54:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50382) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYoJg-0006IR-Lz for qemu-devel@nongnu.org; Fri, 08 Oct 2021 07:45:35 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:33505) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYoJc-0006zT-0B for qemu-devel@nongnu.org; Fri, 08 Oct 2021 07:45:31 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MeCYx-1nA40Y16EJ-00bHkb; Fri, 08 Oct 2021 13:45:25 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 11/13] macfb: fix 24-bit RGB pixel encoding Date: Fri, 8 Oct 2021 13:45:16 +0200 Message-Id: <20211008114518.757615-12-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211008114518.757615-1-laurent@vivier.eu> References: <20211008114518.757615-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:MbQ0v3HaxcJH9NXMsMupu9zhnM1IvxDigB3NKdl2QbD8s+3DPST LALtVgCN94tNKHg7QbJJBl2RpWXJMcQ5LTcnRgyJAlIslxia2r4XL+2tx3IuPchRSQ21U8r 2u/Gp6eIo+M5S2KXYCADgB4Y45lgMViFECsAVSnfUQkq2quLdKU1lpiRlBltTLkp1j5jxcM YSUR31ESvfX0Ig6HPkkfg== X-UI-Out-Filterresults: notjunk:1;V03:K0:Jvgti8FG1jo=:tfOG9LR2suayo8do9jKzvl qn64q3bQdfayBlWeFhPYDvsgrPdKSrLeO1JaoJLIO2o82THr7GiXKe5hHpd2xlFTVpgCBKvQh MISN5PLVJeGFoPmYPLk85q+qIBov7u8DmEBarTxBrKkXmHp73GWiYal64RvDd9/uoYw7z4PDw +XTJEgP5lRXXQ39je6FperS3WivviX1vwDKSCUU+avVjhp9GMooBdHzC60aOu+3SdtW9cyn13 fqamzccjEdFW/kXAJe45QsvHcaIMThMDL68NUHLhzHrC+qKXBaLiI+6AXl+wC92dA8IPWlP9i QW510uFYICcYVOMccfthbmc6h8wmdkfvoOSkejotjx1cVyvyB1qnQbP4joo3s4iNwiLoa6Vzp tkAob1iL8KZcupXCzOTDBRaqojaGeRbN+K0qclhU/y043U6C0yTwlrFNxeD6O1kPBHaXu2BfW ZJxjOlq97FxiSIypWa+gkDFEQvEOLvDV4F3W8nWCDx9WV+79IS/oexCo86YT05zRgEdk9fX29 fUNNS+xA95Msg3TUdU/GKc6ue64oRMbnrarFIc43nNKDZjAyiId2PLOKeCYjKsENi+CNtcgJt ky1fDkLHotpypAWVXTFMVdIRdlAQyvu0fm7bZND1tym1msaEvyaImRJUMsYRASxxdYvaEz5aq XrRQWBG0xOtmU7AhxKWdDxc3iQLf4CMUzglir/rMPD2DwSWAoXb4ODEhn/RmcPuWMbaefGe67 mzO/fUxLytHIGlciXyUxTwxHdDnws2wyvv2aFw== Received-SPF: none client-ip=212.227.126.133; 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 According to Apple Technical Note HW26: "Macintosh Quadra Built-In Video" the in-built framebuffer encodes each 24-bit pixel into 4 bytes. Adjust the 24-bit RGB pixel encoding accordingly which agrees with the encoding expected by MacOS when changing into 24-bit colour mode. Signed-off-by: Mark Cave-Ayland Reviewed-by: Laurent Vivier Message-Id: <20211007221253.29024-12-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- hw/display/macfb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/display/macfb.c b/hw/display/macfb.c index e49c8b6f4b52..3288a71b89a6 100644 --- a/hw/display/macfb.c +++ b/hw/display/macfb.c @@ -224,10 +224,10 @@ static void macfb_draw_line24(MacfbState *s, uint8_t *d, uint32_t addr, int x; for (x = 0; x < width; x++) { - r = macfb_read_byte(s, addr); - g = macfb_read_byte(s, addr + 1); - b = macfb_read_byte(s, addr + 2); - addr += 3; + r = macfb_read_byte(s, addr + 1); + g = macfb_read_byte(s, addr + 2); + b = macfb_read_byte(s, addr + 3); + addr += 4; *(uint32_t *)d = rgb_to_pixel32(r, g, b); d += 4; From patchwork Fri Oct 8 11:45:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1538338 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HQmt25L2Mz9sR4 for ; Fri, 8 Oct 2021 22:58:18 +1100 (AEDT) Received: from localhost ([::1]:47054 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYoVz-0000Gn-0y for incoming@patchwork.ozlabs.org; Fri, 08 Oct 2021 07:58:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50460) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYoJn-0006Mf-Vi for qemu-devel@nongnu.org; Fri, 08 Oct 2021 07:45:40 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:58287) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYoJc-0006zz-JD for qemu-devel@nongnu.org; Fri, 08 Oct 2021 07:45:39 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MysmQ-1mva3b2trm-00vxw0; Fri, 08 Oct 2021 13:45:25 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 12/13] macfb: add vertical blank interrupt Date: Fri, 8 Oct 2021 13:45:17 +0200 Message-Id: <20211008114518.757615-13-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211008114518.757615-1-laurent@vivier.eu> References: <20211008114518.757615-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:zYA0sBfbLhG52JE7dFGrJWCXykAyFc5U09fD6Ps+qarwfGNpoCv H6M5vtv7mdoEGJhszpcNI/XZKcYd98oJYZcwhsj8fv6QdnEebXsaRguNXJr7WadkwfAGL1r 502Kam0NuUTJSiwr7NJXyfnIiXjtvSmkIfZuRIGnI+Ga0th54ts88PVAouKbDfsHliOqGGq 7nyAKHJwwlZeVHPfBV47A== X-UI-Out-Filterresults: notjunk:1;V03:K0:ZLDN3QZnwYs=:YEJ4MUxqk2Tnn3voEF995q 68QLl9czz0qvrNrsp0GqWyIG77+u0/46g6Axcz+s4XcLr76qclOnBnvOaghxKVEPrB8EmYRDQ 3g4ABFZgN2E0+D2evmusO3xPB/htY567g7sBMvHSkPYIf/TvVyTWJ/OpyvO2W1NxuFjGTNlRx z4lLo9ckim1suqiTfeCyXrVKJ2Yu7CYlEQGoFNRWsNU3pkMKycDazXLRoOQwA8mu0gS516Zfq CNnza7+4Jh3FxheMDZ6d17E6we+jAz8I0el7dzpJziOBJwPFIcWkBmV2wrQ35//qZDw/WLc21 owdV28FJlHEpT/IpFv2ZoXoKO9hsnAW7yXdUWmQnRVKVwAYEC5wOMdrgrAKUBKnp2sDm45l3R NmkptZtuHfxDVpHDZ9ChYtvvj63lUkTx8xafYID70Q/apb7772zACgCoU1JKdknsRK5yyihpk xFRf8dFd/W5clGaiSPkJ9Ol1hOYdO1jIJxNlDfVL0G4UrE8T0l1R0urSb3UPpWdJdjTheTe+r UwHGq/UbB2MJIJyob14QhXIeAMjXiL/1P2EDJ4syBo8QTHEC0KfQr+cgmWv8o+tOlsbRyyt1T C1TETta+dcqo4PvoqNMz0+J/XtryWsswUhAa+XP5N914H/fb6Z9tjAUtwdlJKXaK3NIP17x/y tQCe94Rbnu902r2php9uNlR5Nd5WDFGxaD6ZPqZsffEa4/PO0L4sovPKk/Da1wtQkrpg2IOoQ w+TZbgB8lB8FgiTrOR87EhtFzB+ttW9lCFROOA== Received-SPF: none client-ip=212.227.126.131; 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_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 The MacOS driver expects a 60.15Hz vertical blank interrupt to be generated by the framebuffer which in turn schedules the mouse driver via the Vertical Retrace Manager. Signed-off-by: Mark Cave-Ayland Reviewed-by: Laurent Vivier Message-Id: <20211007221253.29024-13-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- include/hw/display/macfb.h | 8 ++++ hw/display/macfb.c | 83 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) diff --git a/include/hw/display/macfb.h b/include/hw/display/macfb.h index 0aff0d84d2af..e52775aa2151 100644 --- a/include/hw/display/macfb.h +++ b/include/hw/display/macfb.h @@ -14,7 +14,9 @@ #define MACFB_H #include "exec/memory.h" +#include "hw/irq.h" #include "ui/console.h" +#include "qemu/timer.h" #include "qom/object.h" typedef enum { @@ -63,6 +65,11 @@ typedef struct MacfbState { uint32_t regs[MACFB_NUM_REGS]; MacFbMode *mode; + + uint32_t irq_state; + uint32_t irq_mask; + QEMUTimer *vbl_timer; + qemu_irq irq; } MacfbState; #define TYPE_MACFB "sysbus-macfb" @@ -81,6 +88,7 @@ struct MacfbNubusDeviceClass { DeviceClass parent_class; DeviceRealize parent_realize; + DeviceUnrealize parent_unrealize; }; diff --git a/hw/display/macfb.c b/hw/display/macfb.c index 3288a71b89a6..4b352eb89c3f 100644 --- a/hw/display/macfb.c +++ b/hw/display/macfb.c @@ -33,9 +33,16 @@ #define DAFB_MODE_CTRL1 0x8 #define DAFB_MODE_CTRL2 0xc #define DAFB_MODE_SENSE 0x1c +#define DAFB_INTR_MASK 0x104 +#define DAFB_INTR_STAT 0x108 +#define DAFB_INTR_CLEAR 0x10c #define DAFB_RESET 0x200 #define DAFB_LUT 0x213 +#define DAFB_INTR_VBL 0x4 + +/* Vertical Blank period (60.15Hz) */ +#define DAFB_INTR_VBL_PERIOD_NS 16625800 /* * Quadra sense codes taken from Apple Technical Note HW26: @@ -470,6 +477,36 @@ static void macfb_update_display(void *opaque) macfb_draw_graphic(s); } +static void macfb_update_irq(MacfbState *s) +{ + uint32_t irq_state = s->irq_state & s->irq_mask; + + if (irq_state) { + qemu_irq_raise(s->irq); + } else { + qemu_irq_lower(s->irq); + } +} + +static int64_t macfb_next_vbl(void) +{ + return (qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + DAFB_INTR_VBL_PERIOD_NS) / + DAFB_INTR_VBL_PERIOD_NS * DAFB_INTR_VBL_PERIOD_NS; +} + +static void macfb_vbl_timer(void *opaque) +{ + MacfbState *s = opaque; + int64_t next_vbl; + + s->irq_state |= DAFB_INTR_VBL; + macfb_update_irq(s); + + /* 60 Hz irq */ + next_vbl = macfb_next_vbl(); + timer_mod(s->vbl_timer, next_vbl); +} + static void macfb_reset(MacfbState *s) { int i; @@ -498,6 +535,9 @@ static uint64_t macfb_ctrl_read(void *opaque, case DAFB_MODE_CTRL2: val = s->regs[addr >> 2]; break; + case DAFB_INTR_STAT: + val = s->irq_state; + break; case DAFB_MODE_SENSE: val = macfb_sense_read(s); break; @@ -513,6 +553,8 @@ static void macfb_ctrl_write(void *opaque, unsigned int size) { MacfbState *s = opaque; + int64_t next_vbl; + switch (addr) { case DAFB_MODE_VADDR1: case DAFB_MODE_VADDR2: @@ -528,8 +570,23 @@ static void macfb_ctrl_write(void *opaque, case DAFB_MODE_SENSE: macfb_sense_write(s, val); break; + case DAFB_INTR_MASK: + s->irq_mask = val; + if (val & DAFB_INTR_VBL) { + next_vbl = macfb_next_vbl(); + timer_mod(s->vbl_timer, next_vbl); + } else { + timer_del(s->vbl_timer); + } + break; + case DAFB_INTR_CLEAR: + s->irq_state &= ~DAFB_INTR_VBL; + macfb_update_irq(s); + break; case DAFB_RESET: s->palette_current = 0; + s->irq_state &= ~DAFB_INTR_VBL; + macfb_update_irq(s); break; case DAFB_LUT: s->color_palette[s->palette_current] = val; @@ -611,6 +668,7 @@ static bool macfb_common_realize(DeviceState *dev, MacfbState *s, Error **errp) s->vram_bit_mask = MACFB_VRAM_SIZE - 1; memory_region_set_coalescing(&s->mem_vram); + s->vbl_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, macfb_vbl_timer, s); macfb_update_mode(s); return true; } @@ -626,6 +684,16 @@ static void macfb_sysbus_realize(DeviceState *dev, Error **errp) sysbus_init_mmio(SYS_BUS_DEVICE(s), &ms->mem_ctrl); sysbus_init_mmio(SYS_BUS_DEVICE(s), &ms->mem_vram); + + qdev_init_gpio_out(dev, &ms->irq, 1); +} + +static void macfb_nubus_set_irq(void *opaque, int n, int level) +{ + MacfbNubusState *s = NUBUS_MACFB(opaque); + NubusDevice *nd = NUBUS_DEVICE(s); + + nubus_set_irq(nd, level); } static void macfb_nubus_realize(DeviceState *dev, Error **errp) @@ -646,6 +714,19 @@ static void macfb_nubus_realize(DeviceState *dev, Error **errp) memory_region_add_subregion(&nd->slot_mem, DAFB_BASE, &ms->mem_ctrl); memory_region_add_subregion(&nd->slot_mem, VIDEO_BASE, &ms->mem_vram); + + ms->irq = qemu_allocate_irq(macfb_nubus_set_irq, s, 0); +} + +static void macfb_nubus_unrealize(DeviceState *dev) +{ + MacfbNubusState *s = NUBUS_MACFB(dev); + MacfbNubusDeviceClass *ndc = NUBUS_MACFB_GET_CLASS(dev); + MacfbState *ms = &s->macfb; + + ndc->parent_unrealize(dev); + + qemu_free_irq(ms->irq); } static void macfb_sysbus_reset(DeviceState *d) @@ -696,6 +777,8 @@ static void macfb_nubus_class_init(ObjectClass *klass, void *data) device_class_set_parent_realize(dc, macfb_nubus_realize, &ndc->parent_realize); + device_class_set_parent_unrealize(dc, macfb_nubus_unrealize, + &ndc->parent_unrealize); dc->desc = "Nubus Macintosh framebuffer"; dc->reset = macfb_nubus_reset; dc->vmsd = &vmstate_macfb; From patchwork Fri Oct 8 11:45:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1538336 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HQmpP5Wkmz9sRN for ; Fri, 8 Oct 2021 22:55:09 +1100 (AEDT) Received: from localhost ([::1]:39738 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYoSx-0003j9-Ha for incoming@patchwork.ozlabs.org; Fri, 08 Oct 2021 07:55:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50512) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYoJp-0006SS-Pj for qemu-devel@nongnu.org; Fri, 08 Oct 2021 07:45:41 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:44865) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYoJj-00072y-5C for qemu-devel@nongnu.org; Fri, 08 Oct 2021 07:45:41 -0400 Received: from quad ([82.142.3.114]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1Mati7-1nB9wL0pmV-00cNgH; Fri, 08 Oct 2021 13:45:26 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 13/13] q800: wire macfb IRQ to separate video interrupt on VIA2 Date: Fri, 8 Oct 2021 13:45:18 +0200 Message-Id: <20211008114518.757615-14-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211008114518.757615-1-laurent@vivier.eu> References: <20211008114518.757615-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:nEm9MPuJR+mgEUR5WMSOssJHt+LcMuZUc1D0RbU2huVa54emPym 6ORXppOE+yjNjSehjc5zKxItf6z8ZAzsVZp2ewP9nXMGh0dUc4F+Kd09K+rbO+RvKDCvPgv 0fWkwJcblrSQde1eRKPvCQ0GKFbmxMbCjoOX0Kdez2+4cX8TDyA9tOVeawJ+FGuUSAq/gBR 67fcMzwR9/CM+Hcash5ug== X-UI-Out-Filterresults: notjunk:1;V03:K0:sOZY2ANzCro=:HEJa9izIulRJ4WFYnvTfol AL+SquH1PGRLU0MZUmOYwR8SVbgxML+jzbFogYlU2hon1jLn2bCUSUty62mTDioerL5U+sGzf DjvMwTmvtSEvs/AqwUSo3cNEC1hclx2WUp0x+tFmkmSl+eXJ6xEHV5icNZFbAx5Hd/sD8o65j TT7T8fkAZWxdv3iHuyZJTlBGqfjlDusKPfkOP5djjt4//IewSOrwIixWtWTqFA5qX7tQBGePe hahiFNklno+89sIq1TdVb46xou6lCSYetHfnG9lVto5EZgMhHYM3/IkczLz9WfC+OevHFI6jE sQHGspd3NyUoHp39ZiHuTBDhSebbKWROwRrVI3OUV1Dr4x7aogmh+UMI1d/jmza3DYobpy9Yb SnxxVtCfDwGe3X7mBCG6zcL7AgUgrG++GIF/OVrMumFVP6IxqQKMkz8aQ4P4RLJntX1wvFjzD h3KOKFHPOpuzbcY26f/hESjNNE5hdxHR0UiOZ5mtnshiJght5fZtDWzFOVEIylrni8hyD4HOD btTbm8XXEgMR4FRm4TTaUQUj2zFSFxs0yb6EZIYHrw9RSGyTyWvsX4VSxkprQRMoma6eKSjfH Szy8uMASX4Rqr9CdhKiBtw6X5e5rlyxPC6oOHSMc8S4Ob951wQQxDaTSFnYUYnmk4MfXX0fwE I5ge7ko5j+YGje0jT3j8gtIt3JoF4R/Lw1MFD2Ru5Adj5OJm3VEYY36nlAnM8GOIrpxOuY/QO 7Au7Sq7T9TpT9K5CvCsNI6kwfch44kVuKqSDOQ== Received-SPF: none client-ip=212.227.126.187; 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_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 Whilst the in-built Quadra 800 framebuffer exists within the Nubus address space for slot 9, it has its own dedicated interrupt on VIA2. Force the macfb device to occupy slot 9 in the q800 machine and wire its IRQ to the separate video interrupt since this is what is expected by the MacOS interrupt handler. Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Laurent Vivier Message-Id: <20211007221253.29024-14-mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier --- hw/m68k/q800.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c index df3fd3711e6e..fd4855047e3f 100644 --- a/hw/m68k/q800.c +++ b/hw/m68k/q800.c @@ -407,8 +407,10 @@ static void q800_init(MachineState *machine) MAC_NUBUS_FIRST_SLOT * NUBUS_SUPER_SLOT_SIZE); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 1, NUBUS_SLOT_BASE + MAC_NUBUS_FIRST_SLOT * NUBUS_SLOT_SIZE); - - for (i = 0; i < VIA2_NUBUS_IRQ_NB; i++) { + qdev_connect_gpio_out(dev, 9, + qdev_get_gpio_in_named(via2_dev, "nubus-irq", + VIA2_NUBUS_IRQ_INTVIDEO)); + for (i = 1; i < VIA2_NUBUS_IRQ_NB; i++) { qdev_connect_gpio_out(dev, 9 + i, qdev_get_gpio_in_named(via2_dev, "nubus-irq", VIA2_NUBUS_IRQ_9 + i)); @@ -419,6 +421,7 @@ static void q800_init(MachineState *machine) /* framebuffer in nubus slot #9 */ dev = qdev_new(TYPE_NUBUS_MACFB); + qdev_prop_set_uint32(dev, "slot", 9); qdev_prop_set_uint32(dev, "width", graphic_width); qdev_prop_set_uint32(dev, "height", graphic_height); qdev_prop_set_uint8(dev, "depth", graphic_depth);