Skip to contentSkip to conversation

Resolve issues with booting distros on x86

PATCH Superseded Simon Glass 4 participants 33 messages Oct 2, 2023 – Nov 15, 2023

Subsystems (3)

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v3 cover Resolve issues with booting distros on x86

This little series reprises the EFI-video fix, fixes a USB problem and enables a boot script for coreboot.

It also moves to truetype fonts for coreboot and qemu-x86, since the menus look much better and there are no strong size constraints.

With these changes it is possible to boot a Linux distro automatically with U-Boot on x86, including when U-Boot is the second-stage bootloader.

Changes in v3:
- Add new patch to refactor mmc prep to allow a different scan
- Add missing word 'function' in the commit message
- Clear the screen before booting
- Add new patch to drop unnecessary truetype operations from SPL
- Add new patch to enable truetype fonts in coreboot
- Add new patch to enable truetype fonts in qemu-x86 and qemu-x86_64

Changes in v2:
- Rebase to -next
- Add some more comments to the header file
- Add fixes tag
- Add new patch to add a return code to bootflow menu
- Add new patch to add a coreboot boot script
- Add new patch to avoid unbinding devices in use by bootflows

Simon Glass (12):
efi: Correct handling of frame buffer
bootstd: Refactor mmc prep to allow a different scan
bootstd: Add a return code to bootflow menu
x86: coreboot: Add a boot script
usb: Avoid unbinding devices in use by bootflows
expo: Correct background colour
video: Correct setting of cursor position
video: Drop unnecessary truetype operations from SPL
x86: Enable SSE in 64-bit mode
x86: coreboot: Enable truetype fonts
x86: qemu: Expand ROM size
x86: qemu: Enable truetype fonts

 arch/x86/config.mk                |  1 -
 arch/x86/cpu/x86_64/cpu.c         | 11 +++++
 arch/x86/dts/coreboot.dts         | 10 +++++
 board/emulation/qemu-x86/Kconfig  |  3 +-
 boot/bootm.c                      |  2 +-
 boot/expo.c                       |  4 +-
 cmd/bootflow.c                    | 53 ++++++++++++++++++------
 common/usb.c                      |  7 +++-
 configs/coreboot64_defconfig      |  4 +-
 configs/coreboot_defconfig        |  4 +-
 configs/qemu-x86_64_defconfig     |  7 ++--
 configs/qemu-x86_defconfig        |  1 +
 doc/usage/cmd/bootflow.rst        | 67 +++++++++++++++++++++++++++++++
 drivers/usb/host/usb-uclass.c     | 14 ++++++-
 drivers/video/console_truetype.c  | 10 +++++
 drivers/video/vidconsole-uclass.c | 15 +++----
 include/usb.h                     | 15 ++++++-
 include/video.h                   |  9 +++--
 lib/efi_loader/efi_gop.c          | 12 +++---
 test/boot/bootflow.c              | 64 ++++++++++++++++++++++++-----
 20 files changed, 264 insertions(+), 49 deletions(-)
Signature · 1 line
2.42.0.582.g8ccd20d70d-goog
#1 lore raw

PATCH v3 1/12 efi: Correct handling of frame buffer

The efi_gop driver uses private fields from the video uclass to obtain a pointer to the frame buffer. Use the platform data instead.

