Skip to contentSkip to conversation

video: bochs: Remove the x86 limitation

PATCH In review Bin Meng 8 participants 64 messages Jul 23, 2023 – Aug 1, 2023 3 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Bin Meng

author
#0 lore raw

cover 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(-)
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH 1/18 dm: video: Cosmetic style fix

Some coding convention fixes for video_post_bind().

---

 drivers/video/video-uclass.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/video/video-uclass.c +4 -2
index 949595f1bc..8f268fc406 100644
@@ -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;
 	}
Signature · 1 line
2.34.1
author
#4 lore raw

PATCH 2/18 video: bochs: Drop inclusion of <asm/mtrr.h>

In reply to Bin Meng

The driver does not call any MTRR APIs.

---

 drivers/video/bochs.c | 1 -
 1 file changed, 1 deletion(-)
drivers/video/bochs.c +0 -1
index 2136b51193..fa0283c158 100644
@@ -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"
 
Signature · 1 line
2.34.1
author
#7 lore raw

PATCH 3/18 video: bochs: Drop the useless argument of bochs_vga_write()

In reply to Bin Meng

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.

---

 drivers/video/bochs.c | 7 ++++---
 drivers/video/bochs.h | 5 ++++-
 2 files changed, 8 insertions(+), 4 deletions(-)
drivers/video/bochs.c +4 -3
index fa0283c158..2d4526c714 100644
@@ -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;
 
drivers/video/bochs.h +4 -1
index 4c8ec83a55..71d3d60141 100644
@@ -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
Signature · 1 line
2.34.1
Reviewed-by Tested-by on v1 3/18
#8 lore raw

Re: [PATCH 03/18] video: bochs: Drop the useless argument of bochs_vga_write()

Quoted 6 lines · Bin Meng

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.

Quoted 6 lines

---

 drivers/video/bochs.c | 7 ++++---
 drivers/video/bochs.h | 5 ++++-
 2 files changed, 8 insertions(+), 4 deletions(-)
#9 lore raw

Re: [PATCH 03/18] video: bochs: Drop the useless argument of bochs_vga_write()

In reply to Bin Meng
Quoted 11 lines · On Sun, 23 Jul 2023 12:40:26 +0800 Bin Meng [email protected] 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.

---

 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

author
#10 lore raw

PATCH 4/18 video: bochs: Avoid using IO instructions to access VGA IO port

In reply to Bin Meng

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.

---

 drivers/video/bochs.c | 6 +++---
 drivers/video/bochs.h | 4 +---
 2 files changed, 4 insertions(+), 6 deletions(-)
drivers/video/bochs.c +3 -3
index 2d4526c714..5923ff81c6 100644
@@ -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;
 
drivers/video/bochs.h +1 -3
index 71d3d60141..3facf690e5 100644
@@ -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
Signature · 1 line
2.34.1
Reviewed-by Tested-by on v1 4/18
#11 lore raw

Re: [PATCH 04/18] video: bochs: Avoid using IO instructions to access VGA IO port

Quoted 7 lines · Bin Meng

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.

Quoted 9 lines

Update the driver to use MMIO access for VGA IO port.

---

 drivers/video/bochs.c | 6 +++---
 drivers/video/bochs.h | 4 +---
 2 files changed, 4 insertions(+), 6 deletions(-)
#12 lore raw

Re: [PATCH 04/18] video: bochs: Avoid using IO instructions to access VGA IO port

In reply to Bin Meng
Quoted 6 lines · On Sun, 23 Jul 2023 12:40:27 +0800 Bin Meng [email protected] 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.

Quoted 8 lines

Update the driver to use MMIO access for VGA IO port.

---

 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

author
#13 lore raw

PATCH 5/18 video: bochs: Remove the x86 dependency

In reply to Bin Meng

Now that the driver is legacy free, remove the x86 dependency so that it can be used on non-x86 architectures.

---

 drivers/video/Kconfig | 1 -
 1 file changed, 1 deletion(-)
drivers/video/Kconfig +0 -1
index b41dc60cec..3cdaa5ff27 100644
@@ -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
Signature · 1 line
2.34.1
#15 lore raw

Re: [PATCH 05/18] video: bochs: Remove the x86 dependency

