summaryrefslogtreecommitdiffstats
path: root/common/optee.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/optee.c')
-rw-r--r--common/optee.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/common/optee.c b/common/optee.c
new file mode 100644
index 0000000000..d542dde118
--- /dev/null
+++ b/common/optee.c
@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#define pr_fmt(fmt) "optee: " fmt
+
+#include <tee/optee.h>
+#include <printk.h>
+#include <asm-generic/errno.h>
+
+int optee_verify_header(struct optee_header *hdr)
+{
+ if (hdr->magic != OPTEE_MAGIC) {
+ pr_err("Invalid header magic 0x%08x, expected 0x%08x\n",
+ hdr->magic, OPTEE_MAGIC);
+ return -EINVAL;
+ }
+
+ if (hdr->arch != OPTEE_ARCH_ARM32 || hdr->init_load_addr_hi) {
+ pr_err("Only 32bit supported\n");
+ return -EINVAL;
+ }
+
+ return 0;
+}