Check the VIDEO_COPY setting to determine which frame buffer to use. Once the next stage is running (and making use of U-Boot's EFI boot services) U-Boot does not handle copying from priv->fb to the hardware framebuffer, so we must allow EFI to write directly to the hardware framebuffer.

We could provide a function to read this, but it seems better to just document how it works. The original change ignored an explicit comment in the video.h file ("Things that are private to the uclass: don't use these in the driver") which is why this was missed when the VIDEO_COPY feature was added.

Fixes 8f661a5b662 ("efi_loader: gop: Expose fb when 32bpp")

---

(no changes since v2)

Changes in v2:
- Rebase to -next
- Add some more comments to the header file
- Add fixes tag

 include/video.h          |  9 ++++++---
 lib/efi_loader/efi_gop.c | 12 +++++++-----
 2 files changed, 13 insertions(+), 8 deletions(-)
include/video.h +6 -3
index 5048116a3d57..4d8df9baaada 100644
@@ -21,9 +21,12 @@ struct udevice;
  * @align: Frame-buffer alignment, indicating the memory boundary the frame
  *	buffer should start on. If 0, 1MB is assumed
  * @size: Frame-buffer size, in bytes
- * @base: Base address of frame buffer, 0 if not yet known
- * @copy_base: Base address of a hardware copy of the frame buffer. See
- *	CONFIG_VIDEO_COPY.
+ * @base: Base address of frame buffer, 0 if not yet known. If CONFIG_VIDEO_COPY
+ *	is enabled, this is the software copy, so writes to this will not be
+ *	visible until vidconsole_sync_copy() is called. If CONFIG_VIDEO_COPY is
+ *	disabled, this is the hardware framebuffer.
+ * @copy_base: Base address of a hardware copy of the frame buffer. If
+ *	CONFIG_VIDEO_COPY is disabled, this is not used.
  * @copy_size: Size of copy framebuffer, used if @size is 0
  * @hide_logo: Hide the logo (used for testing)
  */
lib/efi_loader/efi_gop.c +7 -5
index 778b693f983a..a09db31eb465 100644
@@ -10,6 +10,7 @@
 #include <efi_loader.h>
 #include <log.h>
 #include <malloc.h>
+#include <mapmem.h>
 #include <video.h>
 #include <asm/global_data.h>
 
@@ -467,10 +468,10 @@ efi_status_t efi_gop_register(void)
 	struct efi_gop_obj *gopobj;
 	u32 bpix, format, col, row;
 	u64 fb_base, fb_size;
-	void *fb;
 	efi_status_t ret;
 	struct udevice *vdev;
 	struct video_priv *priv;
+	struct video_uc_plat *plat;
 
 	/* We only support a single video output device for now */
 	if (uclass_first_device_err(UCLASS_VIDEO, &vdev)) {
@@ -483,9 +484,10 @@ efi_status_t efi_gop_register(void)
 	format = priv->format;
 	col = video_get_xsize(vdev);
 	row = video_get_ysize(vdev);
-	fb_base = (uintptr_t)priv->fb;
-	fb_size = priv->fb_size;
-	fb = priv->fb;
+
+	plat = dev_get_uclass_plat(vdev);
+	fb_base = IS_ENABLED(CONFIG_VIDEO_COPY) ? plat->copy_base : plat->base;
+	fb_size = plat->size;
 
 	switch (bpix) {
 	case VIDEO_BPP16:
@@ -547,7 +549,7 @@ efi_status_t efi_gop_register(void)
 	}
 	gopobj->info.pixels_per_scanline = col;
 	gopobj->bpix = bpix;
-	gopobj->fb = fb;
+	gopobj->fb = map_sysmem(fb_base, fb_size);
 
 	return EFI_SUCCESS;
 }
Signature · 1 line
2.42.0.582.g8ccd20d70d-goog
Reviewed-by on v3 1/12
#2 lore raw

Re: [PATCH v3 01/12] efi: Correct handling of frame buffer

Quoted 21 lines · Simon Glass

The efi_gop driver uses private fields from the video uclass to obtain a pointer to the frame buffer. Use the platform data instead.

Check the VIDEO_COPY setting to determine which frame buffer to use. Once the next stage is running (and making use of U-Boot's EFI boot services) U-Boot does not handle copying from priv->fb to the hardware framebuffer, so we must allow EFI to write directly to the hardware framebuffer.

We could provide a function to read this, but it seems better to just document how it works. The original change ignored an explicit comment in the video.h file ("Things that are private to the uclass: don't use these in the driver") which is why this was missed when the VIDEO_COPY feature was added.

Fixes 8f661a5b662 ("efi_loader: gop: Expose fb when 32bpp")

---

(no changes since v2)

Quoted 9 lines

Changes in v2:
- Rebase to -next
- Add some more comments to the header file
- Add fixes tag

 include/video.h          |  9 ++++++---
 lib/efi_loader/efi_gop.c | 12 +++++++-----
 2 files changed, 13 insertions(+), 8 deletions(-)
author Reviewed-by Bin Meng
#3 lore raw

Re: [PATCH v3 01/12] efi: Correct handling of frame buffer

Quoted 21 lines · Simon Glass

The efi_gop driver uses private fields from the video uclass to obtain a pointer to the frame buffer. Use the platform data instead.

Check the VIDEO_COPY setting to determine which frame buffer to use. Once the next stage is running (and making use of U-Boot's EFI boot services) U-Boot does not handle copying from priv->fb to the hardware framebuffer, so we must allow EFI to write directly to the hardware framebuffer.

We could provide a function to read this, but it seems better to just document how it works. The original change ignored an explicit comment in the video.h file ("Things that are private to the uclass: don't use these in the driver") which is why this was missed when the VIDEO_COPY feature was added.

Fixes 8f661a5b662 ("efi_loader: gop: Expose fb when 32bpp")

---

(no changes since v2)

Quoted 9 lines

Changes in v2:
- Rebase to -next
- Add some more comments to the header file
- Add fixes tag

 include/video.h          |  9 ++++++---
 lib/efi_loader/efi_gop.c | 12 +++++++-----
 2 files changed, 13 insertions(+), 8 deletions(-)

Applied to u-boot-dm, thanks!

#4 lore raw

PATCH v3 2/12 bootstd: Refactor mmc prep to allow a different scan

In reply to Simon Glass

Adjust scan_mmc4_bootdev() and related function so that the caller can do its own 'bootflow scan' command. This allows it to change the flags if needed.

---

Changes in v3:
- Add new patch to refactor mmc prep to allow a different scan

 test/boot/bootflow.c | 49 ++++++++++++++++++++++++++++++++++++--------
 1 file changed, 40 insertions(+), 9 deletions(-)
test/boot/bootflow.c +40 -9
index f5b2059140ac..0a992e2bcc14 100644
@@ -511,19 +511,27 @@ BOOTSTD_TEST(bootflow_cmd_boot, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
 /**
  * prep_mmc_bootdev() - Set up an mmc bootdev so we can access other distros
  *
+ * After calling this function, set std->bootdev_order to *@old_orderp to
+ * restore normal operation of bootstd (i.e. with the original bootdev order)
+ *
  * @uts: Unit test state
- * @mmc_dev: MMC device to use, e.g. "mmc4"
+ * @mmc_dev: MMC device to use, e.g. "mmc4". Note that this must remain valid
+ *	in the caller until
+ * @bind_cros: true to bind the ChromiumOS bootmeth
+ * @old_orderp: Returns the original bootdev order, which must be restored
  * Returns 0 on success, -ve on failure
  */
 static int prep_mmc_bootdev(struct unit_test_state *uts, const char *mmc_dev,
-			    bool bind_cros)
+			    bool bind_cros, const char ***old_orderp)
 {
-	const char *order[] = {"mmc2", "mmc1", mmc_dev, NULL};
+	static const char *order[] = {"mmc2", "mmc1", NULL, NULL};
 	struct udevice *dev, *bootstd;
 	struct bootstd_priv *std;
 	const char **old_order;
 	ofnode root, node;
 
+	order[2] = mmc_dev;
+
 	/* Enable the mmc4 node since we need a second bootflow */
 	root = oftree_root(oftree_default());
 	node = ofnode_find_subnode(root, mmc_dev);
@@ -546,26 +554,49 @@ static int prep_mmc_bootdev(struct unit_test_state *uts, const char *mmc_dev,
 	std = dev_get_priv(bootstd);
 	old_order = std->bootdev_order;
 	std->bootdev_order = order;
+	*old_orderp = old_order;
+
+	return 0;
+}
+
+/**
+ * scan_mmc_bootdev() - Set up an mmc bootdev so we can access other distros
+ *
+ * @uts: Unit test state
+ * @mmc_dev: MMC device to use, e.g. "mmc4"
+ * @bind_cros: true to bind the ChromiumOS bootmeth
+ * Returns 0 on success, -ve on failure
+ */
+static int scan_mmc_bootdev(struct unit_test_state *uts, const char *mmc_dev,
+			    bool bind_cros)
+{
+	struct bootstd_priv *std;
+	struct udevice *bootstd;
+	const char **old_order;
+
+	ut_assertok(prep_mmc_bootdev(uts, mmc_dev, bind_cros, &old_order));
 
 	console_record_reset_enable();
 	ut_assertok(run_command("bootflow scan", 0));
 	ut_assert_console_end();
 
 	/* Restore the order used by the device tree */
+	ut_assertok(uclass_first_device_err(UCLASS_BOOTSTD, &bootstd));
+	std = dev_get_priv(bootstd);
 	std->bootdev_order = old_order;
 
 	return 0;
 }
 
 /**
- * prep_mmc4_bootdev() - Set up the mmc4 bootdev so we can access a fake Armbian
+ * scan_mmc4_bootdev() - Set up the mmc4 bootdev so we can access a fake Armbian
  *
  * @uts: Unit test state
  * Returns 0 on success, -ve on failure
  */
-static int prep_mmc4_bootdev(struct unit_test_state *uts)
+static int scan_mmc4_bootdev(struct unit_test_state *uts)
 {
-	ut_assertok(prep_mmc_bootdev(uts, "mmc4", false));
+	ut_assertok(scan_mmc_bootdev(uts, "mmc4", false));
 
 	return 0;
 }
@@ -575,7 +606,7 @@ static int bootflow_cmd_menu(struct unit_test_state *uts)
 {
 	char prev[3];
 
-	ut_assertok(prep_mmc4_bootdev(uts));
+	ut_assertok(scan_mmc4_bootdev(uts));
 
 	/* Add keypresses to move to and select the second one in the list */
 	prev[0] = CTL_CH('n');
@@ -681,7 +712,7 @@ static int bootflow_menu_theme(struct unit_test_state *uts)
 	ofnode node;
 	int i;
 
-	ut_assertok(prep_mmc4_bootdev(uts));
+	ut_assertok(scan_mmc4_bootdev(uts));
 
 	ut_assertok(bootflow_menu_new(&exp));
 	node = ofnode_path("/bootstd/theme");
@@ -976,7 +1007,7 @@ BOOTSTD_TEST(bootflow_cmdline, 0);
 /* Test ChromiumOS bootmeth */
 static int bootflow_cros(struct unit_test_state *uts)
 {
-	ut_assertok(prep_mmc_bootdev(uts, "mmc5", true));
+	ut_assertok(scan_mmc_bootdev(uts, "mmc5", true));
 	ut_assertok(run_command("bootflow list", 0));
 
 	ut_assert_nextlinen("Showing all");
Signature · 1 line
2.42.0.582.g8ccd20d70d-goog
#5 lore raw

Re: [PATCH v3 02/12] bootstd: Refactor mmc prep to allow a different scan

Adjust scan_mmc4_bootdev() and related function so that the caller can do its own 'bootflow scan' command. This allows it to change the flags if needed.

---

Changes in v3:
- Add new patch to refactor mmc prep to allow a different scan

 test/boot/bootflow.c | 49 ++++++++++++++++++++++++++++++++++++--------
 1 file changed, 40 insertions(+), 9 deletions(-)

Applied to u-boot-dm, thanks!

#6 lore raw

PATCH v3 3/12 bootstd: Add a return code to bootflow menu

In reply to Simon Glass

Return an error when the user does not select an OS, so we know whether to boot or not.

Move calling of bootflow_menu_run() into a separate function so we can call it from other places.

Expand the test to cover these cases.

Add some documentation also, while we are here.

---

Changes in v3:
- Add missing word 'function' in the commit message

Changes in v2:
- Add new patch to add a return code to bootflow menu

 cmd/bootflow.c             | 53 +++++++++++++++++++++++-------
 doc/usage/cmd/bootflow.rst | 67 ++++++++++++++++++++++++++++++++++++++
 test/boot/bootflow.c       | 15 +++++++++
 3 files changed, 123 insertions(+), 12 deletions(-)
cmd/bootflow.c +41 -12
index 300ad3aaa760..1516f8a4193b 100644
@@ -89,6 +89,44 @@ static void show_footer(int count, int num_valid)
 	       num_valid);
 }
 
+/**
+ * bootflow_handle_menu() - Handle running the menu and updating cur bootflow
+ *
+ * This shows the menu, allows the user to select something and then prints
+ * what happened
+ *
+ * @std: bootstd information
+ * @text_mode: true to run the menu in text mode
+ * @bflowp: Returns selected bootflow, on success
+ * Return: 0 on success (a bootflow was selected), -EAGAIN if nothing was
+ *	chosen, other -ve value on other error
+ */
+__maybe_unused static int bootflow_handle_menu(struct bootstd_priv *std,
+					       bool text_mode,
+					       struct bootflow **bflowp)
+{
+	struct bootflow *bflow;
+	int ret;
+
+	ret = bootflow_menu_run(std, text_mode, &bflow);
+	if (ret) {
+		if (ret == -EAGAIN) {
+			printf("Nothing chosen\n");
+			std->cur_bootflow = NULL;
+		} else {
+			printf("Menu failed (err=%d)\n", ret);
+		}
+
+		return ret;
+	}
+
+	printf("Selected: %s\n", bflow->os_name ? bflow->os_name : bflow->name);
+	std->cur_bootflow = bflow;
+	*bflowp = bflow;
+
+	return 0;
+}
+
 static int do_bootflow_scan(struct cmd_tbl *cmdtp, int flag, int argc,
 			    char *const argv[])
 {
@@ -455,18 +493,9 @@ static int do_bootflow_menu(struct cmd_tbl *cmdtp, int flag, int argc,
 	if (ret)
 		return CMD_RET_FAILURE;
 
-	ret = bootflow_menu_run(std, text_mode, &bflow);
-	if (ret) {
-		if (ret == -EAGAIN)
-			printf("Nothing chosen\n");
-		else {
-			printf("Menu failed (err=%d)\n", ret);
-			return CMD_RET_FAILURE;
-		}
-	}
-
-	printf("Selected: %s\n", bflow->os_name ? bflow->os_name : bflow->name);
-	std->cur_bootflow = bflow;
+	ret = bootflow_handle_menu(std, text_mode, &bflow);
+	if (ret)
+		return CMD_RET_FAILURE;
 
 	return 0;
 }
doc/usage/cmd/bootflow.rst +67 -0

97 lines not on this page · raw message

test/boot/bootflow.c +15 -0
index 0a992e2bcc14..04a5bd5d7a80 100644
@@ -604,8 +604,12 @@ static int scan_mmc4_bootdev(struct unit_test_state *uts)
 /* Check 'bootflow menu' to select a bootflow */
 static int bootflow_cmd_menu(struct unit_test_state *uts)
 {
+	struct bootstd_priv *std;
 	char prev[3];
 
+	/* get access to the current bootflow */
+	ut_assertok(bootstd_get_priv(&std));
+
 	ut_assertok(scan_mmc4_bootdev(uts));
 
 	/* Add keypresses to move to and select the second one in the list */
@@ -616,6 +620,17 @@ static int bootflow_cmd_menu(struct unit_test_state *uts)
 
 	ut_assertok(run_command("bootflow menu", 0));
 	ut_assert_nextline("Selected: Armbian");
+	ut_assertnonnull(std->cur_bootflow);
+	ut_assert_console_end();
+
+	/* Check not selecting anything */
+	prev[0] = '\e';
+	prev[1] = '\0';
+	ut_asserteq(1, console_in_puts(prev));
+
+	ut_asserteq(1, run_command("bootflow menu", 0));
+	ut_assertnull(std->cur_bootflow);
+	ut_assert_nextline("Nothing chosen");
 	ut_assert_console_end();
 
 	return 0;
Signature · 1 line
2.42.0.582.g8ccd20d70d-goog
#7 lore raw

Re: [PATCH v3 03/12] bootstd: Add a return code to bootflow menu

Return an error when the user does not select an OS, so we know whether to boot or not.

Move calling of bootflow_menu_run() into a separate function so we can call it from other places.

Expand the test to cover these cases.

Add some documentation also, while we are here.

---

Changes in v3:
- Add missing word 'function' in the commit message

Changes in v2:
- Add new patch to add a return code to bootflow menu

 cmd/bootflow.c             | 53 +++++++++++++++++++++++-------
 doc/usage/cmd/bootflow.rst | 67 ++++++++++++++++++++++++++++++++++++++
 test/boot/bootflow.c       | 15 +++++++++
 3 files changed, 123 insertions(+), 12 deletions(-)

Applied to u-boot-dm, thanks!

#8 lore raw

PATCH v3 4/12 x86: coreboot: Add a boot script

In reply to Simon Glass

Provide the user with a list of available boot options. Selecting one causes it to be booted. Pressing <ESC> causes U-Boot to return to the command-line prompt.

---

Changes in v3:
- Clear the screen before booting

Changes in v2:
- Add new patch to add a coreboot boot script

 configs/coreboot64_defconfig | 1 +
 configs/coreboot_defconfig   | 1 +
 2 files changed, 2 insertions(+)
configs/coreboot64_defconfig +1 -0
index 555d281ef3cf..1865f623f6e6 100644
@@ -17,6 +17,7 @@ CONFIG_SYS_MONITOR_BASE=0x01120000
 CONFIG_SHOW_BOOT_PROGRESS=y
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="root=/dev/sdb3 init=/sbin/init rootwait ro"
+CONFIG_BOOTCOMMAND="bootflow scan -l; if bootflow menu; then cls; bootflow boot; fi"
 CONFIG_PRE_CONSOLE_BUFFER=y
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
 CONFIG_LOG=y
configs/coreboot_defconfig +1 -0
index edc38f1f5923..f1728dbfb5c9 100644
@@ -15,6 +15,7 @@ CONFIG_SYS_MONITOR_BASE=0x01110000
 CONFIG_SHOW_BOOT_PROGRESS=y
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="root=/dev/sdb3 init=/sbin/init rootwait ro"
+CONFIG_BOOTCOMMAND="bootflow scan -l; if bootflow menu; then cls; bootflow boot; fi"
 CONFIG_PRE_CONSOLE_BUFFER=y
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
 CONFIG_LOG=y
Signature · 1 line
2.42.0.582.g8ccd20d70d-goog
Reviewed-by on v3 4/12
#9 lore raw

Re: [PATCH v3 04/12] x86: coreboot: Add a boot script

Quoted 11 lines · Simon Glass

Provide the user with a list of available boot options. Selecting one causes it to be booted. Pressing <ESC> causes U-Boot to return to the command-line prompt.

---

Changes in v3:
- Clear the screen before booting

Quoted 7 lines

Changes in v2:
- Add new patch to add a coreboot boot script

 configs/coreboot64_defconfig | 1 +
 configs/coreboot_defconfig   | 1 +
 2 files changed, 2 insertions(+)
#10 lore raw

PATCH v3 5/12 usb: Avoid unbinding devices in use by bootflows

In reply to Simon Glass

When a USB device is unbound, it causes any bootflows attached to it to be removed, via a call to bootdev_clear_bootflows() from bootdev_pre_unbind(). This obviously makes it impossible to boot the bootflow.

However, when booting a bootflow that relies on USB, usb_stop() is called, which unbinds the device. For EFI, this happens in efi_exit_boot_services() which means that the bootflow disappears before it is finished with.

There is no need to unbind all the USB devices just to quiesce them. Add a new usb_pause() call which removes them but leaves them bound.

This resolves a hang on x86 when booting a distro from USB. This was found using a device with 4 bootflows, the last of which was USB.

---

(no changes since v2)

Changes in v2:
- Add new patch to avoid unbinding devices in use by bootflows

 boot/bootm.c                  |  2 +-
 common/usb.c                  |  7 ++++++-
 drivers/usb/host/usb-uclass.c | 14 ++++++++++++--
 include/usb.h                 | 15 ++++++++++++++-
 4 files changed, 33 insertions(+), 5 deletions(-)
boot/bootm.c +1 -1
index b1c3afe0a3ad..5c9ba083e64c 100644
@@ -501,7 +501,7 @@ ulong bootm_disable_interrupts(void)
 	 * updated every 1 ms within the HCCA structure in SDRAM! For more
 	 * details see the OpenHCI specification.
 	 */
-	usb_stop();
+	usb_pause();
 #endif
 	return iflag;
 }
common/usb.c +6 -1
index 836506dcd9e9..4d6ac69111e7 100644
@@ -126,7 +126,7 @@ int usb_init(void)
 /******************************************************************************
  * Stop USB this stops the LowLevel Part and deregisters USB devices.
  */
-int usb_stop(void)
+int usb_pause(void)
 {
 	int i;
 
@@ -144,6 +144,11 @@ int usb_stop(void)
 	return 0;
 }
 
+int usb_stop(void)
+{
+	return usb_pause();
+}
+
 /******************************************************************************
  * Detect if a USB device has been plugged or unplugged.
  */
drivers/usb/host/usb-uclass.c +12 -2
index a1cd0ad2d669..c26c65d7986b 100644
@@ -173,7 +173,7 @@ int usb_get_max_xfer_size(struct usb_device *udev, size_t *size)
 	return ops->get_max_xfer_size(bus, size);
 }
 
-int usb_stop(void)
+static int usb_finish(bool unbind_all)
 {
 	struct udevice *bus;
 	struct udevice *rh;
@@ -195,7 +195,7 @@ int usb_stop(void)
 
 		/* Locate root hub device */
 		device_find_first_child(bus, &rh);
-		if (rh) {
+		if (rh && unbind_all) {
 			/*
 			 * All USB devices are children of root hub.
 			 * Unbinding root hub will unbind all of its children.
@@ -222,6 +222,16 @@ int usb_stop(void)
 	return err;
 }
 
+int usb_stop(void)
+{
+	return usb_finish(true);
+}
+
+int usb_pause(void)
+{
+	return usb_finish(false);
+}
+
 static void usb_scan_bus(struct udevice *bus, bool recurse)
 {
 	struct usb_bus_priv *priv;
include/usb.h +14 -1
index 09e3f0cb309c..ad39b09a6e45 100644
@@ -265,7 +265,20 @@ int usb_kbd_deregister(int force);
  */
 int usb_init(void);
 
-int usb_stop(void); /* stop the USB Controller */
+/**
+ * usb_stop() - stop the USB Controller and unbind all USB controllers/devices
+ *
+ * Return: 0 if OK, -ve on error
+ */
+int usb_stop(void);
+
+/**
+ * usb_pause() - stop the USB Controller DMA, etc.
+ *
+ * Return: 0 if OK, -ve on error
+ */
+int usb_pause(void);
+
 int usb_detect_change(void); /* detect if a USB device has been (un)plugged */
 
 
Signature · 1 line
2.42.0.582.g8ccd20d70d-goog
#11 lore raw

PATCH v3 6/12 expo: Correct background colour

In reply to Simon Glass

Use the correct background colour when using white-on-black.

---

(no changes since v1)

 boot/expo.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
boot/expo.c +3 -1
index 139d684f8e6e..cadb6a0ad6e3 100644
@@ -190,10 +190,12 @@ int expo_render(struct expo *exp)
 	struct udevice *dev = exp->display;
 	struct video_priv *vid_priv = dev_get_uclass_priv(dev);
 	struct scene *scn = NULL;
+	enum colour_idx back;
 	u32 colour;
 	int ret;
 
-	colour = video_index_to_colour(vid_priv, VID_WHITE);
+	back = CONFIG_IS_ENABLED(SYS_WHITE_ON_BLACK) ? VID_BLACK : VID_WHITE;
+	colour = video_index_to_colour(vid_priv, back);
 	ret = video_fill(dev, colour);
 	if (ret)
 		return log_msg_ret("fill", ret);
Signature · 1 line
2.42.0.582.g8ccd20d70d-goog
author Reviewed-by Bin Meng
#13 lore raw

Re: [PATCH v3 06/12] expo: Correct background colour

Quoted 11 lines · Simon Glass

Use the correct background colour when using white-on-black.

---

(no changes since v1)

 boot/expo.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Applied to u-boot-dm, thanks!

#14 lore raw

PATCH v3 7/12 video: Correct setting of cursor position

In reply to Simon Glass

The ANSI codes are not correctly handled at present, in that the requested X position is added to the current one.

Correct this and also call vidconsole_entry_start() to start a new text line.

---

(no changes since v1)

 drivers/video/vidconsole-uclass.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/video/vidconsole-uclass.c +8 -7
index 22d55df71f63..a312a1985242 100644
@@ -125,6 +125,7 @@ void vidconsole_set_cursor_pos(struct udevice *dev, int x, int y)
 	priv->xcur_frac = VID_TO_POS(x);
 	priv->xstart_frac = priv->xcur_frac;
 	priv->ycur = y;
+	vidconsole_entry_start(dev);
 }
 
 /**
@@ -134,8 +135,10 @@ void vidconsole_set_cursor_pos(struct udevice *dev, int x, int y)
  * @row:	new row
  * @col:	new column
  */
-static void set_cursor_position(struct vidconsole_priv *priv, int row, int col)
+static void set_cursor_position(struct udevice *dev, int row, int col)
 {
+	struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
+
 	/*
 	 * Ensure we stay in the bounds of the screen.
 	 */
@@ -144,9 +147,7 @@ static void set_cursor_position(struct vidconsole_priv *priv, int row, int col)
 	if (col >= priv->cols)
 		col = priv->cols - 1;
 
-	priv->ycur = row * priv->y_charsize;
-	priv->xcur_frac = priv->xstart_frac +
-			  VID_TO_POS(col * priv->x_charsize);
+	vidconsole_position_cursor(dev, col, row);
 }
 
 /**
@@ -193,7 +194,7 @@ static void vidconsole_escape_char(struct udevice *dev, char ch)
 			int row = priv->row_saved;
 			int col = priv->col_saved;
 
-			set_cursor_position(priv, row, col);
+			set_cursor_position(dev, row, col);
 			priv->escape = 0;
 			return;
 		}
@@ -255,7 +256,7 @@ static void vidconsole_escape_char(struct udevice *dev, char ch)
 		if (row < 0)
 			row = 0;
 		/* Right and bottom overflows are handled in the callee. */
-		set_cursor_position(priv, row, col);
+		set_cursor_position(dev, row, col);
 		break;
 	}
 	case 'H':
@@ -279,7 +280,7 @@ static void vidconsole_escape_char(struct udevice *dev, char ch)
 		if (col)
 			--col;
 
-		set_cursor_position(priv, row, col);
+		set_cursor_position(dev, row, col);
 
 		break;
 	}
Signature · 1 line
2.42.0.582.g8ccd20d70d-goog
#15 lore raw

Re: [PATCH v3 07/12] video: Correct setting of cursor position

Hi Anatolij,

Quoted 78 lines · Simon Glass

The ANSI codes are not correctly handled at present, in that the requested X position is added to the current one.

Correct this and also call vidconsole_entry_start() to start a new text line.

---

(no changes since v1)

 drivers/video/vidconsole-uclass.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/video/vidconsole-uclass.c +8 -8
index 22d55df71f63..a312a1985242 100644
@@ -125,6 +125,7 @@ void vidconsole_set_cursor_pos(struct udevice *dev, int x, int y)
        priv->xcur_frac = VID_TO_POS(x);
        priv->xstart_frac = priv->xcur_frac;
        priv->ycur = y;
+       vidconsole_entry_start(dev);
 }
 
 /**
@@ -134,8 +135,10 @@ void vidconsole_set_cursor_pos(struct udevice *dev, int x, int y)
  * @row:       new row
  * @col:       new column
  */
-static void set_cursor_position(struct vidconsole_priv *priv, int row, int col)
+static void set_cursor_position(struct udevice *dev, int row, int col)
 {
+       struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
+
        /*
         * Ensure we stay in the bounds of the screen.
         */
@@ -144,9 +147,7 @@ static void set_cursor_position(struct vidconsole_priv *priv, int row, int col)
        if (col >= priv->cols)
                col = priv->cols - 1;
 
-       priv->ycur = row * priv->y_charsize;
-       priv->xcur_frac = priv->xstart_frac +
-                         VID_TO_POS(col * priv->x_charsize);
+       vidconsole_position_cursor(dev, col, row);
 }
 
 /**
@@ -193,7 +194,7 @@ static void vidconsole_escape_char(struct udevice *dev, char ch)
                        int row = priv->row_saved;
                        int col = priv->col_saved;
 
-                       set_cursor_position(priv, row, col);
+                       set_cursor_position(dev, row, col);
                        priv->escape = 0;
                        return;
                }
@@ -255,7 +256,7 @@ static void vidconsole_escape_char(struct udevice *dev, char ch)
                if (row < 0)
                        row = 0;
                /* Right and bottom overflows are handled in the callee. */
-               set_cursor_position(priv, row, col);
+               set_cursor_position(dev, row, col);
                break;
        }
        case 'H':
@@ -279,7 +280,7 @@ static void vidconsole_escape_char(struct udevice *dev, char ch)
                if (col)
                        --col;
 
-               set_cursor_position(priv, row, col);
+               set_cursor_position(dev, row, col);
 
                break;
        }
--
Quoted 2 lines

2.42.0.582.g8ccd20d70d-goog

Any thoughts on this patch, please?

Regards,
Simon

#16 lore raw

Re: [PATCH v3 07/12] video: Correct setting of cursor position

Hi Simon,

On Sun, 12 Nov 2023 13:01:11 -0700
Simon Glass [email protected] wrote:
...

Quoted 2 lines

Any thoughts on this patch, please?

looks good to me, thanks.

--
Anatolij

Reviewed-by on v3 7/12
#17 lore raw

Re: [PATCH v3 07/12] video: Correct setting of cursor position

In reply to Simon Glass
Quoted 6 lines · On Sun, 1 Oct 2023 19:14:42 -0600 Simon Glass [email protected] wrote:

The ANSI codes are not correctly handled at present, in that the requested X position is added to the current one.

Correct this and also call vidconsole_entry_start() to start a new text line.

Quoted 7 lines

---

(no changes since v1)

 drivers/video/vidconsole-uclass.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
#18 lore raw

PATCH v3 8/12 video: Drop unnecessary truetype operations from SPL

In reply to Simon Glass

Saving and restoring entries is used for expo and for the command line, which we don't use in SPL. Drop these methods.

---

Changes in v3:
- Add new patch to drop unnecessary truetype operations from SPL

 drivers/video/console_truetype.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/video/console_truetype.c +10 -0
index 14fb81e9563c..602133575f8c 100644
@@ -8,6 +8,7 @@
 #include <dm.h>
 #include <log.h>
 #include <malloc.h>
+#include <spl.h>
 #include <video.h>
 #include <video_console.h>
 
@@ -799,6 +800,9 @@ static int truetype_entry_save(struct udevice *dev, struct abuf *buf)
 	struct console_tt_store store;
 	const uint size = sizeof(store);
 
+	if (spl_phase() <= PHASE_SPL)
+		return -ENOSYS;
+
 	/*
 	 * store the whole priv structure as it is simpler that picking out
 	 * what we need
@@ -820,6 +824,9 @@ static int truetype_entry_restore(struct udevice *dev, struct abuf *buf)
 	struct console_tt_priv *priv = dev_get_priv(dev);
 	struct console_tt_store store;
 
+	if (spl_phase() <= PHASE_SPL)
+		return -ENOSYS;
+
 	memcpy(&store, abuf_data(buf), sizeof(store));
 
 	vc_priv->xcur_frac = store.cur.xpos_frac;
@@ -844,6 +851,9 @@ static int truetype_set_cursor_visible(struct udevice *dev, bool visible,
 	uint out, val;
 	int ret;
 
+	if (spl_phase() <= PHASE_SPL)
+		return -ENOSYS;
+
 	if (!visible)
 		return 0;
 
Signature · 1 line
2.42.0.582.g8ccd20d70d-goog
Reviewed-by on v3 8/12
#19 lore raw

Re: [PATCH v3 08/12] video: Drop unnecessary truetype operations from SPL

Quoted 4 lines · Simon Glass

Saving and restoring entries is used for expo and for the command line, which we don't use in SPL. Drop these methods.

Quoted 9 lines

---

Changes in v3:
- Add new patch to drop unnecessary truetype operations from SPL

 drivers/video/console_truetype.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
#20 lore raw

PATCH v3 9/12 x86: Enable SSE in 64-bit mode

In reply to Simon Glass

This is needed to support Truetype fonts. In any case, the compiler expects SSE to be available in 64-bit mode. Enable it.

---

(no changes since v1)

 arch/x86/config.mk        |  1 -
 arch/x86/cpu/x86_64/cpu.c | 11 +++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)
arch/x86/config.mk +0 -1
index 26ec1af2f0b0..b038b132985a 100644
@@ -27,7 +27,6 @@ ifeq ($(IS_32BIT),y)
 PLATFORM_CPPFLAGS += -march=i386 -m32
 else
 PLATFORM_CPPFLAGS += $(if $(CONFIG_SPL_BUILD),,-fpic) -fno-common -march=core2 -m64
-PLATFORM_CPPFLAGS += -mno-mmx -mno-sse
 endif
 
 PLATFORM_RELFLAGS += -fdata-sections -ffunction-sections -fvisibility=hidden
arch/x86/cpu/x86_64/cpu.c +11 -0
index 2647bff891f8..54dc31bf6b71 100644
@@ -10,6 +10,7 @@
 #include <init.h>
 #include <asm/cpu.h>
 #include <asm/global_data.h>
+#include <asm/processor-flags.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -39,11 +40,21 @@ int x86_mp_init(void)
 	return 0;
 }
 
+/* enable SSE features */
+static void setup_cpu_features(void)
+{
+	asm ("mov %%cr4, %%rax\n" \
+	"or  %0, %%rax\n" \
+	"mov %%rax, %%cr4\n" \
+	: : "i" (X86_CR4_OSFXSR | X86_CR4_OSXMMEXCPT) : "eax");
+}
+
 int x86_cpu_reinit_f(void)
 {
 	/* set the vendor to Intel so that native_calibrate_tsc() works */
 	gd->arch.x86_vendor = X86_VENDOR_INTEL;
 	gd->arch.has_mtrr = true;
+	setup_cpu_features();
 
 	return 0;
 }
Signature · 1 line
2.42.0.582.g8ccd20d70d-goog
#21 lore raw

Re: [PATCH v3 09/12] x86: Enable SSE in 64-bit mode

Hi Simon,

Quoted 6 lines · Simon Glass

This is needed to support Truetype fonts. In any case, the compiler expects SSE to be available in 64-bit mode. Enable it.

Quoted 8 lines

---

(no changes since v1)

 arch/x86/config.mk        |  1 -
 arch/x86/cpu/x86_64/cpu.c | 11 +++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

I didn't suggest we enable SSE for x86. This is the wrong approach.

We should rewrite the Truetype support codes to avoid using float/double types.

This way the Truetype codes can be used on any other architectures without the need for the compiler to emit explicit floating instructions.

Regards,
Bin

#22 lore raw

Re: [PATCH v3 09/12] x86: Enable SSE in 64-bit mode

Hi Bin,

Quoted 19 lines · Bin Meng

Hi Simon,

Quoted 6 lines · Simon Glass

This is needed to support Truetype fonts. In any case, the compiler expects SSE to be available in 64-bit mode. Enable it.

Quoted 8 lines

---

(no changes since v1)

 arch/x86/config.mk        |  1 -
 arch/x86/cpu/x86_64/cpu.c | 11 +++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)