In reply to Bin Meng
Quoted 8 lines · On Sun, 23 Jul 2023 12:40:28 +0800 Bin Meng [email protected] wrote:

Now that the driver is legacy free, remove the x86 dependency so that it can be used on non-x86 architectures.

---

 drivers/video/Kconfig | 1 -
 1 file changed, 1 deletion(-)

applied to u-boot-video/master, thanks!

--
Anatolij

author
#16 lore raw

PATCH 6/18 video: kconfig: Fix wrong text for the PCI default FB size

In reply to Bin Meng

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.

---

 drivers/video/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/video/Kconfig +2 -2
index 3cdaa5ff27..43ec7e6695 100644
@@ -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
Signature · 1 line
2.34.1
Reviewed-by on v1 6/18
#17 lore raw

Re: [PATCH 06/18] video: kconfig: Fix wrong text for the PCI default FB size

Quoted 10 lines · Bin Meng

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.

---

 drivers/video/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
#18 lore raw

Re: [PATCH 06/18] video: kconfig: Fix wrong text for the PCI default FB size

In reply to Bin Meng
Quoted 9 lines · On Sun, 23 Jul 2023 12:40:29 +0800 Bin Meng [email protected] 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.

---

 drivers/video/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

applied to u-boot-video/master, thanks!

--
Anatolij

author
#19 lore raw

PATCH 7/18 video: kconfig: Drop the superfluous dependency

In reply to Bin Meng

PCI is always selected by X86 architecture hence "X86 && PCI" does not make it better.

---

 drivers/video/Kconfig | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/video/Kconfig +4 -4
index 43ec7e6695..3f6b7d71b8 100644
@@ -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
Signature · 1 line
2.34.1
#21 lore raw

Re: [PATCH 07/18] video: kconfig: Drop the superfluous dependency

In reply to Bin Meng
Quoted 8 lines · On Sun, 23 Jul 2023 12:40:30 +0800 Bin Meng [email protected] wrote:

PCI is always selected by X86 architecture hence "X86 && PCI" does not make it better.

---

 drivers/video/Kconfig | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

applied to u-boot-video/master, thanks!

--
Anatolij

author
#22 lore raw

PATCH 8/18 video: kconfig: Set default FB size for Bochs

In reply to Bin Meng

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.

---

 drivers/video/Kconfig | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/video/Kconfig +4 -2
index 3f6b7d71b8..e32ce13fb6 100644
@@ -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
Signature · 1 line
2.34.1
Reviewed-by on v1 8/18
#23 lore raw

Re: [PATCH 08/18] video: kconfig: Set default FB size for Bochs

Quoted 10 lines · Bin Meng

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.

---

 drivers/video/Kconfig | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
#24 lore raw

Re: [PATCH 08/18] video: kconfig: Set default FB size for Bochs

In reply to Bin Meng
Quoted 9 lines · On Sun, 23 Jul 2023 12:40:31 +0800 Bin Meng [email protected] 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.

---

 drivers/video/Kconfig | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

applied to u-boot-video/master, thanks!

--
Anatolij

author
#25 lore raw

PATCH 9/18 video: bochs: Set the frame buffer size per configuration

In reply to Bin Meng

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.

---

 drivers/video/bochs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/video/bochs.c +2 -2
index 5923ff81c6..022ea38d4c 100644
@@ -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;
Signature · 1 line
2.34.1
Reviewed-by Tested-by on v1 9/18
#26 lore raw

Re: [PATCH 09/18] video: bochs: Set the frame buffer size per configuration

Quoted 11 lines · Bin Meng

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.

---

 drivers/video/bochs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
#27 lore raw

Re: [PATCH 09/18] video: bochs: Set the frame buffer size per configuration

In reply to Bin Meng
Quoted 9 lines · On Sun, 23 Jul 2023 12:40:32 +0800 Bin Meng [email protected] 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.

---

 drivers/video/bochs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

applied to u-boot-video/master, thanks!

--
Anatolij

author
#28 lore raw

PATCH 10/18 riscv: qemu: Enable Bochs video support

In reply to Bin Meng

Enable video console using the emulated Bochs VGA card.

