vbe: Verified Boot for Embedded initial support
Subsystems (4)
cover vbe: Verified Boot for Embedded initial support
This adds the concept of a VBE method to U-Boot, along with an implementation of the 'VBE simple' method, basically a simple way of updating firmware in MMC from userspace and monitoring it from U-Boot.
VBE simple is implemented in fwupd. U-Boot's role is to set up the device tree with the required firmware-update properties and provide the developer with information about the current VBE state. To that end this series includes a new 'vbe' command that allows VBE methods to be listed and examined.
As part of this work, support for doing FDT fixups via the event interface is provided, along with the ability to write to the device tree via the ofnode interface.
Further work is needed to pull everything together, but this is a step along the way.
Simon Glass (19):
video: Renname vbe.h to vesa.h
video: Rename structs and functions to avoid VBE
dm: core: Split out the declaration of ofnode
ofnode: Add a note about how livetree updates work
ofnode: Introduce support for multiple trees
dm: core: Move ofnode-writing test to ofnode
dm: core: Swap parameters of ofnode_write_prop()
dm: core: Tidy up ofnode-writing test
dm: core: Prepare for updating the device tree with ofnode
ofnode: Allow writing to a flat tree
dm: core: Add support for writing u32 with ofnode
event: Add an event for device tree fixups
read: Support sandbox
bootstd: Fix comment in bootmeth test
bootstd: Detect empty bootmeth ordering
bootstd: Provide a bootmeth method to obtain state info
vbe: Add initial support for VBE
vbe: Support VBE simple
vbe: Add a new vbe command
arch/sandbox/dts/sandbox.dtsi | 13 ++ arch/sandbox/dts/test.dts | 15 ++ arch/x86/lib/bios.c | 12 +- arch/x86/lib/coreboot_table.c | 2 +- arch/x86/lib/fsp/fsp_graphics.c | 4 +- boot/Kconfig | 21 ++ boot/Makefile | 3 + boot/bootmeth-uclass.c | 12 + boot/bootmeth_distro.c | 14 ++ boot/image-fdt.c | 11 + boot/vbe.c | 119 ++++++++++ boot/vbe_simple.c | 304 ++++++++++++++++++++++++++ cmd/Kconfig | 10 + cmd/Makefile | 1 + cmd/elf.c | 2 +- cmd/read.c | 3 +- cmd/vbe.c | 87 ++++++++ common/event.c | 3 + doc/develop/driver-model/livetree.rst | 60 ++++- drivers/bios_emulator/atibios.c | 18 +- drivers/core/of_access.c | 57 ++++- drivers/core/ofnode.c | 81 +++---- drivers/pci/pci_rom.c | 14 +- drivers/video/broadwell_igd.c | 4 +- drivers/video/coreboot.c | 4 +- drivers/video/efi.c | 4 +- drivers/video/ivybridge_igd.c | 4 +- drivers/video/vesa.c | 4 +- include/bios_emul.h | 6 +- include/bootmeth.h | 38 +++- include/bootstd.h | 2 + include/dm/of_access.h | 22 +- include/dm/ofnode.h | 122 +++++------ include/dm/ofnode_decl.h | 85 +++++++ include/event.h | 14 ++ include/of_live.h | 16 ++ include/test/test.h | 2 + include/vbe.h | 146 ++++--------- include/vesa.h | 116 ++++++++++ lib/elf.c | 2 +- lib/of_live.c | 14 +- test/boot/Makefile | 4 + test/boot/bootflow.c | 53 +++-- test/boot/bootmeth.c | 31 ++- test/boot/vbe_simple.c | 115 ++++++++++ test/dm/ofnode.c | 132 +++++++++++ test/dm/test-fdt.c | 53 ----- test/py/tests/test_event_dump.py | 1 + test/test-main.c | 3 +- 49 files changed, 1503 insertions(+), 360 deletions(-) create mode 100644 boot/vbe.c create mode 100644 boot/vbe_simple.c create mode 100644 cmd/vbe.c create mode 100644 include/dm/ofnode_decl.h create mode 100644 include/vesa.h create mode 100644 test/boot/vbe_simple.c
Signature · 1 line
2.37.0.170.g444d1eabd0-goog
PATCH 1/19 video: Renname vbe.h to vesa.h
We want to use VBE to mean Verfiied Boot for Embedded in U-Boot. Rename the existing VBE (Vesa BIOS extensions) to allow this.
---
arch/x86/lib/bios.c | 2 +-
arch/x86/lib/coreboot_table.c | 2 +-
arch/x86/lib/fsp/fsp_graphics.c | 2 +-
cmd/elf.c | 2 +-
drivers/bios_emulator/atibios.c | 2 +-
drivers/pci/pci_rom.c | 2 +-
drivers/video/broadwell_igd.c | 2 +-
drivers/video/coreboot.c | 2 +-
drivers/video/efi.c | 2 +-
drivers/video/ivybridge_igd.c | 2 +-
drivers/video/vesa.c | 2 +-
include/{vbe.h => vesa.h} | 4 ++--
lib/elf.c | 2 +-
13 files changed, 14 insertions(+), 14 deletions(-)
rename include/{vbe.h => vesa.h} (98%)arch/x86/lib/bios.c +1 -1
@@ -10,7 +10,7 @@#include <bios_emul.h> #include <irq_func.h> #include <log.h> -#include <vbe.h> +#include <vesa.h> #include <linux/linkage.h> #include <asm/cache.h> #include <asm/processor.h>
arch/x86/lib/coreboot_table.c +1 -1
@@ -6,7 +6,7 @@#include <common.h> #include <malloc.h> #include <net.h> -#include <vbe.h> +#include <vesa.h> #include <acpi/acpi_s3.h> #include <asm/coreboot_tables.h> #include <asm/e820.h>
arch/x86/lib/fsp/fsp_graphics.c +1 -1
@@ -9,7 +9,7 @@#include <dm.h> #include <init.h> #include <log.h> -#include <vbe.h> +#include <vesa.h> #include <video.h> #include <acpi/acpi_table.h> #include <asm/fsp/fsp_support.h>
cmd/elf.c +1 -1
@@ -14,7 +14,7 @@#include <net.h> #include <vxworks.h> #ifdef CONFIG_X86 -#include <vbe.h> +#include <vesa.h> #include <asm/cache.h> #include <asm/e820.h> #include <linux/linkage.h>
drivers/bios_emulator/atibios.c +1 -1
@@ -51,7 +51,7 @@#include <errno.h> #include <log.h> #include <malloc.h> -#include <vbe.h> +#include <vesa.h> #include <linux/delay.h> #include "biosemui.h"
drivers/pci/pci_rom.c +1 -1
@@ -34,7 +34,7 @@#include <malloc.h> #include <pci.h> #include <pci_rom.h> -#include <vbe.h> +#include <vesa.h> #include <video.h> #include <acpi/acpi_s3.h> #include <asm/global_data.h>
drivers/video/broadwell_igd.c +1 -1
@@ -11,7 +11,7 @@#include <dm.h> #include <init.h> #include <log.h> -#include <vbe.h> +#include <vesa.h> #include <video.h> #include <asm/cpu.h> #include <asm/global_data.h>
drivers/video/coreboot.c +1 -1
@@ -6,7 +6,7 @@#include <common.h> #include <dm.h> #include <init.h> -#include <vbe.h> +#include <vesa.h> #include <video.h> #include <asm/cb_sysinfo.h>
drivers/video/efi.c +1 -1
@@ -9,7 +9,7 @@#include <dm.h> #include <efi_api.h> #include <log.h> -#include <vbe.h> +#include <vesa.h> #include <video.h> struct pixel {
drivers/video/ivybridge_igd.c +1 -1
@@ -10,7 +10,7 @@#include <fdtdec.h> #include <log.h> #include <pci_rom.h> -#include <vbe.h> +#include <vesa.h> #include <video.h> #include <asm/global_data.h> #include <asm/intel_regs.h>
drivers/video/vesa.c +1 -1
@@ -7,7 +7,7 @@#include <dm.h> #include <log.h> #include <pci.h> -#include <vbe.h> +#include <vesa.h> #include <video.h> #include <asm/mtrr.h>
include/vesa.h renamed from include/vbe.h +2 -2
@@ -7,8 +7,8 @@* Contributors: * IBM Corporation - initial implementation *****************************************************************************/ -#ifndef _VBE_H -#define _VBE_H +#ifndef _VESA_H +#define _VESA_H/* these structs are for input from and output to OF */ struct __packed vbe_screen_info {
lib/elf.c +1 -1
@@ -11,7 +11,7 @@#include <net.h> #include <vxworks.h> #ifdef CONFIG_X86 -#include <vbe.h> +#include <vesa.h> #include <asm/e820.h> #include <linux/linkage.h> #endif
Signature · 1 line
2.37.0.170.g444d1eabd0-goog
Re: [PATCH 01/19] video: Renname vbe.h to vesa.h
Hi Simon,
Quoted 2 lines · Simon Glass
We want to use VBE to mean Verfiied Boot for Embedded in U-Boot. Rename
typo: Verified
Is there a doc link to describe the Verified Boot for Embedded ? Just want to make sure if this acronym is the correct one to replace another existing and old VBE.
Quoted 5 lines
the existing VBE (Vesa BIOS extensions) to allow this.
Signed-off-by Simon Glass <[email protected]>---
Quoted 16 lines
arch/x86/lib/bios.c | 2 +-
arch/x86/lib/coreboot_table.c | 2 +-
arch/x86/lib/fsp/fsp_graphics.c | 2 +-
cmd/elf.c | 2 +-
drivers/bios_emulator/atibios.c | 2 +-
drivers/pci/pci_rom.c | 2 +-
drivers/video/broadwell_igd.c | 2 +-
drivers/video/coreboot.c | 2 +-
drivers/video/efi.c | 2 +-
drivers/video/ivybridge_igd.c | 2 +-
drivers/video/vesa.c | 2 +-
include/{vbe.h => vesa.h} | 4 ++--
lib/elf.c | 2 +-
13 files changed, 14 insertions(+), 14 deletions(-)
rename include/{vbe.h => vesa.h} (98%)Regards,
Bin
Re: [PATCH 01/19] video: Renname vbe.h to vesa.h
Hi Bin,
Quoted 5 lines · Bin Meng
Hi Simon,
Quoted 1 line · Simon Glass
Quoted 7 lines
Quoted 1 line
We want to use VBE to mean Verfiied Boot for Embedded in U-Boot. Rename
typo: Verified
Is there a doc link to describe the Verified Boot for Embedded ? Just want to make sure if this acronym is the correct one to replace another existing and old VBE.
Also this has more links:
https://github.com/fwupd/fwupd/tree/main/plugins/vbe#documentation
Quoted 6 lines
Quoted 6 lines
the existing VBE (Vesa BIOS extensions) to allow this.
Signed-off-by Simon Glass <[email protected]>---
Regards,
Simon
Re: [PATCH 01/19] video: Renname vbe.h to vesa.h
Hi Simon,
Quoted 13 lines · Simon Glass
Hi Bin,
Quoted 9 lines · Bin Meng
Hi Simon,
Quoted 2 lines · Simon Glass
We want to use VBE to mean Verfiied Boot for Embedded in U-Boot. Rename
typo: Verified
Quoted 9 lines
Quoted 3 lines
Is there a doc link to describe the Verified Boot for Embedded ? Just want to make sure if this acronym is the correct one to replace another existing and old VBE.
Also this has more links:
https://github.com/fwupd/fwupd/tree/main/plugins/vbe#documentation
Thanks for the links. I suggest we put these links in the commit message and/or code for reference.
Regards,
Bin
PATCH 2/19 video: Rename structs and functions to avoid VBE
In reply to Simon GlassRename these to VESA, itself an abbreviation, to avoid a conflict with Verified Boot for Embedded.
Rename this to avoid referencing VBE.
---
arch/x86/lib/bios.c | 10 +++++----- arch/x86/lib/fsp/fsp_graphics.c | 2 +- drivers/bios_emulator/atibios.c | 16 ++++++++-------- drivers/pci/pci_rom.c | 12 ++++++------ drivers/video/broadwell_igd.c | 2 +- drivers/video/coreboot.c | 2 +- drivers/video/efi.c | 2 +- drivers/video/ivybridge_igd.c | 2 +- drivers/video/vesa.c | 2 +- include/bios_emul.h | 6 +++--- include/vesa.h | 25 ++++++++++++++----------- 11 files changed, 42 insertions(+), 39 deletions(-)
arch/x86/lib/bios.c +5 -5
@@ -190,7 +190,7 @@ static void setup_realmode_idt(void) }#ifdef CONFIG_FRAMEBUFFER_SET_VESA_MODE -static u8 vbe_get_mode_info (struct vbe_mode_info *mi) +static u8 vbe_get_mode_info (struct vesa_state *mi) {u16 buffer_seg;u16 buffer_adr;
@@ -204,13 +204,13 @@ static u8 vbe_get_mode_info(struct vbe_mode_info *mi)realmode_interrupt (0x10 ,VESA_GET_MODE_INFO ,0x0000 , mi->video_mode,0x0000 , buffer_seg, buffer_adr); -memcpy (mi->mode_info_block, buffer,sizeof (struct vbe_mode_info )); +memcpy (mi->mode_info_block, buffer,sizeof (struct vesa_state )); mi->valid = true;return 0 ; } -static u8 vbe_set_mode (struct vbe_mode_info *mi) +static u8 vbe_set_mode (struct vesa_state *mi) {int video_mode = mi->video_mode;
@@ -225,7 +225,7 @@ static u8 vbe_set_mode(struct vbe_mode_info *mi)return 0 ; } -static void vbe_set_graphics (int vesa_mode,struct vbe_mode_info *mode_info) +static void vbe_set_graphics (int vesa_mode,struct vesa_state *mode_info) {unsigned char *framebuffer;
@@ -249,7 +249,7 @@ static void vbe_set_graphics(int vesa_mode, struct vbe_mode_info *mode_info)#endif /* CONFIG_FRAMEBUFFER_SET_VESA_MODE */ void bios_run_on_x86 (struct udevice *dev,unsigned long addr,int vesa_mode, -struct vbe_mode_info *mode_info) +struct vesa_state *mode_info) {pci_dev_t pcidev =dm_pci_get_bdf (dev);u32 num_dev;
arch/x86/lib/fsp/fsp_graphics.c +1 -1
@@ -106,7 +106,7 @@ static int fsp_video_probe(struct udevice *dev) vesa->phys_base_ptr =dm_pci_read_bar32 (dev,2 ); gd->fb_base = vesa->phys_base_ptr; - ret =vbe_setup_video_priv (vesa, uc_priv, plat); + ret =vesa_setup_video_priv (vesa, uc_priv, plat);if (ret) goto err;
drivers/bios_emulator/atibios.c +8 -8
@@ -83,13 +83,13 @@ static const void *bios_ptr(const void *buf, BE_VGAInfo *vga_info, }static int atibios_debug_mode (BE_VGAInfo *vga_info,RMREGS *regs, -int vesa_mode,struct vbe_mode_info *mode_info) +int vesa_mode,struct vesa_state *mode_info) {void *buffer = (void *)(M .mem_base + vbe_offset);u16 buffer_seg = (((unsigned long )vbe_offset) >>4 ) &0xff00 ;u16 buffer_adr = ((unsigned long )vbe_offset) &0xffff ;struct vesa_mode_info *vm; -struct vbe_info *info; +struct vesa_bios_ext_info *info;const u16 *modes_bios, *ptr;u16 *modes;int size;
@@ -140,7 +140,7 @@ static int atibios_debug_mode(BE_VGAInfo *vga_info, RMREGS *regs,int attr;debug ("Mode %x: " , mode); -memset (buffer,'\0' ,sizeof (struct vbe_mode_info )); +memset (buffer,'\0' ,sizeof (struct vesa_state )); regs->e.eax =VESA_GET_MODE_INFO ; regs->e.ebx =0 ; regs->e.ecx = mode;
@@ -174,7 +174,7 @@ static int atibios_debug_mode(BE_VGAInfo *vga_info, RMREGS *regs, }static int atibios_set_vesa_mode (RMREGS *regs,int vesa_mode, -struct vbe_mode_info *mode_info) +struct vesa_state *mode_info) {void *buffer = (void *)(M .mem_base + vbe_offset);u16 buffer_seg = (((unsigned long )vbe_offset) >>4 ) &0xff00 ;
@@ -192,7 +192,7 @@ static int atibios_set_vesa_mode(RMREGS *regs, int vesa_mode,return -ENOSYS ; } -memset (buffer,'\0' ,sizeof (struct vbe_mode_info )); +memset (buffer,'\0' ,sizeof (struct vesa_state ));debug ("VBE: Geting info for VESA mode %#04x\n" , vesa_mode); regs->e.eax =VESA_GET_MODE_INFO ; regs->e.ecx = vesa_mode;
@@ -231,7 +231,7 @@ at this stage the controller has its I/O and memory space enabled andthat all other controllers are in a disabled state. ****************************************************************************/ static void PCI_doBIOSPOST (struct udevice *pcidev,BE_VGAInfo *vga_info, -int vesa_mode,struct vbe_mode_info *mode_info) +int vesa_mode,struct vesa_state *mode_info) {RMREGS regs;RMSREGS sregs;
@@ -416,7 +416,7 @@ image we can extract over the PCI bus.****************************************************************************/ static int PCI_postController (struct udevice *pcidev,uchar *bios_rom,int bios_len,BE_VGAInfo *vga_info, -int vesa_mode,struct vbe_mode_info *mode_info) +int vesa_mode,struct vesa_state *mode_info) {u32 bios_image_len;uchar *mapped_bios;
@@ -496,7 +496,7 @@ void biosemu_set_interrupt_handler(int intnum, int (*int_func)(void)) int biosemu_run(struct udevice *pcidev, uchar *bios_rom, int bios_len, BE_VGAInfo *vga_info, int clean_up, int vesa_mode, - struct vbe_mode_info *mode_info) + struct vesa_state *mode_info) { /*Post all the display controller BIOS'es*/ if (!PCI_postController(pcidev, bios_rom, bios_len, vga_info,
drivers/pci/pci_rom.c +6 -6
@@ -202,7 +202,7 @@ static int pci_rom_load(struct pci_rom_header *rom_header,return 0 ; } -struct vbe_mode_info mode_info; +struct vesa_state mode_info;void setup_video (struct screen_info *screen_info) {
@@ -326,9 +326,9 @@ err: }#ifdef CONFIG_DM_VIDEO -int vbe_setup_video_priv (struct vesa_mode_info *vesa, -struct video_priv *uc_priv, -struct video_uc_plat *plat) +int vesa_setup_video_priv (struct vesa_mode_info *vesa, +struct video_priv *uc_priv, +struct video_uc_plat *plat) {if (!vesa->x_resolution)return log_msg_ret ("No x resolution" , -ENXIO );
@@ -358,7 +358,7 @@ int vbe_setup_video_priv(struct vesa_mode_info *vesa,return 0 ; } -int vbe_setup_video (struct udevice *dev,int (*int15_handler)(void )) +int vesa_setup_video (struct udevice *dev,int (*int15_handler)(void )) {struct video_uc_plat *plat =dev_get_uclass_plat (dev);struct video_priv *uc_priv =dev_get_uclass_priv (dev);
@@ -378,7 +378,7 @@ int vbe_setup_video(struct udevice *dev, int (*int15_handler)(void))return ret; } - ret =vbe_setup_video_priv (&mode_info.vesa, uc_priv, plat); + ret =vesa_setup_video_priv (&mode_info.vesa, uc_priv, plat);if (ret) {if (ret == -ENFILE ) {/*
drivers/video/broadwell_igd.c +1 -1
@@ -681,7 +681,7 @@ static int broadwell_igd_probe(struct udevice *dev)debug ("%s: is_broadwell=%d\n" , __func__, is_broadwell); ret =igd_pre_init (dev, is_broadwell);if (!ret) { - ret =vbe_setup_video (dev, broadwell_igd_int15_handler); + ret =vesa_setup_video (dev, broadwell_igd_int15_handler);if (ret)debug ("failed to run video BIOS: %d\n" , ret); }
drivers/video/coreboot.c +1 -1
@@ -57,7 +57,7 @@ static int coreboot_video_probe(struct udevice *dev) goto err; } - ret =vbe_setup_video_priv (vesa, uc_priv, plat); + ret =vesa_setup_video_priv (vesa, uc_priv, plat);if (ret) { ret =log_msg_ret ("setup" , ret); goto err;
drivers/video/efi.c +1 -1
@@ -149,7 +149,7 @@ static int efi_video_probe(struct udevice *dev)if (ret) goto err; - ret =vbe_setup_video_priv (vesa, uc_priv, plat); + ret =vesa_setup_video_priv (vesa, uc_priv, plat);if (ret) goto err;
drivers/video/ivybridge_igd.c +1 -1
@@ -762,7 +762,7 @@ static int bd82x6x_video_probe(struct udevice *dev) rev =gma_func0_init (dev);if (rev <0 )return rev; - ret =vbe_setup_video (dev, int15_handler); + ret =vesa_setup_video (dev, int15_handler);if (ret)return ret;
drivers/video/vesa.c +1 -1
@@ -17,7 +17,7 @@ static int vesa_video_probe(struct udevice *dev)ulong fbbase;int ret; - ret =vbe_setup_video (dev,NULL ); + ret =vesa_setup_video (dev,NULL );if (ret)return log_ret (ret);
include/bios_emul.h +3 -3
@@ -36,14 +36,14 @@ typedef struct {u8 LowMem[1536 ]; } BE_VGAInfo; -struct vbe_mode_info ; +struct vesa_state ;int BootVideoCardBIOS (struct udevice *pcidev,BE_VGAInfo **pVGAInfo,int clean_up);/* Run a BIOS ROM natively (only supported on x86 machines) */ void bios_run_on_x86 (struct udevice *dev,unsigned long addr,int vesa_mode, -struct vbe_mode_info *mode_info); +struct vesa_state *mode_info);/** * bios_set_interrupt_handler() - Install an interrupt handler for the BIOS
@@ -61,6 +61,6 @@ int biosemu_setup(struct udevice *pcidev, BE_VGAInfo **pVGAInfo);int biosemu_run (struct udevice *dev,uchar *bios_rom,int bios_len,BE_VGAInfo *vga_info,int clean_up,int vesa_mode, -struct vbe_mode_info *mode_info); +struct vesa_state *mode_info);#endif
include/vesa.h +14 -11
@@ -11,7 +11,7 @@#define _VESA_H/* these structs are for input from and output to OF */ -struct __packed vbe_screen_info { +struct __packed vesa_screen_info {u8 display_type;/* 0=NONE, 1= analog, 2=digital */ u16 screen_width;u16 screen_height;
@@ -22,7 +22,7 @@ struct __packed vbe_screen_info {u8 edid_block_zero[128 ]; }; -struct __packed vbe_screen_info_input { +struct __packed vesa_screen_info_input {u8 signature[4 ];u16 size_reserved;u8 monitor_number;
@@ -30,8 +30,11 @@ struct __packed vbe_screen_info_input {u8 color_depth; }; -/* these structs only store the required a subset of the VBE-defined fields */ -struct __packed vbe_info { +/* +* These structs only store the required subset of fields in Vesa BIOS +* Extensions +*/ +struct __packed vesa_bios_ext_info {char signature[4 ];u16 version;u32 oem_string_ptr;
@@ -80,7 +83,7 @@ struct __packed vesa_mode_info {u8 reserved[206 ]; }; -struct vbe_mode_info { +struct vesa_state {u16 video_mode;bool valid;union {
@@ -89,7 +92,7 @@ struct vbe_mode_info { }; }; -struct vbe_ddc_info { +struct vesa_ddc_info {u8 port_number;/* i.e. monitor number */ u8 edid_transfer_time;u8 ddc_level;
@@ -101,13 +104,13 @@ struct vbe_ddc_info {#define VESA_SET_MODE 0x4f02#define VESA_GET_CUR_MODE 0x4f03 -extern struct vbe_mode_info mode_info; +extern struct vesa_state mode_info;struct video_priv ;struct video_uc_plat ; -int vbe_setup_video_priv (struct vesa_mode_info *vesa, -struct video_priv *uc_priv, -struct video_uc_plat *plat); -int vbe_setup_video (struct udevice *dev,int (*int15_handler)(void )); +int vesa_setup_video_priv (struct vesa_mode_info *vesa, +struct video_priv *uc_priv, +struct video_uc_plat *plat); +int vesa_setup_video (struct udevice *dev,int (*int15_handler)(void ));#endif
Signature · 1 line
2.37.0.170.g444d1eabd0-goog
PATCH 3/19 dm: core: Split out the declaration of ofnode
In reply to Simon GlassThis is used by a lot of files, but ofnode.h needs to include a lot of header files. This can create dependency cycles, particularly with global_data.h which must include various declarations.
Split the core delcarations into a separate file to fix this.
---
include/dm/ofnode.h | 61 +--------------------------------- include/dm/ofnode_decl.h | 72 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 60 deletions(-) create mode 100644 include/dm/ofnode_decl.h
include/dm/ofnode.h +1 -60
@@ -19,41 +19,7 @@struct resource ; -/** -* typedef union ofnode_union ofnode - reference to a device tree node -* -* This union can hold either a straightforward pointer to a struct device_node -* in the live device tree, or an offset within the flat device tree. In the -* latter case, the pointer value is just the integer offset within the flat DT. -* -* Thus we can reference nodes in both the live tree (once available) and the -* flat tree (until then). Functions are available to translate between an -* ofnode and either an offset or a `struct device_node *`. -* -* The reference can also hold a null offset, in which case the pointer value -* here is NULL. This corresponds to a struct device_node * value of -* NULL, or an offset of -1. -* -* There is no ambiguity as to whether ofnode holds an offset or a node -* pointer: when the live tree is active it holds a node pointer, otherwise it -* holds an offset. The value itself does not need to be unique and in theory -* the same value could point to a valid device node or a valid offset. We -* could arrange for a unique value to be used (e.g. by making the pointer -* point to an offset within the flat device tree in the case of an offset) but -* this increases code size slightly due to the subtraction. Since it offers no -* real benefit, the approach described here seems best. -* -* For now these points use constant types, since we don't allow writing -* the DT. -* -* @np: Pointer to device node, used for live tree -* @of_offset: Pointer into flat device tree, used for flat tree. Note that this -* is not a really a pointer to a node: it is an offset value. See above. -*/ -typedef union ofnode_union { -const struct device_node *np; -long of_offset; -}ofnode ; +#include <dm/ofnode_decl.h> struct ofnode_phandle_args {ofnode node;
@@ -61,31 +27,6 @@ struct ofnode_phandle_args {uint32_t args[OF_MAX_PHANDLE_ARGS ]; }; -/** -* struct ofprop - reference to a property of a device tree node -* -* This struct hold the reference on one property of one node, -* using struct ofnode and an offset within the flat device tree or either -* a pointer to a struct property in the live device tree. -* -* Thus we can reference arguments in both the live tree and the flat tree. -* -* The property reference can also hold a null reference. This corresponds to -* a struct property NULL pointer or an offset of -1. -* -* @node: Pointer to device node -* @offset: Pointer into flat device tree, used for flat tree. -* @prop: Pointer to property, used for live treee. -*/ - -struct ofprop { -ofnode node; -union { -int offset; -const struct property *prop; - }; -}; -/** * ofnode_to_np() - convert an ofnode to a live DT node pointer *
include/dm/ofnode_decl.h new file +72 -0
72 lines not on this page · raw message
Signature · 1 line
2.37.0.170.g444d1eabd0-goog
PATCH 4/19 ofnode: Add a note about how livetree updates work
In reply to Simon GlassThe unflattening algorithm results in a single block of memory being allocated for the whole tree. When writing new properties, these are allocated new memory outside that block. When the block is freed, the allocated properties remain.
Document how this works and the potential memory leak, as well as mentioning that updating the livetree is actually supported now.
---
doc/develop/driver-model/livetree.rst | 17 +++++++++++++---- include/dm/ofnode.h | 3 ++- 2 files changed, 15 insertions(+), 5 deletions(-)
doc/develop/driver-model/livetree.rst +13 -4
@@ -211,9 +211,18 @@ using it in new code. Modifying the livetree ---------------------- -This is not currently supported. Once implemented it should provide a much -more efficient implementation for modification of the device tree than using -the flat tree. +This is supported in a limited way, with ofnode_write_prop() and related +functions. + +The unflattening algorithm results in a single block of memory being +allocated for the whole tree. When writing new properties, these are +allocated new memory outside that block. When the block is freed, the +allocated properties remain. This can result in a memory leak. + +The solution to this leak would be to add a flag for properties (and nodes when +support is provided for adding those) that indicates that they should be +freed. Then the tree can be scanned for these 'separately allocated' nodes and +properties before freeing the memory block. Internal implementation
@@ -281,6 +290,6 @@ Live tree support was introduced in U-Boot 2017.07. There is still quite a bit of work to do to flesh this out: - tests for all access functions -- support for livetree modification +- more support for livetree modification - addition of more access functions as needed - support for livetree in SPL and before relocation (if desired)
include/dm/ofnode.h +2 -1
@@ -1081,7 +1081,8 @@ int ofnode_device_is_compatible(ofnode node, const char *compat);* ofnode_write_prop() - Set a property of a ofnode * * Note that the value passed to the function is *not* allocated by the -* function itself, but must be allocated by the caller if necessary. +* function itself, but must be allocated by the caller if necessary. However +* it does allocate memory for the property struct and name. * * @node: The node for whose property should be set * @propname: The name of the property to set
Signature · 1 line
2.37.0.170.g444d1eabd0-goog
PATCH 5/19 ofnode: Introduce support for multiple trees
In reply to Simon GlassAt present ofnode only works with a single device tree, for the most part. This is the control FDT used by U-Boot.
When booting an OS we may obtain a different device tree and want to modify it. Add some initial support for this into the ofnode API.
Note that we don't permit aliases in this other device tree, since the of_access implementation maintains a list of aliases collected at start-up. Also, we don't need aliases to do fixups in the other FDT. So make sure that flat tree and live tree processing are consistent in this area.
---
doc/develop/driver-model/livetree.rst | 17 +++++++ drivers/core/of_access.c | 14 ++++-- drivers/core/ofnode.c | 11 +++++ include/dm/of_access.h | 10 +++- include/dm/ofnode.h | 28 +++++++++++ include/dm/ofnode_decl.h | 13 ++++++ include/of_live.h | 16 +++++++ lib/of_live.c | 14 +----- test/dm/ofnode.c | 67 +++++++++++++++++++++++++++ 9 files changed, 171 insertions(+), 19 deletions(-)
doc/develop/driver-model/livetree.rst +17 -0
@@ -225,6 +225,23 @@ freed. Then the tree can be scanned for these 'separately allocated' nodes and properties before freeing the memory block. +Multiple livetrees +------------------ + +The livetree implementation was originally designed for use with the control +FDT. This means that the FDT fix-ups (ft_board_setup() and the like, must use +a flat tree. + +It would be helpful to use livetree for fixups, since adding a lot of nodes and +properties would involve less memory copying and be more efficient. As a step +towards this, an `oftree` type has been introduced. It is normally set to +oftree_default() but can be set to other values. Eventually this should allow +the use of FDT fixups using the ofnode interface, instead of the low-level +libfdt one. + +See dm_test_ofnode_root() for some examples. + + Internal implementation -----------------------
drivers/core/of_access.c +10 -4
@@ -343,24 +343,30 @@ static struct device_node *__of_find_node_by_path(struct device_node *parent,#define for_each_property_of_node (dn, pp) \ for (pp = dn->properties; pp != NULL; pp = pp->next) -struct device_node *of_find_node_opts_by_path (const char *path, +struct device_node *of_find_node_opts_by_path (struct device_node *root, +const char *path,const char **opts) {struct device_node *np =NULL ;struct property *pp;const char *separator =strchr (path,':' ); +if (!root) + root = gd->of_root;if (opts) *opts = separator ? separator +1 :NULL ;if (strcmp (path,"/" ) ==0 ) -return of_node_get (gd->of_root); +return of_node_get (root);/* The path could begin with an alias */ if (*path !='/' ) {int len;const char *p = separator; +/* Only allow alias processing on the control FDT */ +if (root != gd->of_root) +return NULL ;if (!p) p =strchrnul (path,'/' ); len = p - path;
@@ -383,7 +389,7 @@ struct device_node *of_find_node_opts_by_path(const char *path,/* Step down the tree matching path components */ if (!np) - np =of_node_get (gd->of_root); + np =of_node_get (root);while (np && *path =='/' ) {struct device_node *tmp = np;
@@ -791,7 +797,7 @@ int of_alias_scan(void) name =of_get_property (of_chosen,"stdout-path" ,NULL );if (name) - of_stdout =of_find_node_opts_by_path (name, + of_stdout =of_find_node_opts_by_path (NULL , name, &of_stdout_options); }
drivers/core/ofnode.c +11 -0
@@ -552,6 +552,17 @@ ofnode ofnode_path(const char *path)return offset_to_ofnode (fdt_path_offset (gd->fdt_blob, path)); } +ofnode ofnode_path_root (oftree tree,const char *path) +{ +if (of_live_active ()) +return np_to_ofnode (of_find_node_opts_by_path (tree.np, path, +NULL )); +else if (*path !='/' && tree.fdt != gd->fdt_blob) +return ofnode_null ();/* Aliases only on control FDT */ +else +return offset_to_ofnode (fdt_path_offset (tree.fdt, path)); +} +const void *ofnode_read_chosen_prop (const char *propname,int *sizep) {ofnode chosen_node;
include/dm/of_access.h +8 -2
@@ -197,6 +197,11 @@ struct device_node *of_get_parent(const struct device_node *np);/** * of_find_node_opts_by_path() - Find a node matching a full OF path * +* Note that alias processing is only available on the control FDT (gd->of_root). +* For other trees it is skipped, so any attempt to obtain an alias will result +* in returning NULL. +* +* @root: Root node of the tree to use. If this is NULL, then gd->of_root is used * @path: Either the full path to match, or if the path does not start with * '/', the name of a property of the /aliases node (an alias). In the * case of an alias, the node matching the alias' value will be returned.
@@ -210,12 +215,13 @@ struct device_node *of_get_parent(const struct device_node *np);* * Return: a node pointer or NULL if not found */ -struct device_node *of_find_node_opts_by_path (const char *path, +struct device_node *of_find_node_opts_by_path (struct device_node *root, +const char *path,const char **opts);static inline struct device_node *of_find_node_by_path (const char *path) { -return of_find_node_opts_by_path (path,NULL ); +return of_find_node_opts_by_path (NULL , path,NULL ); }/**
include/dm/ofnode.h +28 -0
@@ -176,6 +176,23 @@ static inline ofnode ofnode_root(void)return node; } +/** +* oftree_default() - Returns the default device tree (U-Boot's control FDT) +* +* Returns: reference to the control FDT +*/ +static inline oftree oftree_default (void ) +{ +oftree tree; + +if (of_live_active ()) + tree.np =gd_of_root (); +else + tree.fdt = (void *)gd->fdt_blob; + +return tree; +} +/** * ofnode_name_eq() - Check if the node name is equivalent to a given name * ignoring the unit address
@@ -640,11 +657,22 @@ int ofnode_count_phandle_with_args(ofnode node, const char *list_name,/** * ofnode_path() - find a node by full path * +* This uses the control FDT. +* * @path: Full path to node, e.g. "/bus/spi@1" * Return: reference to the node found. Use ofnode_valid() to check if it exists */ ofnode ofnode_path (const char *path); +/** +* ofnode_path_root() - find a node by full path from a root node +* +* @tree: Device tree to use +* @path: Full path to node, e.g. "/bus/spi@1" +* Return: reference to the node found. Use ofnode_valid() to check if it exists +*/ +ofnode ofnode_path_root (oftree tree,const char *path); +/** * ofnode_read_chosen_prop() - get the value of a chosen property *
include/dm/ofnode_decl.h +13 -0
@@ -68,5 +68,18 @@ struct ofprop { }; }; +/** +* union oftree_union - reference to a tree of device tree nodes +* +* One or other of the members is used, depending on of_live_active() +* +* @np: Pointer to roott device node, used for live tree +* @fdt: Pointer to the flat device tree, used for flat tree +*/ +typedef union oftree_union { +struct device_node *np; +void *fdt; +}oftree ; +#endif
include/of_live.h +16 -0
@@ -20,4 +20,20 @@ struct device_node;*/ int of_live_build (const void *fdt_blob,struct device_node **rootp); +/** +* unflatten_device_tree() - create tree of device_nodes from flat blob +* +* Note that this allocates a single block of memory, pointed to by *mynodes. +* To free the tree, use free(*mynodes) +* +* unflattens a device-tree, creating the +* tree of struct device_node. It also fills the "name" and "type" +* pointers of the nodes so the normal device-tree walking functions +* can be used. +* @blob: The blob to expand +* @mynodes: The device_node tree created by the call +* Return: 0 if OK, -ve on error +*/ +int unflatten_device_tree (const void *blob,struct device_node **mynodes); +#endif
lib/of_live.c +1 -13
@@ -248,19 +248,7 @@ static void *unflatten_dt_node(const void *blob, void *mem, int *poffset,return mem; } -/** -* unflatten_device_tree() - create tree of device_nodes from flat blob -* -* unflattens a device-tree, creating the -* tree of struct device_node. It also fills the "name" and "type" -* pointers of the nodes so the normal device-tree walking functions -* can be used. -* @blob: The blob to expand -* @mynodes: The device_node tree created by the call -* Return: 0 if OK, -ve on error -*/ -static int unflatten_device_tree (const void *blob, -struct device_node **mynodes) +int unflatten_device_tree (const void *blob,struct device_node **mynodes) {unsigned long size;int start;
test/dm/ofnode.c +67 -0
76 lines not on this page · raw message
Signature · 1 line
2.37.0.170.g444d1eabd0-goog
PATCH 6/19 dm: core: Move ofnode-writing test to ofnode
In reply to Simon GlassThis fits better in the ofnode tests, so move it.
---
test/dm/ofnode.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++ test/dm/test-fdt.c | 53 ------------------------------------------- 2 files changed, 56 insertions(+), 53 deletions(-)
test/dm/ofnode.c +56 -0
@@ -4,8 +4,12 @@#include <dm.h> #include <log.h> #include <of_live.h> +#include <dm/device-internal.h> +#include <dm/lists.h> #include <dm/of_extra.h> +#include <dm/root.h> #include <dm/test.h> +#include <dm/uclass-internal.h> #include <test/test.h> #include <test/ut.h>
@@ -536,3 +540,55 @@ static int dm_test_ofnode_root(struct unit_test_state *uts)return 0 ; }DM_TEST (dm_test_ofnode_root,UT_TESTF_SCAN_FDT ); + +static int dm_test_ofnode_livetree_writing (struct unit_test_state *uts) +{ +struct udevice *dev; +ofnode node; + +if (!of_live_active ()) { +printf ("Live tree not active; ignore test\n" ); +return 0 ; + } + +/* Test enabling devices */ + + node =ofnode_path ("/usb@2" ); + +ut_assert (!of_device_is_available (ofnode_to_np (node))); +ofnode_set_enabled (node, true); +ut_assert (of_device_is_available (ofnode_to_np (node))); + +device_bind_driver_to_node (dm_root (),"usb_sandbox" ,"usb@2" , node, + &dev); +ut_assertok (uclass_find_device_by_seq (UCLASS_USB ,2 , &dev)); + +/* Test string property setting */ + +ut_assert (device_is_compatible (dev,"sandbox,usb" )); +ofnode_write_string (node,"compatible" ,"gdsys,super-usb" ); +ut_assert (device_is_compatible (dev,"gdsys,super-usb" )); +ofnode_write_string (node,"compatible" ,"sandbox,usb" ); +ut_assert (device_is_compatible (dev,"sandbox,usb" )); + +/* Test setting generic properties */ + +/* Non-existent in DTB */ +ut_asserteq_64 (FDT_ADDR_T_NONE ,dev_read_addr (dev)); +/* reg = 0x42, size = 0x100 */ +ut_assertok (ofnode_write_prop (node,"reg" ,8 , +"\x00\x00\x00\x42\x00\x00\x01\x00" )); +ut_asserteq (0x42 ,dev_read_addr (dev)); + +/* Test disabling devices */ + +device_remove (dev,DM_REMOVE_NORMAL ); +device_unbind (dev); + +ut_assert (of_device_is_available (ofnode_to_np (node))); +ofnode_set_enabled (node, false); +ut_assert (!of_device_is_available (ofnode_to_np (node))); + +return 0 ; +} +DM_TEST (dm_test_ofnode_livetree_writing,UT_TESTF_SCAN_PDATA |UT_TESTF_SCAN_FDT );
test/dm/test-fdt.c +0 -53
65 lines not on this page · raw message
Signature · 1 line
2.37.0.170.g444d1eabd0-goog
PATCH 7/19 dm: core: Swap parameters of ofnode_write_prop()
In reply to Simon GlassIt is normal for the length to come after the value in libfdt. Follow this same convention with ofnode.
---
drivers/core/ofnode.c | 6 +++--- include/dm/ofnode.h | 6 +++--- test/dm/ofnode.c | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-)
drivers/core/ofnode.c +3 -3
@@ -1105,8 +1105,8 @@ ofnode ofnode_by_prop_value(ofnode from, const char *propname, } } -int ofnode_write_prop (ofnode node,const char *propname,int len, -const void *value) +int ofnode_write_prop (ofnode node,const char *propname,const void *value, +int len) {const struct device_node *np =ofnode_to_np (node);struct property *pp;
@@ -1161,7 +1161,7 @@ int ofnode_write_string(ofnode node, const char *propname, const char *value)debug ("%s: %s = %s" , __func__, propname, value); -return ofnode_write_prop (node, propname,strlen (value) +1 , value); +return ofnode_write_prop (node, propname, value,strlen (value) +1 ); }int ofnode_set_enabled (ofnode node,bool value)
include/dm/ofnode.h +3 -3
@@ -1114,13 +1114,13 @@ int ofnode_device_is_compatible(ofnode node, const char *compat);* * @node: The node for whose property should be set * @propname: The name of the property to set -* @len: The length of the new value of the property * @value: The new value of the property (must be valid prior to calling * the function) +* @len: The length of the new value of the property * Return: 0 if successful, -ve on error */ -int ofnode_write_prop (ofnode node,const char *propname,int len, -const void *value); +int ofnode_write_prop (ofnode node,const char *propname,const void *value, +int len);/** * ofnode_write_string() - Set a string property of a ofnode
test/dm/ofnode.c +2 -2
@@ -576,8 +576,8 @@ static int dm_test_ofnode_livetree_writing(struct unit_test_state *uts)/* Non-existent in DTB */ ut_asserteq_64 (FDT_ADDR_T_NONE ,dev_read_addr (dev));/* reg = 0x42, size = 0x100 */ -ut_assertok (ofnode_write_prop (node,"reg" ,8 , -"\x00\x00\x00\x42\x00\x00\x01\x00" )); +ut_assertok (ofnode_write_prop (node,"reg" , +"\x00\x00\x00\x42\x00\x00\x01\x00" ,8 ));ut_asserteq (0x42 ,dev_read_addr (dev));/* Test disabling devices */
Signature · 1 line
2.37.0.170.g444d1eabd0-goog
PATCH 8/19 dm: core: Tidy up ofnode-writing test
In reply to Simon GlassUpdate this test to use the livetree flag so that special check can be avoided. Also drop a few blank lines.
---
test/dm/ofnode.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
test/dm/ofnode.c +2 -9
@@ -546,13 +546,7 @@ static int dm_test_ofnode_livetree_writing(struct unit_test_state *uts)struct udevice *dev;ofnode node; -if (!of_live_active ()) { -printf ("Live tree not active; ignore test\n" ); -return 0 ; - } -/* Test enabling devices */ - node =ofnode_path ("/usb@2" );ut_assert (!of_device_is_available (ofnode_to_np (node)));
@@ -564,7 +558,6 @@ static int dm_test_ofnode_livetree_writing(struct unit_test_state *uts)ut_assertok (uclass_find_device_by_seq (UCLASS_USB ,2 , &dev));/* Test string property setting */ -ut_assert (device_is_compatible (dev,"sandbox,usb" ));ofnode_write_string (node,"compatible" ,"gdsys,super-usb" );ut_assert (device_is_compatible (dev,"gdsys,super-usb" ));
@@ -581,7 +574,6 @@ static int dm_test_ofnode_livetree_writing(struct unit_test_state *uts)ut_asserteq (0x42 ,dev_read_addr (dev));/* Test disabling devices */ -device_remove (dev,DM_REMOVE_NORMAL );device_unbind (dev);
@@ -591,4 +583,5 @@ static int dm_test_ofnode_livetree_writing(struct unit_test_state *uts)return 0 ; } -DM_TEST (dm_test_ofnode_livetree_writing,UT_TESTF_SCAN_PDATA |UT_TESTF_SCAN_FDT ); +DM_TEST (dm_test_ofnode_livetree_writing, +UT_TESTF_SCAN_PDATA |UT_TESTF_SCAN_FDT |UT_TESTF_LIVE_TREE );
Signature · 1 line
2.37.0.170.g444d1eabd0-goog
PATCH 9/19 dm: core: Prepare for updating the device tree with ofnode
In reply to Simon GlassAdd some documentation and a new flag so that we can safely enabled using the ofnode interface to write to the device tree.
---
doc/develop/driver-model/livetree.rst | 26 ++++++++++++++++++++++++++ include/test/test.h | 2 ++ test/test-main.c | 3 ++- 3 files changed, 30 insertions(+), 1 deletion(-)
doc/develop/driver-model/livetree.rst +26 -0
@@ -224,6 +224,32 @@ support is provided for adding those) that indicates that they should be freed. Then the tree can be scanned for these 'separately allocated' nodes and properties before freeing the memory block. +The ofnode_write\_...() functions also support writing to the flat tree. Care +should be taken however, since this can change the position of node names and +properties in the flat tree, thus affecting the live tree. Generally this does +not matter, since when we fire up the live tree we don't ever use the flat tree +again. But in the case of tests, this can cause a problem. + +The sandbox tests typically run with OF_LIVE enabled but with the actual live +tree either present or absent. This is to make sure that the flat tree functions +work correctly even with OF_LIVE is enabled. But if a test modifies the flat +device tree, then the live tree can become invalid. Any live tree tests that run +after that point will use a corrupted tree, e.g. with an incorrect property name +or worse. To deal with this we use a flag UT_TESTF_LIVE_OR_FLAT then ensures +that tests which write to the flat tree are not run if OF_LIVE is enabled. Only +the live tree version of the test is run, when OF_LIVE is enabled, with +sandbox_flattree running the flat tree version. + +This is of course a work-around, even if a reasonable one. One solution to this +problem would be to make a copy of the flat tree before the test and restore it +afterwards, in the same memory location, so that the live tree pointers work +again. Another would be to regenerate the live tree if a test modified the flat +tree. + +Neither of these solutions is currently implemented, since the situation that +causes the problem can only occur in sandbox tests, is somewhat esoteric and +the UT_TESTF_LIVE_OR_FLAT flag deals with it in a reasonable way. + Multiple livetrees ------------------
include/test/test.h +2 -0
@@ -46,6 +46,8 @@ enum {UT_TESTF_CONSOLE_REC =BIT (5 ),/* needs console recording */ /* do extra driver model init and uninit */ UT_TESTF_DM =BIT (6 ), +/* live or flat device tree, but not both in the same executable */ + UT_TESTF_LIVE_OR_FLAT = BIT(4), };/**
test/test-main.c +2 -1
@@ -338,7 +338,8 @@ static int ut_run_test_live_flat(struct unit_test_state *uts,/* Run with the live tree if possible */ runs =0 ;if (CONFIG_IS_ENABLED (OF_LIVE )) { -if (!(test->flags &UT_TESTF_FLAT_TREE )) { +if (!(test->flags & + (UT_TESTF_FLAT_TREE |UT_TESTF_LIVE_OR_FLAT ))) { uts->of_live = true;ut_assertok (ut_run_test (uts, test, test->name)); runs++;
Signature · 1 line
2.37.0.170.g444d1eabd0-goog
PATCH 10/19 ofnode: Allow writing to a flat tree
In reply to Simon GlassIn generally it is not permitted to implement an ofnode function only for flat tree or live tree. Both must be supported. Also the code for live tree access should be in of_access.c rather than ofnode.c which is really just for holding the API-conversion code.
Update ofnode_write_prop() accordingly and fix the test so it can work with flat tree too.
---
drivers/core/of_access.c | 43 +++++++++++++++++++++++++++++++++ drivers/core/ofnode.c | 51 ++++------------------------------------ include/dm/of_access.h | 12 ++++++++++ include/dm/ofnode.h | 18 ++++++++++++++ test/dm/ofnode.c | 14 +++++------ 5 files changed, 85 insertions(+), 53 deletions(-)
drivers/core/of_access.c +43 -0
@@ -887,3 +887,46 @@ struct device_node *of_get_stdout(void) {return of_stdout; } + +int of_write_prop (struct device_node *np,const char *propname,int len, +const void *value) +{ +struct property *pp; +struct property *pp_last =NULL ; +struct property *new; + +if (!np) +return -EINVAL ; + +for (pp = np->properties; pp; pp = pp->next) { +if (strcmp (pp->name, propname) ==0 ) { +/* Property exists -> change value */ + pp->value = (void *)value; + pp->length = len; +return 0 ; + } + pp_last = pp; + } + +if (!pp_last) +return -ENOENT ; + +/* Property does not exist -> append new property */ + new =malloc (sizeof (struct property )); +if (!new) +return -ENOMEM ; + + new->name =strdup (propname); +if (!new->name) { +free (new); +return -ENOMEM ; + } + + new->value = (void *)value; + new->length = len; + new->next =NULL ; + + pp_last->next = new; + +return 0 ; +}
drivers/core/ofnode.c +5 -46
69 lines not on this page · raw message
include/dm/of_access.h +12 -0
@@ -519,4 +519,16 @@ int of_alias_get_highest_id(const char *stem);*/ struct device_node *of_get_stdout (void ); +/** +* of_write_prop() - Write a property to the device tree +* +* @np: device node to which the property value is to be written +* @propname: name of the property to write +* @value: value of the property +* @len: length of the property in bytes +* Returns: 0 if OK, -ve on error +*/ +int of_write_prop (struct device_node *np,const char *propname,int len, +const void *value); +#endif
include/dm/ofnode.h +18 -0
@@ -44,6 +44,24 @@ static inline const struct device_node *ofnode_to_np(ofnode node)return node.np; } +/** +* ofnode_to_npw() - convert an ofnode to a writeable live DT node pointer +* +* This cannot be called if the reference contains an offset. +* +* @node: Reference containing struct device_node * (possibly invalid) +* Return: pointer to device node (can be NULL) +*/ +static inline struct device_node *ofnode_to_npw (ofnode node) +{ +#ifdef OF_CHECKS +if (!of_live_active ()) +return NULL ; +#endif +/* Drop constant */ +return (struct device_node *)node.np; +} +/** * ofnode_to_offset() - convert an ofnode to a flat DT offset *
test/dm/ofnode.c +7 -7
@@ -549,9 +549,9 @@ static int dm_test_ofnode_livetree_writing(struct unit_test_state *uts)/* Test enabling devices */ node =ofnode_path ("/usb@2" ); -ut_assert (!of_device_is_available (ofnode_to_np (node))); -ofnode_set_enabled (node, true); -ut_assert (of_device_is_available (ofnode_to_np (node))); +ut_assert (!ofnode_is_enabled (node)); +ut_assertok (ofnode_set_enabled (node, true)); +ut_asserteq (true,ofnode_is_enabled (node));device_bind_driver_to_node (dm_root (),"usb_sandbox" ,"usb@2" , node, &dev);
@@ -577,11 +577,11 @@ static int dm_test_ofnode_livetree_writing(struct unit_test_state *uts)device_remove (dev,DM_REMOVE_NORMAL );device_unbind (dev); -ut_assert (of_device_is_available (ofnode_to_np (node))); -ofnode_set_enabled (node, false); -ut_assert (!of_device_is_available (ofnode_to_np (node))); +ut_assert (ofnode_is_enabled (node)); +ut_assertok (ofnode_set_enabled (node, false)); +ut_assert (!ofnode_is_enabled (node));return 0 ; }DM_TEST (dm_test_ofnode_livetree_writing, -UT_TESTF_SCAN_PDATA |UT_TESTF_SCAN_FDT |UT_TESTF_LIVE_TREE ); +UT_TESTF_SCAN_PDATA |UT_TESTF_SCAN_FDT |UT_TESTF_LIVE_OR_FLAT );
Signature · 1 line
2.37.0.170.g444d1eabd0-goog
PATCH 11/19 dm: core: Add support for writing u32 with ofnode
In reply to Simon GlassAdd a new function to write an integer to an ofnode (live tree or flat tree).
---
drivers/core/ofnode.c | 15 +++++++++++++++ include/dm/ofnode.h | 10 ++++++++++ test/dm/ofnode.c | 16 ++++++++++++++++ 3 files changed, 41 insertions(+)
drivers/core/ofnode.c +15 -0
@@ -1126,6 +1126,21 @@ int ofnode_write_string(ofnode node, const char *propname, const char *value)return ofnode_write_prop (node, propname, value,strlen (value) +1 ); } +int ofnode_write_u32 (ofnode node,const char *propname,u32 value) +{ +fdt32_t *val; + +assert (ofnode_valid (node)); + +log_debug ("%s = %x" , propname, value); + val =malloc (sizeof (*val)); +if (!val) +return -ENOMEM ; + *val =cpu_to_fdt32 (value); + +return ofnode_write_prop (node, propname, val,sizeof (value)); +} +int ofnode_set_enabled (ofnode node,bool value) {assert (ofnode_valid (node));
include/dm/ofnode.h +10 -0
@@ -1154,6 +1154,16 @@ int ofnode_write_prop(ofnode node, const char *propname, const void *value,*/ int ofnode_write_string (ofnode node,const char *propname,const char *value); +/** +* ofnode_write_u32() - Set an integer property of an ofnode +* +* @node: The node for whose string property should be set +* @propname: The name of the string property to set +* @value: The new value of the 32-bit integer property +* Return: 0 if successful, -ve on error +*/ +int ofnode_write_u32 (ofnode node,const char *propname,u32 value); +/** * ofnode_set_enabled() - Enable or disable a device tree node given by its * ofnode
test/dm/ofnode.c +16 -0
@@ -585,3 +585,19 @@ static int dm_test_ofnode_livetree_writing(struct unit_test_state *uts) }DM_TEST (dm_test_ofnode_livetree_writing,UT_TESTF_SCAN_PDATA |UT_TESTF_SCAN_FDT |UT_TESTF_LIVE_OR_FLAT ); + +static int dm_test_ofnode_u32 (struct unit_test_state *uts) +{ +ofnode node; + + node =ofnode_path ("/lcd" ); +ut_assert (ofnode_valid (node)); +ut_asserteq (1366 ,ofnode_read_u32_default (node,"xres" ,123 )); +ut_assertok (ofnode_write_u32 (node,"xres" ,1367 )); +ut_asserteq (1367 ,ofnode_read_u32_default (node,"xres" ,123 )); +ut_assertok (ofnode_write_u32 (node,"xres" ,1366 )); + +return 0 ; +} +DM_TEST (dm_test_ofnode_u32, +UT_TESTF_SCAN_PDATA |UT_TESTF_SCAN_FDT |UT_TESTF_LIVE_OR_FLAT );
Signature · 1 line
2.37.0.170.g444d1eabd0-goog
PATCH 12/19 event: Add an event for device tree fixups
In reply to Simon GlassAt present there is a confusing array of functions that handle the device tree fix-ups needed for booting an OS. We should be able to switch to using events to clean this up.
As a first step, create a new event type and call it from the standard place.
Note that this event uses the ofnode interface only, since this can support live tree which is more efficient when making lots of updates.
---
boot/image-fdt.c | 11 +++++++++++ common/event.c | 3 +++ include/event.h | 14 ++++++++++++++ test/py/tests/test_event_dump.py | 1 + 4 files changed, 29 insertions(+)
boot/image-fdt.c +11 -0
@@ -21,6 +21,7 @@#include <linux/libfdt.h> #include <mapmem.h> #include <asm/io.h> +#include <dm/ofnode.h> #include <tee/optee.h> #ifndef CONFIG_SYS_FDT_PAD
@@ -668,6 +669,16 @@ int image_setup_libfdt(bootm_headers_t *images, void *blob, goto err; } } +if (CONFIG_IS_ENABLED (EVENT )) { +struct event_ft_fixup fixup; + + fixup.tree =oftree_default (); + ret =event_notify (EVT_FT_FIXUP , &fixup,sizeof (fixup)); +if (ret) { +printf ("ERROR: fdt fixup event failed: %d\n" , ret); + goto err; + } + }/* Delete the old LMB reservation */ if (lmb)
common/event.c +3 -0
@@ -35,6 +35,9 @@ const char *const type_name[] = {/* init hooks */ "misc_init_f" , + +/* fdt hooks */ +"ft_fixup" , };_Static_assert (ARRAY_SIZE (type_name) ==EVT_COUNT ,"event type_name size" );
include/event.h +14 -0
@@ -10,6 +10,8 @@#ifndef __event_h#define __event_h +#include <dm/ofnode_decl.h> +/** * enum event_t - Types of events supported by U-Boot *
@@ -29,6 +31,9 @@ enum event_t {/* Init hooks */ EVT_MISC_INIT_F , +/* Device tree fixups before booting */ +EVT_FT_FIXUP , + EVT_COUNT };
@@ -50,6 +55,15 @@ union event_data {struct event_dm {struct udevice *dev; } dm; + +/** +* struct event_ft_fixup - FDT fixup before booting +* +* @tree: tree to update +*/ +struct event_ft_fixup { +oftree tree; + } ft_fixup; };/**
test/py/tests/test_event_dump.py +1 -0
@@ -16,5 +16,6 @@ def test_event_dump(u_boot_console): out = util.run_and_log(cons, ['scripts/event_dump.py', sandbox]) expect = '''.*Event type Id Source location -------------------- ------------------------------ ------------------------------ +EVT_FT_FIXUP bootmeth_vbe_simple_ft_fixup boot/vbe_simple.c:.* EVT_MISC_INIT_F sandbox_misc_init_f .*arch/sandbox/cpu/start.c:''' assert re.match(expect, out, re.MULTILINE) is not None
Signature · 1 line
2.37.0.170.g444d1eabd0-goog
PATCH 13/19 read: Support sandbox
In reply to Simon GlassUpdate the 'read' command to work correctly with sandbox.
---
cmd/read.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
cmd/read.c +2 -1
@@ -10,6 +10,7 @@#include <common.h> #include <command.h> +#include <mapmem.h> #include <part.h> int do_read (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[])
@@ -45,7 +46,7 @@ int do_read(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])return 1 ; } - addr = (void *)hextoul (argv[3 ],NULL ); + addr =map_sysmem (hextoul (argv[3 ],NULL ),0 ); blk =hextoul (argv[4 ],NULL ); cnt =hextoul (argv[5 ],NULL );
Signature · 1 line
2.37.0.170.g444d1eabd0-goog
PATCH 14/19 bootstd: Fix comment in bootmeth test
In reply to Simon GlassCorrect the comment at the top of this file.
---
test/boot/bootmeth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
test/boot/bootmeth.c +1 -1
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0+ /* -* Test for bootdev functions. All start with 'bootdev' +* Test for bootdev functions. All start with 'bootmeth' * * Copyright 2021 Google LLC * Written by Simon Glass <[email protected]>
Signature · 1 line
2.37.0.170.g444d1eabd0-goog
PATCH 15/19 bootstd: Detect empty bootmeth ordering
In reply to Simon GlassIf the ordering produces no entries, this is an error. Report it, so that the caller doesn't try to continue with a NULL bootmeth.
This fixes a crash in the bootflow_iter test when running with the sandbox 'default' device tree, instead of the required 'test' one.
---
boot/bootmeth-uclass.c | 2 ++ 1 file changed, 2 insertions(+)
boot/bootmeth-uclass.c +2 -0
@@ -114,6 +114,8 @@ int bootmeth_setup_iter_order(struct bootflow_iter *iter) } count = upto; } +if (!count) +return log_msg_ret ("count2" , -ENOENT ); iter->method_order = order; iter->num_methods = count;
Signature · 1 line
2.37.0.170.g444d1eabd0-goog
PATCH 16/19 bootstd: Provide a bootmeth method to obtain state info
In reply to Simon GlassSome bootmeths can provide information about what is available to boot. For example, VBE simple provides access to the firmware state.
Add a new method for this, along with a sandbox test.
---
boot/bootmeth-uclass.c | 10 ++++++++++ boot/bootmeth_distro.c | 14 ++++++++++++++ include/bootmeth.h | 38 +++++++++++++++++++++++++++++++++++++- test/boot/bootmeth.c | 18 ++++++++++++++++++ 4 files changed, 79 insertions(+), 1 deletion(-)
boot/bootmeth-uclass.c +10 -0
@@ -20,6 +20,16 @@DECLARE_GLOBAL_DATA_PTR ; +int bootmeth_get_state_desc (struct udevice *dev,char *buf,int maxsize) +{ +const struct bootmeth_ops *ops =bootmeth_get_ops (dev); + +if (!ops->get_state_desc) +return -ENOSYS ; + +return ops->get_state_desc (dev, buf, maxsize); +} +int bootmeth_check (struct udevice *dev,struct bootflow_iter *iter) {const struct bootmeth_ops *ops =bootmeth_get_ops (dev);
boot/bootmeth_distro.c +14 -0
@@ -22,6 +22,19 @@#include <mmc.h> #include <pxe_utils.h> +static int distro_get_state_desc (struct udevice *dev,char *buf,int maxsize) +{ +if (IS_ENABLED (CONFIG_SANDBOX )) { +int len; + + len =snprintf (buf, maxsize,"OK" ); + +return len +1 < maxsize ?0 : -ENOSPC ; + } + +return 0 ; +} +static int disto_getfile (struct pxe_context *ctx,const char *file_path,char *file_addr,ulong *sizep) {
@@ -123,6 +136,7 @@ static int distro_bootmeth_bind(struct udevice *dev) }static struct bootmeth_ops distro_bootmeth_ops = { + .get_state_desc = distro_get_state_desc, .check = distro_check, .read_bootflow = distro_read_bootflow, .read_file = bootmeth_common_read_file,
include/bootmeth.h +37 -1
@@ -24,7 +24,25 @@ struct bootmeth_uc_plat {/** struct bootmeth_ops - Operations for boot methods */ struct bootmeth_ops {/** -* check_supported() - check if a bootmeth supports this bootflow +* get_state_desc() - get detailed state information +* +* Prodecues a textual description of the state of the bootmeth. This +* can include newline characters if it extends to multiple lines. It +* must be a nul-terminated string. +* +* This may involve reading state from the system, e.g. some data in +* the firmware area. +* +* @dev: Bootmethod device to check +* @buf: Buffer to place the info in (terminator must fit) +* @maxsize: Size of buffer +* Returns: 0 if OK, -ENOSPC is buffer is too small, other -ve error if +* something else went wrong +*/ +int (*get_state_desc)(struct udevice *dev,char *buf,int maxsize); + +/** +* check_supported() - check if a bootmeth supports this bootdev * * This is optional. If not provided, the bootdev is assumed to be * supported
@@ -91,6 +109,24 @@ struct bootmeth_ops {#define bootmeth_get_ops (dev) ((struct bootmeth_ops *)(dev)->driver->ops) +/** +* bootmeth_get_state_desc() - get detailed state information +* +* Prodecues a textual description of the state of the bootmeth. This +* can include newline characters if it extends to multiple lines. It +* must be a nul-terminated string. +* +* This may involve reading state from the system, e.g. some data in +* the firmware area. +* +* @dev: Bootmethod device to check +* @buf: Buffer to place the info in (terminator must fit) +* @maxsize: Size of buffer +* Returns: 0 if OK, -ENOSPC is buffer is too small, other -ve error if +* something else went wrong +*/ +int bootmeth_get_state_desc (struct udevice *dev,char *buf,int maxsize); +/** * bootmeth_check() - check if a bootmeth supports this bootflow *
test/boot/bootmeth.c +18 -0
@@ -7,7 +7,9 @@*/ #include <common.h> +#include <bootmeth.h> #include <bootstd.h> +#include <dm.h> #include <test/suites.h> #include <test/ut.h> #include "bootstd_common.h"
@@ -120,3 +122,19 @@ static int bootmeth_env(struct unit_test_state *uts)return 0 ; }BOOTSTD_TEST (bootmeth_env,UT_TESTF_DM |UT_TESTF_SCAN_FDT ); + +/* Check the get_state_desc() method */ +static int bootmeth_state (struct unit_test_state *uts) +{ +struct udevice *dev; +char buf[50 ]; + +ut_assertok (uclass_first_device (UCLASS_BOOTMETH , &dev)); +ut_assertnonnull (dev); + +ut_assertok (bootmeth_get_state_desc (dev, buf,sizeof (buf))); +ut_asserteq_str ("OK" , buf); + +return 0 ; +} +BOOTSTD_TEST (bootmeth_state,UT_TESTF_DM |UT_TESTF_SCAN_FDT );
Signature · 1 line
2.37.0.170.g444d1eabd0-goog
PATCH 17/19 vbe: Add initial support for VBE
In reply to Simon GlassCreate a new bootmeth for VBE along with a library to handle finding the VBE methods.
---
boot/Kconfig | 9 ++++ boot/Makefile | 2 + boot/vbe.c | 119 ++++++++++++++++++++++++++++++++++++++++++++++ include/bootstd.h | 2 + include/vbe.h | 47 ++++++++++++++++++ 5 files changed, 179 insertions(+) create mode 100644 boot/vbe.c create mode 100644 include/vbe.h
boot/Kconfig +9 -0
@@ -385,6 +385,15 @@ config BOOTMETH_EFILOADER This provides a way to try out standard boot on an existing boot flow. +config BOOTMETH_VBE + bool "Bootdev support for Verified Boot for Embedded" + depends on FIT + default y + help + Enables support for VBE boot. This is a standard boot method which + supports selection of various firmware components, seleciton of an OS to + boot as well as updating these using fwupd. + config BOOTMETH_SANDBOX def_bool y depends on SANDBOX
boot/Makefile +2 -0
@@ -47,3 +47,5 @@ obj-$(CONFIG_CMD_ADTIMG) += image-android-dt.o ifdef CONFIG_SPL_BUILD obj-$(CONFIG_SPL_LOAD_FIT) += common_fit.o endif + +obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_VBE) += vbe.o
boot/vbe.c new file +119 -0
119 lines not on this page · raw message
include/bootstd.h +2 -0
@@ -26,6 +26,7 @@ struct udevice;* @glob_head: Head for the global list of all bootflows across all bootdevs * @bootmeth_count: Number of bootmeth devices in @bootmeth_order * @bootmeth_order: List of bootmeth devices to use, in order, NULL-terminated +* @vbe_bootmeth: Currently selected VBE bootmeth, NULL if none */ struct bootstd_priv {const char **prefixes;
@@ -35,6 +36,7 @@ struct bootstd_priv {struct list_head glob_head;int bootmeth_count;struct udevice **bootmeth_order; +struct udevice *vbe_bootmeth; };/**
include/vbe.h new file +47 -0
47 lines not on this page · raw message
Signature · 1 line
2.37.0.170.g444d1eabd0-goog
PATCH 18/19 vbe: Support VBE simple
In reply to Simon GlassAdd support for VBE simple, which permits firmware update of a single image stored in MMC or another block device.
---
boot/Kconfig | 12 ++ boot/Makefile | 1 + boot/vbe_simple.c | 304 +++++++++++++++++++++++++++++++ test/py/tests/test_event_dump.py | 2 +- 4 files changed, 318 insertions(+), 1 deletion(-) create mode 100644 boot/vbe_simple.c
boot/Kconfig +12 -0
@@ -394,6 +394,18 @@ config BOOTMETH_VBE supports selection of various firmware components, seleciton of an OS to boot as well as updating these using fwupd. +if BOOTMETH_VBE + +config BOOTMETH_VBE_SIMPLE + bool "Bootdev support for VBE 'simple' method" + default y + help + Enables support for VBE 'simple' boot. This allows updating a single + firmware image in boot media such as MMC. It does not support any sort + of rollback, recovery or A/B boot. + +endif # BOOTMETH_VBE + config BOOTMETH_SANDBOX def_bool y depends on SANDBOX
boot/Makefile +1 -0
@@ -49,3 +49,4 @@ obj-$(CONFIG_SPL_LOAD_FIT) += common_fit.o endif obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_VBE) += vbe.o +obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_VBE_SIMPLE) += vbe_simple.o
boot/vbe_simple.c new file +304 -0
304 lines not on this page · raw message
test/py/tests/test_event_dump.py +1 -1
@@ -16,6 +16,6 @@ def test_event_dump(u_boot_console): out = util.run_and_log(cons, ['scripts/event_dump.py', sandbox]) expect = '''.*Event type Id Source location -------------------- ------------------------------ ------------------------------ -EVT_FT_FIXUP bootmeth_vbe_simple_ft_fixup boot/vbe_simple.c:.* +EVT_FT_FIXUP bootmeth_vbe_simple_ft_fixup .*boot/vbe_simple.c:.* EVT_MISC_INIT_F sandbox_misc_init_f .*arch/sandbox/cpu/start.c:''' assert re.match(expect, out, re.MULTILINE) is not None
Signature · 1 line
2.37.0.170.g444d1eabd0-goog
PATCH 19/19 vbe: Add a new vbe command
In reply to Simon GlassAdd a command to look at VBE methods and their status. Provide a test for all of this as well.
---
arch/sandbox/dts/sandbox.dtsi | 13 ++++ arch/sandbox/dts/test.dts | 15 +++++ cmd/Kconfig | 10 +++ cmd/Makefile | 1 + cmd/vbe.c | 87 +++++++++++++++++++++++++ test/boot/Makefile | 4 ++ test/boot/bootflow.c | 53 ++++++++++------ test/boot/bootmeth.c | 11 ++-- test/boot/vbe_simple.c | 115 ++++++++++++++++++++++++++++++++++ 9 files changed, 285 insertions(+), 24 deletions(-) create mode 100644 cmd/vbe.c create mode 100644 test/boot/vbe_simple.c
arch/sandbox/dts/sandbox.dtsi +13 -0
@@ -12,6 +12,19 @@ chosen { stdout-path = "/serial"; + + fwupd { + compatible = "simple-bus"; + firmware { + compatible = "fwupd,vbe-simple"; + cur-version = "1.2.3"; + bootloader-version = "2022.01"; + storage = "mmc1"; + area-start = <0x0>; + area-size = <0x1000000>; + skip-offset = <0x8000>; + }; + }; }; audio: audio-codec {
arch/sandbox/dts/test.dts +15 -0
@@ -1378,6 +1378,21 @@ compatible = "denx,u-boot-fdt-test"; reg = <9 1>; }; + + fwupd { + compatible = "simple-bus"; + firmware0 { + compatible = "fwupd,vbe-simple"; + storage = "mmc1"; + area-start = <0x400>; + area-size = <0x1000>; + skip-offset = <0x200>; + state-offset = <0x400>; + state-size = <0x40>; + version-offset = <0x800>; + version-size = <0x100>; + }; + }; }; translation-test@8000 {
cmd/Kconfig +10 -0
@@ -328,6 +328,16 @@ config BOOTM_RTEMS help Support booting RTEMS images via the bootm command. +config CMD_VBE + bool "vbe - Verified Boot for Embedded" + depends on BOOTMETH_VBE + default y + help + Provides various subcommands related to VBE, such as listing the + available methods, looking at the state and changing which method + is used to boot. Updating the parameters is not currently + supported. + config BOOTM_VXWORKS bool "Support booting VxWorks OS images" depends on CMD_BOOTM
cmd/Makefile +1 -0
@@ -179,6 +179,7 @@ obj-$(CONFIG_CMD_FS_UUID) += fs_uuid.o obj-$(CONFIG_CMD_USB_MASS_STORAGE) += usb_mass_storage.o obj-$(CONFIG_CMD_USB_SDP) += usb_gadget_sdp.o obj-$(CONFIG_CMD_THOR_DOWNLOAD) += thordown.o +obj-$(CONFIG_CMD_VBE) += vbe.o obj-$(CONFIG_CMD_XIMG) += ximg.o obj-$(CONFIG_CMD_YAFFS2) += yaffs2.o obj-$(CONFIG_CMD_SPL) += spl.o
cmd/vbe.c new file +87 -0
87 lines not on this page · raw message
test/boot/Makefile +4 -0
@@ -3,3 +3,7 @@ # Copyright 2021 Google LLC obj-$(CONFIG_BOOTSTD) += bootdev.o bootstd_common.o bootflow.o bootmeth.o + +ifdef CONFIG_OF_LIVE +obj-$(CONFIG_BOOTMETH_VBE_SIMPLE) += vbe_simple.o +endif
test/boot/bootflow.c +33 -20
138 lines not on this page · raw message
test/boot/bootmeth.c +7 -4
@@ -23,8 +23,9 @@ static int bootmeth_cmd_list(struct unit_test_state *uts)ut_assert_nextlinen ("---" );ut_assert_nextline (" 0 0 syslinux Syslinux boot from a block device" );ut_assert_nextline (" 1 1 efi EFI boot from an .efi file" ); +ut_assert_nextline (" 2 2 firmware0 VBE simple" );ut_assert_nextlinen ("---" ); -ut_assert_nextline ("(2 bootmeths)" ); +ut_assert_nextline ("(3 bootmeths)" );ut_assert_console_end ();return 0 ;
@@ -56,8 +57,9 @@ static int bootmeth_cmd_order(struct unit_test_state *uts)ut_assert_nextlinen ("---" );ut_assert_nextline (" 0 0 syslinux Syslinux boot from a block device" );ut_assert_nextline (" - 1 efi EFI boot from an .efi file" ); +ut_assert_nextline (" - 2 firmware0 VBE simple" );ut_assert_nextlinen ("---" ); -ut_assert_nextline ("(2 bootmeths)" ); +ut_assert_nextline ("(3 bootmeths)" );ut_assert_console_end ();/* Check the -a flag with the reverse order */
@@ -68,8 +70,9 @@ static int bootmeth_cmd_order(struct unit_test_state *uts)ut_assert_nextlinen ("---" );ut_assert_nextline (" 1 0 syslinux Syslinux boot from a block device" );ut_assert_nextline (" 0 1 efi EFI boot from an .efi file" ); +ut_assert_nextline (" - 2 firmware0 VBE simple" );ut_assert_nextlinen ("---" ); -ut_assert_nextline ("(2 bootmeths)" ); +ut_assert_nextline ("(3 bootmeths)" );ut_assert_console_end ();/* Now reset the order to empty, which should show all of them again */
@@ -77,7 +80,7 @@ static int bootmeth_cmd_order(struct unit_test_state *uts)ut_assert_console_end ();ut_assertnull (env_get ("bootmeths" ));ut_assertok (run_command ("bootmeth list" ,0 )); -ut_assert_skip_to_line ("(2 bootmeths)" ); +ut_assert_skip_to_line ("(3 bootmeths)" );/* Try reverse order */ ut_assertok (run_command ("bootmeth order \"efi syslinux\"" ,0 ));
test/boot/vbe_simple.c new file +115 -0
115 lines not on this page · raw message
Signature · 1 line
2.37.0.170.g444d1eabd0-goog