From nobody Fri May 17 05:00:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1681317355; cv=none; d=zohomail.com; s=zohoarc; b=BqBWPSNPM8lWpZZYSUcgB8QZamTzmvoonnXluSzYyFE9sNEpKSD6GlZ0oQM9KFLPsek2Y8vwL3JLadoff+W19bqs2D0yuk9U7ymrjs55RNvM/OW88mD8FsbMQeOb8p2swIbC3LRimIgMjWdWuu81sc3Xwgnaqq1Cj66+Y6WZtVA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681317355; h=Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=2jD4H5gPXnaAqY8DUO1QMGzsP2+rnnVc7YftHAxjNAE=; b=MtqJk1b0AnWrbHIYhS1StCG93mCW7YuSOs4syjQAnbXTfO1d761SKSRBzhVmzf5jrV8M511cko0Z+Gs66meGSpzXlQ9IKppp41714hmG+MOLWwMX9HOOzdHhswevVL83pBdJAufkc0Qvf47YMJ+dJDzG/RtgJrT/6E8tRtKFfwU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1681317355929258.8467032310406; Wed, 12 Apr 2023 09:35:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pmdRG-00064V-Ga; Wed, 12 Apr 2023 12:35:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pmdR9-00064C-6V for qemu-devel@nongnu.org; Wed, 12 Apr 2023 12:35:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pmdR6-0007Fv-SX for qemu-devel@nongnu.org; Wed, 12 Apr 2023 12:35:10 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-529-DOU_Or9LPdqe3Of3O_5ONQ-1; Wed, 12 Apr 2023 12:35:05 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4D2BA889058; Wed, 12 Apr 2023 16:35:05 +0000 (UTC) Received: from thuth.com (unknown [10.39.192.113]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8626340C83A9; Wed, 12 Apr 2023 16:35:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681317307; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=2jD4H5gPXnaAqY8DUO1QMGzsP2+rnnVc7YftHAxjNAE=; b=BUsEwJOwinkAFJO5dXkSSHJv8pI87Q2b9fGAGDoGYsIZXX20+kj7yEpqFPO7+zrLUDp9uR x4Vx557hWxWH/A7C0ORxGQGLNI/Kvxxopb+e4mm5s+VC/jw4Z73+RGthcNkaU27rF8I5bm 7upKJfi5+IPBjpXIojArNeEGCUqDqvk= X-MC-Unique: DOU_Or9LPdqe3Of3O_5ONQ-1 From: Thomas Huth To: qemu-devel@nongnu.org, Gerd Hoffmann , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH for-8.1] hw/display: Compile vga.c as target-independent code Date: Wed, 12 Apr 2023 18:35:01 +0200 Message-Id: <20230412163501.36770-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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=170.10.129.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1681317358268100002 Content-Type: text/plain; charset="utf-8" The target checks here are only during the initialization, so they are not performance critical. We can switch these to runtime checks to avoid that we have to compile this file multiple times during the build, and make the code ready for an universal build one day. Signed-off-by: Thomas Huth Reviewed-by: Fabiano Rosas --- hw/display/vga.c | 31 ++++++++++++++++++++++--------- hw/display/meson.build | 2 +- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/hw/display/vga.c b/hw/display/vga.c index 7a5fdff649..37557c3442 100644 --- a/hw/display/vga.c +++ b/hw/display/vga.c @@ -26,7 +26,9 @@ #include "qemu/units.h" #include "sysemu/reset.h" #include "qapi/error.h" +#include "hw/core/cpu.h" #include "hw/display/vga.h" +#include "hw/i386/x86.h" #include "hw/pci/pci.h" #include "vga_int.h" #include "vga_regs.h" @@ -2244,11 +2246,8 @@ bool vga_common_init(VGACommonState *s, Object *obj,= Error **errp) * into a device attribute set by the machine/platform to remove * all target endian dependencies from this file. */ -#if TARGET_BIG_ENDIAN - s->default_endian_fb =3D true; -#else - s->default_endian_fb =3D false; -#endif + s->default_endian_fb =3D target_words_bigendian(); + vga_dirty_log_start(s); =20 return true; @@ -2263,11 +2262,15 @@ static const MemoryRegionPortio vga_portio_list[] = =3D { PORTIO_END_OF_LIST(), }; =20 -static const MemoryRegionPortio vbe_portio_list[] =3D { +static const MemoryRegionPortio vbe_portio_list_x86[] =3D { { 0, 1, 2, .read =3D vbe_ioport_read_index, .write =3D vbe_ioport_writ= e_index }, -# ifdef TARGET_I386 { 1, 1, 2, .read =3D vbe_ioport_read_data, .write =3D vbe_ioport_write= _data }, -# endif + { 2, 1, 2, .read =3D vbe_ioport_read_data, .write =3D vbe_ioport_write= _data }, + PORTIO_END_OF_LIST(), +}; + +static const MemoryRegionPortio vbe_portio_list_no_x86[] =3D { + { 0, 1, 2, .read =3D vbe_ioport_read_index, .write =3D vbe_ioport_writ= e_index }, { 2, 1, 2, .read =3D vbe_ioport_read_data, .write =3D vbe_ioport_write= _data }, PORTIO_END_OF_LIST(), }; @@ -2278,9 +2281,19 @@ MemoryRegion *vga_init_io(VGACommonState *s, Object = *obj, const MemoryRegionPortio **vbe_ports) { MemoryRegion *vga_mem; + MachineState *ms =3D MACHINE(qdev_get_machine()); + + /* + * We unfortunately need two VBE lists since non-x86 machines might + * not be able to do 16-bit accesses at unaligned addresses (0x1cf) + */ + if (object_dynamic_cast(OBJECT(ms), TYPE_X86_MACHINE)) { + *vbe_ports =3D vbe_portio_list_x86; + } else { + *vbe_ports =3D vbe_portio_list_no_x86; + } =20 *vga_ports =3D vga_portio_list; - *vbe_ports =3D vbe_portio_list; =20 vga_mem =3D g_malloc(sizeof(*vga_mem)); memory_region_init_io(vga_mem, obj, &vga_mem_ops, s, diff --git a/hw/display/meson.build b/hw/display/meson.build index 4191694380..17165bd536 100644 --- a/hw/display/meson.build +++ b/hw/display/meson.build @@ -36,7 +36,7 @@ softmmu_ss.add(when: 'CONFIG_CG3', if_true: files('cg3.c'= )) softmmu_ss.add(when: 'CONFIG_MACFB', if_true: files('macfb.c')) softmmu_ss.add(when: 'CONFIG_NEXTCUBE', if_true: files('next-fb.c')) =20 -specific_ss.add(when: 'CONFIG_VGA', if_true: files('vga.c')) +softmmu_ss.add(when: 'CONFIG_VGA', if_true: files('vga.c')) =20 if (config_all_devices.has_key('CONFIG_VGA_CIRRUS') or config_all_devices.has_key('CONFIG_VGA_PCI') or --=20 2.31.1