On Tue, Jan 16, 2024 at 06:07:25PM +0100, Marco Felsch wrote:
> Add a new scratch storage slot for possible optee-hdr information which
> have to passed between barebox-pbl and barebox-proper. Reserve 512 bytes
> between the bootrom-log and the optee-hdr in case the bootrom-log need
> more space in the future.
> 
> Signed-off-by: Marco Felsch <m.fel...@pengutronix.de>
> ---
>  arch/arm/mach-imx/scratch.c | 29 +++++++++++++++++++++++++++++
>  include/mach/imx/scratch.h  |  5 +++++
>  2 files changed, 34 insertions(+)
> 
> diff --git a/arch/arm/mach-imx/scratch.c b/arch/arm/mach-imx/scratch.c
> index f4faff835c8c..6ba9b9d55b7d 100644
> --- a/arch/arm/mach-imx/scratch.c
> +++ b/arch/arm/mach-imx/scratch.c
> @@ -8,10 +8,13 @@
>  #include <mach/imx/esdctl.h>
>  #include <mach/imx/scratch.h>
>  #include <memory.h>
> +#include <tee/optee.h>
>  #include <pbl.h>
>  
>  struct imx_scratch_space {
>       u32 bootrom_log[128];
> +     u32 reserved[128];              /* reserve for bootrom log */
> +     struct optee_header optee_hdr;
>  };
>  
>  static struct imx_scratch_space *scratch;
> @@ -53,6 +56,32 @@ const u32 *imx8m_scratch_get_bootrom_log(void)
>       return scratch->bootrom_log;
>  }
>  
> +void imx8m_scratch_save_optee_hdr(const struct optee_header *hdr)
> +{
> +     size_t sz = sizeof(*hdr);
> +
> +     if (!scratch) {
> +             pr_err("No scratch area initialized, skip saving optee-hdr");
> +             return;
> +     }
> +
> +     pr_debug("Saving optee-hdr to scratch area 0x%p\n", 
> &scratch->optee_hdr);
> +
> +     memcpy(&scratch->optee_hdr, hdr, sz);
> +}
> +
> +const struct optee_header *imx8m_scratch_get_optee_hdr(void)
> +{
> +     if (!scratch) {
> +             if (IN_PBL)
> +                     return ERR_PTR(-EINVAL);
> +             else
> +                     scratch = (void *)arm_mem_scratch_get();
> +     }
> +
> +     return &scratch->optee_hdr;
> +}

These two function do not seem to be i.MX8 specific, I could reuse them
on i.MX9, so better with imx_ prefix?

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

Reply via email to