Quoted 7 lines

I didn't suggest we enable SSE for x86. This is the wrong approach.

We should rewrite the Truetype support codes to avoid using float/double types.

This way the Truetype codes can be used on any other architectures without the need for the compiler to emit explicit floating instructions.

I am not aware of any such library. At present, enabling truetype on coreboot64 causes a hang.

Regards,
Simon

#23 lore raw

Re: [PATCH v3 09/12] x86: Enable SSE in 64-bit mode

+ Tom,

Hi Simon,

Quoted 25 lines · Simon Glass

Hi Bin,

Quoted 21 lines · Bin Meng

Hi Simon,

Quoted 6 lines · Simon Glass

This is needed to support Truetype fonts. In any case, the compiler expects SSE to be available in 64-bit mode. Enable it.

Quoted 8 lines

---

(no changes since v1)

 arch/x86/config.mk        |  1 -
 arch/x86/cpu/x86_64/cpu.c | 11 +++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

I didn't suggest we enable SSE for x86. This is the wrong approach.

Quoted 9 lines
Quoted 5 lines

We should rewrite the Truetype support codes to avoid using float/double types.

This way the Truetype codes can be used on any other architectures without the need for the compiler to emit explicit floating instructions.

I am not aware of any such library. At present, enabling truetype on coreboot64 causes a hang.