---

 board/emulation/qemu-riscv/Kconfig | 3 +++
 doc/board/emulation/qemu-riscv.rst | 5 +++++
 include/configs/qemu-riscv.h       | 5 +++++
 3 files changed, 13 insertions(+)
board/emulation/qemu-riscv/Kconfig +3 -0
index 6114e1b812..976c350e50 100644
@@ -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
doc/board/emulation/qemu-riscv.rst +5 -0
index 509bf7c4a6..9d21f3270c 100644
@@ -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
 ----------------
 
include/configs/qemu-riscv.h +5 -0
index f6d326bda0..7ec3d12ce1 100644
@@ -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" \
Signature · 1 line
2.34.1
Reviewed-by on v1 10/18
#29 lore raw

Re: [PATCH 10/18] riscv: qemu: Enable Bochs video support

Quoted 10 lines · Bin Meng

Enable video console using the emulated Bochs VGA card.

---

 board/emulation/qemu-riscv/Kconfig | 3 +++
 doc/board/emulation/qemu-riscv.rst | 5 +++++
 include/configs/qemu-riscv.h       | 5 +++++
 3 files changed, 13 insertions(+)

How about a series to move this over to txt environment?

author
#30 lore raw

PATCH 11/18 console: kconfig: Drop the redundant VIDEO dependency

In reply to Bin Meng

The VIDEO dependency is described twice in CONSOLE_MUX.

---

 common/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/Kconfig +1 -1
index 973482f075..d103bc6ddb 100644
@@ -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.
Signature · 1 line
2.34.1
Reviewed-by on v1 11/18
#31 lore raw

Re: [PATCH 11/18] console: kconfig: Drop the redundant VIDEO dependency

Quoted 3 lines · Bin Meng

The VIDEO dependency is described twice in CONSOLE_MUX.

Quoted 18 lines

---

  common/Kconfig | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
common/Kconfig +1 -1
index 973482f075..d103bc6ddb 100644
@@ -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.
author
#33 lore raw

PATCH 12/18 console: Make stdio_print_current_devices() static

In reply to Bin Meng

As it is only called in common/console.c

---

 common/console.c    | 2 +-
 include/stdio_dev.h | 2 --
 2 files changed, 1 insertion(+), 3 deletions(-)
common/console.c +1 -1
index 71ad8efd6f..d0640ba05a 100644
@@ -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:    ");
include/stdio_dev.h +0 -2
index 77bf8a8970..7f18102052 100644
@@ -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".
  *
Signature · 1 line
2.34.1
author
#35 lore raw

PATCH 13/18 console: Refactor stdio_print_current_devices() a little bit

In reply to Bin Meng

In preparation to future changes, refactor this routine a little bit.

---

 common/console.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)
common/console.c +15 -15
index d0640ba05a..af52897ec3 100644
@@ -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)
Signature · 1 line
2.34.1
#36 lore raw

Re: [PATCH 13/18] console: Refactor stdio_print_current_devices() a little bit

Quoted 14 lines · Bin Meng

In preparation to future changes, refactor this routine a little bit.

---

  common/console.c | 30 +++++++++++++++---------------
  1 file changed, 15 insertions(+), 15 deletions(-)
common/console.c +0 -0
index d0640ba05a..af52897ec3 100644
@@ -1012,27 +1012,27 @@ int console_init_f(void)
 

common/console.c int console_init_f(void) · line 1022

Quoted 10 lines
common/console.c +8 -0
  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

Quoted 31 lines
common/console.c +7 -15
+	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)
author
#37 lore raw

PATCH 14/18 console: Print out complete stdio device list

In reply to Bin Meng

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.

---

 common/console.c | 30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)
common/console.c +21 -9
index af52897ec3..98c3ee6ca6 100644
@@ -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:    ");
Signature · 1 line
2.34.1
#38 lore raw

Re: [PATCH 14/18] console: Print out complete stdio device list

Quoted 29 lines · Bin Meng

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.

---

  common/console.c | 30 +++++++++++++++++++++---------
  1 file changed, 21 insertions(+), 9 deletions(-)
common/console.c +0 -8
index af52897ec3..98c3ee6ca6 100644
@@ -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 :

common/console.c static void stdio_print_current_devices(void) · line 1025

Quoted 10 lines
common/console.c +9 -1
-		     "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.

