2 * Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
23 #ifndef __NVKM_SECBOOT_LS_UCODE_H__
24 #define __NVKM_SECBOOT_LS_UCODE_H__
27 #include <core/subdev.h>
28 #include <subdev/secboot.h>
37 * struct lsf_ucode_desc - LS falcon signatures
38 * @prd_keys: signature to use when the GPU is in production mode
39 * @dgb_keys: signature to use when the GPU is in debug mode
40 * @b_prd_present: whether the production key is present
41 * @b_dgb_present: whether the debug key is present
42 * @falcon_id: ID of the falcon the ucode applies to
44 * Directly loaded from a signature file.
46 struct lsf_ucode_desc {
55 * struct lsf_lsb_header - LS firmware header
56 * @signature: signature to verify the firmware against
57 * @ucode_off: offset of the ucode blob in the WPR region. The ucode
58 * blob contains the bootloader, code and data of the
60 * @ucode_size: size of the ucode blob, including bootloader
61 * @data_size: size of the ucode blob data
62 * @bl_code_size: size of the bootloader code
63 * @bl_imem_off: offset in imem of the bootloader
64 * @bl_data_off: offset of the bootloader data in WPR region
65 * @bl_data_size: size of the bootloader data
66 * @app_code_off: offset of the app code relative to ucode_off
67 * @app_code_size: size of the app code
68 * @app_data_off: offset of the app data relative to ucode_off
69 * @app_data_size: size of the app data
70 * @flags: flags for the secure bootloader
72 * This structure is written into the WPR region for each managed falcon. Each
73 * instance is referenced by the lsb_offset member of the corresponding
76 struct lsf_lsb_header {
77 struct lsf_ucode_desc signature;
90 #define LSF_FLAG_LOAD_CODE_AT_0 1
91 #define LSF_FLAG_DMACTL_REQ_CTX 4
92 #define LSF_FLAG_FORCE_PRIV_LOAD 8
96 * struct lsf_wpr_header - LS blob WPR Header
97 * @falcon_id: LS falcon ID
98 * @lsb_offset: offset of the lsb_lsf_header in the WPR region
99 * @bootstrap_owner: secure falcon reponsible for bootstrapping the LS falcon
100 * @lazy_bootstrap: skip bootstrapping by ACR
101 * @status: bootstrapping status
103 * An array of these is written at the beginning of the WPR region, one for
104 * each managed falcon. The array is terminated by an instance which falcon_id
105 * is LSF_FALCON_ID_INVALID.
107 struct lsf_wpr_header {
113 #define LSF_IMAGE_STATUS_NONE 0
114 #define LSF_IMAGE_STATUS_COPY 1
115 #define LSF_IMAGE_STATUS_VALIDATION_CODE_FAILED 2
116 #define LSF_IMAGE_STATUS_VALIDATION_DATA_FAILED 3
117 #define LSF_IMAGE_STATUS_VALIDATION_DONE 4
118 #define LSF_IMAGE_STATUS_VALIDATION_SKIPPED 5
119 #define LSF_IMAGE_STATUS_BOOTSTRAP_READY 6
124 * struct ls_ucode_img_desc - descriptor of firmware image
125 * @descriptor_size: size of this descriptor
126 * @image_size: size of the whole image
127 * @bootloader_start_offset: start offset of the bootloader in ucode image
128 * @bootloader_size: size of the bootloader
129 * @bootloader_imem_offset: start off set of the bootloader in IMEM
130 * @bootloader_entry_point: entry point of the bootloader in IMEM
131 * @app_start_offset: start offset of the LS firmware
132 * @app_size: size of the LS firmware's code and data
133 * @app_imem_offset: offset of the app in IMEM
134 * @app_imem_entry: entry point of the app in IMEM
135 * @app_dmem_offset: offset of the data in DMEM
136 * @app_resident_code_offset: offset of app code from app_start_offset
137 * @app_resident_code_size: size of the code
138 * @app_resident_data_offset: offset of data from app_start_offset
139 * @app_resident_data_size: size of data
141 * A firmware image contains the code, data, and bootloader of a given LS
142 * falcon in a single blob. This structure describes where everything is.
144 * This can be generated from a (bootloader, code, data) set if they have
145 * been loaded separately, or come directly from a file.
147 struct ls_ucode_img_desc {
153 u32 bootloader_start_offset;
155 u32 bootloader_imem_offset;
156 u32 bootloader_entry_point;
157 u32 app_start_offset;
162 u32 app_resident_code_offset;
163 u32 app_resident_code_size;
164 u32 app_resident_data_offset;
165 u32 app_resident_data_size;
167 struct {u32 start; u32 size; } load_ovl[64];
172 * struct ls_ucode_img - temporary storage for loaded LS firmwares
173 * @node: to link within lsf_ucode_mgr
174 * @falcon_id: ID of the falcon this LS firmware is for
175 * @ucode_desc: loaded or generated map of ucode_data
176 * @ucode_data: firmware payload (code and data)
177 * @ucode_size: size in bytes of data in ucode_data
178 * @wpr_header: WPR header to be written to the LS blob
179 * @lsb_header: LSB header to be written to the LS blob
181 * Preparing the WPR LS blob requires information about all the LS firmwares
182 * (size, etc) to be known. This structure contains all the data of one LS
185 struct ls_ucode_img {
186 struct list_head node;
187 enum nvkm_secboot_falcon falcon_id;
189 struct ls_ucode_img_desc ucode_desc;
193 struct lsf_wpr_header wpr_header;
194 struct lsf_lsb_header lsb_header;
198 * struct fw_bin_header - header of firmware files
199 * @bin_magic: always 0x3b1d14f0
200 * @bin_ver: version of the bin format
201 * @bin_size: entire image size including this header
202 * @header_offset: offset of the firmware/bootloader header in the file
203 * @data_offset: offset of the firmware/bootloader payload in the file
204 * @data_size: size of the payload
206 * This header is located at the beginning of the HS firmware and HS bootloader
207 * files, to describe where the headers and data can be found.
209 struct fw_bin_header {
219 * struct fw_bl_desc - firmware bootloader descriptor
220 * @start_tag: starting tag of bootloader
221 * @desc_dmem_load_off: DMEM offset of flcn_bl_dmem_desc
222 * @code_off: offset of code section
223 * @code_size: size of code section
224 * @data_off: offset of data section
225 * @data_size: size of data section
227 * This structure is embedded in bootloader firmware files at to describe the
228 * IMEM and DMEM layout expected by the bootloader.
239 int acr_ls_ucode_load_fecs(const struct nvkm_subdev *, struct ls_ucode_img *);
240 int acr_ls_ucode_load_gpccs(const struct nvkm_subdev *, struct ls_ucode_img *);