bl_common.h
9.11 KB
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2005
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*****************************************************************************
*
* Filename:
* ---------
* bl_common.h
*
* Project:
* --------
* Bootloader
*
* Description:
* ------------
* Bootloader header, common definitions
*
* Author:
* -------
* -------
*
*============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*============================================================================
****************************************************************************/
/*****************************************************************************
[Note]
Following files/modules are currently shared by MAUI and Bootloader, or invoking MAUI components.
Must consult with the owner if the behavior is changed
For accessing cp15, initializing cache
--------------------------------------------------
cp15
cp15_clean_dcache
cp15_disable_alignment_fault
cp15_disable_dcache
cp15_disable_icache
cp15_disable_mmu
cp15_disable_rom_protect
cp15_drain_write_buffer
cp15_enable_dcache
cp15_enable_icache
cp15_enable_mmu
cp15_invalidate_dcache
cp15_invalidate_icache
cp15_is_dcache_enabled
cp15_is_icache_enabled
cp15_write_domain_access
cp15_write_tbbr
To turn on code cache
--------------------------------------------------
cache
MTKL1CACHE_InvalidAllCacheLines
MPUClearAllSetting
CodeCacheClearAllSetting
CodeCacheGetChannel
CodeCacheSetting
CodeCacheConfig
NAND driver
--------------------------------------------------
NAND_DevConfig, nand_dal
Crypto/Hashing for security platform
--------------------------------------------------
md5_engine
CHE_md5_init
CHE_md5_append
CHE_md5_finish
rc4_engine
che_rc4_set_key
che_rc4
sha1_engine
CHE_sha1_Init
CHE_sha1_append
CHE_sha1_finish
USBDL sharing USB driver with MAUI
--------------------------------------------------
usb_custom.obj
usbdl_debug_tool.obj
usbdl_pmu.obj
usbdl_usb.obj
usbdl_usb_drv.obj
usbdl_usb_resource.obj
usbdl_usbacm_adap.obj
usbdl_usbacm_drv.obj
Custom files for EMI/DRAM init
--------------------------------------------------
custom_emi
custom_InitDRAM
custom_setEMI
custom_flash
custom_get_NORFLASH_Base
custom_get_NORFLASH_Size
*****************************************************************************/
#ifndef _BOOTLOADER_COMMON_H
#define _BOOTLOADER_COMMON_H
#include "kal_general_types.h"
#include "bl_fota.h"
#include "bl_loader.h"
#include "bl_features.h"
#include "bl_custom.h"
#include "bl_setting.h"
#include "bl_status.h"
extern kal_uint32 custom_ROM_baseaddr(void);
extern kal_uint32 custom_ROM_LV_baseaddr(void);
extern kal_uint32 Load$$EXT_READ_ONLY$$Base;
//#define BL_DEBUG_PRINT dbg_print
#define BL_DEBUG_PRINT(...)
#if defined(BL_DEBUG)
#define BL_PRINT bl_print
#else
#define BL_PRINT(...)
#endif
#ifdef __BL_SLIM_DIV__
#define BL_SLIM_UDIV_R(N, D, R) (bl_slim_div(N, D, &R))
#define BL_SLIM_UDIV(N, D) (bl_slim_div(N, D, NULL))
#define BL_SLIM_UMOD(N, D) (bl_slim_mod(N, D))
#else
#define BL_SLIM_UDIV_R(N, D, R) (((R)=(N)%(D)), ((N)/(D)))
#define BL_SLIM_UDIV(N, D) ((N)/(D))
#define BL_SLIM_UMOD(N, D) ((N)%(D))
#endif
#define INVALID_START_ADDR (0xffffffff)
#define MAUI_START_ADDR_NOR ((kal_uint32)custom_ROM_baseaddr())
#define FACTORY_BIN_START_ADDR_NOR ((kal_uint32)custom_FACTORY_ROM_baseaddr())
#define MAUI_LV_ADDR_NOR ((kal_uint32)custom_ROM_LV_baseaddr())
#define BL_DA_SHARED_DATA_ID_FUNC_TBL_ADDR 1
#define BL_DA_SHARED_DATA_ID_SECURE_RO_ADDR 2
#define BL_DA_SHARED_DATA_ID_EXT_BL_UPDATE_INFO 3
#define BL_BOOTUP_FAIL_REASON_NONE 0
#define BL_BOOTUP_FAIL_REASON_UPDATE_IN_PROGRESS 1
#define BL_BOOTUP_FAIL_REASON_UNABLE_TO_READ_ILB 2
#define BL_BOOTUP_FAIL_PAIRED_VER_MISMATCHED 3
#define BL_BOOTUP_FAIL_UNSUPPORTED_MAUI_FEAUTRE 4
#define BL_BOOTUP_FAIL_LOADING_MAUI_HEAD_ERROR 5
#define BL_BOOTUP_FAIL_LOADING_MAUI_BODY_ERROR 6
#define BL_BOOTUP_FAIL_BACKUP_BL_EXECUTING 7
#define BL_BOOTUP_FAIL_REASON_FUNET_IN_PROGRESS 8
extern const kal_int8 BootLDVerno[];
extern kal_uint32 g_mauiFeatureCombination;
#ifdef __CUST_NEW__
extern const kal_uint8 gpio_usbdl_pin; //Defined by Drv Tool
#endif /* __CUST_NEW__ */
extern const kal_uint8 usbdlkey_position;
extern const kal_uint8 usbdlkey_position2;
extern const kal_uint8 usbdlkey_rescue_position;
extern const kal_uint8 usbdlkey_rescue_position2;
extern const kal_uint8 metakey_position;
extern const kal_uint16 usbdlauto_timeout;
extern const kal_bool usbdl_holding_mode;
#ifdef __SV5_ENABLED__
extern kal_uint32 g_maui_load_addr;
#else
extern const MTK_EXT_BL_INFO_v01 g_ExtBootloaderInfo;
extern kal_uint32 g_ExtBootloaderLen;
#endif /* __SV5_ENABLED__ */
#ifdef __EXT_BL_UPDATE__
extern BL_EXT_BL_UPDATE_INFO g_extBlUpdateInfo;
#endif /* __EXT_BL_UPDATE__ */
extern void bl_print(LOG_LEVEL level, kal_char *fmt, ...);
extern kal_uint32 GetBootloaderRegionBound(void);
extern kal_bool CheckFeatureCompatibility(kal_uint32 mauiFeatureSet);
extern kal_uint32 BlFeatureCombination(void);
extern kal_uint32 MauiFeatureCombination(void);
typedef enum {
BL_FREE_TO_DA = 1, // OK to load and execute DA
BL_FREE_DURING_EXECUTION = 2, // OK to execute DA but not for loading (Free to DA after jumping)
BL_EXCLUSIVE_TO_DA = 3 // DA should not use it even in the DA's life cycle
} BL_MEM_PERM;
typedef struct
{
kal_uint32 addr;
kal_uint32 len;
BL_MEM_PERM type;
} BL_MEM_REGION_INFO;
#endif /* _BOOTLOADER_COMMON_H */