U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Anderson <seanga2@gmail.com>
To: Simon Glass <sjg@chromium.org>,
	U-Boot Mailing List <u-boot@lists.denx.de>
Cc: Michal Simek <michal.simek@amd.com>,
	Lean Sheng Tan <sheng.tan@9elements.com>,
	Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Tom Rini <trini@konsulko.com>
Subject: Re: [PATCH v2 20/21] sandbox: Add an SPL loader for UPL
Date: Thu, 18 Jul 2024 10:12:52 -0400	[thread overview]
Message-ID: <ea2af812-f6a5-478d-5069-ee918bf507a8@gmail.com> (raw)
In-Reply-To: <20240713070055.2172883-20-sjg@chromium.org>

On 7/13/24 03:00, Simon Glass wrote:
> 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 <sjg@chromium.org>
> ---
> 
> (no changes since v1)
> 
>   arch/sandbox/cpu/spl.c         | 49 +++++++++++++++++++++++++++++++++-
>   arch/sandbox/include/asm/spl.h |  1 +
>   2 files changed, 49 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c
> index 39869f27a7b..f665f86d64c 100644
> --- a/arch/sandbox/cpu/spl.c
> +++ b/arch/sandbox/cpu/spl.c
> @@ -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 */

Why do we have to do this? Didn't we just load the FIT in sandbox_spl_load_fit?

> +	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);
> diff --git a/arch/sandbox/include/asm/spl.h b/arch/sandbox/include/asm/spl.h
> index d50d9ad6b48..d824b2123a2 100644
> --- a/arch/sandbox/include/asm/spl.h
> +++ b/arch/sandbox/include/asm/spl.h
> @@ -18,6 +18,7 @@ enum {
>   	BOOT_DEVICE_NOR,
>   	BOOT_DEVICE_SPI,
>   	BOOT_DEVICE_NAND,
> +	BOOT_DEVICE_UPL,
>   };
>   
>   /**


  reply	other threads:[~2024-07-18 14:13 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-13  7:00 [PATCH v2 00/21] Universal Payload initial series Simon Glass
2024-07-13  7:00 ` [PATCH v2 01/21] sandbox: Use const in os_jump_to_file() Simon Glass
2024-07-18  8:02   ` Mattijs Korpershoek
2024-07-13  7:00 ` [PATCH v2 02/21] sandbox: Fix a comment in os_find_u_boot() Simon Glass
2024-07-18  8:02   ` Mattijs Korpershoek
2024-07-13  7:00 ` [PATCH v2 03/21] test: Move some SPL-loading test-code into sandbox common Simon Glass
2024-07-18 14:11   ` Sean Anderson
2024-07-13  7:00 ` [PATCH v2 04/21] sandbox: Enable SPL_LOAD_BLOCK Simon Glass
2024-07-18 13:28   ` Sean Anderson
2024-07-18 23:58     ` Sean Anderson
2024-07-13  7:00 ` [PATCH v2 05/21] fdt: Don't overwrite bloblist devicetree Simon Glass
2024-07-13  7:00 ` [PATCH v2 06/21] sandbox: fdt: Avoid overwriting an existing fdt Simon Glass
2024-07-13  7:00 ` [PATCH v2 07/21] sandbox: Return error code from read/write/seek Simon Glass
2024-07-13  7:00 ` [PATCH v2 08/21] sandbox: Add ELF file to VPL u-boot.img Simon Glass
2024-07-13  7:00 ` [PATCH v2 09/21] sandbox: Set up global_data earlier Simon Glass
2024-07-13  7:00 ` [PATCH v2 10/21] upl: Add support for reading a upl handoff Simon Glass
2024-07-18 14:41   ` Heinrich Schuchardt
2024-07-20 12:36     ` Simon Glass
2024-07-13  7:00 ` [PATCH v2 11/21] upl: Add support for writing " Simon Glass
2024-07-13  7:00 ` [PATCH v2 12/21] upl: Add basic tests Simon Glass
2024-07-13  7:00 ` [PATCH v2 13/21] upl: Add a command Simon Glass
2024-07-13  7:00 ` [PATCH v2 14/21] upl: Add support for Universal Payload in SPL Simon Glass
2024-07-13  7:00 ` [PATCH v2 15/21] spl: Plumb in the Universal Payload handoff Simon Glass
2024-07-18 13:54   ` Sean Anderson
2024-07-20 12:36     ` Simon Glass
2024-07-20 14:44       ` Sean Anderson
2024-07-21 10:08         ` Simon Glass
2024-07-13  7:00 ` [PATCH v2 16/21] upl: Plumb in universal payload to the init process Simon Glass
2024-07-13  7:00 ` [PATCH v2 17/21] sandbox_vpl: Enable Universal Payload Simon Glass
2024-07-13  7:00 ` [PATCH v2 18/21] upl: Add initial documentation Simon Glass
2024-07-13  7:00 ` [PATCH v2 19/21] sandbox: Add a flag to enable UPL Simon Glass
2024-07-13  7:00 ` [PATCH v2 20/21] sandbox: Add an SPL loader for UPL Simon Glass
2024-07-18 14:12   ` Sean Anderson [this message]
2024-07-20 12:36     ` Simon Glass
2024-07-13  7:00 ` [PATCH v2 21/21] upl: Add an end-to-end test Simon Glass
2024-07-13  8:12 ` [PATCH v2 00/21] Universal Payload initial series Mark Kettenis
2024-07-13 19:40   ` Heinrich Schuchardt
2024-07-16 19:08     ` Tom Rini
2024-07-18  8:23       ` Heinrich Schuchardt
2024-07-18 14:15         ` Tom Rini
2024-08-07 14:36   ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ea2af812-f6a5-478d-5069-ee918bf507a8@gmail.com \
    --to=seanga2@gmail.com \
    --cc=michal.simek@amd.com \
    --cc=sheng.tan@9elements.com \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox