transfer-list-compiler.rst 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. Transfer List Compiler
  2. ======================
  3. The Transfer List Compiler (tlc) is a host tool used by TF-A to generate transfer
  4. lists compliant with the v0.9 of the `Firmware Handoff specification`_. It enables
  5. developers to statically generate transfer list blobs containing any number of
  6. transfer entries.
  7. Getting Started
  8. ~~~~~~~~~~~~~~~
  9. ``tlc`` is installed by default with TF-A's poetry environment. All of it's
  10. dependencies are listed in `tools/tlc/pyproject.toml`_.
  11. To install ``tlc`` seperately, run the following command:
  12. .. code::
  13. make -C tools/tlc install
  14. Creating a Transfer List
  15. ~~~~~~~~~~~~~~~~~~~~~~~~
  16. To create an empty TL, you can use the ``create`` command.
  17. .. code::
  18. tlc create tl.bin
  19. This commands generates a binary blob representing an empty TL, shown in the
  20. hexdump below.
  21. .. code::
  22. $ hexdump tl.bin | head
  23. 0000000 b10b 4a0f 01a6 0318 0018 0000 1000 0000
  24. 0000010 0001 0000 0000 0000
  25. A common use-case this tool supports is the addition of TE's via the option
  26. ``--entry``. This takes as input the tag ID and path to a binary blob to be
  27. included in the transfer list. The snippet below shows how to include an FDT in
  28. the TL.
  29. .. code::
  30. tlc create --entry 1 fdt.dtb tl.bin
  31. Alternatively, addition of a device tree is supported through the option
  32. ``--fdt``. This has the same effect as passing the device tree and it's tag ID
  33. through the ``--entry`` option.
  34. .. code::
  35. tlc create --fdt fdt.dtb tl.bin
  36. .. note::
  37. ``tlc`` makes no effort to verify the contents of a binary blob against the
  38. provided tag ID. It only checks that the tags provided as input are within
  39. range and that there is sufficient memory to include their TE's.
  40. You can also create a TL from a YAML config file.
  41. .. code ::
  42. tlc create --from-yaml config.yaml tl.bin
  43. Printing the contents of a TL
  44. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  45. Support is provided for dumping the contents of a TL via the ``info`` command.
  46. This prints the header of the TL and all included TE's.
  47. .. code::
  48. $ tlc info tl.bin
  49. signature 0x4a0fb10b
  50. checksum 0xe1
  51. version 0x1
  52. hdr_size 0x18
  53. alignment 0x3
  54. size 0x2a6f
  55. total_size 0x4e20
  56. flags 0x1
  57. ----
  58. id 0x1
  59. data_size 0x2a47
  60. hdr_size 0x8
  61. offset 0x18
  62. ----
  63. id 0x0
  64. data_size 0x0
  65. hdr_size 0x8
  66. offset 0x2a68
  67. The example above shows the dump produced by ``tlc`` for a 20Kb TL containing a
  68. device tree (tag_id=1) and a NULL entry (tag_id=0).
  69. Modifying the contents of an existing TL
  70. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  71. `tlc` supports removal of one or more entries from a TL through the ``remove``
  72. command. It takes as argument the filename, and one or more tag ID's, passed
  73. through the ``--tags`` option. It produces a valid TL blob without those
  74. entries.
  75. For example, using the same blob as in the section above, we can remove the FDT
  76. TE with the command.
  77. .. code::
  78. $ tlc remove --tags 1 tl.bin
  79. Using the ``info`` command, shows the the TE has been remove:
  80. .. code::
  81. $ tlc info tl.bin
  82. signature 0x4a0fb10b
  83. checksum 0x38
  84. version 0x1
  85. hdr_size 0x18
  86. alignment 0x3
  87. size 0x20
  88. total_size 0x4e20
  89. flags 0x1
  90. ----
  91. id 0x0
  92. data_size 0x0
  93. hdr_size 0x8
  94. offset 0x18
  95. Note that more than one entry can be removed at a time. The ``--tags`` option
  96. accepts multiple tag ID's.
  97. Conversely, TE's can be added to an existing TL. This is achieved through the
  98. `add` command.
  99. .. code::
  100. $ tlc add --entry 1 fdt.dtb tl.bin
  101. The result of this modification is shown below:
  102. .. code::
  103. $ tlc info tl.bin
  104. signature 0x4a0fb10b
  105. checksum 0xe1
  106. version 0x1
  107. hdr_size 0x18
  108. alignment 0x3
  109. size 0x2a6f
  110. total_size 0x4e20
  111. flags 0x1
  112. ----
  113. id 0x0
  114. data_size 0x0
  115. hdr_size 0x8
  116. offset 0x18
  117. ----
  118. id 0x1
  119. data_size 0x2a47
  120. hdr_size 0x8
  121. offset 0x20
  122. Unpacking a Transfer List
  123. ~~~~~~~~~~~~~~~~~~~~~~~~~
  124. Given a transfer list, ``tlc`` also provides a mechanism for extracting TE data.
  125. Running the command ``unpack``, yields binary files containing data from all the TE's.
  126. .. code::
  127. $ tlc create --size 20000 --fdt build/fvp/debug/fdts/fvp-base-gicv3-psci.dtb tl.bin
  128. $ tlc unpack tl.bin
  129. $ file te_1.bin
  130. te_1.bin: Device Tree Blob version 17, size=10823, boot CPU=0, string block size=851, DT structure block size=9900
  131. Validate a Transfer List
  132. ~~~~~~~~~~~~~~~~~~~~~~~~
  133. ``tlc validate`` provides a quick and simple mechanism for checking wether the TL
  134. is compliant with version of the specification supported by the tool. It
  135. performs the following checks:
  136. #. Validates the signature.
  137. #. Ensures that the specified version is greater than or equal to the tool’s current version.
  138. #. Verifies alignment criteria for all TE’s.
  139. YAML Config File Format
  140. ~~~~~~~~~~~~~~~~~~~~~~~
  141. Example YAML config file:
  142. .. code::
  143. execution_state: aarch32
  144. has_checksum: true
  145. max_size: 4096
  146. entries:
  147. - tag_id: 258 # entry point info
  148. ep_info:
  149. args:
  150. - 67112968
  151. - 67112960
  152. - 0
  153. - 0
  154. - 0
  155. - 0
  156. - 0
  157. - 0
  158. h:
  159. attr: 8
  160. type: 1
  161. version: 2
  162. pc: 67239936
  163. spsr: 467
  164. - tag_id: 3 # memory layout
  165. addr: 8
  166. size: 8
  167. - tag_id: 1, # fdt
  168. blob_file_path: "fdt.bin",
  169. `max_size` defaults to `0x1000`, `execution_state` defaults to `aarch64`, and `has_checksum`
  170. defaults to `true`.
  171. The fields of the YAML file should match the fields in the specification for the transfer list. You
  172. don't need to give the hdr_size or data_size fields. For example, a memory layout entry would have
  173. an entry like:
  174. .. code::
  175. tag_id: 3
  176. addr: 8
  177. size: 8
  178. You can input blob files by giving paths to the current working directory. You can do this for any
  179. TE type. For example, an FDT layout would have an entry like:
  180. .. code::
  181. tag_id: 1,
  182. blob_file_path: "fdt.bin",
  183. You can input C-types by giving its fields. For example, an entry point
  184. info entry would have an entry like:
  185. .. code::
  186. tag_id: 258
  187. ep_info:
  188. args:
  189. - 67112968
  190. - 67112960
  191. - 0
  192. - 0
  193. h:
  194. attr: 8
  195. type: 1
  196. version: 2
  197. lr_svc: 0
  198. pc: 67239936
  199. spsr: 467
  200. You can give the name of the tag instead of the tag id number. The valid tag names are in the
  201. `transfer_entry_formats` dict in `tools/tlc/tlc/tl.py`_. Some examples are:
  202. * empty
  203. * fdt
  204. * hob_block
  205. * hob_list
  206. You can input the attr field of entry_point_info as a string of flag
  207. names separated by `|`. The names are taken from ep_info_exp.h in TF-A.
  208. For example:
  209. .. code::
  210. has_checksum: true
  211. max_size: 4096
  212. entries:
  213. - tag_id: 0x102
  214. ep_info:
  215. args:
  216. - 67112976
  217. - 67112960
  218. - 0
  219. - 0
  220. - 0
  221. - 0
  222. - 0
  223. - 0
  224. h:
  225. attr: EP_NON_SECURE | EP_ST_ENABLE
  226. type: 1
  227. version: 2
  228. pc: 67239936
  229. spsr: 965
  230. --------------
  231. *Copyright (c) 2024, Arm Limited. All rights reserved.*
  232. .. _Firmware Handoff specification: https://github.com/FirmwareHandoff/firmware_handoff/
  233. .. _tools/tlc/pyproject.toml: https://review.trustedfirmware.org/plugins/gitiles/TF-A/trusted-firmware-a/+/refs/heads/master/tools/tlc/pyproject.toml
  234. .. _tools/tlc/tlc/tl.py: https://review.trustedfirmware.org/plugins/gitiles/TF-A/trusted-firmware-a/+/refs/heads/master/tools/tlc/tlc/tl.py