[PATCH 5/5] qemu-riscv: Enable ramfb by default

Alexander Graf agraf at csgraf.de
Sun Feb 27 18:03:52 CET 2022


Now that we have everything in place to support ramfb, let's wire it up
by default in the RISC-V QEMU targets. That way, you can easily use a
graphical console by just passing -device ramfb to the QEMU command line.

Signed-off-by: Alexander Graf <agraf at csgraf.de>
---
 board/emulation/qemu-riscv/Kconfig      |  6 ++++++
 board/emulation/qemu-riscv/qemu-riscv.c | 15 +++++++++++++++
 include/configs/qemu-riscv.h            |  9 +++++++++
 3 files changed, 30 insertions(+)

diff --git a/board/emulation/qemu-riscv/Kconfig b/board/emulation/qemu-riscv/Kconfig
index 02bf84725b..1967fb3a63 100644
--- a/board/emulation/qemu-riscv/Kconfig
+++ b/board/emulation/qemu-riscv/Kconfig
@@ -67,5 +67,11 @@ config BOARD_SPECIFIC_OPTIONS # dummy
 	imply MTD_NOR_FLASH
 	imply CFI_FLASH
 	imply OF_HAS_PRIOR_STAGE
+	imply BOARD_EARLY_INIT_R
+	imply DM_VIDEO
+	imply VIDEO_RAMFB
+	imply SYS_CONSOLE_IS_IN_ENV
+	imply CMD_QFW
+	imply QFW_MMIO
 
 endif
diff --git a/board/emulation/qemu-riscv/qemu-riscv.c b/board/emulation/qemu-riscv/qemu-riscv.c
index ae3b7a3295..31799b8c3a 100644
--- a/board/emulation/qemu-riscv/qemu-riscv.c
+++ b/board/emulation/qemu-riscv/qemu-riscv.c
@@ -10,6 +10,7 @@
 #include <fdtdec.h>
 #include <image.h>
 #include <log.h>
+#include <qfw.h>
 #include <spl.h>
 #include <init.h>
 #include <virtio_types.h>
@@ -28,6 +29,20 @@ int is_flash_available(void)
 }
 #endif
 
+int board_early_init_r(void)
+{
+	struct udevice *qfw_dev;
+
+	/*
+	 * Make sure we enumerate the QEMU Firmware device to find ramfb
+	 * before console init starts.
+	 */
+	if (IS_ENABLED(CONFIG_CMD_QFW))
+		qfw_get_dev(&qfw_dev);
+
+	return 0;
+}
+
 int board_init(void)
 {
 	/*
diff --git a/include/configs/qemu-riscv.h b/include/configs/qemu-riscv.h
index 618c3b63d4..663ba50688 100644
--- a/include/configs/qemu-riscv.h
+++ b/include/configs/qemu-riscv.h
@@ -39,6 +39,12 @@
 	func(SCSI, scsi, 0) \
 	func(DHCP, dhcp, na)
 
+#ifdef CONFIG_VIDEO_RAMFB
+# define QEMU_STDOUT "serial,vidconsole"
+#else
+# define QEMU_STDOUT "serial"
+#endif
+
 #include <config_distro_bootcmd.h>
 
 #define BOOTENV_DEV_QEMU(devtypeu, devtypel, instance) \
@@ -58,6 +64,9 @@
 	"scriptaddr=0x88100000\0" \
 	"pxefile_addr_r=0x88200000\0" \
 	"ramdisk_addr_r=0x88300000\0" \
+	"stdin=serial\0" \
+	"stdout=" QEMU_STDOUT "\0" \
+	"stderr=" QEMU_STDOUT "\0" \
 	BOOTENV
 #endif
 
-- 
2.32.0



More information about the U-Boot mailing list