[PATCH 00/18] video: bochs: Remove the x86 limitation

The Bochs VGA card emulated by QEMU does not enforce any architecture. It was first introduced on x86 and indeed the x86 IO instruction is used to access the legacy VGA IO ports, but that does not mean it has to be done like this.
The first half of this series enhances the bochs video driver to remove the x86 limitation.
The second half of this series enables bochs video as the output console for QEMU RISC-V, to prove that the bochs video driver can indeed work on a non-x86 architecture. To make it actually useful, enable a usb keyboard as well, otherwise we can't just type anything :-)
This series is available at u-boot-x86/bochs for testing.
Bin Meng (17): dm: video: Cosmetic style fix video: bochs: Drop inclusion of <asm/mtrr.h> video: bochs: Drop the useless argument of bochs_vga_write() video: bochs: Avoid using IO instructions to access VGA IO port video: bochs: Remove the x86 dependency video: kconfig: Fix wrong text for the PCI default FB size video: kconfig: Drop the superfluous dependency video: kconfig: Set default FB size for Bochs video: bochs: Set the frame buffer size per configuration riscv: qemu: Enable Bochs video support console: kconfig: Drop the redundant VIDEO dependency console: Make stdio_print_current_devices() static console: Refactor stdio_print_current_devices() a little bit console: Print out complete stdio device list riscv: qemu: Enable PRE_CONSOLE_BUFFER riscv: qemu: Remove out-of-date "riscv,kernel-start" handling riscv: qemu: Enable usb keyboard as an input device
Heinrich Schuchardt (1): riscv: define a cache line size for the generic CPU
arch/riscv/cpu/generic/Kconfig | 1 + board/emulation/qemu-riscv/Kconfig | 13 ++++++++ board/emulation/qemu-riscv/qemu-riscv.c | 27 +++------------ common/Kconfig | 2 +- common/console.c | 44 ++++++++++++++++--------- doc/board/emulation/qemu-riscv.rst | 10 ++++++ drivers/video/Kconfig | 15 +++++---- drivers/video/bochs.c | 12 +++---- drivers/video/bochs.h | 7 ++-- drivers/video/video-uclass.c | 6 ++-- include/configs/qemu-riscv.h | 15 +++------ include/stdio_dev.h | 2 -- 12 files changed, 84 insertions(+), 70 deletions(-)

Some coding convention fixes for video_post_bind().
Signed-off-by: Bin Meng bmeng@tinylab.org ---
drivers/video/video-uclass.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c index 949595f1bc..8f268fc406 100644 --- a/drivers/video/video-uclass.c +++ b/drivers/video/video-uclass.c @@ -626,10 +626,12 @@ static int video_post_bind(struct udevice *dev) addr = uc_priv->video_ptr; size = alloc_fb(dev, &addr); if (addr < gd->video_bottom) { - /* Device tree node may need the 'bootph-all' or + /* + * Device tree node may need the 'bootph-all' or * 'bootph-some-ram' tag */ - printf("Video device '%s' cannot allocate frame buffer memory -ensure the device is set up before relocation\n", + printf("Video device '%s' cannot allocate frame buffer memory " + "- ensure the device is set up before relocation\n", dev->name); return -ENOSPC; }

On Sat, 22 Jul 2023 at 22:41, Bin Meng bmeng@tinylab.org wrote:
Some coding convention fixes for video_post_bind().
Signed-off-by: Bin Meng bmeng@tinylab.org
drivers/video/video-uclass.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org Tested-by: Simon Glass sjg@chromium.org # qemu-x86_64

On Sun, 23 Jul 2023 12:40:24 +0800 Bin Meng bmeng@tinylab.org wrote:
Some coding convention fixes for video_post_bind().
Signed-off-by: Bin Meng bmeng@tinylab.org
drivers/video/video-uclass.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
applied to u-boot-video/master, thanks!
-- Anatolij

The driver does not call any MTRR APIs.
Signed-off-by: Bin Meng bmeng@tinylab.org ---
drivers/video/bochs.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/drivers/video/bochs.c b/drivers/video/bochs.c index 2136b51193..fa0283c158 100644 --- a/drivers/video/bochs.c +++ b/drivers/video/bochs.c @@ -11,7 +11,6 @@ #include <pci.h> #include <video.h> #include <asm/io.h> -#include <asm/mtrr.h> #include <linux/sizes.h> #include "bochs.h"

On Sat, 22 Jul 2023 at 22:41, Bin Meng bmeng@tinylab.org wrote:
The driver does not call any MTRR APIs.
Signed-off-by: Bin Meng bmeng@tinylab.org
drivers/video/bochs.c | 1 - 1 file changed, 1 deletion(-)
Reviewed-by: Simon Glass sjg@chromium.org Tested-by: Simon Glass sjg@chromium.org # qemu-x86_64

On Sun, 23 Jul 2023 12:40:25 +0800 Bin Meng bmeng@tinylab.org wrote:
The driver does not call any MTRR APIs.
Signed-off-by: Bin Meng bmeng@tinylab.org
drivers/video/bochs.c | 1 - 1 file changed, 1 deletion(-)
applied to u-boot-video/master, thanks!
-- Anatolij

bochs_vga_write() takes 'index' as one argument, but never uses it.
While we are here, use macros instead of magic numbers for the VGA IO port register name and value.
Signed-off-by: Bin Meng bmeng@tinylab.org ---
drivers/video/bochs.c | 7 ++++--- drivers/video/bochs.h | 5 ++++- 2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/video/bochs.c b/drivers/video/bochs.c index fa0283c158..2d4526c714 100644 --- a/drivers/video/bochs.c +++ b/drivers/video/bochs.c @@ -27,9 +27,9 @@ static int bochs_read(void *mmio, int index) return readw(mmio + MMIO_BASE + index * 2); }
-static void bochs_vga_write(int index, uint8_t val) +static void bochs_vga_write(uint8_t val) { - outb(val, VGA_INDEX); + outb(val, VGA_ATT_W); }
static int bochs_init_fb(struct udevice *dev) @@ -78,7 +78,8 @@ static int bochs_init_fb(struct udevice *dev) bochs_write(mmio, INDEX_Y_OFFSET, 0); bochs_write(mmio, INDEX_ENABLE, ENABLED | LFB_ENABLED);
- bochs_vga_write(0, 0x20); /* disable blanking */ + /* disable blanking */ + bochs_vga_write(VGA_AR_ENABLE_DISPLAY);
plat->base = fb;
diff --git a/drivers/video/bochs.h b/drivers/video/bochs.h index 4c8ec83a55..71d3d60141 100644 --- a/drivers/video/bochs.h +++ b/drivers/video/bochs.h @@ -6,7 +6,10 @@ #ifndef __BOCHS_H #define __BOCHS_H
-#define VGA_INDEX 0x3c0 +#define VGA_INDEX 0x3c0 + +#define VGA_ATT_W 0x3c0 +#define VGA_AR_ENABLE_DISPLAY 0x20
#define IOPORT_INDEX 0x01ce #define IOPORT_DATA 0x01cf

On Sat, 22 Jul 2023 at 22:41, Bin Meng bmeng@tinylab.org wrote:
bochs_vga_write() takes 'index' as one argument, but never uses it.
While we are here, use macros instead of magic numbers for the VGA IO port register name and value.
Signed-off-by: Bin Meng bmeng@tinylab.org
drivers/video/bochs.c | 7 ++++--- drivers/video/bochs.h | 5 ++++- 2 files changed, 8 insertions(+), 4 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org Tested-by: Simon Glass sjg@chromium.org # qemu-x86_64

On Sun, 23 Jul 2023 12:40:26 +0800 Bin Meng bmeng@tinylab.org wrote:
bochs_vga_write() takes 'index' as one argument, but never uses it.
While we are here, use macros instead of magic numbers for the VGA IO port register name and value.
Signed-off-by: Bin Meng bmeng@tinylab.org
drivers/video/bochs.c | 7 ++++--- drivers/video/bochs.h | 5 ++++- 2 files changed, 8 insertions(+), 4 deletions(-)
applied to u-boot-video/master, thanks!
-- Anatolij

At present the driver uses IO instructions to access the legacy VGA IO ports, which unfortunately limits the driver to work only on x86. It turns out the IO instruction is not necessary as Bochs VGA card remaps the legacy VGA IO ports (0x3c0 -> 0x3df) to its memory mapped register space from offset 0x400.
Update the driver to use MMIO access for VGA IO port.
Signed-off-by: Bin Meng bmeng@tinylab.org ---
drivers/video/bochs.c | 6 +++--- drivers/video/bochs.h | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/video/bochs.c b/drivers/video/bochs.c index 2d4526c714..5923ff81c6 100644 --- a/drivers/video/bochs.c +++ b/drivers/video/bochs.c @@ -27,9 +27,9 @@ static int bochs_read(void *mmio, int index) return readw(mmio + MMIO_BASE + index * 2); }
-static void bochs_vga_write(uint8_t val) +static void bochs_vga_write(void *mmio, int index, uint8_t val) { - outb(val, VGA_ATT_W); + writeb(val, mmio + VGA_BASE + index); }
static int bochs_init_fb(struct udevice *dev) @@ -79,7 +79,7 @@ static int bochs_init_fb(struct udevice *dev) bochs_write(mmio, INDEX_ENABLE, ENABLED | LFB_ENABLED);
/* disable blanking */ - bochs_vga_write(VGA_AR_ENABLE_DISPLAY); + bochs_vga_write(mmio, VGA_ATT_W - VGA_INDEX, VGA_AR_ENABLE_DISPLAY);
plat->base = fb;
diff --git a/drivers/video/bochs.h b/drivers/video/bochs.h index 71d3d60141..3facf690e5 100644 --- a/drivers/video/bochs.h +++ b/drivers/video/bochs.h @@ -11,9 +11,6 @@ #define VGA_ATT_W 0x3c0 #define VGA_AR_ENABLE_DISPLAY 0x20
-#define IOPORT_INDEX 0x01ce -#define IOPORT_DATA 0x01cf - enum { INDEX_ID, INDEX_XRES, @@ -34,6 +31,7 @@ enum { #define LFB_ENABLED BIT(6) #define NOCLEARMEM BIT(7)
+#define VGA_BASE 0x400 #define MMIO_BASE 0x500
#endif

