Resolve issues with booting distros on x86
Subsystems (2)
v6 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 v6:
- Rebase to -next
- Move 'Avoid unbinding devices in use by bootflows' to another series
Changes in v4:
- Use a Kconfig option
Changes in v3:
- 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:
- Add new patch to add a coreboot boot script
Simon Glass (7):
x86: coreboot: Add a boot script
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/Kconfig | 8 ++++++++ arch/x86/config.mk | 4 ++++ arch/x86/cpu/x86_64/cpu.c | 12 ++++++++++++ arch/x86/dts/coreboot.dts | 10 ++++++++++ board/emulation/qemu-x86/Kconfig | 3 ++- configs/coreboot64_defconfig | 2 ++ configs/coreboot_defconfig | 2 ++ configs/qemu-x86_64_defconfig | 5 +++-- configs/qemu-x86_defconfig | 1 + drivers/video/Kconfig | 1 + drivers/video/console_truetype.c | 10 ++++++++++ drivers/video/vidconsole-uclass.c | 15 ++++++++------- 12 files changed, 63 insertions(+), 10 deletions(-)
Signature · 1 line
2.34.1
PATCH v6 1/7 x86: coreboot: Add a boot script
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 v6:
- Rebase to -next
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
@@ -17,6 +17,7 @@ CONFIG_BOOTSTD_DEFAULTS=y 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_SYS_PBSIZE=532 CONFIG_PRE_CONSOLE_BUFFER=y CONFIG_SYS_CONSOLE_INFO_QUIET=y
configs/coreboot_defconfig +1 -0
@@ -15,6 +15,7 @@ CONFIG_BOOTSTD_DEFAULTS=y 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.34.1
PATCH v6 2/7 video: Correct setting of cursor position
In reply to Simon GlassThe 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
@@ -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.34.1
PATCH v6 3/7 video: Drop unnecessary truetype operations from SPL
In reply to Simon GlassSaving and restoring entries is used for expo and for the command line, which we don't use in SPL. Drop these methods.
---
(no changes since v3)
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
@@ -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.34.1
PATCH v6 4/7 x86: Enable SSE in 64-bit mode
In reply to Simon GlassThis is needed to support Truetype fonts. In any case, the compiler expects SSE to be available in 64-bit mode. Provide an option to enable SSE so that hardware floating-point arithmetic works.
---
(no changes since v4)
Changes in v4:
- Use a Kconfig option
arch/x86/Kconfig | 8 ++++++++ arch/x86/config.mk | 4 ++++ arch/x86/cpu/x86_64/cpu.c | 12 ++++++++++++ drivers/video/Kconfig | 1 + 4 files changed, 25 insertions(+)
arch/x86/Kconfig +8 -0
@@ -723,6 +723,14 @@ config ROM_TABLE_SIZE hex default 0x10000 +config X86_HARDFP + bool "Support hardware floating point" + help + U-Boot generally does not make use of floating point. Where this is + needed, it can be enabled using this option. This adjusts the + start-up code for 64-bit mode and changes the compiler options for + 64-bit to enable SSE. + config HAVE_ITSS bool "Enable ITSS" help
arch/x86/config.mk +4 -0
@@ -27,9 +27,13 @@ ifeq ($(IS_32BIT),y) PLATFORM_CPPFLAGS += -march=i386 -m32 else PLATFORM_CPPFLAGS += $(if $(CONFIG_SPL_BUILD),,-fpic) -fno-common -march=core2 -m64 + +ifndef CONFIG_X86_HARDFP PLATFORM_CPPFLAGS += -mno-mmx -mno-sse endif +endif # IS_32BIT + PLATFORM_RELFLAGS += -fdata-sections -ffunction-sections -fvisibility=hidden KBUILD_LDFLAGS += -Bsymbolic -Bsymbolic-functions
arch/x86/cpu/x86_64/cpu.c +12 -0
@@ -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,22 @@ int x86_mp_init(void)return 0 ; } +/* enable SSE features for hardware floating point */ +static void setup_sse_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; +if (IS_ENABLED (CONFIG_X86_HARDFP )) +setup_sse_features ();return 0 ; }
drivers/video/Kconfig +1 -0
@@ -180,6 +180,7 @@ config CONSOLE_ROTATION config CONSOLE_TRUETYPE bool "Support a console that uses TrueType fonts" + select X86_HARDFP if X86 help TrueTrype fonts can provide outline-drawing capability rather than needing to provide a bitmap for each font and size that is needed.
Signature · 1 line
2.34.1
PATCH v6 5/7 x86: coreboot: Enable truetype fonts
In reply to Simon GlassTruetype fonts look better in the menu, so enable them.
---
(no changes since v3)
Changes in v3:
- Add new patch to enable truetype fonts in coreboot
arch/x86/dts/coreboot.dts | 10 ++++++++++ configs/coreboot64_defconfig | 1 + configs/coreboot_defconfig | 1 + 3 files changed, 12 insertions(+)
arch/x86/dts/coreboot.dts +10 -0
@@ -46,6 +46,16 @@ compatible = "coreboot-fb"; }; + bootstd { + compatible = "u-boot,boot-std"; + + theme { + font-size = <30>; + menu-inset = <3>; + menuitem-gap-y = <1>; + }; + }; + sysinfo { compatible = "coreboot,sysinfo"; };
configs/coreboot64_defconfig +1 -0
@@ -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 +1 -0
@@ -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.34.1
PATCH v6 6/7 x86: qemu: Expand ROM size
In reply to Simon GlassExpand 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 | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-)
board/emulation/qemu-x86/Kconfig +2 -1
@@ -21,7 +21,8 @@ config BOARD_SPECIFIC_OPTIONS # dummy select X86_RESET_VECTOR select QEMU select QFW_PIO if CMD_QFW - 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 +2 -2
@@ -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,7 +17,7 @@ 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
Signature · 1 line
2.34.1
PATCH v6 7/7 x86: qemu: Enable truetype fonts
In reply to Simon GlassEnable 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 v6:
- Move 'Avoid unbinding devices in use by bootflows' to another series
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
@@ -81,6 +81,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
@@ -58,6 +58,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.34.1
Quoted 11 lines · Simon Glass
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.
[...]
Applied to u-boot/master, thanks!
Signature · 1 line
Tom