If that's the case, we will have to either:

- Switch all U-Boot builds' to use software float (e.g. -msoft-float) which unfortunately depends on the compiler runtime intrinsics.
- Introduce a Kconfig option for hard float enabling and let each architecture to decide whether it implements it or not, and update Truetype to depend on the hard float.

Regards,
Bin

#24 lore raw

Re: [PATCH v3 09/12] x86: Enable SSE in 64-bit mode

Quoted 40 lines · Bin Meng

+ Tom,

Hi Simon,

Quoted 25 lines · Simon Glass

Hi Bin,

Quoted 21 lines · Bin Meng

Hi Simon,

Quoted 6 lines · Simon Glass

This is needed to support Truetype fonts. In any case, the compiler expects SSE to be available in 64-bit mode. Enable it.

Quoted 8 lines

---

(no changes since v1)

 arch/x86/config.mk        |  1 -
 arch/x86/cpu/x86_64/cpu.c | 11 +++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

I didn't suggest we enable SSE for x86. This is the wrong approach.

Quoted 9 lines
Quoted 5 lines

We should rewrite the Truetype support codes to avoid using float/double types.

This way the Truetype codes can be used on any other architectures without the need for the compiler to emit explicit floating instructions.

I am not aware of any such library. At present, enabling truetype on coreboot64 causes a hang.