On Sat, 22 Jul 2023 at 22:41, Bin Meng bmeng@tinylab.org wrote:
At present the driver uses IO instructions to access the legacy VGA IO ports, which unfortunately limits the driver to work only on x86. It turns out the IO instruction is not necessary as Bochs VGA card remaps the legacy VGA IO ports (0x3c0 -> 0x3df) to its memory mapped register space from offset 0x400.
Update the driver to use MMIO access for VGA IO port.
Signed-off-by: Bin Meng bmeng@tinylab.org
drivers/video/bochs.c | 6 +++--- drivers/video/bochs.h | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org Tested-by: Simon Glass sjg@chromium.org # qemu-x86_64

On Sun, 23 Jul 2023 12:40:27 +0800 Bin Meng bmeng@tinylab.org wrote:
At present the driver uses IO instructions to access the legacy VGA IO ports, which unfortunately limits the driver to work only on x86. It turns out the IO instruction is not necessary as Bochs VGA card remaps the legacy VGA IO ports (0x3c0 -> 0x3df) to its memory mapped register space from offset 0x400.
Update the driver to use MMIO access for VGA IO port.
Signed-off-by: Bin Meng bmeng@tinylab.org
drivers/video/bochs.c | 6 +++--- drivers/video/bochs.h | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-)
applied to u-boot-video/master, thanks!
-- Anatolij

Now that the driver is legacy free, remove the x86 dependency so that it can be used on non-x86 architectures.
Signed-off-by: Bin Meng bmeng@tinylab.org ---
drivers/video/Kconfig | 1 - 1 file changed, 1 deletion(-)
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index b41dc60cec..3cdaa5ff27 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -280,7 +280,6 @@ config VIDCONSOLE_AS_NAME
config VIDEO_BOCHS bool "Enable Bochs video emulation for QEMU" - depends on X86 help Enable this to use the Bochs video support provided in the QEMU emulator. This appears as a PCI device which U-Boot can set up to

On Sat, 22 Jul 2023 at 22:41, Bin Meng bmeng@tinylab.org wrote:
Now that the driver is legacy free, remove the x86 dependency so that it can be used on non-x86 architectures.
Signed-off-by: Bin Meng bmeng@tinylab.org
drivers/video/Kconfig | 1 - 1 file changed, 1 deletion(-)
Reviewed-by: Simon Glass sjg@chromium.org Tested-by: Simon Glass sjg@chromium.org # qemu-x86_64

On Sun, 23 Jul 2023 12:40:28 +0800 Bin Meng bmeng@tinylab.org wrote:
Now that the driver is legacy free, remove the x86 dependency so that it can be used on non-x86 architectures.
Signed-off-by: Bin Meng bmeng@tinylab.org
drivers/video/Kconfig | 1 - 1 file changed, 1 deletion(-)
applied to u-boot-video/master, thanks!
-- Anatolij

There is an example in the VIDEO_PCI_DEFAULT_FB_SIZE help text to tell people how to calculate its value but the resolution given does not match the value. Fix it.
Signed-off-by: Bin Meng bmeng@tinylab.org ---
drivers/video/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 3cdaa5ff27..43ec7e6695 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -77,7 +77,7 @@ config VIDEO_PCI_DEFAULT_FB_SIZE devices to have a framebuffer allocated by U-Boot.
Note: the framebuffer needs to be large enough to store all pixels at - maximum resolution. For example, at 1920 x 1200 with 32 bits per + maximum resolution. For example, at 2560 x 1600 with 32 bits per pixel, 2560 * 1600 * 32 / 8 = 0xfa0000 bytes are needed.
config VIDEO_COPY @@ -1049,7 +1049,7 @@ config SPL_VIDEO_PCI_DEFAULT_FB_SIZE devices to have a framebuffer allocated by U-Boot.
Note: the framebuffer needs to be large enough to store all pixels at - maximum resolution. For example, at 1920 x 1200 with 32 bits per + maximum resolution. For example, at 2560 x 1600 with 32 bits per pixel, 2560 * 1600 * 32 / 8 = 0xfa0000 bytes are needed.
config SPL_CONSOLE_SCROLL_LINES

On Sat, 22 Jul 2023 at 22:41, Bin Meng bmeng@tinylab.org wrote:
There is an example in the VIDEO_PCI_DEFAULT_FB_SIZE help text to tell people how to calculate its value but the resolution given does not match the value. Fix it.
Signed-off-by: Bin Meng bmeng@tinylab.org
drivers/video/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

On Sun, 23 Jul 2023 12:40:29 +0800 Bin Meng bmeng@tinylab.org wrote:
There is an example in the VIDEO_PCI_DEFAULT_FB_SIZE help text to tell people how to calculate its value but the resolution given does not match the value. Fix it.
Signed-off-by: Bin Meng bmeng@tinylab.org
drivers/video/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
applied to u-boot-video/master, thanks!
-- Anatolij

PCI is always selected by X86 architecture hence "X86 && PCI" does not make it better.
Signed-off-by: Bin Meng bmeng@tinylab.org ---
drivers/video/Kconfig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 43ec7e6695..3f6b7d71b8 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -64,8 +64,8 @@ config BACKLIGHT
config VIDEO_PCI_DEFAULT_FB_SIZE hex "Default framebuffer size to use if no drivers request it" - default 0x1000000 if X86 && PCI - default 0 if !(X86 && PCI) + default 0x1000000 if X86 + default 0 if !X86 help Generally, video drivers request the amount of memory they need for the frame buffer when they are bound, by setting the size field in @@ -1036,8 +1036,8 @@ config SPL_SYS_WHITE_ON_BLACK
config SPL_VIDEO_PCI_DEFAULT_FB_SIZE hex "Default framebuffer size to use if no drivers request it at SPL" - default 0x1000000 if X86 && PCI - default 0 if !(X86 && PCI) + default 0x1000000 if X86 + default 0 if !X86 help Generally, video drivers request the amount of memory they need for the frame buffer when they are bound, by setting the size field in

On Sat, 22 Jul 2023 at 22:41, Bin Meng bmeng@tinylab.org wrote:
PCI is always selected by X86 architecture hence "X86 && PCI" does not make it better.
Signed-off-by: Bin Meng bmeng@tinylab.org
drivers/video/Kconfig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org Tested-by: Simon Glass sjg@chromium.org # qemu-x86_64

On Sun, 23 Jul 2023 12:40:30 +0800 Bin Meng bmeng@tinylab.org wrote:
PCI is always selected by X86 architecture hence "X86 && PCI" does not make it better.
Signed-off-by: Bin Meng bmeng@tinylab.org
drivers/video/Kconfig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
applied to u-boot-video/master, thanks!
-- Anatolij

Set up a default frame buffer size of 8MiB for Bochs for non-x86 architecturs as PCI is normally not enumerated before relocation on these architectures.
Signed-off-by: Bin Meng bmeng@tinylab.org ---
drivers/video/Kconfig | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 3f6b7d71b8..e32ce13fb6 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -65,7 +65,8 @@ config BACKLIGHT config VIDEO_PCI_DEFAULT_FB_SIZE hex "Default framebuffer size to use if no drivers request it" default 0x1000000 if X86 - default 0 if !X86 + default 0x800000 if !X86 && VIDEO_BOCHS + default 0 if !X86 && !VIDEO_BOCHS help Generally, video drivers request the amount of memory they need for the frame buffer when they are bound, by setting the size field in @@ -1037,7 +1038,8 @@ config SPL_SYS_WHITE_ON_BLACK config SPL_VIDEO_PCI_DEFAULT_FB_SIZE hex "Default framebuffer size to use if no drivers request it at SPL" default 0x1000000 if X86 - default 0 if !X86 + default 0x800000 if !X86 && VIDEO_BOCHS + default 0 if !X86 && !VIDEO_BOCHS help Generally, video drivers request the amount of memory they need for the frame buffer when they are bound, by setting the size field in

On Sat, 22 Jul 2023 at 22:41, Bin Meng bmeng@tinylab.org wrote:
Set up a default frame buffer size of 8MiB for Bochs for non-x86 architecturs as PCI is normally not enumerated before relocation on these architectures.
Signed-off-by: Bin Meng bmeng@tinylab.org
drivers/video/Kconfig | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

On Sun, 23 Jul 2023 12:40:31 +0800 Bin Meng bmeng@tinylab.org wrote:
Set up a default frame buffer size of 8MiB for Bochs for non-x86 architecturs as PCI is normally not enumerated before relocation on these architectures.
Signed-off-by: Bin Meng bmeng@tinylab.org
drivers/video/Kconfig | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
applied to u-boot-video/master, thanks!
-- Anatolij

