[PATCH v2 05/18] ARM: i.MX8M: scratch: add optee_hdr area

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.felsch@xxxxxxxxxxxxxx>
---
 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;
+}
+
 static int imx8m_reserve_scratch_area(void)
 {
 	return PTR_ERR_OR_ZERO(request_sdram_region("scratch area",
diff --git a/include/mach/imx/scratch.h b/include/mach/imx/scratch.h
index 487171fbee97..59681145e76f 100644
--- a/include/mach/imx/scratch.h
+++ b/include/mach/imx/scratch.h
@@ -8,6 +8,11 @@ void imx8m_init_scratch_space(int ddr_buswidth, bool zero_init);
 const u32 *imx8m_scratch_get_bootrom_log(void);
 void imx8m_scratch_save_bootrom_log(const u32 *rom_log);
 
+struct optee_header;
+
+const struct optee_header *imx8m_scratch_get_optee_hdr(void);
+void imx8m_scratch_save_optee_hdr(const struct optee_header *hdr);
+
 #define imx8mq_init_scratch_space() imx8m_init_scratch_space(32, true)
 #define imx8mm_init_scratch_space() imx8m_init_scratch_space(32, true)
 #define imx8mn_init_scratch_space() imx8m_init_scratch_space(16, true)
-- 
2.39.2





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux