transfer_list.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. * Copyright (c) 2023-2024, Linaro Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef __TRANSFER_LIST_H
  7. #define __TRANSFER_LIST_H
  8. #include <stdbool.h>
  9. #include <stdint.h>
  10. #include <common/ep_info.h>
  11. #include <lib/utils_def.h>
  12. #define TRANSFER_LIST_SIGNATURE U(0x4a0fb10b)
  13. #define TRANSFER_LIST_VERSION U(0x0001)
  14. /*
  15. * Init value of maximum alignment required by any TE data in the TL
  16. * specified as a power of two
  17. */
  18. #define TRANSFER_LIST_INIT_MAX_ALIGN U(3)
  19. /* Alignment required by TE header start address, in bytes */
  20. #define TRANSFER_LIST_GRANULE U(8)
  21. /*
  22. * Version of the register convention used.
  23. * Set to 1 for both AArch64 and AArch32 according to fw handoff spec v0.9
  24. */
  25. #define REGISTER_CONVENTION_VERSION_MASK (1 << 24)
  26. #ifndef __ASSEMBLER__
  27. #define TL_FLAGS_HAS_CHECKSUM BIT(0)
  28. enum transfer_list_tag_id {
  29. TL_TAG_EMPTY = 0,
  30. TL_TAG_FDT = 1,
  31. TL_TAG_HOB_BLOCK = 2,
  32. TL_TAG_HOB_LIST = 3,
  33. TL_TAG_ACPI_TABLE_AGGREGATE = 4,
  34. TL_TAG_OPTEE_PAGABLE_PART = 0x100,
  35. TL_TAG_DT_SPMC_MANIFEST = 0x101,
  36. TL_TAG_EXEC_EP_INFO64 = 0x102,
  37. TL_TAG_TB_FW_CONFIG = 0x103,
  38. TL_TAG_SRAM_LAYOUT64 = 0x104,
  39. };
  40. enum transfer_list_ops {
  41. TL_OPS_NON, /* invalid for any operation */
  42. TL_OPS_ALL, /* valid for all operations */
  43. TL_OPS_RO, /* valid for read only */
  44. TL_OPS_CUS, /* abort or switch to special code to interpret */
  45. };
  46. struct transfer_list_header {
  47. uint32_t signature;
  48. uint8_t checksum;
  49. uint8_t version;
  50. uint8_t hdr_size;
  51. uint8_t alignment; /* max alignment of TE data */
  52. uint32_t size; /* TL header + all TEs */
  53. uint32_t max_size;
  54. uint32_t flags;
  55. uint32_t reserved; /* spare bytes */
  56. /*
  57. * Commented out element used to visualize dynamic part of the
  58. * data structure.
  59. *
  60. * Note that struct transfer_list_entry also is dynamic in size
  61. * so the elements can't be indexed directly but instead must be
  62. * traversed in order
  63. *
  64. * struct transfer_list_entry entries[];
  65. */
  66. };
  67. struct __attribute__((packed)) transfer_list_entry {
  68. uint32_t tag_id : 24;
  69. uint8_t hdr_size;
  70. uint32_t data_size;
  71. /*
  72. * Commented out element used to visualize dynamic part of the
  73. * data structure.
  74. *
  75. * Note that padding is added at the end of @data to make to reach
  76. * a 8-byte boundary.
  77. *
  78. * uint8_t data[ROUNDUP(data_size, 8)];
  79. */
  80. };
  81. CASSERT(sizeof(struct transfer_list_entry) == U(0x8), assert_transfer_list_entry_size);
  82. void transfer_list_dump(struct transfer_list_header *tl);
  83. entry_point_info_t *
  84. transfer_list_set_handoff_args(struct transfer_list_header *tl,
  85. entry_point_info_t *ep_info);
  86. struct transfer_list_header *transfer_list_init(void *addr, size_t max_size);
  87. struct transfer_list_header *
  88. transfer_list_relocate(struct transfer_list_header *tl, void *addr,
  89. size_t max_size);
  90. enum transfer_list_ops
  91. transfer_list_check_header(const struct transfer_list_header *tl);
  92. void transfer_list_update_checksum(struct transfer_list_header *tl);
  93. bool transfer_list_verify_checksum(const struct transfer_list_header *tl);
  94. bool transfer_list_set_data_size(struct transfer_list_header *tl,
  95. struct transfer_list_entry *entry,
  96. uint32_t new_data_size);
  97. void *transfer_list_entry_data(struct transfer_list_entry *entry);
  98. bool transfer_list_rem(struct transfer_list_header *tl,
  99. struct transfer_list_entry *entry);
  100. struct transfer_list_entry *transfer_list_add(struct transfer_list_header *tl,
  101. uint32_t tag_id,
  102. uint32_t data_size,
  103. const void *data);
  104. struct transfer_list_entry *
  105. transfer_list_add_with_align(struct transfer_list_header *tl, uint32_t tag_id,
  106. uint32_t data_size, const void *data,
  107. uint8_t alignment);
  108. struct transfer_list_entry *
  109. transfer_list_next(struct transfer_list_header *tl,
  110. struct transfer_list_entry *last);
  111. struct transfer_list_entry *transfer_list_find(struct transfer_list_header *tl,
  112. uint32_t tag_id);
  113. #endif /*__ASSEMBLER__*/
  114. #endif /*__TRANSFER_LIST_H*/