Quoted 7 lines

If that's the case, we will have to either:

- Switch all U-Boot builds' to use software float (e.g. -msoft-float) which unfortunately depends on the compiler runtime intrinsics.
- Introduce a Kconfig option for hard float enabling and let each architecture to decide whether it implements it or not, and update Truetype to depend on the hard float.

We generally do -msoft-float already, so introducing that for x86, and some Kconfig logic to ensure that no one else steps on this particular bug sounds reasonable.

Signature · 1 line
Tom
#25 lore raw

Re: [PATCH v3 09/12] x86: Enable SSE in 64-bit mode

Hi Bin,

Quoted 50 lines · Tom Rini
Quoted 40 lines · Bin Meng

+ Tom,

Hi Simon,

Quoted 25 lines · Simon Glass

Hi Bin,

Quoted 21 lines · Bin Meng

Hi Simon,

Quoted 6 lines · Simon Glass

This is needed to support Truetype fonts. In any case, the compiler expects SSE to be available in 64-bit mode. Enable it.

Quoted 8 lines

---

(no changes since v1)

 arch/x86/config.mk        |  1 -
 arch/x86/cpu/x86_64/cpu.c | 11 +++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

I didn't suggest we enable SSE for x86. This is the wrong approach.

Quoted 9 lines
Quoted 5 lines