common/console.c static void stdio_print_current_devices(void) · line 1033

Quoted 8 lines
common/console.c +8 -0
+		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

common/console.c static void stdio_print_current_devices(void) · line 1037

Quoted 4 lines
common/console.c +4 -0
+		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

Quoted 3 lines
common/console.c +0 -0
  	/* Print information */
  	puts("In:    ");
#39 lore raw

Re: [PATCH 14/18] console: Print out complete stdio device list

Hi Heinrich,

Quoted 35 lines · Heinrich Schuchardt
Quoted 33 lines · Bin Meng

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.

---

  common/console.c | 30 +++++++++++++++++++++---------
  1 file changed, 21 insertions(+), 9 deletions(-)
common/console.c +3 -9
index af52897ec3..98c3ee6ca6 100644
@@ -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 */
Quoted 8 lines

common/console.c static void stdio_print_current_devices(void) · line 1025

Quoted 6 lines
common/console.c +6 -0
+             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.

Quoted 12 lines

common/console.c static void stdio_print_current_devices(void) · line 1033

Quoted 9 lines
common/console.c +8 -0
+             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

Quoted 7 lines

common/console.c static void stdio_print_current_devices(void) · line 1037

Quoted 4 lines
common/console.c +4 -0
+             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

#40 lore raw

Re: [PATCH 14/18] console: Print out complete stdio device list

Am 23. Juli 2023 14:04:39 MESZ schrieb Bin Meng <[email protected]>:

Quoted 67 lines

Hi Heinrich,

Quoted 35 lines · Heinrich Schuchardt
Quoted 33 lines · Bin Meng

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.

---

  common/console.c | 30 +++++++++++++++++++++---------
  1 file changed, 21 insertions(+), 9 deletions(-)
common/console.c +3 -9
index af52897ec3..98c3ee6ca6 100644
@@ -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 */
Quoted 8 lines

common/console.c static void stdio_print_current_devices(void) · line 1025

Quoted 6 lines
common/console.c +6 -0
+             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.

Quoted 17 lines

common/console.c static void stdio_print_current_devices(void) · line 1033

Quoted 9 lines
common/console.c +8 -0
+             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

Quoted 4 lines
common/console.c +4 -0
+             stderrname = stdio_devices[stderr] ?
+                     stdio_devices[stderr]->name :
+                     "No error devices available!";
+     }
Quoted 5 lines
Quoted 2 lines

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

Quoted 3 lines

Regards,
Bin

#41 lore raw

Re: [PATCH 14/18] console: Print out complete stdio device list

Hi Heinrich,

Quoted 74 lines · Heinrich Schuchardt

Am 23. Juli 2023 14:04:39 MESZ schrieb Bin Meng <[email protected]>:

Quoted 70 lines

Hi Heinrich,

Quoted 35 lines · Heinrich Schuchardt
Quoted 33 lines · Bin Meng

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.

---

  common/console.c | 30 +++++++++++++++++++++---------
  1 file changed, 21 insertions(+), 9 deletions(-)
common/console.c +3 -9
index af52897ec3..98c3ee6ca6 100644
@@ -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 */
Quoted 8 lines

common/console.c static void stdio_print_current_devices(void) · line 1025

Quoted 6 lines
common/console.c +6 -0
+             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.

Quoted 19 lines

common/console.c static void stdio_print_current_devices(void) · line 1033

Quoted 9 lines
common/console.c +8 -0
+             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

common/console.c static void stdio_print_current_devices(void) · line 1037

Quoted 4 lines
common/console.c +4 -0
+             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.

Quoted 6 lines
Quoted 2 lines

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

Reviewed-by
#42 lore raw

Re: [PATCH 14/18] console: Print out complete stdio device list

Quoted 97 lines · Bin Meng

Hi Heinrich,

Quoted 74 lines · Heinrich Schuchardt

Am 23. Juli 2023 14:04:39 MESZ schrieb Bin Meng <[email protected]>:

Quoted 70 lines

Hi Heinrich,

Quoted 35 lines · Heinrich Schuchardt
Quoted 33 lines · Bin Meng

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.

---

  common/console.c | 30 +++++++++++++++++++++---------
  1 file changed, 21 insertions(+), 9 deletions(-)
