diff options
author | Rouven Czerwinski <r.czerwinski@pengutronix.de> | 2020-01-28 06:38:18 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2020-01-28 10:22:27 +0100 |
commit | c3474d0f77324a15c503551dc79fdf2ef891876f (patch) | |
tree | adb1cf5276c21735fc9b80d9c8bd36663a8a779b /common | |
parent | ee8960aec018df2ded4ac28776243bda0b633d67 (diff) | |
download | barebox-c3474d0f77324a15c503551dc79fdf2ef891876f.tar.gz barebox-c3474d0f77324a15c503551dc79fdf2ef891876f.tar.xz |
optee: move optee_verify_header() to common
Subsequent patches will use this to verify the header in the PBL, move
it to common to make it potentially available for both.
Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r-- | common/Makefile | 1 | ||||
-rw-r--r-- | common/optee.c | 23 |
2 files changed, 24 insertions, 0 deletions
diff --git a/common/Makefile b/common/Makefile index 11c91dd016..c86db71920 100644 --- a/common/Makefile +++ b/common/Makefile @@ -67,6 +67,7 @@ obj-$(CONFIG_BAREBOX_UPDATE_IMX_NAND_FCB) += imx-bbu-nand-fcb.o obj-$(CONFIG_BOOT) += boot.o obj-$(CONFIG_SERIAL_DEV_BUS) += serdev.o obj-$(CONFIG_USBGADGET_START) += usbgadget.o +obj-$(CONFIG_BOOTM_OPTEE) += optee.o ifdef CONFIG_PASSWORD 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; +} |