linux/types.h: Surround 'struct ustat' with __linux__
[oweals/u-boot.git] / include / tee / optee.h
index 8943afb4390778ba51f3a227001dd12a646d98e3..9446928fd4896de4e728a3940c586e47315cad8f 100644 (file)
@@ -1,10 +1,9 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
 /*
  * OP-TEE related definitions
  *
  * (C) Copyright 2016 Linaro Limited
  * Andrew F. Davis <andrew.davis@linaro.org>
- *
- * SPDX-License-Identifier: BSD-2-Clause
  */
 
 #ifndef        _OPTEE_H
@@ -29,6 +28,18 @@ struct optee_header {
        uint32_t paged_size;
 };
 
+static inline uint32_t optee_image_get_entry_point(const image_header_t *hdr)
+{
+       struct optee_header *optee_hdr = (struct optee_header *)(hdr + 1);
+
+       return optee_hdr->init_load_addr_lo;
+}
+
+static inline uint32_t optee_image_get_load_addr(const image_header_t *hdr)
+{
+       return optee_image_get_entry_point(hdr) - sizeof(struct optee_header);
+}
+
 #if defined(CONFIG_OPTEE)
 int optee_verify_image(struct optee_header *hdr, unsigned long tzdram_start,
                       unsigned long tzdram_len, unsigned long image_len);
@@ -43,4 +54,17 @@ static inline int optee_verify_image(struct optee_header *hdr,
 
 #endif
 
+#if defined(CONFIG_OPTEE)
+int optee_verify_bootm_image(unsigned long image_addr,
+                            unsigned long image_load_addr,
+                            unsigned long image_len);
+#else
+static inline int optee_verify_bootm_image(unsigned long image_addr,
+                                          unsigned long image_load_addr,
+                                          unsigned long image_len)
+{
+       return -EPERM;
+}
+#endif
+
 #endif /* _OPTEE_H */