yu.dong | c33b307 | 2024-08-21 23:14:49 -0700 | [diff] [blame^] | 1 | #!/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 | #* sysInfoProcessScat.pm
|
| 40 | #*
|
| 41 | #* Project:
|
| 42 | #* --------
|
| 43 | #*
|
| 44 | #*
|
| 45 | #* Description:
|
| 46 | #* ------------
|
| 47 | #* This module collects the subroutines for system information.
|
| 48 | #*
|
| 49 | #*
|
| 50 | #* Author:
|
| 51 | #* -------
|
| 52 | #* Carl Kao (mtk08237)
|
| 53 | #*
|
| 54 | #****************************************************************************/
|
| 55 |
|
| 56 | BEGIN { push @INC, '../', './tools/', './tools/MemoryUtility/' }
|
| 57 | package sysInfoProcScat;
|
| 58 | use CommonUtility;
|
| 59 | use sysGenUtility;
|
| 60 | use scatInfo;
|
| 61 | use strict;
|
| 62 |
|
| 63 | #****************************************************************************
|
| 64 | # Constants
|
| 65 | #****************************************************************************
|
| 66 | my $SYSINFOPROCSCAT_VERNO = " m0.04";
|
| 67 | # m0.04 , 2015/01/19, Memory Utility Refinement
|
| 68 | # m0.03 , 2012/08/03, Modify GetTCMmargin() to store TCM physical size
|
| 69 | # m0.02 , 2012/08/03, Modify module name and push additional library path
|
| 70 | # m0.01 , 2012/07/05, Initial revision
|
| 71 |
|
| 72 | #****************************************************************************
|
| 73 | # Global variable
|
| 74 | #****************************************************************************
|
| 75 | my $g_MAUIScat;
|
| 76 | my $DebugPrint = 1;
|
| 77 |
|
| 78 | #****************************************************************************
|
| 79 | # oo >>> Finished
|
| 80 | #****************************************************************************
|
| 81 | return 1;
|
| 82 |
|
| 83 | #****************************************************************************
|
| 84 | # Subroutine: GetChipInsideRAMregion - to query all Chip inside RAM regions
|
| 85 | # Parameters: $SCATTERFILE = the path of scatter file
|
| 86 | # $INTSRAMregion_href = a Hash reference to store ChipInsideRAM infomation
|
| 87 | # $INTSRAMregion_href->{regionName} = []
|
| 88 | # Returns: $nINTSRAMnum = the number of ChipInsideRAM regions
|
| 89 | #****************************************************************************
|
| 90 | sub GetChipInsideRAMregion
|
| 91 | {
|
| 92 | my ($SCATTERFILE, $INTSRAMregion_href) = (@_);
|
| 93 | my $nINTSRAMnum = 0;
|
| 94 |
|
| 95 | &GetScatInfo($SCATTERFILE);
|
| 96 | my $ExeRegion_ref = $g_MAUIScat->GetAllExeRegion();
|
| 97 | foreach (@$ExeRegion_ref)
|
| 98 | {
|
| 99 | if($_ =~ /EMIINIT_CODE|^INTSRAM|^L2TCM/)
|
| 100 | {
|
| 101 | next if ($_ =~ /DUMMY/);
|
| 102 | $nINTSRAMnum++;
|
| 103 | $INTSRAMregion_href -> {$_} = [];
|
| 104 | }
|
| 105 | }
|
| 106 |
|
| 107 | return ($nINTSRAMnum);
|
| 108 | }
|
| 109 |
|
| 110 | #****************************************************************************
|
| 111 | # Subroutine: GetChipInsideRAMsize - to query ChipInsideRAM size
|
| 112 | # Parameters: $SCATTERFILE = the path of scatter file
|
| 113 | # $INTSRAMinfo_href = a Hash reference to store ChipInsideRAM infomation
|
| 114 | # ($INTSRAMinfo_href -> {ChipInsideRAM type} = MaxSize)
|
| 115 | # Returns: $nINTSRAMnum = the number of ChipInsideRAM types
|
| 116 | #****************************************************************************
|
| 117 | sub GetChipInsideRAMsize
|
| 118 | {
|
| 119 | my ($SCATTERFILE, $INTSRAMinfo_href) = (@_);
|
| 120 | my $nINTSRAMnum = 0;
|
| 121 | my $strINTSRAMName = undef;
|
| 122 |
|
| 123 | &GetScatInfo($SCATTERFILE);
|
| 124 | my $ExeRegion_ref = $g_MAUIScat->GetAllExeRegion();
|
| 125 | foreach (@$ExeRegion_ref)
|
| 126 | {
|
| 127 | if($_ =~ /INTSRAM_CODE|INTSRAM_DATA$|L2TCM_CODE|L2TCM_DATA|INTSRAM_MULTIMEDIA/)
|
| 128 | {
|
| 129 | #print "region = $_"."\n";
|
| 130 | $nINTSRAMnum++;
|
| 131 | my $Info = $g_MAUIScat->GetExeRegionInfo($_);
|
| 132 | my $nMaxSize = hex($Info->[Region::MaxSize]);
|
| 133 | my $strOffest = $Info->[Region::Offset];
|
| 134 | if($_ eq 'INTSRAM_CODE')
|
| 135 | {
|
| 136 | $strINTSRAMName = 'ITCM';
|
| 137 | }
|
| 138 | elsif($_ eq 'INTSRAM_DATA')
|
| 139 | {
|
| 140 | $strINTSRAMName = 'DTCM';
|
| 141 | if($strOffest eq '+0x0')
|
| 142 | {
|
| 143 | $nINTSRAMnum--;
|
| 144 | my $TCMsize = $INTSRAMinfo_href->{'ITCM'};
|
| 145 | $INTSRAMinfo_href->{'TCM'} = $TCMsize;
|
| 146 | delete $INTSRAMinfo_href->{'ITCM'};
|
| 147 | next;
|
| 148 | }
|
| 149 | }
|
| 150 | elsif($_ eq 'L2TCM_CODE')
|
| 151 | {
|
| 152 | $strINTSRAMName = 'L2TCM_CODE';
|
| 153 | }
|
| 154 | elsif($_ eq 'L2TCM_DATA')
|
| 155 | {
|
| 156 | $strINTSRAMName = 'L2TCM_DATA';
|
| 157 | }
|
| 158 | elsif($_ eq 'INTSRAM_MULTIMEDIA')
|
| 159 | {
|
| 160 | $strINTSRAMName = 'MM_SYSRAM';
|
| 161 | }
|
| 162 | $INTSRAMinfo_href->{$strINTSRAMName} = $nMaxSize;
|
| 163 | }
|
| 164 | }
|
| 165 | return ($nINTSRAMnum);
|
| 166 | }
|
| 167 |
|
| 168 | #****************************************************************************
|
| 169 | # Subroutine: GetTCMmargin - to query TCM margin
|
| 170 | # Parameters: $SCATTERFILE = the path of scatter file
|
| 171 | # $TCMregion_href = a Hash reference to store TCM infomation
|
| 172 | # $TCMregion_href->{'regionName'} = size
|
| 173 | # Returns: $hTCMmargin = a Hash reference to store TCM information
|
| 174 | # $TCMmargin_href->{ITCM}->[0] = ITCM physical size, $TCMmargin_href->{ITCM}->[1] = ITCM margin
|
| 175 | # $TCMmargin_href->{DTCM}->[0] = DTCM physical size, $TCMmargin_href->{DTCM}->[1] = DTCM margin
|
| 176 | # $TCMmargin_href->{TCM}->[0] = TCM physical size , $TCMmargin_href->{TCM}->[1] = TCM margin
|
| 177 | #****************************************************************************
|
| 178 | sub GetTCMmargin
|
| 179 | {
|
| 180 | my ($SCATTERFILE, $TCMregion_href) = (@_);
|
| 181 | my %hTCMmargin;
|
| 182 | my %INTSRAMinfo;
|
| 183 | my ($TCMmargin, $ITCMmargin, $DTCMmargin) = (undef,undef,undef);
|
| 184 | my ($ITCMusedsize, $DTCMusedsize) = (0,0);
|
| 185 | &GetChipInsideRAMsize($SCATTERFILE, \%INTSRAMinfo);
|
| 186 |
|
| 187 | foreach my $strINTSRAM (keys %{$TCMregion_href})
|
| 188 | {
|
| 189 | if( $strINTSRAM =~ /^INTSRAM/)
|
| 190 | {
|
| 191 | $ITCMusedsize += $TCMregion_href->{$strINTSRAM} if($strINTSRAM =~ /CODE/);
|
| 192 | $DTCMusedsize += $TCMregion_href->{$strINTSRAM} if($strINTSRAM =~ /DATA/);
|
| 193 | }
|
| 194 | }
|
| 195 |
|
| 196 | foreach my $strINTSRAMname (keys %INTSRAMinfo)
|
| 197 | {
|
| 198 | if($strINTSRAMname =~ /^TCM/)
|
| 199 | {
|
| 200 | my $TCMsize = $INTSRAMinfo{$strINTSRAMname};
|
| 201 | $TCMmargin = $TCMsize - $ITCMusedsize - $DTCMusedsize;
|
| 202 | $hTCMmargin{'TCM'} = [$TCMsize, $TCMmargin];
|
| 203 | }
|
| 204 | elsif($strINTSRAMname =~ /^ITCM/)
|
| 205 | {
|
| 206 | my $ITCMsize = $INTSRAMinfo{$strINTSRAMname};
|
| 207 | $ITCMmargin = $ITCMsize - $ITCMusedsize;
|
| 208 | $hTCMmargin{'ITCM'} = [$ITCMsize, $ITCMmargin];
|
| 209 | }
|
| 210 | elsif($strINTSRAMname =~ /^DTCM/)
|
| 211 | {
|
| 212 | my $DTCMsize = $INTSRAMinfo{$strINTSRAMname};
|
| 213 | $DTCMmargin = $DTCMsize - $DTCMusedsize;
|
| 214 | $hTCMmargin{'DTCM'} = [$DTCMsize, $DTCMmargin];
|
| 215 | }
|
| 216 | }
|
| 217 | return (\%hTCMmargin);
|
| 218 | }
|
| 219 |
|
| 220 |
|
| 221 | #****************************************************************************
|
| 222 | # Subroutine: GetphysicalRAMsize - to query physical RAM size
|
| 223 | # Parameters: $BB_PATH = the path of BB folder
|
| 224 | # Returns: $nRAMsize = the physical RAM size
|
| 225 | #****************************************************************************
|
| 226 | sub GetphysicalRAMsize
|
| 227 | {
|
| 228 | my ($BB_PATH) = (@_);
|
| 229 | my $CUSTOM_EMI_RELEASE_H = $BB_PATH . '/' . "custom_EMI_release.h";
|
| 230 | my $nRAMsize = 0;
|
| 231 |
|
| 232 | open (EMIRELEASEH_HANDLE, "<$CUSTOM_EMI_RELEASE_H") or &sysInfoProcess_die("$CUSTOM_EMI_RELEASE_H: file error!", __FILE__, __LINE__);
|
| 233 | while (<EMIRELEASEH_HANDLE>) {
|
| 234 | if (/^#define EMI_EXTSRAM_SIZE\s+\(\s*\(*\s*\(*\s*(\S+)\)*\s*<<\s*20\s*\)*\s*>>\s*3\s*\)/)
|
| 235 | {
|
| 236 | $nRAMsize = $1 * 1024 * 1024 / 8;
|
| 237 | }
|
| 238 | }
|
| 239 | close (EMIRELEASEH_HANDLE);
|
| 240 | return $nRAMsize;
|
| 241 | }
|
| 242 |
|
| 243 |
|
| 244 | #****************************************************************************
|
| 245 | # Subroutine: GetAvailableRAMsize - to query available RAM size
|
| 246 | # Parameters: $BB_PATH = the path of BB folder
|
| 247 | # Returns: $nRAMsize = the available RAM size
|
| 248 | #****************************************************************************
|
| 249 | sub GetAvailableRAMsize
|
| 250 | {
|
| 251 | my ($BB_PATH) = (@_);
|
| 252 | my $nRAMsize = undef;
|
| 253 | my $CUSTOM_FEATURECONFIG_H = $BB_PATH . '/' . "custom_FeatureConfig.h";
|
| 254 | my $CUSTOM_EMI_RELEASE_H = $BB_PATH . '/' . "custom_EMI_release.h";
|
| 255 | my $bsetLimit = 0;
|
| 256 | my $isNOR = (&FileInfo::is_NOR() and !FileInfo::is_SmartPhone()) ? 1 : 0;
|
| 257 |
|
| 258 | open (FEATURECONFIGH_HANDLE, "<$CUSTOM_FEATURECONFIG_H") or &sysInfoProcSCAT_die("$CUSTOM_FEATURECONFIG_H: file error!", __FILE__, __LINE__);
|
| 259 | while (<FEATURECONFIGH_HANDLE>) {
|
| 260 | if (/^#define PROJECT_EXPECTED_RAM_LIMIT\s*(\w*)/ && $isNOR)
|
| 261 | {
|
| 262 | $nRAMsize = hex($1);
|
| 263 | $bsetLimit = 1;
|
| 264 | }
|
| 265 | elsif (/^#define PROJECT_EXPECTED_RAM_LIMIT_NFB\s*(\w*)/)
|
| 266 | {
|
| 267 | $nRAMsize = hex($1);
|
| 268 | $bsetLimit = 1;
|
| 269 | }
|
| 270 | }
|
| 271 | close (FEATURECONFIGH_HANDLE);
|
| 272 |
|
| 273 | if($bsetLimit == 0)
|
| 274 | {
|
| 275 | open (EMIRELEASEH_HANDLE, "<$CUSTOM_EMI_RELEASE_H") or &sysInfoProcess_die("$CUSTOM_EMI_RELEASE_H: file error!", __FILE__, __LINE__);
|
| 276 | while (<EMIRELEASEH_HANDLE>) {
|
| 277 | if (/^#define EMI_EXTSRAM_SIZE\s+\(\s*\(*\s*\(*\s*(\S+)\)*\s*<<\s*20\s*\)*\s*>>\s*3\s*\)/)
|
| 278 | {
|
| 279 | $nRAMsize = $1 * 1024 * 1024 / 8;
|
| 280 | }
|
| 281 | }
|
| 282 | close (EMIRELEASEH_HANDLE);
|
| 283 | }
|
| 284 | return $nRAMsize;
|
| 285 | }
|
| 286 |
|
| 287 | #****************************************************************************
|
| 288 | # Subroutine: GetRAMregion - to query all regions placed in RAM
|
| 289 | # Parameters: $BB_PATH
|
| 290 | # $SCATTERFILE = the path of scatter file
|
| 291 | # $RAMregion_aref = a Array reference to store RAM regions
|
| 292 | # $MAKEFILE_ref = a Hash to contain MAKEFILE information
|
| 293 | # Returns: $nRAMnum = the number of RAM regions
|
| 294 | #****************************************************************************
|
| 295 | sub GetRAMregion
|
| 296 | {
|
| 297 | my ($BB_path, $SCATTERFILE, $RAMregion_aref, $MAKEFILE_ref) = (@_);
|
| 298 | my $CUSTOM_FEATURECONFIG_H = $BB_path . '/' . "custom_FeatureConfig.h";
|
| 299 | my $nRAMnum = 0;
|
| 300 | my $isNOR = (&FileInfo::is_NOR() and !FileInfo::is_SmartPhone());
|
| 301 |
|
| 302 | &GetScatInfo($SCATTERFILE);
|
| 303 | my $ExeRegion_ref = $g_MAUIScat->GetAllExeRegion();
|
| 304 |
|
| 305 | if(!$isNOR)
|
| 306 | {
|
| 307 | foreach (@$ExeRegion_ref)
|
| 308 | {
|
| 309 | #print $_."\n";
|
| 310 | next if($_ =~ /GFH$|SIGNATURE|EMIINIT_CODE|^INTSRAM|^L2TCM|DUMMY|SHOULDBE_EMPTYSECTION/);
|
| 311 | $nRAMnum++;
|
| 312 | push(@$RAMregion_aref, $_);
|
| 313 | }
|
| 314 | }
|
| 315 | else
|
| 316 | {
|
| 317 | foreach (@$ExeRegion_ref)
|
| 318 | {
|
| 319 | if($_ =~ /^EXTSRAM|^CACHED|^DYNAMIC|PAGETABLE/)
|
| 320 | {
|
| 321 | next if($_ =~ /DUMMY|SHOULDBE_EMPTYSECTION/);
|
| 322 | $nRAMnum++;
|
| 323 | push(@$RAMregion_aref, $_);
|
| 324 | }
|
| 325 | }
|
| 326 | }
|
| 327 | return ($nRAMnum);
|
| 328 | }
|
| 329 |
|
| 330 | #****************************************************************************
|
| 331 | # Subroutine: GetRAMBoundaryregion - to query the boundary regions in RAM
|
| 332 | # this function can be used to calculate RAM margin
|
| 333 | # Parameters: $SCATTERFILE = the path of scatter file
|
| 334 | # $MAKEFILE_ref = a Hash to contain MAKEFILE information
|
| 335 | # Returns: $LAST_CACHED_REGION = the last cached region in RAM
|
| 336 | # $DUMMY_END = the dummy_end region in RAM
|
| 337 | #****************************************************************************
|
| 338 | sub GetRAMBoundaryregion
|
| 339 | {
|
| 340 | my ($SCATTERFILE, $MAKEFILE_ref) = (@_);
|
| 341 | my $bb = $MAKEFILE_ref->{"platform"};
|
| 342 | my $DUMMY_END = undef;
|
| 343 | my $LAST_CACHED_REGION = undef;
|
| 344 |
|
| 345 | &GetScatInfo($SCATTERFILE);
|
| 346 | $DUMMY_END= &Gen_RegionName_EV_DUMMY_END_Base($bb);
|
| 347 | $LAST_CACHED_REGION = &Gen_RegionName_EV_LAST_CACHED_REGION($bb);
|
| 348 |
|
| 349 | return ($LAST_CACHED_REGION, $DUMMY_END);
|
| 350 | }
|
| 351 |
|
| 352 | #****************************************************************************
|
| 353 | # Subroutine: GetphysicalROMsize - to query physical ROM size
|
| 354 | # Parameters: $BB_PATH = the path of BB folder
|
| 355 | # $MAKEFILE_ref = a Hash to contain MAKEFILE information
|
| 356 | # Returns: $nROMsize = the physical ROM size
|
| 357 | #****************************************************************************
|
| 358 | sub GetphysicalROMsize
|
| 359 | {
|
| 360 | my ($BB_PATH) = (@_);
|
| 361 | my $nROMsize = undef;
|
| 362 | my $CUSTOM_FLASH_H = $BB_PATH . '/' . "custom_flash.h";
|
| 363 | my $FLASH_OPT_GEN_H = $BB_PATH . '/' . "flash_opt_gen.h";
|
| 364 | my $isNOR = (&FileInfo::is_NOR() and !FileInfo::is_SmartPhone()) ? 1 : 0;
|
| 365 |
|
| 366 | if($isNOR)
|
| 367 | {
|
| 368 | open (FLASHH_HANDLE, "<$CUSTOM_FLASH_H") or &sysInfoProcSCAT_die("$CUSTOM_FLASH_H: file error!", __FILE__, __LINE__);
|
| 369 | while (<FLASHH_HANDLE>) {
|
| 370 | if (/^\s*\*\s+NOR_FLASH_SIZE\(Mb\):\s*(\w*)/)
|
| 371 | {
|
| 372 | $nROMsize = $1 * 1024 * 1024 / 8;
|
| 373 | }
|
| 374 | }
|
| 375 | close (FLASHH_HANDLE);
|
| 376 | }
|
| 377 | else
|
| 378 | {
|
| 379 | open (FLASHOPTGENH_HANDLE, "<$FLASH_OPT_GEN_H") or &sysInfoProcSCAT_die("$FLASH_OPT_GEN_H: file error!", __FILE__, __LINE__);
|
| 380 | while (<FLASHOPTGENH_HANDLE>) {
|
| 381 | if (/^#define NAND_TOTAL_SIZE\s*(\w*)/)
|
| 382 | {
|
| 383 | $nROMsize = $1 * 1024 * 1024;
|
| 384 | }
|
| 385 | }
|
| 386 | close (FLASHOPTGENH_HANDLE);
|
| 387 | }
|
| 388 | return $nROMsize;
|
| 389 | }
|
| 390 |
|
| 391 | #****************************************************************************
|
| 392 | # Subroutine: GetAvailableROMsize - to query available ROM size
|
| 393 | # Parameters: $BB_PATH = the path of BB folder
|
| 394 | # $MAKEFILE_ref = a Hash to contain MAKEFILE information
|
| 395 | # Returns: $nROMsize = the available ROM size
|
| 396 | #****************************************************************************
|
| 397 | sub GetAvailableROMsize
|
| 398 | {
|
| 399 | my ($BB_PATH) = (@_);
|
| 400 | my $nROMsize = 0;
|
| 401 | my $CUSTOM_FEATURECONFIG_H = $BB_PATH . '/' . "custom_FeatureConfig.h";
|
| 402 | my $CUSTOM_MEMORYDEVICE_H = $BB_PATH . '/' . "custom_MemoryDevice.h";
|
| 403 | my $CUSTOM_FALSH_H = $BB_PATH . '/' . "custom_flash.h";
|
| 404 | my $isNOR = (&FileInfo::is_NOR() and !FileInfo::is_SmartPhone()) ? 1 : 0;
|
| 405 |
|
| 406 | #code/data can not be executed in NAND flash
|
| 407 | return $nROMsize if(!$isNOR);
|
| 408 |
|
| 409 | my %FEATURE_CONFIG_Value;
|
| 410 | my %MEM_DEV_H_Value;
|
| 411 | &ParseDefinition($CUSTOM_FEATURECONFIG_H, \%FEATURE_CONFIG_Value);
|
| 412 | &ParseDefinition($CUSTOM_MEMORYDEVICE_H, \%MEM_DEV_H_Value);
|
| 413 |
|
| 414 | if (exists $FEATURE_CONFIG_Value{'PROJECT_EXPECTED_CODE_LIMIT'})
|
| 415 | {
|
| 416 | $nROMsize = hex($FEATURE_CONFIG_Value{'PROJECT_EXPECTED_CODE_LIMIT'});;
|
| 417 | }
|
| 418 | elsif (exists $MEM_DEV_H_Value{'NOR_BOOTING_NOR_FS_BASE_ADDRESS'})
|
| 419 | {
|
| 420 | $nROMsize = hex($MEM_DEV_H_Value{'NOR_BOOTING_NOR_FS_BASE_ADDRESS'});
|
| 421 | }
|
| 422 | else
|
| 423 | {
|
| 424 | my $flash_size = 0;
|
| 425 | my $sum_of_regions = 0;
|
| 426 | my $bisNORFDM5 = 0;
|
| 427 | my %FLASH_H_Value;
|
| 428 | my (@FLASH_H_Value_BLK_LIST, @FLASH_H_Value_REGION_LIST, @FLASH_H_Value_BANK_LIST);
|
| 429 | &ParseFlashInfo($CUSTOM_FALSH_H, \%FLASH_H_Value, \@FLASH_H_Value_BLK_LIST,
|
| 430 | \@FLASH_H_Value_REGION_LIST,
|
| 431 | \@FLASH_H_Value_BANK_LIST);
|
| 432 | $flash_size = hex($FLASH_H_Value{'NOR_FLASH_DENSITY'});
|
| 433 | $bisNORFDM5 = ((defined $MEM_DEV_H_Value{'__NOR_FDM5__'}) && ($MEM_DEV_H_Value{'__NOR_FDM5__'} eq 'TRUE')) ? 1 : 0;
|
| 434 | $sum_of_regions = &Comp_lastBANKsize(\@FLASH_H_Value_REGION_LIST, \@FLASH_H_Value_BLK_LIST, $flash_size, $bisNORFDM5);
|
| 435 | $nROMsize = $flash_size - $sum_of_regions;
|
| 436 | }
|
| 437 | return $nROMsize;
|
| 438 | }
|
| 439 |
|
| 440 | #****************************************************************************
|
| 441 | # Subroutine: GetROMregion - to query all regions placed in ROM
|
| 442 | # Parameters: $BB_PATH
|
| 443 | # $SCATTERFILE = the path of scatter file
|
| 444 | # $ROMregion_href = a Hash reference to store ROM regions
|
| 445 | # $ROMregion_href->{regionName} = []
|
| 446 | # $MAKEFILE_ref = a Hash to contain MAKEFILE information
|
| 447 | # Returns: $nROMnum = the number of ROM regions
|
| 448 | #****************************************************************************
|
| 449 | sub GetROMregion
|
| 450 | {
|
| 451 | my ($BB_path, $SCATTERFILE, $ROMregion_href, $MAKEFILE_ref) = (@_);
|
| 452 | my $CUSTOM_FEATURECONFIG_H = $BB_path . '/' . "custom_FeatureConfig.h";
|
| 453 | my $nROMnum = 0;
|
| 454 | my $isNOR = (&FileInfo::is_NOR() and !FileInfo::is_SmartPhone()) ? 1 : 0;
|
| 455 |
|
| 456 | return $nROMnum if(!$isNOR);
|
| 457 |
|
| 458 | &GetScatInfo($SCATTERFILE);
|
| 459 | my $ExeRegion_ref = $g_MAUIScat->GetAllExeRegion();
|
| 460 | foreach (@$ExeRegion_ref)
|
| 461 | {
|
| 462 | if($_ =~ /^ROM/)
|
| 463 | {
|
| 464 | $nROMnum++;
|
| 465 | $ROMregion_href -> {$_} = [];
|
| 466 | }
|
| 467 | }
|
| 468 | return ($nROMnum);
|
| 469 | }
|
| 470 |
|
| 471 | #****************************************************************************
|
| 472 | # Subroutine: Gen_RegionName_EV_DUMMY_END_Base - to query DUMMY_END region
|
| 473 | # Parameters: $bb = bb chip
|
| 474 | # Returns: $strRegionName = region name
|
| 475 | #****************************************************************************
|
| 476 | sub Gen_RegionName_EV_DUMMY_END_Base
|
| 477 | {
|
| 478 | my ($bb) = (@_);
|
| 479 | my $strRegionName;
|
| 480 | if(1 == &sysUtil::is_mmu($bb))
|
| 481 | {
|
| 482 | $strRegionName = "CACHED_DUMMY_END";
|
| 483 | $strRegionName = $g_MAUIScat->SearchExeRegionName("DUMMY_END") if(! $g_MAUIScat->IsRegionExistent($strRegionName));
|
| 484 | }
|
| 485 | return $strRegionName;
|
| 486 | }
|
| 487 |
|
| 488 | #****************************************************************************
|
| 489 | # Subroutine: Gen_RegionName_EV_LAST_CACHED_REGION - to query the last cached region
|
| 490 | # before dummy end
|
| 491 | # Parameters: $bb = bb chip
|
| 492 | # Returns: $strPreviousRegionName = region name
|
| 493 | #****************************************************************************
|
| 494 | sub Gen_RegionName_EV_LAST_CACHED_REGION
|
| 495 | {
|
| 496 | my ($bb) = (@_);
|
| 497 | my $strPreviousRegionName;
|
| 498 | if(1 == &sysUtil::is_mmu($bb))
|
| 499 | {
|
| 500 | my $strRegionName = &Gen_RegionName_EV_DUMMY_END_Base($bb);
|
| 501 | $strPreviousRegionName = $g_MAUIScat->GetPreviousExeRegionName($strRegionName) if(defined $strRegionName);
|
| 502 | &sysInfoProcSCAT_die("Region Name can't be empty!", __FILE__, __LINE__) if(!defined $strPreviousRegionName);
|
| 503 | }
|
| 504 | return $strPreviousRegionName;
|
| 505 | }
|
| 506 | #****************************************************************************
|
| 507 | # Subroutine: ParseFlashInfo - parse key definition in CUSTOM_FLASH_H
|
| 508 | # Parameters: $strFilePath
|
| 509 | # $Hash_refResult Container) = a Hash reference to store the parse result
|
| 510 | # $BLK_LIST_aref = an Array reference to store Block info
|
| 511 | # $REGION_LIST_aref = an Array reference to store Region info
|
| 512 | # $BANK_LIST_aref = an Array reference to store Bank info
|
| 513 | #****************************************************************************
|
| 514 | sub ParseFlashInfo
|
| 515 | {
|
| 516 | my ($strFilePath, $Hash_ref, $BLK_LIST_aref, $REGION_LIST_aref, $BANK_LIST_aref) = @_;
|
| 517 | open (FLASHC_HANDLE, "<$strFilePath") or &sysInfoProcSCAT_die("$strFilePath: file error!", __FILE__, __LINE__);
|
| 518 | while (<FLASHC_HANDLE>) {
|
| 519 | if (/^FLASH_REGIONINFO_VAR_MODIFIER\s+FlashBlockTBL\s+\S+/)
|
| 520 | {
|
| 521 | $Hash_ref->{'BlockTBLFlag'} ++;
|
| 522 | }
|
| 523 | elsif (defined $Hash_ref->{'BlockTBLFlag'})
|
| 524 | {
|
| 525 | $Hash_ref->{'BlockTBLTxt'} .= $_;
|
| 526 | # debug purpose
|
| 527 | # print $_;
|
| 528 | if (/\{\s*(\S+)\s*,\s*(\S+)\s*\}/)
|
| 529 | {
|
| 530 | push @$BLK_LIST_aref, $_;
|
| 531 | }
|
| 532 | delete $Hash_ref->{'BlockTBLFlag'} if (/^\s+EndBlockInfo\s+/);
|
| 533 | }
|
| 534 | elsif (/^FLASH_REGIONINFO_VAR_MODIFIER\s+FlashRegionInfo\s+oriRegionInfo\S+/)
|
| 535 | {
|
| 536 | $Hash_ref->{'RegionInfoFlag'} ++;
|
| 537 | }
|
| 538 | elsif (defined $Hash_ref->{'RegionInfoFlag'})
|
| 539 | {
|
| 540 | $Hash_ref->{'RegionInfoTxt'} .= $_;
|
| 541 | if (/\{\s*(\S+)\s*,\s*(\S+)\s*\}/)
|
| 542 | {
|
| 543 | push @$REGION_LIST_aref, $_;
|
| 544 | }
|
| 545 | delete $Hash_ref->{'RegionInfoFlag'} if (/^\s+EndoriRegionInfo\s+/);
|
| 546 | }
|
| 547 | elsif (/^static\s+NORBankInfo\s+oriBankInfo\S+/)
|
| 548 | {
|
| 549 | $Hash_ref->{'BankInfoFlag'} ++;
|
| 550 | }
|
| 551 | elsif (defined $Hash_ref->{'BankInfoFlag'})
|
| 552 | {
|
| 553 | $Hash_ref->{'BankInfoTxt'} .= $_;
|
| 554 | if (/\{\s*(\S+)\s*,\s*(\S+)\s*\}/)
|
| 555 | {
|
| 556 | push @$BANK_LIST_aref, $_;
|
| 557 | }
|
| 558 | delete $Hash_ref->{'BankInfoFlag'} if (/^\s+EndBankInfo\s+/);
|
| 559 | }
|
| 560 | elsif (/^\s*\*\s+NOR_FLASH_DENSITY:\s*(\w*)/)
|
| 561 | {
|
| 562 | $Hash_ref->{'NOR_FLASH_DENSITY'} = $1;
|
| 563 | }
|
| 564 | elsif (/^\s*\*\s+NOR_FLASH_SIZE\(Mb\):\s*(\w*)/)
|
| 565 | {
|
| 566 | $Hash_ref->{'NOR_FLASH_SIZE(Mb)'} = $1;
|
| 567 | }
|
| 568 | }
|
| 569 | close (FLASHC_HANDLE);
|
| 570 | }
|
| 571 |
|
| 572 | #****************************************************************************
|
| 573 | # Subroutine: ParseDefinition - parse key definition in the input file
|
| 574 | # Parameters: $strFilePath
|
| 575 | # $Hash_refResult Container) = a Hash reference to store the parse result
|
| 576 | #****************************************************************************
|
| 577 | sub ParseDefinition
|
| 578 | {
|
| 579 | my ($strFilePath, $Hash_ref) = @_;
|
| 580 | open (MEMDEVH_HANDLE, "<$strFilePath") or &sysInfoProcSCAT_die("$strFilePath: file error!", __FILE__, __LINE__);
|
| 581 | while (<MEMDEVH_HANDLE>) {
|
| 582 | if (/^#define\s+(\w+)\s+\((\w*)\)/ || /^#define\s+(\w+)\s+(\w*)/)
|
| 583 | {
|
| 584 | my $option = $1;
|
| 585 | my $value = $2;
|
| 586 |
|
| 587 | &sysInfoProcSCAT_die("$strFilePath: $option redefined in custom_MemoryDevice.h!", __FILE__, __LINE__) if defined($Hash_ref->{$option});
|
| 588 | if (!defined $value)
|
| 589 | {
|
| 590 | $Hash_ref->{$option} = 'TRUE';
|
| 591 | }
|
| 592 | else
|
| 593 | {
|
| 594 | $Hash_ref->{$option} = $value;
|
| 595 | }
|
| 596 | }
|
| 597 | }
|
| 598 | close (MEMDEVH_HANDLE);
|
| 599 | }
|
| 600 |
|
| 601 | #****************************************************************************
|
| 602 | # Subroutine: ParseFlashInfo - parse key definition in CUSTOM_FLASH_H
|
| 603 | # Parameters: $regions_aref = an Array reference to store Region info
|
| 604 | # $blk_aref = an Array reference to store Block info
|
| 605 | # $flash_size = Total flash size
|
| 606 | # $bisFDM5 = check if __NOR_FDM5__
|
| 607 | # Returns : $fat_space = the size of FAT
|
| 608 | #****************************************************************************
|
| 609 | sub Comp_lastBANKsize
|
| 610 | {
|
| 611 | my ($regions_aref, $blk_aref, $flash_size , $bisFDM5) = (@_);
|
| 612 | my @regions = @$regions_aref;
|
| 613 | my @blocks = @$blk_aref;
|
| 614 | my $small_block_start = $flash_size;
|
| 615 | my $sum_of_regions = 0;
|
| 616 | my $fat_space = 0;
|
| 617 |
|
| 618 | for (0..$#regions)
|
| 619 | {
|
| 620 | if ($regions[$_] =~ /\{(0x\w+),\s*(\d+)\}/) # match {0x20000, 7}
|
| 621 | {
|
| 622 | $sum_of_regions += hex($1) * $2;
|
| 623 | }
|
| 624 | }
|
| 625 |
|
| 626 | if (($#regions>=0) && $bisFDM5)
|
| 627 | {
|
| 628 | if ($blocks[$#blocks] =~ /\{(0x\w+),\s*(0x\w+)\}/) # match {0xFF0000,0x2000}
|
| 629 | {
|
| 630 | $small_block_start = hex($1);
|
| 631 | }
|
| 632 | $fat_space = $sum_of_regions - ($flash_size-$small_block_start);
|
| 633 | }
|
| 634 | else
|
| 635 | {
|
| 636 | $fat_space = $sum_of_regions;
|
| 637 | }
|
| 638 | return $fat_space;
|
| 639 | }
|
| 640 |
|
| 641 | #****************************************************************************
|
| 642 | # Subroutine: GetLdsInfo - to query Scat info by LdsInfo.pm
|
| 643 | # Parameters: $LDSFILE = lds file
|
| 644 | #****************************************************************************
|
| 645 | sub GetScatInfo
|
| 646 | {
|
| 647 | my ($SCATTERFILE) = (@_);
|
| 648 | $g_MAUIScat = new scatInfo;
|
| 649 | $g_MAUIScat->ParseScatterFile($SCATTERFILE);
|
| 650 | }
|
| 651 |
|
| 652 | #****************************************************************************
|
| 653 | # subroutine: sysInfoProcSCAT_die
|
| 654 | # sample code: (message, __FILE__, __LINE__)
|
| 655 | # parameters: $error_msg, $file, $line_no
|
| 656 | #****************************************************************************
|
| 657 | sub sysInfoProcSCAT_die
|
| 658 | {
|
| 659 | my ($error_msg, $file, $line_no) = (@_);
|
| 660 | &CommonUtil::error_handler($error_msg, $file, $line_no, 'SYSINFOPROCESSSCAT');
|
| 661 | } |