1 /* 2 * $ Copyright Cypress Semiconductor Apache2 $ 3 */ 4 5 #ifndef INCLUDED_WHD_TRXHDR_H_ 6 #define INCLUDED_WHD_TRXHDR_H_ 7 8 #ifdef __cplusplus 9 extern "C" { 10 #endif 11 12 #ifdef TRXV5 13 14 #else 15 /* Bootloader makes special use of trx header "offsets" array */ 16 enum 17 { 18 TRX_V4_OFFS_SIGN_INFO_IDX = 0, 19 TRX_V4_OFFS_DATA_FOR_SIGN1_IDX = 1, 20 TRX_V4_OFFS_DATA_FOR_SIGN2_IDX = 2, 21 TRX_V4_OFFS_ROOT_MODULUS_IDX = 3, 22 TRX_V4_OFFS_ROOT_EXPONENT_IDX = 67, 23 TRX_V4_OFFS_CONT_MODULUS_IDX = 68, 24 TRX_V4_OFFS_CONT_EXPONENT_IDX = 132, 25 TRX_V4_OFFS_HASH_FW_IDX = 133, 26 TRX_V4_OFFS_FW_LEN_IDX = 149, 27 TRX_V4_OFFS_TR_RST_IDX = 150, 28 TRX_V4_OFFS_FW_VER_FOR_ANTIROOLBACK_IDX = 151, 29 TRX_V4_OFFS_IV_IDX = 152, 30 TRX_V4_OFFS_NONCE_IDX = 160, 31 TRX_V4_OFFS_SIGN_INFO2_IDX = 168, 32 TRX_V4_OFFS_MAX_IDX 33 }; 34 #endif 35 /****************************************************** 36 * TRX header Constants 37 ******************************************************/ 38 39 #define TRX_MAGIC 0x30524448 /* "HDR0" */ 40 41 #ifdef TRXV5 42 #define TRX_VERSION 5 /* Version trxv5 */ 43 #else 44 #define TRX_VERSION 4 /* Version trxv4 */ 45 #define TRX_MAX_OFFSET TRX_V4_OFFS_MAX_IDX /* Max number of file offsets for trxv4 */ 46 #endif 47 /****************************************************** 48 * Structures 49 ******************************************************/ 50 #ifdef TRXV5 51 typedef struct 52 { 53 uint32_t magic; /* "HDR0" */ 54 uint32_t len; /* Length of file including header */ 55 uint32_t crc32; /* CRC from flag_version to end of file */ 56 uint32_t flag_version; /* 0:15 flags, 16:31 version */ 57 uint32_t offsets[4]; /* Offsets of partitions */ 58 } trx_header_t; 59 #else 60 typedef struct 61 { 62 uint32_t magic; /* "HDR0" */ 63 uint32_t len; /* Length of file including header */ 64 uint32_t crc32; /* CRC from flag_version to end of file */ 65 uint32_t flag_version; /* 0:15 flags, 16:31 version */ 66 uint32_t offsets[TRX_MAX_OFFSET]; /* Offsets of partitions */ 67 } trx_header_t; 68 #endif 69 70 #ifdef __cplusplus 71 } /* extern "C" */ 72 #endif 73 74 #endif /* ifndef INCLUDED_WHD_TRXHDR_H_ */ 75 76