common/console.c +3 -9
index af52897ec3..98c3ee6ca6 100644
@@ -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 */
Quoted 8 lines

common/console.c static void stdio_print_current_devices(void) · line 1025

Quoted 6 lines
common/console.c +6 -0
+             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.

Quoted 19 lines

common/console.c static void stdio_print_current_devices(void) · line 1033

Quoted 9 lines
common/console.c +8 -0
+             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

common/console.c static void stdio_print_current_devices(void) · line 1037

Quoted 4 lines
common/console.c +4 -0
+             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.

Quoted 6 lines
Quoted 2 lines

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.

Quoted 1 line

Tom, what's your idea?

I agree that we should show it, since otherwise it is misleading.

Reviewed-by on v1 14/18
#43 lore raw

Re: [PATCH 14/18] console: Print out complete stdio device list

In reply to Bin Meng
Quoted 8 lines · Bin Meng

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.

This approach makes sense to me.

Signature · 1 line
Tom
author
#44 lore raw

PATCH 15/18 riscv: qemu: Enable PRE_CONSOLE_BUFFER

In reply to Bin Meng

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.

---

 board/emulation/qemu-riscv/Kconfig | 5 +++++
 1 file changed, 5 insertions(+)
board/emulation/qemu-riscv/Kconfig +5 -0
index 976c350e50..7220c55350 100644
@@ -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
Signature · 1 line
2.34.1

A message that is not in the archive (sent off-list or not yet received): SEZPR03MB806449404CFF3CB65A435E52C103A@SEZPR03MB8064.apcprd03.prod.outlook.com

Reviewed-by
#46 lore raw

Re: [PATCH 15/18] riscv: qemu: Enable PRE_CONSOLE_BUFFER

Quoted 9 lines

From: U-Boot <[email protected]> On Behalf Of Bin Meng
Sent: Sunday, July 23, 2023 12:41 PM
To: Simon Glass <[email protected]>; [email protected]
Cc: Bin Meng <[email protected]>
Subject: [PATCH 15/18] riscv: qemu: Enable PRE_CONSOLE_BUFFER

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.

Quoted 7 lines

Enable this support, and carefully select an address for the buffer.

---

 board/emulation/qemu-riscv/Kconfig | 5 +++++
 1 file changed, 5 insertions(+)
Reviewed-by
#47 lore raw

Re: [PATCH 15/18] riscv: qemu: Enable PRE_CONSOLE_BUFFER

Quoted 12 lines · Rick Chen
Quoted 12 lines

From: U-Boot <[email protected]> On Behalf Of Bin Meng
Sent: Sunday, July 23, 2023 12:41 PM
To: Simon Glass <[email protected]>; [email protected]
Cc: Bin Meng <[email protected]>
Subject: [PATCH 15/18] riscv: qemu: Enable PRE_CONSOLE_BUFFER

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.

Quoted 7 lines
Quoted 5 lines

---

 board/emulation/qemu-riscv/Kconfig | 5 +++++
 1 file changed, 5 insertions(+)
author
#48 lore raw

PATCH 16/18 riscv: define a cache line size for the generic CPU

In reply to Bin Meng

From: Heinrich Schuchardt <[email protected]>

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.

---

 arch/riscv/cpu/generic/Kconfig | 1 +
 1 file changed, 1 insertion(+)
arch/riscv/cpu/generic/Kconfig +1 -0
index 897765c3c6..2baba22992 100644
@@ -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)
Signature · 1 line
2.34.1
author
#49 lore raw

PATCH 17/18 riscv: qemu: Remove out-of-date "riscv, kernel-start" handling

In reply to Bin Meng

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.

---

 board/emulation/qemu-riscv/qemu-riscv.c | 24 ------------------------
 include/configs/qemu-riscv.h            | 10 ----------
 2 files changed, 34 deletions(-)
board/emulation/qemu-riscv/qemu-riscv.c +0 -24
index ae3b7a3295..f39f3be366 100644
@@ -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;
 }
 
include/configs/qemu-riscv.h +0 -10
index 7ec3d12ce1..d5146e70f7 100644
@@ -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" \
Signature · 1 line
2.34.1

