[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 15/23] hw/display: Compile vga.c as target-independent code
From: |
Thomas Huth |
Subject: |
[PULL 15/23] hw/display: Compile vga.c as target-independent code |
Date: |
Thu, 20 Apr 2023 12:12:08 +0200 |
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.
Message-Id: <20230412163501.36770-1-thuth@redhat.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
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 = true;
-#else
- s->default_endian_fb = false;
-#endif
+ s->default_endian_fb = target_words_bigendian();
+
vga_dirty_log_start(s);
return true;
@@ -2263,11 +2262,15 @@ static const MemoryRegionPortio vga_portio_list[] = {
PORTIO_END_OF_LIST(),
};
-static const MemoryRegionPortio vbe_portio_list[] = {
+static const MemoryRegionPortio vbe_portio_list_x86[] = {
{ 0, 1, 2, .read = vbe_ioport_read_index, .write = vbe_ioport_write_index
},
-# ifdef TARGET_I386
{ 1, 1, 2, .read = vbe_ioport_read_data, .write = vbe_ioport_write_data },
-# endif
+ { 2, 1, 2, .read = vbe_ioport_read_data, .write = vbe_ioport_write_data },
+ PORTIO_END_OF_LIST(),
+};
+
+static const MemoryRegionPortio vbe_portio_list_no_x86[] = {
+ { 0, 1, 2, .read = vbe_ioport_read_index, .write = vbe_ioport_write_index
},
{ 2, 1, 2, .read = vbe_ioport_read_data, .write = 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 = 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 = vbe_portio_list_x86;
+ } else {
+ *vbe_ports = vbe_portio_list_no_x86;
+ }
*vga_ports = vga_portio_list;
- *vbe_ports = vbe_portio_list;
vga_mem = 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'))
-specific_ss.add(when: 'CONFIG_VGA', if_true: files('vga.c'))
+softmmu_ss.add(when: 'CONFIG_VGA', if_true: files('vga.c'))
if (config_all_devices.has_key('CONFIG_VGA_CIRRUS') or
config_all_devices.has_key('CONFIG_VGA_PCI') or
--
2.31.1
- [PULL 02/23] docs: Fix typo (wphx => whpx), (continued)
- [PULL 02/23] docs: Fix typo (wphx => whpx), Thomas Huth, 2023/04/20
- [PULL 01/23] hw: Add compat machines for 8.1, Thomas Huth, 2023/04/20
- [PULL 05/23] qtest: Don't assert on "-qtest chardev:myid", Thomas Huth, 2023/04/20
- [PULL 06/23] chardev: Allow setting file chardev input file on the command line, Thomas Huth, 2023/04/20
- [PULL 10/23] target/i386: Set family/model/stepping of the "max" CPU according to LM bit, Thomas Huth, 2023/04/20
- [PULL 08/23] travis.yml: Add missing 'flex', 'bison' packages to 'GCC (user)' job, Thomas Huth, 2023/04/20
- [PULL 14/23] softmmu: Make qtest.c target independent, Thomas Huth, 2023/04/20
- [PULL 07/23] travis.yml: Add missing clang-10 package to the 'Clang (disable-tcg)' job, Thomas Huth, 2023/04/20
- [PULL 04/23] test: Fix test-crypto-secret when compiling without keyring support, Thomas Huth, 2023/04/20
- [PULL 13/23] include/exec: Provide the tswap() functions for target independent code, too, Thomas Huth, 2023/04/20
- [PULL 15/23] hw/display: Compile vga.c as target-independent code,
Thomas Huth <=
- [PULL 12/23] softmmu/qtest: Move the target-specific pseries RTAS code out of qtest.c, Thomas Huth, 2023/04/20
- [PULL 17/23] hw/core: Move numa.c into the target independent source set, Thomas Huth, 2023/04/20
- [PULL 21/23] qtest: Move tpm_util_tis_transmit() into tpm-tis-utils.c and rename it, Thomas Huth, 2023/04/20
- [PULL 23/23] tests/vm/freebsd: Update to FreeBSD 13.2, Thomas Huth, 2023/04/20
- [PULL 09/23] tests/migration: Only run auto_converge in slow mode, Thomas Huth, 2023/04/20
- [PULL 11/23] hw/char: Move two more files from specific_ss to softmmu_ss, Thomas Huth, 2023/04/20
- [PULL 18/23] cpu: Remove parameter of list_cpus(), Thomas Huth, 2023/04/20
- [PULL 16/23] softmmu: Move dirtylimit.c into the target independent source set, Thomas Huth, 2023/04/20
- [PULL 20/23] qtest: Add functions for accessing devices on Aspeed I2C controller, Thomas Huth, 2023/04/20
- [PULL 22/23] qtest: Add a test case for TPM TIS I2C connected to Aspeed I2C controller, Thomas Huth, 2023/04/20