Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
CTCaer
GitHub Repository: CTCaer/hekate
Path: blob/master/bdk/utils/tegra_bct.h
3694 views
1
/*
2
* Copyright (c) 2018-2022 CTCaer
3
*
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms and conditions of the GNU General Public License,
6
* version 2, as published by the Free Software Foundation.
7
*
8
* This program is distributed in the hope it will be useful, but WITHOUT
9
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11
* more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
15
*/
16
17
#ifndef TEGRA_BCT_H
18
#define TEGRA_BCT_H
19
20
#include <utils/types.h>
21
22
#include <mem/sdram_param_t210.h>
23
#include <mem/sdram_param_t210b01.h>
24
25
#define BCT_IRAM_ADDRESS 0x40000100
26
#define BCT_IRAM_ADDRESS_B01 0x40000464
27
28
#define BCT_BOOT_DEV_NONE 0
29
#define BCT_BOOT_DEV_SPI 3
30
#define BCT_BOOT_DEV_SDMMC 4
31
#define BCT_BOOT_DEV_USB3 9
32
#define BCT_BOOT_DEV_UART 11
33
34
// ECID is checked for the following.
35
#define BCT_SEC_DBG_JTAG BIT(0)
36
#define BCT_SEC_DBG_DEV BIT(1)
37
#define BCT_SEC_DBG_SPNID BIT(2)
38
#define BCT_SEC_DBG_SPID BIT(3)
39
#define BCT_SEC_DBG_NID BIT(4) // ECID not checked for T210B01.
40
#define BCT_SEC_DBG_DBG BIT(5) // ECID not checked for T210B01.
41
42
#define BCT_SDMMC_CFG_SDR25_SINGLE_PAGE 0
43
#define BCT_SDMMC_CFG_SDR52_MULTI_PAGE 1
44
#define BCT_SDMMC_CFG_SDR25_MULTI_PAGE 2
45
#define BCT_SDMMC_CFG_DDR52_MULTI_PAGE 3
46
#define BCT_SDMMC_CFG_DDR25_MULTI_PAGE 4
47
48
#define BCT_SPI_CFG_PIO_X1_20_4MHZ_SREAD 0
49
#define BCT_SPI_CFG_PIO_X1_19_2MHZ_SREAD 1
50
#define BCT_SPI_CFG_PIO_X4_51_0MHZ_QREAD 2
51
52
typedef struct _bct_bad_blocks_t
53
{
54
u32 used_entries; // For block table.
55
u8 virtual_block_size_log2;
56
u8 block_size_log2;
57
u8 block_table[512]; // Each bit is a block (4096 blocks).
58
59
u8 padding[10];
60
} bct_bad_blocks_t;
61
62
typedef struct _bct_sdmmc_dev_t210_t
63
{
64
u32 clk_div;
65
u32 bus_width;
66
u8 power_class_max;
67
u8 multi_block_max;
68
} bct_sdmmc_dev_t210_t;
69
70
typedef struct _bct_sdmmc_dev_t210b01_t
71
{
72
u8 sdmmc_config;
73
u8 power_class_max;
74
} bct_sdmmc_dev_t210b01_t;
75
76
typedef struct _bct_spi_dev_t210_t
77
{
78
u32 clk_src;
79
u8 clk_div;
80
u8 cmd_read_fast;
81
u8 page_size; // 0: 2KB, 1: 16KB.
82
} bct_spi_dev_t210_t;
83
84
typedef struct _bct_spi_dev_t210b01_t
85
{
86
u8 spi_config;
87
} bct_spi_dev_t210b01_t;
88
89
typedef struct _bct_usb3_dev_t
90
{
91
u8 clk_div;
92
u8 root_port;
93
u8 page_size; // 0: 2KB, 1: 16KB.
94
u8 oc_pin;
95
u8 vbus_en;
96
} bct_usb3_dev_t;
97
98
typedef union
99
{
100
bct_sdmmc_dev_t210_t sdmmc_params;
101
bct_spi_dev_t210_t spi_params;
102
bct_usb3_dev_t usb3_params;
103
104
u8 padding[64];
105
} bct_boot_dev_t210_t;
106
107
typedef union
108
{
109
bct_sdmmc_dev_t210b01_t sdmmc_params;
110
bct_spi_dev_t210b01_t spi_params;
111
112
u8 padding[64];
113
} bct_boot_dev_t210b01_t;
114
115
typedef struct _bct_bootloader_t210_t
116
{
117
u32 version;
118
u32 start_block;
119
u32 start_page;
120
121
u32 length; // Should be bl size + 16 and aligned to 16.
122
u32 load_addr;
123
u32 entrypoint;
124
u32 attributes; // ODM.
125
126
u8 aes_cmac_hash[16];
127
u8 rsa_pss_signature[256];
128
} bct_bootloader_t210_t;
129
130
typedef struct _bct_bootloader_t210b01_t
131
{
132
u32 start_block;
133
u32 start_page;
134
u32 version;
135
u32 padding;
136
} bct_bootloader_t210b01_t;
137
138
typedef struct _tegra_bct_t210_t
139
{
140
/* Unsigned section */
141
bct_bad_blocks_t bad_block_table;
142
143
u8 rsa_modulus[256];
144
u8 aes_cmac_hash[16];
145
u8 rsa_pss_signature[256];
146
147
u32 secprov_aes_key_num_insecure;
148
u8 secprov_aes_key[32];
149
150
u8 customer_data[204];
151
152
/* Signed section */
153
u8 random_aes_block[16];
154
155
u32 ecid[4];
156
157
u32 data_version; // 0x210001.
158
159
u32 block_size_log2;
160
u32 page_size_log2;
161
u32 partition_size;
162
163
u32 boot_dev_params_num;
164
u32 boot_dev_type;
165
bct_boot_dev_t210_t boot_dev_params;
166
167
u32 dram_params_num;
168
sdram_params_t210_t dram_params[4];
169
170
u32 bootloader_num;
171
bct_bootloader_t210_t bootLoader[4];
172
u32 bootloader_failback_en;
173
174
u32 sec_dbg_ctrl; // Copied to APBDEV_PMC_DEBUG_AUTHENTICATION. ECID checked.
175
176
u32 secprov_aes_key_num_secure;
177
178
u8 padding[20];
179
} tegra_bct_t210_t;
180
181
typedef struct _tegra_bct_t210b01_t
182
{
183
/* Unsigned section */
184
u32 rsa_key_size;
185
u32 padding0[3];
186
u8 rsa_modulus[256];
187
u8 rsa_exponent[256];
188
189
u8 aes_cmac_hash[16];
190
u8 rsa_pss_signature[256];
191
192
u8 secprov_aes_key[32];
193
u32 secprov_aes_key_num_insecure;
194
195
u8 padding_unsigned[12];
196
197
u8 customer_data0[208];
198
199
/* Signed section */
200
u8 random_aes_block0[16];
201
202
u32 boot_config0[4]; // Customer controlled features.
203
204
/// Unused space allocated for customer usage.
205
u32 customer_data1_signed[16];
206
207
/* Encrypted section (optionally) */
208
u8 random_aes_block1[16];
209
210
u32 ecid[4];
211
212
u32 data_version; // 0x210001.
213
214
u32 block_size_log2;
215
u32 page_size_log2;
216
u32 partition_size;
217
218
u32 boot_dev_params_num;
219
u32 boot_dev_type;
220
bct_boot_dev_t210b01_t boot_dev_params;
221
222
u32 dram_params_num;
223
sdram_params_t210b01_t dram_params[4];
224
225
u32 bootloader_num;
226
bct_bootloader_t210b01_t bootLoader[4];
227
228
u32 sec_dbg_ctrl; // Copied to APBDEV_PMC_DEBUG_AUTHENTICATION. ECID not checked.
229
u32 sec_dbg_ctrl_ecid; // Copied to APBDEV_PMC_DEBUG_AUTHENTICATION. ECID checked.
230
231
u32 boot_config1[4]; // Customer controlled features. bit0 AON TZRAM powergating enable
232
233
u32 customer_data2_signed[16]; // u32[0]: bl attributes.
234
235
u32 secprov_aes_key_num_secure;
236
237
u8 padding_signed[388];
238
} tegra_bct_t210b01_t;
239
240
typedef struct _bootLoader_hdr_t210b01_t
241
{
242
/* Unsigned section */
243
u8 aes_cmac_hash[16];
244
u8 rsa_pss_signature[256];
245
246
/* Signed section */
247
u8 salt[16]; // random_aes_block.
248
u8 bootLoader_sha256[16];
249
u32 version;
250
u32 length;
251
u32 load_addr;
252
u32 entrypoint;
253
u8 padding[16];
254
} bootLoader_hdr_t210b01_t;
255
256
#endif
257
258