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