From nobody Thu May 9 13:16:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633645368468461.51260791077857; Thu, 7 Oct 2021 15:22:48 -0700 (PDT) Received: from localhost ([::1]:42174 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYbmi-0008Bf-BC for importer@patchew.org; Thu, 07 Oct 2021 18:22:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55938) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYbdV-000343-Te for qemu-devel@nongnu.org; Thu, 07 Oct 2021 18:13:09 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]:41872 helo=mail.default.ilande.bv.iomart.io) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYbdU-0006j0-By for qemu-devel@nongnu.org; Thu, 07 Oct 2021 18:13:09 -0400 Received: from [2a00:23c4:8b9d:4100:5d98:71b5:90ca:dad1] (helo=kentang.home) by mail.default.ilande.bv.iomart.io with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mYbdC-0003uC-Tx; Thu, 07 Oct 2021 23:12:55 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, laurent@vivier.eu Date: Thu, 7 Oct 2021 23:12:41 +0100 Message-Id: <20211007221253.29024-2-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211007221253.29024-1-mark.cave-ayland@ilande.co.uk> References: <20211007221253.29024-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a00:23c4:8b9d:4100:5d98:71b5:90ca:dad1 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v4 01/13] macfb: handle errors that occur during realize X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.default.ilande.bv.iomart.io) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.default.ilande.bv.iomart.io 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, SPF_HELO_NONE=0.001, SPF_PASS=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1633645369501100001 Content-Type: text/plain; charset="utf-8" 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 --- hw/display/macfb.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hw/display/macfb.c b/hw/display/macfb.c index 76808b69cc..2b747a8de8 100644 --- a/hw/display/macfb.c +++ b/hw/display/macfb.c @@ -379,6 +379,10 @@ static void macfb_sysbus_realize(DeviceState *dev, Err= or **errp) MacfbState *ms =3D &s->macfb; =20 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, Erro= r **errp) MacfbState *ms =3D &s->macfb; =20 ndc->parent_realize(dev, errp); + if (*errp) { + return; + } =20 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); } --=20 2.20.1 From nobody Thu May 9 13:16:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633644947558647.1575633600723; Thu, 7 Oct 2021 15:15:47 -0700 (PDT) Received: from localhost ([::1]:54682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYbg2-0005uC-4g for importer@patchew.org; Thu, 07 Oct 2021 18:15:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55952) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYbdZ-0003BJ-A7 for qemu-devel@nongnu.org; Thu, 07 Oct 2021 18:13:13 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]:41876 helo=mail.default.ilande.bv.iomart.io) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYbdX-0006mU-PJ for qemu-devel@nongnu.org; Thu, 07 Oct 2021 18:13:13 -0400 Received: from [2a00:23c4:8b9d:4100:5d98:71b5:90ca:dad1] (helo=kentang.home) by mail.default.ilande.bv.iomart.io with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mYbdH-0003uC-DQ; Thu, 07 Oct 2021 23:12:59 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, laurent@vivier.eu Date: Thu, 7 Oct 2021 23:12:42 +0100 Message-Id: <20211007221253.29024-3-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211007221253.29024-1-mark.cave-ayland@ilande.co.uk> References: <20211007221253.29024-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a00:23c4:8b9d:4100:5d98:71b5:90ca:dad1 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v4 02/13] macfb: update macfb.c to use the Error API best practices X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.default.ilande.bv.iomart.io) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.default.ilande.bv.iomart.io 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, SPF_HELO_NONE=0.001, SPF_PASS=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1633644950221100002 Content-Type: text/plain; charset="utf-8" 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. Not= e that memory_region_init_ram_nomigrate() is also updated to use &error_abort to i= ndicate 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 --- 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 2b747a8de8..2ec25c5d6f 100644 --- a/hw/display/macfb.c +++ b/hw/display/macfb.c @@ -343,14 +343,14 @@ static const GraphicHwOps macfb_ops =3D { .gfx_update =3D macfb_update_display, }; =20 -static void macfb_common_realize(DeviceState *dev, MacfbState *s, Error **= errp) +static bool macfb_common_realize(DeviceState *dev, MacfbState *s, Error **= errp) { DisplaySurface *surface; =20 if (s->depth !=3D 1 && s->depth !=3D 2 && s->depth !=3D 4 && s->depth = !=3D 8 && s->depth !=3D 16 && s->depth !=3D 24) { error_setg(errp, "unknown guest depth %d", s->depth); - return; + return false; } =20 s->con =3D graphic_console_init(dev, 0, &macfb_ops, s); @@ -359,18 +359,20 @@ static void macfb_common_realize(DeviceState *dev, Ma= cfbState *s, Error **errp) if (surface_bits_per_pixel(surface) !=3D 32) { error_setg(errp, "unknown host depth %d", surface_bits_per_pixel(surface)); - return; + return false; } =20 memory_region_init_io(&s->mem_ctrl, OBJECT(dev), &macfb_ctrl_ops, s, "macfb-ctrl", 0x1000); =20 memory_region_init_ram_nomigrate(&s->mem_vram, OBJECT(s), "macfb-vram", - MACFB_VRAM_SIZE, errp); + MACFB_VRAM_SIZE, &error_abort); s->vram =3D memory_region_get_ram_ptr(&s->mem_vram); s->vram_bit_mask =3D MACFB_VRAM_SIZE - 1; vmstate_register_ram(&s->mem_vram, dev); memory_region_set_coalescing(&s->mem_vram); + + return true; } =20 static void macfb_sysbus_realize(DeviceState *dev, Error **errp) @@ -378,8 +380,7 @@ static void macfb_sysbus_realize(DeviceState *dev, Erro= r **errp) MacfbSysBusState *s =3D MACFB(dev); MacfbState *ms =3D &s->macfb; =20 - macfb_common_realize(dev, ms, errp); - if (*errp) { + if (!macfb_common_realize(dev, ms, errp)) { return; } =20 @@ -399,8 +400,7 @@ static void macfb_nubus_realize(DeviceState *dev, Error= **errp) return; } =20 - macfb_common_realize(dev, ms, errp); - if (*errp) { + if (!macfb_common_realize(dev, ms, errp)) { return; } =20 --=20 2.20.1 From nobody Thu May 9 13:16:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633644948002709.0510462432079; Thu, 7 Oct 2021 15:15:48 -0700 (PDT) Received: from localhost ([::1]:54660 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYbg2-0005tO-U7 for importer@patchew.org; Thu, 07 Oct 2021 18:15:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55964) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYbdc-0003GQ-FS for qemu-devel@nongnu.org; Thu, 07 Oct 2021 18:13:16 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]:41884 helo=mail.default.ilande.bv.iomart.io) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYbdb-0006p2-3v for qemu-devel@nongnu.org; Thu, 07 Oct 2021 18:13:16 -0400 Received: from [2a00:23c4:8b9d:4100:5d98:71b5:90ca:dad1] (helo=kentang.home) by mail.default.ilande.bv.iomart.io with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mYbdL-0003uC-Rg; Thu, 07 Oct 2021 23:13:03 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, laurent@vivier.eu Date: Thu, 7 Oct 2021 23:12:43 +0100 Message-Id: <20211007221253.29024-4-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211007221253.29024-1-mark.cave-ayland@ilande.co.uk> References: <20211007221253.29024-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a00:23c4:8b9d:4100:5d98:71b5:90ca:dad1 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v4 03/13] macfb: fix invalid object reference in macfb_common_realize() X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.default.ilande.bv.iomart.io) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.default.ilande.bv.iomart.io 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, SPF_HELO_NONE=0.001, SPF_PASS=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1633644950216100001 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 t= he 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=C3=A9 Reviewed-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 2ec25c5d6f..b363bab889 100644 --- a/hw/display/macfb.c +++ b/hw/display/macfb.c @@ -365,7 +365,7 @@ static bool macfb_common_realize(DeviceState *dev, Macf= bState *s, Error **errp) memory_region_init_io(&s->mem_ctrl, OBJECT(dev), &macfb_ctrl_ops, s, "macfb-ctrl", 0x1000); =20 - memory_region_init_ram_nomigrate(&s->mem_vram, OBJECT(s), "macfb-vram", + memory_region_init_ram_nomigrate(&s->mem_vram, OBJECT(dev), "macfb-vra= m", MACFB_VRAM_SIZE, &error_abort); s->vram =3D memory_region_get_ram_ptr(&s->mem_vram); s->vram_bit_mask =3D MACFB_VRAM_SIZE - 1; --=20 2.20.1 From nobody Thu May 9 13:16:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633644952236885.7102845293625; Thu, 7 Oct 2021 15:15:52 -0700 (PDT) Received: from localhost ([::1]:54818 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYbg7-000602-6e for importer@patchew.org; Thu, 07 Oct 2021 18:15:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55982) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYbdh-0003K6-Rb for qemu-devel@nongnu.org; Thu, 07 Oct 2021 18:13:21 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]:41890 helo=mail.default.ilande.bv.iomart.io) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYbde-0006s5-Pu for qemu-devel@nongnu.org; Thu, 07 Oct 2021 18:13:21 -0400 Received: from [2a00:23c4:8b9d:4100:5d98:71b5:90ca:dad1] (helo=kentang.home) by mail.default.ilande.bv.iomart.io with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mYbdP-0003uC-UY; Thu, 07 Oct 2021 23:13:07 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, laurent@vivier.eu Date: Thu, 7 Oct 2021 23:12:44 +0100 Message-Id: <20211007221253.29024-5-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211007221253.29024-1-mark.cave-ayland@ilande.co.uk> References: <20211007221253.29024-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a00:23c4:8b9d:4100:5d98:71b5:90ca:dad1 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v4 04/13] macfb: fix overflow of color_palette array X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.default.ilande.bv.iomart.io) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.default.ilande.bv.iomart.io 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, SPF_HELO_NONE=0.001, SPF_PASS=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1633644954266100001 Content-Type: text/plain; charset="utf-8" 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 in= dex 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 --- 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 b363bab889..39dab49026 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 =3D 0; break; case DAFB_LUT: - s->color_palette[s->palette_current++] =3D val; + s->color_palette[s->palette_current] =3D val; + s->palette_current =3D (s->palette_current + 1) % + ARRAY_SIZE(s->color_palette); if (s->palette_current % 3) { macfb_invalidate_display(s); } --=20 2.20.1 From nobody Thu May 9 13:16:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633645199981994.2496827263524; Thu, 7 Oct 2021 15:19:59 -0700 (PDT) Received: from localhost ([::1]:35390 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYbk6-0003Zz-PH for importer@patchew.org; Thu, 07 Oct 2021 18:19:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55998) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYbdk-0003Q5-Ol for qemu-devel@nongnu.org; Thu, 07 Oct 2021 18:13:25 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]:41896 helo=mail.default.ilande.bv.iomart.io) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYbdj-0006u8-B0 for qemu-devel@nongnu.org; Thu, 07 Oct 2021 18:13:24 -0400 Received: from [2a00:23c4:8b9d:4100:5d98:71b5:90ca:dad1] (helo=kentang.home) by mail.default.ilande.bv.iomart.io with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mYbdT-0003uC-Q3; Thu, 07 Oct 2021 23:13:12 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, laurent@vivier.eu Date: Thu, 7 Oct 2021 23:12:45 +0100 Message-Id: <20211007221253.29024-6-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211007221253.29024-1-mark.cave-ayland@ilande.co.uk> References: <20211007221253.29024-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a00:23c4:8b9d:4100:5d98:71b5:90ca:dad1 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v4 05/13] macfb: use memory_region_init_ram() in macfb_common_realize() for the framebuffer X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.default.ilande.bv.iomart.io) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.default.ilande.bv.iomart.io 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, SPF_HELO_NONE=0.001, SPF_PASS=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1633645201647100001 Currently macfb_common_realize() defines the framebuffer RAM memory region = as being non-migrateable but then immediately registers it for migration. Repl= ace memory_region_init_ram_nomigrate() with memory_region_init_ram() which is c= learer and does exactly the same thing. Signed-off-by: Mark Cave-Ayland Reviewed-by: BALATON Zoltan Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-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 39dab49026..f88f5a6523 100644 --- a/hw/display/macfb.c +++ b/hw/display/macfb.c @@ -367,11 +367,10 @@ static bool macfb_common_realize(DeviceState *dev, Ma= cfbState *s, Error **errp) memory_region_init_io(&s->mem_ctrl, OBJECT(dev), &macfb_ctrl_ops, s, "macfb-ctrl", 0x1000); =20 - memory_region_init_ram_nomigrate(&s->mem_vram, OBJECT(dev), "macfb-vra= m", - MACFB_VRAM_SIZE, &error_abort); + memory_region_init_ram(&s->mem_vram, OBJECT(dev), "macfb-vram", + MACFB_VRAM_SIZE, &error_abort); s->vram =3D memory_region_get_ram_ptr(&s->mem_vram); s->vram_bit_mask =3D MACFB_VRAM_SIZE - 1; - vmstate_register_ram(&s->mem_vram, dev); memory_region_set_coalescing(&s->mem_vram); =20 return true; --=20 2.20.1 From nobody Thu May 9 13:16:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633645390840133.3356698002334; Thu, 7 Oct 2021 15:23:10 -0700 (PDT) Received: from localhost ([::1]:44416 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYbnB-0001I7-KH for importer@patchew.org; Thu, 07 Oct 2021 18:23:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56022) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYbdp-0003RO-C5 for qemu-devel@nongnu.org; Thu, 07 Oct 2021 18:13:33 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]:41902 helo=mail.default.ilande.bv.iomart.io) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYbdn-000772-UX for qemu-devel@nongnu.org; Thu, 07 Oct 2021 18:13:29 -0400 Received: from [2a00:23c4:8b9d:4100:5d98:71b5:90ca:dad1] (helo=kentang.home) by mail.default.ilande.bv.iomart.io with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mYbdY-0003uC-5u; Thu, 07 Oct 2021 23:13:16 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, laurent@vivier.eu Date: Thu, 7 Oct 2021 23:12:46 +0100 Message-Id: <20211007221253.29024-7-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211007221253.29024-1-mark.cave-ayland@ilande.co.uk> References: <20211007221253.29024-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a00:23c4:8b9d:4100:5d98:71b5:90ca:dad1 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v4 06/13] macfb: add trace events for reading and writing the control registers X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.default.ilande.bv.iomart.io) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.default.ilande.bv.iomart.io 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, SPF_HELO_NONE=0.001, SPF_PASS=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1633645391437100001 Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-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 f88f5a6523..1128a51c98 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" =20 #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 =3D 0; + + trace_macfb_ctrl_read(addr, val, size); + return val; } =20 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); } =20 static const MemoryRegionOps macfb_ctrl_ops =3D { diff --git a/hw/display/trace-events b/hw/display/trace-events index f03f6655bc..f227de1bb9 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= =3D0x%x, val=3D0x%x" sm501_disp_ctrl_write(uint32_t addr, uint32_t val) "addr=3D0x%x, val=3D0x%= x" sm501_2d_engine_read(uint32_t addr, uint32_t val) "addr=3D0x%x, val=3D0x%x" sm501_2d_engine_write(uint32_t addr, uint32_t val) "addr=3D0x%x, val=3D0x%= 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 0= x%"PRIx64 " value 0x%"PRIx64 " size %u" --=20 2.20.1 From nobody Thu May 9 13:16:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633645574392778.48743447515; Thu, 7 Oct 2021 15:26:14 -0700 (PDT) Received: from localhost ([::1]:51728 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYbq8-00068P-Pj for importer@patchew.org; Thu, 07 Oct 2021 18:26:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56026) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYbds-0003RV-U9 for qemu-devel@nongnu.org; Thu, 07 Oct 2021 18:13:34 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]:41906 helo=mail.default.ilande.bv.iomart.io) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYbdn-00077F-Ux for qemu-devel@nongnu.org; Thu, 07 Oct 2021 18:13:32 -0400 Received: from [2a00:23c4:8b9d:4100:5d98:71b5:90ca:dad1] (helo=kentang.home) by mail.default.ilande.bv.iomart.io with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mYbdc-0003uC-GA; Thu, 07 Oct 2021 23:13:16 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, laurent@vivier.eu Date: Thu, 7 Oct 2021 23:12:47 +0100 Message-Id: <20211007221253.29024-8-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211007221253.29024-1-mark.cave-ayland@ilande.co.uk> References: <20211007221253.29024-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a00:23c4:8b9d:4100:5d98:71b5:90ca:dad1 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v4 07/13] macfb: implement mode sense to allow display type to be detected X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.default.ilande.bv.iomart.io) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.default.ilande.bv.iomart.io 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, SPF_HELO_NONE=0.001, SPF_PASS=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1633645576767100001 Content-Type: text/plain; charset="utf-8" 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 t= he monitor sense using information found in Apple Technical Note HW26: "Macint= osh 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 --- hw/display/macfb.c | 117 ++++++++++++++++++++++++++++++++++++- hw/display/trace-events | 2 + include/hw/display/macfb.h | 20 +++++++ 3 files changed, 137 insertions(+), 2 deletions(-) diff --git a/hw/display/macfb.c b/hw/display/macfb.c index 1128a51c98..6e485d7aef 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) =20 -#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 =3D pin tied to ground + * 1 =3D pin unconnected + * + * Extended Sense: + * bit 2: pins 4-10 + * bit 1: pins 10-7 + * bit 0: pins 7-4 + * + * 0 =3D pins tied together + * 1 =3D pins unconnected + * + * Reads from the sense register appear to be active low, i.e. a 1 indicat= es + * 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 enab= les + * 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[] =3D { + { 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 }, +}; =20 =20 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); } =20 +static uint32_t macfb_sense_read(MacfbState *s) +{ + MacFbSense *macfb_sense; + uint8_t sense; + + macfb_sense =3D &macfb_sense_table[MACFB_DISPLAY_VGA]; + if (macfb_sense->sense =3D=3D 0x7) { + /* Extended sense */ + sense =3D 0; + if (!(macfb_sense->ext_sense & 1)) { + /* Pins 7-4 together */ + if (~s->sense & 3) { + sense =3D (~s->sense & 7) | 3; + } + } + if (!(macfb_sense->ext_sense & 2)) { + /* Pins 10-7 together */ + if (~s->sense & 6) { + sense =3D (~s->sense & 7) | 6; + } + } + if (!(macfb_sense->ext_sense & 4)) { + /* Pins 4-10 together */ + if (~s->sense & 5) { + sense =3D (~s->sense & 7) | 5; + } + } + } else { + /* Normal sense */ + sense =3D (~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 =3D val; + + trace_macfb_sense_write(val); + return; +} + static void macfb_update_display(void *opaque) { MacfbState *s =3D opaque; @@ -290,8 +392,15 @@ static uint64_t macfb_ctrl_read(void *opaque, hwaddr addr, unsigned int size) { + MacfbState *s =3D opaque; uint64_t val =3D 0; =20 + switch (addr) { + case DAFB_MODE_SENSE: + val =3D 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 =3D opaque; switch (addr) { + case DAFB_MODE_SENSE: + macfb_sense_write(s, val); + break; case DAFB_RESET: s->palette_current =3D 0; break; @@ -342,6 +454,7 @@ static const VMStateDescription vmstate_macfb =3D { .fields =3D (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 f227de1bb9..30cb460e4d 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) "add= r=3D0x%x, val=3D0x%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 0= x%"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 diff --git a/include/hw/display/macfb.h b/include/hw/display/macfb.h index 80806b0306..febf4ce0e8 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" =20 +typedef enum { + MACFB_DISPLAY_APPLE_21_COLOR =3D 0, + MACFB_DISPLAY_APPLE_PORTRAIT =3D 1, + MACFB_DISPLAY_APPLE_12_RGB =3D 2, + MACFB_DISPLAY_APPLE_2PAGE_MONO =3D 3, + MACFB_DISPLAY_NTSC_UNDERSCAN =3D 4, + MACFB_DISPLAY_NTSC_OVERSCAN =3D 5, + MACFB_DISPLAY_APPLE_12_MONO =3D 6, + MACFB_DISPLAY_APPLE_13_RGB =3D 7, + MACFB_DISPLAY_16_COLOR =3D 8, + MACFB_DISPLAY_PAL1_UNDERSCAN =3D 9, + MACFB_DISPLAY_PAL1_OVERSCAN =3D 10, + MACFB_DISPLAY_PAL2_UNDERSCAN =3D 11, + MACFB_DISPLAY_PAL2_OVERSCAN =3D 12, + MACFB_DISPLAY_VGA =3D 13, + MACFB_DISPLAY_SVGA =3D 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; =20 #define TYPE_MACFB "sysbus-macfb" --=20 2.20.1 From nobody Thu May 9 13:16:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633645485102387.79231183981597; Thu, 7 Oct 2021 15:24:45 -0700 (PDT) Received: from localhost ([::1]:50118 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYboi-00054l-5N for importer@patchew.org; Thu, 07 Oct 2021 18:24:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56046) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYbdv-0003Sw-Lw for qemu-devel@nongnu.org; Thu, 07 Oct 2021 18:13:38 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]:41914 helo=mail.default.ilande.bv.iomart.io) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYbds-00079m-M3 for qemu-devel@nongnu.org; Thu, 07 Oct 2021 18:13:35 -0400 Received: from [2a00:23c4:8b9d:4100:5d98:71b5:90ca:dad1] (helo=kentang.home) by mail.default.ilande.bv.iomart.io with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mYbdc-0003uC-Uz; Thu, 07 Oct 2021 23:13:21 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, laurent@vivier.eu Date: Thu, 7 Oct 2021 23:12:48 +0100 Message-Id: <20211007221253.29024-9-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211007221253.29024-1-mark.cave-ayland@ilande.co.uk> References: <20211007221253.29024-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a00:23c4:8b9d:4100:5d98:71b5:90ca:dad1 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v4 08/13] macfb: add qdev property to specify display type X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.default.ilande.bv.iomart.io) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.default.ilande.bv.iomart.io 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, SPF_HELO_NONE=0.001, SPF_PASS=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1633645486654100001 Since the available resolutions and colour depths are determined by the att= ached 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 co= lour and SVGA resolution up to 800x600 with 24-bit colour so update the q800 mac= hine to allow high resolution mode if specified and otherwise fall back to SVGA. Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Laurent Vivier --- hw/display/macfb.c | 7 ++++++- hw/m68k/q800.c | 5 +++++ include/hw/display/macfb.h | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/hw/display/macfb.c b/hw/display/macfb.c index 6e485d7aef..f98bcdec2d 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; =20 - macfb_sense =3D &macfb_sense_table[MACFB_DISPLAY_VGA]; + assert(s->type < ARRAY_SIZE(macfb_sense_table)); + macfb_sense =3D &macfb_sense_table[s->type]; if (macfb_sense->sense =3D=3D 0x7) { /* Extended sense */ sense =3D 0; @@ -544,6 +545,8 @@ static Property macfb_sysbus_properties[] =3D { 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(), }; =20 @@ -551,6 +554,8 @@ static Property macfb_nubus_properties[] =3D { 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(), }; =20 diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c index 09b3366024..5223b880bc 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 =3D=3D 1152 && graphic_height =3D=3D 870 && graphic_= depth =3D=3D 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); =20 cs =3D CPU(cpu); diff --git a/include/hw/display/macfb.h b/include/hw/display/macfb.h index febf4ce0e8..e95a97ebdc 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; =20 uint32_t sense; } MacfbState; --=20 2.20.1 From nobody Thu May 9 13:16:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633645189057463.55397878843814; Thu, 7 Oct 2021 15:19:49 -0700 (PDT) Received: from localhost ([::1]:35114 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYbjs-0003PI-5R for importer@patchew.org; Thu, 07 Oct 2021 18:19:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56068) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYbdz-0003TF-0v for qemu-devel@nongnu.org; Thu, 07 Oct 2021 18:13:39 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]:41920 helo=mail.default.ilande.bv.iomart.io) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYbdw-0007CP-VN for qemu-devel@nongnu.org; Thu, 07 Oct 2021 18:13:38 -0400 Received: from [2a00:23c4:8b9d:4100:5d98:71b5:90ca:dad1] (helo=kentang.home) by mail.default.ilande.bv.iomart.io with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mYbdh-0003uC-9K; Thu, 07 Oct 2021 23:13:25 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, laurent@vivier.eu Date: Thu, 7 Oct 2021 23:12:49 +0100 Message-Id: <20211007221253.29024-10-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211007221253.29024-1-mark.cave-ayland@ilande.co.uk> References: <20211007221253.29024-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a00:23c4:8b9d:4100:5d98:71b5:90ca:dad1 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v4 09/13] macfb: add common monitor modes supported by the MacOS toolbox ROM X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.default.ilande.bv.iomart.io) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.default.ilande.bv.iomart.io 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, SPF_HELO_NONE=0.001, SPF_PASS=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1633645190848100001 Content-Type: text/plain; charset="utf-8" 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 th= at 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 t= he existing sense register, the newly discovered control registers above, and = also the DAFB_MODE_VADDR1 and DAFB_MODE_VADDR2 registers which are used by NetBS= D to determine the current video mode. These experiments also show that the offset of the start of video RAM and t= he stride can change depending upon the monitor mode, so update macfb_draw_gra= phic() 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 --- hw/display/macfb.c | 149 +++++++++++++++++++++++++++++++++---- hw/display/trace-events | 1 + hw/m68k/q800.c | 11 ++- include/hw/display/macfb.h | 16 +++- 4 files changed, 156 insertions(+), 21 deletions(-) diff --git a/hw/display/macfb.c b/hw/display/macfb.c index f98bcdec2d..2759fb5e34 100644 --- a/hw/display/macfb.c +++ b/hw/display/macfb.c @@ -22,12 +22,16 @@ #include "migration/vmstate.h" #include "trace.h" =20 -#define VIDEO_BASE 0x00001000 +#define VIDEO_BASE 0x0 #define DAFB_BASE 0x00800000 =20 #define MACFB_PAGE_SIZE 4096 #define MACFB_VRAM_SIZE (4 * MiB) =20 +#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[] =3D { { MACFB_DISPLAY_SVGA, 0x7, 0x5 }, }; =20 +static MacFbMode macfb_mode_table[] =3D { + { 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, 0x8= 0 }, +}; =20 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 =3D 0; int y, ymin; - int macfb_stride =3D (s->depth * s->width + 7) / 8; + int macfb_stride =3D s->mode->stride; macfb_draw_line_func *macfb_draw_line; =20 switch (s->depth) { @@ -278,7 +298,7 @@ static void macfb_draw_graphic(MacfbState *s) DIRTY_MEMORY_VGA); =20 ymin =3D -1; - page =3D 0; + page =3D s->mode->offset; for (y =3D 0; y < s->height; y++, page +=3D 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 =3D 0; if (!(macfb_sense->ext_sense & 1)) { /* Pins 7-4 together */ - if (~s->sense & 3) { - sense =3D (~s->sense & 7) | 3; + if (~s->regs[DAFB_MODE_SENSE >> 2] & 3) { + sense =3D (~s->regs[DAFB_MODE_SENSE >> 2] & 7) | 3; } } if (!(macfb_sense->ext_sense & 2)) { /* Pins 10-7 together */ - if (~s->sense & 6) { - sense =3D (~s->sense & 7) | 6; + if (~s->regs[DAFB_MODE_SENSE >> 2] & 6) { + sense =3D (~s->regs[DAFB_MODE_SENSE >> 2] & 7) | 6; } } if (!(macfb_sense->ext_sense & 4)) { /* Pins 4-10 together */ - if (~s->sense & 5) { - sense =3D (~s->sense & 7) | 5; + if (~s->regs[DAFB_MODE_SENSE >> 2] & 5) { + sense =3D (~s->regs[DAFB_MODE_SENSE >> 2] & 7) | 5; } } } else { /* Normal sense */ - sense =3D (~macfb_sense->sense & 7) | (~s->sense & 7); + sense =3D (~macfb_sense->sense & 7) | + (~s->regs[DAFB_MODE_SENSE >> 2] & 7); } =20 trace_macfb_sense_read(sense); @@ -350,12 +371,84 @@ static uint32_t macfb_sense_read(MacfbState *s) =20 static void macfb_sense_write(MacfbState *s, uint32_t val) { - s->sense =3D val; + s->regs[DAFB_MODE_SENSE >> 2] =3D val; =20 trace_macfb_sense_write(val); return; } =20 +static void macfb_update_mode(MacfbState *s) +{ + s->width =3D s->mode->width; + s->height =3D s->mode->height; + s->depth =3D 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 =3D 0; i < ARRAY_SIZE(macfb_mode_table); i++) { + macfb_mode =3D &macfb_mode_table[i]; + + if (s->type !=3D macfb_mode->type) { + continue; + } + + if ((s->regs[DAFB_MODE_CTRL1 >> 2] & 0xff) =3D=3D + (macfb_mode->mode_ctrl1 & 0xff) && + (s->regs[DAFB_MODE_CTRL2 >> 2] & 0xff) =3D=3D + (macfb_mode->mode_ctrl2 & 0xff)) { + s->mode =3D 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 =3D 0; i < ARRAY_SIZE(macfb_mode_table); i++) { + macfb_mode =3D &macfb_mode_table[i]; + + if (display_type =3D=3D macfb_mode->type && width =3D=3D macfb_mod= e->width && + height =3D=3D macfb_mode->height && depth =3D=3D macfb_mod= e->depth) { + return macfb_mode; + } + } + + return NULL; +} + +static gchar *macfb_mode_list(void) +{ + gchar *list =3D NULL; + gchar *mode; + MacFbMode *macfb_mode; + int i; + + for (i =3D 0; i < ARRAY_SIZE(macfb_mode_table); i++) { + macfb_mode =3D &macfb_mode_table[i]; + + mode =3D g_strdup_printf(" %dx%dx%d\n", macfb_mode->width, + macfb_mode->height, macfb_mode->depth); + list =3D g_strconcat(mode, list, NULL); + g_free(mode); + } + + return list; +} + + static void macfb_update_display(void *opaque) { MacfbState *s =3D opaque; @@ -397,6 +490,12 @@ static uint64_t macfb_ctrl_read(void *opaque, uint64_t val =3D 0; =20 switch (addr) { + case DAFB_MODE_VADDR1: + case DAFB_MODE_VADDR2: + case DAFB_MODE_CTRL1: + case DAFB_MODE_CTRL2: + val =3D s->regs[addr >> 2]; + break; case DAFB_MODE_SENSE: val =3D macfb_sense_read(s); break; @@ -413,6 +512,17 @@ static void macfb_ctrl_write(void *opaque, { MacfbState *s =3D opaque; switch (addr) { + case DAFB_MODE_VADDR1: + case DAFB_MODE_VADDR2: + s->regs[addr >> 2] =3D val; + break; + case DAFB_MODE_CTRL1 ... DAFB_MODE_CTRL1 + 3: + case DAFB_MODE_CTRL2 ... DAFB_MODE_CTRL2 + 3: + s->regs[addr >> 2] =3D 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 =3D { =20 static int macfb_post_load(void *opaque, int version_id) { - macfb_invalidate_display(opaque); + macfb_mode_write(opaque); return 0; } =20 @@ -455,7 +565,7 @@ static const VMStateDescription vmstate_macfb =3D { .fields =3D (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, Mac= fbState *s, Error **errp) { DisplaySurface *surface; =20 - if (s->depth !=3D 1 && s->depth !=3D 2 && s->depth !=3D 4 && s->depth = !=3D 8 && - s->depth !=3D 16 && s->depth !=3D 24) { - error_setg(errp, "unknown guest depth %d", s->depth); + s->mode =3D 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 =3D macfb_mode_list(); + error_append_hint(errp, "Available modes:\n%s", list); + g_free(list); + return false; } =20 @@ -493,6 +609,7 @@ static bool macfb_common_realize(DeviceState *dev, Macf= bState *s, Error **errp) s->vram_bit_mask =3D MACFB_VRAM_SIZE - 1; memory_region_set_coalescing(&s->mem_vram); =20 + macfb_update_mode(s); return true; } =20 diff --git a/hw/display/trace-events b/hw/display/trace-events index 30cb460e4d..3a7a2c957f 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 0= x%"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" diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c index 5223b880bc..df3fd3711e 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 =20 #define MAC_CLOCK 3686418 =20 @@ -221,6 +221,7 @@ static void q800_init(MachineState *machine) uint8_t *prom; const int io_slice_nb =3D (IO_SIZE / IO_SLICE) - 1; int i, checksum; + MacFbMode *macfb_mode; ram_addr_t ram_size =3D machine->ram_size; const char *kernel_filename =3D machine->kernel_filename; const char *initrd_filename =3D machine->initrd_filename; @@ -428,6 +429,8 @@ static void q800_init(MachineState *machine) } qdev_realize_and_unref(dev, BUS(nubus), &error_fatal); =20 + macfb_mode =3D (NUBUS_MACFB(dev)->macfb).mode; + cs =3D 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); =20 rom =3D g_malloc(sizeof(*rom)); diff --git a/include/hw/display/macfb.h b/include/hw/display/macfb.h index e95a97ebdc..0aff0d84d2 100644 --- a/include/hw/display/macfb.h +++ b/include/hw/display/macfb.h @@ -35,6 +35,19 @@ typedef enum { MACFB_DISPLAY_SVGA =3D 14, } MacfbDisplayType; =20 +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; =20 - uint32_t sense; + uint32_t regs[MACFB_NUM_REGS]; + MacFbMode *mode; } MacfbState; =20 #define TYPE_MACFB "sysbus-macfb" --=20 2.20.1 From nobody Thu May 9 13:16:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633645726834502.2569546832459; Thu, 7 Oct 2021 15:28:46 -0700 (PDT) Received: from localhost ([::1]:59494 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYbsb-00034T-Iq for importer@patchew.org; Thu, 07 Oct 2021 18:28:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56106) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYbe5-0003ZV-Uj for qemu-devel@nongnu.org; Thu, 07 Oct 2021 18:13:45 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]:41926 helo=mail.default.ilande.bv.iomart.io) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYbe4-0007HK-9b for qemu-devel@nongnu.org; Thu, 07 Oct 2021 18:13:45 -0400 Received: from [2a00:23c4:8b9d:4100:5d98:71b5:90ca:dad1] (helo=kentang.home) by mail.default.ilande.bv.iomart.io with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mYbdl-0003uC-QB; Thu, 07 Oct 2021 23:13:30 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, laurent@vivier.eu Date: Thu, 7 Oct 2021 23:12:50 +0100 Message-Id: <20211007221253.29024-11-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211007221253.29024-1-mark.cave-ayland@ilande.co.uk> References: <20211007221253.29024-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a00:23c4:8b9d:4100:5d98:71b5:90ca:dad1 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v4 10/13] macfb: fix up 1-bit pixel encoding X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.default.ilande.bv.iomart.io) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.default.ilande.bv.iomart.io 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, SPF_HELO_NONE=0.001, SPF_PASS=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1633645728935100001 Content-Type: text/plain; charset="utf-8" The MacOS driver expects the RGB values for the pixel to be in entries 0 an= d 1 of the colour palette. Signed-off-by: Mark Cave-Ayland Reviewed-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 2759fb5e34..e49c8b6f4b 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 =3D 0; x < width; x++) { int bit =3D x & 7; int idx =3D (macfb_read_byte(s, addr) >> (7 - bit)) & 1; - r =3D g =3D b =3D ((1 - idx) << 7); + r =3D s->color_palette[idx * 3]; + g =3D s->color_palette[idx * 3 + 1]; + b =3D s->color_palette[idx * 3 + 2]; addr +=3D (bit =3D=3D 7); =20 *(uint32_t *)d =3D rgb_to_pixel32(r, g, b); --=20 2.20.1 From nobody Thu May 9 13:16:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633645173029632.8485321221217; Thu, 7 Oct 2021 15:19:33 -0700 (PDT) Received: from localhost ([::1]:34718 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYbje-000399-8N for importer@patchew.org; Thu, 07 Oct 2021 18:19:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56118) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYbe6-0003ct-Vs for qemu-devel@nongnu.org; Thu, 07 Oct 2021 18:13:47 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]:41932 helo=mail.default.ilande.bv.iomart.io) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYbe5-0007Hp-5A for qemu-devel@nongnu.org; Thu, 07 Oct 2021 18:13:46 -0400 Received: from [2a00:23c4:8b9d:4100:5d98:71b5:90ca:dad1] (helo=kentang.home) by mail.default.ilande.bv.iomart.io with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mYbdq-0003uC-9p; Thu, 07 Oct 2021 23:13:34 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, laurent@vivier.eu Date: Thu, 7 Oct 2021 23:12:51 +0100 Message-Id: <20211007221253.29024-12-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211007221253.29024-1-mark.cave-ayland@ilande.co.uk> References: <20211007221253.29024-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a00:23c4:8b9d:4100:5d98:71b5:90ca:dad1 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v4 11/13] macfb: fix 24-bit RGB pixel encoding X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.default.ilande.bv.iomart.io) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.default.ilande.bv.iomart.io 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, SPF_HELO_NONE=0.001, SPF_PASS=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1633645173717100001 Content-Type: text/plain; charset="utf-8" According to Apple Technical Note HW26: "Macintosh Quadra Built-In Video" t= he 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 M= acOS when changing into 24-bit colour mode. Signed-off-by: Mark Cave-Ayland Reviewed-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 e49c8b6f4b..3288a71b89 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; =20 for (x =3D 0; x < width; x++) { - r =3D macfb_read_byte(s, addr); - g =3D macfb_read_byte(s, addr + 1); - b =3D macfb_read_byte(s, addr + 2); - addr +=3D 3; + r =3D macfb_read_byte(s, addr + 1); + g =3D macfb_read_byte(s, addr + 2); + b =3D macfb_read_byte(s, addr + 3); + addr +=3D 4; =20 *(uint32_t *)d =3D rgb_to_pixel32(r, g, b); d +=3D 4; --=20 2.20.1 From nobody Thu May 9 13:16:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633645379831411.24136680381775; Thu, 7 Oct 2021 15:22:59 -0700 (PDT) Received: from localhost ([::1]:43326 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYbn0-0000Yw-RW for importer@patchew.org; Thu, 07 Oct 2021 18:22:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56130) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYbeB-0003u6-CP for qemu-devel@nongnu.org; Thu, 07 Oct 2021 18:13:51 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]:41938 helo=mail.default.ilande.bv.iomart.io) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYbe9-0007L6-IG for qemu-devel@nongnu.org; Thu, 07 Oct 2021 18:13:51 -0400 Received: from [2a00:23c4:8b9d:4100:5d98:71b5:90ca:dad1] (helo=kentang.home) by mail.default.ilande.bv.iomart.io with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mYbdu-0003uC-3f; Thu, 07 Oct 2021 23:13:38 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, laurent@vivier.eu Date: Thu, 7 Oct 2021 23:12:52 +0100 Message-Id: <20211007221253.29024-13-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211007221253.29024-1-mark.cave-ayland@ilande.co.uk> References: <20211007221253.29024-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a00:23c4:8b9d:4100:5d98:71b5:90ca:dad1 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v4 12/13] macfb: add vertical blank interrupt X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.default.ilande.bv.iomart.io) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.default.ilande.bv.iomart.io 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, SPF_HELO_NONE=0.001, SPF_PASS=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1633645381995100001 Content-Type: text/plain; charset="utf-8" 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 R= etrace Manager. Signed-off-by: Mark Cave-Ayland Reviewed-by: Laurent Vivier --- hw/display/macfb.c | 83 ++++++++++++++++++++++++++++++++++++++ include/hw/display/macfb.h | 8 ++++ 2 files changed, 91 insertions(+) diff --git a/hw/display/macfb.c b/hw/display/macfb.c index 3288a71b89..4b352eb89c 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 =20 +#define DAFB_INTR_VBL 0x4 + +/* Vertical Blank period (60.15Hz) */ +#define DAFB_INTR_VBL_PERIOD_NS 16625800 =20 /* * Quadra sense codes taken from Apple Technical Note HW26: @@ -470,6 +477,36 @@ static void macfb_update_display(void *opaque) macfb_draw_graphic(s); } =20 +static void macfb_update_irq(MacfbState *s) +{ + uint32_t irq_state =3D 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_N= S) / + DAFB_INTR_VBL_PERIOD_NS * DAFB_INTR_VBL_PERIOD_NS; +} + +static void macfb_vbl_timer(void *opaque) +{ + MacfbState *s =3D opaque; + int64_t next_vbl; + + s->irq_state |=3D DAFB_INTR_VBL; + macfb_update_irq(s); + + /* 60 Hz irq */ + next_vbl =3D 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 =3D s->regs[addr >> 2]; break; + case DAFB_INTR_STAT: + val =3D s->irq_state; + break; case DAFB_MODE_SENSE: val =3D macfb_sense_read(s); break; @@ -513,6 +553,8 @@ static void macfb_ctrl_write(void *opaque, unsigned int size) { MacfbState *s =3D 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 =3D val; + if (val & DAFB_INTR_VBL) { + next_vbl =3D macfb_next_vbl(); + timer_mod(s->vbl_timer, next_vbl); + } else { + timer_del(s->vbl_timer); + } + break; + case DAFB_INTR_CLEAR: + s->irq_state &=3D ~DAFB_INTR_VBL; + macfb_update_irq(s); + break; case DAFB_RESET: s->palette_current =3D 0; + s->irq_state &=3D ~DAFB_INTR_VBL; + macfb_update_irq(s); break; case DAFB_LUT: s->color_palette[s->palette_current] =3D val; @@ -611,6 +668,7 @@ static bool macfb_common_realize(DeviceState *dev, Macf= bState *s, Error **errp) s->vram_bit_mask =3D MACFB_VRAM_SIZE - 1; memory_region_set_coalescing(&s->mem_vram); =20 + s->vbl_timer =3D 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, Err= or **errp) =20 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 =3D NUBUS_MACFB(opaque); + NubusDevice *nd =3D NUBUS_DEVICE(s); + + nubus_set_irq(nd, level); } =20 static void macfb_nubus_realize(DeviceState *dev, Error **errp) @@ -646,6 +714,19 @@ static void macfb_nubus_realize(DeviceState *dev, Erro= r **errp) =20 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 =3D qemu_allocate_irq(macfb_nubus_set_irq, s, 0); +} + +static void macfb_nubus_unrealize(DeviceState *dev) +{ + MacfbNubusState *s =3D NUBUS_MACFB(dev); + MacfbNubusDeviceClass *ndc =3D NUBUS_MACFB_GET_CLASS(dev); + MacfbState *ms =3D &s->macfb; + + ndc->parent_unrealize(dev); + + qemu_free_irq(ms->irq); } =20 static void macfb_sysbus_reset(DeviceState *d) @@ -696,6 +777,8 @@ static void macfb_nubus_class_init(ObjectClass *klass, = void *data) =20 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 =3D "Nubus Macintosh framebuffer"; dc->reset =3D macfb_nubus_reset; dc->vmsd =3D &vmstate_macfb; diff --git a/include/hw/display/macfb.h b/include/hw/display/macfb.h index 0aff0d84d2..e52775aa21 100644 --- a/include/hw/display/macfb.h +++ b/include/hw/display/macfb.h @@ -14,7 +14,9 @@ #define MACFB_H =20 #include "exec/memory.h" +#include "hw/irq.h" #include "ui/console.h" +#include "qemu/timer.h" #include "qom/object.h" =20 typedef enum { @@ -63,6 +65,11 @@ typedef struct MacfbState { =20 uint32_t regs[MACFB_NUM_REGS]; MacFbMode *mode; + + uint32_t irq_state; + uint32_t irq_mask; + QEMUTimer *vbl_timer; + qemu_irq irq; } MacfbState; =20 #define TYPE_MACFB "sysbus-macfb" @@ -81,6 +88,7 @@ struct MacfbNubusDeviceClass { DeviceClass parent_class; =20 DeviceRealize parent_realize; + DeviceUnrealize parent_unrealize; }; =20 =20 --=20 2.20.1 From nobody Thu May 9 13:16:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633645383096748.9812339634173; Thu, 7 Oct 2021 15:23:03 -0700 (PDT) Received: from localhost ([::1]:43528 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYbn3-0000hk-1X for importer@patchew.org; Thu, 07 Oct 2021 18:23:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56144) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYbeE-0003uu-QV for qemu-devel@nongnu.org; Thu, 07 Oct 2021 18:13:55 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]:41942 helo=mail.default.ilande.bv.iomart.io) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYbeD-0007Nn-Fa for qemu-devel@nongnu.org; Thu, 07 Oct 2021 18:13:54 -0400 Received: from [2a00:23c4:8b9d:4100:5d98:71b5:90ca:dad1] (helo=kentang.home) by mail.default.ilande.bv.iomart.io with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mYbdy-0003uC-Ie; Thu, 07 Oct 2021 23:13:42 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, laurent@vivier.eu Date: Thu, 7 Oct 2021 23:12:53 +0100 Message-Id: <20211007221253.29024-14-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211007221253.29024-1-mark.cave-ayland@ilande.co.uk> References: <20211007221253.29024-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a00:23c4:8b9d:4100:5d98:71b5:90ca:dad1 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v4 13/13] q800: wire macfb IRQ to separate video interrupt on VIA2 X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.default.ilande.bv.iomart.io) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.default.ilande.bv.iomart.io 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, SPF_HELO_NONE=0.001, SPF_PASS=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1633645384177100001 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=C3=A9 Reviewed-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 df3fd3711e..fd4855047e 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 =3D 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 =3D 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 */ =20 dev =3D 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); --=20 2.20.1