blob: 9ec89d73c7f7335eca7e58cee99db583ce319d25 [file] [log] [blame]
yu.dongc33b3072024-08-21 23:14:49 -07001#!/usr/bin/perl
2#
3# Copyright Statement:
4# --------------------
5# This software is protected by Copyright and the information contained
6# herein is confidential. The software may not be copied and the information
7# contained herein may not be used or disclosed except with the written
8# permission of MediaTek Inc. (C) 2006
9#
10# BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
11# THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
12# RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
13# AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
14# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
15# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
16# NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
17# SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
18# SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
19# THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
20# NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
21# SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
22#
23# BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
24# LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
25# AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
26# OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
27# MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
28#
29# THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
30# WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
31# LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
32# RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
33# THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
34#
35#*****************************************************************************
36#*
37#* Filename:
38#* ---------
39#* scatGenBL.pl
40#*
41#* Project:
42#* --------
43#*
44#*
45#* Description:
46#* ------------
47#* This script designed as module to be include by top level perl script
48#*
49#* Author:
50#* -------
51#* Claudia Lo (mtk01876)
52#*
53#****************************************************************************/
54#use strict;
55BEGIN { push @INC, "pcore/" , './pcore/tools/' } # add additional library path
56use sysGenUtility; #pm file name without case sensitivity
57use FileInfoParser;
58
59my $feature_query_function_ptr;
60my $nfb;
61my $scatter_maui;
62my $emiinitcode_exist;
63my $emiinitcode_base;
64my $emiinitcode_size;
65my $sysram_base;
66my $sysram_size;
67my $maui_bootloader_base;
68my $maui_bootloader_size;
69my $maui_ext_bootloader_base;
70my $maui_ext_bootloader_size;
71my $g_MAKEFILE_ref;
72
731;
74
75#****************************************************************************
76# MAIN INTERFACE
77# input:
78#****************************************************************************
79sub scatGenBL_main
80{
81 my ($func, $bb, $rs, $bb_path, $scatter) = @_;
82
83 $feature_query_function_ptr = $func;
84 my $nand_flash_booting = &$func('nand_flash_booting');
85 my $emmc_booting = &$func('emmc_booting');
86 $nfb = "NONE";
87 if ((defined $nand_flash_booting) and ($nand_flash_booting ne "NONE"))
88 {
89 $nfb = $nand_flash_booting;
90 }
91 elsif ((defined $emmc_booting) and ($emmc_booting ne "NONE"))
92 {
93 $nfb = $emmc_booting;
94 }
95 $scatter_maui = $scatter;
96 $g_MAKEFILE_ref = &FileInfo::GetMakeFileRef(undef);
97
98 ### Parse MAUI scatter to get Sys RAM info
99 open (SCATTER_H, "<$scatter_maui") or &sysUtil::sysgen_die("$scatter_maui: file error!", __FILE__, __LINE__);
100 my $itcm_base;
101 while (<SCATTER_H>)
102 {
103 if (/\s*INTSRAM_CODE\s*(0x\w+)\s*\w*/)
104 {
105 $itcm_base = $1;
106 }
107 elsif (/\s*INTSRAM_MULTIMEDIA\s*(0x\w+)\s*\w*\s*(0x\w+)/)
108 {
109 $sysram_base = $1;
110 $sysram_size = $2;
111 }
112 elsif (/\s*EXT_BOOTLOADER\s*(0x\w+)\s*\w*\s*(0x\w+)/)
113 {
114 $maui_ext_bootloader_base = $1;
115 $maui_ext_bootloader_size = $2;
116 }
117 elsif (/\s*EXT_BOOTLOADER\s*(0x\w+)\s*\w*\s*/)
118 {
119 $maui_ext_bootloader_base = $1;
120 $maui_ext_bootloader_size = undef;
121 }
122 elsif (/^\s*BOOTLOADER\s*(0x\w+)\s*\w*\s*(0x\w+)/)
123 {
124 $maui_bootloader_base = $1;
125 $maui_bootloader_size = $2;
126 }
127 elsif (/^\s*BOOTLOADER\s*(0x\w+)\s*\w*\s*/)
128 {
129 $maui_bootloader_base = $1;
130 $maui_bootloader_size = undef;
131 }
132 }
133 $sysram_base = $itcm_base if (!defined $sysram_base);
134 close (SCATTER_H) or &sysUtil::sysgen_die("$scatter_maui: file error!", __FILE__, __LINE__);
135
136 ### Generate BL scatter
137 my $bl_scat_output;
138 if (&sysUtil::is_sv5($bb) == 1)
139 {
140 $bl_scat_output .= &layout_bl_sv5($bb, $rs, $nfb);
141 }
142 else
143 {
144 $bl_scat_output .= &layout_bl_sv3($bb, $rs, $nfb);
145 }
146
147 ### Generate EXT-BL scatter
148 my $ext_bl_scat_output = &layout_ext_bl($bb, $rs, $nfb);
149
150 # Finally , return output
151 return ($bl_scat_output, $ext_bl_scat_output);
152}
153
154#****************************************************************************
155# subroutine: BL SV3 Layout
156# return: the body strings
157#****************************************************************************
158sub layout_bl_sv3
159{
160 my ($bb, $rs, $nfb) = @_;
161
162 # --- --- ---
163 my %BBtbl_READ_ONLY_base =
164 (
165 'MT6268' => '0x92002000',
166 'MT6235' => '0x40002000',
167 'MT6235B' => '0x40002000',
168 'MT6236' => '0x40002000',
169 'MT6252' => '0x00000000',
170 'MT6253' => '0x00000000',
171 'MT6921' => '0x40002000',
172 );
173 my $read_only_base = '0x00000000'; # NOR+SV3 always starts from 0x0
174 $read_only_base = &config_query_hash_bb(\%BBtbl_READ_ONLY_base, $bb, __LINE__) if ($nfb ne 'NONE');
175 my $read_only_size = "";
176 $read_only_size = $maui_bootloader_size if($nfb eq 'NONE');
177 # --- --- ---
178 my $ev_read_only = &layout_read_only_ev($bb, $rs, $nfb, $read_only_base);
179
180 # --- --- ---
181 my $ev_hidden_bl_secure_mac = &layout_hidden_bl_secure_mac_ev();
182
183 my $mac_overlay;
184 if ($nfb ne 'NONE' or 1 == &FileInfo::is_SmartPhone($g_MAKEFILE_ref))
185 {
186 $mac_overlay = "OVERLAY";
187 }
188
189 # --- --- ---
190 my $layout = <<"__LAYOUT";
191READ_ONLY $read_only_base $read_only_size
192{
193$ev_read_only
194}
195
196;=========================================================================
197; This load region must be behind all the protected load region
198;=========================================================================
199; do NOT modify load region naming and pragma naming!
200;=========================================================================
201
202__HIDDEN_BL_SECURE_MAC +0x0 $mac_overlay
203{
204$ev_hidden_bl_secure_mac
205}
206
207__LAYOUT
208
209 return $layout;
210}
211
212#****************************************************************************
213# subroutine: BL SV5 Layout
214# return: the body strings
215#****************************************************************************
216sub layout_bl_sv5
217{
218 my ($bb, $rs, $nfb) = @_;
219
220 # --- --- ---
221 my %BBtbl_READ_ONLY_base =
222 (
223 'MT6276' => '0x50000000',
224 'MT6251' => '0x40020000',
225 'MT6256' => '0x91004000',
226 'MT6255' => '0x40000900',
227 'MT6280' => '0x7000a000',
228 'MT6922' => '0x40000900',
229 'MT6250' => '0x70008000',
230 );
231
232 my $read_only_base = &config_query_hash_bb(\%BBtbl_READ_ONLY_base, $bb, __LINE__);
233 my $read_only_size = "";
234 $read_only_size = $maui_bootloader_size if($nfb eq 'NONE');
235
236 # --- --- ---
237 my $ev_read_only = &layout_read_only_ev($bb, $rs, $nfb, $read_only_base);
238
239 # --- --- ---
240 my $layout = <<"__LAYOUT";
241READ_ONLY $read_only_base $read_only_size
242{
243$ev_read_only
244}
245
246__LAYOUT
247
248 return $layout;
249}
250
251#****************************************************************************
252# subroutine: EXT-BL Layout
253# return: the body strings
254#****************************************************************************
255sub layout_ext_bl
256{
257 my ($bb, $rs, $nfb) = @_;
258
259 # --- --- ---
260 my ($ext_bootloader_base, $ext_bootloader_size);
261 my $ext_bl_update_support = &$feature_query_function_ptr('ext_bl_update_support');
262 if (defined $ext_bl_update_support and $ext_bl_update_support eq 'TRUE')
263 {
264 ### NAND: ExtMem size - 1M, NOR/N+0: fixed
265 ### NAND: 1M, NOR: 512K, N+0:fixed
266 if ($bb eq 'MT6251')
267 {
268 $ext_bootloader_base = "0x40030000";
269 $ext_bootloader_size = "0x30000";
270 }
271 elsif ($nfb ne 'NONE' or 1 == &FileInfo::is_SmartPhone($g_MAKEFILE_ref))
272 {
273 $ext_bootloader_base = sprintf("0x%x", $rs - (1024*1024));
274 $ext_bootloader_size = sprintf("0x%x", (1024*1024));
275 }
276 else
277 {
278 $ext_bootloader_base = sprintf("0x%x", &sysUtil::query_cs1_addr($bb ,0, 1) + 72*1024);
279 $ext_bootloader_size = sprintf("0x%x", (512*1024));
280 }
281 }
282 else
283 {
284 if ($nfb ne 'NONE' or 1 == &FileInfo::is_SmartPhone($g_MAKEFILE_ref))
285 {
286 $ext_bootloader_base = sprintf("0x%x", $rs - (1024*1024));
287 $ext_bootloader_size = "";
288 }
289 else
290 {
291 $ext_bootloader_base = sprintf("0x%08x", hex($maui_ext_bootloader_base) & (~0xf8000000));
292 $ext_bootloader_size = $maui_ext_bootloader_size;
293 $ext_bootloader_base = sprintf("0x%08x", hex($maui_ext_bootloader_base)) if($bb eq "MT6255" or $bb eq "MT6280" or $bb eq "MT6922" or $bb eq "MT6250");
294 }
295 }
296
297 # --- --- ---
298 my $ev_ext_bootloader = &layout_ext_bootloader_ev($bb, $rs, $nfb, $read_only_base, $ext_bootloader_base);
299
300 # --- --- ---
301 my $layout = <<"__LAYOUT";
302EXT_BOOTLOADER $ext_bootloader_base $ext_bootloader_size
303{
304$ev_ext_bootloader
305}
306
307__LAYOUT
308
309 return $layout;
310}
311
312#****************************************************************************
313# subroutine: Layout :: READ_ONLY :: Exec View
314# input: BB chip, ram size [value]
315#****************************************************************************
316sub layout_read_only_ev
317{
318 my ($bb, $rs, $nfb, $read_only_base) = @_;
319
320 # --- --- ---
321 $READ_WRITE_BASE_6921 = (($bb eq 'MT6921') and ($nfb ne 'NONE')) ? '+0x0' : '0x50000000';
322 my %BBtbl_READ_WRITE_base =
323 (
324 'MT6276' => '+0x0',
325 'MT6268' => '+0x0',
326 'MT6235' => '+0x0',
327 'MT6235B' => '+0x0',
328 'MT6236' => '+0x0',
329 'MT6921' => $READ_WRITE_BASE_6921,
330 'MT6252' => '0x40009000',
331 'MT6251' => '+0x0',
332 'MT6253' => '0x40000000',
333 'MT6256' => '+0x0',
334 'MT6255' => '+0x0',
335 'MT6922' => '+0x0',
336 'MT6250' => '+0x0',
337 'MT6280' => '+0x0',
338 );
339
340 my %BBtbl_READ_ONLY_INT_base =
341 (
342 'MT6276' => '0x5000C000',
343 'MT6268' => '0x92014000',
344 'MT6235' => '0x50008000',
345 'MT6235B' => '0x50008000',
346 'MT6236' => '0x50008000',
347 'MT6921' => '0x50008000',
348 'MT6252' => '+0x0',
349 'MT6251' => '+0x0',
350 'MT6253' => '+0x0',
351 'MT6256' => '0x50000000',
352 'MT6255' => '0x50000000',
353 'MT6280' => '0x70018000',
354 'MT6922' => '0x50000000',
355 'MT6250' => '0x70004940',
356 );
357
358 my %BBtbl_READ_WRITE_INT_base =
359 (
360 'MT6276' => '0x5004C000',
361 'MT6268' => '0x50048000',
362 'MT6235' => '0x5002E000',
363 'MT6235B' => '0x5002E000',
364 'MT6236' => '0x5004E000',
365 'MT6921' => '0x5004E000',
366 'MT6252' => '+0x0',
367 'MT6251' => '+0x0',
368 'MT6253' => '+0x0',
369 'MT6256' => '0x9100C000',
370 'MT6255' => '0x40006000',
371 'MT6280' => '+0x0',
372 'MT6922' => '0x40006000',
373 'MT6250' => '+0x0',
374 );
375
376 my %BBtbl_EMIINIT_CODE_base =
377 (
378 'MT6252' => '0x40008000',
379 'MT6251' => '0x40000080',
380 'MT6253' => '0x40000000',
381 'MT6255' => '0x40000080',
382 'MT6922' => '0x40000080',
383 'MT6921' => '0x50000000',
384 );
385
386 my %BBtbl_STACK_AREA_base =
387 (
388 'MT6276' => '0x5004F000',
389 'MT6268' => '0x50052800',
390 'MT6235' => '0x50033000',
391 'MT6235B' => '0x50033000',
392 'MT6236' => '0x50053000',
393 'MT6921' => '0x50053000',
394 'MT6252' => '0x4000BC00',
395 'MT6251' => '0x4005E000',
396 'MT6253' => '0x4001F000',
397 'MT6256' => '0x50042000',
398 'MT6255' => '0x50041000',
399 'MT6280' => '0x7001f000',
400 'MT6922' => '0x50041000',
401 'MT6250' => '0x7000c400',
402 );
403
404 my %BBtbl_DUMMY_END_base =
405 (
406 'MT6276' => '0xC8014000',
407 'MT6268' => '0x92018000',
408 'MT6235' => '0x40010000',
409 'MT6235B' => '0x40010000',
410 'MT6236' => '0x40010000',
411 'MT6921' => '0x40010000',
412 'MT6252' => '0x4000cc00',
413 'MT6251' => '0x40060000',
414 'MT6253' => '0x40020000',
415 'MT6256' => '0x91010000',
416 'MT6255' => '0x40007000',
417 'MT6280' => '0x70038000',
418 'MT6922' => '0x40007000',
419 'MT6250' => '0x7000d400',
420 );
421
422 # --- --- ---
423 ### NAND: ExtMem size - 4M, NOR: ExtMem size - 1.5M, N+0: fixed
424 my $ext_un_init_base;
425 if ($bb eq 'MT6251')
426 {
427 $ext_un_init_base = "0x40007000";
428 }
429 elsif ($nfb ne 'NONE' or 1 == &FileInfo::is_SmartPhone($g_MAKEFILE_ref))
430 {
431 $ext_un_init_base = sprintf("0x%x", $rs - (4*1024*1024));
432 }
433 else
434 {
435 $ext_un_init_base = sprintf("0x%x", &sysUtil::query_cs1_addr($bb, 0, 1) + ($rs - (1.5*1024*1024)));
436 }
437
438 # --- --- ---
439 ### NAND: 8K, NOR: 8K, N+0: Last 8K of IntRam
440 ### N+0:4K, others: 64K
441 my ($share_buf_base, $share_buf_size);
442 if ($bb eq 'MT6251')
443 {
444 $share_buf_base = "0x4005F000";
445 $share_buf_size = "0x1000"
446 }
447 elsif ($nfb ne 'NONE' or 1 == &FileInfo::is_SmartPhone($g_MAKEFILE_ref))
448 {
449 $share_buf_base = sprintf("0x%x", 8*1024);
450 $share_buf_size = "0x10000";
451 }
452 else
453 {
454 $share_buf_base = sprintf("0x%x", &sysUtil::query_cs1_addr($bb,0, 1)+(8*1024));
455 $share_buf_size = "0x10000";
456 }
457
458 # --- --- ---
459 my @bl_gfh_section_libs = split("\n", &BL_GFH_SECTION_EV());
460 map { s/^\s+//; } @bl_gfh_section_libs;
461
462 my @read_only_libs = split("\n", &READ_ONLY_EV());
463 map { s/^\s+//; } @read_only_libs;
464
465 my @read_only_head_libs = split("\n", &READ_ONLY_HEAD_EV());
466 map { s/^\s+//; } @read_only_head_libs;
467
468 my @read_only_int_libs = split("\n", &READ_ONLY_INT_EV());
469 map { s/^\s+//; } @read_only_int_libs;
470
471 my @read_write_int_libs = split("\n", &READ_WRITE_INT_EV());
472 map { s/^\s+//; } @read_write_int_libs;
473
474 my @stack_area_libs = split("\n", &STACK_AREA_EV());
475 map { s/^\s+//; } @stack_area_libs;
476
477 my @ext_un_init_libs = split("\n", &EXT_UN_INIT_EV());
478 map { s/^\s+//; } @ext_un_init_libs;
479
480 # --- --- ---
481 my $template;
482 if (&sysUtil::is_sv5($bb) == 1) # Only generate on SV5 platform
483 {
484 $template .= &format_execution_view('BL_GFH_SECTION',
485 '+0x0',
486 undef,
487 \@bl_gfh_section_libs);
488 }
489 $template .= &format_execution_view('READ_ONLY',
490 '+0x0',
491 undef,
492 \@read_only_libs);
493 $template .= &format_execution_view('READ_ONLY_HEAD',
494 '+0x0',
495 undef,
496 \@read_only_head_libs);
497 if (&sysUtil::is_sv5($bb) != 1) # Only generate on non-SV5 platform
498 {
499 my $bl_alg_table_base = sprintf("0x%x FIXED", hex($read_only_base)+0x400);
500 $template .= &format_execution_view('BL_ALG_TABLE',
501 $bl_alg_table_base,
502 undef,
503 ["*.obj (BL_ALG_TABLE)"]);
504 $template .= &format_execution_view('BL_SECINFO',
505 '+0x0',
506 undef,
507 ["*.obj (BL_SECINFO)"]);
508 }
509 $template .= &format_execution_view('READ_ONLY_TAIL',
510 '+0x0',
511 undef,
512 ["* (+RO)"]);
513 $template .= &format_execution_view('READ_WRITE',
514 &config_query_hash_bb(\%BBtbl_READ_WRITE_base, $bb, __LINE__),
515 undef,
516 ["* (+RW, +ZI)"]);
517 $template .= &format_execution_view('READ_ONLY_INT',
518 &config_query_hash_bb(\%BBtbl_READ_ONLY_INT_base, $bb, __LINE__),
519 undef,
520 \@read_only_int_libs);
521 $template .= &format_execution_view('READ_WRITE_INT',
522 &config_query_hash_bb(\%BBtbl_READ_WRITE_INT_base, $bb, __LINE__),
523 undef,
524 \@read_write_int_libs);
525 if ((&sysUtil::is_sv5($bb) == 1) or ($nfb ne 'NONE') or 1 == &FileInfo::is_SmartPhone($g_MAKEFILE_ref) )
526 {
527 $template .= &format_execution_view('EMIINIT_CODE',
528 '+0x0',
529 undef,
530 ["* (EMIINITZI)"]);
531 }
532 else
533 {
534 my $emiinit_code_base = &config_query_hash_bb(\%BBtbl_EMIINIT_CODE_base, $bb, __LINE__) . " OVERLAY";
535 $template .= &format_execution_view('EMIINIT_CODE',
536 $emiinit_code_base,
537 undef,
538 ["* (EMIINITCODE, EMIINITCONST, EMIINITRW, EMIINITZI)"]);
539 }
540 $template .= &format_execution_view('STACK_AREA_NOINIT',
541 &config_query_hash_bb(\%BBtbl_STACK_AREA_base, $bb, __LINE__),
542 '0x1000',
543 \@stack_area_libs);
544 $template .= &format_execution_view('EXT_UN_INIT_NOINIT',
545 $ext_un_init_base,
546 undef,
547 \@ext_un_init_libs);
548 $template .= &format_execution_view('SHARE_BUF_NOINIT',
549 $share_buf_base,
550 $share_buf_size,
551 ["* (MINI_EXT_DA_SHARE)"]);
552 if ($nfb ne 'NONE' or 1 == &FileInfo::is_SmartPhone($g_MAKEFILE_ref)) # Only generate on NFB
553 {
554 $template .= &format_execution_view('READ_WRITE_SYS_RAM',
555 $sysram_base,
556 '0x2000',
557 ["bl_ImageLoaderCommon.obj (BL_INFO_SHARED_ZI)"]);
558 }
559 $template .= &format_execution_view('DUMMY_END',
560 &config_query_hash_bb(\%BBtbl_DUMMY_END_base, $bb, __LINE__),
561 '0x04',
562 ["bl_bootarm_rvct.obj (DUMMY_POOL)"]);
563 if (&sysUtil::is_sv5($bb) == 1) # Only generate on SV5 platform
564 {
565 $template .= &format_execution_view('BL_SIGNATURE_SECTION',
566 '+0x0',
567 undef,
568 ["* (BL_SIGNATURE_SECTION)"]);
569 }
570 chomp $template;
571 return $template;
572}
573
574#****************************************************************************
575# subroutine: Layout :: EXT_BOOTLOADER :: Exec View
576# input: BB chip, ram size [value]
577#****************************************************************************
578sub layout_ext_bootloader_ev
579{
580 my ($bb, $rs, $nfb, $read_only_base, $ext_bootloader_base) = @_;
581
582 # --- --- ---
583 my %BBtbl_EXT_READ_ONLY_INT_base =
584 (
585 'MT6276' => '0x5000C000',
586 'MT6268' => '0x92014000',
587 'MT6235' => '0x50008000',
588 'MT6235B' => '0x50008000',
589 'MT6236' => '0x50008000',
590 'MT6921' => '0x50008000',
591 'MT6252' => '0x40008080',
592 'MT6251' => '+0x0',
593 'MT6253' => '0x40000080',
594 'MT6256' => '0x50000000',
595 'MT6255' => '0x50000000',
596 'MT6280' => '0x70018000',
597 'MT6922' => '0x50000000',
598 'MT6250' => '0x700040c0',
599 );
600
601 my %BBtbl_EXT_READ_WRITE_INT_base =
602 (
603 'MT6276' => '0x5004C000',
604 'MT6268' => '0x50048000',
605 'MT6235' => '0x5002E000',
606 'MT6235B' => '0x5002E000',
607 'MT6236' => '0x5004E000',
608 'MT6921' => '0x5004E000',
609 'MT6252' => '+0x0',
610 'MT6251' => '+0x0',
611 'MT6253' => '+0x0',
612 'MT6256' => '0x9100C000',
613 'MT6255' => '0x40006000',
614 'MT6280' => '+0x0',
615 'MT6922' => '0x40006000',
616 'MT6250' => '+0x0',
617 );
618
619 my %BBtbl_STACK_AREA_base =
620 (
621 'MT6276' => '0x5004F000',
622 'MT6268' => '0x50052800',
623 'MT6235' => '0x50033000',
624 'MT6235B' => '0x50033000',
625 'MT6236' => '0x50053000',
626 'MT6921' => '0x50053000',
627 'MT6252' => '0x4000BC00',
628 'MT6251' => '0x4005E000',
629 'MT6253' => '0x4001F000',
630 'MT6256' => '0x50042000',
631 'MT6255' => '0x50041000',
632 'MT6280' => '0x7001f000',
633 'MT6922' => '0x50041000',
634 'MT6250' => '0x7000c400',
635 );
636
637 my %BBtbl_BL_INFO_NOR_base = #Sysram Base
638 (
639 'MT6252' => '0x40008000',
640 'MT6251' => '0x40000080',
641 'MT6253' => '0x40000000',
642 'MT6921' => '0x40000000',
643 'MT6255' => '0x40000000',
644 'MT6280' => '0x70000040',
645 );
646
647 my %BBtbl_DUMMY_END_base =
648 (
649 'MT6276' => '0xC8014000',
650 'MT6268' => '0x92018000',
651 'MT6235' => '0x40010000',
652 'MT6235B' => '0x40010000',
653 'MT6236' => '0x40010000',
654 'MT6921' => '0x40010000',
655 'MT6252' => '0x4000cc00',
656 'MT6251' => '0x40060000',
657 'MT6253' => '0x40020000',
658 'MT6256' => '0x91010000',
659 'MT6255' => '0x40007000',
660 'MT6280' => '0x70038000',
661 );
662
663 # --- --- ---
664 my $ext_read_write_base;
665 my $ext_bl_update_support = &$feature_query_function_ptr('ext_bl_update_support');
666 if ($nfb ne 'NONE' or (defined $ext_bl_update_support and $ext_bl_update_support eq 'TRUE')
667 or 1 == &FileInfo::is_SmartPhone($g_MAKEFILE_ref))
668 {
669 $ext_read_write_base = "+0x0";
670 }
671 else
672 {
673 if ($bb eq 'MT6251')
674 {
675 $ext_read_write_base = "0x40030000";
676 }
677 else
678 {
679 $ext_read_write_base = sprintf("0x%x", &sysUtil::query_cs1_addr($bb,0, 1) + 72*1024);
680 }
681 }
682
683 # --- --- ---
684 ### NAND: ExtMem size - 4M, NOR: ExtMem size - 1.5M, N+0: fixed
685 my $ext_un_init_base;
686 if ($bb eq 'MT6251')
687 {
688 $ext_un_init_base = "0x40007000";
689 }
690 elsif ($nfb ne 'NONE' or 1 == &FileInfo::is_SmartPhone($g_MAKEFILE_ref))
691 {
692 $ext_un_init_base = sprintf("0x%x", $rs - (4*1024*1024));
693 }
694 else
695 {
696 $ext_un_init_base = sprintf("0x%x", &sysUtil::query_cs1_addr($bb,0, 1) + ($rs - (1.5*1024*1024)));
697 }
698
699 # --- --- ---
700 ### NAND: 8K, NOR: 8K, N+0: Last 8K of IntRam
701 ### N+0:4K, others: 64K
702 my ($share_buf_base, $share_buf_size);
703 if ($bb eq 'MT6251')
704 {
705 $share_buf_base = "0x4005F000";
706 $share_buf_size = "0x1000"
707 }
708 elsif ($nfb ne 'NONE' or 1 == &FileInfo::is_SmartPhone($g_MAKEFILE_ref))
709 {
710 $share_buf_base = sprintf("0x%x", 8*1024);
711 $share_buf_size = "0x10000";
712 }
713 else
714 {
715 $share_buf_base = sprintf("0x%x", &sysUtil::query_cs1_addr($bb,0, 1)+(8*1024));
716 $share_buf_size = "0x10000";
717 }
718
719 # --- --- ---
720 my @ext_read_only_head_libs = split("\n", &EXT_READ_ONLY_HEAD_EV());
721 map { s/^\s+//; } @ext_read_only_head_libs;
722
723 my @ext_read_only_int_libs = split("\n", &EXT_READ_ONLY_INT_EV($bb));
724 map { s/^\s+//; } @ext_read_only_int_libs;
725
726 my @ext_read_write_int_libs = split("\n", &EXT_READ_WRITE_INT_EV($bb));
727 map { s/^\s+//; } @ext_read_write_int_libs;
728
729 my @da_share_libs = split("\n", &DA_SHARE_EV());
730 map { s/^\s+//; } @da_share_libs;
731
732 my @ext_un_init_libs = split("\n", &EXT_UN_INIT_EV());
733 map { s/^\s+//; } @ext_un_init_libs;
734
735 # --- --- ---
736 my $template;
737 if (&sysUtil::is_sv5($bb) == 1) # Only generate on SV5 platform
738 {
739 $template .= &format_execution_view('EXT_BL_GFH_SECTION',
740 '+0x0',
741 undef,
742 ["* (EXT_BOOTLOADER_GFH, +First)"]);
743 }
744 $template .= &format_execution_view('EXT_READ_ONLY',
745 '+0x0',
746 undef,
747 ["bl_bootarm_rvct.obj (VECTOR_TBL, +First)"]);
748 $template .= &format_execution_view('EXT_READ_ONLY_HEAD',
749 '+0x0',
750 undef,
751 \@ext_read_only_head_libs);
752 if (&sysUtil::is_sv5($bb) != 1) # Only generate on non-SV5 platform
753 {
754 my $ext_bl_alg_table_base = sprintf("0x%x FIXED", hex($ext_bootloader_base)+0x400);
755 $template .= &format_execution_view('BL_ALG_TABLE',
756 $ext_bl_alg_table_base,
757 undef,
758 ["*.obj (BL_ALG_TABLE)"]);
759 $template .= &format_execution_view('BL_SECINFO',
760 '+0x0',
761 undef,
762 ["*.obj (BL_SECINFO)"]);
763 }
764 $template .= &format_execution_view('EXT_READ_ONLY_TAIL',
765 '+0x0',
766 undef,
767 ["* (+RO)"]);
768 $template .= &format_execution_view('EXT_READ_WRITE',
769 $ext_read_write_base,
770 undef,
771 ["* (+RW, +ZI)"]);
772 $template .= &format_execution_view('EXT_READ_ONLY_INT',
773 &config_query_hash_bb(\%BBtbl_EXT_READ_ONLY_INT_base, $bb, __LINE__),
774 undef,
775 \@ext_read_only_int_libs);
776 $template .= &format_execution_view('EXT_READ_WRITE_INT',
777 &config_query_hash_bb(\%BBtbl_EXT_READ_WRITE_INT_base, $bb, __LINE__),
778 undef,
779 \@ext_read_write_int_libs);
780 if ($bb eq 'MT6251')
781 {
782 $template .= &format_execution_view('DA_SHARE',
783 '0x40000A00',
784 undef,
785 \@da_share_libs);
786 }
787 $template .= &format_execution_view('STACK_AREA_NOINIT',
788 &config_query_hash_bb(\%BBtbl_STACK_AREA_base, $bb, __LINE__),
789 '0x1000',
790 ["bl_bootarm_rvct.obj (STACK_POOL_INTSRAM)"]);
791 $template .= &format_execution_view('EXT_UN_INIT_NOINIT',
792 $ext_un_init_base,
793 undef,
794 \@ext_un_init_libs);
795 $template .= &format_execution_view('SHARE_BUF_NOINIT',
796 $share_buf_base,
797 $share_buf_size,
798 ["* (MINI_EXT_DA_SHARE)"]);
799 if ($nfb ne 'NONE' or 1 == &FileInfo::is_SmartPhone($g_MAKEFILE_ref)) # Only generate on NFB
800 {
801 $template .= &format_execution_view('READ_WRITE_SYS_RAM',
802 $sysram_base,
803 '0x2000',
804 ["bl_ImageLoaderCommon.obj (BL_INFO_SHARED_ZI)"]);
805 }
806 else # Only generate on NOR
807 {
808 $template .= &format_execution_view('BL_INFO_NOR',
809 &config_query_hash_bb(\%BBtbl_BL_INFO_NOR_base, $bb, __LINE__),
810 '0x80',
811 ["*.obj (BL_INFO_SHARED_ZI)"]);
812 }
813 $template .= &format_execution_view('DUMMY_END',
814 &config_query_hash_bb(\%BBtbl_DUMMY_END_base, $bb, __LINE__),
815 '0x04',
816 ["bl_bootarm_rvct.obj (DUMMY_POOL)"]);
817 if (&sysUtil::is_sv5($bb) == 1) # Only generate on SV5 platform
818 {
819 $template .= &format_execution_view('EXT_BL_SIGNATURE_SECTION',
820 '+0x0',
821 undef,
822 ["* (EXT_BL_SIGNATURE_SECTION)"]);
823 }
824 chomp $template;
825 return $template;
826}
827
828#****************************************************************************
829# subroutine: Layout :: __HIDDEN_BL_SECURE_MAC :: Exec View
830# input: BB chip, ram size [value]
831#****************************************************************************
832sub layout_hidden_bl_secure_mac_nfb_ev
833{
834 my $template;
835 $template .= &format_execution_view('__HIDDEN_BL_SECURE_MAC',
836 '+0x0 OVERLAY',
837 undef,
838 ["*.obj (BL_SECURE_MAC_SIZE)"]);
839 $template .= &format_execution_view('__HIDDEN_BL_SECURE_MAC_CONTENT',
840 '+0x0 OVERLAY',
841 undef,
842 ["*.obj (BL_SECURE_MAC_CONTENT)"]);
843 $template .= &format_execution_view('__HIDDEN_SECURE_MAC',
844 '+0x0 OVERLAY',
845 undef,
846 ["*.obj (FOTA_SECINFO)"]);
847 chomp $template;
848 return $template;
849}
850
851#****************************************************************************
852# subroutine: Layout :: __HIDDEN_BL_SECURE_MAC :: Exec View
853# input: BB chip, ram size [value]
854#****************************************************************************
855sub layout_hidden_bl_secure_mac_ev
856{
857 my $template;
858 $template .= &format_execution_view('__HIDDEN_BL_SECURE_MAC',
859 '+0x0',
860 undef,
861 ["*.obj (BL_SECURE_MAC_SIZE)"]);
862 $template .= &format_execution_view('__HIDDEN_BL_SECURE_MAC_CONTENT',
863 '+0x0',
864 undef,
865 ["*.obj (BL_SECURE_MAC_CONTENT)"]);
866 $template .= &format_execution_view('__HIDDEN_SECURE_MAC',
867 '+0x0',
868 undef,
869 ["*.obj (FOTA_SECINFO)"]);
870 chomp $template;
871 return $template;
872}
873
874#****************************************************************************
875# subroutine: NFB Layout :: EXT_READ_ONLY
876# return: the body strings
877#****************************************************************************
878sub BL_GFH_SECTION_EV
879{
880 my $template = <<"__TEMPLATE";
881 * (BOOTLOADER_GFH, +First)
882 * (BOOTLOADER_GFH_EXT)
883__TEMPLATE
884
885 return $template;
886}
887
888#****************************************************************************
889# subroutine: Layout :: READ_ONLY
890# return: the body strings
891#****************************************************************************
892sub READ_ONLY_EV
893{
894 my $template .= <<"__TEMPLATE";
895 bl_bootarm_rvct.obj (VECTOR_TBL, +First)
896 * (BL_RESV_REGION)
897__TEMPLATE
898
899 return $template;
900}
901
902#****************************************************************************
903# subroutine: Layout :: READ_ONLY_HEAD
904# return: the body strings
905#****************************************************************************
906sub READ_ONLY_HEAD_EV
907{
908 my $template .= <<"__TEMPLATE";
909 bl_bootarm_rvct.obj (C\$\$code, +First)
910 *.obj (HEAD_BL)
911 * (INIT_CODE)
912__TEMPLATE
913
914 return $template;
915}
916
917#****************************************************************************
918# subroutine: Layout :: READ_ONLY_INT
919# return: the body strings
920#****************************************************************************
921sub READ_ONLY_INT_EV
922{
923 my $template = <<"__TEMPLATE";
924 sha1_engine.obj (+RO)
925 md5_engine.obj (+RO)
926 br_crypto_asm.obj (+RO)
927 br_crypto_drv*.obj (+RO)
928 br_sha256_sw.obj (+RO)
929 br_sha256_hw.obj (+RO)
930 br_sha1_sw.obj (+RO)
931 br_sha1_hw.obj (+RO)
932 br_rsa_sw.obj (+RO)
933 br_M1_rsa.obj (+RO)
934 br_crypto_platform.obj (+RO)
935 * (INTERNCODE)
936__TEMPLATE
937
938 return $template;
939}
940
941#****************************************************************************
942# subroutine: Layout :: READ_ONLY_INT
943# return: the body strings
944#****************************************************************************
945sub READ_WRITE_INT_EV
946{
947 my $template = <<"__TEMPLATE";
948 sha1_engine.obj (+RW, +ZI)
949 md5_engine.obj (+RW, +ZI)
950 br_crypto_asm.obj (+RW, +ZI)
951 br_crypto_drv*.obj (+RW, +ZI)
952 br_sha256_sw.obj (+RW, +ZI)
953 br_sha256_hw.obj (+RW, +ZI)
954 br_sha1_sw.obj (+RW, +ZI)
955 br_sha1_hw.obj (+RW, +ZI)
956 br_rsa_sw.obj (+RW, +ZI)
957 br_M1_RSA.obj (+RW, +ZI)
958 br_crypto_platform.obj (+RW, +ZI)
959 * (INTERNDATA)
960__TEMPLATE
961
962 return $template;
963}
964
965#****************************************************************************
966# subroutine: Layout :: STACK_AREA
967# return: the body strings
968#****************************************************************************
969sub STACK_AREA_EV
970{
971 my $template = <<"__TEMPLATE";
972 bl_bootarm_rvct.obj (STACK_POOL_INTSRAM)
973 br_time_stamp.obj (UN_INIT_RW, UN_INIT_ZI)
974__TEMPLATE
975
976 return $template;
977}
978
979#****************************************************************************
980# subroutine: Layout :: EXT_UN_INIT
981# return: the body strings
982#****************************************************************************
983sub EXT_UN_INIT_EV
984{
985 my $template = <<"__TEMPLATE";
986 * (EXT_UN_INIT_RW, EXT_UN_INIT_ZI)
987 bl_cache.obj (BL_PAGETABLE)
988__TEMPLATE
989
990 return $template;
991}
992
993#****************************************************************************
994# subroutine: EXT_READ_ONLY_HEAD
995# return: the body strings
996#****************************************************************************
997sub EXT_READ_ONLY_HEAD_EV
998{
999 my $template = <<"__TEMPLATE";
1000 bl_bootarm_rvct.obj (C\$\$code, +First)
1001 *.obj (HEAD_BL)
1002 * (INIT_CODE)
1003__TEMPLATE
1004
1005 return $template;
1006}
1007
1008#****************************************************************************
1009# subroutine: Layout :: EXT_READ_ONLY_INT
1010# return: the body strings
1011#****************************************************************************
1012sub EXT_READ_ONLY_INT_EV
1013{
1014 my ($bb) = @_;
1015
1016 my $template;
1017 if ($bb eq 'MT6251')
1018 {
1019 $template = <<"__TEMPLATE";
1020 br_crypto_asm.obj (+RO)
1021 br_crypto_drv*.obj (+RO)
1022 br_sha256_sw.obj (+RO)
1023 br_sha256_hw.obj (+RO)
1024 br_sha1_sw.obj (+RO)
1025 br_sha1_hw.obj (+RO)
1026 br_rsa_sw.obj (+RO)
1027 br_M1_rsa.obj (+RO)
1028 br_crypto_platform.obj (+RO)
1029 * (INTERNCODE)
1030__TEMPLATE
1031 }
1032 else
1033 {
1034 $template = <<"__TEMPLATE";
1035 sha1_engine.obj (+RO)
1036 md5_engine.obj (+RO)
1037 br_crypto_asm.obj (+RO)
1038 br_crypto_drv*.obj (+RO)
1039 br_sha256_sw.obj (+RO)
1040 br_sha256_hw.obj (+RO)
1041 br_sha1_sw.obj (+RO)
1042 br_sha1_hw.obj (+RO)
1043 br_rsa_sw.obj (+RO)
1044 br_M1_rsa.obj (+RO)
1045 br_crypto_platform.obj (+RO)
1046 * (INTERNCODE)
1047__TEMPLATE
1048 }
1049 my $serial_flash_stt_support = &$feature_query_function_ptr('serial_flash_stt_support');
1050 if (defined $serial_flash_stt_support and $serial_flash_stt_support eq 'TRUE')
1051 {
1052 my $stt_template = << "__TEMPLATE";
1053 divrt_9e.o (+RO)
1054 bl_STT_SF.obj (+RO)
1055 bl_DBGPRINT.obj (+RO)
1056 bl_UART.obj (+RO)
1057__TEMPLATE
1058 $template .= $stt_template;
1059 }
1060 return $template;
1061}
1062
1063#****************************************************************************
1064# subroutine: Layout :: EXT_READ_WRITE_INT
1065# return: the body strings
1066#****************************************************************************
1067sub EXT_READ_WRITE_INT_EV
1068{
1069 my ($bb) = @_;
1070
1071 my $template;
1072 if ($bb eq 'MT6251')
1073 {
1074 $template = <<"__TEMPLATE";
1075 br_crypto_asm.obj (+RW, +ZI)
1076 br_crypto_drv*.obj (+RW, +ZI)
1077 br_sha256_sw.obj (+RW, +ZI)
1078 br_sha256_hw.obj (+RW, +ZI)
1079 br_sha1_sw.obj (+RW, +ZI)
1080 br_sha1_hw.obj (+RW, +ZI)
1081 br_rsa_sw.obj (+RW, +ZI)
1082 br_M1_RSA.obj (+RW, +ZI)
1083 br_crypto_platform.obj (+RW, +ZI)
1084 * (INTERNDATA)
1085__TEMPLATE
1086 }
1087 else
1088 {
1089 $template = <<"__TEMPLATE";
1090 sha1_engine.obj (+RW, +ZI)
1091 md5_engine.obj (+RW, +ZI)
1092 br_crypto_asm.obj (+RW, +ZI)
1093 br_crypto_drv*.obj (+RW, +ZI)
1094 br_sha256_sw.obj (+RW, +ZI)
1095 br_sha256_hw.obj (+RW, +ZI)
1096 br_sha1_sw.obj (+RW, +ZI)
1097 br_sha1_hw.obj (+RW, +ZI)
1098 br_rsa_sw.obj (+RW, +ZI)
1099 br_M1_RSA.obj (+RW, +ZI)
1100 br_crypto_platform.obj (+RW, +ZI)
1101 * (INTERNDATA)
1102__TEMPLATE
1103 }
1104
1105 return $template;
1106}
1107
1108#****************************************************************************
1109# subroutine: Layout :: DA_SHARE
1110# return: the body strings
1111#****************************************************************************
1112sub DA_SHARE_EV
1113{
1114 my $template = <<"__TEMPLATE";
1115 *.l (+RO, +RW, +ZI)
1116 bl_bootarm_rvct.obj (SHARECODE)
1117 bl_DBGPRINT.obj (+RO, +RW, +ZI)
1118 bl_portingfunc.obj (+RO, +RW, +ZI)
1119 bl_UART.obj (+RO, +RW, +ZI)
1120 sha1_engine.obj (+RO, +RW, +ZI)
1121 md5_engine.obj (+RO, +RW, +ZI)
1122 M1_rsa.obj (+RO, +RW, +ZI)
1123 SSS_interface.obj (+RO, +RW, +ZI)
1124 SSS_secure_shared.obj (+RO, +RW, +ZI)
1125__TEMPLATE
1126
1127 return $template;
1128}
1129
1130#****************************************************************************
1131# subroutine: Execution View Generator
1132# input: Region name [string], Begin [string], Length [string], Content [Array Reference]
1133# output: execution view body string
1134#****************************************************************************
1135sub format_execution_view
1136{
1137 my ($name, $begin, $length, $ar) = @_;
1138 my $formated_string = ' ' x 4 . $name . " $begin $length\n";
1139 $formated_string .= ' ' x 4 . "{\n";
1140 foreach (@$ar)
1141 {
1142 $formated_string .= ' ' x 9 . $_ . "\n";
1143 }
1144 $formated_string .= ' ' x 4 . "}\n";
1145 return $formated_string;
1146}
1147
1148#****************************************************************************
1149# subroutine: config_query_hash_bb
1150# return: address/size defined in the input hash of the input bb
1151#****************************************************************************
1152sub config_query_hash_bb
1153{
1154 my ($href, $bb, $Line) = @_;
1155 if (not exists $href->{$bb})
1156 {
1157 print "pcore/tools/scatGenBL.pl:[Line$Line]Unsupported Bootloader Scatter information on $bb !\n";
1158 exit 0;
1159 }
1160
1161 return $href->{$bb};
1162}