14353bb20SYann Gautier /* 2*b0ce4024SYann Gautier * Copyright (c) 2017-2023, STMicroelectronics - All Rights Reserved 34353bb20SYann Gautier * 44353bb20SYann Gautier * SPDX-License-Identifier: BSD-3-Clause 54353bb20SYann Gautier */ 64353bb20SYann Gautier 7c3cf06f1SAntonio Nino Diaz #ifndef BOOT_API_H 8c3cf06f1SAntonio Nino Diaz #define BOOT_API_H 94353bb20SYann Gautier 104353bb20SYann Gautier #include <stdint.h> 11aec7de41SYann Gautier #include <stdio.h> 124353bb20SYann Gautier 134353bb20SYann Gautier /* 144bdb1a7aSLionel Debieve * Possible value of boot context field 'auth_status' 154bdb1a7aSLionel Debieve */ 165f52eb15SLionel Debieve #if STM32MP13 175f52eb15SLionel Debieve /* No authentication done */ 185f52eb15SLionel Debieve #define BOOT_API_CTX_AUTH_NO 0x7CFDD351U 195f52eb15SLionel Debieve /* Authentication done and failed */ 205f52eb15SLionel Debieve #define BOOT_API_CTX_AUTH_FAILED 0x51330884U 215f52eb15SLionel Debieve /* Authentication done and success */ 225f52eb15SLionel Debieve #define BOOT_API_CTX_AUTH_SUCCESS 0x67E8CAE1U 235f52eb15SLionel Debieve #endif 245f52eb15SLionel Debieve #if STM32MP15 254bdb1a7aSLionel Debieve /* No authentication done */ 264bdb1a7aSLionel Debieve #define BOOT_API_CTX_AUTH_NO 0x0U 274bdb1a7aSLionel Debieve /* Authentication done and failed */ 284bdb1a7aSLionel Debieve #define BOOT_API_CTX_AUTH_FAILED 0x1U 294bdb1a7aSLionel Debieve /* Authentication done and succeeded */ 304bdb1a7aSLionel Debieve #define BOOT_API_CTX_AUTH_SUCCESS 0x2U 315f52eb15SLionel Debieve #endif 324bdb1a7aSLionel Debieve 334bdb1a7aSLionel Debieve /* 344353bb20SYann Gautier * Possible value of boot context field 'boot_interface_sel' 354353bb20SYann Gautier */ 364353bb20SYann Gautier 374353bb20SYann Gautier /* Value of field 'boot_interface_sel' when no boot occurred */ 384353bb20SYann Gautier #define BOOT_API_CTX_BOOT_INTERFACE_SEL_NO 0x0U 394353bb20SYann Gautier 404353bb20SYann Gautier /* Boot occurred on SD */ 414353bb20SYann Gautier #define BOOT_API_CTX_BOOT_INTERFACE_SEL_FLASH_SD 0x1U 424353bb20SYann Gautier 434353bb20SYann Gautier /* Boot occurred on EMMC */ 444353bb20SYann Gautier #define BOOT_API_CTX_BOOT_INTERFACE_SEL_FLASH_EMMC 0x2U 454353bb20SYann Gautier 4612e21dfdSLionel Debieve /* Boot occurred on FMC */ 4712e21dfdSLionel Debieve #define BOOT_API_CTX_BOOT_INTERFACE_SEL_FLASH_NAND_FMC 0x3U 4812e21dfdSLionel Debieve 49b1b218fbSLionel Debieve /* Boot occurred on QSPI NOR */ 50*b0ce4024SYann Gautier #define BOOT_API_CTX_BOOT_INTERFACE_SEL_FLASH_NOR_SPI 0x4U 51b1b218fbSLionel Debieve 529083fa11SPatrick Delaunay /* Boot occurred on UART */ 539083fa11SPatrick Delaunay #define BOOT_API_CTX_BOOT_INTERFACE_SEL_SERIAL_UART 0x5U 549083fa11SPatrick Delaunay 55fa92fef0SPatrick Delaunay /* Boot occurred on USB */ 56fa92fef0SPatrick Delaunay #define BOOT_API_CTX_BOOT_INTERFACE_SEL_SERIAL_USB 0x6U 57fa92fef0SPatrick Delaunay 5857044228SLionel Debieve /* Boot occurred on QSPI NAND */ 59*b0ce4024SYann Gautier #define BOOT_API_CTX_BOOT_INTERFACE_SEL_FLASH_NAND_SPI 0x7U 6057044228SLionel Debieve 614353bb20SYann Gautier /** 624353bb20SYann Gautier * @brief Possible value of boot context field 'EmmcXferStatus' 634353bb20SYann Gautier */ 644353bb20SYann Gautier /* 654353bb20SYann Gautier * Possible value of boot context field 'emmc_xfer_status' 664353bb20SYann Gautier */ 674353bb20SYann Gautier #define BOOT_API_CTX_EMMC_XFER_STATUS_NOT_STARTED 0x0U 684353bb20SYann Gautier #define BOOT_API_CTX_EMMC_XFER_STATUS_DATAEND_DETECTED 0x1U 694353bb20SYann Gautier #define BOOT_API_CTX_EMMC_XFER_STATUS_XFER_OVERALL_TIMEOUT_DETECTED 0x2U 704353bb20SYann Gautier #define BOOT_API_CTX_EMMC_XFER_STATUS_XFER_DATA_TIMEOUT 0x3U 714353bb20SYann Gautier 724353bb20SYann Gautier /* 734353bb20SYann Gautier * Possible value of boot context field 'emmc_error_status' 744353bb20SYann Gautier */ 754353bb20SYann Gautier #define BOOT_API_CTX_EMMC_ERROR_STATUS_NONE 0x0U 764353bb20SYann Gautier #define BOOT_API_CTX_EMMC_ERROR_STATUS_CMD_TIMEOUT 0x1U 774353bb20SYann Gautier #define BOOT_API_CTX_EMMC_ERROR_STATUS_ACK_TIMEOUT 0x2U 784353bb20SYann Gautier #define BOOT_API_CTX_EMMC_ERROR_STATUS_DATA_CRC_FAIL 0x3U 794353bb20SYann Gautier #define BOOT_API_CTX_EMMC_ERROR_STATUS_NOT_ENOUGH_BOOT_DATA_RX 0x4U 804353bb20SYann Gautier #define BOOT_API_CTX_EMMC_ERROR_STATUS_HEADER_NOT_FOUND 0x5U 814353bb20SYann Gautier #define BOOT_API_CTX_EMMC_ERROR_STATUS_HEADER_SIZE_ZERO 0x6U 824353bb20SYann Gautier #define BOOT_API_CTX_EMMC_ERROR_STATUS_IMAGE_NOT_COMPLETE 0x7U 835f52eb15SLionel Debieve #define BOOT_API_CTX_EMMC_ERROR_STATUS_ACK_ERROR 0x8U 844353bb20SYann Gautier 854353bb20SYann Gautier /* Image Header related definitions */ 864353bb20SYann Gautier 874353bb20SYann Gautier /* Definition of header version */ 885f52eb15SLionel Debieve #if STM32MP13 895f52eb15SLionel Debieve #define BOOT_API_HEADER_VERSION 0x00020000U 905f52eb15SLionel Debieve #endif 915f52eb15SLionel Debieve #if STM32MP15 924353bb20SYann Gautier #define BOOT_API_HEADER_VERSION 0x00010000U 935f52eb15SLionel Debieve #endif 944353bb20SYann Gautier 954353bb20SYann Gautier /* 964353bb20SYann Gautier * Magic number used to detect header in memory 974353bb20SYann Gautier * Its value must be 'S' 'T' 'M' 0x32, i.e 0x324D5453 as field 984353bb20SYann Gautier * 'bootapi_image_header_t.magic' 994353bb20SYann Gautier * This identifies the start of a boot image. 1004353bb20SYann Gautier */ 1014353bb20SYann Gautier #define BOOT_API_IMAGE_HEADER_MAGIC_NB 0x324D5453U 1024353bb20SYann Gautier 1034353bb20SYann Gautier /* Definitions related to Authentication used in image header structure */ 1044353bb20SYann Gautier #define BOOT_API_ECDSA_PUB_KEY_LEN_IN_BYTES 64 1054353bb20SYann Gautier #define BOOT_API_ECDSA_SIGNATURE_LEN_IN_BYTES 64 1064353bb20SYann Gautier #define BOOT_API_SHA256_DIGEST_SIZE_IN_BYTES 32 1074353bb20SYann Gautier 1084353bb20SYann Gautier /* Possible values of the field 'boot_api_image_header_t.ecc_algo_type' */ 1094353bb20SYann Gautier #define BOOT_API_ECDSA_ALGO_TYPE_P256NIST 1 1104353bb20SYann Gautier #define BOOT_API_ECDSA_ALGO_TYPE_BRAINPOOL256 2 1114353bb20SYann Gautier 1124353bb20SYann Gautier /* 1135f52eb15SLionel Debieve * Extension headers related definitions 1145f52eb15SLionel Debieve */ 1155f52eb15SLionel Debieve /* 'bootapi_image_header_t.extension_flag' used for authentication feature */ 1165f52eb15SLionel Debieve #define BOOT_API_AUTHENTICATION_EXTENSION_BIT BIT(0) 1175f52eb15SLionel Debieve /* 'bootapi_image_header_t.extension_flag' used for FSBL decryption feature */ 1185f52eb15SLionel Debieve #define BOOT_API_FSBL_DECRYPTION_EXTENSION_BIT BIT(1) 1195f52eb15SLionel Debieve /* 'bootapi_image_header_t.extension_flag' used for padding header feature */ 1205f52eb15SLionel Debieve #define BOOT_API_PADDING_EXTENSION_BIT BIT(31) 1215f52eb15SLionel Debieve /* 1225f52eb15SLionel Debieve * mask of bits of field 'bootapi_image_header_t.extension_flag' 1235f52eb15SLionel Debieve * used for extension headers 1245f52eb15SLionel Debieve */ 1255f52eb15SLionel Debieve #define BOOT_API_ALL_EXTENSIONS_MASK \ 1265f52eb15SLionel Debieve (BOOT_API_AUTHENTICATION_EXTENSION_BIT | \ 1275f52eb15SLionel Debieve BOOT_API_FSBL_DECRYPTION_EXTENSION_BIT | \ 1285f52eb15SLionel Debieve BOOT_API_PADDING_EXTENSION_BIT) 1295f52eb15SLionel Debieve /* 1305f52eb15SLionel Debieve * Magic number of FSBL decryption extension header 1315f52eb15SLionel Debieve * The value shall gives the four bytes 'S','T',0x00,0x01 in memory 1325f52eb15SLionel Debieve */ 1335f52eb15SLionel Debieve #define BOOT_API_FSBL_DECRYPTION_HEADER_MAGIC_NB 0x01005453U 1345f52eb15SLionel Debieve 1355f52eb15SLionel Debieve /* 1365f52eb15SLionel Debieve * Magic number of PKH revocation extension header 1375f52eb15SLionel Debieve * The value shall gives the four bytes 'S','T',0x00,0x02 in memory 1385f52eb15SLionel Debieve */ 1395f52eb15SLionel Debieve #define BOOT_API_AUTHENTICATION_HEADER_MAGIC_NB 0x02005453U 1405f52eb15SLionel Debieve 1415f52eb15SLionel Debieve /* Max number of ECDSA public key hash in table */ 1425f52eb15SLionel Debieve #define BOOT_API_AUTHENTICATION_NB_PKH_MAX 8U 1435f52eb15SLionel Debieve 1445f52eb15SLionel Debieve /* ECDSA public key hash table size in bytes */ 1455f52eb15SLionel Debieve #define BOOT_API_AUTHENTICATION_TABLE_SIZE_BYTES \ 1465f52eb15SLionel Debieve (BOOT_API_AUTHENTICATION_NB_PKH_MAX * \ 1475f52eb15SLionel Debieve BOOT_API_SHA256_DIGEST_SIZE_IN_BYTES) 1485f52eb15SLionel Debieve 1495f52eb15SLionel Debieve /* 1505f52eb15SLionel Debieve * Magic number of padding extension header 1515f52eb15SLionel Debieve * The value shall gives the four bytes 'S','T',0xFF,0xFF in memory 1525f52eb15SLionel Debieve */ 1535f52eb15SLionel Debieve #define BOOT_API_PADDING_HEADER_MAGIC_NB 0xFFFF5453U 1545f52eb15SLionel Debieve 1555f52eb15SLionel Debieve /* 1564353bb20SYann Gautier * Cores secure magic numbers 1574353bb20SYann Gautier * Constant to be stored in bakcup register 1584353bb20SYann Gautier * BOOT_API_MAGIC_NUMBER_TAMP_BCK_REG_IDX 1594353bb20SYann Gautier */ 1604353bb20SYann Gautier #define BOOT_API_A7_CORE0_MAGIC_NUMBER 0xCA7FACE0U 1614353bb20SYann Gautier #define BOOT_API_A7_CORE1_MAGIC_NUMBER 0xCA7FACE1U 1624353bb20SYann Gautier 1634353bb20SYann Gautier /* 1644353bb20SYann Gautier * TAMP_BCK4R register index 1654353bb20SYann Gautier * This register is used to write a Magic Number in order to restart 1664353bb20SYann Gautier * Cortex A7 Core 1 and make it execute @ branch address from TAMP_BCK5R 1674353bb20SYann Gautier */ 1684353bb20SYann Gautier #define BOOT_API_CORE1_MAGIC_NUMBER_TAMP_BCK_REG_IDX 4U 1694353bb20SYann Gautier 1704353bb20SYann Gautier /* 1714353bb20SYann Gautier * TAMP_BCK5R register index 1724353bb20SYann Gautier * This register is used to contain the branch address of 1734353bb20SYann Gautier * Cortex A7 Core 1 when restarted by a TAMP_BCK4R magic number writing 1744353bb20SYann Gautier */ 1754353bb20SYann Gautier #define BOOT_API_CORE1_BRANCH_ADDRESS_TAMP_BCK_REG_IDX 5U 1764353bb20SYann Gautier 1774353bb20SYann Gautier /* 1784353bb20SYann Gautier * Possible value of boot context field 'hse_clock_value_in_hz' 1794353bb20SYann Gautier */ 1804353bb20SYann Gautier #define BOOT_API_CTX_HSE_CLOCK_VALUE_UNDEFINED 0U 1814353bb20SYann Gautier #define BOOT_API_CTX_HSE_CLOCK_VALUE_24_MHZ 24000000U 1824353bb20SYann Gautier #define BOOT_API_CTX_HSE_CLOCK_VALUE_25_MHZ 25000000U 1834353bb20SYann Gautier #define BOOT_API_CTX_HSE_CLOCK_VALUE_26_MHZ 26000000U 1844353bb20SYann Gautier 1854353bb20SYann Gautier /* 1864353bb20SYann Gautier * Possible value of boot context field 'boot_partition_used_toboot' 1874353bb20SYann Gautier */ 1884353bb20SYann Gautier #define BOOT_API_CTX_BOOT_PARTITION_UNDEFINED 0U 1894353bb20SYann Gautier 1904353bb20SYann Gautier /* Used FSBL1 to boot */ 1914353bb20SYann Gautier #define BOOT_API_CTX_BOOT_PARTITION_FSBL1 1U 1924353bb20SYann Gautier 1934353bb20SYann Gautier /* Used FSBL2 to boot */ 1944353bb20SYann Gautier #define BOOT_API_CTX_BOOT_PARTITION_FSBL2 2U 1954353bb20SYann Gautier 1964353bb20SYann Gautier /* OTP_CFG0 */ 1974353bb20SYann Gautier #define BOOT_API_OTP_MODE_WORD_NB 0 1984353bb20SYann Gautier /* Closed = OTP_CFG0[6] */ 1994353bb20SYann Gautier #define BOOT_API_OTP_MODE_CLOSED_BIT_POS 6 2004353bb20SYann Gautier 201697d18aeSLionel Debieve #define BOOT_API_RETURN_OK 0x77U 2024bdb1a7aSLionel Debieve 2034353bb20SYann Gautier /* 2044353bb20SYann Gautier * Boot Context related definitions 2054353bb20SYann Gautier */ 2064353bb20SYann Gautier 2074353bb20SYann Gautier /* 2084353bb20SYann Gautier * Boot core boot configuration structure 2094353bb20SYann Gautier * Specifies all items of the cold boot configuration 2104353bb20SYann Gautier * Memory and peripheral part. 2114353bb20SYann Gautier */ 2124353bb20SYann Gautier typedef struct { 2134353bb20SYann Gautier /* 2144353bb20SYann Gautier * Boot interface used to boot : take values from defines 2154353bb20SYann Gautier * BOOT_API_CTX_BOOT_INTERFACE_SEL_XXX above 2164353bb20SYann Gautier */ 2174353bb20SYann Gautier uint16_t boot_interface_selected; 2184353bb20SYann Gautier uint16_t boot_interface_instance; 2195f52eb15SLionel Debieve #if STM32MP13 2205f52eb15SLionel Debieve uint32_t reserved1[12]; 2215f52eb15SLionel Debieve #endif 2225f52eb15SLionel Debieve #if STM32MP15 2234353bb20SYann Gautier uint32_t reserved1[13]; 2245f52eb15SLionel Debieve #endif 2254353bb20SYann Gautier uint32_t otp_afmux_values[3]; 2265f52eb15SLionel Debieve uint32_t reserved[3]; 2275f52eb15SLionel Debieve #if STM32MP15 2285f52eb15SLionel Debieve uint32_t reserved2[2]; 2295f52eb15SLionel Debieve #endif 2304bdb1a7aSLionel Debieve uint32_t auth_status; 2314bdb1a7aSLionel Debieve 2325f52eb15SLionel Debieve #if STM32MP15 2334bdb1a7aSLionel Debieve /* 2344bdb1a7aSLionel Debieve * Pointers to bootROM External Secure Services 2354bdb1a7aSLionel Debieve * - ECDSA verify signature 2364bdb1a7aSLionel Debieve */ 237f30034a2SLionel Debieve uint32_t reserved3; 2384bdb1a7aSLionel Debieve uint32_t (*bootrom_ecdsa_verify_signature)(uint8_t *hash_in, 2394bdb1a7aSLionel Debieve uint8_t *pubkey_in, 2404bdb1a7aSLionel Debieve uint8_t *signature, 2414bdb1a7aSLionel Debieve uint32_t ecc_algo); 242f30034a2SLionel Debieve uint32_t reserved4; 2435f52eb15SLionel Debieve #endif 2444353bb20SYann Gautier /* 2454353bb20SYann Gautier * Information specific to an SD boot 2464353bb20SYann Gautier * Updated each time an SD boot is at least attempted, 2474353bb20SYann Gautier * even if not successful 2484353bb20SYann Gautier * Note : This is useful to understand why an SD boot failed 2494353bb20SYann Gautier * in particular 2504353bb20SYann Gautier */ 2514353bb20SYann Gautier uint32_t sd_err_internal_timeout_cnt; 2524353bb20SYann Gautier uint32_t sd_err_dcrc_fail_cnt; 2534353bb20SYann Gautier uint32_t sd_err_dtimeout_cnt; 2544353bb20SYann Gautier uint32_t sd_err_ctimeout_cnt; 2554353bb20SYann Gautier uint32_t sd_err_ccrc_fail_cnt; 2564353bb20SYann Gautier uint32_t sd_overall_retry_cnt; 2574353bb20SYann Gautier /* 2584353bb20SYann Gautier * Information specific to an eMMC boot 2594353bb20SYann Gautier * Updated each time an eMMC boot is at least attempted, 2604353bb20SYann Gautier * even if not successful 2614353bb20SYann Gautier * Note : This is useful to understand why an eMMC boot failed 2624353bb20SYann Gautier * in particular 2634353bb20SYann Gautier */ 2644353bb20SYann Gautier uint32_t emmc_xfer_status; 2654353bb20SYann Gautier uint32_t emmc_error_status; 2664353bb20SYann Gautier uint32_t emmc_nbbytes_rxcopied_tosysram_download_area; 2674353bb20SYann Gautier uint32_t hse_clock_value_in_hz; 2684353bb20SYann Gautier /* 2694353bb20SYann Gautier * Boot partition : 2704353bb20SYann Gautier * ie FSBL partition on which the boot was successful 2714353bb20SYann Gautier */ 2724353bb20SYann Gautier uint32_t boot_partition_used_toboot; 2734353bb20SYann Gautier 2744353bb20SYann Gautier } __packed boot_api_context_t; 2754353bb20SYann Gautier 2764353bb20SYann Gautier /* 2774353bb20SYann Gautier * Image Header related definitions 2784353bb20SYann Gautier */ 2794353bb20SYann Gautier 2804353bb20SYann Gautier /* 2814353bb20SYann Gautier * Structure used to define the common Header format used for FSBL, xloader, 2824353bb20SYann Gautier * ... and in particular used by bootROM for FSBL header readout. 2834353bb20SYann Gautier * FSBL header size is 256 Bytes = 0x100 2844353bb20SYann Gautier */ 2854353bb20SYann Gautier typedef struct { 2864353bb20SYann Gautier /* BOOT_API_IMAGE_HEADER_MAGIC_NB */ 2874353bb20SYann Gautier uint32_t magic; 2884353bb20SYann Gautier uint8_t image_signature[BOOT_API_ECDSA_SIGNATURE_LEN_IN_BYTES]; 2894353bb20SYann Gautier /* 2904353bb20SYann Gautier * Checksum of payload 2915f52eb15SLionel Debieve * 32-bit sum all payload bytes considered as 8 bit unsigned 2925f52eb15SLionel Debieve * numbers, discarding any overflow bits. 2934353bb20SYann Gautier * Use to check UART/USB downloaded image integrity when signature 2945f52eb15SLionel Debieve * is not used 2954353bb20SYann Gautier */ 2964353bb20SYann Gautier uint32_t payload_checksum; 2974353bb20SYann Gautier /* Image header version : should have value BOOT_API_HEADER_VERSION */ 2984353bb20SYann Gautier uint32_t header_version; 2994353bb20SYann Gautier /* Image length in bytes */ 3004353bb20SYann Gautier uint32_t image_length; 3014353bb20SYann Gautier /* 3024353bb20SYann Gautier * Image Entry point address : should be in the SYSRAM area 3034353bb20SYann Gautier * and at least within the download area range 3044353bb20SYann Gautier */ 3054353bb20SYann Gautier uint32_t image_entry_point; 3064353bb20SYann Gautier /* Reserved */ 3074353bb20SYann Gautier uint32_t reserved1; 3084353bb20SYann Gautier /* 3094353bb20SYann Gautier * Image load address : not used by bootROM but to be consistent 3104353bb20SYann Gautier * with header format for other packages (xloader, ...) 3114353bb20SYann Gautier */ 3124353bb20SYann Gautier uint32_t load_address; 3134353bb20SYann Gautier /* Reserved */ 3144353bb20SYann Gautier uint32_t reserved2; 3154353bb20SYann Gautier /* Image version to be compared by bootROM with monotonic 3164353bb20SYann Gautier * counter value in OTP_CFG4 prior executing the downloaded image 3174353bb20SYann Gautier */ 3184353bb20SYann Gautier uint32_t image_version; 3195f52eb15SLionel Debieve 3205f52eb15SLionel Debieve #if STM32MP13 3215f52eb15SLionel Debieve /* 3225f52eb15SLionel Debieve * Extension flags : 3235f52eb15SLionel Debieve * 3245f52eb15SLionel Debieve * Bit 0 : Authentication extension header 3255f52eb15SLionel Debieve * value 0 : No signature check request 3265f52eb15SLionel Debieve * Bit 1 : Encryption extension header 3275f52eb15SLionel Debieve * Bit 2 : Padding extension header 3285f52eb15SLionel Debieve */ 3295f52eb15SLionel Debieve uint32_t extension_flags; 3305f52eb15SLionel Debieve /* Length in bytes of all extension headers */ 3315f52eb15SLionel Debieve uint32_t extension_headers_length; 3325f52eb15SLionel Debieve /* Add binary type information */ 3335f52eb15SLionel Debieve uint32_t binary_type; 3345f52eb15SLionel Debieve /* Pad up to 128 byte total size */ 3355f52eb15SLionel Debieve uint8_t pad[16]; 33689c07747SLionel Debieve /* Followed by extension header */ 33789c07747SLionel Debieve uint8_t ext_header[]; 3385f52eb15SLionel Debieve #endif 3395f52eb15SLionel Debieve #if STM32MP15 3404353bb20SYann Gautier /* 3414353bb20SYann Gautier * Option flags: 3424353bb20SYann Gautier * Bit 0 : No signature check request : 'No_sig_check' 3434353bb20SYann Gautier * value 1 : for No signature check request 3444353bb20SYann Gautier * value 0 : No request to bypass the signature check 3454353bb20SYann Gautier * Note : No signature check is never allowed on a Secured chip 3464353bb20SYann Gautier */ 3474353bb20SYann Gautier uint32_t option_flags; 3484353bb20SYann Gautier /* 3494353bb20SYann Gautier * Type of ECC algorithm to use : 3504353bb20SYann Gautier * value 1 : for P-256 NIST algorithm 3514353bb20SYann Gautier * value 2 : for Brainpool 256 algorithm 3524353bb20SYann Gautier * See definitions 'BOOT_API_ECDSA_ALGO_TYPE_XXX' above. 3534353bb20SYann Gautier */ 3544353bb20SYann Gautier uint32_t ecc_algo_type; 3554353bb20SYann Gautier /* 3564353bb20SYann Gautier * OEM ECC Public Key (aka Root pubk) provided in header on 512 bits. 3574353bb20SYann Gautier * The SHA-256 hash of the OEM ECC pubk must match the one stored 3584353bb20SYann Gautier * in OTP cells. 3594353bb20SYann Gautier */ 3604353bb20SYann Gautier uint8_t ecc_pubk[BOOT_API_ECDSA_PUB_KEY_LEN_IN_BYTES]; 3614353bb20SYann Gautier /* Pad up to 256 byte total size */ 362aec7de41SYann Gautier uint8_t pad[83]; 363aec7de41SYann Gautier /* Add binary type information */ 364aec7de41SYann Gautier uint8_t binary_type; 3655f52eb15SLionel Debieve #endif 3664353bb20SYann Gautier } __packed boot_api_image_header_t; 3674353bb20SYann Gautier 36889c07747SLionel Debieve typedef uint8_t boot_api_sha256_t[BOOT_API_SHA256_DIGEST_SIZE_IN_BYTES]; 36989c07747SLionel Debieve 37089c07747SLionel Debieve typedef struct { 37189c07747SLionel Debieve /* Extension header type: 37289c07747SLionel Debieve * BOOT_API_FSBL_DECRYPTION_HEADER_MAGIC_NB or 37389c07747SLionel Debieve * BOOT_API_AUTHENTICATION_HEADER_MAGIC_NB 37489c07747SLionel Debieve * BOOT_API_PADDING_HEADER_MAGIC_NB 37589c07747SLionel Debieve */ 37689c07747SLionel Debieve uint32_t type; 37789c07747SLionel Debieve /* Extension header len in byte */ 37889c07747SLionel Debieve uint32_t len; 37989c07747SLionel Debieve /* parameters of this extension */ 38089c07747SLionel Debieve uint8_t params[]; 38189c07747SLionel Debieve } __packed boot_extension_header_t; 38289c07747SLionel Debieve 38389c07747SLionel Debieve typedef struct { 38489c07747SLionel Debieve /* Idx of ECDSA public key to be used in table */ 38589c07747SLionel Debieve uint32_t pk_idx; 38689c07747SLionel Debieve /* Number of ECDSA public key in table */ 38789c07747SLionel Debieve uint32_t nb_pk; 38889c07747SLionel Debieve /* 38989c07747SLionel Debieve * Type of ECC algorithm to use : 39089c07747SLionel Debieve * value 1 : for P-256 NIST algorithm 39189c07747SLionel Debieve * value 2 : for Brainpool 256 algorithm 39289c07747SLionel Debieve * See definitions 'BOOT_API_ECDSA_ALGO_TYPE_XXX' above. 39389c07747SLionel Debieve */ 39489c07747SLionel Debieve uint32_t ecc_algo_type; 39589c07747SLionel Debieve /* ECDSA public key to be used to check signature. */ 39689c07747SLionel Debieve uint8_t ecc_pubk[BOOT_API_ECDSA_PUB_KEY_LEN_IN_BYTES]; 39789c07747SLionel Debieve /* table of Hash of Algo+ECDSA public key */ 39889c07747SLionel Debieve boot_api_sha256_t pk_hashes[]; 39989c07747SLionel Debieve } __packed boot_ext_header_params_authentication_t; 40089c07747SLionel Debieve 40189c07747SLionel Debieve typedef struct { 40289c07747SLionel Debieve /* Size of encryption key (128 or 256) */ 40389c07747SLionel Debieve uint32_t key_size; 40489c07747SLionel Debieve uint32_t derivation_cont; 40589c07747SLionel Debieve /* 128 msb bits of plain payload SHA256 */ 40689c07747SLionel Debieve uint32_t hash[4]; 40789c07747SLionel Debieve } __packed boot_ext_header_params_encrypted_fsbl_t; 40889c07747SLionel Debieve 409c3cf06f1SAntonio Nino Diaz #endif /* BOOT_API_H */ 410