ls_ucode.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  20. * DEALINGS IN THE SOFTWARE.
  21. */
  22. #ifndef __NVKM_SECBOOT_LS_UCODE_H__
  23. #define __NVKM_SECBOOT_LS_UCODE_H__
  24. #include <core/os.h>
  25. #include <core/subdev.h>
  26. #include <subdev/secboot.h>
  27. /**
  28. * struct ls_ucode_img_desc - descriptor of firmware image
  29. * @descriptor_size: size of this descriptor
  30. * @image_size: size of the whole image
  31. * @bootloader_start_offset: start offset of the bootloader in ucode image
  32. * @bootloader_size: size of the bootloader
  33. * @bootloader_imem_offset: start off set of the bootloader in IMEM
  34. * @bootloader_entry_point: entry point of the bootloader in IMEM
  35. * @app_start_offset: start offset of the LS firmware
  36. * @app_size: size of the LS firmware's code and data
  37. * @app_imem_offset: offset of the app in IMEM
  38. * @app_imem_entry: entry point of the app in IMEM
  39. * @app_dmem_offset: offset of the data in DMEM
  40. * @app_resident_code_offset: offset of app code from app_start_offset
  41. * @app_resident_code_size: size of the code
  42. * @app_resident_data_offset: offset of data from app_start_offset
  43. * @app_resident_data_size: size of data
  44. *
  45. * A firmware image contains the code, data, and bootloader of a given LS
  46. * falcon in a single blob. This structure describes where everything is.
  47. *
  48. * This can be generated from a (bootloader, code, data) set if they have
  49. * been loaded separately, or come directly from a file.
  50. */
  51. struct ls_ucode_img_desc {
  52. u32 descriptor_size;
  53. u32 image_size;
  54. u32 tools_version;
  55. u32 app_version;
  56. char date[64];
  57. u32 bootloader_start_offset;
  58. u32 bootloader_size;
  59. u32 bootloader_imem_offset;
  60. u32 bootloader_entry_point;
  61. u32 app_start_offset;
  62. u32 app_size;
  63. u32 app_imem_offset;
  64. u32 app_imem_entry;
  65. u32 app_dmem_offset;
  66. u32 app_resident_code_offset;
  67. u32 app_resident_code_size;
  68. u32 app_resident_data_offset;
  69. u32 app_resident_data_size;
  70. u32 nb_overlays;
  71. struct {u32 start; u32 size; } load_ovl[64];
  72. u32 compressed;
  73. };
  74. /**
  75. * struct ls_ucode_img - temporary storage for loaded LS firmwares
  76. * @node: to link within lsf_ucode_mgr
  77. * @falcon_id: ID of the falcon this LS firmware is for
  78. * @ucode_desc: loaded or generated map of ucode_data
  79. * @ucode_data: firmware payload (code and data)
  80. * @ucode_size: size in bytes of data in ucode_data
  81. * @sig: signature for this firmware
  82. * @sig:size: size of the signature in bytes
  83. *
  84. * Preparing the WPR LS blob requires information about all the LS firmwares
  85. * (size, etc) to be known. This structure contains all the data of one LS
  86. * firmware.
  87. */
  88. struct ls_ucode_img {
  89. struct list_head node;
  90. enum nvkm_secboot_falcon falcon_id;
  91. struct ls_ucode_img_desc ucode_desc;
  92. u8 *ucode_data;
  93. u32 ucode_size;
  94. u8 *sig;
  95. u32 sig_size;
  96. };
  97. /**
  98. * struct fw_bin_header - header of firmware files
  99. * @bin_magic: always 0x3b1d14f0
  100. * @bin_ver: version of the bin format
  101. * @bin_size: entire image size including this header
  102. * @header_offset: offset of the firmware/bootloader header in the file
  103. * @data_offset: offset of the firmware/bootloader payload in the file
  104. * @data_size: size of the payload
  105. *
  106. * This header is located at the beginning of the HS firmware and HS bootloader
  107. * files, to describe where the headers and data can be found.
  108. */
  109. struct fw_bin_header {
  110. u32 bin_magic;
  111. u32 bin_ver;
  112. u32 bin_size;
  113. u32 header_offset;
  114. u32 data_offset;
  115. u32 data_size;
  116. };
  117. /**
  118. * struct fw_bl_desc - firmware bootloader descriptor
  119. * @start_tag: starting tag of bootloader
  120. * @desc_dmem_load_off: DMEM offset of flcn_bl_dmem_desc
  121. * @code_off: offset of code section
  122. * @code_size: size of code section
  123. * @data_off: offset of data section
  124. * @data_size: size of data section
  125. *
  126. * This structure is embedded in bootloader firmware files at to describe the
  127. * IMEM and DMEM layout expected by the bootloader.
  128. */
  129. struct fw_bl_desc {
  130. u32 start_tag;
  131. u32 dmem_load_off;
  132. u32 code_off;
  133. u32 code_size;
  134. u32 data_off;
  135. u32 data_size;
  136. };
  137. int acr_ls_ucode_load_fecs(const struct nvkm_subdev *, struct ls_ucode_img *);
  138. int acr_ls_ucode_load_gpccs(const struct nvkm_subdev *, struct ls_ucode_img *);
  139. #endif