At present the uclass stored frame buffer size is set to a hard coded value, but we can calculate the correct value based on what is configured.
Signed-off-by: Bin Meng bmeng@tinylab.org ---
drivers/video/bochs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/video/bochs.c b/drivers/video/bochs.c index 5923ff81c6..022ea38d4c 100644 --- a/drivers/video/bochs.c +++ b/drivers/video/bochs.c @@ -101,8 +101,8 @@ static int bochs_video_bind(struct udevice *dev) { struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev);
- /* Set the maximum supported resolution */ - uc_plat->size = 2560 * 1600 * 4; + /* Set the frame buffer size per configuration */ + uc_plat->size = xsize * ysize * 32 / 8; log_debug("%s: Frame buffer size %x\n", __func__, uc_plat->size);
return 0;

On Sat, 22 Jul 2023 at 22:41, Bin Meng bmeng@tinylab.org wrote:
At present the uclass stored frame buffer size is set to a hard coded value, but we can calculate the correct value based on what is configured.
Signed-off-by: Bin Meng bmeng@tinylab.org
drivers/video/bochs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org Tested-by: Simon Glass sjg@chromium.org # qemu-x86_64

On Sun, 23 Jul 2023 12:40:32 +0800 Bin Meng bmeng@tinylab.org wrote:
At present the uclass stored frame buffer size is set to a hard coded value, but we can calculate the correct value based on what is configured.
Signed-off-by: Bin Meng bmeng@tinylab.org
drivers/video/bochs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
applied to u-boot-video/master, thanks!
-- Anatolij

Enable video console using the emulated Bochs VGA card.
Signed-off-by: Bin Meng bmeng@tinylab.org ---
board/emulation/qemu-riscv/Kconfig | 3 +++ doc/board/emulation/qemu-riscv.rst | 5 +++++ include/configs/qemu-riscv.h | 5 +++++ 3 files changed, 13 insertions(+)
diff --git a/board/emulation/qemu-riscv/Kconfig b/board/emulation/qemu-riscv/Kconfig index 6114e1b812..976c350e50 100644 --- a/board/emulation/qemu-riscv/Kconfig +++ b/board/emulation/qemu-riscv/Kconfig @@ -68,5 +68,8 @@ config BOARD_SPECIFIC_OPTIONS # dummy imply MTD_NOR_FLASH imply CFI_FLASH imply OF_HAS_PRIOR_STAGE + imply VIDEO + imply VIDEO_BOCHS + imply SYS_WHITE_ON_BLACK
endif diff --git a/doc/board/emulation/qemu-riscv.rst b/doc/board/emulation/qemu-riscv.rst index 509bf7c4a6..9d21f3270c 100644 --- a/doc/board/emulation/qemu-riscv.rst +++ b/doc/board/emulation/qemu-riscv.rst @@ -133,6 +133,11 @@ An attached disk can be emulated in RISC-V virt machine by adding::
You will have to run 'scsi scan' to use it.
+A video console can be emulated in RISC-V virt machine by removing "-nographic" +and adding:: + + -serial stdio -device VGA + Running with KVM ----------------
diff --git a/include/configs/qemu-riscv.h b/include/configs/qemu-riscv.h index f6d326bda0..7ec3d12ce1 100644 --- a/include/configs/qemu-riscv.h +++ b/include/configs/qemu-riscv.h @@ -17,6 +17,10 @@
/* Environment options */
+#define CFG_STD_DEVICES_SETTINGS "stdin=serial\0" \ + "stdout=serial,vidconsole\0" \ + "stderr=serial,vidconsole\0" + #define BOOT_TARGET_DEVICES(func) \ func(QEMU, qemu, na) \ func(VIRTIO, virtio, 0) \ @@ -35,6 +39,7 @@ "qemu "
#define CFG_EXTRA_ENV_SETTINGS \ + CFG_STD_DEVICES_SETTINGS \ "fdt_high=0xffffffffffffffff\0" \ "initrd_high=0xffffffffffffffff\0" \ "kernel_addr_r=0x84000000\0" \

On Sat, 22 Jul 2023 at 22:41, Bin Meng bmeng@tinylab.org wrote:
Enable video console using the emulated Bochs VGA card.
Signed-off-by: Bin Meng bmeng@tinylab.org
board/emulation/qemu-riscv/Kconfig | 3 +++ doc/board/emulation/qemu-riscv.rst | 5 +++++ include/configs/qemu-riscv.h | 5 +++++ 3 files changed, 13 insertions(+)
Reviewed-by: Simon Glass sjg@chromium.org
How about a series to move this over to txt environment?

The VIDEO dependency is described twice in CONSOLE_MUX.
Signed-off-by: Bin Meng bmeng@tinylab.org ---
common/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/common/Kconfig b/common/Kconfig index 973482f075..d103bc6ddb 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -226,7 +226,7 @@ config CONSOLE_FLUSH_SUPPORT
config CONSOLE_MUX bool "Enable console multiplexing" - default y if VIDEO || VIDEO || LCD + default y if VIDEO || LCD help This allows multiple devices to be used for each console 'file'. For example, stdout can be set to go to serial and video.

On 7/23/23 06:40, Bin Meng wrote:
The VIDEO dependency is described twice in CONSOLE_MUX.
Signed-off-by: Bin Meng bmeng@tinylab.org
Reviewed-by: Heinrich Schuchardt xypron.glpk@gmx.de
common/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/common/Kconfig b/common/Kconfig index 973482f075..d103bc6ddb 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -226,7 +226,7 @@ config CONSOLE_FLUSH_SUPPORT
config CONSOLE_MUX bool "Enable console multiplexing"
- default y if VIDEO || VIDEO || LCD
- default y if VIDEO || LCD help This allows multiple devices to be used for each console 'file'. For example, stdout can be set to go to serial and video.

On Sun, 23 Jul 2023 at 00:39, Heinrich Schuchardt xypron.glpk@gmx.de wrote:
On 7/23/23 06:40, Bin Meng wrote:
The VIDEO dependency is described twice in CONSOLE_MUX.
Signed-off-by: Bin Meng bmeng@tinylab.org
Reviewed-by: Heinrich Schuchardt xypron.glpk@gmx.de
common/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Simon Glass sjg@chromium.org

As it is only called in common/console.c
Signed-off-by: Bin Meng bmeng@tinylab.org ---
common/console.c | 2 +- include/stdio_dev.h | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/common/console.c b/common/console.c index 71ad8efd6f..d0640ba05a 100644 --- a/common/console.c +++ b/common/console.c @@ -1010,7 +1010,7 @@ int console_init_f(void) return 0; }
-void stdio_print_current_devices(void) +static void stdio_print_current_devices(void) { /* Print information */ puts("In: "); diff --git a/include/stdio_dev.h b/include/stdio_dev.h index 77bf8a8970..7f18102052 100644 --- a/include/stdio_dev.h +++ b/include/stdio_dev.h @@ -84,8 +84,6 @@ int stdio_init_tables(void); */ int stdio_add_devices(void);
-void stdio_print_current_devices(void); - /** * stdio_deregister_dev() - deregister the device "devname". *

On Sat, 22 Jul 2023 at 22:42, Bin Meng bmeng@tinylab.org wrote:
As it is only called in common/console.c
Signed-off-by: Bin Meng bmeng@tinylab.org
common/console.c | 2 +- include/stdio_dev.h | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org Tested-by: Simon Glass sjg@chromium.org # qemu-x86_64

In preparation to future changes, refactor this routine a little bit.
Signed-off-by: Bin Meng bmeng@tinylab.org ---
common/console.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/common/console.c b/common/console.c index d0640ba05a..af52897ec3 100644 --- a/common/console.c +++ b/common/console.c @@ -1012,27 +1012,27 @@ int console_init_f(void)
static void stdio_print_current_devices(void) { + char *stdinname, *stdoutname, *stderrname; + + stdinname = stdio_devices[stdin] ? + stdio_devices[stdin]->name : + "No input devices available!"; + stdoutname = stdio_devices[stdout] ? + stdio_devices[stdout]->name : + "No output devices available!"; + stderrname = stdio_devices[stderr] ? + stdio_devices[stderr]->name : + "No error devices available!"; + /* Print information */ puts("In: "); - if (stdio_devices[stdin] == NULL) { - puts("No input devices available!\n"); - } else { - printf ("%s\n", stdio_devices[stdin]->name); - } + printf("%s\n", stdinname);
puts("Out: "); - if (stdio_devices[stdout] == NULL) { - puts("No output devices available!\n"); - } else { - printf ("%s\n", stdio_devices[stdout]->name); - } + printf("%s\n", stdoutname);
puts("Err: "); - if (stdio_devices[stderr] == NULL) { - puts("No error devices available!\n"); - } else { - printf ("%s\n", stdio_devices[stderr]->name); - } + printf("%s\n", stderrname); }
#if CONFIG_IS_ENABLED(SYS_CONSOLE_IS_IN_ENV)

On 7/23/23 06:40, Bin Meng wrote:
In preparation to future changes, refactor this routine a little bit.
Signed-off-by: Bin Meng bmeng@tinylab.org
common/console.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/common/console.c b/common/console.c index d0640ba05a..af52897ec3 100644 --- a/common/console.c +++ b/common/console.c @@ -1012,27 +1012,27 @@ int console_init_f(void)
static void stdio_print_current_devices(void) {
- char *stdinname, *stdoutname, *stderrname;
- stdinname = stdio_devices[stdin] ?
stdio_devices[stdin]->name :
"No input devices available!";
- stdoutname = stdio_devices[stdout] ?
stdio_devices[stdout]->name :
"No output devices available!";
This string will never be printed as you have no output device.
Best regards
Heinrich
- stderrname = stdio_devices[stderr] ?
stdio_devices[stderr]->name :
"No error devices available!";
- /* Print information */ puts("In: ");
- if (stdio_devices[stdin] == NULL) {
puts("No input devices available!\n");
- } else {
printf ("%s\n", stdio_devices[stdin]->name);
- }
printf("%s\n", stdinname);
puts("Out: ");
- if (stdio_devices[stdout] == NULL) {
puts("No output devices available!\n");
- } else {
printf ("%s\n", stdio_devices[stdout]->name);
- }
printf("%s\n", stdoutname);
puts("Err: ");
- if (stdio_devices[stderr] == NULL) {
puts("No error devices available!\n");
- } else {
printf ("%s\n", stdio_devices[stderr]->name);
- }
printf("%s\n", stderrname); }
#if CONFIG_IS_ENABLED(SYS_CONSOLE_IS_IN_ENV)

