Alper Nebi Yasak has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/80376?usp=email )
Change subject: drivers/qemu/bochs: Allow building for non-x86 architectures ......................................................................
drivers/qemu/bochs: Allow building for non-x86 architectures
The Bochs display driver was written for x86 and is only allowed to build only for that, but the devices can be used just fine on other architectures on the QEMU side as long as the emulated platform supports PCI. Commit efaf1b32ba1eb ("drivers/emulation/qemu/bochs: Rewrite driver") adds support for using MMIO mapped Bochs display devices, which would work for other architectures as well if not for the x86 parts.
The existing driver can use MMIO, but if the device is a legacy-capable VGA device it defaults to using I/O ports. Add an additional CONFIG(VGA) check to that so we can avoid x86-style I/O for architectures where that is not implemented yet.
Allow the Bochs display driver to be built for non-x86 QEMU boards by changing the Kconfig dependencies and using #if directives to avoid port-based IO functions. Make VGA and text framebuffer support depend on x86. Add a dependency on PCI since this is a PCI device and vexpress-a9 (qemu-armv7) doesn't have the (emulated) hardware for PCI.
Change-Id: I7f72d7ea13e54ecf89d067394c02b572c5f92d24 Signed-off-by: Alper Nebi Yasak alpernebiyasak@gmail.com --- M src/drivers/emulation/qemu/Kconfig M src/drivers/emulation/qemu/bochs.c 2 files changed, 19 insertions(+), 6 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/76/80376/1
diff --git a/src/drivers/emulation/qemu/Kconfig b/src/drivers/emulation/qemu/Kconfig index e846a29..8e2dad9 100644 --- a/src/drivers/emulation/qemu/Kconfig +++ b/src/drivers/emulation/qemu/Kconfig @@ -1,11 +1,12 @@ config DRIVERS_EMULATION_QEMU_BOCHS bool "bochs dispi interface vga driver" default y - depends on CPU_QEMU_X86 + depends on PCI + depends on VENDOR_EMULATION depends on MAINBOARD_DO_NATIVE_VGA_INIT - select HAVE_VGA_TEXT_FRAMEBUFFER + select HAVE_VGA_TEXT_FRAMEBUFFER if CPU_QEMU_X86 select HAVE_LINEAR_FRAMEBUFFER - select VGA + select VGA if CPU_QEMU_X86 help VGA driver for qemu emulated vga cards supporting the bochs dispi interface. This includes diff --git a/src/drivers/emulation/qemu/bochs.c b/src/drivers/emulation/qemu/bochs.c index 0650430..b8a6fa9 100644 --- a/src/drivers/emulation/qemu/bochs.c +++ b/src/drivers/emulation/qemu/bochs.c @@ -1,6 +1,10 @@ /* SPDX-License-Identifier: GPL-2.0-only */
+#if CONFIG(CPU_QEMU_X86) #include <arch/io.h> +#else +#include <arch/mmio.h> +#endif #include <console/console.h> #include <device/device.h> #include <device/mmio.h> @@ -45,8 +49,10 @@ static void bochs_write(struct resource *res, int index, int val) { if (res->flags & IORESOURCE_IO) { +#if CONFIG(CPU_QEMU_X86) outw(index, res->base); outw(val, res->base + 1); +#endif } else { write16(res2mmio(res, 0x500 + index * 2, 0), val); } @@ -55,8 +61,12 @@ static int bochs_read(struct resource *res, int index) { if (res->flags & IORESOURCE_IO) { +#if CONFIG(CPU_QEMU_X86) outw(index, res->base); return inw(res->base + 1); +#else + return 0; +#endif } else { return read16(res2mmio(res, 0x500 + index * 2, 0)); } @@ -64,9 +74,11 @@
static void bochs_vga_write(struct resource *res, int index, uint8_t val) { - if (res->flags & IORESOURCE_IO) + if (res->flags & IORESOURCE_IO) { +#if CONFIG(CPU_QEMU_X86) outb(val, index + 0x3c0); - else +#endif + } else write8(res2mmio(res, 0x400 + index, 0), val); }
@@ -103,7 +115,7 @@
/* MMIO bar supported since qemu 3.0+ */ res_io = probe_resource(dev, PCI_BASE_ADDRESS_2); - if (((dev->class >> 8) == PCI_CLASS_DISPLAY_VGA) || + if ((CONFIG(VGA) && (dev->class >> 8) == PCI_CLASS_DISPLAY_VGA) || !res_io || !(res_io->flags & IORESOURCE_MEM)) { printk(BIOS_DEBUG, "QEMU VGA: Using legacy VGA\n"); res_io = &res_legacy;