Universal Payload initial series
Subsystems (5)
v2 cover Universal Payload initial series
Universal Payload (UPL) is an Industry Standard for firmware components[1]. UPL is designed to improve interoperability within the firmware industry, allowing mixing and matching of projects with less friction and fewer project-specific implementations. UPL is cross-platform, supporting ARM, x86 and RISC-V initially.
This series provides some initial support for this, targeting 0.9.1 and sandbox only.
Features still to come include:
- Support for architectures
- FIT validation
- Handoff validation
- Interoperability tests
This series is available at dm/uplb-working and requires the alist series at dm/alist-working[2]
[1] https://universalpayload.github.io/spec/
[2] https://patchwork.ozlabs.org/project/uboot/list/?series=414642
Changes in v2:
- Put the upl tests under their own subcommand to avoid bootstd init
- Add a function to init the UPL process in SPL
- Hang when something goes wrong, to avoid a broken boot
- Add a runtime flag to enable UPL
- Add a link to the spec
- Add a link to the command
- Support CI testing
- Rework to use alist instead of fixed-length arrays
Simon Glass (21):
sandbox: Use const in os_jump_to_file()
sandbox: Fix a comment in os_find_u_boot()
test: Move some SPL-loading test-code into sandbox common
sandbox: Enable SPL_LOAD_BLOCK
fdt: Don't overwrite bloblist devicetree
sandbox: fdt: Avoid overwriting an existing fdt
sandbox: Return error code from read/write/seek
sandbox: Add ELF file to VPL u-boot.img
sandbox: Set up global_data earlier
upl: Add support for reading a upl handoff
upl: Add support for writing a upl handoff
upl: Add basic tests
upl: Add a command
upl: Add support for Universal Payload in SPL
spl: Plumb in the Universal Payload handoff
upl: Plumb in universal payload to the init process
sandbox_vpl: Enable Universal Payload
upl: Add initial documentation
sandbox: Add a flag to enable UPL
sandbox: Add an SPL loader for UPL
upl: Add an end-to-end test
MAINTAINERS | 13 + Makefile | 4 +- arch/sandbox/cpu/cpu.c | 2 + arch/sandbox/cpu/os.c | 30 +- arch/sandbox/cpu/spl.c | 116 +++++- arch/sandbox/cpu/start.c | 18 +- arch/sandbox/include/asm/spl.h | 15 + arch/sandbox/include/asm/state.h | 1 + boot/Kconfig | 70 ++++ boot/Makefile | 4 + boot/upl_common.c | 60 +++ boot/upl_common.h | 24 ++ boot/upl_read.c | 588 ++++++++++++++++++++++++++++ boot/upl_write.c | 622 ++++++++++++++++++++++++++++++ cmd/Kconfig | 7 + cmd/Makefile | 1 + cmd/upl.c | 118 ++++++ common/board_f.c | 22 ++ common/board_r.c | 2 + common/spl/Kconfig | 1 + common/spl/Makefile | 2 + common/spl/spl.c | 8 + common/spl/spl_fit.c | 22 ++ common/spl/spl_upl.c | 171 ++++++++ configs/sandbox_defconfig | 1 + configs/sandbox_vpl_defconfig | 4 + doc/usage/cmd/upl.rst | 186 +++++++++ doc/usage/index.rst | 2 + doc/usage/upl.rst | 46 +++ drivers/block/sandbox.c | 4 +- drivers/usb/emul/sandbox_flash.c | 2 +- fs/sandbox/sandboxfs.c | 6 +- include/asm-generic/global_data.h | 19 + include/os.h | 6 +- include/spl.h | 16 + include/test/suites.h | 1 + include/upl.h | 361 +++++++++++++++++ lib/fdtdec.c | 1 + test/boot/Makefile | 2 + test/boot/upl.c | 436 +++++++++++++++++++++ test/cmd_ut.c | 3 + test/image/spl_load_os.c | 53 +-- test/py/tests/test_upl.py | 38 ++ 43 files changed, 3036 insertions(+), 72 deletions(-) create mode 100644 boot/upl_common.c create mode 100644 boot/upl_common.h create mode 100644 boot/upl_read.c create mode 100644 boot/upl_write.c create mode 100644 cmd/upl.c create mode 100644 common/spl/spl_upl.c create mode 100644 doc/usage/cmd/upl.rst create mode 100644 doc/usage/upl.rst create mode 100644 include/upl.h create mode 100644 test/boot/upl.c create mode 100644 test/py/tests/test_upl.py
Signature · 1 line
2.34.1
PATCH v2 1/21 sandbox: Use const in os_jump_to_file()
The argument array is not changed by the callee, so mark it const.
---
(no changes since v1)
arch/sandbox/cpu/os.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/sandbox/cpu/os.c +2 -2
@@ -808,7 +808,7 @@ static int make_exec(char *fname, const void *data, int size)* @count: Number of arguments in @add_args * Return: 0 if OK, -ENOMEM if out of memory */ -static int add_args (char ***argvp,char *add_args[],int count) +static int add_args (char ***argvp,const char *add_args[],int count) {char **argv, **ap;int argc;
@@ -859,7 +859,7 @@ static int os_jump_to_file(const char *fname, bool delete_it)struct sandbox_state *state =state_get_current ();char mem_fname[30 ];int fd, err; -char *extra_args[5 ]; +const char *extra_args[5 ];char **argv = state->argv;int argc;#ifdef DEBUG
Signature · 1 line
2.34.1
Re: [PATCH v2 01/21] sandbox: Use const in os_jump_to_file()
Hi Simon,
Thank you for the patch.
Quoted 3 lines · Simon Glass
The argument array is not changed by the callee, so mark it const.
Signed-off-by Simon Glass <[email protected]>
Quoted 31 lines
---
(no changes since v1)
arch/sandbox/cpu/os.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/sandbox/cpu/os.c +2
-2@@ -808,7 +808,7 @@ static int make_exec(char *fname, const void *data, int size)* @count: Number of arguments in @add_args * Return: 0 if OK, -ENOMEM if out of memory */ -static int add_args (char ***argvp,char *add_args[],int count) +static int add_args (char ***argvp,const char *add_args[],int count) {char **argv, **ap;int argc;@@ -859,7 +859,7 @@ static int os_jump_to_file(const char *fname, bool delete_it)struct sandbox_state *state =state_get_current ();char mem_fname[30 ];int fd, err; -char *extra_args[5 ]; +const char *extra_args[5 ];char **argv = state->argv;int argc;#ifdef DEBUG Signature · 1 line
2.34.1
PATCH v2 2/21 sandbox: Fix a comment in os_find_u_boot()
In reply to Simon GlassFix a missing dot in a comment, since '..' is confusing.
---
(no changes since v1)
arch/sandbox/cpu/os.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sandbox/cpu/os.c +1 -1
@@ -964,7 +964,7 @@ int os_find_u_boot(char *fname, int maxlen, bool use_img, p =strstr (fname, subdir);if (p) {if (*next_prefix) -/* e.g. ".../tpl/u-boot-spl" to "../spl/u-boot-spl" */ +/* e.g. ".../tpl/u-boot-spl" to ".../spl/u-boot-spl" */ memcpy (p +1 , next_prefix,strlen (next_prefix));else /* e.g. ".../spl/u-boot" to ".../u-boot" */
Signature · 1 line
2.34.1
Re: [PATCH v2 02/21] sandbox: Fix a comment in os_find_u_boot()
Hi Simon,
Thank you for the patch.
Quoted 3 lines · Simon Glass
Fix a missing dot in a comment, since '..' is confusing.
Signed-off-by Simon Glass <[email protected]>
Quoted 22 lines
---
(no changes since v1)
arch/sandbox/cpu/os.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/sandbox/cpu/os.c +1
-1@@ -964,7 +964,7 @@ int os_find_u_boot(char *fname, int maxlen, bool use_img, p =strstr (fname, subdir);if (p) {if (*next_prefix) -/* e.g. ".../tpl/u-boot-spl" to "../spl/u-boot-spl" */ +/* e.g. ".../tpl/u-boot-spl" to ".../spl/u-boot-spl" */ memcpy (p +1 , next_prefix,strlen (next_prefix));else /* e.g. ".../spl/u-boot" to ".../u-boot" */ Signature · 1 line
2.34.1
PATCH v2 3/21 test: Move some SPL-loading test-code into sandbox common
In reply to Simon GlassThis code is useful for loading an image in sandbox_spl so move it into a place where it can be called as needed.
---
(no changes since v1)
arch/sandbox/cpu/spl.c | 67 ++++++++++++++++++++++++++++++++++ arch/sandbox/include/asm/spl.h | 14 +++++++ test/image/spl_load_os.c | 53 +-------------------------- 3 files changed, 82 insertions(+), 52 deletions(-)
arch/sandbox/cpu/spl.c +67 -0
@@ -6,6 +6,7 @@#include <dm.h> #include <hang.h> #include <handoff.h> +#include <image.h> #include <init.h> #include <log.h> #include <os.h>
@@ -179,3 +180,69 @@ int handoff_arch_save(struct spl_handoff *ho)return 0 ; } + +/* Context used to hold file descriptor */ +struct load_ctx { +int fd; +}; + +static ulong read_fit_image (struct spl_load_info *load,ulong offset, +ulong size,void *buf) +{ +struct load_ctx *load_ctx = load->priv; +off_t ret; +ssize_t res; + + ret =os_lseek (load_ctx->fd, offset,OS_SEEK_SET ); +if (ret <0 ) { +printf ("Failed to seek to %zx, got %zx (errno=%d)\n" , offset, + ret, errno); +return log_msg_ret ("lse" , ret); + } + + res =os_read (load_ctx->fd, buf, size); +if (res <0 ) { +printf ("Failed to read %lx bytes, got %ld (errno=%d)\n" , + size, res, errno); +return log_msg_ret ("osr" , res); + } + +return size; +} + +int sandbox_spl_load_fit (char *fname,int maxlen,struct spl_image_info *image) +{ +struct legacy_img_hdr *header; +struct load_ctx load_ctx; +struct spl_load_info load; +int ret; +int fd; + +memset (&load,'\0' ,sizeof (load)); +spl_set_bl_len (&load,512 ); + load.read = read_fit_image; + + ret =sandbox_find_next_phase (fname, maxlen, true); +if (ret) { +printf ("%s not found, error %d\n" , fname, ret); +return log_msg_ret ("nph" , ret); + } + + header =spl_get_load_buffer (-sizeof (*header),sizeof (*header)); + +log_debug ("reading from %s\n" , fname); + fd =os_open (fname,OS_O_RDONLY ); +if (fd <0 ) +return log_msg_ret ("ope" , -ENOENT ); +if (os_read (fd, header,512 ) !=512 ) +return log_msg_ret ("rea" , -EIO ); + load_ctx.fd = fd; + + load.priv = &load_ctx; + + ret =spl_load_simple_fit (image, &load,0 , header); +if (ret) +return log_msg_ret ("slf" , ret); + +return 0 ; +}
arch/sandbox/include/asm/spl.h +14 -0
@@ -6,6 +6,8 @@#ifndef __asm_spl_h#define __asm_spl_h +struct spl_image_info ; +enum {BOOT_DEVICE_MMC1 , BOOT_DEVICE_MMC2,
@@ -31,4 +33,16 @@ enum {*/ int sandbox_find_next_phase (char *fname,int maxlen,bool use_img); +/** +* sandbox_spl_load_fit() - Load the next phase from a FIT +* +* Loads a FIT containing the next phase and sets it up for booting +* +* @fname: Returns filename loaded +* @maxlen: Maximum length for @fname including \0 +* @image: Place to put SPL-image information +* Return: 0 if OK, -ve on error +*/ +int sandbox_spl_load_fit (char *fname,int maxlen,struct spl_image_info *image); +#endif
test/image/spl_load_os.c +1 -52
64 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v2 03/21] test: Move some SPL-loading test-code into sandbox common
Quoted 73 lines · Simon Glass
This code is useful for loading an image in
sandbox_splso move it into a place where it can be called as needed.Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
arch/sandbox/cpu/spl.c | 67 ++++++++++++++++++++++++++++++++++ arch/sandbox/include/asm/spl.h | 14 +++++++ test/image/spl_load_os.c | 53 +-------------------------- 3 files changed, 82 insertions(+), 52 deletions(-)arch/sandbox/cpu/spl.c +45
-0@@ -6,6 +6,7 @@#include <dm.h> #include <hang.h> #include <handoff.h> +#include <image.h> #include <init.h> #include <log.h> #include <os.h> @@ -179,3 +180,69 @@ int handoff_arch_save(struct spl_handoff *ho)return 0 ; } + +/* Context used to hold file descriptor */ +struct load_ctx { +int fd; +}; + +static ulong read_fit_image (struct spl_load_info *load,ulong offset, +ulong size,void *buf) +{ +struct load_ctx *load_ctx = load->priv; +off_t ret; +ssize_t res; + + ret =os_lseek (load_ctx->fd, offset,OS_SEEK_SET ); +if (ret <0 ) { +printf ("Failed to seek to %zx, got %zx (errno=%d)\n" , offset, + ret, errno); +return log_msg_ret ("lse" , ret); + } + + res =os_read (load_ctx->fd, buf, size); +if (res <0 ) { +printf ("Failed to read %lx bytes, got %ld (errno=%d)\n" , + size, res, errno); +return log_msg_ret ("osr" , res); + } + +return size; +} + +int sandbox_spl_load_fit (char *fname,int maxlen,struct spl_image_info *image) +{ +struct legacy_img_hdr *header; +struct load_ctx load_ctx; +struct spl_load_info load; +int ret; +int fd; + +memset (&load,'\0' ,sizeof (load)); +spl_set_bl_len (&load,512 ); + load.read = read_fit_image; + + ret =sandbox_find_next_phase (fname, maxlen, true); +if (ret) {
arch/sandbox/cpu/spl.c int handoff_arch_save(struct spl_handoff *ho) · line 236
Quoted 10 lines
arch/sandbox/cpu/spl.c +10
-0+printf ("%s not found, error %d\n" , fname, ret); +return log_msg_ret ("nph" , ret); + } + + header =spl_get_load_buffer (-sizeof (*header),sizeof (*header)); + +log_debug ("reading from %s\n" , fname); + fd =os_open (fname,OS_O_RDONLY ); +if (fd <0 ) +return log_msg_ret ("ope" , -ENOENT );
should return errno
and I think longer messages won't hurt (this is sandbox after all).
arch/sandbox/cpu/spl.c int handoff_arch_save(struct spl_handoff *ho) · line 237
Quoted 1 line
arch/sandbox/cpu/spl.c +1
-0+if (os_read (fd, header,512 ) !=512 )
Actually, this should probably be sizeof(*header) and not 512
arch/sandbox/cpu/spl.c int handoff_arch_save(struct spl_handoff *ho) · line 238
Quoted 1 line
arch/sandbox/cpu/spl.c +1
-0+return log_msg_ret ("rea" , -EIO );
ditto errno/message
Quoted 109 lines
arch/sandbox/cpu/spl.c +10
-0+ load_ctx.fd = fd; + + load.priv = &load_ctx; + + ret =spl_load_simple_fit (image, &load,0 , header); +if (ret) +return log_msg_ret ("slf" , ret); + +return 0 ; +}arch/sandbox/include/asm/spl.h +14
-0@@ -6,6 +6,8 @@#ifndef __asm_spl_h#define __asm_spl_h +struct spl_image_info ; +enum {BOOT_DEVICE_MMC1 , BOOT_DEVICE_MMC2,@@ -31,4 +33,16 @@ enum {*/ int sandbox_find_next_phase (char *fname,int maxlen,bool use_img); +/** +* sandbox_spl_load_fit() - Load the next phase from a FIT +* +* Loads a FIT containing the next phase and sets it up for booting +* +* @fname: Returns filename loaded +* @maxlen: Maximum length for @fname including \0 +* @image: Place to put SPL-image information +* Return: 0 if OK, -ve on error +*/ +int sandbox_spl_load_fit (char *fname,int maxlen,struct spl_image_info *image); +#endif test/image/spl_load_os.c +1
-52@@ -10,63 +10,12 @@#include <test/spl.h> #include <test/ut.h> -/* Context used for this test */ -struct text_ctx { -int fd; -}; - -static ulong read_fit_image (struct spl_load_info *load,ulong offset, -ulong size,void *buf) -{ -struct text_ctx *text_ctx = load->priv; -off_t ret; -ssize_t res; - - ret =os_lseek (text_ctx->fd, offset,OS_SEEK_SET ); -if (ret != offset) { -printf ("Failed to seek to %zx, got %zx (errno=%d)\n" , offset, - ret, errno); -return 0 ; - } - - res =os_read (text_ctx->fd, buf, size); -if (res ==-1 ) { -printf ("Failed to read %lx bytes, got %ld (errno=%d)\n" , - size, res, errno); -return 0 ; - } - -return size; -} -static int spl_test_load (struct unit_test_state *uts) {struct spl_image_info image; -struct legacy_img_hdr *header; -struct text_ctx text_ctx; -struct spl_load_info load;char fname[256 ]; -int ret; -int fd; - -memset (&load,'\0' ,sizeof (load)); -spl_set_bl_len (&load,512 ); - load.read = read_fit_image; - - ret =sandbox_find_next_phase (fname,sizeof (fname), true); -if (ret) -ut_assertf (0 ,"%s not found, error %d\n" , fname, ret); - - header =spl_get_load_buffer (-sizeof (*header),sizeof (*header)); - - fd =os_open (fname,OS_O_RDONLY ); -ut_assert (fd >=0 ); -ut_asserteq (512 ,os_read (fd, header,512 )); - text_ctx.fd = fd; - - load.priv = &text_ctx; -ut_assertok (spl_load_simple_fit (&image, &load,0 , header)); +ut_assertok (sandbox_spl_load_fit (fname,sizeof (fname), &image));return 0 ; }
PATCH v2 4/21 sandbox: Enable SPL_LOAD_BLOCK
In reply to Simon GlassEnable this option for all sandbox boards so that the FIT-loading code can be used without generating an error about block devices not being supported.
---
(no changes since v1)
common/spl/Kconfig | 1 + 1 file changed, 1 insertion(+)
common/spl/Kconfig +1 -0
@@ -288,6 +288,7 @@ config SPL_BOARD_INIT config SPL_LOAD_BLOCK bool + default y if SANDBOX help Support loading images from block devices. This adds a bl_len member to struct spl_load_info.
Signature · 1 line
2.34.1
Sean Anderson
NAKRe: [PATCH v2 04/21] sandbox: Enable SPL_LOAD_BLOCK
Quoted 17 lines · Simon Glass
Enable this option for all sandbox boards so that the FIT-loading code can be used without generating an error about block devices not being supported.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
common/spl/Kconfig | 1 + 1 file changed, 1 insertion(+)common/spl/Kconfig +0
-0
common/spl/Kconfig config SPL_BOARD_INIT · line 294
Quoted 7 lines
common/spl/Kconfig +1
-0@@ -288,6 +288,7 @@ config SPL_BOARD_INIT config SPL_LOAD_BLOCK bool + default y if SANDBOX help Support loading images from block devices. This adds a bl_len member to struct spl_load_info.
NACK.
Enable one of the many configs which select this one instead.
--Sean
Re: [PATCH v2 04/21] sandbox: Enable SPL_LOAD_BLOCK
Quoted 27 lines · Sean Anderson
Quoted 17 lines · Simon Glass
Enable this option for all sandbox boards so that the FIT-loading code can be used without generating an error about block devices not being supported.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
common/spl/Kconfig | 1 +
1 file changed, 1 insertion(+)common/spl/Kconfig +0
-0@@ -288,6 +288,7 @@ config SPL_BOARD_INITQuoted 6 lines
config
SPL_LOAD_BLOCK
bool
+ default y if SANDBOX
help
Support loading images from block devices. This adds abl_lenmember to structspl_load_info.NACK.
Quoted 3 lines
Enable one of the many configs which select this one instead.
--Sean
OK, so I think you wanted to add this because of the previous patch/patch 20.
I think a better solution would be to just reduce the bl_len to 1, since unix I/O is byte-oriented anyway and we now have several tests for bl_len != 1.
--Sean
PATCH v2 5/21 fdt: Don't overwrite bloblist devicetree
In reply to Simon GlassWhen the devicetree comes from a bloblist, it is currently overwritten by the appended one, if present. It should be preserved.
Adjust the logic to support this.
---
(no changes since v1)
lib/fdtdec.c | 1 + 1 file changed, 1 insertion(+)
lib/fdtdec.c +1 -0
@@ -1678,6 +1678,7 @@ int fdtdec_setup(void) gd->fdt_src =FDTSRC_BLOBLIST ;log_debug ("Devicetree is in bloblist at %p\n" , gd->fdt_blob); + ret =0 ; }else {log_debug ("No FDT found in bloblist\n" ); ret = -ENOENT ;
Signature · 1 line
2.34.1
PATCH v2 6/21 sandbox: fdt: Avoid overwriting an existing fdt
In reply to Simon GlassSince the removal of OF_HOSTFILE logic in board_fdt_blob_setup(), the logic for obtaining the DT is handed in the OF_BOARD option. If a devicetree comes from a bloblist it is immediately overwritten by this function.
Fix this by skipping the function if a devicetree is already present.
This is sort-of a fix for e7fb7896 ("sandbox: Remove OF_HOSTFILE") but it has only come to light since bloblist was added, so I have not added a Fixes tag.
Unfortunately it is not possible to report the correct FDT source with the current code. It might be best to use an error-return code for board_fdt_blob_setup() so that an error can be reported if the board does not provide the DT.
---
(no changes since v1)
arch/sandbox/cpu/cpu.c | 2 ++ 1 file changed, 2 insertions(+)
arch/sandbox/cpu/cpu.c +2 -0
@@ -340,6 +340,8 @@ void *board_fdt_blob_setup(int *ret)int err;int fd; +if (gd->fdt_blob) +return (void *)gd->fdt_blob; blob =map_sysmem (CONFIG_SYS_FDT_LOAD_ADDR ,0 ); *ret =0 ;if (!state->fdt_fname) {
Signature · 1 line
2.34.1
PATCH v2 7/21 sandbox: Return error code from read/write/seek
In reply to Simon GlassThe existing API for these functions is different from the rest of U-Boot, in that any error code must be obtained from the errno variable on failure. This variable is part of the C library, so accessing it outside of the special 'sandbox' shim-functions is not ideal.
Adjust the API to return an error code, to avoid this. Update existing uses to check for any negative value, rather than just -1.
---
(no changes since v1)
arch/sandbox/cpu/os.c | 24 +++++++++++++++++++++--- arch/sandbox/cpu/spl.c | 8 ++++---- drivers/block/sandbox.c | 4 ++-- drivers/usb/emul/sandbox_flash.c | 2 +- fs/sandbox/sandboxfs.c | 6 +++--- include/os.h | 6 +++--- 6 files changed, 34 insertions(+), 16 deletions(-)
arch/sandbox/cpu/os.c +21 -3
@@ -47,12 +47,24 @@ struct os_mem_hdr {ssize_t os_read (int fd,void *buf,size_t count) { -return read (fd, buf, count); +ssize_t ret; + + ret =read (fd, buf, count); +if (ret ==-1 ) +return -errno; + +return ret; }ssize_t os_write (int fd,const void *buf,size_t count) { -return write (fd, buf, count); +ssize_t ret; + + ret =write (fd, buf, count); +if (ret ==-1 ) +return -errno; + +return ret; }int os_printf (const char *fmt, ...)
@@ -69,6 +81,8 @@ int os_printf(const char *fmt, ...)off_t os_lseek (int fd,off_t offset,int whence) { +off_t ret; +if (whence ==OS_SEEK_SET ) whence =SEEK_SET ;else if (whence ==OS_SEEK_CUR )
@@ -77,7 +91,11 @@ off_t os_lseek(int fd, off_t offset, int whence) whence =SEEK_END ; else os_exit(1); -return lseek (fd, offset, whence); + ret =lseek (fd, offset, whence); +if (ret ==-1 ) +return -errno; + +return ret; }int os_open (const char *pathname,int os_flags)
arch/sandbox/cpu/spl.c +4 -4
@@ -195,15 +195,15 @@ static ulong read_fit_image(struct spl_load_info *load, ulong offset, ret =os_lseek (load_ctx->fd, offset,OS_SEEK_SET );if (ret <0 ) { -printf ("Failed to seek to %zx, got %zx (errno=%d)\n" , offset, - ret, errno); +printf ("Failed to seek to %zx, got %zx (errno=%zd)\n" , offset, + ret, ret);return log_msg_ret ("lse" , ret); } res =os_read (load_ctx->fd, buf, size);if (res <0 ) { -printf ("Failed to read %lx bytes, got %ld (errno=%d)\n" , - size, res, errno); +printf ("Failed to read %lx bytes, got %ld (errno=%zd)\n" , + size, res, ret);return log_msg_ret ("osr" , res); }
drivers/block/sandbox.c +2 -2
@@ -25,7 +25,7 @@ static unsigned long host_block_read(struct udevice *dev,struct udevice *host_dev =dev_get_parent (dev);struct host_sb_plat *plat =dev_get_plat (host_dev); -if (os_lseek (plat->fd, start * desc->blksz,OS_SEEK_SET ) ==-1 ) { +if (os_lseek (plat->fd, start * desc->blksz,OS_SEEK_SET ) <0 ) {printf ("ERROR: Invalid block %lx\n" , start);return -1 ; }
@@ -44,7 +44,7 @@ static unsigned long host_block_write(struct udevice *dev,struct udevice *host_dev =dev_get_parent (dev);struct host_sb_plat *plat =dev_get_plat (host_dev); -if (os_lseek (plat->fd, start * desc->blksz,OS_SEEK_SET ) ==-1 ) { +if (os_lseek (plat->fd, start * desc->blksz,OS_SEEK_SET ) <0 ) {printf ("ERROR: Invalid block %lx\n" , start);return -1 ; }
drivers/usb/emul/sandbox_flash.c +1 -1
@@ -196,7 +196,7 @@ static int handle_ufi_command(struct sandbox_flash_priv *priv, const void *buff, priv->fd != -1) { offset =os_lseek (priv->fd, info->seek_block * info->block_size,OS_SEEK_SET ); -if (offset == (off_t)-1 ) +if (offset <0 )setup_fail_response (priv);else setup_response (priv);
fs/sandbox/sandboxfs.c +3 -3
@@ -28,7 +28,7 @@ int sandbox_fs_read_at(const char *filename, loff_t pos, void *buffer,if (fd <0 )return fd; ret =os_lseek (fd, pos,OS_SEEK_SET ); -if (ret ==-1 ) { +if (ret <0 ) {os_close (fd);return ret; }
@@ -65,14 +65,14 @@ int sandbox_fs_write_at(const char *filename, loff_t pos, void *buffer,if (fd <0 )return fd; ret =os_lseek (fd, pos,OS_SEEK_SET ); -if (ret ==-1 ) { +if (ret <0 ) {os_close (fd);return ret; } size =os_write (fd, buffer, towrite);os_close (fd); -if (size ==-1 ) { +if (size <0 ) { ret =-1 ; }else { ret =0 ;
include/os.h +3 -3
@@ -29,7 +29,7 @@ int os_printf(const char *format, ...);* @fd: File descriptor as returned by os_open() * @buf: Buffer to place data * @count: Number of bytes to read -* Return: number of bytes read, or -1 on error +* Return: number of bytes read, or -errno on error */ ssize_t os_read (int fd,void *buf,size_t count);
@@ -39,7 +39,7 @@ ssize_t os_read(int fd, void *buf, size_t count);* @fd: File descriptor as returned by os_open() * @buf: Buffer containing data to write * @count: Number of bytes to write -* Return: number of bytes written, or -1 on error +* Return: number of bytes written, or -errno on error */ ssize_t os_write (int fd,const void *buf,size_t count);
@@ -49,7 +49,7 @@ ssize_t os_write(int fd, const void *buf, size_t count);* @fd: File descriptor as returned by os_open() * @offset: File offset (based on whence) * @whence: Position offset is relative to (see below) -* Return: new file offset +* Return: new file offset, or -errno on error */ off_t os_lseek (int fd,off_t offset,int whence);
Signature · 1 line
2.34.1
PATCH v2 8/21 sandbox: Add ELF file to VPL u-boot.img
In reply to Simon GlassAt present sandbox builds package up u-boot.bin in the .img file. This cannot actually be executed, since it is not an ELF file.
For sandbox_vpl we want to be able to run the full boot flow.
Adjust the build rule for sandbox_vpl to package the ELF file and thereby allow full testing of the sandbox transition from SPL to U-Boot proper.
---
(no changes since v1)
Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Makefile +3 -1
@@ -1470,8 +1470,10 @@ u-boot.bin.lzma: u-boot.bin FORCE u-boot-lzma.img: u-boot.bin.lzma FORCE $(call if_changed,mkimage) +fit_image := $(if $(CONFIG_SANDBOX_VPL),u-boot,u-boot-nodtb.bin) + u-boot-dtb.img u-boot.img u-boot.kwb u-boot.pbl u-boot-ivt.img: \ - $(if $(CONFIG_SPL_LOAD_FIT),u-boot-nodtb.bin \ + $(if $(CONFIG_SPL_LOAD_FIT),$(fit_image) \ $(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_SANDBOX),dts/dt.dtb) \ ,$(UBOOT_BIN)) FORCE $(call if_changed,mkimage)
Signature · 1 line
2.34.1
PATCH v2 9/21 sandbox: Set up global_data earlier
In reply to Simon GlassIt is possible for U-Boot functions such as printf() to be called within state_init(). This can end up checking gd->flags (e.g. in putc()) before global_data is set up.
Move the setup earlier to avoid this. This fixes the suppression of some debug output in memory allocation (when enabled).
---
(no changes since v1)
arch/sandbox/cpu/start.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/sandbox/cpu/start.c +3 -2
@@ -483,6 +483,9 @@ int sandbox_main(int argc, char *argv[]) text_base =os_find_text_base (); +memset (&data,'\0' ,sizeof (data)); + gd = &data; +/* * This must be the first invocation of os_malloc() to have * state->ram_buf in the low 4 GiB.
@@ -501,8 +504,6 @@ int sandbox_main(int argc, char *argv[])os_exit (1 );memcpy (os_argv, argv, size); -memset (&data,'\0' ,sizeof (data)); - gd = &data; gd->arch.text_base = text_base; state =state_get_current ();
Signature · 1 line
2.34.1
PATCH v2 10/21 upl: Add support for reading a upl handoff
In reply to Simon GlassUniversal Payload provides a standard way of handing off control between two firmware phases. Add support for reading the handoff information into a structure.
---
(no changes since v1)
MAINTAINERS | 7 + boot/Kconfig | 19 ++ boot/Makefile | 3 + boot/upl_common.c | 60 ++++ boot/upl_common.h | 24 ++ boot/upl_read.c | 588 ++++++++++++++++++++++++++++++++++++++ configs/sandbox_defconfig | 1 + include/upl.h | 352 +++++++++++++++++++++++ 8 files changed, 1054 insertions(+) create mode 100644 boot/upl_common.c create mode 100644 boot/upl_common.h create mode 100644 boot/upl_read.c create mode 100644 include/upl.h
MAINTAINERS +7 -0
@@ -1694,6 +1694,13 @@ M: Neha Malcom Francis <[email protected]> S: Maintained F: drivers/ufs/ +UPL +M: Simon Glass <[email protected]> +S: Maintained +T: git https://source.denx.de/u-boot/custodians/u-boot-dm.git +F: boot/upl* +F: include/upl.h + USB M: Marek Vasut <[email protected]> S: Maintained
boot/Kconfig +19 -0
@@ -719,6 +719,25 @@ config BOOTMETH_SCRIPT This provides a way to try out standard boot on an existing boot flow. It is not enabled by default to save space. +config UPL + bool "upl - Universal Payload Specification" + imply UPL_READ + help + Provides support for UPL payloads and handoff information. U-Boot + supports generating and accepting handoff information. The mkimage + tool will eventually support creating payloads. + +if UPL + +config UPL_READ + bool "upl - Support reading a Universal Payload handoff" + help + Provides support for decoding a UPL-format payload into a C structure + which can be used elsewhere in U-Boot. This is just the reading + implementation, useful for trying it out. + +endif # UPL + endif # BOOTSTD config LEGACY_IMAGE_FORMAT
boot/Makefile +3 -0
@@ -43,6 +43,9 @@ endif obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += fdt_support.o obj-$(CONFIG_$(SPL_TPL_)FDT_SIMPLEFB) += fdt_simplefb.o +obj-$(CONFIG_$(SPL_TPL_)UPL) += upl_common.o +obj-$(CONFIG_$(SPL_TPL_)UPL_READ) += upl_read.o + obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += image-fdt.o obj-$(CONFIG_$(SPL_TPL_)FIT_SIGNATURE) += fdt_region.o obj-$(CONFIG_$(SPL_TPL_)FIT) += image-fit.o
boot/upl_common.c new file +60 -0
60 lines not on this page · raw message
boot/upl_common.h new file +24 -0
@@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* UPL handoff command functions +* +* Copyright 2024 Google LLC +* Written by Simon Glass <[email protected]> +*/ + +#ifndef __UPL_COMMON_H +#define __UPL_COMMON_H + +/* Names of bootmodes */ +extern const char *const bootmode_names[UPLBM_COUNT ]; + +/* Names of memory usages */ +extern const char *const usage_names[UPLUS_COUNT ]; + +/* Names of access types */ +extern const char *const access_types[UPLUS_COUNT ]; + +/* Names of graphics formats */ +extern const char *const graphics_formats[UPLUS_COUNT ]; + +#endif /* __UPL_COMMON_H */
boot/upl_read.c new file +588 -0
588 lines not on this page · raw message
configs/sandbox_defconfig +1 -0
@@ -15,6 +15,7 @@ CONFIG_FIT=y CONFIG_FIT_RSASSA_PSS=y CONFIG_FIT_CIPHER=y CONFIG_FIT_VERBOSE=y +CONFIG_UPL=y CONFIG_LEGACY_IMAGE_FORMAT=y CONFIG_MEASURED_BOOT=y CONFIG_BOOTSTAGE=y
include/upl.h new file +352 -0
352 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v2 10/21] upl: Add support for reading a upl handoff
Quoted 365 lines · Simon Glass
Universal Payload provides a standard way of handing off control between two firmware phases. Add support for reading the handoff information into a structure.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
MAINTAINERS | 7 + boot/Kconfig | 19 ++ boot/Makefile | 3 + boot/upl_common.c | 60 ++++ boot/upl_common.h | 24 ++ boot/upl_read.c | 588 ++++++++++++++++++++++++++++++++++++++ configs/sandbox_defconfig | 1 + include/upl.h | 352 +++++++++++++++++++++++ 8 files changed, 1054 insertions(+)create mode 100644
boot/upl_common.c
create mode 100644boot/upl_common.h
create mode 100644boot/upl_read.c
create mode 100644include/upl.hMAINTAINERS +7
-0@@ -1694,6 +1694,13 @@ M: Neha Malcom Francis <[email protected]> S: Maintained F: drivers/ufs/ +UPL +M: Simon Glass <[email protected]> +S: Maintained +T: git https://source.denx.de/u-boot/custodians/u-boot-dm.git +F: boot/upl* +F: include/upl.h + USB M: Marek Vasut <[email protected]> S: Maintainedboot/Kconfig +19
-0@@ -719,6 +719,25 @@ config BOOTMETH_SCRIPT This provides a way to try out standard boot on an existing boot flow. It is not enabled by default to save space. +config UPL + bool "upl - Universal Payload Specification" + imply UPL_READ + help + Provides support for UPL payloads and handoff information. U-Boot + supports generating and accepting handoff information. The mkimage + tool will eventually support creating payloads. + +if UPL + +config UPL_READ + bool "upl - Support reading a Universal Payload handoff" + help + Provides support for decoding a UPL-format payload into a C structure + which can be used elsewhere in U-Boot. This is just the reading + implementation, useful for trying it out. + +endif # UPL + endif # BOOTSTD config LEGACY_IMAGE_FORMATboot/Makefile +3
-0@@ -43,6 +43,9 @@ endif obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += fdt_support.o obj-$(CONFIG_$(SPL_TPL_)FDT_SIMPLEFB) += fdt_simplefb.o +obj-$(CONFIG_$(SPL_TPL_)UPL) += upl_common.o +obj-$(CONFIG_$(SPL_TPL_)UPL_READ) += upl_read.o + obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += image-fdt.o obj-$(CONFIG_$(SPL_TPL_)FIT_SIGNATURE) += fdt_region.o obj-$(CONFIG_$(SPL_TPL_)FIT) += image-fit.oboot/upl_common.c new file +60
-0@@ -0,0 +1,60 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* UPL handoff command functions +* +* Copyright 2024 Google LLC +* Written by Simon Glass <[email protected]> +*/ + +#define LOG_CATEGORY UCLASS_BOOTSTD + +#include <string.h> +#include <upl.h> + +/* Names of bootmodes */ +const char *const bootmode_names[UPLBM_COUNT ] = { + [UPLBM_FULL ] ="full" , + [UPLBM_MINIMAL ] ="minimal" , + [UPLBM_FAST ] ="fast" , + [UPLBM_DIAG ] ="diag" , + [UPLBM_DEFAULT ] ="default" , + [UPLBM_S2 ] ="s2" , + [UPLBM_S3 ] ="s3" , + [UPLBM_S4 ] ="s4" , + [UPLBM_S5 ] ="s5" , + [UPLBM_FACTORY ] ="factory" , + [UPLBM_FLASH ] ="flash" , + [UPLBM_RECOVERY ] ="recovery" , +}; + +/* Names of memory usages */ +const char *const usage_names[UPLUS_COUNT ] = { + [UPLUS_ACPI_RECLAIM ] ="acpi-reclaim" , + [UPLUS_ACPI_NVS ] ="acpi-nvs" , + [UPLUS_BOOT_CODE ] ="boot-code" , + [UPLUS_BOOT_DATA ] ="boot-data" , + [UPLUS_RUNTIME_CODE ] ="runtime-code" , + [UPLUS_RUNTIME_DATA ] ="runtime-data" , +}; + +/* Names of access types */ +const char *const access_types[UPLUS_COUNT ] = { + [UPLAT_MMIO ] ="mmio" , + [UPLAT_IO ] ="io" , +}; + +/* Names of graphics formats */ +const char *const graphics_formats[UPLUS_COUNT ] = { + [UPLGF_ARGB32 ] ="a8r8g8b8" , + [UPLGF_ABGR32 ] ="a8b8g8r8" , + [UPLGF_ABGR64 ] ="a16b16g16r16" , +}; + +void upl_init (struct upl *upl) +{ +memset (upl,'\0' ,sizeof (struct upl )); + alist_init_struct(&upl->image, struct upl_image); + alist_init_struct(&upl->mem, struct upl_mem); + alist_init_struct(&upl->memmap, struct upl_memmap); + alist_init_struct(&upl->memres, struct upl_memres); +}boot/upl_common.h new file +24
-0@@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* UPL handoff command functions +* +* Copyright 2024 Google LLC +* Written by Simon Glass <[email protected]> +*/ + +#ifndef __UPL_COMMON_H +#define __UPL_COMMON_H + +/* Names of bootmodes */ +extern const char *const bootmode_names[UPLBM_COUNT ]; + +/* Names of memory usages */ +extern const char *const usage_names[UPLUS_COUNT ]; + +/* Names of access types */ +extern const char *const access_types[UPLUS_COUNT ]; + +/* Names of graphics formats */ +extern const char *const graphics_formats[UPLUS_COUNT ]; + +#endif /* __UPL_COMMON_H */ boot/upl_read.c new file +178
-0@@ -0,0 +1,588 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* UPL handoff parsing +* +* Copyright 2024 Google LLC +* Written by Simon Glass <[email protected]> +*/ + +#define LOG_CATEGORY UCLASS_BOOTSTD + +#include <log.h> +#include <upl.h> +#include <dm/ofnode.h> +#include "upl_common.h" + +/** +* read_addr() - Read an address +* +* Reads an address in the correct format, either 32- or 64-bit +* +* @upl: UPL state +* @node: Node to read from +* @prop: Property name to read +* @addr: Place to put the address +* Return: 0 if OK, -ve on error +*/ +static int read_addr (const struct upl *upl,ofnode node,const char *prop, +ulong *addrp) +{ +int ret; + +if (upl->addr_cells ==1 ) { +u32 val; + + ret =ofnode_read_u32 (node, prop, &val); +if (!ret) + *addrp = val; + }else { +u64 val; + + ret =ofnode_read_u64 (node, prop, &val); +if (!ret) + *addrp = val; + } + +return ret; +} + +/** +* read_size() - Read a size +* +* Reads a size in the correct format, either 32- or 64-bit +* +* @upl: UPL state +* @node: Node to read from +* @prop: Property name to read +* @addr: Place to put the size +* Return: 0 if OK, -ve on error +*/ +static int read_size (const struct upl *upl,ofnode node,const char *prop, +ulong *sizep) +{ +int ret; + +if (upl->size_cells ==1 ) { +u32 val; + + ret =ofnode_read_u32 (node, prop, &val); +if (!ret) + *sizep = val; + }else { +u64 val; + + ret =ofnode_read_u64 (node, prop, &val); +if (!ret) + *sizep = val; + } + +return ret; +} + +/** +* ofnode_read_bitmask() - Read a bit mask from a string list +* +* @node: Node to read from +* @prop: Property name to read +* @names: Array of names for each bit +* @count: Number of array entries +* @value: Returns resulting bit-mask value on success +* Return: 0 if OK, -EINVAL if a bit number is not defined, -ENOSPC if the +* string is too long for the (internal) buffer, -EINVAL if no such property +*/ +static int ofnode_read_bitmask (ofnode node,const char *prop, +const char *const names[],uint count, +uint *valuep) +{ +const char **list; +const char **strp; +uint val; +uint bit; +int ret; + + ret =ofnode_read_string_list (node, prop, &list); +if (ret <0 ) +return log_msg_ret ("rea" , ret); + + val =0 ; +for (strp = list; *strp; strp++) { +const char *str = *strp; +bool found = false; + +for (bit =0 ; bit < count; bit++) { +if (!strcmp (str, names[bit])) { + found = true; +break ; + } + } +if (found) + val |=BIT (bit); +else +log_warning ("%s/%s: Invalid value '%s'\n" , +ofnode_get_name (node), prop, str); + } + *valuep = val; + +return 0 ; +} + +/** +* ofnode_read_value() - Read a string value as an int using a lookup +* +* @node: Node to read from +* @prop: Property name to read +* @names: Array of names for each int value +* @count: Number of array entries +* @valuep: Returns int value read +* Return: 0 if OK, -EINVAL if a bit number is not defined, -ENOENT if the +* property does not exist +*/ +static int ofnode_read_value (ofnode node,const char *prop, +const char *const names[],uint count, +uint *valuep) +{ +const char *str; +int i; + + str =ofnode_read_string (node, prop); +if (!str) +return log_msg_ret ("rd" , -ENOENT ); + +for (i =0 ; i < count; i++) { +if (!strcmp (names[i], str)) { + *valuep = i; +return 0 ; + } + } + +log_debug ("Unnamed value '%s'\n" , str); +return log_msg_ret ("val" , -EINVAL ); +} + +static int read_uint (ofnode node,const char *prop,uint *valp) +{ +u32 val; +int ret; + + ret =ofnode_read_u32 (node, prop, &val); +if (ret) +return ret; + *valp = val; + +return 0 ; +} + +/** +* decode_root_props() - Decode root properties from the tree +* +* @upl: UPL state
boot/upl_read.c line 188
Quoted 10 lines
boot/upl_read.c new file +10
-0+* @node: Node to decode +* Return 0 if OK, -ve on error +*/ +static int decode_root_props (struct upl *upl,ofnode node) +{ +int ret; + + ret =read_uint (node,UPLP_ADDRESS_CELLS , &upl->addr_cells); +if (!ret) + ret =read_uint (node,UPLP_SIZE_CELLS , &upl->size_cells);
Why do we need a special handling of addr_cells and size_cells? The device-tree provided by UPL follows the device-tree specification which requires to set these properties in the parent of the node.
Best regards
Heinrich
Quoted 770 lines
boot/upl_read.c new file +400
-0+if (ret) +return log_msg_ret ("cel" , ret); + +return 0 ; +} + +/** +* decode_root_props() - Decode UPL parameters from the tree +* +* @upl: UPL state +* @node: Node to decode +* Return 0 if OK, -ve on error +*/ +static int decode_upl_params (struct upl *upl,ofnode options) +{ +ofnode node; +int ret; + + node =ofnode_find_subnode (options,UPLN_UPL_PARAMS ); +if (!ofnode_valid (node)) +return log_msg_ret ("par" , -EINVAL ); +log_debug ("decoding '%s'\n" ,ofnode_get_name (node)); + + ret =read_addr (upl, node,UPLP_SMBIOS , &upl->smbios); +if (ret) +return log_msg_ret ("smb" , ret); + ret =read_addr (upl, node,UPLP_ACPI , &upl->acpi); +if (ret) +return log_msg_ret ("acp" , ret); + ret =ofnode_read_bitmask (node,UPLP_BOOTMODE , bootmode_names, +UPLBM_COUNT , &upl->bootmode); +if (ret) +return log_msg_ret ("boo" , ret); + ret =read_uint (node,UPLP_ADDR_WIDTH , &upl->addr_width); +if (ret) +return log_msg_ret ("add" , ret); + ret =read_uint (node,UPLP_ACPI_NVS_SIZE , &upl->acpi_nvs_size); +if (ret) +return log_msg_ret ("nvs" , ret); + +return 0 ; +} + +/** +* decode_upl_images() - Decode /options/upl-image nodes +* +* @node: /options node in which to look for the node +* Return 0 if OK, -ve on error +*/ +static int decode_upl_images (struct upl *upl,ofnode options) +{ +ofnode node, images; +int ret; + + images =ofnode_find_subnode (options,UPLN_UPL_IMAGE ); +if (!ofnode_valid (images)) +return log_msg_ret ("img" , -EINVAL ); +log_debug ("decoding '%s'\n" ,ofnode_get_name (images)); + + ret =read_addr (upl, images,UPLP_FIT , &upl->fit); +if (!ret) + ret =read_uint (images,UPLP_CONF_OFFSET , &upl->conf_offset); +if (ret) +return log_msg_ret ("cnf" , ret); + +ofnode_for_each_subnode (node, images) { +struct upl_image img; + + ret =read_addr (upl, node,UPLP_LOAD , &img.load); +if (!ret) + ret =read_size (upl, node,UPLP_SIZE , &img.size); +if (!ret) + ret =read_uint (node,UPLP_OFFSET , &img.offset); + img.description =ofnode_read_string (node,UPLP_DESCRIPTION ); +if (!img.description) +return log_msg_ret ("sim" , ret); + if (!alist_add(&upl->image, img, struct upl_image)) +return log_msg_ret ("img" , -ENOMEM ); + } + +return 0 ; +} + +/** +* decode_addr_size() - Decide a set of addr/size pairs +* +* Each base/size value from the devicetree is written to the region list +* +* @upl: UPL state +* @buf: Bytes to decode +* @size: Number of bytes to decode +* @regions: List of regions to process (struct memregion) +* Returns: number of regions found, if OK, else -ve on error +*/ +static int decode_addr_size (const struct upl *upl,const char *buf,int size, +struct alist *regions) +{ +const char *ptr, *end = buf + size; +int i; + + alist_init_struct(regions, struct memregion); + ptr = buf; +for (i =0 ; ptr < end; i++) { +struct memregion reg; + +if (upl->addr_cells ==1 ) + reg.base =fdt32_to_cpu (*(u32 *)ptr); +else + reg.base =fdt64_to_cpu (*(u64 *)ptr); + ptr += upl->addr_cells *sizeof (u32); + +if (upl->size_cells ==1 ) + reg.size =fdt32_to_cpu (*(u32 *)ptr); +else + reg.size =fdt64_to_cpu (*(u64 *)ptr); + ptr += upl->size_cells *sizeof (u32); +if (ptr > end) +return -ENOSPC ; + + if (!alist_add(regions, reg, struct memregion)) +return log_msg_ret ("reg" , -ENOMEM ); + } + +return i; +} + +/** +* node_matches_at() - Check if a node name matches "base@..." +* +* Return: true if the node name matches the base string followed by an @ sign; +* false otherwise +*/ +static bool node_matches_at (ofnode node,const char *base) +{ +const char *name =ofnode_get_name (node); +int len =strlen (base); + +return !strncmp (base, name, len) && name[len] =='@' ; +} + +/** +* decode_upl_memory_node() - Decode a /memory node from the tree +* +* @upl: UPL state +* @node: Node to decode +* Return 0 if OK, -ve on error +*/ +static int decode_upl_memory_node (struct upl *upl,ofnode node) +{ +struct upl_mem mem; +const char *buf; +int size, len; + + buf =ofnode_read_prop (node,UPLP_REG , &size); +if (!buf) { +log_warning ("Node '%s': Missing '%s' property\n" , +ofnode_get_name (node),UPLP_REG ); +return log_msg_ret ("reg" , -EINVAL ); + } + len =decode_addr_size (upl, buf, size, &mem.region); +if (len <0 ) +return log_msg_ret ("buf" , len); + mem.hotpluggable =ofnode_read_bool (node,UPLP_HOTPLUGGABLE ); + if (!alist_add(&upl->mem, mem, struct upl_mem)) +return log_msg_ret ("mem" , -ENOMEM ); + +return 0 ; +} + +/** +* decode_upl_memmap() - Decode memory-map nodes from the tree +* +* @upl: UPL state +* @root: Parent node containing the /memory-map nodes +* Return 0 if OK, -ve on error +*/ +static int decode_upl_memmap (struct upl *upl,ofnode root) +{ +ofnode node; + +ofnode_for_each_subnode (node, root) { +struct upl_memmap memmap; +int size, len, ret; +const char *buf; + + memmap.name =ofnode_get_name (node); + memmap.usage =0 ; + + buf =ofnode_read_prop (node,UPLP_REG , &size); +if (!buf) { +log_warning ("Node '%s': Missing '%s' property\n" , +ofnode_get_name (node),UPLP_REG ); +continue ; + } + + len =decode_addr_size (upl, buf, size, &memmap.region); +if (len <0 ) +return log_msg_ret ("buf" , len); + ret =ofnode_read_bitmask (node,UPLP_USAGE , usage_names, +UPLUS_COUNT , &memmap.usage); +if (ret && ret != -EINVAL )/* optional property */ +return log_msg_ret ("bit" , ret); + + if (!alist_add(&upl->memmap, memmap, struct upl_memmap)) +return log_msg_ret ("mmp" , -ENOMEM ); + } + +return 0 ; +} + +/** +* decode_upl_memres() - Decode reserved-memory nodes from the tree +* +* @upl: UPL state +* @root: Parent node containing the reserved-memory nodes +* Return 0 if OK, -ve on error +*/ +static int decode_upl_memres (struct upl *upl,ofnode root) +{ +ofnode node; + +ofnode_for_each_subnode (node, root) { +struct upl_memres memres; +const char *buf; +int size, len; + +log_debug ("decoding '%s'\n" ,ofnode_get_name (node)); + memres.name =ofnode_get_name (node); + + buf =ofnode_read_prop (node,UPLP_REG , &size); +if (!buf) { +log_warning ("Node '%s': Missing 'reg' property\n" , +ofnode_get_name (node)); +continue ; + } + + len =decode_addr_size (upl, buf, size, &memres.region); +if (len <0 ) +return log_msg_ret ("buf" , len); + memres.no_map =ofnode_read_bool (node,UPLP_NO_MAP ); + + if (!alist_add(&upl->memres, memres, struct upl_memres)) +return log_msg_ret ("mre" , -ENOMEM ); + } + +return 0 ; +} + +/** +* decode_upl_serial() - Decode the serial node +* +* @upl: UPL state +* @root: Parent node contain node +* Return 0 if OK, -ve on error +*/ +static int decode_upl_serial (struct upl *upl,ofnode node) +{ +struct upl_serial *ser = &upl->serial; +const char *buf; +int len, size; +int ret; + + ser->compatible =ofnode_read_string (node,UPLP_COMPATIBLE ); +if (!ser->compatible) { +log_warning ("Node '%s': Missing compatible string\n" , +ofnode_get_name (node)); +return log_msg_ret ("com" , -EINVAL ); + } + ret =read_uint (node,UPLP_CLOCK_FREQUENCY , &ser->clock_frequency); +if (!ret) + ret =read_uint (node,UPLP_CURRENT_SPEED , &ser->current_speed); +if (ret) +return log_msg_ret ("spe" , ret); + + buf =ofnode_read_prop (node,UPLP_REG , &size); +if (!buf) { +log_warning ("Node '%s': Missing 'reg' property\n" , +ofnode_get_name (node)); +return log_msg_ret ("reg" , -EINVAL ); + } + + len =decode_addr_size (upl, buf,sizeof (buf), &ser->reg); +if (len <0 ) +return log_msg_ret ("buf" , len); + +/* set defaults */ + ser->reg_io_shift =UPLD_REG_IO_SHIFT ; + ser->reg_offset =UPLD_REG_OFFSET ; + ser->reg_io_width =UPLD_REG_IO_WIDTH ; +read_uint (node,UPLP_REG_IO_SHIFT , &ser->reg_io_shift); +read_uint (node,UPLP_REG_OFFSET , &ser->reg_offset); +read_uint (node,UPLP_REG_IO_WIDTH , &ser->reg_io_width); +read_addr (upl, node,UPLP_VIRTUAL_REG , &ser->virtual_reg); + ret =ofnode_read_value (node,UPLP_ACCESS_TYPE , access_types, +ARRAY_SIZE (access_types), &ser->access_type); +if (ret && ret != -ENOENT ) +return log_msg_ret ("ser" , ret); + +return 0 ; +} + +/** +* decode_upl_graphics() - Decode graphics node +* +* @upl: UPL state +* @root: Node to decode +* Return 0 if OK, -ve on error +*/ +static int decode_upl_graphics (struct upl *upl,ofnode node) +{ +struct upl_graphics *gra = &upl->graphics; +const char *buf, *compat; +int len, size; +int ret; + + compat =ofnode_read_string (node,UPLP_COMPATIBLE ); +if (!compat) { +log_warning ("Node '%s': Missing compatible string\n" , +ofnode_get_name (node)); +return log_msg_ret ("com" , -EINVAL ); + } +if (strcmp (UPLC_GRAPHICS , compat)) { +log_warning ("Node '%s': Ignoring compatible '%s'\n" , +ofnode_get_name (node), compat); +return 0 ; + } + + buf =ofnode_read_prop (node,UPLP_REG , &size); +if (!buf) { +log_warning ("Node '%s': Missing 'reg' property\n" , +ofnode_get_name (node)); +return log_msg_ret ("reg" , -EINVAL ); + } + + len =decode_addr_size (upl, buf,sizeof (buf), &gra->reg); +if (len <0 ) +return log_msg_ret ("buf" , len); + + ret =read_uint (node,UPLP_WIDTH , &gra->width); +if (!ret) + ret =read_uint (node,UPLP_HEIGHT , &gra->height); +if (!ret) + ret =read_uint (node,UPLP_STRIDE , &gra->stride); +if (!ret) { + ret =ofnode_read_value (node,UPLP_GRAPHICS_FORMAT , + graphics_formats, +ARRAY_SIZE (graphics_formats), + &gra->format); + } +if (ret) +return log_msg_ret ("pro" , ret); + +return 0 ; +} + +int upl_read_handoff (struct upl *upl,oftree tree) +{ +ofnode root, node; +int ret; + +if (!oftree_valid (tree)) +return log_msg_ret ("tre" , -EINVAL ); + + root =oftree_root (tree); + +upl_init (upl); + ret =decode_root_props (upl, root); +if (ret) +return log_msg_ret ("roo" , ret); + +ofnode_for_each_subnode (node, root) { +const char *name =ofnode_get_name (node); + +log_debug ("decoding '%s'\n" , name); +if (!strcmp (UPLN_OPTIONS , name)) { + ret =decode_upl_params (upl, node); +if (ret) +return log_msg_ret ("opt" , ret); + + ret =decode_upl_images (upl, node); + }else if (node_matches_at (node,UPLN_MEMORY )) { + ret =decode_upl_memory_node (upl, node); + }else if (!strcmp (UPLN_MEMORY_MAP , name)) { + ret =decode_upl_memmap (upl, node); + }else if (!strcmp (UPLN_MEMORY_RESERVED , name)) { + ret =decode_upl_memres (upl, node); + }else if (node_matches_at (node,UPLN_SERIAL )) { + ret =decode_upl_serial (upl, node); + }else if (node_matches_at (node,UPLN_GRAPHICS )) { + ret =decode_upl_graphics (upl, node); + }else { +log_debug ("Unknown node '%s'\n" , name); + ret =0 ; + } +if (ret) +return log_msg_ret ("err" , ret); + } + +return 0 ; +}configs/sandbox_defconfig +1
-0@@ -15,6 +15,7 @@ CONFIG_FIT=y CONFIG_FIT_RSASSA_PSS=y CONFIG_FIT_CIPHER=y CONFIG_FIT_VERBOSE=y +CONFIG_UPL=y CONFIG_LEGACY_IMAGE_FORMAT=y CONFIG_MEASURED_BOOT=y CONFIG_BOOTSTAGE=yinclude/upl.h new file +352
-0@@ -0,0 +1,352 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* UPL handoff generation +* +* Copyright 2024 Google LLC +* Written by Simon Glass <[email protected]> +*/ + +#ifndef __UPL_WRITE_H +#define __UPL_WRITE_H + +#include <alist.h> +#include <dm/ofnode_decl.h> + +struct unit_test_state ; + +#define UPLP_ADDRESS_CELLS "#address-cells" +#define UPLP_SIZE_CELLS "#size-cells" + +#define UPLN_OPTIONS "options" +#define UPLN_UPL_PARAMS "upl-params" +#define UPLP_SMBIOS "smbios" +#define UPLP_ACPI "acpi" +#define UPLP_BOOTMODE "bootmode" +#define UPLP_ADDR_WIDTH "addr-width" +#define UPLP_ACPI_NVS_SIZE "acpi-nvs-size" + +#define UPLPATH_UPL_IMAGE "/options/upl-image" +#define UPLN_UPL_IMAGE "upl-image" +#define UPLN_IMAGE "image" +#define UPLP_FIT "fit" +#define UPLP_CONF_OFFSET "conf-offset" +#define UPLP_LOAD "load" +#define UPLP_SIZE "size" +#define UPLP_OFFSET "offset" +#define UPLP_DESCRIPTION "description" + +#define UPLN_MEMORY "memory" +#define UPLP_HOTPLUGGABLE "hotpluggable" + +#define UPLPATH_MEMORY_MAP "/memory-map" +#define UPLN_MEMORY_MAP "memory-map" +#define UPLP_USAGE "usage" + +#define UPLN_MEMORY_RESERVED "reserved-memory" +#define UPLPATH_MEMORY_RESERVED "/reserved-memory" +#define UPLP_NO_MAP "no-map" + +#define UPLN_SERIAL "serial" +#define UPLP_REG "reg" +#define UPLP_COMPATIBLE "compatible" +#define UPLP_CLOCK_FREQUENCY "clock-frequency" +#define UPLP_CURRENT_SPEED "current-speed" +#define UPLP_REG_IO_SHIFT "reg-io-shift" +#define UPLP_REG_OFFSET "reg-offset" +#define UPLP_REG_IO_WIDTH "reg-io-width" +#define UPLP_VIRTUAL_REG "virtual-reg" +#define UPLP_ACCESS_TYPE "access-type" + +#define UPLN_GRAPHICS "framebuffer" +#define UPLC_GRAPHICS "simple-framebuffer" +#define UPLP_WIDTH "width" +#define UPLP_HEIGHT "height" +#define UPLP_STRIDE "stride" +#define UPLP_GRAPHICS_FORMAT "format" + +/** +* enum upl_boot_mode - Encodes the boot mode +* +* Each is a bit number from the boot_mode mask +*/ +enum upl_boot_mode { +UPLBM_FULL , +UPLBM_MINIMAL , +UPLBM_FAST , +UPLBM_DIAG , +UPLBM_DEFAULT , +UPLBM_S2 , +UPLBM_S3 , +UPLBM_S4 , +UPLBM_S5 , +UPLBM_FACTORY , +UPLBM_FLASH , +UPLBM_RECOVERY , + +UPLBM_COUNT , +}; + +/** +* struct upl_image - UPL image informaiton +* +* @load: Address image was loaded to +* @size: Size of image in bytes +* @offset: Offset of the image in the FIT (0=none) +* @desc: Description of the iamge (taken from the FIT) +*/ +struct upl_image { +ulong load; +ulong size; +uint offset; +const char *description; +}; + +/** +* struct memregion - Information about a region of memory +* +* @base: Base address +* @size: Size in bytes +*/ +struct memregion { +ulong base; +ulong size; +}; + +/** +* struct upl_mem - Information about physical-memory layout +* +* TODO: Figure out initial-mapped-area +* +* @region: Memory region list (struct memregion) +* @hotpluggable: true if hotpluggable +*/ +struct upl_mem { +struct alist region; +bool hotpluggable; +}; + +/** +* enum upl_usage - Encodes the usage +* +* Each is a bit number from the usage mask +*/ +enum upl_usage { +UPLUS_ACPI_RECLAIM , +UPLUS_ACPI_NVS , +UPLUS_BOOT_CODE , +UPLUS_BOOT_DATA , +UPLUS_RUNTIME_CODE , +UPLUS_RUNTIME_DATA , +UPLUS_COUNT +}; + +/** +* struct upl_memmap - Information about logical-memory layout +* +* @name: Node name to use +* @region: Memory region list (struct memregion) +* @usage: Memory-usage mask (enum upl_usage) +*/ +struct upl_memmap { +const char *name; +struct alist region; +uint usage; +}; + +/** +* struct upl_memres - Reserved memory +* +* @name: Node name to use +* @region: Reserved memory region list (struct memregion) +* @no_map: true to indicate that a virtual mapping must not be created +*/ +struct upl_memres { +const char *name; +struct alist region; +bool no_map; +}; + +enum upl_serial_access_type { +UPLSAT_MMIO , +UPLSAT_IO , +}; + +/* serial defaults */ +enum { +UPLD_REG_IO_SHIFT =0 , +UPLD_REG_OFFSET =0 , +UPLD_REG_IO_WIDTH =1 , +}; + +/** +* enum upl_access_type - Access types +* +* @UPLAT_MMIO: Memory-mapped I/O +* @UPLAT_IO: Separate I/O +*/ +enum upl_access_type { +UPLAT_MMIO , +UPLAT_IO , +}; + +/** +* struct upl_serial - Serial console +* +* @compatible: Compatible string (NULL if there is no serial console) +* @clock_frequency: Input clock frequency of UART +* @current_speed: Current baud rate of UART +* @reg: List of base address and size of registers (struct memregion) +* @reg_shift_log2: log2 of distance between each register +* @reg_offset: Offset of registers from the base address +* @reg_width: Register width in bytes +* @virtual_reg: Virtual register access (0 for none) +* @access_type: Register access type to use +*/ +struct upl_serial { +const char *compatible; +uint clock_frequency; +uint current_speed; +struct alist reg; +uint reg_io_shift; +uint reg_offset; +uint reg_io_width; +ulong virtual_reg; +enum upl_serial_access_type access_type; +}; + +/** +* enum upl_graphics_format - Graphics formats +* +* @UPLGF_ARGB32: 32bpp format using 0xaarrggbb +* @UPLGF_ABGR32: 32bpp format using 0xaabbggrr +* @UPLGF_ARGB64: 64bpp format using 0xaaaabbbbggggrrrr +*/ +enum upl_graphics_format { +UPLGF_ARGB32 , +UPLGF_ABGR32 , +UPLGF_ABGR64 , +}; + +/** +* @reg: List of base address and size of registers (struct memregion) +* @width: Width of display in pixels +* @height: Height of display in pixels +* @stride: Number of bytes from one line to the next +* @format: Pixel format +*/ +struct upl_graphics { +struct alist reg; +uint width; +uint height; +uint stride; +enum upl_graphics_format format; +}; + +/* +* Information about the UPL state +* +* @addr_cells: Number of address cells used in the handoff +* @size_cells: Number of size cells used in the handoff +* @bootmode: Boot-mode mask (enum upl_boot_mode) +* @fit: Address of FIT image that was loaded +* @conf_offset: Offset in FIT of the configuration that was selected +* @addr_width: Adress-bus width of machine, e.g. 46 for 46 bits +* @acpi_nvs_size: Size of the ACPI non-volatile-storage area in bytes +* @image: Information about each image (struct upl_image) +* @mem: Information about physical-memory regions (struct upl_mem) +* @nennap: Information about logical-memory regions (struct upl_memmap) +* @nennap: Information about reserved-memory regions (struct upl_memres) +*/ +struct upl { +int addr_cells; +int size_cells; + +ulong smbios; +ulong acpi; +uint bootmode; +ulong fit; +uint conf_offset; +uint addr_width; +uint acpi_nvs_size; + +struct alist image; +struct alist mem; +struct alist memmap; +struct alist memres; +struct upl_serial serial; +struct upl_graphics graphics; +}; + +/** +* upl_write_handoff() - Write a Unversal Payload handoff structure +* +* upl: UPL state to write +* @root: root node to write it to +* @skip_existing: Avoid recreating any nodes which already exist in the +* devicetree. For example, if there is a serial node, just leave it alone, +* since don't need to create a new one +* Return: 0 on success, -ve on error +*/ +int upl_write_handoff (const struct upl *upl,ofnode root,bool skip_existing); + +/** +* upl_create_handoff_tree() - Write a Unversal Payload handoff structure +* +* upl: UPL state to write +* @treep: Returns a new tree containing the handoff +* Return: 0 on success, -ve on error +*/ +int upl_create_handoff_tree (const struct upl *upl,oftree *treep); + +/** +* upl_read_handoff() - Read a Unversal Payload handoff structure +* +* upl: UPL state to read into +* @tree: Devicetree containing the data to read +* Return: 0 on success, -ve on error +*/ +int upl_read_handoff (struct upl *upl,oftree tree); + +#if CONFIG_IS_ENABLED (UPL ) + +/** +* upl_set_fit_info() - Set up basic info about the FIT +* +* @fit: Address of FIT +* @conf_offset: Configuration node being used +* @entry_addr: Entry address for next phase +*/ +void upl_set_fit_info (ulong fit,int conf_offset,ulong entry_addr); + +/** +* upl_set_fit_addr() - Set up the address of the FIT +* +* @fit: Address of FIT +*/ +void upl_set_fit_addr (ulong fit); + +/** +* upl_add_image() - Add a new image to the UPL +* +* @node: Image node offset in FIT +* @load_addr: Address to which images was loaded +* @size: Image size in bytes +* @desc: Description of image +*/ +int upl_add_image (int node,ulong load_addr,ulong size,const char *desc); + +#else +static inline void upl_set_fit_addr (ulong fit) {} +static inline void upl_set_fit_info (ulong fit,int conf_offset, +ulong entry_addr) {} +static inline int upl_add_image (int node,ulong load_addr,ulong size, +const char *desc) +{ +return 0 ; +} +#endif /* UPL */ + +/** upl_init() - Set up a UPL struct */ +void upl_init (struct upl *upl); + +#endif /* __UPL_WRITE_H */
Re: [PATCH v2 10/21] upl: Add support for reading a upl handoff
Hi Heinrich,
Quoted 25 lines · Heinrich Schuchardt
Quoted 23 lines · Simon Glass
Universal Payload provides a standard way of handing off control between two firmware phases. Add support for reading the handoff information into a structure.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
MAINTAINERS | 7 + boot/Kconfig | 19 ++ boot/Makefile | 3 + boot/upl_common.c | 60 ++++ boot/upl_common.h | 24 ++ boot/upl_read.c | 588 ++++++++++++++++++++++++++++++++++++++ configs/sandbox_defconfig | 1 + include/upl.h | 352 +++++++++++++++++++++++ 8 files changed, 1054 insertions(+)create mode 100644
boot/upl_common.c
create mode 100644boot/upl_common.h
create mode 100644boot/upl_read.c
create mode 100644include/upl.h
[..]
Quoted 6 lines
Quoted 6 lines
boot/upl_read.c new file +0
-0@@ -0,0 +1,588 @@
[..]
Quoted 10 lines
Quoted 10 lines
boot/upl_read.c new file +10
-0+/** +* decode_root_props() - Decode root properties from the tree +* +* @upl: UPL state +* @node: Node to decode +* Return 0 if OK, -ve on error +*/ +static int decode_root_props (struct upl *upl,ofnode node) +{ +int ret;
Quoted 8 lines
boot/upl_read.c line 188
Quoted 4 lines
boot/upl_read.c new file +4
-0+ + ret =read_uint (node,UPLP_ADDRESS_CELLS , &upl->addr_cells); +if (!ret) + ret =read_uint (node,UPLP_SIZE_CELLS , &upl->size_cells);Why do we need a special handling of
addr_cellsandsize_cells? The device-tree provided by UPL follows the device-tree specification which requires to set these properties in the parent of the node.
This is just decoding the information so it can be used later as needed. For example, we might want to validate that it is correct before using the data.
[..]
Regards,
Simon
PATCH v2 11/21 upl: Add support for writing a upl handoff
In reply to Simon GlassUniversal Payload provides a standard way of handing off control between two firmware phases. Add support for writing the handoff information from a structure.
---
(no changes since v1)
boot/Kconfig | 8 + boot/Makefile | 1 + boot/upl_write.c | 622 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 631 insertions(+) create mode 100644 boot/upl_write.c
boot/Kconfig +8 -0
@@ -722,6 +722,7 @@ config BOOTMETH_SCRIPT config UPL bool "upl - Universal Payload Specification" imply UPL_READ + imply UPL_WRITE help Provides support for UPL payloads and handoff information. U-Boot supports generating and accepting handoff information. The mkimage
@@ -736,6 +737,13 @@ config UPL_READ which can be used elsewhere in U-Boot. This is just the reading implementation, useful for trying it out. +config UPL_WRITE + bool "upl - Support writing a Universal Payload handoff" + help + Provides support for encoding a UPL-format payload from a C structure + so it can be passed to another program. This is just the writing + implementation, useful for trying it out. + endif # UPL endif # BOOTSTD
boot/Makefile +1 -0
@@ -45,6 +45,7 @@ obj-$(CONFIG_$(SPL_TPL_)FDT_SIMPLEFB) += fdt_simplefb.o obj-$(CONFIG_$(SPL_TPL_)UPL) += upl_common.o obj-$(CONFIG_$(SPL_TPL_)UPL_READ) += upl_read.o +obj-$(CONFIG_$(SPL_TPL_)UPL_WRITE) += upl_write.o obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += image-fdt.o obj-$(CONFIG_$(SPL_TPL_)FIT_SIGNATURE) += fdt_region.o
boot/upl_write.c new file +622 -0
622 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v2 12/21 upl: Add basic tests
In reply to Simon GlassAdd some unit tests to check that we can write a UPL handoff and read it back.
---
Changes in v2:
- Put the upl tests under their own subcommand to avoid bootstd init
MAINTAINERS | 1 + include/test/suites.h | 1 + include/upl.h | 9 ++ test/boot/Makefile | 2 + test/boot/upl.c | 368 ++++++++++++++++++++++++++++++++++++++++++ test/cmd_ut.c | 3 + 6 files changed, 384 insertions(+) create mode 100644 test/boot/upl.c
MAINTAINERS +1 -0
@@ -1700,6 +1700,7 @@ S: Maintained T: git https://source.denx.de/u-boot/custodians/u-boot-dm.git F: boot/upl* F: include/upl.h +F: test/boot/upl.c USB M: Marek Vasut <[email protected]>
include/test/suites.h +1 -0
@@ -63,5 +63,6 @@ int do_ut_str(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);int do_ut_time (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]);int do_ut_unicode (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]); +int do_ut_upl (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]);#endif /* __TEST_SUITES_H__ */
include/upl.h +9 -0
@@ -307,6 +307,15 @@ int upl_create_handoff_tree(const struct upl *upl, oftree *treep);*/ int upl_read_handoff (struct upl *upl,oftree tree); +/** +* upl_get_test_data() - Fill a UPL with some test data +* +* @uts: Test state (can be uninited) +* @upl: Returns test data +* Return: 0 on success, 1 on error +*/ +int upl_get_test_data (struct unit_test_state *uts,struct upl *upl); +#if CONFIG_IS_ENABLED (UPL )/**
test/boot/Makefile +2 -0
@@ -13,3 +13,5 @@ ifdef CONFIG_OF_LIVE obj-$(CONFIG_BOOTMETH_VBE_SIMPLE) += vbe_simple.o endif obj-$(CONFIG_BOOTMETH_VBE) += vbe_fixup.o + +obj-$(CONFIG_UPL) += upl.o
test/boot/upl.c new file +368 -0
368 lines not on this page · raw message
test/cmd_ut.c +3 -0
@@ -133,6 +133,9 @@ static struct cmd_tbl cmd_ut_sub[] = {#ifdef CONFIG_CMD_SEAMA U_BOOT_CMD_MKENT(seama, CONFIG_SYS_MAXARGS, 1, do_ut_seama, "", ""),#endif +#ifdef CONFIG_CMD_UPL + U_BOOT_CMD_MKENT(upl, CONFIG_SYS_MAXARGS, 1, do_ut_upl, "", ""), +#endif }; static int do_ut_all(struct cmd_tbl *cmdtp, int flag, int argc,
Signature · 1 line
2.34.1
PATCH v2 13/21 upl: Add a command
In reply to Simon GlassAdd a 'upl' command to work with Universal Payload features. For now it only supports reading and writing a handoff structure.
---
(no changes since v1)
MAINTAINERS | 2 + boot/Kconfig | 1 + cmd/Kconfig | 7 ++ cmd/Makefile | 1 + cmd/upl.c | 118 +++++++++++++++++++ doc/usage/cmd/upl.rst | 186 ++++++++++++++++++++++++++++++ doc/usage/index.rst | 1 + include/asm-generic/global_data.h | 15 +++ test/boot/upl.c | 40 +++++++ 9 files changed, 371 insertions(+) create mode 100644 cmd/upl.c create mode 100644 doc/usage/cmd/upl.rst
MAINTAINERS +2 -0
@@ -1699,6 +1699,8 @@ M: Simon Glass <[email protected]> S: Maintained T: git https://source.denx.de/u-boot/custodians/u-boot-dm.git F: boot/upl* +F: cmd/upl.c +F: doc/usage/cmd/upl.rst F: include/upl.h F: test/boot/upl.c
boot/Kconfig +1 -0
@@ -721,6 +721,7 @@ config BOOTMETH_SCRIPT config UPL bool "upl - Universal Payload Specification" + imply CMD_UPL imply UPL_READ imply UPL_WRITE help
cmd/Kconfig +7 -0
@@ -388,6 +388,13 @@ config CMD_SEAMA help Support reading NAND Seattle Image (SEAMA) images. +config CMD_UPL + bool "upl - Universal Payload Specification" + help + Provides commands to deal with UPL payloads and handoff information. + U-Boot supports generating and accepting handoff information. The + mkimage tool will eventually support creating payloads. + config CMD_VBE bool "vbe - Verified Boot for Embedded" depends on BOOTMETH_VBE
cmd/Makefile +1 -0
@@ -189,6 +189,7 @@ obj-$(CONFIG_CMD_UBIFS) += ubifs.o obj-$(CONFIG_CMD_UNIVERSE) += universe.o obj-$(CONFIG_CMD_UNLZ4) += unlz4.o obj-$(CONFIG_CMD_UNZIP) += unzip.o +obj-$(CONFIG_CMD_UPL) += upl.o obj-$(CONFIG_CMD_VIRTIO) += virtio.o obj-$(CONFIG_CMD_WDT) += wdt.o obj-$(CONFIG_CMD_LZMADEC) += lzmadec.o
cmd/upl.c new file +118 -0
118 lines not on this page · raw message
doc/usage/cmd/upl.rst new file +186 -0
186 lines not on this page · raw message
doc/usage/index.rst +1 -0
@@ -112,6 +112,7 @@ Shell commands cmd/tftpput cmd/trace cmd/true + cmd/upl cmd/ums cmd/unbind cmd/ut
include/asm-generic/global_data.h +15 -0
@@ -30,6 +30,7 @@struct acpi_ctx ;struct driver_rt ; +struct upl ;typedef struct global_data gd_t ;
@@ -491,6 +492,12 @@ struct global_data {* @dmtag_list: List of DM tags */ struct list_head dmtag_list; +#if CONFIG_IS_ENABLED (UPL ) +/** +* @upl: Universal Payload-handoff information +*/ +struct upl *upl; +#endif };#ifndef DO_DEPS_ONLY static_assert (sizeof (struct global_data ) ==GD_SIZE );
@@ -590,6 +597,14 @@ static_assert(sizeof(struct global_data) == GD_SIZE);#define gd_malloc_ptr () 0L#endif +#if CONFIG_IS_ENABLED (UPL ) +#define gd_upl () gd->upl +#define gd_set_upl (_val) gd->upl = (_val) +#else +#define gd_upl () NULL +#define gd_set_upl (val) +#endif +/** * enum gd_flags - global data flags *
test/boot/upl.c +40 -0
@@ -358,6 +358,46 @@ static int upl_test_base(struct unit_test_state *uts) }UPL_TEST (upl_test_base,0 ); +/* Test 'upl info' command */ +static int upl_test_info (struct unit_test_state *uts) +{ +gd_set_upl (NULL ); +ut_assertok (run_command ("upl info" ,0 )); +ut_assert_nextline ("UPL state: inactive" ); +ut_assert_console_end (); + +gd_set_upl ((struct upl *)uts);/* set it to any non-zero value */ +ut_assertok (run_command ("upl info" ,0 )); +ut_assert_nextline ("UPL state: active" ); +ut_assert_console_end (); +gd_set_upl (NULL ); + +return 0 ; +} +UPL_TEST (upl_test_info,UT_TESTF_CONSOLE_REC ); + +/* Test 'upl read' and 'upl_write' commands */ +static int upl_test_read_write (struct unit_test_state *uts) +{ +ulong addr; + +if (!CONFIG_IS_ENABLED (OFNODE_MULTI_TREE )) +return -EAGAIN ;/* skip test */ +ut_assertok (run_command ("upl write" ,0 )); + + addr =env_get_hex ("upladdr" ,0 ); +ut_assert_nextline ("UPL handoff written to %lx size %lx" , addr, +env_get_hex ("uplsize" ,0 )); +ut_assert_console_end (); + +ut_assertok (run_command ("upl read ${upladdr}" ,0 )); +ut_assert_nextline ("Reading UPL at %lx" , addr); +ut_assert_console_end (); + +return 0 ; +} +UPL_TEST (upl_test_read_write,UT_TESTF_CONSOLE_REC ); +int do_ut_upl (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) {struct unit_test *tests =UNIT_TEST_SUITE_START (upl_test);
Signature · 1 line
2.34.1
PATCH v2 14/21 upl: Add support for Universal Payload in SPL
In reply to Simon GlassAdd the basic code to create a handoff structure in SPL, so it can be passed to the next phase. For now this is not plumbed in.
---
Changes in v2:
- Add a function to init the UPL process in SPL
MAINTAINERS | 1 + boot/Kconfig | 32 ++++++++ common/spl/Makefile | 2 + common/spl/spl_upl.c | 171 +++++++++++++++++++++++++++++++++++++++++++ include/spl.h | 16 ++++ 5 files changed, 222 insertions(+) create mode 100644 common/spl/spl_upl.c
MAINTAINERS +1 -0
@@ -1700,6 +1700,7 @@ S: Maintained T: git https://source.denx.de/u-boot/custodians/u-boot-dm.git F: boot/upl* F: cmd/upl.c +F: common/spl/spl_upl.c F: doc/usage/cmd/upl.rst F: include/upl.h F: test/boot/upl.c
boot/Kconfig +32 -0
@@ -724,6 +724,7 @@ config UPL imply CMD_UPL imply UPL_READ imply UPL_WRITE + imply SPL_UPL if SPL help Provides support for UPL payloads and handoff information. U-Boot supports generating and accepting handoff information. The mkimage
@@ -740,11 +741,42 @@ config UPL_READ config UPL_WRITE bool "upl - Support writing a Universal Payload handoff" + help + Provides support for encoding a UPL-format payload from a C structure + so it can be passed to another program. This is just the writing + implementation, useful for trying it out. See SPL_UPL_OUT + for how to tell U-Boot SPL to actually write it before jumping to + the next phase. + +if SPL + +config SPL_UPL + bool "Write a UPL handoff in SPL" + imply SPL_UPL_OUT + help + This tells SPL to write a UPL handoff and pass it to the next phase + (e.g. to U-Boot or another program which SPL loads and runs). THis + provides information to help that program run correctly and + efficiently on the machine. + +config SPL_UPL_WRITE + bool # upl - Support writing a Universal Payload handoff in SPL + select SPL_BLOBLIST help Provides support for encoding a UPL-format payload from a C structure so it can be passed to another program. This is just the writing implementation, useful for trying it out. +config SPL_UPL_OUT + bool "upl - Support writing a Universal Payload handoff in SPL" + select SPL_UPL_WRITE + help + Provides support for encoding a UPL-format payload and passing it to + the next firmware phase. This allows U-Boot SPL to function as + Platform Init in the meaning of the specification. + +endif # SPL + endif # UPL endif # BOOTSTD
common/spl/Makefile +2 -0
@@ -37,3 +37,5 @@ obj-$(CONFIG_$(SPL_TPL_)SPI_LOAD) += spl_spi.o obj-$(CONFIG_$(SPL_TPL_)RAM_SUPPORT) += spl_ram.o obj-$(CONFIG_$(SPL_TPL_)USB_SDP_SUPPORT) += spl_sdp.o endif + +obj-$(CONFIG_$(SPL_TPL_)UPL) += spl_upl.o
common/spl/spl_upl.c new file +171 -0
171 lines not on this page · raw message
include/spl.h +16 -0
@@ -1074,4 +1074,20 @@ static inline bool spl_decompression_enabled(void) {return IS_ENABLED (CONFIG_SPL_GZIP ) ||IS_ENABLED (CONFIG_SPL_LZMA ); } + +/** +* spl_write_upl_handoff() - Write a Universal Payload hand-off structure +* +* @spl_image: Information about the image being booted +* Return: 0 if OK, -ve on error +*/ +int spl_write_upl_handoff (struct spl_image_info *spl_image); + +/** +* spl_upl_init() - Get UPL ready for information to be added +* +* This must be called before upl_add_image(), etc. +*/ +void spl_upl_init (void ); +#endif
Signature · 1 line
2.34.1
PATCH v2 15/21 spl: Plumb in the Universal Payload handoff
In reply to Simon GlassSpecify the FIT and include information about each loaded image, as required by the UPL handoff.
Write the UPL handoff into the bloblist before jumping to the next phase.
Control this using a runtime flag to avoid conflicting with other handoff mechanisms.
---
Changes in v2:
- Hang when something goes wrong, to avoid a broken boot
- Add a runtime flag to enable UPL
common/spl/spl.c | 8 ++++++++ common/spl/spl_fit.c | 22 ++++++++++++++++++++++ include/asm-generic/global_data.h | 4 ++++ 3 files changed, 34 insertions(+)
common/spl/spl.c +8 -0
@@ -810,6 +810,14 @@ void board_init_r(gd_t *dummy1, ulong dummy2)printf (SPL_TPL_PROMPT "SPL hand-off write failed (err=%d)\n" , ret); } +if (CONFIG_IS_ENABLED (UPL_OUT ) && (gd->flags &GD_FLG_UPL )) { + ret =spl_write_upl_handoff (&spl_image); +if (ret) { +printf (SPL_TPL_PROMPT +"UPL hand-off write failed (err=%d)\n" , ret); +hang (); + } + }if (CONFIG_IS_ENABLED (BLOBLIST )) { ret =bloblist_finish ();if (ret)
common/spl/spl_fit.c +22 -0
@@ -12,6 +12,7 @@#include <memalign.h> #include <mapmem.h> #include <spl.h> +#include <upl.h> #include <sysinfo.h> #include <asm/global_data.h> #include <asm/io.h>
@@ -645,6 +646,8 @@ static int spl_fit_load_fpga(struct spl_fit_info *ctx,printf ("%s: Cannot load the FPGA: %i\n" , __func__, ret);return ret; } +upl_add_image (node, fpga_image.load_addr, fpga_image.size, +fdt_getprop (ctx->fit, node,FIT_DESC_PROP ,NULL ));return spl_fit_upload_fpga (ctx, node, &fpga_image); }
@@ -768,6 +771,9 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,if (ret)return ret; +upl_add_image (node, spl_image->load_addr, spl_image->size, +fdt_getprop (ctx.fit, node,FIT_DESC_PROP ,NULL )); +/* * For backward compatibility, we treat the first node that is * as a U-Boot image, if no OS-type has been declared.
@@ -811,6 +817,8 @@ int spl_load_simple_fit(struct spl_image_info *spl_image, __func__, index, ret);return ret; } +upl_add_image (node, image_info.load_addr, image_info.size, +fdt_getprop (ctx.fit, node,FIT_DESC_PROP ,NULL ));if (spl_fit_image_is_fpga (ctx.fit, node))spl_fit_upload_fpga (&ctx, node, &image_info);
@@ -847,6 +855,8 @@ int spl_load_simple_fit(struct spl_image_info *spl_image, spl_image->entry_point = spl_image->load_addr; spl_image->flags |=SPL_FIT_FOUND ; +upl_set_fit_info (map_to_sysmem (ctx.fit), ctx.conf_node, + spl_image->entry_point);return 0 ; }
@@ -891,6 +901,9 @@ int spl_load_fit_image(struct spl_image_info *spl_image,if (ret <0 )return ret; +upl_add_image (ret, fw_data, fw_len, +fdt_getprop ((void *)header, ret,FIT_DESC_PROP ,NULL )); + spl_image->size = fw_len; spl_image->load_addr = fw_data;if (fit_image_get_entry (header, ret, &spl_image->entry_point))
@@ -911,6 +924,9 @@ int spl_load_fit_image(struct spl_image_info *spl_image,if (ret >=0 ) { spl_image->fdt_addr = (void *)dt_data; +upl_add_image (ret, dt_data, dt_len, +fdt_getprop ((void *)header, ret,FIT_DESC_PROP ,NULL )); +if (spl_image->os ==IH_OS_U_BOOT ) {/* HACK: U-Boot expects FDT at a specific address */ fdt_hack = spl_image->load_addr + spl_image->size;
@@ -940,7 +956,13 @@ int spl_load_fit_image(struct spl_image_info *spl_image, &img_data, &img_len);if (ret <0 )return ret; +upl_add_image (ret, img_data, img_len, +fdt_getprop ((void *)header, ret,FIT_DESC_PROP ,NULL )); } + spl_image->flags |=SPL_FIT_FOUND ; +upl_set_fit_info (map_to_sysmem (header), conf_noffset, + spl_image->entry_point); +return 0 ; }
include/asm-generic/global_data.h +4 -0
@@ -716,6 +716,10 @@ enum gd_flags {* @GD_FLG_HUSH_MODERN_PARSER: Use hush 2021 parser. */ GD_FLG_HUSH_MODERN_PARSER =0x2000000 , +/** +* @GD_FLG_UPL: Read/write a Universal Payload (UPL) handoff +*/ + GD_FLG_UPL = 0x4000000, };#endif /* __ASSEMBLY__ */
Signature · 1 line
2.34.1
Re: [PATCH v2 15/21] spl: Plumb in the Universal Payload handoff
Quoted 52 lines · Simon Glass
Specify the FIT and include information about each loaded image, as required by the UPL handoff.
Write the UPL handoff into the bloblist before jumping to the next phase.
Control this using a runtime flag to avoid conflicting with other handoff mechanisms.
Signed-off-by Simon Glass <[email protected]>---
Changes in v2:
- Hang when something goes wrong, to avoid a broken boot
- Add a runtime flag to enable UPLcommon/spl/spl.c | 8 ++++++++ common/spl/spl_fit.c | 22 ++++++++++++++++++++++ include/asm-generic/global_data.h | 4 ++++ 3 files changed, 34 insertions(+)common/spl/spl.c +8
-0@@ -810,6 +810,14 @@ void board_init_r(gd_t *dummy1, ulong dummy2)printf (SPL_TPL_PROMPT "SPL hand-off write failed (err=%d)\n" , ret); } +if (CONFIG_IS_ENABLED (UPL_OUT ) && (gd->flags &GD_FLG_UPL )) { + ret =spl_write_upl_handoff (&spl_image); +if (ret) { +printf (SPL_TPL_PROMPT +"UPL hand-off write failed (err=%d)\n" , ret); +hang (); + } + }if (CONFIG_IS_ENABLED (BLOBLIST )) { ret =bloblist_finish ();if (ret)common/spl/spl_fit.c +1
-0@@ -12,6 +12,7 @@#include <memalign.h> #include <mapmem.h> #include <spl.h> +#include <upl.h> #include <sysinfo.h> #include <asm/global_data.h> #include <asm/io.h>
common/spl/spl_fit.c static int spl_fit_load_fpga(struct spl_fit_info *ctx, · line 650
Quoted 5 lines
common/spl/spl_fit.c +2
-0@@ -645,6 +646,8 @@ static int spl_fit_load_fpga(struct spl_fit_info *ctx,printf ("%s: Cannot load the FPGA: %i\n" , __func__, ret);return ret; } +upl_add_image (node, fpga_image.load_addr, fpga_image.size, +fdt_getprop (ctx->fit, node,FIT_DESC_PROP ,NULL ));
Does load_addr even make sense for FPGAs?
And I noticed that you always call this after load_simple_fit/fit_image_load. Could we call upl_add_image in those functions instead?
Quoted 22 lines
common/spl/spl_fit.c +5
-0return spl_fit_upload_fpga (ctx, node, &fpga_image); }@@ -768,6 +771,9 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,if (ret)return ret; +upl_add_image (node, spl_image->load_addr, spl_image->size, +fdt_getprop (ctx.fit, node,FIT_DESC_PROP ,NULL )); +/* * For backward compatibility, we treat the first node that is * as a U-Boot image, if no OS-type has been declared. @@ -811,6 +817,8 @@ int spl_load_simple_fit(struct spl_image_info *spl_image, __func__, index, ret);return ret; } +upl_add_image (node, image_info.load_addr, image_info.size, +fdt_getprop (ctx.fit, node,FIT_DESC_PROP ,NULL ));if (spl_fit_image_is_fpga (ctx.fit, node))spl_fit_upload_fpga (&ctx, node, &image_info);
common/spl/spl_fit.c int spl_load_simple_fit(struct spl_image_info *spl_image, · line 859
Quoted 5 lines
common/spl/spl_fit.c +2
-0@@ -847,6 +855,8 @@ int spl_load_simple_fit(struct spl_image_info *spl_image, spl_image->entry_point = spl_image->load_addr; spl_image->flags |=SPL_FIT_FOUND ; +upl_set_fit_info (map_to_sysmem (ctx.fit), ctx.conf_node, + spl_image->entry_point);
I think this should be virt_to_phys, since we aren't really mapping it.
Quoted 24 lines
common/spl/spl_fit.c +6
-0return 0 ; }@@ -891,6 +901,9 @@ int spl_load_fit_image(struct spl_image_info *spl_image,if (ret <0 )return ret; +upl_add_image (ret, fw_data, fw_len, +fdt_getprop ((void *)header, ret,FIT_DESC_PROP ,NULL )); + spl_image->size = fw_len; spl_image->load_addr = fw_data;if (fit_image_get_entry (header, ret, &spl_image->entry_point))@@ -911,6 +924,9 @@ int spl_load_fit_image(struct spl_image_info *spl_image,if (ret >=0 ) { spl_image->fdt_addr = (void *)dt_data; +upl_add_image (ret, dt_data, dt_len, +fdt_getprop ((void *)header, ret,FIT_DESC_PROP ,NULL )); +if (spl_image->os ==IH_OS_U_BOOT ) {/* HACK: U-Boot expects FDT at a specific address */ fdt_hack = spl_image->load_addr + spl_image->size;
common/spl/spl_fit.c int spl_load_fit_image(struct spl_image_info *spl_image, · line 963
Quoted 8 lines
common/spl/spl_fit.c +3
-0@@ -940,7 +956,13 @@ int spl_load_fit_image(struct spl_image_info *spl_image, &img_data, &img_len);if (ret <0 )return ret; +upl_add_image (ret, img_data, img_len, +fdt_getprop ((void *)header, ret,FIT_DESC_PROP ,NULL )); } + spl_image->flags |=SPL_FIT_FOUND ;
This change is unrelated and should be moved into a separate commit.
Quoted 20 lines
common/spl/spl_fit.c +3
-0+upl_set_fit_info (map_to_sysmem (header), conf_noffset, + spl_image->entry_point); +return 0 ; }include/asm-generic/global_data.h +4
-0@@ -716,6 +716,10 @@ enum gd_flags {* @GD_FLG_HUSH_MODERN_PARSER: Use hush 2021 parser. */ GD_FLG_HUSH_MODERN_PARSER =0x2000000 , +/** +* @GD_FLG_UPL: Read/write a Universal Payload (UPL) handoff +*/ + GD_FLG_UPL = 0x4000000, };#endif /* __ASSEMBLY__ */
Re: [PATCH v2 15/21] spl: Plumb in the Universal Payload handoff
Hi Sean,
Quoted 53 lines · Sean Anderson
Quoted 51 lines · Simon Glass
Specify the FIT and include information about each loaded image, as required by the UPL handoff.
Write the UPL handoff into the bloblist before jumping to the next phase.
Control this using a runtime flag to avoid conflicting with other handoff mechanisms.
Signed-off-by Simon Glass <[email protected]>---
Changes in v2:
- Hang when something goes wrong, to avoid a broken boot
- Add a runtime flag to enable UPLcommon/spl/spl.c | 8 ++++++++ common/spl/spl_fit.c | 22 ++++++++++++++++++++++ include/asm-generic/global_data.h | 4 ++++ 3 files changed, 34 insertions(+)common/spl/spl.c +8
-0@@ -810,6 +810,14 @@ void board_init_r(gd_t *dummy1, ulong dummy2)printf (SPL_TPL_PROMPT "SPL hand-off write failed (err=%d)\n" , ret); } +if (CONFIG_IS_ENABLED (UPL_OUT ) && (gd->flags &GD_FLG_UPL )) { + ret =spl_write_upl_handoff (&spl_image); +if (ret) { +printf (SPL_TPL_PROMPT +"UPL hand-off write failed (err=%d)\n" , ret); +hang (); + } + }if (CONFIG_IS_ENABLED (BLOBLIST )) { ret =bloblist_finish ();if (ret)common/spl/spl_fit.c +1
-0@@ -12,6 +12,7 @@#include <memalign.h> #include <mapmem.h> #include <spl.h> +#include <upl.h> #include <sysinfo.h> #include <asm/global_data.h> #include <asm/io.h>
Quoted 8 lines
common/spl/spl_fit.c static int spl_fit_load_fpga(struct spl_fit_info *ctx, · line 650
Quoted 6 lines
common/spl/spl_fit.c +2
-0@@ -645,6 +646,8 @@ static int spl_fit_load_fpga(struct spl_fit_info *ctx,printf ("%s: Cannot load the FPGA: %i\n" , __func__, ret);return ret; } +upl_add_image (node, fpga_image.load_addr, fpga_image.size, +fdt_getprop (ctx->fit, node,FIT_DESC_PROP ,NULL ));Does
load_addreven make sense for FPGAs?
Well the images do get loaded into RAM at a particular address.
Quoted 3 lines
And I noticed that you always call this after load_simple_fit/fit_image_load. Could we call
upl_add_imagein those functions instead?
Yes, although it means compiling upl.h for the host. Perhaps it isn't that bad though and it avoids repeating code.
Quoted 25 lines
Quoted 25 lines
common/spl/spl_fit.c +5
-0return spl_fit_upload_fpga (ctx, node, &fpga_image); }@@ -768,6 +771,9 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,if (ret)return ret; +upl_add_image (node, spl_image->load_addr, spl_image->size, +fdt_getprop (ctx.fit, node,FIT_DESC_PROP ,NULL )); +/* * For backward compatibility, we treat the first node that is * as a U-Boot image, if no OS-type has been declared. @@ -811,6 +817,8 @@ int spl_load_simple_fit(struct spl_image_info *spl_image, __func__, index, ret);return ret; } +upl_add_image (node, image_info.load_addr, image_info.size, +fdt_getprop (ctx.fit, node,FIT_DESC_PROP ,NULL ));if (spl_fit_image_is_fpga (ctx.fit, node))spl_fit_upload_fpga (&ctx, node, &image_info);@@ -847,6 +855,8 @@ int spl_load_simple_fit(struct spl_image_info *spl_image, spl_image->entry_point = spl_image->load_addr;
Quoted 5 lines
common/spl/spl_fit.c int spl_load_simple_fit(struct spl_image_info *spl_image, · line 859
Quoted 3 lines
common/spl/spl_fit.c +2
-0spl_image->flags |=SPL_FIT_FOUND ; +upl_set_fit_info (map_to_sysmem (ctx.fit), ctx.conf_node, + spl_image->entry_point);I think this should be
virt_to_phys, since we aren't really mapping it.
We want to pass the address, which (for sandbox) has to be able to be mapped back to a pointer. Everywhere else in sandbox this is how we handle that...
Quoted 32 lines
Quoted 32 lines
common/spl/spl_fit.c +8
-0return 0 ; }@@ -891,6 +901,9 @@ int spl_load_fit_image(struct spl_image_info *spl_image,if (ret <0 )return ret; +upl_add_image (ret, fw_data, fw_len, +fdt_getprop ((void *)header, ret,FIT_DESC_PROP ,NULL )); + spl_image->size = fw_len; spl_image->load_addr = fw_data;if (fit_image_get_entry (header, ret, &spl_image->entry_point))@@ -911,6 +924,9 @@ int spl_load_fit_image(struct spl_image_info *spl_image,if (ret >=0 ) { spl_image->fdt_addr = (void *)dt_data; +upl_add_image (ret, dt_data, dt_len, +fdt_getprop ((void *)header, ret,FIT_DESC_PROP ,NULL )); +if (spl_image->os ==IH_OS_U_BOOT ) {/* HACK: U-Boot expects FDT at a specific address */ fdt_hack = spl_image->load_addr + spl_image->size;@@ -940,7 +956,13 @@ int spl_load_fit_image(struct spl_image_info *spl_image, &img_data, &img_len);if (ret <0 )return ret; +upl_add_image (ret, img_data, img_len, +fdt_getprop ((void *)header, ret,FIT_DESC_PROP ,NULL )); }
Quoted 3 lines
common/spl/spl_fit.c int spl_load_fit_image(struct spl_image_info *spl_image, · line 963
Quoted 1 line
common/spl/spl_fit.c +1
-0+ spl_image->flags |=SPL_FIT_FOUND ;This change is unrelated and should be moved into a separate commit.
OK
Regards,
Simon
Re: [PATCH v2 15/21] spl: Plumb in the Universal Payload handoff
Quoted 65 lines · Simon Glass
Hi Sean,
Quoted 53 lines · Sean Anderson
Quoted 51 lines · Simon Glass
Specify the FIT and include information about each loaded image, as required by the UPL handoff.
Write the UPL handoff into the bloblist before jumping to the next phase.
Control this using a runtime flag to avoid conflicting with other handoff mechanisms.
Signed-off-by Simon Glass <[email protected]>---
Changes in v2:
- Hang when something goes wrong, to avoid a broken boot
- Add a runtime flag to enable UPLcommon/spl/spl.c | 8 ++++++++ common/spl/spl_fit.c | 22 ++++++++++++++++++++++ include/asm-generic/global_data.h | 4 ++++ 3 files changed, 34 insertions(+)common/spl/spl.c +8
-0@@ -810,6 +810,14 @@ void board_init_r(gd_t *dummy1, ulong dummy2)printf (SPL_TPL_PROMPT "SPL hand-off write failed (err=%d)\n" , ret); } +if (CONFIG_IS_ENABLED (UPL_OUT ) && (gd->flags &GD_FLG_UPL )) { + ret =spl_write_upl_handoff (&spl_image); +if (ret) { +printf (SPL_TPL_PROMPT +"UPL hand-off write failed (err=%d)\n" , ret); +hang (); + } + }if (CONFIG_IS_ENABLED (BLOBLIST )) { ret =bloblist_finish ();if (ret)common/spl/spl_fit.c +1
-0@@ -12,6 +12,7 @@#include <memalign.h> #include <mapmem.h> #include <spl.h> +#include <upl.h> #include <sysinfo.h> #include <asm/global_data.h> #include <asm/io.h> Quoted 8 lines
common/spl/spl_fit.c static int spl_fit_load_fpga(struct spl_fit_info *ctx, · line 650
Quoted 6 lines
common/spl/spl_fit.c +2
-0@@ -645,6 +646,8 @@ static int spl_fit_load_fpga(struct spl_fit_info *ctx,printf ("%s: Cannot load the FPGA: %i\n" , __func__, ret);return ret; } +upl_add_image (node, fpga_image.load_addr, fpga_image.size, +fdt_getprop (ctx->fit, node,FIT_DESC_PROP ,NULL ));Does
load_addreven make sense for FPGAs?
Quoted 1 line
Well the images do get loaded into RAM at a particular address.
No they don't. I mean, technically yes, but it's just an intermediate step before being programmed into the FPGA. Much like how executable boot images may be loaded to an intermediate address before being copied to their final location. And the load_addr is set to 0 a few lines above.
But don't bother special-casing this if you do the next part.
Quoted 6 lines
Quoted 3 lines
And I noticed that you always call this after load_simple_fit/fit_image_load. Could we call
upl_add_imagein those functions instead?Yes, although it means compiling
upl.hfor the host. Perhaps it isn't that bad though and it avoids repeating code.
I would prefer that to help ensure that future programmers don't forget it.
Quoted 31 lines
Quoted 25 lines
Quoted 25 lines
common/spl/spl_fit.c +5
-0return spl_fit_upload_fpga (ctx, node, &fpga_image); }@@ -768,6 +771,9 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,if (ret)return ret; +upl_add_image (node, spl_image->load_addr, spl_image->size, +fdt_getprop (ctx.fit, node,FIT_DESC_PROP ,NULL )); +/* * For backward compatibility, we treat the first node that is * as a U-Boot image, if no OS-type has been declared. @@ -811,6 +817,8 @@ int spl_load_simple_fit(struct spl_image_info *spl_image, __func__, index, ret);return ret; } +upl_add_image (node, image_info.load_addr, image_info.size, +fdt_getprop (ctx.fit, node,FIT_DESC_PROP ,NULL ));if (spl_fit_image_is_fpga (ctx.fit, node))spl_fit_upload_fpga (&ctx, node, &image_info);@@ -847,6 +855,8 @@ int spl_load_simple_fit(struct spl_image_info *spl_image, spl_image->entry_point = spl_image->load_addr;Quoted 5 lines
common/spl/spl_fit.c int spl_load_simple_fit(struct spl_image_info *spl_image, · line 859
Quoted 3 lines
common/spl/spl_fit.c +2
-0spl_image->flags |=SPL_FIT_FOUND ; +upl_set_fit_info (map_to_sysmem (ctx.fit), ctx.conf_node, + spl_image->entry_point);I think this should be
virt_to_phys, since we aren't really mapping it.
Quoted 3 lines
We want to pass the address, which (for sandbox) has to be able to be mapped back to a pointer. Everywhere else in sandbox this is how we handle that...
This is really a nit. But I thought that map_to_sysmem implied a pairing with unmap. But I guess that's map_physmem.
--Sean
Re: [PATCH v2 15/21] spl: Plumb in the Universal Payload handoff
Hi Sean,
Quoted 67 lines · Sean Anderson
Quoted 65 lines · Simon Glass
Hi Sean,
Quoted 61 lines · Sean Anderson
Quoted 52 lines · Simon Glass
Specify the FIT and include information about each loaded image, as required by the UPL handoff.
Write the UPL handoff into the bloblist before jumping to the next phase.
Control this using a runtime flag to avoid conflicting with other handoff mechanisms.
Signed-off-by Simon Glass <[email protected]>---
Changes in v2:
- Hang when something goes wrong, to avoid a broken boot
- Add a runtime flag to enable UPLcommon/spl/spl.c | 8 ++++++++ common/spl/spl_fit.c | 22 ++++++++++++++++++++++ include/asm-generic/global_data.h | 4 ++++ 3 files changed, 34 insertions(+)common/spl/spl.c +8
-0@@ -810,6 +810,14 @@ void board_init_r(gd_t *dummy1, ulong dummy2)printf (SPL_TPL_PROMPT "SPL hand-off write failed (err=%d)\n" , ret); } +if (CONFIG_IS_ENABLED (UPL_OUT ) && (gd->flags &GD_FLG_UPL )) { + ret =spl_write_upl_handoff (&spl_image); +if (ret) { +printf (SPL_TPL_PROMPT +"UPL hand-off write failed (err=%d)\n" , ret); +hang (); + } + }if (CONFIG_IS_ENABLED (BLOBLIST )) { ret =bloblist_finish ();if (ret)common/spl/spl_fit.c +1
-0@@ -12,6 +12,7 @@#include <memalign.h> #include <mapmem.h> #include <spl.h> +#include <upl.h> #include <sysinfo.h> #include <asm/global_data.h> #include <asm/io.h> common/spl/spl_fit.c static int spl_fit_load_fpga(struct spl_fit_info *ctx, · line 650
Quoted 5 lines
common/spl/spl_fit.c +2
-0@@ -645,6 +646,8 @@ static int spl_fit_load_fpga(struct spl_fit_info *ctx,printf ("%s: Cannot load the FPGA: %i\n" , __func__, ret);return ret; } +upl_add_image (node, fpga_image.load_addr, fpga_image.size, +fdt_getprop (ctx->fit, node,FIT_DESC_PROP ,NULL ));Does
load_addreven make sense for FPGAs?
Quoted 8 lines
Quoted 1 line
Well the images do get loaded into RAM at a particular address.
No they don't. I mean, technically yes, but it's just an intermediate step before being programmed into the FPGA. Much like how executable boot images may be loaded to an intermediate address before being copied to their final location. And the
load_addris set to 0 a few lines above.But don't bother special-casing this if you do the next part.
OK. I see the FPGA-loading happening right away. IMO this should be done later, after all images are loaded. But I suppose the code is easier the way it is.
Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
And I noticed that you always call this after load_simple_fit/fit_image_load. Could we call
upl_add_imagein those functions instead?Yes, although it means compiling
upl.hfor the host. Perhaps it isn't that bad though and it avoids repeating code.I would prefer that to help ensure that future programmers don't forget it.
Yes.
Quoted 32 lines
Quoted 32 lines
Quoted 31 lines
Quoted 24 lines
common/spl/spl_fit.c +5
-0return spl_fit_upload_fpga (ctx, node, &fpga_image); }@@ -768,6 +771,9 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,if (ret)return ret; +upl_add_image (node, spl_image->load_addr, spl_image->size, +fdt_getprop (ctx.fit, node,FIT_DESC_PROP ,NULL )); +/* * For backward compatibility, we treat the first node that is * as a U-Boot image, if no OS-type has been declared. @@ -811,6 +817,8 @@ int spl_load_simple_fit(struct spl_image_info *spl_image, __func__, index, ret);return ret; } +upl_add_image (node, image_info.load_addr, image_info.size, +fdt_getprop (ctx.fit, node,FIT_DESC_PROP ,NULL ));if (spl_fit_image_is_fpga (ctx.fit, node))spl_fit_upload_fpga (&ctx, node, &image_info);common/spl/spl_fit.c int spl_load_simple_fit(struct spl_image_info *spl_image, · line 859
Quoted 5 lines
common/spl/spl_fit.c +2
-0@@ -847,6 +855,8 @@ int spl_load_simple_fit(struct spl_image_info *spl_image, spl_image->entry_point = spl_image->load_addr; spl_image->flags |=SPL_FIT_FOUND ; +upl_set_fit_info (map_to_sysmem (ctx.fit), ctx.conf_node, + spl_image->entry_point);I think this should be
virt_to_phys, since we aren't really mapping it.
Quoted 6 lines
Quoted 3 lines
We want to pass the address, which (for sandbox) has to be able to be mapped back to a pointer. Everywhere else in sandbox this is how we handle that...
This is really a nit. But I thought that
map_to_sysmemimplied a pairing with unmap. But I guess that'smap_physmem.
Yes, map_sysmem() is the 'sandbox mapping' from an U-Boot address to a pointer, and map_to_sysmem() reverses that.
Regards,
Simon
PATCH v2 16/21 upl: Plumb in universal payload to the init process
In reply to Simon GlassRead the UPL early in boot so that it is available. For now none of the information is used.
---
(no changes since v1)
boot/Kconfig | 12 +++++++++++- common/board_f.c | 22 ++++++++++++++++++++++ common/board_r.c | 2 ++ 3 files changed, 35 insertions(+), 1 deletion(-)
boot/Kconfig +11 -1
@@ -737,7 +737,9 @@ config UPL_READ help Provides support for decoding a UPL-format payload into a C structure which can be used elsewhere in U-Boot. This is just the reading - implementation, useful for trying it out. + implementation, useful for trying it out. See UPL_IN for how + to tell U-Boot to actually read it on startup and use it for memory + and device information, etc. config UPL_WRITE bool "upl - Support writing a Universal Payload handoff"
@@ -748,6 +750,14 @@ config UPL_WRITE for how to tell U-Boot SPL to actually write it before jumping to the next phase. +config UPL_IN + bool "upl - Read the UPL handoff on startup" + select UPL_READ + help + Read an SPL handoff when U-Boot starts and use it to provide + devices, memory layout, etc. required by U-Boot. This allows U-Boot + to function as a payload in the meaning of the specification. + if SPL config SPL_UPL
common/board_f.c +22 -0
@@ -40,6 +40,7 @@#include <sysreset.h> #include <timer.h> #include <trace.h> +#include <upl.h> #include <video.h> #include <watchdog.h> #include <asm/cache.h>
@@ -862,6 +863,26 @@ __weak int clear_bss(void)return 0 ; } +static int initf_upl (void ) +{ +struct upl *upl; +int ret; + +if (!IS_ENABLED (CONFIG_UPL_IN ) || !(gd->flags &GD_FLG_UPL )) +return 0 ; + + upl =malloc (sizeof (struct upl )); +if (upl) + ret =upl_read_handoff (upl,oftree_default ()); +if (ret) { +printf ("UPL handoff: read failure (err=%dE)\n" , ret); +return ret; + } +gd_set_upl (upl); + +return 0 ; +} +static const init_fnc_t init_sequence_f[] = { setup_mon_len, #ifdef CONFIG_OF_CONTROL
@@ -871,6 +892,7 @@ static const init_fnc_t init_sequence_f[] = { trace_early_init, #endif initf_malloc, + initf_upl, log_init, initf_bootstage,/* uses its own timer, so does not need DM */ event_init,
common/board_r.c +2 -0
@@ -521,6 +521,8 @@ static int dm_announce(void) uclass_count);if (CONFIG_IS_ENABLED (OF_REAL ))printf (", devicetree: %s" ,fdtdec_get_srcname ()); +if (CONFIG_IS_ENABLED (UPL )) +printf (", universal payload active" );printf ("\n" ); if (IS_ENABLED(CONFIG_OF_HAS_PRIOR_STAGE) && (gd->fdt_src == FDTSRC_SEPARATE ||
Signature · 1 line
2.34.1
PATCH v2 17/21 sandbox_vpl: Enable Universal Payload
In reply to Simon GlassUse the sandbox_vpl build to test UPL since it supports a real devicetree in SPL. The sandbox_spl build uses OF_PLATDATA.
Enable writing the UPL handoff in SPL and reading it in U-Boot proper. Provide a test to check that this handoff works.
Note that the test uses the standard devicetree rather than the test one, since it is a lot smaller and fits in the existing bloblist.
---
(no changes since v1)
configs/sandbox_vpl_defconfig | 4 ++++ test/py/tests/test_upl.py | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 test/py/tests/test_upl.py
configs/sandbox_vpl_defconfig +4 -0
@@ -27,6 +27,9 @@ CONFIG_FIT=y CONFIG_FIT_VERBOSE=y CONFIG_FIT_BEST_MATCH=y CONFIG_SPL_LOAD_FIT=y +CONFIG_UPL=y +CONFIG_UPL_IN=y +CONFIG_SPL_UPL_OUT=y CONFIG_BOOTSTAGE=y CONFIG_BOOTSTAGE_REPORT=y CONFIG_BOOTSTAGE_FDT=y
@@ -35,6 +38,7 @@ CONFIG_BOOTSTAGE_STASH_SIZE=0x4096 CONFIG_CONSOLE_RECORD=y CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000 CONFIG_DISPLAY_BOARDINFO_LATE=y +CONFIG_BLOBLIST_SIZE=0x5000 CONFIG_SPL_NO_BSS_LIMIT=y CONFIG_HANDOFF=y CONFIG_SPL_BOARD_INIT=y
test/py/tests/test_upl.py new file +25 -0
@@ -0,0 +1,25 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright 2024 Google LLC +# +# Test addition of Universal Payload + +import os + +import pytest +import u_boot_utils + [email protected]('sandbox_vpl') +def test_upl_handoff(u_boot_console): + cons = u_boot_console + ram = os.path.join(cons.config.build_dir, 'ram.bin') + fdt = os.path.join(cons.config.build_dir, 'u-boot.dtb') + + # Remove any existing RAM file, so we don't have old data present + if os.path.exists(ram): + os.remove(ram) + flags = ['-m', ram, '-d', fdt] + cons.restart_uboot_with_flags(flags, use_dtb=False) + + # Make sure that Universal Payload is detected in U-Boot proper + output = cons.run_command('upl info') + assert output == 'UPL state: active'
Signature · 1 line
2.34.1
PATCH v2 18/21 upl: Add initial documentation
In reply to Simon GlassAdd some documentation to explain the basic concept along with a link to the full spec.
---
Changes in v2:
- Add a link to the spec
- Add a link to the command
MAINTAINERS | 1 + doc/usage/cmd/upl.rst | 4 ++-- doc/usage/index.rst | 1 + doc/usage/upl.rst | 46 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 doc/usage/upl.rst
MAINTAINERS +1 -0
@@ -1701,6 +1701,7 @@ T: git https://source.denx.de/u-boot/custodians/u-boot-dm.git F: boot/upl* F: cmd/upl.c F: common/spl/spl_upl.c +F: doc/usage/upl.rst F: doc/usage/cmd/upl.rst F: include/upl.h F: test/boot/upl.c
doc/usage/cmd/upl.rst +2 -2
@@ -16,8 +16,8 @@ Description ----------- The *upl* command is used to test U-Boot's support for the Universal Payload -Specification (UPL) firmware standard. It allows creation of a fake handoff for -use in testing. +Specification (UPL) firmware standard (see :doc:`../upl`). It allows creation of +a fake handoff for use in testing. upl write
doc/usage/index.rst +1 -0
@@ -15,6 +15,7 @@ Use U-Boot cmdline semihosting measured_boot + upl Shell commands --------------
doc/usage/upl.rst new file +46 -0
46 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v2 19/21 sandbox: Add a flag to enable UPL
In reply to Simon GlassUPL significantly alters the boot flow for sandbox. Add a flag to enable this so that it can be enabled only on tests which need it.
---
(no changes since v1)
arch/sandbox/cpu/start.c | 13 ++++++++++++- arch/sandbox/include/asm/state.h | 1 + 2 files changed, 13 insertions(+), 1 deletion(-)
arch/sandbox/cpu/start.c +12 -1
@@ -431,6 +431,14 @@ static int sandbox_cmdline_cb_autoboot_keyed(struct sandbox_state *state, }SANDBOX_CMDLINE_OPT (autoboot_keyed,0 ,"Allow keyed autoboot" ); +static int sandbox_cmdline_cb_upl (struct sandbox_state *state,const char *arg) +{ + state->upl = true; + +return 0 ; +} +SANDBOX_CMDLINE_OPT (upl,0 ,"Enable Universal Payload (UPL)" ); +static void setup_ram_buf (struct sandbox_state *state) {/* Zero the RAM buffer if we didn't read it, to keep valgrind happy */
@@ -540,6 +548,9 @@ int sandbox_main(int argc, char *argv[]) goto err; } +if (state->upl) + gd->flags |=GD_FLG_UPL ; +#if CONFIG_IS_ENABLED (SYS_MALLOC_F ) gd->malloc_base =CFG_MALLOC_F_ADDR ;#endif
@@ -558,7 +569,7 @@ int sandbox_main(int argc, char *argv[])log_debug ("debug: %s\n" , __func__);/* Do pre- and post-relocation init */ -board_init_f (0 ); +board_init_f (gd->flags);board_init_r (gd->new_gd,0 );
arch/sandbox/include/asm/state.h +1 -0
@@ -97,6 +97,7 @@ struct sandbox_state {bool autoboot_keyed;/* Use keyed-autoboot feature */ bool disable_eth;/* Disable Ethernet devices */ bool disable_sf_bootdevs;/* Don't bind SPI flash bootdevs */ +bool upl;/* Enable Universal Payload (UPL) */ /* Pointer to information for each SPI bus/cs */ struct sandbox_spi_info spi[CONFIG_SANDBOX_SPI_MAX_BUS ]
Signature · 1 line
2.34.1
PATCH v2 20/21 sandbox: Add an SPL loader for UPL
In reply to Simon GlassAdd support for loading a UPL image from SPL. This uses the simple FIT implementation, but also loads the full FIT just to permit more testing.
---
(no changes since v1)
arch/sandbox/cpu/spl.c | 49 +++++++++++++++++++++++++++++++++- arch/sandbox/include/asm/spl.h | 1 + 2 files changed, 49 insertions(+), 1 deletion(-)
arch/sandbox/cpu/spl.c +48 -1
@@ -3,14 +3,18 @@* Copyright (c) 2016 Google, Inc */ +#define LOG_CATEGORY LOGC_BOOT +#include <dm.h> #include <hang.h> #include <handoff.h> #include <image.h> #include <init.h> #include <log.h> +#include <mapmem.h> #include <os.h> #include <spl.h> +#include <upl.h> #include <asm/global_data.h> #include <asm/spl.h> #include <asm/state.h>
@@ -52,7 +56,8 @@ void board_init_f(ulong flag)void board_boot_order (u32 *spl_boot_list) { spl_boot_list[0 ] =BOOT_DEVICE_VBE ; - spl_boot_list[1 ] =BOOT_DEVICE_BOARD ; + spl_boot_list[1 ] =BOOT_DEVICE_UPL ; + spl_boot_list[2 ] =BOOT_DEVICE_BOARD ; } static int spl_board_load_file(struct spl_image_info *spl_image,
@@ -246,3 +251,45 @@ int sandbox_spl_load_fit(char *fname, int maxlen, struct spl_image_info *image)return 0 ; } + +static int upl_load_from_image (struct spl_image_info *spl_image, +struct spl_boot_device *bootdev) +{ +long long size; +char *fname; +int ret, fd; +ulong addr; + +if (!CONFIG_IS_ENABLED (UPL_OUT )) +return -ENOTSUPP ; + +spl_upl_init (); + fname =os_malloc (256 ); + + ret =sandbox_spl_load_fit (fname,256 , spl_image); +if (ret) +return log_msg_ret ("fit" , ret); + spl_image->flags =SPL_SANDBOXF_ARG_IS_BUF ; + spl_image->arg =map_sysmem (spl_image->load_addr,0 ); +/* size is set by load_simple_fit(), offset is left as 0 */ + +/* now read the whole FIT into memory */ + fd =os_open (fname,OS_O_RDONLY ); +if (fd <0 ) +return log_msg_ret ("op2" , -ENOENT ); +if (os_get_filesize (fname, &size)) +return log_msg_ret ("fis" , -ENOENT ); + +/* place it after the loaded image, allowing plenty of space */ + addr =ALIGN (spl_image->load_addr + size,0x1000 ); +log_debug ("Loading whole FIT to %lx\n" , addr); +if (os_read (fd,map_sysmem (addr,0 ), size) != size) +return log_msg_ret ("rea" , -EIO ); +os_close (fd); + +/* tell UPL where it is */ +upl_set_fit_addr (addr); + +return 0 ; +} +SPL_LOAD_IMAGE_METHOD ("upl" ,4 ,BOOT_DEVICE_UPL , upl_load_from_image);
arch/sandbox/include/asm/spl.h +1 -0
@@ -18,6 +18,7 @@ enum {BOOT_DEVICE_NOR ,BOOT_DEVICE_SPI ,BOOT_DEVICE_NAND , + BOOT_DEVICE_UPL, };/**
Signature · 1 line
2.34.1
Re: [PATCH v2 20/21] sandbox: Add an SPL loader for UPL
Quoted 62 lines · Simon Glass
Add support for loading a UPL image from SPL. This uses the simple FIT implementation, but also loads the full FIT just to permit more testing.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
arch/sandbox/cpu/spl.c | 49 +++++++++++++++++++++++++++++++++- arch/sandbox/include/asm/spl.h | 1 + 2 files changed, 49 insertions(+), 1 deletion(-)arch/sandbox/cpu/spl.c +19
-1@@ -3,14 +3,18 @@* Copyright (c) 2016 Google, Inc */ +#define LOG_CATEGORY LOGC_BOOT +#include <dm.h> #include <hang.h> #include <handoff.h> #include <image.h> #include <init.h> #include <log.h> +#include <mapmem.h> #include <os.h> #include <spl.h> +#include <upl.h> #include <asm/global_data.h> #include <asm/spl.h> #include <asm/state.h> @@ -52,7 +56,8 @@ void board_init_f(ulong flag)void board_boot_order (u32 *spl_boot_list) { spl_boot_list[0 ] =BOOT_DEVICE_VBE ; - spl_boot_list[1 ] =BOOT_DEVICE_BOARD ; + spl_boot_list[1 ] =BOOT_DEVICE_UPL ; + spl_boot_list[2 ] =BOOT_DEVICE_BOARD ; } static int spl_board_load_file(struct spl_image_info *spl_image,@@ -246,3 +251,45 @@ int sandbox_spl_load_fit(char *fname, int maxlen, struct spl_image_info *image)return 0 ; } + +static int upl_load_from_image (struct spl_image_info *spl_image, +struct spl_boot_device *bootdev) +{ +long long size; +char *fname; +int ret, fd; +ulong addr; + +if (!CONFIG_IS_ENABLED (UPL_OUT )) +return -ENOTSUPP ; + +spl_upl_init ();
arch/sandbox/cpu/spl.c int sandbox_spl_load_fit(char *fname, int maxlen, struct spl_image_info *image) · line 276
Quoted 10 lines
arch/sandbox/cpu/spl.c +10
-0+ fname =os_malloc (256 ); + + ret =sandbox_spl_load_fit (fname,256 , spl_image); +if (ret) +return log_msg_ret ("fit" , ret); + spl_image->flags =SPL_SANDBOXF_ARG_IS_BUF ; + spl_image->arg =map_sysmem (spl_image->load_addr,0 ); +/* size is set by load_simple_fit(), offset is left as 0 */ + +/* now read the whole FIT into memory */
Why do we have to do this? Didn't we just load the FIT in sandbox_spl_load_fit?
Quoted 31 lines
arch/sandbox/cpu/spl.c +19
-0+ fd =os_open (fname,OS_O_RDONLY ); +if (fd <0 ) +return log_msg_ret ("op2" , -ENOENT ); +if (os_get_filesize (fname, &size)) +return log_msg_ret ("fis" , -ENOENT ); + +/* place it after the loaded image, allowing plenty of space */ + addr =ALIGN (spl_image->load_addr + size,0x1000 ); +log_debug ("Loading whole FIT to %lx\n" , addr); +if (os_read (fd,map_sysmem (addr,0 ), size) != size) +return log_msg_ret ("rea" , -EIO ); +os_close (fd); + +/* tell UPL where it is */ +upl_set_fit_addr (addr); + +return 0 ; +} +SPL_LOAD_IMAGE_METHOD ("upl" ,4 ,BOOT_DEVICE_UPL , upl_load_from_image);arch/sandbox/include/asm/spl.h +1
-0@@ -18,6 +18,7 @@ enum {BOOT_DEVICE_NOR ,BOOT_DEVICE_SPI ,BOOT_DEVICE_NAND , + BOOT_DEVICE_UPL, };/**
Re: [PATCH v2 20/21] sandbox: Add an SPL loader for UPL
Hi Sean,
Quoted 68 lines · Sean Anderson
Quoted 66 lines · Simon Glass
Add support for loading a UPL image from SPL. This uses the simple FIT implementation, but also loads the full FIT just to permit more testing.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
arch/sandbox/cpu/spl.c | 49 +++++++++++++++++++++++++++++++++- arch/sandbox/include/asm/spl.h | 1 + 2 files changed, 49 insertions(+), 1 deletion(-)arch/sandbox/cpu/spl.c +23
-1@@ -3,14 +3,18 @@* Copyright (c) 2016 Google, Inc */ +#define LOG_CATEGORY LOGC_BOOT +#include <dm.h> #include <hang.h> #include <handoff.h> #include <image.h> #include <init.h> #include <log.h> +#include <mapmem.h> #include <os.h> #include <spl.h> +#include <upl.h> #include <asm/global_data.h> #include <asm/spl.h> #include <asm/state.h> @@ -52,7 +56,8 @@ void board_init_f(ulong flag)void board_boot_order (u32 *spl_boot_list) { spl_boot_list[0 ] =BOOT_DEVICE_VBE ; - spl_boot_list[1 ] =BOOT_DEVICE_BOARD ; + spl_boot_list[1 ] =BOOT_DEVICE_UPL ; + spl_boot_list[2 ] =BOOT_DEVICE_BOARD ; } static int spl_board_load_file(struct spl_image_info *spl_image,@@ -246,3 +251,45 @@ int sandbox_spl_load_fit(char *fname, int maxlen, struct spl_image_info *image)return 0 ; } + +static int upl_load_from_image (struct spl_image_info *spl_image, +struct spl_boot_device *bootdev) +{ +long long size; +char *fname; +int ret, fd; +ulong addr; + +if (!CONFIG_IS_ENABLED (UPL_OUT )) +return -ENOTSUPP ; + +spl_upl_init (); + fname =os_malloc (256 ); + + ret =sandbox_spl_load_fit (fname,256 , spl_image); +if (ret)
Quoted 8 lines
arch/sandbox/cpu/spl.c int sandbox_spl_load_fit(char *fname, int maxlen, struct spl_image_info *image) · line 276
Quoted 6 lines
arch/sandbox/cpu/spl.c +6
-0+return log_msg_ret ("fit" , ret); + spl_image->flags =SPL_SANDBOXF_ARG_IS_BUF ; + spl_image->arg =map_sysmem (spl_image->load_addr,0 ); +/* size is set by load_simple_fit(), offset is left as 0 */ + +/* now read the whole FIT into memory */ Why do we have to do this? Didn't we just load the FIT in
sandbox_spl_load_fit?
Sort-of, but really SPL the simple FIT loader just loads the images, not the entire FIT. It is loaded here just for the benefit for the test, which wants to check that the offsets provided in UPL are correct.
Quoted 31 lines
Quoted 31 lines
arch/sandbox/cpu/spl.c +19
-0+ fd =os_open (fname,OS_O_RDONLY ); +if (fd <0 ) +return log_msg_ret ("op2" , -ENOENT ); +if (os_get_filesize (fname, &size)) +return log_msg_ret ("fis" , -ENOENT ); + +/* place it after the loaded image, allowing plenty of space */ + addr =ALIGN (spl_image->load_addr + size,0x1000 ); +log_debug ("Loading whole FIT to %lx\n" , addr); +if (os_read (fd,map_sysmem (addr,0 ), size) != size) +return log_msg_ret ("rea" , -EIO ); +os_close (fd); + +/* tell UPL where it is */ +upl_set_fit_addr (addr); + +return 0 ; +} +SPL_LOAD_IMAGE_METHOD ("upl" ,4 ,BOOT_DEVICE_UPL , upl_load_from_image);arch/sandbox/include/asm/spl.h +1
-0@@ -18,6 +18,7 @@ enum {BOOT_DEVICE_NOR ,BOOT_DEVICE_SPI ,BOOT_DEVICE_NAND , + BOOT_DEVICE_UPL, };
Quoted 2 lines
arch/sandbox/include/asm/spl.h enum { · line 24
Quoted 1 line
arch/sandbox/include/asm/spl.h +0
-0/**
Regards,
Simon
PATCH v2 21/21 upl: Add an end-to-end test
In reply to Simon GlassNow that sandbox_vpl supports UPL, add a test that checks that the payload can be loaded by SPL and the handoff information passed through to U-Boot proper.
---
Changes in v2:
- Support CI testing
- Rework to use alist instead of fixed-length arrays
MAINTAINERS | 1 + test/boot/upl.c | 28 ++++++++++++++++++++++++++++ test/py/tests/test_upl.py | 17 +++++++++++++++-- 3 files changed, 44 insertions(+), 2 deletions(-)
MAINTAINERS +1 -0
@@ -1705,6 +1705,7 @@ F: doc/usage/upl.rst F: doc/usage/cmd/upl.rst F: include/upl.h F: test/boot/upl.c +F: test/py/tests/test_upl.py USB M: Marek Vasut <[email protected]>
test/boot/upl.c +28 -0
@@ -398,6 +398,34 @@ static int upl_test_read_write(struct unit_test_state *uts) }UPL_TEST (upl_test_read_write,UT_TESTF_CONSOLE_REC ); +/* Test UPL passthrough */ +static int upl_test_info_norun (struct unit_test_state *uts) +{ +const struct upl_image *img; +struct upl *upl =gd_upl (); +const void *fit; + +ut_assertok (run_command ("upl info -v" ,0 )); +ut_assert_nextline ("UPL state: active" ); +ut_assert_nextline ("fit %lx" , upl->fit); +ut_assert_nextline ("conf_offset %x" , upl->conf_offset); +ut_assert_nextlinen ("image 0" ); +ut_assert_console_end (); + +/* check the offsets */ + fit =map_sysmem (upl->fit,0 ); +ut_asserteq_str ("conf-1" ,fdt_get_name (fit, upl->conf_offset,NULL )); + +ut_asserteq (1 , upl->image.count); + + img = alist_get(&upl->image, 0, struct upl_image); +ut_asserteq_str ("firmware-1" ,fdt_get_name (fit, img->offset,NULL )); +ut_asserteq (CONFIG_TEXT_BASE , img->load); + +return 0 ; +} +UPL_TEST (upl_test_info_norun,UT_TESTF_CONSOLE_REC |UT_TESTF_MANUAL ); +int do_ut_upl (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) {struct unit_test *tests =UNIT_TEST_SUITE_START (upl_test);
test/py/tests/test_upl.py +15 -2
@@ -10,6 +10,15 @@ import u_boot_utils @pytest.mark.boardspec('sandbox_vpl') def test_upl_handoff(u_boot_console): + """Test of UPL handoff + + This works by starting up U-Boot VPL, which gets to SPL and then sets up a + UPL handoff using the FIT containing U-Boot proper. It then jumps to U-Boot + proper and runs a test to check that the parameters are correct. + + The entire FIT is loaded into memory in SPL (in upl_load_from_image()) so + that it can be inpected in upl_test_info_norun + """ cons = u_boot_console ram = os.path.join(cons.config.build_dir, 'ram.bin') fdt = os.path.join(cons.config.build_dir, 'u-boot.dtb')
@@ -17,9 +26,13 @@ def test_upl_handoff(u_boot_console): # Remove any existing RAM file, so we don't have old data present if os.path.exists(ram): os.remove(ram) - flags = ['-m', ram, '-d', fdt] + flags = ['-m', ram, '-d', fdt, '--upl'] cons.restart_uboot_with_flags(flags, use_dtb=False) # Make sure that Universal Payload is detected in U-Boot proper output = cons.run_command('upl info') - assert output == 'UPL state: active' + assert 'UPL state: active' == output + + # Check the FIT offsets look correct + output = cons.run_command('ut upl -f upl_test_info_norun') + assert 'Failures: 0' in output
Signature · 1 line
2.34.1
Quoted 5 lines
From: Simon Glass <[email protected]>
Date: Sat, 13 Jul 2024 08:00:34 +0100Universal Payload (UPL) is an Industry Standard for firmware components[1].
I think you have some trouble understanding the concept of industry standard ;). I guess you want this to become an industry standard. Firmly https://xkcd.com/927/ territory if you ask me.
Quoted 113 lines
UPL is designed to improve interoperability within the firmware industry, allowing mixing and matching of projects with less friction and fewer project-specific implementations. UPL is cross-platform, supporting ARM, x86 and RISC-V initially.
This series provides some initial support for this, targeting 0.9.1 and sandbox only.
Features still to come include:
- Support for architectures
- FIT validation
- Handoff validation
- Interoperability testsThis series is available at dm/uplb-working and requires the alist series at dm/alist-working[2]
[1] https://universalpayload.github.io/spec/
[2] https://patchwork.ozlabs.org/project/uboot/list/?series=414642Changes in v2:
- Put the upl tests under their own subcommand to avoid bootstd init
- Add a function to init the UPL process in SPL
- Hang when something goes wrong, to avoid a broken boot
- Add a runtime flag to enable UPL
- Add a link to the spec
- Add a link to the command
- Support CI testing
- Rework to use alist instead of fixed-length arraysSimon Glass (21):
sandbox: Use const inos_jump_to_file()
sandbox: Fix a comment inos_find_u_boot()
test: Move some SPL-loading test-code into sandbox common
sandbox: EnableSPL_LOAD_BLOCK
fdt: Don't overwrite bloblist devicetree
sandbox: fdt: Avoid overwriting an existing fdt
sandbox: Return error code from read/write/seek
sandbox: Add ELF file to VPL u-boot.img
sandbox: Set upglobal_dataearlier
upl: Add support for reading a upl handoff
upl: Add support for writing a upl handoff
upl: Add basic tests
upl: Add a command
upl: Add support for Universal Payload in SPL
spl: Plumb in the Universal Payload handoff
upl: Plumb in universal payload to the init process
sandbox_vpl: Enable Universal Payload
upl: Add initial documentation
sandbox: Add a flag to enable UPL
sandbox: Add an SPL loader for UPL
upl: Add an end-to-end testMAINTAINERS | 13 + Makefile | 4 +- arch/sandbox/cpu/cpu.c | 2 + arch/sandbox/cpu/os.c | 30 +- arch/sandbox/cpu/spl.c | 116 +++++- arch/sandbox/cpu/start.c | 18 +- arch/sandbox/include/asm/spl.h | 15 + arch/sandbox/include/asm/state.h | 1 + boot/Kconfig | 70 ++++ boot/Makefile | 4 + boot/upl_common.c | 60 +++ boot/upl_common.h | 24 ++ boot/upl_read.c | 588 ++++++++++++++++++++++++++++ boot/upl_write.c | 622 ++++++++++++++++++++++++++++++ cmd/Kconfig | 7 + cmd/Makefile | 1 + cmd/upl.c | 118 ++++++ common/board_f.c | 22 ++ common/board_r.c | 2 + common/spl/Kconfig | 1 + common/spl/Makefile | 2 + common/spl/spl.c | 8 + common/spl/spl_fit.c | 22 ++ common/spl/spl_upl.c | 171 ++++++++ configs/sandbox_defconfig | 1 + configs/sandbox_vpl_defconfig | 4 + doc/usage/cmd/upl.rst | 186 +++++++++ doc/usage/index.rst | 2 + doc/usage/upl.rst | 46 +++ drivers/block/sandbox.c | 4 +- drivers/usb/emul/sandbox_flash.c | 2 +- fs/sandbox/sandboxfs.c | 6 +- include/asm-generic/global_data.h | 19 + include/os.h | 6 +- include/spl.h | 16 + include/test/suites.h | 1 + include/upl.h | 361 +++++++++++++++++ lib/fdtdec.c | 1 + test/boot/Makefile | 2 + test/boot/upl.c | 436 +++++++++++++++++++++ test/cmd_ut.c | 3 + test/image/spl_load_os.c | 53 +-- test/py/tests/test_upl.py | 38 ++ 43 files changed, 3036 insertions(+), 72 deletions(-) create mode 100644 boot/upl_common.c create mode 100644 boot/upl_common.h create mode 100644 boot/upl_read.c create mode 100644 boot/upl_write.c create mode 100644 cmd/upl.c create mode 100644 common/spl/spl_upl.c create mode 100644 doc/usage/cmd/upl.rst create mode 100644 doc/usage/upl.rst create mode 100644 include/upl.h create mode 100644 test/boot/upl.c create mode 100644 test/py/tests/test_upl.pySignature · 1 line
2.34.1
Am 13. Juli 2024 10:12:50 MESZ schrieb Mark Kettenis <[email protected]>:
Quoted 26 lines
Quoted 5 lines
From: Simon Glass <[email protected]>
Date: Sat, 13 Jul 2024 08:00:34 +0100Universal Payload (UPL) is an Industry Standard for firmware components[1].
I think you have some trouble understanding the concept of industry standard ;). I guess you want this to become an industry standard. Firmly https://xkcd.com/927/ territory if you ask me.
Quoted 16 lines
UPL is designed to improve interoperability within the firmware industry, allowing mixing and matching of projects with less friction and fewer project-specific implementations. UPL is cross-platform, supporting ARM, x86 and RISC-V initially.
This series provides some initial support for this, targeting 0.9.1 and sandbox only.
Features still to come include:
- Support for architectures
- FIT validation
- Handoff validation
- Interoperability testsThis series is available at dm/uplb-working and requires the alist series at dm/alist-working[2]
Why is this series needed?
SPL loading a FIT image as described in the "universal" payload spec is already implemented in U-Boot and for instance works fine for running EDK II on RISC-V.
I cannot see what functionality is missing in U-Boot.
The UPL seems to be half cooked:
The FIT file format is already described elsewhere.
The relocation chapter describes that it should better be removed.
The device-tree chapter duplicates content of the device-tree specification and ignores the existing standardization via the Linux project.
The authors seem not to have given any thought to ACPI.
So let us wait if that UPL thing ever lifts off before wasting a code line on it.
Best regards
Heinrich
Quoted 97 lines
Quoted 97 lines
[1] https://universalpayload.github.io/spec/
[2] https://patchwork.ozlabs.org/project/uboot/list/?series=414642Changes in v2:
- Put the upl tests under their own subcommand to avoid bootstd init
- Add a function to init the UPL process in SPL
- Hang when something goes wrong, to avoid a broken boot
- Add a runtime flag to enable UPL
- Add a link to the spec
- Add a link to the command
- Support CI testing
- Rework to use alist instead of fixed-length arraysSimon Glass (21):
sandbox: Use const inos_jump_to_file()
sandbox: Fix a comment inos_find_u_boot()
test: Move some SPL-loading test-code into sandbox common
sandbox: EnableSPL_LOAD_BLOCK
fdt: Don't overwrite bloblist devicetree
sandbox: fdt: Avoid overwriting an existing fdt
sandbox: Return error code from read/write/seek
sandbox: Add ELF file to VPL u-boot.img
sandbox: Set upglobal_dataearlier
upl: Add support for reading a upl handoff
upl: Add support for writing a upl handoff
upl: Add basic tests
upl: Add a command
upl: Add support for Universal Payload in SPL
spl: Plumb in the Universal Payload handoff
upl: Plumb in universal payload to the init process
sandbox_vpl: Enable Universal Payload
upl: Add initial documentation
sandbox: Add a flag to enable UPL
sandbox: Add an SPL loader for UPL
upl: Add an end-to-end testMAINTAINERS | 13 + Makefile | 4 +- arch/sandbox/cpu/cpu.c | 2 + arch/sandbox/cpu/os.c | 30 +- arch/sandbox/cpu/spl.c | 116 +++++- arch/sandbox/cpu/start.c | 18 +- arch/sandbox/include/asm/spl.h | 15 + arch/sandbox/include/asm/state.h | 1 + boot/Kconfig | 70 ++++ boot/Makefile | 4 + boot/upl_common.c | 60 +++ boot/upl_common.h | 24 ++ boot/upl_read.c | 588 ++++++++++++++++++++++++++++ boot/upl_write.c | 622 ++++++++++++++++++++++++++++++ cmd/Kconfig | 7 + cmd/Makefile | 1 + cmd/upl.c | 118 ++++++ common/board_f.c | 22 ++ common/board_r.c | 2 + common/spl/Kconfig | 1 + common/spl/Makefile | 2 + common/spl/spl.c | 8 + common/spl/spl_fit.c | 22 ++ common/spl/spl_upl.c | 171 ++++++++ configs/sandbox_defconfig | 1 + configs/sandbox_vpl_defconfig | 4 + doc/usage/cmd/upl.rst | 186 +++++++++ doc/usage/index.rst | 2 + doc/usage/upl.rst | 46 +++ drivers/block/sandbox.c | 4 +- drivers/usb/emul/sandbox_flash.c | 2 +- fs/sandbox/sandboxfs.c | 6 +- include/asm-generic/global_data.h | 19 + include/os.h | 6 +- include/spl.h | 16 + include/test/suites.h | 1 + include/upl.h | 361 +++++++++++++++++ lib/fdtdec.c | 1 + test/boot/Makefile | 2 + test/boot/upl.c | 436 +++++++++++++++++++++ test/cmd_ut.c | 3 + test/image/spl_load_os.c | 53 +-- test/py/tests/test_upl.py | 38 ++ 43 files changed, 3036 insertions(+), 72 deletions(-) create mode 100644 boot/upl_common.c create mode 100644 boot/upl_common.h create mode 100644 boot/upl_read.c create mode 100644 boot/upl_write.c create mode 100644 cmd/upl.c create mode 100644 common/spl/spl_upl.c create mode 100644 doc/usage/cmd/upl.rst create mode 100644 doc/usage/upl.rst create mode 100644 include/upl.h create mode 100644 test/boot/upl.c create mode 100644 test/py/tests/test_upl.pySignature · 1 line
2.34.1
Quoted 27 lines · Heinrich Schuchardt
Am 13. Juli 2024 10:12:50 MESZ schrieb Mark Kettenis <[email protected]>:
Quoted 24 lines
Quoted 5 lines
From: Simon Glass <[email protected]>
Date: Sat, 13 Jul 2024 08:00:34 +0100Universal Payload (UPL) is an Industry Standard for firmware components[1].
I think you have some trouble understanding the concept of industry standard ;). I guess you want this to become an industry standard. Firmly https://xkcd.com/927/ territory if you ask me.
Quoted 14 lines
UPL is designed to improve interoperability within the firmware industry, allowing mixing and matching of projects with less friction and fewer project-specific implementations. UPL is cross-platform, supporting ARM, x86 and RISC-V initially.
This series provides some initial support for this, targeting 0.9.1 and sandbox only.
Features still to come include:
- Support for architectures
- FIT validation
- Handoff validation
- Interoperability tests
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
This series is available at dm/uplb-working and requires the alist series at dm/alist-working[2]
Why is this series needed?
Because UPL is a standard, supported by other projects, which requires more than Just Nothing Else on top of what we do today. Please do provide constructive feedback on the changes themselves, but bringing in UPL support proper is something we should (and will) do. Thanks!
Signature · 1 line
Tom
Quoted 31 lines · Tom Rini
Quoted 30 lines · Heinrich Schuchardt
Am 13. Juli 2024 10:12:50 MESZ schrieb Mark Kettenis <[email protected]>:
Quoted 26 lines
Quoted 5 lines
From: Simon Glass <[email protected]>
Date: Sat, 13 Jul 2024 08:00:34 +0100Universal Payload (UPL) is an Industry Standard for firmware components[1].
I think you have some trouble understanding the concept of industry standard ;). I guess you want this to become an industry standard. Firmly https://xkcd.com/927/ territory if you ask me.
Quoted 16 lines
UPL is designed to improve interoperability within the firmware industry, allowing mixing and matching of projects with less friction and fewer project-specific implementations. UPL is cross-platform, supporting ARM, x86 and RISC-V initially.
This series provides some initial support for this, targeting 0.9.1 and sandbox only.
Features still to come include:
- Support for architectures
- FIT validation
- Handoff validation
- Interoperability testsThis series is available at dm/uplb-working and requires the alist series at dm/alist-working[2]
Quoted 7 lines
Quoted 1 line
Why is this series needed?
Because UPL is a standard, supported by other projects, which requires more than Just Nothing Else on top of what we do today. Please do provide constructive feedback on the changes themselves, but bringing in UPL support proper is something we should (and will) do. Thanks!
SPL loading a FIT image (e.g. EDK II + OpenSBI) seems to be very close to UPL. What is missing?
UPL is meant as the interface between two firmware pieces and not between firmware and the OS. Why should we let main U-Boot support UPL? Isn't SPL support sufficient?
Which other projects implement the UPL standard?
Best regards
Heinrich
Quoted 40 lines · Heinrich Schuchardt
Quoted 31 lines · Tom Rini
Quoted 30 lines · Heinrich Schuchardt
Am 13. Juli 2024 10:12:50 MESZ schrieb Mark Kettenis <[email protected]>:
Quoted 26 lines
Quoted 5 lines
From: Simon Glass <[email protected]>
Date: Sat, 13 Jul 2024 08:00:34 +0100Universal Payload (UPL) is an Industry Standard for firmware components[1].
I think you have some trouble understanding the concept of industry standard ;). I guess you want this to become an industry standard. Firmly https://xkcd.com/927/ territory if you ask me.
Quoted 16 lines
UPL is designed to improve interoperability within the firmware industry, allowing mixing and matching of projects with less friction and fewer project-specific implementations. UPL is cross-platform, supporting ARM, x86 and RISC-V initially.
This series provides some initial support for this, targeting 0.9.1 and sandbox only.
Features still to come include:
- Support for architectures
- FIT validation
- Handoff validation
- Interoperability testsThis series is available at dm/uplb-working and requires the alist series at dm/alist-working[2]
Quoted 7 lines
Quoted 1 line
Why is this series needed?
Because UPL is a standard, supported by other projects, which requires more than Just Nothing Else on top of what we do today. Please do provide constructive feedback on the changes themselves, but bringing in UPL support proper is something we should (and will) do. Thanks!
Quoted 8 lines
SPL loading a FIT image (e.g. EDK II + OpenSBI) seems to be very close to UPL. What is missing?
UPL is meant as the interface between two firmware pieces and not between firmware and the OS. Why should we let main U-Boot support UPL? Isn't SPL support sufficient?
Which other projects implement the UPL standard?
coreboot for one, as talked about in the announcement Simon forwarded to the U-Boot list just before this series.
Signature · 1 line
Tom
Hi Mark,
Quoted 10 lines · Mark Kettenis
Quoted 6 lines
From: Simon Glass <[email protected]>
Date: Sat, 13 Jul 2024 08:00:34 +0100Universal Payload (UPL) is an Industry Standard for firmware components[1].
I think you have some trouble understanding the concept of industry standard ;). I guess you want this to become an industry standard. Firmly https://xkcd.com/927/ territory if you ask me.
Please refrain from snarky comments on the U-Boot mailing list. The Linux list might be a better fit but we don't do that here. Yes, I do understand that we all have weak moments where we get frustrated with something.
Regards,
Simon
[..]