]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - drivers/gpu/drm/nouveau/nvkm/subdev/secboot/ls_ucode.h
drm/nouveau/secboot: remove unneeded ls_ucode_img member
[karo-tx-linux.git] / drivers / gpu / drm / nouveau / nvkm / subdev / secboot / ls_ucode.h
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
23 #ifndef __NVKM_SECBOOT_LS_UCODE_H__
24 #define __NVKM_SECBOOT_LS_UCODE_H__
25
26 #include <core/os.h>
27 #include <core/subdev.h>
28 #include <subdev/secboot.h>
29
30 /*
31  *
32  * LS blob structures
33  *
34  */
35
36 /**
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
43  *
44  * Directly loaded from a signature file.
45  */
46 struct lsf_ucode_desc {
47         u8 prd_keys[2][16];
48         u8 dbg_keys[2][16];
49         u32 b_prd_present;
50         u32 b_dbg_present;
51         u32 falcon_id;
52 };
53
54 /**
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
59  *                      LS falcon
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
71  *
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
74  * lsf_wpr_header.
75  */
76 struct lsf_lsb_header {
77         struct lsf_ucode_desc signature;
78         u32 ucode_off;
79         u32 ucode_size;
80         u32 data_size;
81         u32 bl_code_size;
82         u32 bl_imem_off;
83         u32 bl_data_off;
84         u32 bl_data_size;
85         u32 app_code_off;
86         u32 app_code_size;
87         u32 app_data_off;
88         u32 app_data_size;
89         u32 flags;
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
93 };
94
95 /**
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
102  *
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.
106  */
107 struct lsf_wpr_header {
108         u32 falcon_id;
109         u32 lsb_offset;
110         u32 bootstrap_owner;
111         u32 lazy_bootstrap;
112         u32 status;
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
120 };
121
122
123 /**
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
140  *
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.
143  *
144  * This can be generated from a (bootloader, code, data) set if they have
145  * been loaded separately, or come directly from a file.
146  */
147 struct ls_ucode_img_desc {
148         u32 descriptor_size;
149         u32 image_size;
150         u32 tools_version;
151         u32 app_version;
152         char date[64];
153         u32 bootloader_start_offset;
154         u32 bootloader_size;
155         u32 bootloader_imem_offset;
156         u32 bootloader_entry_point;
157         u32 app_start_offset;
158         u32 app_size;
159         u32 app_imem_offset;
160         u32 app_imem_entry;
161         u32 app_dmem_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;
166         u32 nb_overlays;
167         struct {u32 start; u32 size; } load_ovl[64];
168         u32 compressed;
169 };
170
171 /**
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
180  *
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
183  * firmware.
184  */
185 struct ls_ucode_img {
186         struct list_head node;
187         enum nvkm_secboot_falcon falcon_id;
188
189         struct ls_ucode_img_desc ucode_desc;
190         u8 *ucode_data;
191         u32 ucode_size;
192
193         struct lsf_wpr_header wpr_header;
194         struct lsf_lsb_header lsb_header;
195 };
196
197 /**
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
205  *
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.
208  */
209 struct fw_bin_header {
210         u32 bin_magic;
211         u32 bin_ver;
212         u32 bin_size;
213         u32 header_offset;
214         u32 data_offset;
215         u32 data_size;
216 };
217
218 /**
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
226  *
227  * This structure is embedded in bootloader firmware files at to describe the
228  * IMEM and DMEM layout expected by the bootloader.
229  */
230 struct fw_bl_desc {
231         u32 start_tag;
232         u32 dmem_load_off;
233         u32 code_off;
234         u32 code_size;
235         u32 data_off;
236         u32 data_size;
237 };
238
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 *);
241
242
243 #endif