135527fb4SYann Gautier /* 235527fb4SYann Gautier * Copyright (c) 2023, STMicroelectronics - All Rights Reserved 335527fb4SYann Gautier * 435527fb4SYann Gautier * SPDX-License-Identifier: BSD-3-Clause 535527fb4SYann Gautier */ 635527fb4SYann Gautier 735527fb4SYann Gautier #ifndef BOOT_API_H 835527fb4SYann Gautier #define BOOT_API_H 935527fb4SYann Gautier 1035527fb4SYann Gautier #include <stdint.h> 1135527fb4SYann Gautier #include <stdio.h> 1235527fb4SYann Gautier 1335527fb4SYann Gautier /* 1435527fb4SYann Gautier * Exported constants 1535527fb4SYann Gautier */ 1635527fb4SYann Gautier 1735527fb4SYann Gautier /* 1835527fb4SYann Gautier * Boot Context related definitions 1935527fb4SYann Gautier */ 2035527fb4SYann Gautier 2135527fb4SYann Gautier /* 2235527fb4SYann Gautier * Possible value of boot context field 'auth_status' 2335527fb4SYann Gautier */ 2435527fb4SYann Gautier /* No authentication done */ 2535527fb4SYann Gautier #define BOOT_API_CTX_AUTH_NO 0x0U 2635527fb4SYann Gautier /* Authentication done and failed */ 2735527fb4SYann Gautier #define BOOT_API_CTX_AUTH_FAILED 0x1U 2835527fb4SYann Gautier /* Authentication done and succeeded */ 2935527fb4SYann Gautier #define BOOT_API_CTX_AUTH_SUCCESS 0x2U 3035527fb4SYann Gautier 3135527fb4SYann Gautier /* 3235527fb4SYann Gautier * Possible value of boot context field 'boot_interface_sel' 3335527fb4SYann Gautier */ 3435527fb4SYann Gautier 3535527fb4SYann Gautier /* Value of field 'boot_interface_sel' when no boot occurred */ 3635527fb4SYann Gautier #define BOOT_API_CTX_BOOT_INTERFACE_SEL_NO 0x0U 3735527fb4SYann Gautier 3835527fb4SYann Gautier /* Boot occurred on SD */ 3935527fb4SYann Gautier #define BOOT_API_CTX_BOOT_INTERFACE_SEL_FLASH_SD 0x1U 4035527fb4SYann Gautier 4135527fb4SYann Gautier /* Boot occurred on EMMC */ 4235527fb4SYann Gautier #define BOOT_API_CTX_BOOT_INTERFACE_SEL_FLASH_EMMC 0x2U 4335527fb4SYann Gautier 4435527fb4SYann Gautier /* Boot occurred on FMC */ 4535527fb4SYann Gautier #define BOOT_API_CTX_BOOT_INTERFACE_SEL_FLASH_NAND_FMC 0x3U 4635527fb4SYann Gautier 4735527fb4SYann Gautier /* Boot occurred on OSPI NOR */ 4835527fb4SYann Gautier #define BOOT_API_CTX_BOOT_INTERFACE_SEL_FLASH_NOR_SPI 0x4U 4935527fb4SYann Gautier 5035527fb4SYann Gautier /* Boot occurred on UART */ 5135527fb4SYann Gautier #define BOOT_API_CTX_BOOT_INTERFACE_SEL_SERIAL_UART 0x5U 5235527fb4SYann Gautier 5335527fb4SYann Gautier /* Boot occurred on USB */ 5435527fb4SYann Gautier #define BOOT_API_CTX_BOOT_INTERFACE_SEL_SERIAL_USB 0x6U 5535527fb4SYann Gautier 5635527fb4SYann Gautier /* Boot occurred on OSPI NAND */ 5735527fb4SYann Gautier #define BOOT_API_CTX_BOOT_INTERFACE_SEL_FLASH_NAND_SPI 0x7U 5835527fb4SYann Gautier 5935527fb4SYann Gautier /* Boot occurred on HyperFlash QSPI */ 6035527fb4SYann Gautier #define BOOT_API_CTX_BOOT_INTERFACE_SEL_HYPERFLASH_OSPI 0x8U 6135527fb4SYann Gautier 6235527fb4SYann Gautier /* 6335527fb4SYann Gautier * Possible value of boot context field 'emmc_xfer_status' 6435527fb4SYann Gautier */ 6535527fb4SYann Gautier #define BOOT_API_CTX_EMMC_XFER_STATUS_NOT_STARTED 0x0U 6635527fb4SYann Gautier #define BOOT_API_CTX_EMMC_XFER_STATUS_DATAEND_DETECTED 0x1U 6735527fb4SYann Gautier #define BOOT_API_CTX_EMMC_XFER_STATUS_XFER_DATA_TIMEOUT 0x2U 6835527fb4SYann Gautier 6935527fb4SYann Gautier /* 7035527fb4SYann Gautier * Possible value of boot context field 'emmc_error_status' 7135527fb4SYann Gautier */ 7235527fb4SYann Gautier #define BOOT_API_CTX_EMMC_ERROR_STATUS_NONE 0x0U 7335527fb4SYann Gautier #define BOOT_API_CTX_EMMC_ERROR_STATUS_CMD_TIMEOUT 0x1U 7435527fb4SYann Gautier #define BOOT_API_CTX_EMMC_ERROR_STATUS_ACK_TIMEOUT 0x2U 7535527fb4SYann Gautier #define BOOT_API_CTX_EMMC_ERROR_STATUS_DATA_CRC_FAIL 0x3U 7635527fb4SYann Gautier #define BOOT_API_CTX_EMMC_ERROR_STATUS_NOT_ENOUGH_BOOT_DATA_RX 0x4U 7735527fb4SYann Gautier #define BOOT_API_CTX_EMMC_ERROR_STATUS_HEADER_NOT_FOUND 0x5U 7835527fb4SYann Gautier #define BOOT_API_CTX_EMMC_ERROR_STATUS_HEADER_SIZE_ZERO 0x6U 7935527fb4SYann Gautier #define BOOT_API_CTX_EMMC_ERROR_STATUS_IMAGE_NOT_COMPLETE 0x7U 8035527fb4SYann Gautier #define BOOT_API_CTX_EMMC_ERROR_STATUS_ACK_ERROR 0x8U 8135527fb4SYann Gautier 8235527fb4SYann Gautier /* Definitions relative to 'p_rom_version_info->platform_type_ver' field */ 8335527fb4SYann Gautier #define BOOT_API_CTX_ROM_VERSION_PLAT_VER_IC_EMU_FPGA 0xAA 8435527fb4SYann Gautier #define BOOT_API_CTX_ROM_VERSION_PLAT_VER_FPGA_ONLY 0xBB 8535527fb4SYann Gautier 8635527fb4SYann Gautier /* Image Header related definitions */ 8735527fb4SYann Gautier 8835527fb4SYann Gautier /* Definition of header version */ 89*db77f8bfSYann Gautier #define BOOT_API_HEADER_VERSION 0x00020200U 9035527fb4SYann Gautier 9135527fb4SYann Gautier /* 9235527fb4SYann Gautier * Magic number used to detect header in memory 9335527fb4SYann Gautier * Its value must be 'S' 'T' 'M' 0x32, i.e 0x324D5453 as field 9435527fb4SYann Gautier * 'bootapi_image_header_t.magic' 9535527fb4SYann Gautier * This identifies the start of a boot image. 9635527fb4SYann Gautier */ 9735527fb4SYann Gautier #define BOOT_API_IMAGE_HEADER_MAGIC_NB 0x324D5453U 9835527fb4SYann Gautier 9935527fb4SYann Gautier /* Definitions related to Authentication used in image header structure */ 10035527fb4SYann Gautier #define BOOT_API_ECDSA_PUB_KEY_LEN_IN_BYTES 64 10135527fb4SYann Gautier #define BOOT_API_ECDSA_SIGNATURE_LEN_IN_BYTES 64 10235527fb4SYann Gautier #define BOOT_API_SHA256_DIGEST_SIZE_IN_BYTES 32 10335527fb4SYann Gautier 10435527fb4SYann Gautier /* Possible values of the field 'boot_api_image_header_t.ecc_algo_type' */ 10535527fb4SYann Gautier #define BOOT_API_ECDSA_ALGO_TYPE_P256NIST 1 10635527fb4SYann Gautier #define BOOT_API_ECDSA_ALGO_TYPE_BRAINPOOL256 2 10735527fb4SYann Gautier 10835527fb4SYann Gautier /* 10935527fb4SYann Gautier * Extension headers related definitions 11035527fb4SYann Gautier */ 11135527fb4SYann Gautier /* 'bootapi_image_header_t.extension_flag' used for authentication feature */ 11235527fb4SYann Gautier #define BOOT_API_AUTHENTICATION_EXTENSION_BIT BIT(0) 11335527fb4SYann Gautier /* 'bootapi_image_header_t.extension_flag' used for FSBL decryption feature */ 11435527fb4SYann Gautier #define BOOT_API_FSBL_DECRYPTION_EXTENSION_BIT BIT(1) 11535527fb4SYann Gautier /* 'bootapi_image_header_t.extension_flag' used for padding header feature */ 11635527fb4SYann Gautier #define BOOT_API_PADDING_EXTENSION_BIT BIT(31) 11735527fb4SYann Gautier /* 11835527fb4SYann Gautier * mask of bits of field 'bootapi_image_header_t.extension_flag' 11935527fb4SYann Gautier * used for extension headers 12035527fb4SYann Gautier */ 12135527fb4SYann Gautier #define BOOT_API_ALL_EXTENSIONS_MASK \ 12235527fb4SYann Gautier (BOOT_API_AUTHENTICATION_EXTENSION_BIT | \ 12335527fb4SYann Gautier BOOT_API_FSBL_DECRYPTION_EXTENSION_BIT | \ 12435527fb4SYann Gautier BOOT_API_PADDING_EXTENSION_BIT) 12535527fb4SYann Gautier /* 12635527fb4SYann Gautier * Magic number of FSBL decryption extension header 12735527fb4SYann Gautier * The value shall gives the four bytes 'S','T',0x00,0x01 in memory 12835527fb4SYann Gautier */ 12935527fb4SYann Gautier #define BOOT_API_FSBL_DECRYPTION_HEADER_MAGIC_NB 0x01005453U 13035527fb4SYann Gautier 13135527fb4SYann Gautier /* 13235527fb4SYann Gautier * Magic number of PKH revocation extension header 13335527fb4SYann Gautier * The value shall gives the four bytes 'S','T',0x00,0x02 in memory 13435527fb4SYann Gautier */ 13535527fb4SYann Gautier #define BOOT_API_AUTHENTICATION_HEADER_MAGIC_NB 0x02005453U 13635527fb4SYann Gautier 13735527fb4SYann Gautier /* Max number of ECDSA public key hash in table */ 13835527fb4SYann Gautier #define BOOT_API_AUTHENTICATION_NB_PKH_MAX 8U 13935527fb4SYann Gautier 14035527fb4SYann Gautier /* ECDSA public key hash table size in bytes */ 14135527fb4SYann Gautier #define BOOT_API_AUTHENTICATION_TABLE_SIZE_BYTES \ 14235527fb4SYann Gautier (BOOT_API_AUTHENTICATION_NB_PKH_MAX * \ 14335527fb4SYann Gautier BOOT_API_SHA256_DIGEST_SIZE_IN_BYTES) 14435527fb4SYann Gautier 14535527fb4SYann Gautier /* 14635527fb4SYann Gautier * Magic number of padding extension header 14735527fb4SYann Gautier * The value shall gives the four bytes 'S','T',0xFF,0xFF in memory 14835527fb4SYann Gautier */ 14935527fb4SYann Gautier #define BOOT_API_PADDING_HEADER_MAGIC_NB 0xFFFF5453U 15035527fb4SYann Gautier 15135527fb4SYann Gautier /* 15235527fb4SYann Gautier * Related to binaryType 15335527fb4SYann Gautier * 0x00: U-Boot 15435527fb4SYann Gautier * 0x10-0x1F: TF-A 15535527fb4SYann Gautier * 0x20-0X2F: OPTEE 15635527fb4SYann Gautier * 0x30: CM33 image 15735527fb4SYann Gautier */ 15835527fb4SYann Gautier #define BOOT_API_IMAGE_TYPE_UBOOT 0x0 15935527fb4SYann Gautier #define BOOT_API_IMAGE_TYPE_M33 0x30 16035527fb4SYann Gautier 16135527fb4SYann Gautier /* 16235527fb4SYann Gautier * Cores secure magic numbers 16335527fb4SYann Gautier * Constant to be stored in bakcup register 16435527fb4SYann Gautier * BOOT_API_MAGIC_NUMBER_TAMP_BCK_REG_IDX 16535527fb4SYann Gautier */ 16635527fb4SYann Gautier #define BOOT_API_A35_CORE0_MAGIC_NUMBER 0xCA7FACE0U 16735527fb4SYann Gautier #define BOOT_API_A35_CORE1_MAGIC_NUMBER 0xCA7FACE1U 16835527fb4SYann Gautier 16935527fb4SYann Gautier /* 17035527fb4SYann Gautier * TAMP_BCK9R register index 17135527fb4SYann Gautier * This register is used to write a Magic Number in order to restart 17235527fb4SYann Gautier * Cortex A35 Core 1 and make it execute @ branch address from TAMP_BCK5R 17335527fb4SYann Gautier */ 17435527fb4SYann Gautier #define BOOT_API_CORE1_MAGIC_NUMBER_TAMP_BCK_REG_IDX 9U 17535527fb4SYann Gautier 17635527fb4SYann Gautier /* 17735527fb4SYann Gautier * TAMP_BCK10R register index 17835527fb4SYann Gautier * This register is used to contain the branch address of 17935527fb4SYann Gautier * Cortex A35 Core 1 when restarted by a TAMP_BCK4R magic number writing 18035527fb4SYann Gautier */ 18135527fb4SYann Gautier #define BOOT_API_CORE1_BRANCH_ADDRESS_TAMP_BCK_REG_IDX 10U 18235527fb4SYann Gautier 18335527fb4SYann Gautier /* 18435527fb4SYann Gautier * Possible value of boot context field 'hse_clock_value_in_hz' 18535527fb4SYann Gautier */ 18635527fb4SYann Gautier #define BOOT_API_CTX_HSE_CLOCK_VALUE_UNDEFINED 0U 18735527fb4SYann Gautier #define BOOT_API_CTX_HSE_CLOCK_VALUE_19_2_MHZ 19200000U 18835527fb4SYann Gautier #define BOOT_API_CTX_HSE_CLOCK_VALUE_24_MHZ 24000000U 18935527fb4SYann Gautier #define BOOT_API_CTX_HSE_CLOCK_VALUE_25_MHZ 25000000U 19035527fb4SYann Gautier #define BOOT_API_CTX_HSE_CLOCK_VALUE_26_MHZ 26000000U 19135527fb4SYann Gautier #define BOOT_API_CTX_HSE_CLOCK_VALUE_40_MHZ 40000000U 19235527fb4SYann Gautier #define BOOT_API_CTX_HSE_CLOCK_VALUE_48_MHZ 48000000U 19335527fb4SYann Gautier 19435527fb4SYann Gautier /* 19535527fb4SYann Gautier * Possible value of boot context field 'boot_partition_used_toboot' 19635527fb4SYann Gautier */ 19735527fb4SYann Gautier #define BOOT_API_CTX_BOOT_PARTITION_UNDEFINED 0U 19835527fb4SYann Gautier 19935527fb4SYann Gautier /* Used FSBL1 to boot */ 20035527fb4SYann Gautier #define BOOT_API_CTX_BOOT_PARTITION_FSBL1 1U 20135527fb4SYann Gautier 20235527fb4SYann Gautier /* Used FSBL2 to boot */ 20335527fb4SYann Gautier #define BOOT_API_CTX_BOOT_PARTITION_FSBL2 2U 20435527fb4SYann Gautier 20535527fb4SYann Gautier #define BOOT_API_RETURN_OK 0x66U 20635527fb4SYann Gautier 20735527fb4SYann Gautier /* 20835527fb4SYann Gautier * Possible values of boot context field 20935527fb4SYann Gautier * 'ssp_config_ptr_in->ssp_cmd' 21035527fb4SYann Gautier */ 21135527fb4SYann Gautier /* 'K' 'B' 'U' 'P' -.> 'PUBK' */ 21235527fb4SYann Gautier #define BOOT_API_CTX_SSP_CMD_CALC_CHIP_PUBK 0x4B425550 21335527fb4SYann Gautier 21435527fb4SYann Gautier /* 21535527fb4SYann Gautier * Exported types 21635527fb4SYann Gautier */ 21735527fb4SYann Gautier 21835527fb4SYann Gautier /* 21935527fb4SYann Gautier * bootROM version information structure definition 22035527fb4SYann Gautier * Total size = 24 bytes = 6 uint32_t 22135527fb4SYann Gautier */ 22235527fb4SYann Gautier typedef struct { 22335527fb4SYann Gautier /* Chip Version */ 22435527fb4SYann Gautier uint32_t chip_ver; 22535527fb4SYann Gautier 22635527fb4SYann Gautier /* Cut version within a fixed chip version */ 22735527fb4SYann Gautier uint32_t cut_ver; 22835527fb4SYann Gautier 22935527fb4SYann Gautier /* Version of ROM Mask within a fixed cut version */ 23035527fb4SYann Gautier uint32_t rom_mask_ver; 23135527fb4SYann Gautier 23235527fb4SYann Gautier /* Internal Version of bootROM code */ 23335527fb4SYann Gautier uint32_t bootrom_ver; 23435527fb4SYann Gautier 23535527fb4SYann Gautier /* Version of bootROM adapted */ 23635527fb4SYann Gautier uint32_t for_chip_design_rtl_ver; 23735527fb4SYann Gautier 23835527fb4SYann Gautier /* Restriction on compiled platform when it applies */ 23935527fb4SYann Gautier uint32_t platform_type_ver; 24035527fb4SYann Gautier } boot_api_rom_version_info_t; 24135527fb4SYann Gautier 24235527fb4SYann Gautier /* 24335527fb4SYann Gautier * Boot Context related definitions 24435527fb4SYann Gautier */ 24535527fb4SYann Gautier 24635527fb4SYann Gautier /* 24735527fb4SYann Gautier * Boot core boot configuration structure 24835527fb4SYann Gautier * Specifies all items of the secure boot configuration 24935527fb4SYann Gautier * Memory and peripheral part. 25035527fb4SYann Gautier */ 25135527fb4SYann Gautier typedef struct { 25235527fb4SYann Gautier /* Boot partition: ie FSBL partition on which the boot was successful */ 25335527fb4SYann Gautier uint32_t boot_partition_used_toboot; 25435527fb4SYann Gautier 25535527fb4SYann Gautier uint32_t reserved1[3]; 25635527fb4SYann Gautier 25735527fb4SYann Gautier /* 25835527fb4SYann Gautier * Information specific to an SD boot 25935527fb4SYann Gautier * Updated each time an SD boot is at least attempted, 26035527fb4SYann Gautier * even if not successful 26135527fb4SYann Gautier * Note : This is useful to understand why an SD boot failed 26235527fb4SYann Gautier * in particular 26335527fb4SYann Gautier */ 26435527fb4SYann Gautier uint32_t sd_err_internal_timeout_cnt; 26535527fb4SYann Gautier uint32_t sd_err_dcrc_fail_cnt; 26635527fb4SYann Gautier uint32_t sd_err_dtimeout_cnt; 26735527fb4SYann Gautier uint32_t sd_err_ctimeout_cnt; 26835527fb4SYann Gautier uint32_t sd_err_ccrc_fail_cnt; 26935527fb4SYann Gautier uint32_t sd_overall_retry_cnt; 27035527fb4SYann Gautier /* 27135527fb4SYann Gautier * Information specific to an eMMC boot 27235527fb4SYann Gautier * Updated each time an eMMC boot is at least attempted, 27335527fb4SYann Gautier * even if not successful 27435527fb4SYann Gautier * Note : This is useful to understand why an eMMC boot failed 27535527fb4SYann Gautier * in particular 27635527fb4SYann Gautier */ 27735527fb4SYann Gautier uint32_t emmc_xfer_status; 27835527fb4SYann Gautier uint32_t emmc_error_status; 27935527fb4SYann Gautier uint32_t emmc_nbbytes_rxcopied_tosysram_download_area; 28035527fb4SYann Gautier 28135527fb4SYann Gautier uint32_t reserved[4]; 28235527fb4SYann Gautier /* 28335527fb4SYann Gautier * Boot interface used to boot : take values from defines 28435527fb4SYann Gautier * BOOT_API_CTX_BOOT_INTERFACE_SEL_XXX above 28535527fb4SYann Gautier */ 28635527fb4SYann Gautier uint16_t boot_interface_selected; 28735527fb4SYann Gautier uint16_t boot_interface_instance; 28835527fb4SYann Gautier 28935527fb4SYann Gautier uint32_t hse_clock_value_in_hz; 29035527fb4SYann Gautier 29135527fb4SYann Gautier uint32_t nand_fsbl_first_block; 29235527fb4SYann Gautier 29335527fb4SYann Gautier /* 29435527fb4SYann Gautier * Returned authentication status : take values from defines 29535527fb4SYann Gautier * BOOT_API_CTX_AUTH_XXX above 29635527fb4SYann Gautier */ 29735527fb4SYann Gautier uint32_t auth_status; 29835527fb4SYann Gautier 29935527fb4SYann Gautier /* Pointer on ROM constant containing ROM information */ 30035527fb4SYann Gautier const boot_api_rom_version_info_t *p_rom_version_info; 30135527fb4SYann Gautier } __packed boot_api_context_t; 30235527fb4SYann Gautier 30335527fb4SYann Gautier /* 30435527fb4SYann Gautier * Image Header related definitions 30535527fb4SYann Gautier */ 30635527fb4SYann Gautier 30735527fb4SYann Gautier /* 30835527fb4SYann Gautier * Structure used to define the common Header format used for FSBL, xloader, 30935527fb4SYann Gautier * ... and in particular used by bootROM for FSBL header readout. 31035527fb4SYann Gautier * FSBL header size is 256 Bytes = 0x100 31135527fb4SYann Gautier */ 31235527fb4SYann Gautier typedef struct { 31335527fb4SYann Gautier /* BOOT_API_IMAGE_HEADER_MAGIC_NB */ 31435527fb4SYann Gautier uint32_t magic; 31535527fb4SYann Gautier uint8_t image_signature[BOOT_API_ECDSA_SIGNATURE_LEN_IN_BYTES]; 31635527fb4SYann Gautier /* 31735527fb4SYann Gautier * Checksum of payload 31835527fb4SYann Gautier * 32-bit sum all payload bytes considered as 8 bit unsigned 31935527fb4SYann Gautier * numbers, discarding any overflow bits. 32035527fb4SYann Gautier * Use to check UART/USB downloaded image integrity when signature 32135527fb4SYann Gautier * is not used 32235527fb4SYann Gautier */ 32335527fb4SYann Gautier uint32_t payload_checksum; 32435527fb4SYann Gautier /* Image header version : should have value BOOT_API_HEADER_VERSION */ 32535527fb4SYann Gautier uint32_t header_version; 32635527fb4SYann Gautier /* Image length in bytes */ 32735527fb4SYann Gautier uint32_t image_length; 32835527fb4SYann Gautier /* 32935527fb4SYann Gautier * Image Entry point address : should be in the SYSRAM area 33035527fb4SYann Gautier * and at least within the download area range 33135527fb4SYann Gautier */ 33235527fb4SYann Gautier uint32_t image_entry_point; 33335527fb4SYann Gautier /* Reserved */ 33435527fb4SYann Gautier uint32_t reserved1; 33535527fb4SYann Gautier /* 33635527fb4SYann Gautier * Image load address : not used by bootROM but to be consistent 33735527fb4SYann Gautier * with header format for other packages (xloader, ...) 33835527fb4SYann Gautier */ 33935527fb4SYann Gautier uint32_t load_address; 34035527fb4SYann Gautier /* Reserved */ 34135527fb4SYann Gautier uint32_t reserved2; 34235527fb4SYann Gautier /* Image version to be compared by bootROM with FSBL_A or FSBL_M version 34335527fb4SYann Gautier * counter value in OTP prior executing the downloaded image 34435527fb4SYann Gautier */ 34535527fb4SYann Gautier uint32_t image_version; 34635527fb4SYann Gautier /* 34735527fb4SYann Gautier * Extension flags : 34835527fb4SYann Gautier * 34935527fb4SYann Gautier * Bit 0 : Authentication extension header 35035527fb4SYann Gautier * value 0 : No signature check request 35135527fb4SYann Gautier * Bit 1 : Encryption extension header 35235527fb4SYann Gautier * Bit 2 : Padding extension header 35335527fb4SYann Gautier */ 35435527fb4SYann Gautier uint32_t extension_flags; 35535527fb4SYann Gautier /* Length in bytes of all extension headers */ 35635527fb4SYann Gautier uint32_t extension_headers_length; 35735527fb4SYann Gautier /* Add binary type information */ 35835527fb4SYann Gautier uint32_t binary_type; 35935527fb4SYann Gautier /* Pad up to 128 byte total size */ 36035527fb4SYann Gautier uint8_t pad[16]; 36135527fb4SYann Gautier /* Followed by extension header */ 36235527fb4SYann Gautier uint8_t ext_header[]; 36335527fb4SYann Gautier } __packed boot_api_image_header_t; 36435527fb4SYann Gautier 36535527fb4SYann Gautier typedef uint8_t boot_api_sha256_t[BOOT_API_SHA256_DIGEST_SIZE_IN_BYTES]; 36635527fb4SYann Gautier 36735527fb4SYann Gautier typedef struct { 36835527fb4SYann Gautier /* Extension header type: 36935527fb4SYann Gautier * BOOT_API_FSBL_DECRYPTION_HEADER_MAGIC_NB or 37035527fb4SYann Gautier * BOOT_API_AUTHENTICATION_HEADER_MAGIC_NB 37135527fb4SYann Gautier * BOOT_API_PADDING_HEADER_MAGIC_NB 37235527fb4SYann Gautier */ 37335527fb4SYann Gautier uint32_t type; 37435527fb4SYann Gautier /* Extension header len in byte */ 37535527fb4SYann Gautier uint32_t len; 37635527fb4SYann Gautier /* parameters of this extension */ 37735527fb4SYann Gautier uint8_t params[]; 37835527fb4SYann Gautier } __packed boot_extension_header_t; 37935527fb4SYann Gautier 38035527fb4SYann Gautier typedef struct { 38135527fb4SYann Gautier /* Idx of ECDSA public key to be used in table */ 38235527fb4SYann Gautier uint32_t pk_idx; 38335527fb4SYann Gautier /* Number of ECDSA public key in table */ 38435527fb4SYann Gautier uint32_t nb_pk; 38535527fb4SYann Gautier /* 38635527fb4SYann Gautier * Type of ECC algorithm to use : 38735527fb4SYann Gautier * value 1 : for P-256 NIST algorithm 38835527fb4SYann Gautier * value 2 : for Brainpool 256 algorithm 38935527fb4SYann Gautier * See definitions 'BOOT_API_ECDSA_ALGO_TYPE_XXX' above. 39035527fb4SYann Gautier */ 39135527fb4SYann Gautier uint32_t ecc_algo_type; 39235527fb4SYann Gautier /* ECDSA public key to be used to check signature. */ 39335527fb4SYann Gautier uint8_t ecc_pubk[BOOT_API_ECDSA_PUB_KEY_LEN_IN_BYTES]; 39435527fb4SYann Gautier /* table of Hash of Algo+ECDSA public key */ 39535527fb4SYann Gautier boot_api_sha256_t pk_hashes[]; 39635527fb4SYann Gautier } __packed boot_ext_header_params_authentication_t; 39735527fb4SYann Gautier 39835527fb4SYann Gautier typedef struct { 39935527fb4SYann Gautier /* Size of encryption key (128 or 256) */ 40035527fb4SYann Gautier uint32_t key_size; 40135527fb4SYann Gautier uint32_t derivation_cont; 40235527fb4SYann Gautier /* 128 msb bits of plain payload SHA256 */ 40335527fb4SYann Gautier uint32_t hash[4]; 40435527fb4SYann Gautier } __packed boot_ext_header_params_encrypted_fsbl_t; 40535527fb4SYann Gautier 40635527fb4SYann Gautier #endif /* BOOT_API_H */ 407