.. | .. |
---|
1 | | -/* SPDX-License-Identifier: GPL-2.0 */ |
---|
2 | 1 | /* |
---|
3 | 2 | * TRX image file header format. |
---|
4 | 3 | * |
---|
5 | | - * Copyright (C) 1999-2019, Broadcom Corporation |
---|
6 | | - * |
---|
| 4 | + * Portions of this code are copyright (c) 2022 Cypress Semiconductor Corporation |
---|
| 5 | + * |
---|
| 6 | + * Copyright (C) 1999-2017, Broadcom Corporation |
---|
| 7 | + * |
---|
7 | 8 | * Unless you and Broadcom execute a separate written software license |
---|
8 | 9 | * agreement governing use of this software, this software is licensed to you |
---|
9 | 10 | * under the terms of the GNU General Public License version 2 (the "GPL"), |
---|
10 | 11 | * available at http://www.broadcom.com/licenses/GPLv2.php, with the |
---|
11 | 12 | * following added to such license: |
---|
12 | | - * |
---|
| 13 | + * |
---|
13 | 14 | * As a special exception, the copyright holders of this software give you |
---|
14 | 15 | * permission to link this software with independent modules, and to copy and |
---|
15 | 16 | * distribute the resulting executable under terms of your choice, provided that |
---|
.. | .. |
---|
17 | 18 | * the license of that module. An independent module is a module which is not |
---|
18 | 19 | * derived from this software. The special exception does not apply to any |
---|
19 | 20 | * modifications of the software. |
---|
20 | | - * |
---|
| 21 | + * |
---|
21 | 22 | * Notwithstanding the above, under no circumstances may you combine this |
---|
22 | 23 | * software in any way with any other Broadcom software provided under a license |
---|
23 | 24 | * other than the GPL, without Broadcom's express prior written consent. |
---|
.. | .. |
---|
42 | 43 | #define TRX_UNCOMP_IMAGE 0x20 /* Trx contains uncompressed rtecdc.bin image */ |
---|
43 | 44 | #define TRX_BOOTLOADER 0x40 /* the image is a bootloader */ |
---|
44 | 45 | |
---|
45 | | -#define TRX_V1 1 |
---|
46 | | -#define TRX_V1_MAX_OFFSETS 3 /* V1: Max number of individual files */ |
---|
| 46 | +#define TRX_VERSION_BIT_OFFSET 16 |
---|
| 47 | +#define R_COMP_SIZE 32 /* R component - 32 bytes */ |
---|
| 48 | +#define S_COMP_SIZE 32 /* S component - 32 bytes */ |
---|
| 49 | +#define ECDSA_SIGNATURE_SIZE (R_COMP_SIZE + S_COMP_SIZE) /* r[32bytes] and s[32bytes] components */ |
---|
47 | 50 | |
---|
48 | | -#ifndef BCMTRXV2 |
---|
49 | | -#define TRX_VERSION TRX_V1 /* Version 1 */ |
---|
50 | | -#define TRX_MAX_OFFSET TRX_V1_MAX_OFFSETS |
---|
51 | | -#endif |
---|
| 51 | +enum { |
---|
| 52 | + TRX_V4_OFFS_SIGN_INFO_IDX = 0, |
---|
| 53 | + TRX_V4_OFFS_DATA_FOR_SIGN1_IDX = 1, |
---|
| 54 | + TRX_V4_OFFS_DATA_FOR_SIGN2_IDX = 2, |
---|
| 55 | + TRX_V4_OFFS_ROOT_MODULUS_IDX = 3, |
---|
| 56 | + TRX_V4_OFFS_ROOT_EXPONENT_IDX = 67, |
---|
| 57 | + TRX_V4_OFFS_CONT_MODULUS_IDX = 68, |
---|
| 58 | + TRX_V4_OFFS_CONT_EXPONENT_IDX = 132, |
---|
| 59 | + TRX_V4_OFFS_HASH_FW_IDX = 133, |
---|
| 60 | + TRX_V4_OFFS_FW_LEN_IDX = 149, |
---|
| 61 | + TRX_V4_OFFS_TR_RST_IDX = 150, |
---|
| 62 | + TRX_V4_OFFS_FW_VER_FOR_ANTIROOLBACK_IDX = 151, |
---|
| 63 | + TRX_V4_OFFS_IV_IDX = 152, |
---|
| 64 | + TRX_V4_OFFS_NONCE_IDX = 160, |
---|
| 65 | + TRX_V4_OFFS_SIGN_INFO2_IDX = 168, |
---|
| 66 | + TRX_V4_OFFS_MAX_IDX |
---|
| 67 | +}; |
---|
| 68 | + |
---|
| 69 | +#if defined BCMTRXV4 |
---|
| 70 | +#define TRX_VERSION 4 /* Version 4 */ |
---|
| 71 | +#define TRX_MAX_OFFSET (TRX_V4_OFFS_MAX_IDX) |
---|
| 72 | + |
---|
| 73 | +#elif defined BCMTRXV3 |
---|
| 74 | +#define TRX_VERSION 3 /* Version 3 */ |
---|
| 75 | +#define TRX_MAX_OFFSET 4 /* FW size + Jump_addr + NVRAM size[if exist] |
---|
| 76 | + * + signature size |
---|
| 77 | + */ |
---|
| 78 | +#elif defined BCMTRXV2 |
---|
| 79 | +#define TRX_VERSION 2 /* Version 2 */ |
---|
| 80 | +#define TRX_MAX_OFFSET 5 /* Max number of individual files |
---|
| 81 | + * to support SDR signature + Config data region |
---|
| 82 | + */ |
---|
| 83 | +#else |
---|
| 84 | +#define TRX_VERSION 1 /* Version 1 */ |
---|
| 85 | +#define TRX_MAX_OFFSET 3 /* Max number of individual files */ |
---|
| 86 | +#endif /* BCMTRXV3 BCMTRXV2 BCMTRXV4 */ |
---|
52 | 87 | |
---|
53 | 88 | /* BMAC Host driver/application like bcmdl need to support both Ver 1 as well as |
---|
54 | 89 | * Ver 2 of trx header. To make it generic, trx_header is structure is modified |
---|
.. | .. |
---|
63 | 98 | uint32 len; /* Length of file including header */ |
---|
64 | 99 | uint32 crc32; /* 32-bit CRC from flag_version to end of file */ |
---|
65 | 100 | uint32 flag_version; /* 0:15 flags, 16:31 version */ |
---|
66 | | -#ifndef BCMTRXV2 |
---|
67 | 101 | uint32 offsets[TRX_MAX_OFFSET]; /* Offsets of partitions from start of header */ |
---|
68 | | -#else |
---|
69 | | - uint32 offsets[1]; /* Offsets of partitions from start of header */ |
---|
70 | | -#endif |
---|
71 | 102 | }; |
---|
72 | 103 | |
---|
73 | | -#ifdef BCMTRXV2 |
---|
74 | | -#define TRX_VERSION TRX_V2 /* Version 2 */ |
---|
75 | | -#define TRX_MAX_OFFSET TRX_V2_MAX_OFFSETS |
---|
76 | | - |
---|
77 | | -#define TRX_V2 2 |
---|
78 | | -/* V2: Max number of individual files |
---|
79 | | - * To support SDR signature + Config data region |
---|
80 | | - */ |
---|
81 | | -#define TRX_V2_MAX_OFFSETS 5 |
---|
82 | | -#define SIZEOF_TRXHDR_V1 (sizeof(struct trx_header)+(TRX_V1_MAX_OFFSETS-1)*sizeof(uint32)) |
---|
83 | | -#define SIZEOF_TRXHDR_V2 (sizeof(struct trx_header)+(TRX_V2_MAX_OFFSETS-1)*sizeof(uint32)) |
---|
84 | | -#define TRX_VER(trx) ((trx)->flag_version>>16) |
---|
85 | | -#define ISTRX_V1(trx) (TRX_VER(trx) == TRX_V1) |
---|
86 | | -#define ISTRX_V2(trx) (TRX_VER(trx) == TRX_V2) |
---|
87 | | -/* For V2, return size of V2 size: others, return V1 size */ |
---|
88 | | -#define SIZEOF_TRX(trx) (ISTRX_V2(trx) ? SIZEOF_TRXHDR_V2: SIZEOF_TRXHDR_V1) |
---|
89 | | -#else |
---|
90 | | -#define SIZEOF_TRX(trx) (sizeof(struct trx_header)) |
---|
91 | | -#endif /* BCMTRXV2 */ |
---|
| 104 | +/* bootloader makes special use of trx header "offsets" array */ |
---|
| 105 | +enum { |
---|
| 106 | + TRX_OFFS_FW_LEN_IDX = 0, /* Size of the fw; used in uncompressed case */ |
---|
| 107 | + TRX_OFFS_TR_RST_IDX = 1, /* RAM address[tr_rst] for jump to after download */ |
---|
| 108 | + TRX_OFFS_DSG_LEN_IDX = 2, /* Len of digital signature */ |
---|
| 109 | + TRX_OFFS_CFG_LEN_IDX = 3 /* Len of config region */ |
---|
| 110 | +}; |
---|
92 | 111 | |
---|
93 | 112 | /* Compatibility */ |
---|
94 | 113 | typedef struct trx_header TRXHDR, *PTRXHDR; |
---|