A message that is not in the archive (sent off-list or not yet received): SEZPR03MB80646AC3947DBFA62D910A47C103A@SEZPR03MB8064.apcprd03.prod.outlook.com

Reviewed-by
#51 lore raw

Re: [PATCH 17/18] riscv: qemu: Remove out-of-date "riscv, kernel-start" handling

Quoted 11 lines

From: U-Boot <[email protected]> On Behalf Of Bin Meng
Sent: Sunday, July 23, 2023 12:41 PM
To: Simon Glass <[email protected]>; [email protected]
Cc: Bin Meng <[email protected]>
Subject: [PATCH 17/18] riscv: qemu: Remove out-of-date "riscv, kernel-start" handling

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.

Quoted 8 lines

Now we drop all codes in commit 66ffe57, except that BOARD_LATE_INIT is kept for later use.

---

 board/emulation/qemu-riscv/qemu-riscv.c | 24 ------------------------
 include/configs/qemu-riscv.h            | 10 ----------
 2 files changed, 34 deletions(-)
Reviewed-by
#52 lore raw

Re: [PATCH 17/18] riscv: qemu: Remove out-of-date "riscv, kernel-start" handling

Quoted 14 lines · Rick Chen
Quoted 14 lines

From: U-Boot <[email protected]> On Behalf Of Bin Meng
Sent: Sunday, July 23, 2023 12:41 PM
To: Simon Glass <[email protected]>; [email protected]
Cc: Bin Meng <[email protected]>
Subject: [PATCH 17/18] riscv: qemu: Remove out-of-date "riscv, kernel-start" handling

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.

Quoted 8 lines
Quoted 6 lines

---

 board/emulation/qemu-riscv/qemu-riscv.c | 24 ------------------------
 include/configs/qemu-riscv.h            | 10 ----------
 2 files changed, 34 deletions(-)
author
#53 lore raw

PATCH 18/18 riscv: qemu: Enable usb keyboard as an input device

In reply to Bin Meng

This brings PCI xHCI support to QEMU RISC-V and uses a usb keyboard as one of the input devices.

---

 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(-)
board/emulation/qemu-riscv/Kconfig +5 -0
index 7220c55350..b503578d27 100644
@@ -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
board/emulation/qemu-riscv/qemu-riscv.c +5 -0
index f39f3be366..181abbbf97 100644
@@ -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;
 }
 
doc/board/emulation/qemu-riscv.rst +5 -0
index 9d21f3270c..61137bcbf1 100644
@@ -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
 ----------------
 
include/configs/qemu-riscv.h +1 -1
index d5146e70f7..584559cfa3 100644
@@ -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"
 
Signature · 1 line
2.34.1
#54 lore raw

Re: [PATCH 18/18] riscv: qemu: Enable usb keyboard as an input device

Am 23. Juli 2023 06:40:41 MESZ schrieb Bin Meng <[email protected]>:

Quoted 18 lines

This brings PCI xHCI support to QEMU RISC-V and uses a usb keyboard as one of the input devices.

---

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(-)
board/emulation/qemu-riscv/Kconfig +0 -0
index 7220c55350..b503578d27 100644

board/emulation/qemu-riscv/Kconfig config BOARD_SPECIFIC_OPTIONS # dummy · line 81

Quoted 6 lines
board/emulation/qemu-riscv/Kconfig +3 -0
@@ -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

Quoted 56 lines
board/emulation/qemu-riscv/Kconfig +2 -0
+	imply USB_KEYBOARD
+	imply CMD_USB
 

endif

board/emulation/qemu-riscv/qemu-riscv.c +5 -0
index f39f3be366..181abbbf97 100644
@@ -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;
 }
 
doc/board/emulation/qemu-riscv.rst +5 -0
index 9d21f3270c..61137bcbf1 100644
@@ -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
----------------

include/configs/qemu-riscv.h +1 -1
index d5146e70f7..584559cfa3 100644
@@ -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"
 
#55 lore raw

Re: [PATCH 18/18] riscv: qemu: Enable usb keyboard as an input device

Hi Heinrich,

Quoted 17 lines · Heinrich Schuchardt

Am 23. Juli 2023 06:40:41 MESZ schrieb Bin Meng <[email protected]>:

