optee_utils.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright (c) 2017-2023, Arm Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef OPTEE_UTILS_H
  7. #define OPTEE_UTILS_H
  8. #include <stdbool.h>
  9. #include <common/bl_common.h>
  10. bool optee_header_is_valid(uintptr_t header_base);
  11. int parse_optee_header(entry_point_info_t *header_ep,
  12. image_info_t *pager_image_info,
  13. image_info_t *paged_image_info);
  14. /*
  15. * load_addr_hi and load_addr_lo: image load address.
  16. * image_id: 0 - pager, 1 - paged
  17. * size: image size in bytes.
  18. */
  19. typedef struct optee_image {
  20. uint32_t load_addr_hi;
  21. uint32_t load_addr_lo;
  22. uint32_t image_id;
  23. uint32_t size;
  24. } optee_image_t;
  25. #define OPTEE_PAGER_IMAGE_ID 0
  26. #define OPTEE_PAGED_IMAGE_ID 1
  27. #define OPTEE_MAX_NUM_IMAGES 2u
  28. #define TEE_MAGIC_NUM_OPTEE 0x4554504f
  29. /*
  30. * magic: header magic number.
  31. * version: OPTEE header version:
  32. * 1 - not supported
  33. * 2 - supported
  34. * arch: OPTEE os architecture type: 0 - AARCH32, 1 - AARCH64.
  35. * flags: unused currently.
  36. * nb_images: number of images.
  37. */
  38. typedef struct optee_header {
  39. uint32_t magic;
  40. uint8_t version;
  41. uint8_t arch;
  42. uint16_t flags;
  43. uint32_t nb_images;
  44. optee_image_t optee_image_list[];
  45. } optee_header_t;
  46. #endif /* OPTEE_UTILS_H */