huangcm
2025-04-07 511b111543524704f6182b374e489f5d0e51db8c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*
 * (C) Copyright 2007-2013
 * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
 * Jerry Wang <wangflord@allwinnertech.com>
 *
 * See file CREDITS for list of people who contributed to this
 * project.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 */
 
#ifndef  __toc_v2_h
#define  __toc_v2_h
 
 
#include "spare_head.h"
 
#define  TOC0_MAGIC             "TOC0.GLH"
#define  TOC_MAIN_INFO_MAGIC    0x89119800
 
#define  SECURE_SWITCH_OTHER   0
#define  SECURE_SWITCH_NORMAL  1
#define  SECURE_NON_SECUREOS   2
 
/*增加安全启动下,toc0的头部数据结构 */
typedef struct {
   u8 name[8];    /*字符串,可以更改,没有作限制 */
   u32 magic;     /*必须是0x89119800 */
   u32 check_sum; /*整个数据的校验和,参考现在boot0做法 */
 
   u32 serial_num; /*序列号,可以更改,没有限制 */
   u32 status;     /*可以更改,没有限制 */
 
   u32 items_nr;     /*总的项目个数,对TOC0来说,必须是2 */
   u32 length;       /*TOC0的长度 */
   u8  platform[4];  /*toc_platform[0]标示启动介质 */
           /*0:nand;1:卡0;2:卡2;3:spinor */
   u32 reserved[2];  /*保留位 */
   u32 end;          /*表示头部结构体结束,必须是0x3b45494d */
 
}
toc0_private_head_t;
 
//增加安全启动下,toc1的头部数据结构
typedef struct sbrom_toc1_head_info
{
   char name[16]    ;    //user can modify
   u32  magic    ;    //must equal TOC_U32_MAGIC
   u32  add_sum    ;
 
   u32  serial_num    ;    //user can modify
   u32  status        ;    //user can modify,such as TOC_MAIN_INFO_STATUS_ENCRYP_NOT_USED
 
   u32  items_nr;    //total entry number
   u32  valid_len;
   u32  version_main;    //only one byte
   u32  version_sub;   //two bytes
   u32  reserved[3];    //reserved for future
 
   u32  end;
}
sbrom_toc1_head_info_t;
 
 
typedef struct sbrom_toc1_item_info
{
   char name[64];            //such as ITEM_NAME_SBROMSW_CERTIF
   u32  data_offset;
   u32  data_len;
   u32  encrypt;            //0: no aes   //1: aes
   u32  type;                //0: normal file, dont care  1: key certif  2: sign certif 3: bin file
   u32  run_addr;          //if it is a bin file, then run on this address; if not, it should be 0
   u32  index;             //if it is a bin file, this value shows the index to run; if not
                          //if it is a certif file, it should equal to the bin file index
                          //that they are in the same group
                          //it should be 0 when it anyother data type
   u32  reserved[69];       //reserved for future;
   u32  end;
}sbrom_toc1_item_info_t;
 
 
typedef struct sbrom_toc0_config
{
   unsigned char        config_vsn[4];
   unsigned int          dram_para[32];      // dram参数
   int                      uart_port;          // UART控制器编号
   normal_gpio_cfg       uart_ctrl[2];        // UART控制器GPIO
   int                  enable_jtag;        // JTAG使能
   normal_gpio_cfg       jtag_gpio[5];        // JTAG控制器GPIO
   normal_gpio_cfg      storage_gpio[50];     // 存储设备 GPIO信息
                                            // 0-23放nand,24-31存放卡0,32-39放卡2
                                            // 40-49存放spi
   char                   storage_data[384];  // 0-159,存储nand信息;160-255,存放卡信息
   unsigned int       secure_dram_mbytes; //
   unsigned int       drm_start_mbytes;   //
   unsigned int       drm_size_mbytes;    //
   unsigned int       boot_cpu;           //
   special_gpio_cfg    a15_power_gpio;  //the gpio config is to a15 extern power enable gpio
   unsigned int       next_exe_pa;
   unsigned int       secure_without_OS;   //secure boot without semelis
   unsigned char       debug_mode;         //1:turn on printf; 0 :turn off printf
   unsigned char       power_mode;          /* 0:axp , 1: dummy pmu  */
   unsigned char       reserver[2];
   unsigned int        card_work_mode;
   unsigned int          res[2];               // 总共1024字节
 
}
sbrom_toc0_config_t;
 
#define RSA_BIT            (2048)
#define PK_MAX_LEN_BIT        (RSA_BIT*2)
#define PK_MAX_LEN_BYTE        (PK_MAX_LEN_BIT >> 3)
 
typedef struct SBROM_TOC0_KEY_ITEM_info {
   unsigned int    vendor_id;
   unsigned int    KEY0_PK_mod_len;
   unsigned int    KEY0_PK_e_len;
   unsigned int    KEY1_PK_mod_len;
   unsigned int    KEY1_PK_e_len;
   unsigned int    sign_len;
   unsigned char    KEY0_PK[PK_MAX_LEN_BYTE];
   unsigned char    KEY1_PK[PK_MAX_LEN_BYTE];
   unsigned char    reserve[32];
   unsigned char    sign[256];
} SBROM_TOC0_KEY_ITEM_info_t;
 
typedef struct SBROM_TOC0_ITEM_info {
   u32 name;
   u32 data_offset;
   u32 data_len;
   u32 status;
   u32 type;
   u32 run_addr;
   u32 reserved_1;
   u32 end;
}  SBROM_TOC0_ITEM_info_t;
 
#define ITEM_PARAMETER_NAME             "parameter"
#define ITEM_OPTEE_NAME            "optee"
#define ITEM_SCP_NAME            "scp"
#define ITEM_MONITOR_NAME        "monitor"
#define ITEM_UBOOT_NAME            "u-boot"
#define ITEM_LOGO_NAME            "logo"
#define ITEM_DTB_NAME            "dtb"
#define ITEM_SOCCFG_NAME        "soc-cfg"
#define ITEM_BDCFG_NAME            "board-cfg"
#define ITEM_ESM_IMG_NAME          "esm-img"
#define ITEM_SHUTDOWNCHARGE_LOGO_NAME    "shutdowncharge"
#define ITEM_ANDROIDCHARGE_LOGO_NAME    "androidcharge"
#define ITEM_EMMC_FW_NAME        "emmc-fw"
#define ITEM_NAME_SBROMSW_KEY        0x010303
 
#endif     //  ifndef __toc_h
 
/* end of toc.h */