We should rewrite the Truetype support codes to avoid using float/double types.

This way the Truetype codes can be used on any other architectures without the need for the compiler to emit explicit floating instructions.

I am not aware of any such library. At present, enabling truetype on coreboot64 causes a hang.

Quoted 7 lines

If that's the case, we will have to either:

- Switch all U-Boot builds' to use software float (e.g. -msoft-float) which unfortunately depends on the compiler runtime intrinsics.
- Introduce a Kconfig option for hard float enabling and let each architecture to decide whether it implements it or not, and update Truetype to depend on the hard float.

Quoted 3 lines

We generally do -msoft-float already, so introducing that for x86, and some Kconfig logic to ensure that no one else steps on this particular bug sounds reasonable.

Yes soft float seems to be not-much-used on x86. For 64-bit chips the compiler seems to assume that hardfp is available.

So perhaps the best thing is to introduce a HARDFP option to x86 only.

Regards,
Simon

#26 lore raw

Re: [PATCH v3 09/12] x86: Enable SSE in 64-bit mode

Hi Simon,

Quoted 54 lines · Simon Glass

Hi Bin,

Quoted 50 lines · Tom Rini
Quoted 47 lines · Bin Meng

+ Tom,

Hi Simon,

Quoted 25 lines · Simon Glass

Hi Bin,

Quoted 21 lines · Bin Meng

Hi Simon,

Quoted 6 lines · Simon Glass

This is needed to support Truetype fonts. In any case, the compiler expects SSE to be available in 64-bit mode. Enable it.

Quoted 8 lines

---

(no changes since v1)

 arch/x86/config.mk        |  1 -
 arch/x86/cpu/x86_64/cpu.c | 11 +++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

I didn't suggest we enable SSE for x86. This is the wrong approach.

Quoted 9 lines
Quoted 5 lines

We should rewrite the Truetype support codes to avoid using float/double types.

This way the Truetype codes can be used on any other architectures without the need for the compiler to emit explicit floating instructions.

I am not aware of any such library. At present, enabling truetype on coreboot64 causes a hang.

If that's the case, we will have to either:

- Switch all U-Boot builds' to use software float (e.g. -msoft-float) which unfortunately depends on the compiler runtime intrinsics.
- Introduce a Kconfig option for hard float enabling and let each architecture to decide whether it implements it or not, and update Truetype to depend on the hard float.

Quoted 6 lines
Quoted 3 lines

We generally do -msoft-float already, so introducing that for x86, and some Kconfig logic to ensure that no one else steps on this particular bug sounds reasonable.

Yes soft float seems to be not-much-used on x86. For 64-bit chips the compiler seems to assume that hardfp is available.