At present if both CONSOLE_MUX and SYS_CONSOLE_IS_IN_ENV are on, during boot, the printed out stdio devices are incomplete, e.g.: with "stdout=serial,vidconsole", only "vidconsole" is printed.
For such case, we can print out the stdio device name from the environment variables.
Signed-off-by: Bin Meng bmeng@tinylab.org ---
common/console.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-)
diff --git a/common/console.c b/common/console.c index af52897ec3..98c3ee6ca6 100644 --- a/common/console.c +++ b/common/console.c @@ -1014,15 +1014,27 @@ static void stdio_print_current_devices(void) { char *stdinname, *stdoutname, *stderrname;
- stdinname = stdio_devices[stdin] ? - stdio_devices[stdin]->name : - "No input devices available!"; - stdoutname = stdio_devices[stdout] ? - stdio_devices[stdout]->name : - "No output devices available!"; - stderrname = stdio_devices[stderr] ? - stdio_devices[stderr]->name : - "No error devices available!"; + if (CONFIG_IS_ENABLED(CONSOLE_MUX) && + CONFIG_IS_ENABLED(SYS_CONSOLE_IS_IN_ENV)) { + /* stdin stdout and stderr are in environment */ + stdinname = env_get("stdin"); + stdoutname = env_get("stdout"); + stderrname = env_get("stderr"); + + stdinname = stdinname ? : "No input devices available!"; + stdoutname = stdoutname ? : "No output devices available!"; + stderrname = stderrname ? : "No error devices available!"; + } else { + stdinname = stdio_devices[stdin] ? + stdio_devices[stdin]->name : + "No input devices available!"; + stdoutname = stdio_devices[stdout] ? + stdio_devices[stdout]->name : + "No output devices available!"; + stderrname = stdio_devices[stderr] ? + stdio_devices[stderr]->name : + "No error devices available!"; + }
/* Print information */ puts("In: ");

On 7/23/23 06:40, Bin Meng wrote:
At present if both CONSOLE_MUX and SYS_CONSOLE_IS_IN_ENV are on, during boot, the printed out stdio devices are incomplete, e.g.: with "stdout=serial,vidconsole", only "vidconsole" is printed.
For such case, we can print out the stdio device name from the environment variables.
Signed-off-by: Bin Meng bmeng@tinylab.org
common/console.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-)
diff --git a/common/console.c b/common/console.c index af52897ec3..98c3ee6ca6 100644 --- a/common/console.c +++ b/common/console.c @@ -1014,15 +1014,27 @@ static void stdio_print_current_devices(void) { char *stdinname, *stdoutname, *stderrname;
- stdinname = stdio_devices[stdin] ?
stdio_devices[stdin]->name :
"No input devices available!";
- stdoutname = stdio_devices[stdout] ?
stdio_devices[stdout]->name :
"No output devices available!";
- stderrname = stdio_devices[stderr] ?
stdio_devices[stderr]->name :
"No error devices available!";
- if (CONFIG_IS_ENABLED(CONSOLE_MUX) &&
CONFIG_IS_ENABLED(SYS_CONSOLE_IS_IN_ENV)) {
/* stdin stdout and stderr are in environment */
stdinname = env_get("stdin");
stdoutname = env_get("stdout");
stderrname = env_get("stderr");
stdinname = stdinname ? : "No input devices available!";
stdoutname = stdoutname ? : "No output devices available!";
This string will never be printed as you have no output device.
stderrname = stderrname ? : "No error devices available!";
- } else {
stdinname = stdio_devices[stdin] ?
stdio_devices[stdin]->name :
"No input devices available!";
stdoutname = stdio_devices[stdout] ?
stdio_devices[stdout]->name :
"No output devices available!";
ditto
stderrname = stdio_devices[stderr] ?
stdio_devices[stderr]->name :
"No error devices available!";
- }
do_coninfo() shows how to print all muxed devices irrespective of SYS_CONSOLE_IS_IN_ENV.
Best regards
Heinrich
/* Print information */ puts("In: ");

Hi Heinrich,
On Sun, Jul 23, 2023 at 2:38 PM Heinrich Schuchardt xypron.glpk@gmx.de wrote:
On 7/23/23 06:40, Bin Meng wrote:
At present if both CONSOLE_MUX and SYS_CONSOLE_IS_IN_ENV are on, during boot, the printed out stdio devices are incomplete, e.g.: with "stdout=serial,vidconsole", only "vidconsole" is printed.
For such case, we can print out the stdio device name from the environment variables.
Signed-off-by: Bin Meng bmeng@tinylab.org
common/console.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-)
diff --git a/common/console.c b/common/console.c index af52897ec3..98c3ee6ca6 100644 --- a/common/console.c +++ b/common/console.c @@ -1014,15 +1014,27 @@ static void stdio_print_current_devices(void) { char *stdinname, *stdoutname, *stderrname;
stdinname = stdio_devices[stdin] ?
stdio_devices[stdin]->name :
"No input devices available!";
stdoutname = stdio_devices[stdout] ?
stdio_devices[stdout]->name :
"No output devices available!";
stderrname = stdio_devices[stderr] ?
stdio_devices[stderr]->name :
"No error devices available!";
if (CONFIG_IS_ENABLED(CONSOLE_MUX) &&
CONFIG_IS_ENABLED(SYS_CONSOLE_IS_IN_ENV)) {
/* stdin stdout and stderr are in environment */
stdinname = env_get("stdin");
stdoutname = env_get("stdout");
stderrname = env_get("stderr");
stdinname = stdinname ? : "No input devices available!";
stdoutname = stdoutname ? : "No output devices available!";
This string will never be printed as you have no output device.
This logic follows what it was before. Yes, without a stdout device, puts() or printf() is useless.
stderrname = stderrname ? : "No error devices available!";
} else {
stdinname = stdio_devices[stdin] ?
stdio_devices[stdin]->name :
"No input devices available!";
stdoutname = stdio_devices[stdout] ?
stdio_devices[stdout]->name :
"No output devices available!";
ditto
stderrname = stdio_devices[stderr] ?
stdio_devices[stderr]->name :
"No error devices available!";
}
do_coninfo() shows how to print all muxed devices irrespective of SYS_CONSOLE_IS_IN_ENV.
Are you suggesting we refactor the codes to follow the same logic used in do_coninfo()?
Regards, Bin

Am 23. Juli 2023 14:04:39 MESZ schrieb Bin Meng bmeng.cn@gmail.com:
Hi Heinrich,
On Sun, Jul 23, 2023 at 2:38 PM Heinrich Schuchardt xypron.glpk@gmx.de wrote:
On 7/23/23 06:40, Bin Meng wrote:
At present if both CONSOLE_MUX and SYS_CONSOLE_IS_IN_ENV are on, during boot, the printed out stdio devices are incomplete, e.g.: with "stdout=serial,vidconsole", only "vidconsole" is printed.
For such case, we can print out the stdio device name from the environment variables.
Signed-off-by: Bin Meng bmeng@tinylab.org
common/console.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-)
diff --git a/common/console.c b/common/console.c index af52897ec3..98c3ee6ca6 100644 --- a/common/console.c +++ b/common/console.c @@ -1014,15 +1014,27 @@ static void stdio_print_current_devices(void) { char *stdinname, *stdoutname, *stderrname;
stdinname = stdio_devices[stdin] ?
stdio_devices[stdin]->name :
"No input devices available!";
stdoutname = stdio_devices[stdout] ?
stdio_devices[stdout]->name :
"No output devices available!";
stderrname = stdio_devices[stderr] ?
stdio_devices[stderr]->name :
"No error devices available!";
if (CONFIG_IS_ENABLED(CONSOLE_MUX) &&
CONFIG_IS_ENABLED(SYS_CONSOLE_IS_IN_ENV)) {
/* stdin stdout and stderr are in environment */
stdinname = env_get("stdin");
stdoutname = env_get("stdout");
stderrname = env_get("stderr");
stdinname = stdinname ? : "No input devices available!";
stdoutname = stdoutname ? : "No output devices available!";
This string will never be printed as you have no output device.
This logic follows what it was before. Yes, without a stdout device, puts() or printf() is useless.
stderrname = stderrname ? : "No error devices available!";
} else {
stdinname = stdio_devices[stdin] ?
stdio_devices[stdin]->name :
"No input devices available!";
stdoutname = stdio_devices[stdout] ?
stdio_devices[stdout]->name :
"No output devices available!";
ditto
stderrname = stdio_devices[stderr] ?
stdio_devices[stderr]->name :
"No error devices available!";
}
do_coninfo() shows how to print all muxed devices irrespective of SYS_CONSOLE_IS_IN_ENV.
Are you suggesting we refactor the codes to follow the same logic used in do_coninfo()?
As the coninfo command is enabled on most devices, we could use a common output function to reduce code size.
Do we need this output at all if we hsve coninfo?
Regards
Heinrich
Regards, Bin

Hi Heinrich,
On Sun, Jul 23, 2023 at 8:48 PM Heinrich Schuchardt xypron.glpk@gmx.de wrote:
Am 23. Juli 2023 14:04:39 MESZ schrieb Bin Meng bmeng.cn@gmail.com:
Hi Heinrich,
On Sun, Jul 23, 2023 at 2:38 PM Heinrich Schuchardt xypron.glpk@gmx.de wrote:
On 7/23/23 06:40, Bin Meng wrote:
At present if both CONSOLE_MUX and SYS_CONSOLE_IS_IN_ENV are on, during boot, the printed out stdio devices are incomplete, e.g.: with "stdout=serial,vidconsole", only "vidconsole" is printed.
For such case, we can print out the stdio device name from the environment variables.
Signed-off-by: Bin Meng bmeng@tinylab.org
common/console.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-)
diff --git a/common/console.c b/common/console.c index af52897ec3..98c3ee6ca6 100644 --- a/common/console.c +++ b/common/console.c @@ -1014,15 +1014,27 @@ static void stdio_print_current_devices(void) { char *stdinname, *stdoutname, *stderrname;
stdinname = stdio_devices[stdin] ?
stdio_devices[stdin]->name :
"No input devices available!";
stdoutname = stdio_devices[stdout] ?
stdio_devices[stdout]->name :
"No output devices available!";
stderrname = stdio_devices[stderr] ?
stdio_devices[stderr]->name :
"No error devices available!";
if (CONFIG_IS_ENABLED(CONSOLE_MUX) &&
CONFIG_IS_ENABLED(SYS_CONSOLE_IS_IN_ENV)) {
/* stdin stdout and stderr are in environment */
stdinname = env_get("stdin");
stdoutname = env_get("stdout");
stderrname = env_get("stderr");
stdinname = stdinname ? : "No input devices available!";
stdoutname = stdoutname ? : "No output devices available!";
This string will never be printed as you have no output device.
This logic follows what it was before. Yes, without a stdout device, puts() or printf() is useless.
stderrname = stderrname ? : "No error devices available!";
} else {
stdinname = stdio_devices[stdin] ?
stdio_devices[stdin]->name :
"No input devices available!";
stdoutname = stdio_devices[stdout] ?
stdio_devices[stdout]->name :
"No output devices available!";
ditto
stderrname = stdio_devices[stderr] ?
stdio_devices[stderr]->name :
"No error devices available!";
}
do_coninfo() shows how to print all muxed devices irrespective of SYS_CONSOLE_IS_IN_ENV.
Are you suggesting we refactor the codes to follow the same logic used in do_coninfo()?
As the coninfo command is enabled on most devices, we could use a common output function to reduce code size.
Do we need this output at all if we hsve coninfo?
I think so. U-Boot has been displaying the stdio devices for quite a long time. The config option SYS_CONSOLE_INFO_QUIET was introduced for any board who does not want this.
config SYS_CONSOLE_INFO_QUIET bool "Don't display the console devices on boot" help Normally U-Boot displays the current settings for stdout, stdin and stderr on boot when the post-relocation console is set up. Enable this option to suppress this output. It can be obtained by calling stdio_print_current_devices() from board code.
Tom, what's your idea?
Regards, Bin

On Sun, 23 Jul 2023 at 08:17, Bin Meng bmeng.cn@gmail.com wrote:
Hi Heinrich,
On Sun, Jul 23, 2023 at 8:48 PM Heinrich Schuchardt xypron.glpk@gmx.de wrote:
Am 23. Juli 2023 14:04:39 MESZ schrieb Bin Meng bmeng.cn@gmail.com:
Hi Heinrich,
On Sun, Jul 23, 2023 at 2:38 PM Heinrich Schuchardt xypron.glpk@gmx.de wrote:
On 7/23/23 06:40, Bin Meng wrote:
At present if both CONSOLE_MUX and SYS_CONSOLE_IS_IN_ENV are on, during boot, the printed out stdio devices are incomplete, e.g.: with "stdout=serial,vidconsole", only "vidconsole" is printed.
For such case, we can print out the stdio device name from the environment variables.
Signed-off-by: Bin Meng bmeng@tinylab.org
common/console.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-)
diff --git a/common/console.c b/common/console.c index af52897ec3..98c3ee6ca6 100644 --- a/common/console.c +++ b/common/console.c @@ -1014,15 +1014,27 @@ static void stdio_print_current_devices(void) { char *stdinname, *stdoutname, *stderrname;
stdinname = stdio_devices[stdin] ?
stdio_devices[stdin]->name :
"No input devices available!";
stdoutname = stdio_devices[stdout] ?
stdio_devices[stdout]->name :
"No output devices available!";
stderrname = stdio_devices[stderr] ?
stdio_devices[stderr]->name :
"No error devices available!";
if (CONFIG_IS_ENABLED(CONSOLE_MUX) &&
CONFIG_IS_ENABLED(SYS_CONSOLE_IS_IN_ENV)) {
/* stdin stdout and stderr are in environment */
stdinname = env_get("stdin");
stdoutname = env_get("stdout");
stderrname = env_get("stderr");
stdinname = stdinname ? : "No input devices available!";
stdoutname = stdoutname ? : "No output devices available!";
This string will never be printed as you have no output device.
This logic follows what it was before. Yes, without a stdout device, puts() or printf() is useless.
stderrname = stderrname ? : "No error devices available!";
} else {
stdinname = stdio_devices[stdin] ?
stdio_devices[stdin]->name :
"No input devices available!";
stdoutname = stdio_devices[stdout] ?
stdio_devices[stdout]->name :
"No output devices available!";
ditto
stderrname = stdio_devices[stderr] ?
stdio_devices[stderr]->name :
"No error devices available!";
}
do_coninfo() shows how to print all muxed devices irrespective of SYS_CONSOLE_IS_IN_ENV.
Are you suggesting we refactor the codes to follow the same logic used in do_coninfo()?
As the coninfo command is enabled on most devices, we could use a common output function to reduce code size.
Do we need this output at all if we hsve coninfo?
I think so. U-Boot has been displaying the stdio devices for quite a long time. The config option SYS_CONSOLE_INFO_QUIET was introduced for any board who does not want this.
config SYS_CONSOLE_INFO_QUIET bool "Don't display the console devices on boot" help Normally U-Boot displays the current settings for stdout, stdin and stderr on boot when the post-relocation console is set up. Enable this option to suppress this output. It can be obtained by calling stdio_print_current_devices() from board code.
Tom, what's your idea?
I agree that we should show it, since otherwise it is misleading.
Reviewed-by: Simon Glass sjg@chromium.org

On Sun, Jul 23, 2023 at 12:40:37PM +0800, Bin Meng wrote:
At present if both CONSOLE_MUX and SYS_CONSOLE_IS_IN_ENV are on, during boot, the printed out stdio devices are incomplete, e.g.: with "stdout=serial,vidconsole", only "vidconsole" is printed.
For such case, we can print out the stdio device name from the environment variables.
Signed-off-by: Bin Meng bmeng@tinylab.org
This approach makes sense to me.
Reviewed-by: Tom Rini trini@konsulko.com

By default the video console only outputs messages after it's ready. Messages before that won't show on the video console, but U-Boot has an option to buffer the console messages before it's ready.
Enable this support, and carefully select an address for the buffer.
Signed-off-by: Bin Meng bmeng@tinylab.org ---
board/emulation/qemu-riscv/Kconfig | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/board/emulation/qemu-riscv/Kconfig b/board/emulation/qemu-riscv/Kconfig index 976c350e50..7220c55350 100644 --- a/board/emulation/qemu-riscv/Kconfig +++ b/board/emulation/qemu-riscv/Kconfig @@ -25,6 +25,10 @@ config SPL_OPENSBI_LOAD_ADDR hex default 0x80100000
+config PRE_CON_BUF_ADDR + hex + default 0x81000000 + config BOARD_SPECIFIC_OPTIONS # dummy def_bool y select GENERIC_RISCV @@ -71,5 +75,6 @@ config BOARD_SPECIFIC_OPTIONS # dummy imply VIDEO imply VIDEO_BOCHS imply SYS_WHITE_ON_BLACK + imply PRE_CONSOLE_BUFFER
endif

From: Heinrich Schuchardt heinrich.schuchardt@canonical.com
The USB 3.0 driver xhci-mem.c requires CONFIG_SYS_CACHELINE_SIZE to be set.
Define the cache line size for QEMU on RISC-V to be 64 bytes.
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com Reviewed-by: Bin Meng bmeng@tinylab.org Signed-off-by: Bin Meng bmeng@tinylab.org ---
arch/riscv/cpu/generic/Kconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/arch/riscv/cpu/generic/Kconfig b/arch/riscv/cpu/generic/Kconfig index 897765c3c6..2baba22992 100644 --- a/arch/riscv/cpu/generic/Kconfig +++ b/arch/riscv/cpu/generic/Kconfig @@ -6,6 +6,7 @@ config GENERIC_RISCV bool select BINMAN if SPL select ARCH_EARLY_INIT_R + select SYS_CACHE_SHIFT_6 imply CPU imply CPU_RISCV imply RISCV_TIMER if (RISCV_SMODE || SPL_RISCV_SMODE)

Commit 66ffe57 ("riscv: qemu: detect and boot the kernel passed by QEMU") added some logic to handle "riscv,kernel-start" in DT and stored the address to an environment variable kernel_start.
However this "riscv,kernel-start" has never been an upstream DT binding. The upstream QEMU never generates such a DT either. Presumably U-Boot development was based on a downstream QEMU fork.
Now we drop all codes in commit 66ffe57, except that BOARD_LATE_INIT is kept for later use.
Signed-off-by: Bin Meng bmeng@tinylab.org ---
board/emulation/qemu-riscv/qemu-riscv.c | 24 ------------------------ include/configs/qemu-riscv.h | 10 ---------- 2 files changed, 34 deletions(-)
diff --git a/board/emulation/qemu-riscv/qemu-riscv.c b/board/emulation/qemu-riscv/qemu-riscv.c index ae3b7a3295..f39f3be366 100644 --- a/board/emulation/qemu-riscv/qemu-riscv.c +++ b/board/emulation/qemu-riscv/qemu-riscv.c @@ -41,30 +41,6 @@ int board_init(void)
int board_late_init(void) { - ulong kernel_start; - ofnode chosen_node; - int ret; - - chosen_node = ofnode_path("/chosen"); - if (!ofnode_valid(chosen_node)) { - debug("No chosen node found, can't get kernel start address\n"); - return 0; - } - -#ifdef CONFIG_ARCH_RV64I - ret = ofnode_read_u64(chosen_node, "riscv,kernel-start", - (u64 *)&kernel_start); -#else - ret = ofnode_read_u32(chosen_node, "riscv,kernel-start", - (u32 *)&kernel_start); -#endif - if (ret) { - debug("Can't find kernel start address in device tree\n"); - return 0; - } - - env_set_hex("kernel_start", kernel_start); - return 0; }
diff --git a/include/configs/qemu-riscv.h b/include/configs/qemu-riscv.h index 7ec3d12ce1..d5146e70f7 100644 --- a/include/configs/qemu-riscv.h +++ b/include/configs/qemu-riscv.h @@ -22,22 +22,12 @@ "stderr=serial,vidconsole\0"
#define BOOT_TARGET_DEVICES(func) \ - func(QEMU, qemu, na) \ func(VIRTIO, virtio, 0) \ func(SCSI, scsi, 0) \ func(DHCP, dhcp, na)
#include <config_distro_bootcmd.h>
-#define BOOTENV_DEV_QEMU(devtypeu, devtypel, instance) \ - "bootcmd_qemu=" \ - "if env exists kernel_start; then " \ - "bootm ${kernel_start} - ${fdtcontroladdr};" \ - "fi;\0" - -#define BOOTENV_DEV_NAME_QEMU(devtypeu, devtypel, instance) \ - "qemu " - #define CFG_EXTRA_ENV_SETTINGS \ CFG_STD_DEVICES_SETTINGS \ "fdt_high=0xffffffffffffffff\0" \

This brings PCI xHCI support to QEMU RISC-V and uses a usb keyboard as one of the input devices.
Signed-off-by: Bin Meng bmeng@tinylab.org
---
board/emulation/qemu-riscv/Kconfig | 5 +++++ board/emulation/qemu-riscv/qemu-riscv.c | 5 +++++ doc/board/emulation/qemu-riscv.rst | 5 +++++ include/configs/qemu-riscv.h | 2 +- 4 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/board/emulation/qemu-riscv/Kconfig b/board/emulation/qemu-riscv/Kconfig index 7220c55350..b503578d27 100644 --- a/board/emulation/qemu-riscv/Kconfig +++ b/board/emulation/qemu-riscv/Kconfig @@ -76,5 +76,10 @@ config BOARD_SPECIFIC_OPTIONS # dummy imply VIDEO_BOCHS imply SYS_WHITE_ON_BLACK imply PRE_CONSOLE_BUFFER + imply USB + imply USB_XHCI_HCD + imply USB_XHCI_PCI + imply USB_KEYBOARD + imply CMD_USB
endif diff --git a/board/emulation/qemu-riscv/qemu-riscv.c b/board/emulation/qemu-riscv/qemu-riscv.c index f39f3be366..181abbbf97 100644 --- a/board/emulation/qemu-riscv/qemu-riscv.c +++ b/board/emulation/qemu-riscv/qemu-riscv.c @@ -12,6 +12,7 @@ #include <log.h> #include <spl.h> #include <init.h> +#include <usb.h> #include <virtio_types.h> #include <virtio.h>
@@ -41,6 +42,10 @@ int board_init(void)
int board_late_init(void) { + /* start usb so that usb keyboard can be used as input device */ + if (CONFIG_IS_ENABLED(USB_KEYBOARD)) + usb_init(); + return 0; }
diff --git a/doc/board/emulation/qemu-riscv.rst b/doc/board/emulation/qemu-riscv.rst index 9d21f3270c..61137bcbf1 100644 --- a/doc/board/emulation/qemu-riscv.rst +++ b/doc/board/emulation/qemu-riscv.rst @@ -138,6 +138,11 @@ and adding::
-serial stdio -device VGA
+In addition, a usb keyboard can be attached to an emulated xHCI controller in +RISC-V virt machine as an option of input devices by adding:: + + -device qemu-xhci,id=xhci -device usb-kbd,bus=xhci.0 + Running with KVM ----------------
diff --git a/include/configs/qemu-riscv.h b/include/configs/qemu-riscv.h index d5146e70f7..584559cfa3 100644 --- a/include/configs/qemu-riscv.h +++ b/include/configs/qemu-riscv.h @@ -17,7 +17,7 @@
/* Environment options */
-#define CFG_STD_DEVICES_SETTINGS "stdin=serial\0" \ +#define CFG_STD_DEVICES_SETTINGS "stdin=serial,usbkbd\0" \ "stdout=serial,vidconsole\0" \ "stderr=serial,vidconsole\0"

Am 23. Juli 2023 06:40:41 MESZ schrieb Bin Meng bmeng@tinylab.org:
This brings PCI xHCI support to QEMU RISC-V and uses a usb keyboard as one of the input devices.
Signed-off-by: Bin Meng bmeng@tinylab.org
board/emulation/qemu-riscv/Kconfig | 5 +++++ board/emulation/qemu-riscv/qemu-riscv.c | 5 +++++ doc/board/emulation/qemu-riscv.rst | 5 +++++ include/configs/qemu-riscv.h | 2 +- 4 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/board/emulation/qemu-riscv/Kconfig b/board/emulation/qemu-riscv/Kconfig index 7220c55350..b503578d27 100644 --- a/board/emulation/qemu-riscv/Kconfig +++ b/board/emulation/qemu-riscv/Kconfig @@ -76,5 +76,10 @@ config BOARD_SPECIFIC_OPTIONS # dummy imply VIDEO_BOCHS imply SYS_WHITE_ON_BLACK imply PRE_CONSOLE_BUFFER
- imply USB
- imply USB_XHCI_HCD
- imply USB_XHCI_PCI
QEMU could alternatively use EHCI or OHCI for the keyboard. Does enabling XHCI add support for these too?
Best regards
Heinrich
- imply USB_KEYBOARD
- imply CMD_USB
endif diff --git a/board/emulation/qemu-riscv/qemu-riscv.c b/board/emulation/qemu-riscv/qemu-riscv.c index f39f3be366..181abbbf97 100644 --- a/board/emulation/qemu-riscv/qemu-riscv.c +++ b/board/emulation/qemu-riscv/qemu-riscv.c @@ -12,6 +12,7 @@ #include <log.h> #include <spl.h> #include <init.h> +#include <usb.h> #include <virtio_types.h> #include <virtio.h>
@@ -41,6 +42,10 @@ int board_init(void)
int board_late_init(void) {
- /* start usb so that usb keyboard can be used as input device */
- if (CONFIG_IS_ENABLED(USB_KEYBOARD))
usb_init();
- return 0;
}
diff --git a/doc/board/emulation/qemu-riscv.rst b/doc/board/emulation/qemu-riscv.rst index 9d21f3270c..61137bcbf1 100644 --- a/doc/board/emulation/qemu-riscv.rst +++ b/doc/board/emulation/qemu-riscv.rst @@ -138,6 +138,11 @@ and adding::
-serial stdio -device VGA
+In addition, a usb keyboard can be attached to an emulated xHCI controller in +RISC-V virt machine as an option of input devices by adding::
- -device qemu-xhci,id=xhci -device usb-kbd,bus=xhci.0
Running with KVM
diff --git a/include/configs/qemu-riscv.h b/include/configs/qemu-riscv.h index d5146e70f7..584559cfa3 100644 --- a/include/configs/qemu-riscv.h +++ b/include/configs/qemu-riscv.h @@ -17,7 +17,7 @@
/* Environment options */
-#define CFG_STD_DEVICES_SETTINGS "stdin=serial\0" \ +#define CFG_STD_DEVICES_SETTINGS "stdin=serial,usbkbd\0" \ "stdout=serial,vidconsole\0" \ "stderr=serial,vidconsole\0"

Hi Heinrich,
On Sun, Jul 23, 2023 at 2:11 PM Heinrich Schuchardt xypron.glpk@gmx.de wrote:
Am 23. Juli 2023 06:40:41 MESZ schrieb Bin Meng bmeng@tinylab.org:
This brings PCI xHCI support to QEMU RISC-V and uses a usb keyboard as one of the input devices.
Signed-off-by: Bin Meng bmeng@tinylab.org
board/emulation/qemu-riscv/Kconfig | 5 +++++ board/emulation/qemu-riscv/qemu-riscv.c | 5 +++++ doc/board/emulation/qemu-riscv.rst | 5 +++++ include/configs/qemu-riscv.h | 2 +- 4 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/board/emulation/qemu-riscv/Kconfig b/board/emulation/qemu-riscv/Kconfig index 7220c55350..b503578d27 100644 --- a/board/emulation/qemu-riscv/Kconfig +++ b/board/emulation/qemu-riscv/Kconfig @@ -76,5 +76,10 @@ config BOARD_SPECIFIC_OPTIONS # dummy imply VIDEO_BOCHS imply SYS_WHITE_ON_BLACK imply PRE_CONSOLE_BUFFER
imply USB
imply USB_XHCI_HCD
imply USB_XHCI_PCI
QEMU could alternatively use EHCI or OHCI for the keyboard. Does enabling XHCI add support for these too?
No, EHCI or OHCI support is separate from xHCI. I don't think enabling EHCI or OHCI *by default* brings a lot of value here as xHCI is the latest and greatest and USB keyboard could work with xHCI without any problem.
Regards, Bin

From: Bin Meng bmeng@tinylab.org Date: Sun, 23 Jul 2023 12:40:41 +0800
This brings PCI xHCI support to QEMU RISC-V and uses a usb keyboard as one of the input devices.
Signed-off-by: Bin Meng bmeng@tinylab.org
board/emulation/qemu-riscv/Kconfig | 5 +++++ board/emulation/qemu-riscv/qemu-riscv.c | 5 +++++ doc/board/emulation/qemu-riscv.rst | 5 +++++ include/configs/qemu-riscv.h | 2 +- 4 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/board/emulation/qemu-riscv/Kconfig b/board/emulation/qemu-riscv/Kconfig index 7220c55350..b503578d27 100644 --- a/board/emulation/qemu-riscv/Kconfig +++ b/board/emulation/qemu-riscv/Kconfig @@ -76,5 +76,10 @@ config BOARD_SPECIFIC_OPTIONS # dummy imply VIDEO_BOCHS imply SYS_WHITE_ON_BLACK imply PRE_CONSOLE_BUFFER
- imply USB
- imply USB_XHCI_HCD
- imply USB_XHCI_PCI
- imply USB_KEYBOARD
- imply CMD_USB
endif diff --git a/board/emulation/qemu-riscv/qemu-riscv.c b/board/emulation/qemu-riscv/qemu-riscv.c index f39f3be366..181abbbf97 100644 --- a/board/emulation/qemu-riscv/qemu-riscv.c +++ b/board/emulation/qemu-riscv/qemu-riscv.c @@ -12,6 +12,7 @@ #include <log.h> #include <spl.h> #include <init.h> +#include <usb.h> #include <virtio_types.h> #include <virtio.h>
@@ -41,6 +42,10 @@ int board_init(void)
int board_late_init(void) {
- /* start usb so that usb keyboard can be used as input device */
- if (CONFIG_IS_ENABLED(USB_KEYBOARD))
usb_init();
This is typically handled by including "usb start" in CONFIG_PREBOOT, which is done by boot/Kconfig. Any reason why that doesn't work for you?
return 0; }
diff --git a/doc/board/emulation/qemu-riscv.rst b/doc/board/emulation/qemu-riscv.rst index 9d21f3270c..61137bcbf1 100644 --- a/doc/board/emulation/qemu-riscv.rst +++ b/doc/board/emulation/qemu-riscv.rst @@ -138,6 +138,11 @@ and adding::
-serial stdio -device VGA
+In addition, a usb keyboard can be attached to an emulated xHCI controller in +RISC-V virt machine as an option of input devices by adding::
- -device qemu-xhci,id=xhci -device usb-kbd,bus=xhci.0
Running with KVM
diff --git a/include/configs/qemu-riscv.h b/include/configs/qemu-riscv.h index d5146e70f7..584559cfa3 100644 --- a/include/configs/qemu-riscv.h +++ b/include/configs/qemu-riscv.h @@ -17,7 +17,7 @@
/* Environment options */
-#define CFG_STD_DEVICES_SETTINGS "stdin=serial\0" \ +#define CFG_STD_DEVICES_SETTINGS "stdin=serial,usbkbd\0" \ "stdout=serial,vidconsole\0" \ "stderr=serial,vidconsole\0"
-- 2.34.1

Am 23. Juli 2023 10:38:00 MESZ schrieb Mark Kettenis mark.kettenis@xs4all.nl:
From: Bin Meng bmeng@tinylab.org Date: Sun, 23 Jul 2023 12:40:41 +0800
This brings PCI xHCI support to QEMU RISC-V and uses a usb keyboard as one of the input devices.
Signed-off-by: Bin Meng bmeng@tinylab.org
board/emulation/qemu-riscv/Kconfig | 5 +++++ board/emulation/qemu-riscv/qemu-riscv.c | 5 +++++ doc/board/emulation/qemu-riscv.rst | 5 +++++ include/configs/qemu-riscv.h | 2 +- 4 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/board/emulation/qemu-riscv/Kconfig b/board/emulation/qemu-riscv/Kconfig index 7220c55350..b503578d27 100644 --- a/board/emulation/qemu-riscv/Kconfig +++ b/board/emulation/qemu-riscv/Kconfig @@ -76,5 +76,10 @@ config BOARD_SPECIFIC_OPTIONS # dummy imply VIDEO_BOCHS imply SYS_WHITE_ON_BLACK imply PRE_CONSOLE_BUFFER
- imply USB
- imply USB_XHCI_HCD
- imply USB_XHCI_PCI
- imply USB_KEYBOARD
- imply CMD_USB
endif diff --git a/board/emulation/qemu-riscv/qemu-riscv.c b/board/emulation/qemu-riscv/qemu-riscv.c index f39f3be366..181abbbf97 100644 --- a/board/emulation/qemu-riscv/qemu-riscv.c +++ b/board/emulation/qemu-riscv/qemu-riscv.c @@ -12,6 +12,7 @@ #include <log.h> #include <spl.h> #include <init.h> +#include <usb.h> #include <virtio_types.h> #include <virtio.h>
@@ -41,6 +42,10 @@ int board_init(void)
int board_late_init(void) {
- /* start usb so that usb keyboard can be used as input device */
- if (CONFIG_IS_ENABLED(USB_KEYBOARD))
usb_init();
This is typically handled by including "usb start" in CONFIG_PREBOOT, which is done by boot/Kconfig. Any reason why that doesn't work for you?
We run pci_init() in board_r.c. Why don't do the same for USB instead of the PREBOOT quirk?
Regards
Heinrich
return 0; }
diff --git a/doc/board/emulation/qemu-riscv.rst b/doc/board/emulation/qemu-riscv.rst index 9d21f3270c..61137bcbf1 100644 --- a/doc/board/emulation/qemu-riscv.rst +++ b/doc/board/emulation/qemu-riscv.rst @@ -138,6 +138,11 @@ and adding::
-serial stdio -device VGA
+In addition, a usb keyboard can be attached to an emulated xHCI controller in +RISC-V virt machine as an option of input devices by adding::
- -device qemu-xhci,id=xhci -device usb-kbd,bus=xhci.0
Running with KVM
diff --git a/include/configs/qemu-riscv.h b/include/configs/qemu-riscv.h index d5146e70f7..584559cfa3 100644 --- a/include/configs/qemu-riscv.h +++ b/include/configs/qemu-riscv.h @@ -17,7 +17,7 @@
/* Environment options */
-#define CFG_STD_DEVICES_SETTINGS "stdin=serial\0" \ +#define CFG_STD_DEVICES_SETTINGS "stdin=serial,usbkbd\0" \ "stdout=serial,vidconsole\0" \ "stderr=serial,vidconsole\0"
-- 2.34.1

Date: Sun, 23 Jul 2023 11:30:31 +0200 From: Heinrich Schuchardt xypron.glpk@gmx.de
Am 23. Juli 2023 10:38:00 MESZ schrieb Mark Kettenis mark.kettenis@xs4all.nl:
From: Bin Meng bmeng@tinylab.org Date: Sun, 23 Jul 2023 12:40:41 +0800
This brings PCI xHCI support to QEMU RISC-V and uses a usb keyboard as one of the input devices.
Signed-off-by: Bin Meng bmeng@tinylab.org
board/emulation/qemu-riscv/Kconfig | 5 +++++ board/emulation/qemu-riscv/qemu-riscv.c | 5 +++++ doc/board/emulation/qemu-riscv.rst | 5 +++++ include/configs/qemu-riscv.h | 2 +- 4 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/board/emulation/qemu-riscv/Kconfig b/board/emulation/qemu-riscv/Kconfig index 7220c55350..b503578d27 100644 --- a/board/emulation/qemu-riscv/Kconfig +++ b/board/emulation/qemu-riscv/Kconfig @@ -76,5 +76,10 @@ config BOARD_SPECIFIC_OPTIONS # dummy imply VIDEO_BOCHS imply SYS_WHITE_ON_BLACK imply PRE_CONSOLE_BUFFER
- imply USB
- imply USB_XHCI_HCD
- imply USB_XHCI_PCI
- imply USB_KEYBOARD
- imply CMD_USB
endif diff --git a/board/emulation/qemu-riscv/qemu-riscv.c b/board/emulation/qemu-riscv/qemu-riscv.c index f39f3be366..181abbbf97 100644 --- a/board/emulation/qemu-riscv/qemu-riscv.c +++ b/board/emulation/qemu-riscv/qemu-riscv.c @@ -12,6 +12,7 @@ #include <log.h> #include <spl.h> #include <init.h> +#include <usb.h> #include <virtio_types.h> #include <virtio.h>
@@ -41,6 +42,10 @@ int board_init(void)
int board_late_init(void) {
- /* start usb so that usb keyboard can be used as input device */
- if (CONFIG_IS_ENABLED(USB_KEYBOARD))
usb_init();
This is typically handled by including "usb start" in CONFIG_PREBOOT, which is done by boot/Kconfig. Any reason why that doesn't work for you?
We run pci_init() in board_r.c. Why don't do the same for USB instead of the PREBOOT quirk?
Well, yes, that was going to be my next question. If using PREBOOT is for some reason no longer the preferred way to do this, should there be some other generic method to make sure the USB controllers are started when a USB keyboard is configured as an input method. Doing something generic like this in board-specific code seems wrong to me.
Cheers,
Mark
return 0; }
diff --git a/doc/board/emulation/qemu-riscv.rst b/doc/board/emulation/qemu-riscv.rst index 9d21f3270c..61137bcbf1 100644 --- a/doc/board/emulation/qemu-riscv.rst +++ b/doc/board/emulation/qemu-riscv.rst @@ -138,6 +138,11 @@ and adding::
-serial stdio -device VGA
+In addition, a usb keyboard can be attached to an emulated xHCI controller in +RISC-V virt machine as an option of input devices by adding::
- -device qemu-xhci,id=xhci -device usb-kbd,bus=xhci.0
Running with KVM
diff --git a/include/configs/qemu-riscv.h b/include/configs/qemu-riscv.h index d5146e70f7..584559cfa3 100644 --- a/include/configs/qemu-riscv.h +++ b/include/configs/qemu-riscv.h @@ -17,7 +17,7 @@
/* Environment options */
-#define CFG_STD_DEVICES_SETTINGS "stdin=serial\0" \ +#define CFG_STD_DEVICES_SETTINGS "stdin=serial,usbkbd\0" \ "stdout=serial,vidconsole\0" \ "stderr=serial,vidconsole\0"
-- 2.34.1

On 23.07.23 12:11, Mark Kettenis wrote:
Date: Sun, 23 Jul 2023 11:30:31 +0200 From: Heinrich Schuchardt xypron.glpk@gmx.de
Am 23. Juli 2023 10:38:00 MESZ schrieb Mark Kettenis mark.kettenis@xs4all.nl:
From: Bin Meng bmeng@tinylab.org Date: Sun, 23 Jul 2023 12:40:41 +0800
This brings PCI xHCI support to QEMU RISC-V and uses a usb keyboard as one of the input devices.
Signed-off-by: Bin Meng bmeng@tinylab.org
board/emulation/qemu-riscv/Kconfig | 5 +++++ board/emulation/qemu-riscv/qemu-riscv.c | 5 +++++ doc/board/emulation/qemu-riscv.rst | 5 +++++ include/configs/qemu-riscv.h | 2 +- 4 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/board/emulation/qemu-riscv/Kconfig b/board/emulation/qemu-riscv/Kconfig index 7220c55350..b503578d27 100644 --- a/board/emulation/qemu-riscv/Kconfig +++ b/board/emulation/qemu-riscv/Kconfig @@ -76,5 +76,10 @@ config BOARD_SPECIFIC_OPTIONS # dummy imply VIDEO_BOCHS imply SYS_WHITE_ON_BLACK imply PRE_CONSOLE_BUFFER
imply USB
imply USB_XHCI_HCD
imply USB_XHCI_PCI
imply USB_KEYBOARD
imply CMD_USB
endif
diff --git a/board/emulation/qemu-riscv/qemu-riscv.c b/board/emulation/qemu-riscv/qemu-riscv.c index f39f3be366..181abbbf97 100644 --- a/board/emulation/qemu-riscv/qemu-riscv.c +++ b/board/emulation/qemu-riscv/qemu-riscv.c @@ -12,6 +12,7 @@ #include <log.h> #include <spl.h> #include <init.h> +#include <usb.h> #include <virtio_types.h> #include <virtio.h>
@@ -41,6 +42,10 @@ int board_init(void)
int board_late_init(void) {
- /* start usb so that usb keyboard can be used as input device */
- if (CONFIG_IS_ENABLED(USB_KEYBOARD))
usb_init();
This is typically handled by including "usb start" in CONFIG_PREBOOT, which is done by boot/Kconfig. Any reason why that doesn't work for you?
We run pci_init() in board_r.c. Why don't do the same for USB instead of the PREBOOT quirk?
Well, yes, that was going to be my next question. If using PREBOOT is for some reason no longer the preferred way to do this, should there be some other generic method to make sure the USB controllers are started when a USB keyboard is configured as an input method. Doing something generic like this in board-specific code seems wrong to me.
Cheers,
Mark
+CC Marek
return 0; }
diff --git a/doc/board/emulation/qemu-riscv.rst b/doc/board/emulation/qemu-riscv.rst index 9d21f3270c..61137bcbf1 100644 --- a/doc/board/emulation/qemu-riscv.rst +++ b/doc/board/emulation/qemu-riscv.rst @@ -138,6 +138,11 @@ and adding::
-serial stdio -device VGA
+In addition, a usb keyboard can be attached to an emulated xHCI controller in +RISC-V virt machine as an option of input devices by adding::
- -device qemu-xhci,id=xhci -device usb-kbd,bus=xhci.0
Running with KVM
diff --git a/include/configs/qemu-riscv.h b/include/configs/qemu-riscv.h index d5146e70f7..584559cfa3 100644 --- a/include/configs/qemu-riscv.h +++ b/include/configs/qemu-riscv.h @@ -17,7 +17,7 @@
/* Environment options */
-#define CFG_STD_DEVICES_SETTINGS "stdin=serial\0" \ +#define CFG_STD_DEVICES_SETTINGS "stdin=serial,usbkbd\0" \ "stdout=serial,vidconsole\0" \ "stderr=serial,vidconsole\0"
-- 2.34.1

Hi Rick,
On Sun, Jul 23, 2023 at 12:40 PM Bin Meng bmeng@tinylab.org wrote:
The Bochs VGA card emulated by QEMU does not enforce any architecture. It was first introduced on x86 and indeed the x86 IO instruction is used to access the legacy VGA IO ports, but that does not mean it has to be done like this.
The first half of this series enhances the bochs video driver to remove the x86 limitation.
The second half of this series enables bochs video as the output console for QEMU RISC-V, to prove that the bochs video driver can indeed work on a non-x86 architecture. To make it actually useful, enable a usb keyboard as well, otherwise we can't just type anything :-)
This series is available at u-boot-x86/bochs for testing.
Bin Meng (17): dm: video: Cosmetic style fix video: bochs: Drop inclusion of <asm/mtrr.h> video: bochs: Drop the useless argument of bochs_vga_write() video: bochs: Avoid using IO instructions to access VGA IO port video: bochs: Remove the x86 dependency video: kconfig: Fix wrong text for the PCI default FB size video: kconfig: Drop the superfluous dependency video: kconfig: Set default FB size for Bochs video: bochs: Set the frame buffer size per configuration riscv: qemu: Enable Bochs video support console: kconfig: Drop the redundant VIDEO dependency console: Make stdio_print_current_devices() static console: Refactor stdio_print_current_devices() a little bit console: Print out complete stdio device list riscv: qemu: Enable PRE_CONSOLE_BUFFER riscv: qemu: Remove out-of-date "riscv,kernel-start" handling riscv: qemu: Enable usb keyboard as an input device
Would you please review patch 10, 15, 17, 18? Thanks!
Regards, Bin

On Sun, Jul 23, 2023 at 12:40 PM Bin Meng bmeng@tinylab.org wrote:
The Bochs VGA card emulated by QEMU does not enforce any architecture. It was first introduced on x86 and indeed the x86 IO instruction is used to access the legacy VGA IO ports, but that does not mean it has to be done like this.
The first half of this series enhances the bochs video driver to remove the x86 limitation.
The second half of this series enables bochs video as the output console for QEMU RISC-V, to prove that the bochs video driver can indeed work on a non-x86 architecture. To make it actually useful, enable a usb keyboard as well, otherwise we can't just type anything :-)
This series is available at u-boot-x86/bochs for testing.
Bin Meng (17): dm: video: Cosmetic style fix video: bochs: Drop inclusion of <asm/mtrr.h> video: bochs: Drop the useless argument of bochs_vga_write() video: bochs: Avoid using IO instructions to access VGA IO port video: bochs: Remove the x86 dependency video: kconfig: Fix wrong text for the PCI default FB size video: kconfig: Drop the superfluous dependency video: kconfig: Set default FB size for Bochs video: bochs: Set the frame buffer size per configuration riscv: qemu: Enable Bochs video support console: kconfig: Drop the redundant VIDEO dependency console: Make stdio_print_current_devices() static console: Refactor stdio_print_current_devices() a little bit console: Print out complete stdio device list riscv: qemu: Enable PRE_CONSOLE_BUFFER riscv: qemu: Remove out-of-date "riscv,kernel-start" handling riscv: qemu: Enable usb keyboard as an input device
Looks the first half is assigned to Anatolij and the second half to Rick.
I guess the first half should go first.
Ping for apply?
Regards, Bin

Hi Bin,
On Mon, 31 Jul 2023 13:26:23 +0800 Bin Meng bmeng.cn@gmail.com wrote: ...
Looks the first half is assigned to Anatolij and the second half to Rick.
I guess the first half should go first.
Ping for apply?
I've applied patches 1/18 to 9/18 now, a pull request is pending.
-- Anatolij

On Tue, Aug 1, 2023 at 9:03 PM Anatolij Gustschin agust@denx.de wrote:
Hi Bin,
On Mon, 31 Jul 2023 13:26:23 +0800 Bin Meng bmeng.cn@gmail.com wrote: ...
Looks the first half is assigned to Anatolij and the second half to Rick.
I guess the first half should go first.
Ping for apply?
I've applied patches 1/18 to 9/18 now, a pull request is pending.
Thank you Anatolij.
Regards, Bin
participants (7)
-
Anatolij Gustschin
-
Bin Meng
-
Bin Meng
-
Heinrich Schuchardt
-
Mark Kettenis
-
Simon Glass
-
Tom Rini