Quoted 13 lines

This brings PCI xHCI support to QEMU RISC-V and uses a usb keyboard as one of the input devices.

---

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(-)
Quoted 13 lines

board/emulation/qemu-riscv/Kconfig config BOARD_SPECIFIC_OPTIONS # dummy · line 81

Quoted 11 lines
board/emulation/qemu-riscv/Kconfig +3 -0
index 7220c55350..b503578d27 100644
@@ -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

#56 lore raw

Re: [PATCH 18/18] riscv: qemu: Enable usb keyboard as an input device

In reply to Bin Meng
Quoted 44 lines

From: Bin Meng <[email protected]>
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.

---

 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(-)
board/emulation/qemu-riscv/Kconfig +5 -0
index 7220c55350..b503578d27 100644
@@ -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
board/emulation/qemu-riscv/qemu-riscv.c +1 -0
index f39f3be366..181abbbf97 100644
@@ -12,6 +12,7 @@
 #include <log.h>
 #include <spl.h>
 #include <init.h>
+#include <usb.h>
 #include <virtio_types.h>
 #include <virtio.h>
 

board/emulation/qemu-riscv/qemu-riscv.c int board_init(void) · line 48

Quoted 7 lines
board/emulation/qemu-riscv/qemu-riscv.c +4 -0
@@ -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?

Quoted 36 lines
board/emulation/qemu-riscv/qemu-riscv.c +0 -0
 	return 0;
 }
 
doc/board/emulation/qemu-riscv.rst +5 -0
index 9d21f3270c..61137bcbf1 100644
@@ -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
 ----------------
 
include/configs/qemu-riscv.h +1 -1
index d5146e70f7..584559cfa3 100644
@@ -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"
 
Signature · 1 line
2.34.1
#57 lore raw

Re: [PATCH 18/18] riscv: qemu: Enable usb keyboard as an input device

Am 23. Juli 2023 10:38:00 MESZ schrieb Mark Kettenis <[email protected]>:

Quoted 45 lines
Quoted 45 lines

From: Bin Meng <[email protected]>
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.

---

 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(-)
board/emulation/qemu-riscv/Kconfig +5 -0
index 7220c55350..b503578d27 100644
@@ -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
board/emulation/qemu-riscv/qemu-riscv.c +1 -0
index f39f3be366..181abbbf97 100644
@@ -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)
 
Quoted 10 lines

board/emulation/qemu-riscv/qemu-riscv.c int board_init(void) · line 48

Quoted 6 lines
board/emulation/qemu-riscv/qemu-riscv.c +4 -0
 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

Quoted 37 lines
Quoted 37 lines
board/emulation/qemu-riscv/qemu-riscv.c +0 -0
 	return 0;
 }
 
doc/board/emulation/qemu-riscv.rst +5 -0
index 9d21f3270c..61137bcbf1 100644
@@ -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
 ----------------
 
include/configs/qemu-riscv.h +1 -1
index d5146e70f7..584559cfa3 100644
@@ -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"
 
Signature · 1 line
2.34.1
#58 lore raw

Re: [PATCH 18/18] riscv: qemu: Enable usb keyboard as an input device

Quoted 60 lines

Date: Sun, 23 Jul 2023 11:30:31 +0200
From: Heinrich Schuchardt <[email protected]>

Am 23. Juli 2023 10:38:00 MESZ schrieb Mark Kettenis <[email protected]>:

Quoted 45 lines
Quoted 45 lines

From: Bin Meng <[email protected]>
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.

---

 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(-)
board/emulation/qemu-riscv/Kconfig +5 -0
index 7220c55350..b503578d27 100644
@@ -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
board/emulation/qemu-riscv/qemu-riscv.c +1 -0
index f39f3be366..181abbbf97 100644
@@ -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)
 
Quoted 10 lines

board/emulation/qemu-riscv/qemu-riscv.c int board_init(void) · line 48

Quoted 6 lines
board/emulation/qemu-riscv/qemu-riscv.c +4 -0
 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?

Quoted 2 lines

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

Quoted 38 lines
Quoted 37 lines
Quoted 37 lines
board/emulation/qemu-riscv/qemu-riscv.c +0 -0
 	return 0;
 }
 
