blob: 4657646b0a98f6e4b37f483249478422f4059e6d [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#* sysGenUtility.pm
40#*
41#* Project:
42#* --------
43#*
44#*
45#* Description:
46#* ------------
47#* This module collects the subroutines for common utility.
48#*
49#*
50#* Author:
51#* -------
52#* Carl Kao (mtk08237)
53#*
54#****************************************************************************/
55
56#****************************************************************************
57# SYSGEN ERROR MESSAGE
58#****************************************************************************
59use FileInfoParser;
60
61package genERR;
62use constant SYSERR_1_1 => "SYSGEN ERROR: [1.1][Feature Option Related]";
63use constant SYSERR_1_2 => "SYSGEN ERROR: [1.2][Memory Expired]";
64use constant SYSERR_1_3 => "SYSGEN ERROR: [1.3][UnSupported/Wrong Configuration]";
65use constant SYSERR_1_4 => "SYSGEN ERROR: [1.4][File/Path doesn't exist]";
66use constant SYSERR_1_5 => "SYSGEN ERROR: [1.5][Other errors]";
67use constant SYSERR_2_0 => "SYSGEN ERROR: [2.0]";
68use constant SYSERR_3_1 => "SYSGEN ERROR: [3.1]";
69use constant SYSERR_3_2 => "SYSGEN ERROR: [3.2]";
70
71package sysUtil;
72use strict;
73use Cwd;
74#use warnings;
75
76#****************************************************************************
77# Constants
78#****************************************************************************
79
80my $SYSGENUTILITY_VERNO = " LR13_v0.08";
81 # LR13_v0.08 , 2018/07/30 , Frank, Added support for MT6779
82 # LR13_v0.07 , 2018/05/04 , Tero, Increased DSP TX size for EL1S
83 # LR13_v0.06 , 2017/12/17 , Tero, Added support for MT3967
84 # LR13_v0.05 , 2017/11/01 , Tero, Added support for MT6765
85 # LR13_v0.04 , 2017/09/27 , Tero, MT6771 Memory map updated
86 # LR13_v0.03 , 2017/08/22 , Tero, Add support for MT6771
87 # LR13_v0.02 , 2017/04/21 , Tero, Add support for MT6739
88 # LR13_v0.01 , 2016/12/22 , Tero, Enable AAPMC for MT6763
89 # LR12_v0.05 , 2016/02/17 , Tero, Added ELBRUS support for VoLTE_core_query_length
90 # LR12_v0.04 , 2016/01/31 , Tero, Added ELBRUS support for DSPTXRX_query_length
91 # LR12_v0.03 , 2016/01/18 , Tero, Temporaly Disable AAPMC for ELBRUS
92 # LR12_v0.02 , 2015/12/28 , Carl, Support user specifec lds
93 # LR12_v0.01, 2015/12/23, Carl, Change GetCacheablePrefix to bank6
94 # u0.21, 2015/07/20, Carl, Support ldsGen for MT6797
95 # u0.20, 2015/07/03, Carl, Add GetDefaultSharedMemorySize for setting default shared memory size
96 # u0.19, 2015/06/04, Carl, Support ldsGen for MT6755
97 # u0.18, 2015/05/11, Carl, Support Ramdisk for TK6291
98 # u0.17, 2015/02/06, disable isSupportedToAdjustLoadView for ESL COSIM
99 # u0.16, 2015/01/06, lds refinement: 1) auto adjust shared region size, 2) reserve pcore, l1core SWLA space
100 # u0.15, 2014/11/05, Align start address of shared memory section to 1MB
101 # u0.14, 2014/10/06, Increase default shared memory size to 48 MB
102 # u0.13, 2014/09/26, Support GFH + SIG
103 # u0.12, 2014/09/22, Rename MT6291 to TK6291
104 # u0.11, 2014/09/09, Revert default shared memory size since there are still shared memory users
105 # u0.10, 2014/09/05, Reduce default shared memory size for PCORE ONLY project
106 # ...
107 # m0.32, 2014/01/02, Let aapmc apply on modem only load for load view part
108 # m0.31, 2013/11/06, Support MT6595
109 # m0.30, 2013/09/11, MT6290=SV5
110 # m0.29, 2013/05/21, Support MT6290_COPRO
111 # m0.28, 2013/03/21, Support GetMD_AlignmentByChip()
112 # m0.27, 2013/02/03, Rename MT7208 to MT6290
113 # m0.26, 2013/01/24, Enable MT6280 to be able to auto-config LoadView part
114 # m0.25, 2013/01/16, Add isSupportedToAdjustLoadView() and isSupportedToAdjustRAMSize()
115 # m0.24, 2013/01/15, Support address prefix query function
116 # Remove useless chip
117 # m0.22, 2012/12/28, Add MT7208 into XIP_Shadowing
118 # m0.21, 2012/10/31, Refine Error Message not to meet \w+ for easier function naming in ldsGen
119 # m0.20, 2012/10/02, Support MT7208
120 # m0.17, 2012/09/02, Support ALPS database check-in history
121 # m0.16, [Reserved for WR8]
122 # m0.15, 2012/08/17, Support Total RAM size in smartphone
123 # Support MT6583 MD1/MD2
124 # m0.14, 2012/08/13, Support MT6577
125 # m0.13, 2012/08/07, Move Dec2Hex to CommonUtility.pm and add isDummyScatter()
126 # m0.12, 2012/07/24, Support sysgen common error code/messages.
127 # m0.11, 2012/07/12, Remove booting type query to FileInfoParser.pm
128 # m0.10, 2012/07/02, Remove PrintDependency() to use tools::pack_dep_gen; PrintDependModule();
129 # m0.09, 2012/07/02, Support SwitchToClonedChip
130 # m0.08, 2012/06/28, Support MOLY database check-in history
131 # m0.07, 2012/05/28, Support path and filename case sensitive on Linux
132 # m0.06, 2012/05/01, Support lds description_file_header
133 # m0.05, 2012/01/20, Support NOR for CR4
134 # m0.04, 2012/01/13, Support MT6280 BLscatGen
135 # m0.03, 2012/01/13, Remove MT6280 from SmartPhone
136 # m0.02, 2012/01/08, Support MT6280
137 # m0.01 , 2012/05/07, Move DSPTXRX_query_length from scatGenLib.pl to here.
138 # v0.22 , 2012/04/12, Modify GetIntsramInfo() to enhance 6250 FTE performance
139 # v0.21 , 2012/03/26, Modify the query method of vivaHelper.pm in query_viva_size()
140 # v0.20 , 2012/03/22, Add query_viva_size to support VIVA
141 # v0.19 , 2012/03/21, Support MT6250
142 # v0.18 , 2012/04/17, Support EWS to print file dependency
143 # v0.17 , 2012/02/14, Add check_cs1_base() and modify query_cs1_addr() to determine CS1 base address
144 # v0.16 , 2012/01/30, Support MT6922
145 # v0.15 , 2012/01/28, Add is_NOR() without supporting smartphone part
146 # v0.14 , 2012/01/08, Add is_CR4(), GetIntsramHWBoundary() and Support TK6280
147 # v0.13 , 2012/01/08, Add GetIntsramInfo() to get intsram CODE/DATA's information
148 # v0.12 , 2012/01/08, Remove has_cache()
149 # v0.11 , 2011/11/04, Remove phased-out chips and add is_arm7()
150 # v0.10 , 2011/10/29, modify query_cs1_addr for MT6255 bootloader workaround
151 # v0.09 , 2011/10/28, To support MT6255
152 # v0.08 , 2011/10/28, print an error message if the file can't be deleted
153 # v0.07 , 2011/10/10, Add has_cache()
154 # v0.06 , 2011/09/25, Move ChangeDefineValue() to auto_adjust_mem.pm and
155 # seperate HasCheckinHistory out from del_noCheckinHistory_file
156 # v0.05 , 2011/09/16, Add ChangeDefineValue() for common usage
157 # if needed to modify define value in some header files.
158 # v0.04 , 2011/09/15, Collect common functions which can be reused
159 # v0.02 , 2011/05/24, Support MT6921 in arm9 family
160 # v0.01 , 2011/03/30, Initial revision
161
162#****************************************************************************
163# oo >>> Finished
164#****************************************************************************
165return 1;
166
167#****************************************************************************
168# Subroutine: sysgenUtility_verno - to query this package's version number
169# Parameters: x
170# Returns: version number string
171#****************************************************************************
172sub sysgenUtility_verno
173{
174 return $SYSGENUTILITY_VERNO;
175}
176
177#****************************************************************************
178# Subroutine: GetIntsramInfo - to query INTSRAM_CODE and INTSRAM_DATA's Base/MaxSize
179# Parameters: BB chip (eg. MT6276)
180# Returns: $strCODEBase, $strCODESize, $strDATABase, $strDATASize
181#****************************************************************************
182sub GetIntsramInfo
183{#unsupported on ldsGen's chip
184 my ($bb) = @_;
185 my ($strCODEBase, $strCODESize, $strDATABase, $strDATASize) = (undef, undef, undef, undef);
186 my %BB_INTSRAM_tbl =
187 ( # $bb => [INTSRAM_CODE_Base, INTSRAM_CODE_Size, INTSRAM_DATA_Base, INTSRAM_DATA_Size]
188 # 'TK6291' => ["0xBF000000", "0x40000", "0xBF040000", "0x00040000"],
189 );
190 if(exists $BB_INTSRAM_tbl{$bb})
191 {
192 $strCODEBase = $BB_INTSRAM_tbl{$bb}[0];
193 $strCODESize = $BB_INTSRAM_tbl{$bb}[1];
194 $strDATABase = $BB_INTSRAM_tbl{$bb}[2];
195 $strDATASize = $BB_INTSRAM_tbl{$bb}[3];
196 }
197 return ($strCODEBase, $strCODESize, $strDATABase, $strDATASize);
198}
199#****************************************************************************
200# Subroutine: GetIntsramHWBoundary - to query INTSRAM_PHYSICAL_BOUNDARY's Base/MaxSize
201# Parameters: BB chip (eg. MT6276)
202# Returns: $strBase, $strSize
203#****************************************************************************
204sub GetIntsramHWBoundary
205{#unsupported on ldsGen's chip
206 my ($bb) = @_;
207 my ($strBase, $strSize) = (undef, undef);
208 my %BB_tbl =
209 ( # $bb => [ Base, Size]
210 #'MT6290' => ["0xBF040000", "0x00040000"],
211 );
212 if(&is_CR4($bb)==1 and exists $BB_tbl{$bb})
213 {
214 $strBase = $BB_tbl{$bb}[0];
215 $strSize = $BB_tbl{$bb}[1];
216 }
217 return ($strBase, $strSize);
218}
219#****************************************************************************
220# Subroutine: is_arm7 - Query if it's ARM7 Family
221# Parameters: BB chip (eg. MT6276)
222# Returns: 1=belongs arm7 family, undef=not arm7 family
223#****************************************************************************
224sub is_arm7
225{
226 my ($bb) = @_;
227 my %BBtbl_ARM7_Family =
228 (
229 #'MT6290_COPRO' => 1,
230 );
231 return $BBtbl_ARM7_Family{$bb};
232}
233#****************************************************************************
234# subroutine: is_mpu_capable - Query if it has mpu capability
235# Input: BB chip (eg. MT6276)
236# Output: 1=has mpu capability, others=doesn't have mpu capability
237#****************************************************************************
238sub is_mpu_capable
239{
240 my ($bb) = (@_);
241 my $nDefault_MPU_Capability = 1;
242 my %BBtbl_MPU_Capability =
243 (
244 #'TK6291' => 1,
245 #'MT6755' => 1,
246 );
247 return (exists $BBtbl_MPU_Capability{$bb} ?
248 $BBtbl_MPU_Capability{$bb} : $nDefault_MPU_Capability);
249}
250
251#****************************************************************************
252# Subroutine: is_arm9 - Query if it's ARM9 Family
253# Parameters: BB chip (eg. MT6235)
254# Returns: 1=belongs arm9 family, undef=not arm9 family
255#****************************************************************************
256sub is_arm9
257{
258 my ($bb) = @_;
259 my %BBtbl_ARM9_Family =
260 (
261 #'MT6589_MD2' => 1,
262 );
263 return $BBtbl_ARM9_Family{$bb};
264}
265
266
267#****************************************************************************
268# Subroutine: is_arm11 - Query if it's ARM11 Family
269# Parameters: BB chip (eg. MT6276)
270# Returns: 1=belongs arm11 family, undef=not arm11 family
271#****************************************************************************
272sub is_arm11
273{
274 my ($bb) = @_;
275 my %BBtbl_ARM11_Family =
276 (
277 # 'MT6577' => 1,
278 );
279 return $BBtbl_ARM11_Family{$bb};
280}
281
282#****************************************************************************
283# Subroutine: is_CR4 - Query if it's CR4
284# Parameters: BB chip (eg. MT6280)
285# Returns: 1=belongs CR4, undef=not CR4
286#****************************************************************************
287sub is_CR4
288{
289 my ($bb) = @_;
290 my $nDefault_CR4_Family = 1;
291 my %BBtbl_CR4_Family =
292 (
293 #'TK6291' => 1,
294 #'MT6755' => 1,
295 );
296 return (exists $BBtbl_CR4_Family{$bb}
297 ? $BBtbl_CR4_Family{$bb} : $nDefault_CR4_Family);
298}
299
300#****************************************************************************
301# Subroutine: is_LTE - Query if it's LTE project
302# Parameters: BB chip (eg. MT6280)
303# Returns: 1=belongs CR4, undef=not CR4
304#****************************************************************************
305sub is_LTE
306{
307 my ($bb) = @_;
308 my $nDefault_LTE_Family = 1;
309 my %BBtbl_LTE_Family =
310 (
311 #'TK6291' => 1,
312 #'MT6755' => 1,
313 );
314 return (exists $BBtbl_LTE_Family{$bb}
315 ? $BBtbl_LTE_Family{$bb}: $nDefault_LTE_Family);
316}
317
318
319#****************************************************************************
320# subroutine: Query if it has MMU(arm9, arm11, mtkmmu) or MPU (CR4)
321# to map the address like 0xf-------
322# input: BB chip (eg. MT6276)
323# Output: 0=non-mmu, 1=it has mmu
324#****************************************************************************
325sub is_mmu
326{
327 my ($bb) = (@_);
328 my $nIsMMU = 0; #0=non-MMU, 1=hasMMU;
329 my %BBtbl_MTKMMU_Family =
330 (
331 'MT6252' => 1,
332 'MT6252H' => 1,
333 'MT6250' => 1,
334 );
335 #############
336 # WARNING, return 1 if $bb = CR4
337 #############
338 if(&is_arm9($bb) or &is_arm11($bb) or defined $BBtbl_MTKMMU_Family{$bb} or &is_CR4($bb))
339 {
340 $nIsMMU = 1;
341 }
342 return $nIsMMU;
343}
344#****************************************************************************
345# subroutine: is_sv5 - Query if it's SV5 Family
346# Input: BB chip (eg. MT6276)
347# Output: 1=belongs sv5 family, undef=not sv5 family
348#****************************************************************************
349sub is_sv5
350{
351 my ($bb) = (@_);
352 my $nDefault_SV5_Family = 1;
353 my %BBtbl_SV5_Family =
354 (
355 #'TK6291' => 1,
356 #'MT6755' => 1,
357 );
358 return (exists $BBtbl_SV5_Family{$bb}
359 ? $BBtbl_SV5_Family{$bb}: $nDefault_SV5_Family);
360}
361
362#****************************************************************************
363# subroutine: DSPTXRX_query_length
364# purpose : Exec View :: DSP TX RX :: Size Of TX RX query
365# Input: 1. $bb: e.g. MT6280
366# 2. $mode: e.g. BASIC, L1S, GSM, GPRS, UMTS
367# Output: (nTXLength, nRXLength)
368#****************************************************************************
369sub DSPTXRX_query_length
370{
371 my ($bb, $mode) = @_;
372 # --- --- ---
373 my %BBtbl_l1s_tx =
374 (
375 #'TK6291' => 0x20000, # format: '"chip"' -> 'size'
376 'ELBRUS' => 0x20000,
377 'MT6763' => 0x20000,
378 'MT6739' => 0x20000,
379 'MT6771' => 0x20000,
380 'MT6295M' => 0x20000
381 );
382 #map {print $_, "\n";} keys %BBtbl;
383 my %BBtbl_l1s_rx =
384 (
385 'ELBRUS' => 0x20000,
386 'MT6763' => 0x20000,
387 'MT6739' => 0x20000,
388 'MT6771' => 0x20000,
389 'MT6295M' => 0x20000
390 );
391 #map {print $_, "\n";} keys %BBtbl;
392 # --- --- ---
393
394 my ($nTX, $nRX) = (0x20000, 0x20000); #default on MD
395
396 if ($mode =~ /L1S/i)
397 {
398 if ((exists $BBtbl_l1s_tx{$bb}) and (exists $BBtbl_l1s_rx{$bb}))
399 {
400 ($nTX, $nRX) = ($BBtbl_l1s_tx{$bb}, $BBtbl_l1s_rx{$bb});
401 }
402 }
403
404 return ($nTX, $nRX)
405}
406
407#****************************************************************************
408# subroutine: VoLTE_core_query_length
409# purpose : for refurn length of SS1 DSP
410# Input: 1. $bb: e.g. MT6763
411
412# Output: nVoLTE_len
413#****************************************************************************
414sub VoLTE_core_query_length
415{
416 my ($bb) = @_;
417
418 my %BBtbl_VoLTE_len =
419 (
420 # format: '"chip"' => 'size'1
421 'MT6763' => 0x1000000
422 );
423
424 my $nVoLTE_len = 0;
425 $nVoLTE_len = $BBtbl_VoLTE_len{$bb} if (exists $BBtbl_VoLTE_len{$bb});
426 return $nVoLTE_len;
427}
428
429#****************************************************************************
430# subroutine: determine CS1 base address
431# input: BB chip
432# Output: 1 = CS1 base address is 0x08000000, others = CS1 base address is 0x10000000
433#****************************************************************************
434sub check_cs1_base
435{
436 my ($bb) = (@_);
437 my %BBtbl_cs1_base =
438 (
439 #'MT6251' => 1,
440 );
441 return $BBtbl_cs1_base{$bb};
442
443}
444
445#****************************************************************************
446# subroutine: SCHEME Configure Routines :: Query :: CS1 base address
447# Note : this function doesn't guarantee if the chip needs to remap.
448# it only returns the address if needing remapping.
449# input: BB chip, base address(if no input, it's 0 in default), isBootloader(undef or 0= not bootloader)
450# Output: CS1 default base address
451#****************************************************************************
452sub query_cs1_addr
453{
454 my ($bb, $nBaseAddress, $bisBL) = @_;
455 $nBaseAddress = 0 if(!defined $nBaseAddress);
456 my $nCS1BaseAddress = $nBaseAddress;
457 if (&check_cs1_base($bb) == 1)
458 {
459 $nCS1BaseAddress = $nBaseAddress ^ 0x08000000;
460 }
461 else
462 {
463 $nCS1BaseAddress = $nBaseAddress ^ 0x10000000;
464 }
465 if(defined $bisBL and $bisBL != 0)
466 {
467 if($bb eq "MT6255")
468 {
469 $nCS1BaseAddress = $nBaseAddress;
470 }
471 }
472 return $nCS1BaseAddress;
473}
474#****************************************************************************
475# subroutine: SCHEME Configure Routines :: Query :: viva header size
476# note: This function is used to get viva header size if
477# DCMP support or ZIMAGE support or ALICE support
478# input: BB chip
479# Output: viva header size
480#****************************************************************************
481sub query_viva_size
482{
483 require "pcore/tools/vivaHelper.pm";
484 my ($bb) = @_;
485 my $viva_size = &vivaHelper::GetVIVAHeaderSize_NI(&is_sv5($bb));
486 return $viva_size;
487}
488#****************************************************************************
489# subroutine: is_XIP_Shadowing
490# Note : this function is to query which chip needs to do shadowing
491# due to speeding up on NOR or Serial Flash
492# input: BB chip
493# Output: 0=unsupported, 1=supported
494#****************************************************************************
495sub is_XIP_Shadowing
496{
497 my ($bb) = @_;
498 my $nDefault_XIP_Family = 1;
499 my %BBtbl_XIP_Family =
500 (
501 #'TK6291' => 1,
502 #'MT6755' => 1,
503 );
504 return (exists $BBtbl_XIP_Family{$bb}
505 ? $BBtbl_XIP_Family{$bb}: $nDefault_XIP_Family);
506}
507
508#****************************************************************************
509# subroutine: SwitchToClonedChip
510# Note : this function is to get original cloned chip
511# otherwises it returns input chip.
512# input: strBBChip (e.g. MT6280)
513# Output: strBBChip (e.g. MT6280)
514#****************************************************************************
515sub SwitchToClonedChip
516{
517 my ($bb) = @_;
518 my %BBtbl_Family =
519 (
520# "TK6291" => "MT6290",
521 "MT6765" => "MT6771",
522 "MT3967" => "MT6295M",
523 "MT6779" => "MT6295M",
524 "MT6785" => "MT6295M",
525 "MT6885" => "MT6297",
526 "MERCURY" => "MT6297",
527 "MT6873" => "MT6297",
528 "MT6853" => "MT6297",
529 "MT6833" => "MT6297",
530 "MT6893" => "MT6297",
531 "MT6880" => "MT6297",
532 "MT6890" => "MT6297",
533 "MT2735" => "MT6297",
534 "MT6877" => "MT6297",
535 );
536 $bb = $BBtbl_Family{$bb} if(defined $BBtbl_Family{$bb});
537 return $bb;
538}
539
540#****************************************************************************
541# subroutine: isSupportedtoAdjustLoadView
542# Note : this function is to get if this chip supported AAPMC to adjust rom length and ram base
543# input: strBBChip (e.g. MT6280)
544# Output: 0: not supported, 1= supported by default
545#****************************************************************************
546sub isSupportedToAdjustLoadView
547{
548 my ($bb) = @_;
549 my $bSupported = 1; # support to adjust ROM Length and RAM base by default
550 $bb = SwitchToClonedChip($bb);
551 my %BBtbl_Family =
552 (
553 #"TK6291" => 1,
554 "ELBRUS" => 0,
555 "MT6763" => 1,
556 "MT6739" => 1,
557 "MT6771" => 1,
558 "MT6295M" => 1,
559 );
560 $bSupported = $BBtbl_Family{$bb} if(defined $BBtbl_Family{$bb});
561 $bSupported = 1 if(FileInfo::is("ORIGINAL_FLAVOR", "SLT")); #SLT default = md only load
562 $bSupported = 0 if(BuildInfo::exist(BuildOPT::CMPL, "__ESL_COSIM_LTE__"));
563 return $bSupported;
564}
565#****************************************************************************
566# subroutine: isSupportedToAdjustRAMSize
567# Note : this function is to get if this chip supported AAPMC to adjust RAM Length
568# input: strBBChip (e.g. MT6280)
569# Output: 0: not supported by default, 1= supported
570#****************************************************************************
571sub isSupportedToAdjustRAMSize
572{
573 my ($bb) = @_;
574 my $bSupported = 1; # do support to adjust RAM Length by default
575 $bb = SwitchToClonedChip($bb);
576 my %BBtbl_Family =
577 (
578 "ELBRUS" => 0,
579 "MT6763" => 1,
580 "MT6739" => 1,
581 "MT6771" => 1,
582 "MT6295M" => 1,
583 );
584 $bSupported = $BBtbl_Family{$bb} if(defined $BBtbl_Family{$bb});
585 $bSupported = 0 if(FileInfo::is("SMART_PHONE_CORE", "MODEM_ONLY"));
586 $bSupported = 1 if(FileInfo::is("ORIGINAL_FLAVOR", "SLT")); #SLT default = md only load
587 return $bSupported;
588}
589
590#****************************************************************************
591# subroutine: GetDefaultSharedMemorySize
592# Note : this function is to get default shared memory size by chip, for 1st linking
593# input: strBBChip (e.g. MT6280)
594# Output: $nAlignment: default =1
595#****************************************************************************
596sub GetDefaultSharedMemorySize
597{ #remember to check MD total size in GetMDTotolSize (ldsGenLib.pl)
598
599 my ($bb) = @_;
600
601 my %BBtbl_SHMsize =
602 (
603 'TK6291' => 0x8000000, # 128 MB
604 'MT6755' => 0x5000000, # 80 MB
605 'MT6797' => 0x5000000, # 80 MB
606 );
607
608 my $SHM_with_ramdisk_default_size = 0x8000000; # 128 MB
609 my %BBtbl_SHM_with_ramdisk_size =
610 ( # format: '"chip"' -> 'size'
611 );
612
613 &error_handler("No default shared memory size for this chip $bb", __FILE__, __LINE__)
614 if(! exists $BBtbl_SHMsize{$bb});
615
616 # for ramdisk or MD only load
617 if ( FileInfo::is("FS_RAMDISK", "TRUE")
618 or FileInfo::is("SMART_PHONE_CORE", "MODEM_ONLY") )
619 {
620 return $BBtbl_SHM_with_ramdisk_size{$bb} if (exists $BBtbl_SHM_with_ramdisk_size{$bb});
621 return $SHM_with_ramdisk_default_size;
622 }
623
624 # return default size
625 return $BBtbl_SHMsize{$bb};
626}
627
628#****************************************************************************
629# subroutine: GetMD_AlignmentByChip
630# Note : this function is to get MD Ram Alignment by chip
631# input: strBBChip (e.g. MT6280)
632# Output: $nAlignment: default =1
633#****************************************************************************
634sub GetMD_AlignmentByChip
635{
636 my ($bb) = @_;
637 my $nAlignment = 1; #1MB aligned
638 my %BBtbl_Alignment =
639 (
640 #'MT6582' => 2,
641 );
642 if(exists $BBtbl_Alignment{$bb})
643 {
644 $nAlignment = $BBtbl_Alignment{$bb};
645 }
646 return $nAlignment;
647}
648
649#****************************************************************************
650# subroutine: GetMD_AlignmentByChip
651# Note : this function is to get MD Ram Alignment by chip
652# input: strBBChip (e.g. MT6280)
653# Output: $nAlignment: default =1
654#****************************************************************************
655sub GetCopro_KBAlignment
656{
657 my ($strCopro) = @_;
658 my $nAlignment = 1024; # 1MB aligned
659 my %BBtbl_Alignment =
660 (
661 # 'L1CORE' => 4,
662 );
663 if(exists $BBtbl_Alignment{$strCopro})
664 {
665 $nAlignment = $BBtbl_Alignment{$strCopro};
666 }
667 return $nAlignment;
668}
669
670
671#****************************************************************************
672# Subroutine: GetNonCacheablePrefix
673# Parameters: strBBChip (e.g. MT6280)
674# Returns: an bank adress for OR
675# default: 0x0
676#****************************************************************************
677sub GetNonCacheablePrefix
678{
679 my ($bb) = @_;
680 my %BBtbl_Family =
681 (
682
683 );
684 my $prefix = 0;
685 $prefix = $BBtbl_Family{$bb} if(defined $BBtbl_Family{$bb});
686 return $prefix;
687}
688#****************************************************************************
689# Subroutine: GetCacheablePrefix
690# Parameters: strBBChip (e.g. MT6280)
691# Returns: an bank adress for OR
692# default: 0xF0000000
693#****************************************************************************
694sub GetCacheablePrefix
695{
696 my ($bb) = @_;
697 my %BBtbl_Family =
698 (
699
700 );
701 my $prefix = 0x60000000;
702 $prefix = $BBtbl_Family{$bb} if(defined $BBtbl_Family{$bb});
703 return $prefix;
704
705}
706#****************************************************************************
707# Subroutine: del_noCheckinHistory_file
708# Parameters: one file path
709# Returns: N/A
710#****************************************************************************
711sub del_noCheckinHistory_file
712{
713 my ($filepath) = @_;
714 return unless (-e $filepath);
715
716 my $nHas = &HasCheckinHistory($filepath);
717 if($nHas == 1)
718 {
719 print "$filepath: Check-in message is found. No need to update.\n";
720 }
721 elsif($nHas == 0)
722 {
723 unlink $filepath;
724 print "delete $filepath since no manual check-in pattern!\n" if(!-f $filepath);
725 print "$filepath can't be deleted properly!\n" if(-f $filepath);
726 }
727 return;
728}
729#****************************************************************************
730# Subroutine: HasCheckinHistory
731# Parameters: one file path
732# Returns: undef=not exists, 0=no history, 1=has history
733#****************************************************************************
734sub HasCheckinHistory
735{
736 my ($filepath) = @_;
737 return undef unless (-e $filepath);
738 my $nReturn = 0; # Empty=not exists, 0=no history, 1=has history
739
740 ## Now check if the $target file check-in or auto-gen
741 open SRC_FILE_R , "<$filepath" or &error_handler("$filepath: file error!", __FILE__, __LINE__);
742 my $reading;
743 {
744 local $/;
745 $reading = <SRC_FILE_R>;
746 }
747 close SRC_FILE_R;
748
749 ## Look for check-in pattern ##
750 if (($reading =~ /\[MAUI_\d{8}\]|\[MOLY\d{8}\]|\[ALPS\d{8}\]/) or ($reading =~ /MANUAL-CHECKIN/i))
751 {
752 return 1;
753 }
754 return 0;
755}
756
757#****************************************************************************
758# subroutine: CopyFileWithReplacement
759# input: $SrcPath - source file path
760# $DestPath - destination path
761# $Array_ref : An array of strings to be replaced to empty string
762# output: N/A
763# Description: 1. if the file name doesn't contain .template, replace sysgen1 verno on it
764# 2. replace the string in $Array_ref to empty string
765#****************************************************************************
766sub CopyFileWithReplacement
767{
768 my ($SrcPath, $DestPath, $Array_ref, $StrVersion) = @_;
769 my $content;
770 open FILE, "<$SrcPath" or &sysUtil::sysgen_die("$SrcPath: open file error!", __FILE__, __LINE__);
771 {
772 local $/;
773 $content = <FILE>;
774 }
775 close FILE;
776
777 if($SrcPath !~ /\.template$/)
778 {
779 #Add sysgen1.pl's verno to the file
780 $content =~ s/system\s*auto\s*generator(.*)//;
781 $content =~ s/Author\s*:\s+(.*)\s+(.*)/Author:\n $1\n $2 $StrVersion /;
782 }
783
784 #replace the string in $Array_ref to empty string
785 map {$content =~ s/$_//ig} @$Array_ref;
786
787 open FILE, ">$DestPath" or &sysUtil::sysgen_die("$DestPath: open file error!", __FILE__, __LINE__);
788 print FILE $content;
789 close FILE;
790}
791
792#****************************************************************************
793# Subroutine: isDummyScatter
794# Parameters: $bINSIDE_MTK = 0 or 1, $strDUMMY_SCATTER_FORCE = TRUE or FALSE
795# Returns: 0=not dummy , 1=is dummy
796#****************************************************************************
797sub isDummyScatter
798{
799 my ($bINSIDE_MTK, $strDUMMY_SCATTER_FORCE) = @_;
800 my $bIsDummy = 0; #not dummy by default
801 if (1 == &FileInfo::is_NOR())
802 {
803 if(&FileInfo::is('dummy_scatter_enable', "TRUE"))
804 {
805 $bIsDummy = 1 if($bINSIDE_MTK == 1);
806 }
807 }
808 $bIsDummy = 1 if($strDUMMY_SCATTER_FORCE eq 'TRUE');
809 return $bIsDummy;
810}
811
812sub GetSigSize
813{
814 return 256;
815}
816
817
818
819
820#****************************************************************************
821# subroutine: error_handler
822# input: $error_msg: error message
823#****************************************************************************
824sub error_handler
825{
826 my ($error_msg, $file, $line_no, $strTitle) = @_;
827
828 my $final_error_msg = "$strTitle ERROR: $error_msg at $file line $line_no : $!\n";
829 print $final_error_msg;
830 die $final_error_msg;
831}
832
833sub sysgen_die
834{
835 my ($error_msg, $file, $line_no) = @_;
836 &error_handler($error_msg, $file, $line_no, 'SYSGEN');
837}
838sub sysUtil_die
839{
840 my ($error_msg, $file, $line_no) = @_;
841 &error_handler($error_msg, $file, $line_no, 'SYSGENUTILITY');
842}
843
844#****************************************************************************
845# subroutine: description_file_header
846# return: file header -- description
847# input: $filename: filename
848# input: $description: one line description
849# input: $author: optional
850# input: $strComment: optional
851# input: $bAutoGen optional: 1=AutoGen, 0 or undef = not AutoGen
852#****************************************************************************
853sub description_file_header
854{
855 my ($filename, $description, $author, $strComment, $bAutoGen) = @_;
856 $filename =~ s/.*\///;
857 my $strAutoGeneratedDate = " *\n";
858 my $strWarning;
859 if($bAutoGen == 1)
860 {
861 my ($day, $month, $year) = (localtime)[3,4,5]; $month++; $year+=1900;
862 $strAutoGeneratedDate = <<"__TEMPLATE";
863 *
864 * Auto Generated Date:
865 * -------
866 * $year/$month/$day
867 *
868__TEMPLATE
869 $strWarning = <<"__TEMPLATE";
870 * This file is auto-generated and please DO NOT change the content at will
871 *=========================================================================
872__TEMPLATE
873 $strComment = $strWarning.$strComment;
874 }
875 my $template = <<"__TEMPLATE";
876/*****************************************************************************
877 *
878 * Filename:
879 * ---------
880 * $filename
881 *
882 * Project:
883 * --------
884 * Maui_Software
885 *
886 * Description:
887 * ------------
888 * $description
889 *
890 * Author:
891 * -------
892 * $author
893$strAutoGeneratedDate
894 *============================================================================
895 * HISTORY
896 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
897 *------------------------------------------------------------------------------
898 * \$Revision\$
899 * \$Modtime\$
900 * \$Log\$
901 *
902 *------------------------------------------------------------------------------
903 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
904 *============================================================================
905$strComment
906 ****************************************************************************/
907
908__TEMPLATE
909
910 return $template;
911}
912
913#****************************************************************************
914# subroutine: copyright_file_header
915# return: file header -- copyright
916#****************************************************************************
917sub copyright_file_header
918{
919 my $template = <<"__TEMPLATE";
920/*****************************************************************************
921* Copyright Statement:
922* --------------------
923* This software is protected by Copyright and the information contained
924* herein is confidential. The software may not be copied and the information
925* contained herein may not be used or disclosed except with the written
926* permission of MediaTek Inc. (C) 2006
927*
928* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
929* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
930* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
931* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
932* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
933* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
934* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
935* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
936* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
937* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
938* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
939* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
940*
941* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
942* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
943* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
944* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
945* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
946*
947* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
948* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
949* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
950* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
951* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
952*
953*****************************************************************************/
954
955__TEMPLATE
956
957 return $template;
958}