We have compiler flags to ensure the compiler does not generate SSE instructions. Yes, I know SSE is in almost every x86 processor we see nowadays.

Quoted 2 lines

So perhaps the best thing is to introduce a HARDFP option to x86 only.

This option should be global as some other arches also don't have hardware fp, like RISC-V whose fp extension is optional.

Regards,
Bin

#27 lore raw

Re: [PATCH v3 09/12] x86: Enable SSE in 64-bit mode

Hi Bin,

Quoted 70 lines · Bin Meng

Hi Simon,

Quoted 54 lines · Simon Glass

Hi Bin,

Quoted 50 lines · Tom Rini
Quoted 47 lines · Bin Meng

+ Tom,

Hi Simon,

Quoted 25 lines · Simon Glass

Hi Bin,

Quoted 21 lines · Bin Meng

Hi Simon,

Quoted 6 lines · Simon Glass

This is needed to support Truetype fonts. In any case, the compiler expects SSE to be available in 64-bit mode. Enable it.

Quoted 8 lines

---

(no changes since v1)

 arch/x86/config.mk        |  1 -
 arch/x86/cpu/x86_64/cpu.c | 11 +++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

I didn't suggest we enable SSE for x86. This is the wrong approach.

Quoted 9 lines
Quoted 5 lines

We should rewrite the Truetype support codes to avoid using float/double types.

This way the Truetype codes can be used on any other architectures without the need for the compiler to emit explicit floating instructions.

I am not aware of any such library. At present, enabling truetype on coreboot64 causes a hang.

If that's the case, we will have to either:

- Switch all U-Boot builds' to use software float (e.g. -msoft-float) which unfortunately depends on the compiler runtime intrinsics.
- Introduce a Kconfig option for hard float enabling and let each architecture to decide whether it implements it or not, and update Truetype to depend on the hard float.

Quoted 6 lines
Quoted 3 lines

We generally do -msoft-float already, so introducing that for x86, and some Kconfig logic to ensure that no one else steps on this particular bug sounds reasonable.

Yes soft float seems to be not-much-used on x86. For 64-bit chips the compiler seems to assume that hardfp is available.

We have compiler flags to ensure the compiler does not generate SSE instructions. Yes, I know SSE is in almost every x86 processor we see nowadays.

Quoted 1 line
Quoted 4 lines
Quoted 1 line

So perhaps the best thing is to introduce a HARDFP option to x86 only.

This option should be global as some other arches also don't have hardware fp, like RISC-V whose fp extension is optional.

Here is the patch I have:

https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

So perhaps move it to arch/Kconfig , rename it to HARDFP and update the help to be more generic?

Regards,
Simon

#28 lore raw

Re: [PATCH v3 09/12] x86: Enable SSE in 64-bit mode

In reply to Bin Meng
Quoted 69 lines · Bin Meng

Hi Simon,

Quoted 54 lines · Simon Glass

Hi Bin,

Quoted 50 lines · Tom Rini
Quoted 47 lines · Bin Meng

+ Tom,

Hi Simon,

Quoted 25 lines · Simon Glass

Hi Bin,

Quoted 21 lines · Bin Meng

Hi Simon,

Quoted 6 lines · Simon Glass

This is needed to support Truetype fonts. In any case, the compiler expects SSE to be available in 64-bit mode. Enable it.

Quoted 8 lines

---

(no changes since v1)

 arch/x86/config.mk        |  1 -
 arch/x86/cpu/x86_64/cpu.c | 11 +++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

I didn't suggest we enable SSE for x86. This is the wrong approach.

Quoted 9 lines
Quoted 5 lines

We should rewrite the Truetype support codes to avoid using float/double types.

This way the Truetype codes can be used on any other architectures without the need for the compiler to emit explicit floating instructions.

I am not aware of any such library. At present, enabling truetype on coreboot64 causes a hang.

If that's the case, we will have to either:

- Switch all U-Boot builds' to use software float (e.g. -msoft-float) which unfortunately depends on the compiler runtime intrinsics.
- Introduce a Kconfig option for hard float enabling and let each architecture to decide whether it implements it or not, and update Truetype to depend on the hard float.

Quoted 6 lines
Quoted 3 lines

We generally do -msoft-float already, so introducing that for x86, and some Kconfig logic to ensure that no one else steps on this particular bug sounds reasonable.

Yes soft float seems to be not-much-used on x86. For 64-bit chips the compiler seems to assume that hardfp is available.

We have compiler flags to ensure the compiler does not generate SSE instructions. Yes, I know SSE is in almost every x86 processor we see nowadays.

Quoted 1 line
Quoted 4 lines
Quoted 1 line

So perhaps the best thing is to introduce a HARDFP option to x86 only.

This option should be global as some other arches also don't have hardware fp, like RISC-V whose fp extension is optional.

RISC-V should take the ARM approach (and what I was suggesting for x86) and enforce soft-float for everyone.

Signature · 1 line
Tom
#29 lore raw

Re: [PATCH v3 09/12] x86: Enable SSE in 64-bit mode

Hi Tom,

Quoted 71 lines · Tom Rini
Quoted 69 lines · Bin Meng

Hi Simon,

Quoted 54 lines · Simon Glass

Hi Bin,

Quoted 50 lines · Tom Rini
Quoted 47 lines · Bin Meng

+ Tom,

Hi Simon,

Quoted 25 lines · Simon Glass

Hi Bin,

Quoted 21 lines · Bin Meng

Hi Simon,

Quoted 6 lines · Simon Glass

This is needed to support Truetype fonts. In any case, the compiler expects SSE to be available in 64-bit mode. Enable it.

Quoted 8 lines

---

(no changes since v1)

 arch/x86/config.mk        |  1 -
 arch/x86/cpu/x86_64/cpu.c | 11 +++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

I didn't suggest we enable SSE for x86. This is the wrong approach.

Quoted 9 lines
Quoted 5 lines

We should rewrite the Truetype support codes to avoid using float/double types.

This way the Truetype codes can be used on any other architectures without the need for the compiler to emit explicit floating instructions.

I am not aware of any such library. At present, enabling truetype on coreboot64 causes a hang.

If that's the case, we will have to either:

- Switch all U-Boot builds' to use software float (e.g. -msoft-float) which unfortunately depends on the compiler runtime intrinsics.
- Introduce a Kconfig option for hard float enabling and let each architecture to decide whether it implements it or not, and update Truetype to depend on the hard float.

Quoted 6 lines
Quoted 3 lines

We generally do -msoft-float already, so introducing that for x86, and some Kconfig logic to ensure that no one else steps on this particular bug sounds reasonable.

Yes soft float seems to be not-much-used on x86. For 64-bit chips the compiler seems to assume that hardfp is available.

We have compiler flags to ensure the compiler does not generate SSE instructions. Yes, I know SSE is in almost every x86 processor we see nowadays.

Quoted 1 line
Quoted 7 lines
Quoted 4 lines
Quoted 1 line

So perhaps the best thing is to introduce a HARDFP option to x86 only.

This option should be global as some other arches also don't have hardware fp, like RISC-V whose fp extension is optional.

RISC-V should take the ARM approach (and what I was suggesting for x86) and enforce soft-float for everyone.

But see my comment above...I'm just not sure softfp is widely used on x86. It also is a bit silly, since 64-bit CPUs have hardfp and it is trivial to enable (in fact we have to disable it if we don;t want it).

Bin, please let me know what you think.

Regards,
Simon

#30 lore raw

PATCH v3 10/12 x86: coreboot: Enable truetype fonts

In reply to Simon Glass

Truetype fonts look better in the menu, so enable them.

---

Changes in v3:
- Add new patch to enable truetype fonts in coreboot

 arch/x86/dts/coreboot.dts    | 10 ++++++++++
 configs/coreboot64_defconfig |  3 ++-
 configs/coreboot_defconfig   |  3 ++-
 3 files changed, 14 insertions(+), 2 deletions(-)
