ls_ucode.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. struct nvkm_acr;
  28. /**
  29. * struct ls_ucode_img_desc - descriptor of firmware image
  30. * @descriptor_size: size of this descriptor
  31. * @image_size: size of the whole image
  32. * @bootloader_start_offset: start offset of the bootloader in ucode image
  33. * @bootloader_size: size of the bootloader
  34. * @bootloader_imem_offset: start off set of the bootloader in IMEM
  35. * @bootloader_entry_point: entry point of the bootloader in IMEM
  36. * @app_start_offset: start offset of the LS firmware
  37. * @app_size: size of the LS firmware's code and data
  38. * @app_imem_offset: offset of the app in IMEM
  39. * @app_imem_entry: entry point of the app in IMEM
  40. * @app_dmem_offset: offset of the data in DMEM
  41. * @app_resident_code_offset: offset of app code from app_start_offset
  42. * @app_resident_code_size: size of the code
  43. * @app_resident_data_offset: offset of data from app_start_offset
  44. * @app_resident_data_size: size of data
  45. *
  46. * A firmware image contains the code, data, and bootloader of a given LS
  47. * falcon in a single blob. This structure describes where everything is.
  48. *
  49. * This can be generated from a (bootloader, code, data) set if they have
  50. * been loaded separately, or come directly from a file.
  51. */
  52. struct ls_ucode_img_desc {
  53. u32 descriptor_size;
  54. u32 image_size;
  55. u32 tools_version;
  56. u32 app_version;
  57. char date[64];
  58. u32 bootloader_start_offset;
  59. u32 bootloader_size;
  60. u32 bootloader_imem_offset;
  61. u32 bootloader_entry_point;
  62. u32 app_start_offset;
  63. u32 app_size;
  64. u32 app_imem_offset;
  65. u32 app_imem_entry;
  66. u32 app_dmem_offset;
  67. u32 app_resident_code_offset;
  68. u32 app_resident_code_size;
  69. u32 app_resident_data_offset;
  70. u32 app_resident_data_size;
  71. u32 nb_overlays;
  72. struct {u32 start; u32 size; } load_ovl[64];
  73. u32 compressed;
  74. };
  75. /**
  76. * struct ls_ucode_img - temporary storage for loaded LS firmwares
  77. * @node: to link within lsf_ucode_mgr
  78. * @falcon_id: ID of the falcon this LS firmware is for
  79. * @ucode_desc: loaded or generated map of ucode_data
  80. * @ucode_data: firmware payload (code and data)
  81. * @ucode_size: size in bytes of data in ucode_data
  82. * @ucode_off: offset of the ucode in ucode_data
  83. * @sig: signature for this firmware
  84. * @sig:size: size of the signature in bytes
  85. *
  86. * Preparing the WPR LS blob requires information about all the LS firmwares
  87. * (size, etc) to be known. This structure contains all the data of one LS
  88. * firmware.
  89. */
  90. struct ls_ucode_img {
  91. struct list_head node;
  92. enum nvkm_secboot_falcon falcon_id;
  93. struct ls_ucode_img_desc ucode_desc;
  94. u8 *ucode_data;
  95. u32 ucode_size;
  96. u32 ucode_off;
  97. u8 *sig;
  98. u32 sig_size;
  99. };
  100. /**
  101. * struct fw_bin_header - header of firmware files
  102. * @bin_magic: always 0x3b1d14f0
  103. * @bin_ver: version of the bin format
  104. * @bin_size: entire image size including this header
  105. * @header_offset: offset of the firmware/bootloader header in the file
  106. * @data_offset: offset of the firmware/bootloader payload in the file
  107. * @data_size: size of the payload
  108. *
  109. * This header is located at the beginning of the HS firmware and HS bootloader
  110. * files, to describe where the headers and data can be found.
  111. */
  112. struct fw_bin_header {
  113. u32 bin_magic;
  114. u32 bin_ver;
  115. u32 bin_size;
  116. u32 header_offset;
  117. u32 data_offset;
  118. u32 data_size;
  119. };
  120. /**
  121. * struct fw_bl_desc - firmware bootloader descriptor
  122. * @start_tag: starting tag of bootloader
  123. * @desc_dmem_load_off: DMEM offset of flcn_bl_dmem_desc
  124. * @code_off: offset of code section
  125. * @code_size: size of code section
  126. * @data_off: offset of data section
  127. * @data_size: size of data section
  128. *
  129. * This structure is embedded in bootloader firmware files at to describe the
  130. * IMEM and DMEM layout expected by the bootloader.
  131. */
  132. struct fw_bl_desc {
  133. u32 start_tag;
  134. u32 dmem_load_off;
  135. u32 code_off;
  136. u32 code_size;
  137. u32 data_off;
  138. u32 data_size;
  139. };
  140. int acr_ls_ucode_load_fecs(const struct nvkm_secboot *, struct ls_ucode_img *);
  141. int acr_ls_ucode_load_gpccs(const struct nvkm_secboot *, struct ls_ucode_img *);
  142. int acr_ls_ucode_load_pmu(const struct nvkm_secboot *, struct ls_ucode_img *);
  143. int acr_ls_pmu_post_run(const struct nvkm_acr *, const struct nvkm_secboot *);
  144. int acr_ls_ucode_load_sec2(const struct nvkm_secboot *, struct ls_ucode_img *);
  145. int acr_ls_sec2_post_run(const struct nvkm_acr *, const struct nvkm_secboot *);
  146. #endif