doc/board/emulation/qemu-riscv.rst +5 -0
index 9d21f3270c..61137bcbf1 100644
@@ -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
 ----------------
 
include/configs/qemu-riscv.h +1 -1
index d5146e70f7..584559cfa3 100644
@@ -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"
 
Signature · 1 line
2.34.1
#59 lore raw

Re: [PATCH 18/18] riscv: qemu: Enable usb keyboard as an input device

Quoted 69 lines · Mark Kettenis
Quoted 60 lines

Date: Sun, 23 Jul 2023 11:30:31 +0200
From: Heinrich Schuchardt <[email protected]>

Am 23. Juli 2023 10:38:00 MESZ schrieb Mark Kettenis <[email protected]>:

Quoted 45 lines
Quoted 45 lines

From: Bin Meng <[email protected]>
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.

---

  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(-)
board/emulation/qemu-riscv/Kconfig +5 -0
index 7220c55350..b503578d27 100644
@@ -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
board/emulation/qemu-riscv/qemu-riscv.c +1 -0
index f39f3be366..181abbbf97 100644
@@ -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)
 
Quoted 10 lines

board/emulation/qemu-riscv/qemu-riscv.c int board_init(void) · line 48

Quoted 6 lines
board/emulation/qemu-riscv/qemu-riscv.c +4 -0
  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?

Quoted 2 lines

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.

Quoted 3 lines

Cheers,

Mark

+CC Marek

Quoted 38 lines
Quoted 38 lines
Quoted 38 lines
Quoted 38 lines
board/emulation/qemu-riscv/qemu-riscv.c +0 -0
  	return 0;
  }
 
doc/board/emulation/qemu-riscv.rst +5 -0
index 9d21f3270c..61137bcbf1 100644
@@ -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
  ----------------
 
include/configs/qemu-riscv.h +1 -2
index d5146e70f7..584559cfa3 100644
@@ -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

A message that is not in the archive (sent off-list or not yet received): SEZPR03MB80643451FB26D109D4606A90C103A@SEZPR03MB8064.apcprd03.prod.outlook.com

Reviewed-by
#61 lore raw

Re: [PATCH 18/18] riscv: qemu: Enable usb keyboard as an input device

Quoted 10 lines

From: U-Boot <[email protected]> On Behalf Of Bin Meng
Sent: Sunday, July 23, 2023 12:41 PM
To: Simon Glass <[email protected]>; [email protected]
Cc: Bin Meng <[email protected]>; Heinrich Schuchardt <[email protected]>
Subject: [PATCH 18/18] riscv: qemu: Enable usb keyboard as an input device

This brings PCI xHCI support to QEMU RISC-V and uses a usb keyboard as one of the input devices.

Quoted 7 lines

---

 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(-)
Reviewed-by
#62 lore raw

Re: [PATCH 18/18] riscv: qemu: Enable usb keyboard as an input device

Quoted 13 lines · Rick Chen
Quoted 13 lines

From: U-Boot <[email protected]> On Behalf Of Bin Meng
Sent: Sunday, July 23, 2023 12:41 PM
To: Simon Glass <[email protected]>; [email protected]
Cc: Bin Meng <[email protected]>; Heinrich Schuchardt <[email protected]>
Subject: [PATCH 18/18] riscv: qemu: Enable usb keyboard as an input device

This brings PCI xHCI support to QEMU RISC-V and uses a usb keyboard as one of the input devices.

---

Quoted 7 lines
Quoted 5 lines
 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(-)
#63 lore raw
In reply to Bin Meng

Hi Rick,

Quoted 27 lines · Bin Meng

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

Quoted 8 lines

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

#64 lore raw
Quoted 28 lines · Bin Meng
Quoted 27 lines

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

Quoted 9 lines
Quoted 8 lines

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

#65 lore raw

Hi Bin,

On Mon, 31 Jul 2023 13:26:23 +0800
Bin Meng [email protected] wrote:
...

Quoted 5 lines

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

#66 lore raw
Quoted 6 lines · Anatolij Gustschin

Hi Bin,

On Mon, 31 Jul 2023 13:26:23 +0800
Bin Meng [email protected] wrote:
...

Quoted 8 lines
Quoted 5 lines

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