arch/x86/dts/coreboot.dts +10 -0
index 0eb31cae42c1..83beb82f37c7 100644
@@ -45,4 +45,14 @@
 		bootph-some-ram;
 		compatible = "coreboot-fb";
 	};
+
+	bootstd {
+		compatible = "u-boot,boot-std";
+
+		theme {
+			font-size = <30>;
+			menu-inset = <3>;
+			menuitem-gap-y = <1>;
+		};
+	};
 };
configs/coreboot64_defconfig +2 -1
index 1865f623f6e6..42b46ba0d9b9 100644
@@ -9,11 +9,11 @@ CONFIG_PRE_CON_BUF_ADDR=0x100000
 CONFIG_X86_RUN_64BIT=y
 CONFIG_VENDOR_COREBOOT=y
 CONFIG_TARGET_COREBOOT=y
+CONFIG_SYS_MONITOR_BASE=0x01120000
 CONFIG_FIT=y
 CONFIG_FIT_SIGNATURE=y
 CONFIG_BOOTSTD_FULL=y
 CONFIG_BOOTSTD_DEFAULTS=y
-CONFIG_SYS_MONITOR_BASE=0x01120000
 CONFIG_SHOW_BOOT_PROGRESS=y
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="root=/dev/sdb3 init=/sbin/init rootwait ro"
@@ -61,6 +61,7 @@ CONFIG_SYS_NS16550_MEM32=y
 CONFIG_SOUND=y
 CONFIG_SOUND_I8254=y
 CONFIG_VIDEO_COPY=y
+CONFIG_CONSOLE_TRUETYPE=y
 CONFIG_CONSOLE_SCROLL_LINES=5
 CONFIG_SPL_ACPI=y
 CONFIG_CMD_DHRYSTONE=y
configs/coreboot_defconfig +2 -1
index f1728dbfb5c9..7d744e9962ae 100644
@@ -7,11 +7,11 @@ CONFIG_DEFAULT_DEVICE_TREE="coreboot"
 CONFIG_PRE_CON_BUF_ADDR=0x100000
 CONFIG_VENDOR_COREBOOT=y
 CONFIG_TARGET_COREBOOT=y
+CONFIG_SYS_MONITOR_BASE=0x01110000
 CONFIG_FIT=y
 CONFIG_FIT_SIGNATURE=y
 CONFIG_BOOTSTD_FULL=y
 CONFIG_BOOTSTD_DEFAULTS=y
-CONFIG_SYS_MONITOR_BASE=0x01110000
 CONFIG_SHOW_BOOT_PROGRESS=y
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="root=/dev/sdb3 init=/sbin/init rootwait ro"
@@ -55,6 +55,7 @@ CONFIG_SYS_NS16550_MEM32=y
 CONFIG_SOUND=y
 CONFIG_SOUND_I8254=y
 CONFIG_VIDEO_COPY=y
+CONFIG_CONSOLE_TRUETYPE=y
 CONFIG_CONSOLE_SCROLL_LINES=5
 CONFIG_CMD_DHRYSTONE=y
 # CONFIG_GZIP is not set
Signature · 1 line
2.42.0.582.g8ccd20d70d-goog
#31 lore raw

PATCH v3 11/12 x86: qemu: Expand ROM size

In reply to Simon Glass

Expand the ROM for x86_64 to 2MB to make space for the font, as it is already on the edge.

---

(no changes since v1)

 board/emulation/qemu-x86/Kconfig | 3 ++-
 configs/qemu-x86_64_defconfig    | 6 +++---
 2 files changed, 5 insertions(+), 4 deletions(-)
board/emulation/qemu-x86/Kconfig +2 -1
index 787751abba4f..04b7a8aff89e 100644
@@ -21,7 +21,8 @@ config BOARD_SPECIFIC_OPTIONS # dummy
 	select X86_RESET_VECTOR
 	select QEMU
 	select QFW_PIO
-	select BOARD_ROMSIZE_KB_1024
+	select BOARD_ROMSIZE_KB_1024 if TARGET_QEMU_X86
+	select BOARD_ROMSIZE_KB_2048 if TARGET_QEMU_X86_64
 	imply VIRTIO_PCI
 	imply VIRTIO_NET
 	imply VIRTIO_BLK
configs/qemu-x86_64_defconfig +3 -3
index 165f0b512c8b..6de3da2d8269 100644
@@ -6,7 +6,7 @@ CONFIG_ENV_SIZE=0x40000
 CONFIG_MAX_CPUS=2
 CONFIG_SPL_DM_SPI=y
 CONFIG_DEFAULT_DEVICE_TREE="qemu-x86_i440fx"
-CONFIG_SPL_TEXT_BASE=0xfffd8000
+CONFIG_SPL_TEXT_BASE=0xfffd4000
 CONFIG_SPL_SYS_MALLOC_F_LEN=0x2000
 CONFIG_DEBUG_UART_BASE=0x3f8
 CONFIG_DEBUG_UART_CLOCK=1843200
@@ -17,12 +17,12 @@ CONFIG_DEBUG_UART=y
 CONFIG_SMP=y
 CONFIG_GENERATE_PIRQ_TABLE=y
 CONFIG_GENERATE_MP_TABLE=y
-CONFIG_X86_OFFSET_U_BOOT=0xfff00000
+CONFIG_X86_OFFSET_U_BOOT=0xffe00000
+CONFIG_SYS_MONITOR_BASE=0x01110000
 CONFIG_FIT=y
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_BOOTSTD_FULL=y
 CONFIG_BOOTSTD_DEFAULTS=y
-CONFIG_SYS_MONITOR_BASE=0x01110000
 CONFIG_BOOTSTAGE=y
 CONFIG_BOOTSTAGE_REPORT=y
 CONFIG_SHOW_BOOT_PROGRESS=y
Signature · 1 line
2.42.0.582.g8ccd20d70d-goog
#32 lore raw

PATCH v3 12/12 x86: qemu: Enable truetype fonts

In reply to Simon Glass

Enable this feature to provide a larger font choice and more attractive menus. Expand the ROM for x86_64 to 2MB to make space for the font.

---

Changes in v3:
- Add new patch to enable truetype fonts in qemu-x86 and qemu-x86_64

 configs/qemu-x86_64_defconfig | 1 +
 configs/qemu-x86_defconfig    | 1 +
 2 files changed, 2 insertions(+)
configs/qemu-x86_64_defconfig +1 -0
index 6de3da2d8269..c73d3f96e53d 100644
@@ -83,6 +83,7 @@ CONFIG_SPL_DM_RTC=y
 CONFIG_SYS_NS16550_PORT_MAPPED=y
 CONFIG_SPI=y
 CONFIG_USB_KEYBOARD=y
+CONFIG_CONSOLE_TRUETYPE=y
 CONFIG_FRAMEBUFFER_SET_VESA_MODE=y
 CONFIG_FRAMEBUFFER_VESA_MODE_USER=y
 CONFIG_FRAMEBUFFER_VESA_MODE=0x144
configs/qemu-x86_defconfig +1 -0
index 4b2787d4aaef..123d5ad63e53 100644
@@ -60,6 +60,7 @@ CONFIG_NVME_PCI=y
 CONFIG_SYS_NS16550_PORT_MAPPED=y
 CONFIG_SPI=y
 CONFIG_USB_KEYBOARD=y
+CONFIG_CONSOLE_TRUETYPE=y
 CONFIG_FRAMEBUFFER_SET_VESA_MODE=y
 CONFIG_FRAMEBUFFER_VESA_MODE_USER=y
 CONFIG_FRAMEBUFFER_VESA_MODE=0x144
Signature · 1 line
2.42.0.582.g8ccd20d70d-goog