xref: /arm-trusted-firmware/plat/st/stm32mp1/include/boot_api.h (revision 91f16700b400a8c0651d24a598fc48ee2997a0d7)
1*91f16700Schasinglulu /*
2*91f16700Schasinglulu  * Copyright (c) 2017-2023, STMicroelectronics - All Rights Reserved
3*91f16700Schasinglulu  *
4*91f16700Schasinglulu  * SPDX-License-Identifier: BSD-3-Clause
5*91f16700Schasinglulu  */
6*91f16700Schasinglulu 
7*91f16700Schasinglulu #ifndef BOOT_API_H
8*91f16700Schasinglulu #define BOOT_API_H
9*91f16700Schasinglulu 
10*91f16700Schasinglulu #include <stdint.h>
11*91f16700Schasinglulu #include <stdio.h>
12*91f16700Schasinglulu 
13*91f16700Schasinglulu /*
14*91f16700Schasinglulu  * Possible value of boot context field 'auth_status'
15*91f16700Schasinglulu  */
16*91f16700Schasinglulu #if STM32MP13
17*91f16700Schasinglulu  /* No authentication done */
18*91f16700Schasinglulu #define BOOT_API_CTX_AUTH_NO					0x7CFDD351U
19*91f16700Schasinglulu  /* Authentication done and failed */
20*91f16700Schasinglulu #define BOOT_API_CTX_AUTH_FAILED				0x51330884U
21*91f16700Schasinglulu  /* Authentication done and success */
22*91f16700Schasinglulu #define BOOT_API_CTX_AUTH_SUCCESS				0x67E8CAE1U
23*91f16700Schasinglulu #endif
24*91f16700Schasinglulu #if STM32MP15
25*91f16700Schasinglulu /* No authentication done */
26*91f16700Schasinglulu #define BOOT_API_CTX_AUTH_NO					0x0U
27*91f16700Schasinglulu /* Authentication done and failed */
28*91f16700Schasinglulu #define BOOT_API_CTX_AUTH_FAILED				0x1U
29*91f16700Schasinglulu /* Authentication done and succeeded */
30*91f16700Schasinglulu #define BOOT_API_CTX_AUTH_SUCCESS				0x2U
31*91f16700Schasinglulu #endif
32*91f16700Schasinglulu 
33*91f16700Schasinglulu /*
34*91f16700Schasinglulu  * Possible value of boot context field 'boot_interface_sel'
35*91f16700Schasinglulu  */
36*91f16700Schasinglulu 
37*91f16700Schasinglulu /* Value of field 'boot_interface_sel' when no boot occurred */
38*91f16700Schasinglulu #define BOOT_API_CTX_BOOT_INTERFACE_SEL_NO			0x0U
39*91f16700Schasinglulu 
40*91f16700Schasinglulu /* Boot occurred on SD */
41*91f16700Schasinglulu #define BOOT_API_CTX_BOOT_INTERFACE_SEL_FLASH_SD		0x1U
42*91f16700Schasinglulu 
43*91f16700Schasinglulu /* Boot occurred on EMMC */
44*91f16700Schasinglulu #define BOOT_API_CTX_BOOT_INTERFACE_SEL_FLASH_EMMC		0x2U
45*91f16700Schasinglulu 
46*91f16700Schasinglulu /* Boot occurred on FMC */
47*91f16700Schasinglulu #define BOOT_API_CTX_BOOT_INTERFACE_SEL_FLASH_NAND_FMC		0x3U
48*91f16700Schasinglulu 
49*91f16700Schasinglulu /* Boot occurred on QSPI NOR */
50*91f16700Schasinglulu #define BOOT_API_CTX_BOOT_INTERFACE_SEL_FLASH_NOR_SPI		0x4U
51*91f16700Schasinglulu 
52*91f16700Schasinglulu /* Boot occurred on UART */
53*91f16700Schasinglulu #define BOOT_API_CTX_BOOT_INTERFACE_SEL_SERIAL_UART		0x5U
54*91f16700Schasinglulu 
55*91f16700Schasinglulu /* Boot occurred on USB */
56*91f16700Schasinglulu #define BOOT_API_CTX_BOOT_INTERFACE_SEL_SERIAL_USB		0x6U
57*91f16700Schasinglulu 
58*91f16700Schasinglulu /* Boot occurred on QSPI NAND */
59*91f16700Schasinglulu #define BOOT_API_CTX_BOOT_INTERFACE_SEL_FLASH_NAND_SPI		0x7U
60*91f16700Schasinglulu 
61*91f16700Schasinglulu /**
62*91f16700Schasinglulu  * @brief  Possible value of boot context field 'EmmcXferStatus'
63*91f16700Schasinglulu  */
64*91f16700Schasinglulu /*
65*91f16700Schasinglulu  * Possible value of boot context field 'emmc_xfer_status'
66*91f16700Schasinglulu  */
67*91f16700Schasinglulu #define BOOT_API_CTX_EMMC_XFER_STATUS_NOT_STARTED			0x0U
68*91f16700Schasinglulu #define BOOT_API_CTX_EMMC_XFER_STATUS_DATAEND_DETECTED			0x1U
69*91f16700Schasinglulu #define BOOT_API_CTX_EMMC_XFER_STATUS_XFER_OVERALL_TIMEOUT_DETECTED	0x2U
70*91f16700Schasinglulu #define BOOT_API_CTX_EMMC_XFER_STATUS_XFER_DATA_TIMEOUT			0x3U
71*91f16700Schasinglulu 
72*91f16700Schasinglulu /*
73*91f16700Schasinglulu  * Possible value of boot context field 'emmc_error_status'
74*91f16700Schasinglulu  */
75*91f16700Schasinglulu #define BOOT_API_CTX_EMMC_ERROR_STATUS_NONE                     0x0U
76*91f16700Schasinglulu #define BOOT_API_CTX_EMMC_ERROR_STATUS_CMD_TIMEOUT              0x1U
77*91f16700Schasinglulu #define BOOT_API_CTX_EMMC_ERROR_STATUS_ACK_TIMEOUT              0x2U
78*91f16700Schasinglulu #define BOOT_API_CTX_EMMC_ERROR_STATUS_DATA_CRC_FAIL            0x3U
79*91f16700Schasinglulu #define BOOT_API_CTX_EMMC_ERROR_STATUS_NOT_ENOUGH_BOOT_DATA_RX  0x4U
80*91f16700Schasinglulu #define BOOT_API_CTX_EMMC_ERROR_STATUS_HEADER_NOT_FOUND         0x5U
81*91f16700Schasinglulu #define BOOT_API_CTX_EMMC_ERROR_STATUS_HEADER_SIZE_ZERO         0x6U
82*91f16700Schasinglulu #define BOOT_API_CTX_EMMC_ERROR_STATUS_IMAGE_NOT_COMPLETE       0x7U
83*91f16700Schasinglulu #define BOOT_API_CTX_EMMC_ERROR_STATUS_ACK_ERROR                0x8U
84*91f16700Schasinglulu 
85*91f16700Schasinglulu /* Image Header related definitions */
86*91f16700Schasinglulu 
87*91f16700Schasinglulu /* Definition of header version */
88*91f16700Schasinglulu #if STM32MP13
89*91f16700Schasinglulu #define BOOT_API_HEADER_VERSION					0x00020000U
90*91f16700Schasinglulu #endif
91*91f16700Schasinglulu #if STM32MP15
92*91f16700Schasinglulu #define BOOT_API_HEADER_VERSION					0x00010000U
93*91f16700Schasinglulu #endif
94*91f16700Schasinglulu 
95*91f16700Schasinglulu /*
96*91f16700Schasinglulu  * Magic number used to detect header in memory
97*91f16700Schasinglulu  * Its value must be 'S' 'T' 'M' 0x32, i.e 0x324D5453 as field
98*91f16700Schasinglulu  * 'bootapi_image_header_t.magic'
99*91f16700Schasinglulu  * This identifies the start of a boot image.
100*91f16700Schasinglulu  */
101*91f16700Schasinglulu #define BOOT_API_IMAGE_HEADER_MAGIC_NB				0x324D5453U
102*91f16700Schasinglulu 
103*91f16700Schasinglulu /* Definitions related to Authentication used in image header structure */
104*91f16700Schasinglulu #define BOOT_API_ECDSA_PUB_KEY_LEN_IN_BYTES			64
105*91f16700Schasinglulu #define BOOT_API_ECDSA_SIGNATURE_LEN_IN_BYTES			64
106*91f16700Schasinglulu #define BOOT_API_SHA256_DIGEST_SIZE_IN_BYTES			32
107*91f16700Schasinglulu 
108*91f16700Schasinglulu /* Possible values of the field 'boot_api_image_header_t.ecc_algo_type' */
109*91f16700Schasinglulu #define BOOT_API_ECDSA_ALGO_TYPE_P256NIST			1
110*91f16700Schasinglulu #define BOOT_API_ECDSA_ALGO_TYPE_BRAINPOOL256			2
111*91f16700Schasinglulu 
112*91f16700Schasinglulu /*
113*91f16700Schasinglulu  * Extension headers related definitions
114*91f16700Schasinglulu  */
115*91f16700Schasinglulu /* 'bootapi_image_header_t.extension_flag' used for authentication feature */
116*91f16700Schasinglulu #define BOOT_API_AUTHENTICATION_EXTENSION_BIT			BIT(0)
117*91f16700Schasinglulu /* 'bootapi_image_header_t.extension_flag' used for FSBL decryption feature */
118*91f16700Schasinglulu #define BOOT_API_FSBL_DECRYPTION_EXTENSION_BIT			BIT(1)
119*91f16700Schasinglulu /* 'bootapi_image_header_t.extension_flag' used for padding header feature */
120*91f16700Schasinglulu #define BOOT_API_PADDING_EXTENSION_BIT				BIT(31)
121*91f16700Schasinglulu /*
122*91f16700Schasinglulu  * mask of bits of field 'bootapi_image_header_t.extension_flag'
123*91f16700Schasinglulu  * used for extension headers
124*91f16700Schasinglulu  */
125*91f16700Schasinglulu #define BOOT_API_ALL_EXTENSIONS_MASK \
126*91f16700Schasinglulu 	(BOOT_API_AUTHENTICATION_EXTENSION_BIT | \
127*91f16700Schasinglulu 	 BOOT_API_FSBL_DECRYPTION_EXTENSION_BIT | \
128*91f16700Schasinglulu 	 BOOT_API_PADDING_EXTENSION_BIT)
129*91f16700Schasinglulu /*
130*91f16700Schasinglulu  * Magic number of FSBL decryption extension header
131*91f16700Schasinglulu  * The value shall gives the four bytes 'S','T',0x00,0x01 in memory
132*91f16700Schasinglulu  */
133*91f16700Schasinglulu #define BOOT_API_FSBL_DECRYPTION_HEADER_MAGIC_NB		0x01005453U
134*91f16700Schasinglulu 
135*91f16700Schasinglulu /*
136*91f16700Schasinglulu  * Magic number of PKH revocation extension header
137*91f16700Schasinglulu  * The value shall gives the four bytes 'S','T',0x00,0x02 in memory
138*91f16700Schasinglulu  */
139*91f16700Schasinglulu #define BOOT_API_AUTHENTICATION_HEADER_MAGIC_NB			0x02005453U
140*91f16700Schasinglulu 
141*91f16700Schasinglulu /* Max number of ECDSA public key hash in table */
142*91f16700Schasinglulu #define BOOT_API_AUTHENTICATION_NB_PKH_MAX			8U
143*91f16700Schasinglulu 
144*91f16700Schasinglulu /* ECDSA public key hash table size in bytes */
145*91f16700Schasinglulu #define BOOT_API_AUTHENTICATION_TABLE_SIZE_BYTES \
146*91f16700Schasinglulu 	(BOOT_API_AUTHENTICATION_NB_PKH_MAX * \
147*91f16700Schasinglulu 	 BOOT_API_SHA256_DIGEST_SIZE_IN_BYTES)
148*91f16700Schasinglulu 
149*91f16700Schasinglulu /*
150*91f16700Schasinglulu  * Magic number of padding extension header
151*91f16700Schasinglulu  * The value shall gives the four bytes 'S','T',0xFF,0xFF in memory
152*91f16700Schasinglulu  */
153*91f16700Schasinglulu #define BOOT_API_PADDING_HEADER_MAGIC_NB			0xFFFF5453U
154*91f16700Schasinglulu 
155*91f16700Schasinglulu /*
156*91f16700Schasinglulu  * Cores secure magic numbers
157*91f16700Schasinglulu  * Constant to be stored in bakcup register
158*91f16700Schasinglulu  * BOOT_API_MAGIC_NUMBER_TAMP_BCK_REG_IDX
159*91f16700Schasinglulu  */
160*91f16700Schasinglulu #define BOOT_API_A7_CORE0_MAGIC_NUMBER				0xCA7FACE0U
161*91f16700Schasinglulu #define BOOT_API_A7_CORE1_MAGIC_NUMBER				0xCA7FACE1U
162*91f16700Schasinglulu 
163*91f16700Schasinglulu /*
164*91f16700Schasinglulu  * TAMP_BCK4R register index
165*91f16700Schasinglulu  * This register is used to write a Magic Number in order to restart
166*91f16700Schasinglulu  * Cortex A7 Core 1 and make it execute @ branch address from TAMP_BCK5R
167*91f16700Schasinglulu  */
168*91f16700Schasinglulu #define BOOT_API_CORE1_MAGIC_NUMBER_TAMP_BCK_REG_IDX		4U
169*91f16700Schasinglulu 
170*91f16700Schasinglulu /*
171*91f16700Schasinglulu  * TAMP_BCK5R register index
172*91f16700Schasinglulu  * This register is used to contain the branch address of
173*91f16700Schasinglulu  * Cortex A7 Core 1 when restarted by a TAMP_BCK4R magic number writing
174*91f16700Schasinglulu  */
175*91f16700Schasinglulu #define BOOT_API_CORE1_BRANCH_ADDRESS_TAMP_BCK_REG_IDX		5U
176*91f16700Schasinglulu 
177*91f16700Schasinglulu /*
178*91f16700Schasinglulu  * Possible value of boot context field 'hse_clock_value_in_hz'
179*91f16700Schasinglulu  */
180*91f16700Schasinglulu #define BOOT_API_CTX_HSE_CLOCK_VALUE_UNDEFINED			0U
181*91f16700Schasinglulu #define BOOT_API_CTX_HSE_CLOCK_VALUE_24_MHZ			24000000U
182*91f16700Schasinglulu #define BOOT_API_CTX_HSE_CLOCK_VALUE_25_MHZ			25000000U
183*91f16700Schasinglulu #define BOOT_API_CTX_HSE_CLOCK_VALUE_26_MHZ			26000000U
184*91f16700Schasinglulu 
185*91f16700Schasinglulu /*
186*91f16700Schasinglulu  * Possible value of boot context field 'boot_partition_used_toboot'
187*91f16700Schasinglulu  */
188*91f16700Schasinglulu #define BOOT_API_CTX_BOOT_PARTITION_UNDEFINED			0U
189*91f16700Schasinglulu 
190*91f16700Schasinglulu /* Used FSBL1 to boot */
191*91f16700Schasinglulu #define BOOT_API_CTX_BOOT_PARTITION_FSBL1			1U
192*91f16700Schasinglulu 
193*91f16700Schasinglulu /* Used FSBL2 to boot */
194*91f16700Schasinglulu #define BOOT_API_CTX_BOOT_PARTITION_FSBL2			2U
195*91f16700Schasinglulu 
196*91f16700Schasinglulu /* OTP_CFG0 */
197*91f16700Schasinglulu #define BOOT_API_OTP_MODE_WORD_NB				0
198*91f16700Schasinglulu /* Closed = OTP_CFG0[6] */
199*91f16700Schasinglulu #define BOOT_API_OTP_MODE_CLOSED_BIT_POS			6
200*91f16700Schasinglulu 
201*91f16700Schasinglulu #define BOOT_API_RETURN_OK					0x77U
202*91f16700Schasinglulu 
203*91f16700Schasinglulu /*
204*91f16700Schasinglulu  * Boot Context related definitions
205*91f16700Schasinglulu  */
206*91f16700Schasinglulu 
207*91f16700Schasinglulu /*
208*91f16700Schasinglulu  * Boot core boot configuration structure
209*91f16700Schasinglulu  * Specifies all items of the cold boot configuration
210*91f16700Schasinglulu  * Memory and peripheral part.
211*91f16700Schasinglulu  */
212*91f16700Schasinglulu typedef struct {
213*91f16700Schasinglulu 	/*
214*91f16700Schasinglulu 	 * Boot interface used to boot : take values from defines
215*91f16700Schasinglulu 	 * BOOT_API_CTX_BOOT_INTERFACE_SEL_XXX above
216*91f16700Schasinglulu 	 */
217*91f16700Schasinglulu 	uint16_t boot_interface_selected;
218*91f16700Schasinglulu 	uint16_t boot_interface_instance;
219*91f16700Schasinglulu #if STM32MP13
220*91f16700Schasinglulu 	uint32_t reserved1[12];
221*91f16700Schasinglulu #endif
222*91f16700Schasinglulu #if STM32MP15
223*91f16700Schasinglulu 	uint32_t reserved1[13];
224*91f16700Schasinglulu #endif
225*91f16700Schasinglulu 	uint32_t otp_afmux_values[3];
226*91f16700Schasinglulu 	uint32_t reserved[3];
227*91f16700Schasinglulu #if STM32MP15
228*91f16700Schasinglulu 	uint32_t reserved2[2];
229*91f16700Schasinglulu #endif
230*91f16700Schasinglulu 	uint32_t auth_status;
231*91f16700Schasinglulu 
232*91f16700Schasinglulu #if STM32MP15
233*91f16700Schasinglulu 	/*
234*91f16700Schasinglulu 	 * Pointers to bootROM External Secure Services
235*91f16700Schasinglulu 	 * - ECDSA verify signature
236*91f16700Schasinglulu 	 */
237*91f16700Schasinglulu 	uint32_t reserved3;
238*91f16700Schasinglulu 	uint32_t (*bootrom_ecdsa_verify_signature)(uint8_t *hash_in,
239*91f16700Schasinglulu 						   uint8_t *pubkey_in,
240*91f16700Schasinglulu 						   uint8_t *signature,
241*91f16700Schasinglulu 						   uint32_t ecc_algo);
242*91f16700Schasinglulu 	uint32_t reserved4;
243*91f16700Schasinglulu #endif
244*91f16700Schasinglulu 	/*
245*91f16700Schasinglulu 	 * Information specific to an SD boot
246*91f16700Schasinglulu 	 * Updated each time an SD boot is at least attempted,
247*91f16700Schasinglulu 	 * even if not successful
248*91f16700Schasinglulu 	 * Note : This is useful to understand why an SD boot failed
249*91f16700Schasinglulu 	 * in particular
250*91f16700Schasinglulu 	 */
251*91f16700Schasinglulu 	uint32_t sd_err_internal_timeout_cnt;
252*91f16700Schasinglulu 	uint32_t sd_err_dcrc_fail_cnt;
253*91f16700Schasinglulu 	uint32_t sd_err_dtimeout_cnt;
254*91f16700Schasinglulu 	uint32_t sd_err_ctimeout_cnt;
255*91f16700Schasinglulu 	uint32_t sd_err_ccrc_fail_cnt;
256*91f16700Schasinglulu 	uint32_t sd_overall_retry_cnt;
257*91f16700Schasinglulu 	/*
258*91f16700Schasinglulu 	 * Information specific to an eMMC boot
259*91f16700Schasinglulu 	 * Updated each time an eMMC boot is at least attempted,
260*91f16700Schasinglulu 	 * even if not successful
261*91f16700Schasinglulu 	 * Note : This is useful to understand why an eMMC boot failed
262*91f16700Schasinglulu 	 * in particular
263*91f16700Schasinglulu 	 */
264*91f16700Schasinglulu 	uint32_t emmc_xfer_status;
265*91f16700Schasinglulu 	uint32_t emmc_error_status;
266*91f16700Schasinglulu 	uint32_t emmc_nbbytes_rxcopied_tosysram_download_area;
267*91f16700Schasinglulu 	uint32_t hse_clock_value_in_hz;
268*91f16700Schasinglulu 	/*
269*91f16700Schasinglulu 	 * Boot partition :
270*91f16700Schasinglulu 	 * ie FSBL partition on which the boot was successful
271*91f16700Schasinglulu 	 */
272*91f16700Schasinglulu 	uint32_t boot_partition_used_toboot;
273*91f16700Schasinglulu 
274*91f16700Schasinglulu } __packed boot_api_context_t;
275*91f16700Schasinglulu 
276*91f16700Schasinglulu /*
277*91f16700Schasinglulu  * Image Header related definitions
278*91f16700Schasinglulu  */
279*91f16700Schasinglulu 
280*91f16700Schasinglulu /*
281*91f16700Schasinglulu  * Structure used to define the common Header format used for FSBL, xloader,
282*91f16700Schasinglulu  * ... and in particular used by bootROM for FSBL header readout.
283*91f16700Schasinglulu  * FSBL header size is 256 Bytes = 0x100
284*91f16700Schasinglulu  */
285*91f16700Schasinglulu typedef struct {
286*91f16700Schasinglulu 	/* BOOT_API_IMAGE_HEADER_MAGIC_NB */
287*91f16700Schasinglulu 	uint32_t magic;
288*91f16700Schasinglulu 	uint8_t image_signature[BOOT_API_ECDSA_SIGNATURE_LEN_IN_BYTES];
289*91f16700Schasinglulu 	/*
290*91f16700Schasinglulu 	 * Checksum of payload
291*91f16700Schasinglulu 	 * 32-bit sum all payload bytes considered as 8 bit unsigned
292*91f16700Schasinglulu 	 * numbers, discarding any overflow bits.
293*91f16700Schasinglulu 	 * Use to check UART/USB downloaded image integrity when signature
294*91f16700Schasinglulu 	 * is not used
295*91f16700Schasinglulu 	 */
296*91f16700Schasinglulu 	uint32_t payload_checksum;
297*91f16700Schasinglulu 	/* Image header version : should have value BOOT_API_HEADER_VERSION */
298*91f16700Schasinglulu 	uint32_t header_version;
299*91f16700Schasinglulu 	/* Image length in bytes */
300*91f16700Schasinglulu 	uint32_t image_length;
301*91f16700Schasinglulu 	/*
302*91f16700Schasinglulu 	 * Image Entry point address : should be in the SYSRAM area
303*91f16700Schasinglulu 	 * and at least within the download area range
304*91f16700Schasinglulu 	 */
305*91f16700Schasinglulu 	uint32_t image_entry_point;
306*91f16700Schasinglulu 	/* Reserved */
307*91f16700Schasinglulu 	uint32_t reserved1;
308*91f16700Schasinglulu 	/*
309*91f16700Schasinglulu 	 * Image load address : not used by bootROM but to be consistent
310*91f16700Schasinglulu 	 * with header format for other packages (xloader, ...)
311*91f16700Schasinglulu 	 */
312*91f16700Schasinglulu 	uint32_t load_address;
313*91f16700Schasinglulu 	/* Reserved */
314*91f16700Schasinglulu 	uint32_t reserved2;
315*91f16700Schasinglulu 	/* Image version to be compared by bootROM with monotonic
316*91f16700Schasinglulu 	 * counter value in OTP_CFG4 prior executing the downloaded image
317*91f16700Schasinglulu 	 */
318*91f16700Schasinglulu 	uint32_t image_version;
319*91f16700Schasinglulu 
320*91f16700Schasinglulu #if STM32MP13
321*91f16700Schasinglulu 	/*
322*91f16700Schasinglulu 	 * Extension flags :
323*91f16700Schasinglulu 	 *
324*91f16700Schasinglulu 	 * Bit 0 : Authentication extension header
325*91f16700Schasinglulu 	 *      value 0 : No signature check request
326*91f16700Schasinglulu 	 * Bit 1 : Encryption extension header
327*91f16700Schasinglulu 	 * Bit 2 : Padding extension header
328*91f16700Schasinglulu 	 */
329*91f16700Schasinglulu 	uint32_t extension_flags;
330*91f16700Schasinglulu 	/* Length in bytes of all extension headers */
331*91f16700Schasinglulu 	uint32_t extension_headers_length;
332*91f16700Schasinglulu 	/* Add binary type information */
333*91f16700Schasinglulu 	uint32_t binary_type;
334*91f16700Schasinglulu 	/* Pad up to 128 byte total size */
335*91f16700Schasinglulu 	uint8_t pad[16];
336*91f16700Schasinglulu 	/* Followed by extension header */
337*91f16700Schasinglulu 	uint8_t ext_header[];
338*91f16700Schasinglulu #endif
339*91f16700Schasinglulu #if STM32MP15
340*91f16700Schasinglulu 	/*
341*91f16700Schasinglulu 	 * Option flags:
342*91f16700Schasinglulu 	 * Bit 0 : No signature check request : 'No_sig_check'
343*91f16700Schasinglulu 	 *      value 1 : for No signature check request
344*91f16700Schasinglulu 	 *      value 0 : No request to bypass the signature check
345*91f16700Schasinglulu 	 * Note : No signature check is never allowed on a Secured chip
346*91f16700Schasinglulu 	 */
347*91f16700Schasinglulu 	uint32_t option_flags;
348*91f16700Schasinglulu 	/*
349*91f16700Schasinglulu 	 * Type of ECC algorithm to use  :
350*91f16700Schasinglulu 	 * value 1 : for P-256 NIST algorithm
351*91f16700Schasinglulu 	 * value 2 : for Brainpool 256 algorithm
352*91f16700Schasinglulu 	 * See definitions 'BOOT_API_ECDSA_ALGO_TYPE_XXX' above.
353*91f16700Schasinglulu 	 */
354*91f16700Schasinglulu 	uint32_t ecc_algo_type;
355*91f16700Schasinglulu 	/*
356*91f16700Schasinglulu 	 * OEM ECC Public Key (aka Root pubk) provided in header on 512 bits.
357*91f16700Schasinglulu 	 * The SHA-256 hash of the OEM ECC pubk must match the one stored
358*91f16700Schasinglulu 	 * in OTP cells.
359*91f16700Schasinglulu 	 */
360*91f16700Schasinglulu 	uint8_t ecc_pubk[BOOT_API_ECDSA_PUB_KEY_LEN_IN_BYTES];
361*91f16700Schasinglulu 	/* Pad up to 256 byte total size */
362*91f16700Schasinglulu 	uint8_t pad[83];
363*91f16700Schasinglulu 	/* Add binary type information */
364*91f16700Schasinglulu 	uint8_t binary_type;
365*91f16700Schasinglulu #endif
366*91f16700Schasinglulu } __packed boot_api_image_header_t;
367*91f16700Schasinglulu 
368*91f16700Schasinglulu typedef uint8_t boot_api_sha256_t[BOOT_API_SHA256_DIGEST_SIZE_IN_BYTES];
369*91f16700Schasinglulu 
370*91f16700Schasinglulu typedef struct {
371*91f16700Schasinglulu 	/* Extension header type:
372*91f16700Schasinglulu 	 * BOOT_API_FSBL_DECRYPTION_HEADER_MAGIC_NB or
373*91f16700Schasinglulu 	 * BOOT_API_AUTHENTICATION_HEADER_MAGIC_NB
374*91f16700Schasinglulu 	 * BOOT_API_PADDING_HEADER_MAGIC_NB
375*91f16700Schasinglulu 	 */
376*91f16700Schasinglulu 	uint32_t type;
377*91f16700Schasinglulu 	/* Extension header len in byte */
378*91f16700Schasinglulu 	uint32_t len;
379*91f16700Schasinglulu 	/* parameters of this extension */
380*91f16700Schasinglulu 	uint8_t  params[];
381*91f16700Schasinglulu } __packed boot_extension_header_t;
382*91f16700Schasinglulu 
383*91f16700Schasinglulu typedef struct {
384*91f16700Schasinglulu 	/* Idx of ECDSA public key to be used in table */
385*91f16700Schasinglulu 	uint32_t pk_idx;
386*91f16700Schasinglulu 	/* Number of ECDSA public key in table */
387*91f16700Schasinglulu 	uint32_t nb_pk;
388*91f16700Schasinglulu 	/*
389*91f16700Schasinglulu 	 * Type of ECC algorithm to use  :
390*91f16700Schasinglulu 	 * value 1 : for P-256 NIST algorithm
391*91f16700Schasinglulu 	 * value 2 : for Brainpool 256 algorithm
392*91f16700Schasinglulu 	 * See definitions 'BOOT_API_ECDSA_ALGO_TYPE_XXX' above.
393*91f16700Schasinglulu 	 */
394*91f16700Schasinglulu 	uint32_t ecc_algo_type;
395*91f16700Schasinglulu 	/* ECDSA public key to be used to check signature. */
396*91f16700Schasinglulu 	uint8_t ecc_pubk[BOOT_API_ECDSA_PUB_KEY_LEN_IN_BYTES];
397*91f16700Schasinglulu 	/* table of Hash of Algo+ECDSA public key */
398*91f16700Schasinglulu 	boot_api_sha256_t pk_hashes[];
399*91f16700Schasinglulu } __packed boot_ext_header_params_authentication_t;
400*91f16700Schasinglulu 
401*91f16700Schasinglulu typedef struct {
402*91f16700Schasinglulu 	/* Size of encryption key (128 or 256) */
403*91f16700Schasinglulu 	uint32_t key_size;
404*91f16700Schasinglulu 	uint32_t derivation_cont;
405*91f16700Schasinglulu 	/* 128 msb bits of plain payload SHA256 */
406*91f16700Schasinglulu 	uint32_t hash[4];
407*91f16700Schasinglulu } __packed boot_ext_header_params_encrypted_fsbl_t;
408*91f16700Schasinglulu 
409*91f16700Schasinglulu #endif /* BOOT_API_H */
410