rjw | 6c1fd8f | 2022-11-30 14:33:01 +0800 | [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 | #* SystemInfo.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 sysInfo; |
| 58 | use sysInfoProcessScat; #this module is applied to RVCT compiler |
| 59 | use sysInfoProcessLds; #this module is applied to GCC compiler |
| 60 | use FileInfoParser; |
| 61 | use strict; |
| 62 | |
| 63 | #**************************************************************************** |
| 64 | # Constants |
| 65 | #**************************************************************************** |
| 66 | my $SYSINFO_VERNO = " u0.02"; |
| 67 | # u0.02 , 2015/01/23, Add TX/RX section to FilterOutSharedRegion |
| 68 | # u0.01 , 2015/01/14, Memory Utility Refinement |
| 69 | # m0.05 , 2013/10/20, Support FilterOutSecureRegion() |
| 70 | # m0.04 , 2013/06/25, Support FilterOutCoproReservedRegion() |
| 71 | # m0.03 , 2012/08/03, Modify the comment of GetTCMmargin() |
| 72 | # m0.02 , 2012/08/03, Modify module name and push additional library path |
| 73 | # m0.01 , 2012/07/05, Initial revision |
| 74 | |
| 75 | #**************************************************************************** |
| 76 | # Global variable |
| 77 | #**************************************************************************** |
| 78 | my $DebugPrint = 0; |
| 79 | |
| 80 | #**************************************************************************** |
| 81 | # oo >>> Finished |
| 82 | #**************************************************************************** |
| 83 | return 1; |
| 84 | |
| 85 | #**************************************************************************** |
| 86 | # Subroutine: systemInfo_verno - to query this package's version number |
| 87 | # Parameters: x |
| 88 | # Returns: version number string |
| 89 | #**************************************************************************** |
| 90 | sub systemInfo_verno |
| 91 | { |
| 92 | return $SYSINFO_VERNO; |
| 93 | } |
| 94 | |
| 95 | #**************************************************************************** |
| 96 | # Subroutine: GetChipInsideRAMregion - to query all Chip inside RAM regions |
| 97 | # Parameters: $strFilePath = the path of file (scatter file or lds file) |
| 98 | # $INTSRAMregion_href = a Hash reference to store ChipInsideRAM infomation |
| 99 | # $INTSRAMregion_href->{regionName} = [] |
| 100 | # $MAKEFILE_ref = a Hash to contain MAKEFILE information |
| 101 | # Returns: $nINTSRAMnum = the number of ChipInsideRAM regions |
| 102 | #**************************************************************************** |
| 103 | sub GetChipInsideRAMregion |
| 104 | { |
| 105 | my ($strFilePath, $INTSRAMregion_href, $MAKEFILE_ref) = (@_); |
| 106 | print "file path = $strFilePath\n" if($DebugPrint == 1); |
| 107 | my $strCompiler = &FileInfo::GetCompiler($MAKEFILE_ref); |
| 108 | |
| 109 | my $nINTSRAMnum = 0; |
| 110 | if($strCompiler eq "RVCT") |
| 111 | { |
| 112 | $nINTSRAMnum = &sysInfoProcScat::GetChipInsideRAMregion($strFilePath, $INTSRAMregion_href); |
| 113 | } |
| 114 | elsif($strCompiler eq "GCC") |
| 115 | { |
| 116 | $nINTSRAMnum = &sysInfoProcLds::GetChipInsideRAMregion($strFilePath, $INTSRAMregion_href); |
| 117 | } |
| 118 | return ($nINTSRAMnum); |
| 119 | } |
| 120 | |
| 121 | #**************************************************************************** |
| 122 | # Subroutine: GetChipInsideRAMsize - to query ChipInsideRAM size |
| 123 | # Parameters: $strFilePath = the path of file (scatter file or lds file) |
| 124 | # $INTSRAMinfo_href = a Hash reference to store ChipInsideRAM infomation |
| 125 | # ($INTSRAMinfo_href -> {ChipInsideRAM type} = MaxSize) |
| 126 | # $MAKEFILE_ref = a Hash to contain MAKEFILE information |
| 127 | # Returns: $nINTSRAMnum = the number of ChipInsideRAM types |
| 128 | #**************************************************************************** |
| 129 | sub GetChipInsideRAMsize |
| 130 | { |
| 131 | my ($strFilePath, $INTSRAMinfo_href, $MAKEFILE_ref) = (@_); |
| 132 | print "file path = $strFilePath\n" if($DebugPrint == 1); |
| 133 | my $strCompiler = &FileInfo::GetCompiler($MAKEFILE_ref); |
| 134 | |
| 135 | my $nINTSRAMnum = 0; |
| 136 | if($strCompiler eq "RVCT") |
| 137 | { |
| 138 | $nINTSRAMnum = &sysInfoProcScat::GetChipInsideRAMsize($strFilePath, $INTSRAMinfo_href); |
| 139 | } |
| 140 | elsif($strCompiler eq "GCC") |
| 141 | { |
| 142 | $nINTSRAMnum = &sysInfoProcLds::GetChipInsideRAMsize($strFilePath, $INTSRAMinfo_href); |
| 143 | } |
| 144 | return ($nINTSRAMnum); |
| 145 | } |
| 146 | |
| 147 | #**************************************************************************** |
| 148 | # Subroutine: GetTCMmargin - to query TCM margin |
| 149 | # Parameters: $strFilePath = the path of file (scatter file or lds file) |
| 150 | # $TCMregion_href = a Hash reference to store TCM infomation |
| 151 | # $TCMregion_href->{'regionName'} = size |
| 152 | # $MAKEFILE_ref = a Hash to contain MAKEFILE information |
| 153 | # Returns: $TCMmargin_href = a Hash reference to store TCM information |
| 154 | # $TCMmargin_href->{ITCM}->[0] = ITCM physical size, $TCMmargin_href->{ITCM}->[1] = ITCM margin |
| 155 | # $TCMmargin_href->{DTCM}->[0] = DTCM physical size, $TCMmargin_href->{DTCM}->[1] = DTCM margin |
| 156 | # $TCMmargin_href->{TCM}->[0] = TCM physical size , $TCMmargin_href->{TCM}->[1] = TCM margin |
| 157 | #**************************************************************************** |
| 158 | sub GetTCMmargin |
| 159 | { |
| 160 | my ($strFilePath, $TCMregion_href, $MAKEFILE_ref) = (@_); |
| 161 | print "file path = $strFilePath\n" if($DebugPrint == 1); |
| 162 | my $strCompiler = &FileInfo::GetCompiler($MAKEFILE_ref); |
| 163 | |
| 164 | my $TCMmargin_href = undef; |
| 165 | if($strCompiler eq "RVCT") |
| 166 | { |
| 167 | $TCMmargin_href = &sysInfoProcScat::GetTCMmargin($strFilePath, $TCMregion_href); |
| 168 | } |
| 169 | elsif($strCompiler eq "GCC") |
| 170 | { |
| 171 | $TCMmargin_href = &sysInfoProcLds::GetTCMmargin($strFilePath, $TCMregion_href); |
| 172 | } |
| 173 | return ($TCMmargin_href); |
| 174 | } |
| 175 | |
| 176 | #**************************************************************************** |
| 177 | # Subroutine: GetphysicalRAMsize - to query physical RAM size |
| 178 | # Parameters: $BB_PATH = the path of BB folder |
| 179 | # $MAKEFILE_ref = a Hash to contain MAKEFILE information |
| 180 | # Returns: $nRAMsize = the physical RAM size |
| 181 | #**************************************************************************** |
| 182 | sub GetphysicalRAMsize |
| 183 | { |
| 184 | my ($BB_PATH, $MAKEFILE_ref) = (@_); |
| 185 | my $nRAMsize = undef; |
| 186 | my $strCompiler = &FileInfo::GetCompiler($MAKEFILE_ref); |
| 187 | |
| 188 | if($strCompiler eq "RVCT") |
| 189 | { |
| 190 | $nRAMsize = &sysInfoProcScat::GetphysicalRAMsize($BB_PATH); |
| 191 | } |
| 192 | elsif($strCompiler eq "GCC") |
| 193 | { |
| 194 | $nRAMsize = &sysInfoProcLds::GetphysicalRAMsize($BB_PATH); |
| 195 | } |
| 196 | return $nRAMsize; |
| 197 | } |
| 198 | |
| 199 | #**************************************************************************** |
| 200 | # Subroutine: GetAvailableRAMsize - to query available RAM size |
| 201 | # Parameters: $BB_PATH = the path of BB folder |
| 202 | # $MAKEFILE_ref = a Hash to contain MAKEFILE information |
| 203 | # Returns: $nRAMsize = the available RAM size |
| 204 | #**************************************************************************** |
| 205 | sub GetAvailableRAMsize |
| 206 | { |
| 207 | my ($BB_PATH, $MAKEFILE_ref) = (@_); |
| 208 | my $nRAMsize = undef; |
| 209 | my $strCompiler = &FileInfo::GetCompiler($MAKEFILE_ref); |
| 210 | |
| 211 | if($strCompiler eq "RVCT") |
| 212 | { |
| 213 | $nRAMsize = &sysInfoProcScat::GetAvailableRAMsize($BB_PATH); |
| 214 | } |
| 215 | elsif($strCompiler eq "GCC") |
| 216 | { |
| 217 | $nRAMsize = &sysInfoProcLds::GetAvailableRAMsize($BB_PATH); |
| 218 | } |
| 219 | return $nRAMsize; |
| 220 | } |
| 221 | |
| 222 | #**************************************************************************** |
| 223 | # Subroutine: GetRAMregion - to query all regions placed in RAM |
| 224 | # Parameters: $BB_PATH |
| 225 | # $strFilePath = the path of file (scatter file or lds file) |
| 226 | # $RAMregion_aref = a Array reference to store RAM regions |
| 227 | # $RAMregion_href->{regionName} = [] |
| 228 | # $MAKEFILE_ref = a Hash to contain MAKEFILE information |
| 229 | # Returns: $nRAMnum = the number of RAM regions |
| 230 | #**************************************************************************** |
| 231 | sub GetRAMregion |
| 232 | { |
| 233 | my ($BB_PATH, $strFilePath, $RAMregion_aref, $MAKEFILE_ref) = @_; |
| 234 | print "file path = $strFilePath\n" if($DebugPrint == 1); |
| 235 | my $strCompiler = &FileInfo::GetCompiler($MAKEFILE_ref); |
| 236 | |
| 237 | my $nRAMnum = 0; |
| 238 | if($strCompiler eq "RVCT") |
| 239 | { |
| 240 | $nRAMnum = &sysInfoProcScat::GetRAMregion($BB_PATH, $strFilePath, $RAMregion_aref, $MAKEFILE_ref); |
| 241 | } |
| 242 | elsif($strCompiler eq "GCC") |
| 243 | { |
| 244 | $nRAMnum = &sysInfoProcLds::GetRAMregion($BB_PATH, $strFilePath, $RAMregion_aref, $MAKEFILE_ref); |
| 245 | } |
| 246 | return ($nRAMnum); |
| 247 | } |
| 248 | |
| 249 | #**************************************************************************** |
| 250 | # Subroutine: GetRAMBoundaryregion - to query the boundary regions in RAM |
| 251 | # this function can be used to calculate RAM margin |
| 252 | # Parameters: $strFilePath = the path of file (scatter file or lds file) |
| 253 | # $MAKEFILE_ref = a Hash to contain MAKEFILE information |
| 254 | # Returns: $LAST_CACHED_REGION = the last cached region in RAM |
| 255 | # $DUMMY_END = the dummy_end region in RAM |
| 256 | #**************************************************************************** |
| 257 | sub GetRAMBoundaryregion |
| 258 | { |
| 259 | my ($strFilePath, $MAKEFILE_ref) = (@_); |
| 260 | print "file path = $strFilePath\n" if($DebugPrint == 1); |
| 261 | my $strCompiler = &FileInfo::GetCompiler($MAKEFILE_ref); |
| 262 | |
| 263 | my ($LAST_CACHED_REGION, $DUMMY_END)= (undef, undef); |
| 264 | if($strCompiler eq "RVCT") |
| 265 | { |
| 266 | ($LAST_CACHED_REGION, $DUMMY_END) = &sysInfoProcScat::GetRAMBoundaryregion($strFilePath, $MAKEFILE_ref); |
| 267 | } |
| 268 | elsif($strCompiler eq "GCC") |
| 269 | { |
| 270 | ($LAST_CACHED_REGION, $DUMMY_END) = &sysInfoProcLds::GetRAMBoundaryregion($strFilePath, $MAKEFILE_ref); |
| 271 | } |
| 272 | return ($LAST_CACHED_REGION, $DUMMY_END); |
| 273 | } |
| 274 | |
| 275 | #**************************************************************************** |
| 276 | # Subroutine: GetphysicalROMsize - to query physical ROM size |
| 277 | # Parameters: $BB_PATH = the path of BB folder |
| 278 | # $MAKEFILE_ref = a Hash to contain MAKEFILE information |
| 279 | # Returns: $nROMsize = the physical ROM size |
| 280 | #**************************************************************************** |
| 281 | sub GetphysicalROMsize |
| 282 | { |
| 283 | my ($BB_PATH, $MAKEFILE_ref) = (@_); |
| 284 | my $nROMsize = undef; |
| 285 | my $strCompiler = &FileInfo::GetCompiler($MAKEFILE_ref); |
| 286 | |
| 287 | if($strCompiler eq "RVCT") |
| 288 | { |
| 289 | $nROMsize = &sysInfoProcScat::GetphysicalROMsize($BB_PATH); |
| 290 | } |
| 291 | elsif($strCompiler eq "GCC") |
| 292 | { |
| 293 | $nROMsize = &sysInfoProcLds::GetphysicalROMsize($BB_PATH); |
| 294 | } |
| 295 | return $nROMsize; |
| 296 | } |
| 297 | |
| 298 | #**************************************************************************** |
| 299 | # Subroutine: GetAvailableROMsize - to query available ROM size |
| 300 | # Parameters: $BB_PATH = the path of BB folder |
| 301 | # $MAKEFILE_ref = a Hash to contain MAKEFILE information |
| 302 | # Returns: $nROMsize = the available ROM size |
| 303 | #**************************************************************************** |
| 304 | sub GetAvailableROMsize |
| 305 | { |
| 306 | my ($BB_PATH, $MAKEFILE_ref) = (@_); |
| 307 | my $nROMsize = undef; |
| 308 | my $strCompiler = &FileInfo::GetCompiler($MAKEFILE_ref); |
| 309 | |
| 310 | if($strCompiler eq "RVCT") |
| 311 | { |
| 312 | $nROMsize = &sysInfoProcScat::GetAvailableROMsize($BB_PATH); |
| 313 | } |
| 314 | elsif($strCompiler eq "GCC") |
| 315 | { |
| 316 | $nROMsize = &sysInfoProcLds::GetAvailableROMsize($BB_PATH); |
| 317 | } |
| 318 | return $nROMsize; |
| 319 | } |
| 320 | |
| 321 | #**************************************************************************** |
| 322 | # Subroutine: GetROMregion - to query all regions placed in ROM |
| 323 | # Parameters: $BB_PATH |
| 324 | # $strFilePath = the path of file (scatter file or lds file) |
| 325 | # $ROMregion_href = a Hash reference to store ROM regions |
| 326 | # $ROMregion_href->{regionName} = [] |
| 327 | # $MAKEFILE_ref = a Hash to contain MAKEFILE information |
| 328 | # Returns: $nROMnum = the number of ROM regions |
| 329 | #**************************************************************************** |
| 330 | sub GetROMregion |
| 331 | { |
| 332 | my ($BB_PATH, $strFilePath, $ROMregion_href, $MAKEFILE_ref) = (@_); |
| 333 | print "file path = $strFilePath\n" if($DebugPrint == 1); |
| 334 | my $strCompiler = &FileInfo::GetCompiler($MAKEFILE_ref); |
| 335 | |
| 336 | my $nROMnum = 0; |
| 337 | if($strCompiler eq "RVCT") |
| 338 | { |
| 339 | $nROMnum = &sysInfoProcScat::GetROMregion($BB_PATH, $strFilePath, $ROMregion_href, $MAKEFILE_ref); |
| 340 | } |
| 341 | elsif($strCompiler eq "GCC") |
| 342 | { |
| 343 | $nROMnum = &sysInfoProcLds::GetROMregion($BB_PATH, $strFilePath, $ROMregion_href, $MAKEFILE_ref); |
| 344 | } |
| 345 | return ($nROMnum); |
| 346 | } |
| 347 | |
| 348 | sub FilterOutRegionInRAM |
| 349 | { |
| 350 | my ($prvER_aref, $MAKEFILE_ref) = @_; |
| 351 | my @ERInRAM; |
| 352 | my $strCompiler = &FileInfo::GetCompiler($MAKEFILE_ref); |
| 353 | if($strCompiler eq "GCC") |
| 354 | { |
| 355 | &sysInfoProcLds::FilterOutRegionInRAM($prvER_aref, \@ERInRAM); |
| 356 | } |
| 357 | return \@ERInRAM; |
| 358 | } |
| 359 | sub FilterOutFixedRegion |
| 360 | { |
| 361 | my ($prvER_aref, $MAKEFILE_ref) = @_; |
| 362 | my @ERInRAM; |
| 363 | my $strCompiler = &FileInfo::GetCompiler($MAKEFILE_ref); |
| 364 | if($strCompiler eq "GCC") |
| 365 | { |
| 366 | &sysInfoProcLds::FilterOutFixedRegion($prvER_aref, \@ERInRAM); |
| 367 | } |
| 368 | return \@ERInRAM; |
| 369 | } |
| 370 | |
| 371 | sub FilterOutCoproReservedRegion |
| 372 | { |
| 373 | my ($prvER_aref) = @_; |
| 374 | my @ERs; |
| 375 | my @ReversePrvER = reverse @$prvER_aref; |
| 376 | my $bTrim = 0; |
| 377 | foreach my $item (@ReversePrvER) |
| 378 | { |
| 379 | ####################### |
| 380 | # add L1CORE_LV and L1CORE_RWZI to list |
| 381 | ####################### |
| 382 | if($item !~/copro|L1CORE_LV|L1CORE_RWZI/i) |
| 383 | { |
| 384 | push (@ERs , $item); |
| 385 | } |
| 386 | else |
| 387 | { |
| 388 | # print "[FilterOutCoproReservedRegion]Skip $item\n"; |
| 389 | } |
| 390 | } |
| 391 | @ERs = reverse @ERs; |
| 392 | return \@ERs; |
| 393 | } |
| 394 | |
| 395 | sub FilterOutSecureRegion |
| 396 | { |
| 397 | my ($prvER_aref) = @_; |
| 398 | my @ERs; |
| 399 | my @ReversePrvER = reverse @$prvER_aref; |
| 400 | my $bTrim = 0; |
| 401 | foreach my $item (@ReversePrvER) |
| 402 | { |
| 403 | if($item !~/SECURE_RO|SIGNATURE/i) |
| 404 | { |
| 405 | push (@ERs , $item); |
| 406 | } |
| 407 | else |
| 408 | { |
| 409 | # print "[FilterOutCoproReservedRegion]Skip $item\n"; |
| 410 | } |
| 411 | } |
| 412 | @ERs = reverse @ERs; |
| 413 | return \@ERs; |
| 414 | } |
| 415 | |
| 416 | sub FilterOutSharedRegion |
| 417 | { |
| 418 | my ($prvER_aref) = @_; |
| 419 | my @ERs; |
| 420 | my @ReversePrvER = reverse @$prvER_aref; |
| 421 | my $bTrim = 0; |
| 422 | foreach my $item (@ReversePrvER) |
| 423 | { |
| 424 | if($item !~/SHARED|TX|RX/i) |
| 425 | { |
| 426 | push (@ERs , $item); |
| 427 | } |
| 428 | else |
| 429 | { |
| 430 | # print "[FilterOutCoproReservedRegion]Skip $item\n"; |
| 431 | } |
| 432 | } |
| 433 | @ERs = reverse @ERs; |
| 434 | return \@ERs; |
| 435 | } |
| 436 | |
| 437 | sub GetRegionInfo |
| 438 | { |
| 439 | my ($ER, $nOption, $strFilePath, $MAKEFILE_ref) = @_; |
| 440 | my $strCompiler = &FileInfo::GetCompiler($MAKEFILE_ref); |
| 441 | my $Info; |
| 442 | if($strCompiler eq "GCC") |
| 443 | { |
| 444 | $Info = &sysInfoProcLds::GetRegionInfoFromLDS($ER, $nOption, $strFilePath); |
| 445 | } |
| 446 | return $Info; |
| 447 | } |
| 448 | |
| 449 | sub GetMemoryInfo |
| 450 | { |
| 451 | my ($strName, $nOption, $strFilePath, $MAKEFILE_ref) = @_; |
| 452 | my $strCompiler = &FileInfo::GetCompiler($MAKEFILE_ref); |
| 453 | my $strInfo; |
| 454 | if($strCompiler eq "GCC") |
| 455 | { |
| 456 | $strInfo = &sysInfoProcLds::GetMemoryInfoFromLDS($strName, $nOption, $strFilePath); |
| 457 | } |
| 458 | return $strInfo; |
| 459 | } |
| 460 | |
| 461 | __END__ |
| 462 | |
| 463 | =head1 NAME |
| 464 | |
| 465 | systemInfo.pm - Perl module to get system Infomation |
| 466 | |
| 467 | =head1 SYNOPSIS |
| 468 | |
| 469 | use systemInfo; |
| 470 | |
| 471 | =head2 Table of Contents |
| 472 | |
| 473 | systemInfo consists of a collection of modules whose details |
| 474 | are too big to fit in one document. This POD explains the |
| 475 | top-level APIs and general topics. For detailed implementation |
| 476 | , please see the PODs below: |
| 477 | |
| 478 | Name Description |
| 479 | -------------------------------------------------------- |
| 480 | sysInfoProcessGCC Process module for GCC compiler |
| 481 | sysInfoProcessRVCT Process module for RVCT compiler |
| 482 | -------------------------------------------------------- |
| 483 | |
| 484 | =head1 DESCRIPTION |
| 485 | |
| 486 | The module provides the interfaces to get the system information under GCC/RVCT build environment |
| 487 | |
| 488 | =head1 EXAMPLES |
| 489 | |
| 490 | Here are some code samples showing a possible usage of systemInfo: |
| 491 | |
| 492 | 1. Get all ChipInside-RAM regions |
| 493 | |
| 494 | use systemInfo; |
| 495 | use FileInfoParser; |
| 496 | |
| 497 | my $makeFile = "/proj/[usrID]/[path]/MT6280_R7R8_HSPA(FULL_VERSION).mak"; |
| 498 | my $file = "/proj/[usrID]/[path]/ldsMT6280_R7R8.txt"; |
| 499 | my %MAKEFILE_OPTIONS; |
| 500 | my %ChipInsideRam_region; |
| 501 | my $nChipInsideRAMnum = 0; |
| 502 | |
| 503 | &FileInfo::Parse_MAKEFILE($makeFile, \%MAKEFILE_OPTIONS); #Must run this subroutine first for other activities |
| 504 | |
| 505 | $nChipInsideRAMnum = &sysInfo::GetChipInsideRAMregion($file, \%ChipInsideRam_region, \%MAKEFILE_OPTIONS); |
| 506 | |
| 507 | print "nChipInsideRAMnum = $nChipInsideRAMnum\n"; |
| 508 | foreach my $strRegionName (keys %ChipInsideRam_region) |
| 509 | { |
| 510 | print "ChipInsideRAMregion = $strINTSRAMname\n"; |
| 511 | } |
| 512 | |
| 513 | <OUTPUT> |
| 514 | |
| 515 | nChipInsideRAMnum = 5 |
| 516 | ChipInsideRAMregion = INTSRAM_PHYSICAL_BOUNDARY |
| 517 | ChipInsideRAMregion = INTSRAM_DATA |
| 518 | ChipInsideRAMregion = EMIINIT_CODE |
| 519 | ChipInsideRAMregion = INTSRAM_DATA_PREINIT_ZI |
| 520 | ChipInsideRAMregion = INTSRAM_CODE |
| 521 | |
| 522 | 2. Get the size of all ChipInside RAM |
| 523 | |
| 524 | use systemInfo; |
| 525 | use FileInfoParser; |
| 526 | |
| 527 | my $makeFile = "/proj/[usrID]/[path]/MT6280_R7R8_HSPA(FULL_VERSION).mak"; |
| 528 | my $file = "/proj/[usrID]/[path]/ldsMT6280_R7R8.txt"; |
| 529 | my %MAKEFILE_OPTIONS; |
| 530 | my %ChipInsideRAMInfo; |
| 531 | my $nChipInsideRAMnum = 0; |
| 532 | |
| 533 | &FileInfo::Parse_MAKEFILE($makeFile, \%MAKEFILE_OPTIONS); #Must run this subroutine first for other activities |
| 534 | $nChipInsideRAMnum = &sysInfo::GetINTSRAMsize($file, \%ChipInsideRAMInfo, \%MAKEFILE_OPTIONS); |
| 535 | |
| 536 | print "nChipInsideRAMnum = $nChipInsideRAMnum\n"; |
| 537 | foreach my $strRegionName (keys %ChipInsideRAMInfo) |
| 538 | { |
| 539 | print "$strRegionName size = ".%ChipInsideRAMInfo->{$strRegionName}."\n"; |
| 540 | } |
| 541 | |
| 542 | <OUTPUT> |
| 543 | |
| 544 | nChipInsideRAMnum = 1 |
| 545 | TCM size = 229376 |
| 546 | |
| 547 | 3. Get TCM margin (TCM or DTCM/ITCM) |
| 548 | |
| 549 | to use this API, the following steps are listed: |
| 550 | |
| 551 | [step1] |
| 552 | Get all ChipInside RAM regions - run GetChipInsideRAMregion() subroutine in systemInf.pm |
| 553 | |
| 554 | [step2] |
| 555 | Get the usage of each ChipInside RAM region - run GetTotalSizeByExeRegion() subroutine in LinkerOutputParser.pm |
| 556 | Store these information in a hash - please refer to the example below |
| 557 | ([size] need to replace to the real size get from LinkerOutputParser.pm) |
| 558 | my %ChipInsideRAMinfo= ( |
| 559 | INTSRAM_PHYSICAL_BOUNDARY => [size], |
| 560 | INTSRAM_DATA => [size], |
| 561 | EMIINIT_CODE => [size], |
| 562 | INTSRAM_DATA_PREINIT_ZI => [size], |
| 563 | INTSRAM_CODE => [size], |
| 564 | ); |
| 565 | [step3] |
| 566 | run this script to get TCM margin |
| 567 | (%ChipInsideRAMinfo is created in step2) |
| 568 | |
| 569 | my $makeFile = "/proj/[usrID]/[path]/MT6280_R7R8_HSPA(FULL_VERSION).mak"; |
| 570 | my $file = "/proj/[usrID]/[path]/ldsMT6280_R7R8.txt"; |
| 571 | my %MAKEFILE_OPTIONS; |
| 572 | my $TCMmargin_href = undef; |
| 573 | |
| 574 | &FileInfo::Parse_MAKEFILE($makeFile, \%MAKEFILE_OPTIONS); #Must run this subroutine first for other activities |
| 575 | $TCMmargin_href = &sysInfo::GetTCMmargin($file, \%ChipInsideRAMinfo, \%MAKEFILE_OPTIONS); |
| 576 | |
| 577 | foreach my $strRegionname (keys %$TCMmargin_href) |
| 578 | { |
| 579 | print "$strRegionname margin = ". $TCMmargin_href->{$strRegionname}."\n"; |
| 580 | } |
| 581 | |
| 582 | <OUTPUT> |
| 583 | |
| 584 | TCM margin = 228926 |
| 585 | |
| 586 | 4. Get physical RAM size |
| 587 | |
| 588 | use systemInfo; |
| 589 | use FileInfoParser; |
| 590 | |
| 591 | my $makeFile = "/proj/[usrID]/[path]/MT6280_R7R8_HSPA(FULL_VERSION).mak"; |
| 592 | my $BB_PATH = "/proj/[usrID]/[path]/mcu/build/[project]/[flavor]/custom/system";; |
| 593 | my %MAKEFILE_OPTIONS; |
| 594 | |
| 595 | &FileInfo::Parse_MAKEFILE($makeFile, \%MAKEFILE_OPTIONS); #Must run this subroutine first for other activities |
| 596 | my $nPhyRAMsize = 0; |
| 597 | $nPhyRAMsize = &sysInfo::GetphysicalRAMsize($BB_PATH, \%MAKEFILE_OPTIONS); |
| 598 | print "nPhyRAMsize = $phyRAMsize\n"; |
| 599 | |
| 600 | <OUTPUT> |
| 601 | |
| 602 | nPhyRAMsize = 8388608 |
| 603 | |
| 604 | 5. Get available RAM size |
| 605 | |
| 606 | use systemInfo; |
| 607 | use FileInfoParser; |
| 608 | |
| 609 | my $makeFile = "/proj/[usrID]/[path]/MT6280_R7R8_HSPA(FULL_VERSION).mak"; |
| 610 | my $BB_PATH = "/proj/[usrID]/[path]/mcu/build/[project]/[flavor]/custom/system";; |
| 611 | my %MAKEFILE_OPTIONS; |
| 612 | |
| 613 | &FileInfo::Parse_MAKEFILE($makeFile, \%MAKEFILE_OPTIONS); #Must run this subroutine first for other activities |
| 614 | my $nPhyRAMsize = 0; |
| 615 | $nPhyRAMsize = &sysInfo::GetphysicalRAMsize($BB_PATH, \%MAKEFILE_OPTIONS); |
| 616 | print "nPhyRAMsize = $phyRAMsize\n"; |
| 617 | |
| 618 | <OUTPUT> |
| 619 | |
| 620 | nPhyRAMsize = 8388608 |
| 621 | |
| 622 | 6. Get RAM regions |
| 623 | |
| 624 | use systemInfo; |
| 625 | use FileInfoParser; |
| 626 | |
| 627 | my $makeFile = "/proj/[usrID]/[path]/MT6280_R7R8_HSPA(FULL_VERSION).mak"; |
| 628 | my $BB_PATH = "/proj/[usrID]/[path]/mcu/build/[project]/[flavor]/custom/system"; |
| 629 | my $file = "/proj/[usrID]/[path]/ldsMT6280_R7R8.txt"; |
| 630 | my %MAKEFILE_OPTIONS; |
| 631 | my %RAM_region; |
| 632 | my $nRAMnum = 0; |
| 633 | |
| 634 | &FileInfo::Parse_MAKEFILE($makeFile, \%MAKEFILE_OPTIONS); #Must run this subroutine first for other activities |
| 635 | $nRAMnum = &sysInfo::GetRAMregion($BB_PATH, $file, \%RAM_region, \%MAKEFILE_OPTIONS); |
| 636 | |
| 637 | print "nRAMnum = $nRAMnum\n"; |
| 638 | foreach my $strRAMname (keys %RAM_region) |
| 639 | { |
| 640 | print "RAMregion = $strRAMname\n"; |
| 641 | } |
| 642 | |
| 643 | <OUTPUT> |
| 644 | |
| 645 | nRAMnum = 15 |
| 646 | RAMregion = ROM0 |
| 647 | RAMregion = DYNAMIC_CACHEABLE_EXTSRAM_DEFAULT_NONCACHEABLE_RW |
| 648 | RAMregion = DYNAMIC_CACHEABLE_EXTSRAM_DEFAULT_NONCACHEABLE_ZI_MMIPOOL |
| 649 | RAMregion = ROMHEAD |
| 650 | RAMregion = DYNAMIC_CACHEABLE_EXTSRAM_DEFAULT_CACHEABLE_ZI_MMIPOOL |
| 651 | RAMregion = CACHED_EXTSRAM |
| 652 | RAMregion = EXTSRAM |
| 653 | RAMregion = CACHED_EXTSRAM_NVRAM_LTABLE |
| 654 | RAMregion = ROM |
| 655 | RAMregion = ROM1 |
| 656 | RAMregion = EXTSRAM_DSP_TX |
| 657 | RAMregion = DYNAMIC_CACHEABLE_EXTSRAM_DEFAULT_CACHEABLE_ZI |
| 658 | RAMregion = DYNAMIC_CACHEABLE_EXTSRAM_DEFAULT_NONCACHEABLE_ZI |
| 659 | RAMregion = EXTSRAM_DSP_RX |
| 660 | RAMregion = DYNAMIC_CACHEABLE_EXTSRAM_DEFAULT_CACHEABLE_RW |
| 661 | |
| 662 | NOTE: This function can not be applied to 11B branch |
| 663 | |
| 664 | 7. Get RAM boundary regions |
| 665 | |
| 666 | my $makeFile = "/proj/[usrID]/[path]/MT6280_R7R8_HSPA(FULL_VERSION).mak"; |
| 667 | my $file = "/proj/[usrID]/[path]/ldsMT6280_R7R8.txt"; |
| 668 | my %MAKEFILE_OPTIONS; |
| 669 | |
| 670 | &FileInfo::Parse_MAKEFILE($makeFile, \%MAKEFILE_OPTIONS); #Must run this subroutine first for other activities |
| 671 | my($LastRegionBeforeDUMMYEND, $DUMMY_END) = &sysInfo::GetRAMBoundaryregion($file,\%MAKEFILE_OPTIONS); |
| 672 | |
| 673 | print "Last Region Before DUMMY_END = $LastRegionBeforeDUMMYEND\nDUMMY_END = $DUMMY_END\n"; |
| 674 | |
| 675 | <OUTPUT> |
| 676 | |
| 677 | Last Region Before DUMMY_END = DYNAMIC_CACHEABLE_EXTSRAM_DEFAULT_CACHEABLE_ZI |
| 678 | DUMMY_END = CACHED_DUMMY_END |
| 679 | |
| 680 | Note: This API can be used to get RAM margin |
| 681 | RAM margin = DUMMY_END_base - (LastRegionBeforeDUMMYEND_base + LastRegionBeforeDUMMYEND_size); |
| 682 | |
| 683 | 8. Get physical ROM size |
| 684 | |
| 685 | use systemInfo; |
| 686 | use FileInfoParser; |
| 687 | |
| 688 | my $makeFile = "/proj/[usrID]/[path]/MT6280_R7R8_HSPA(FULL_VERSION).mak"; |
| 689 | my $BB_PATH = "/proj/[usrID]/[path]/mcu/build/[project]/[flavor]/custom/system";; |
| 690 | my %MAKEFILE_OPTIONS; |
| 691 | |
| 692 | &FileInfo::Parse_MAKEFILE($makeFile, \%MAKEFILE_OPTIONS); #Must run this subroutine first for other activities |
| 693 | my $nPhyROMsize = 0; |
| 694 | $nPhyROMsize = &sysInfo::GetphysicalROMsize($BB_PATH, \%MAKEFILE_OPTIONS); |
| 695 | print "nPhyROMsize = $phyROMsize\n"; |
| 696 | |
| 697 | <OUTPUT> |
| 698 | |
| 699 | nPhyROMsize = 268435456 |
| 700 | |
| 701 | 9. Get available ROM size |
| 702 | |
| 703 | use systemInfo; |
| 704 | use FileInfoParser; |
| 705 | |
| 706 | my $makeFile = "/proj/[usrID]/[path]/MT6280_R7R8_HSPA(FULL_VERSION).mak"; |
| 707 | my $BB_PATH = "/proj/[usrID]/[path]/mcu/build/[project]/[flavor]/custom/system";; |
| 708 | my %MAKEFILE_OPTIONS; |
| 709 | |
| 710 | &FileInfo::Parse_MAKEFILE($makeFile, \%MAKEFILE_OPTIONS); #Must run this subroutine first for other activities |
| 711 | my $nPhyROMsize = 0; |
| 712 | $nPhyROMsize = &sysInfo::GetphysicalROMsize($BB_PATH, \%MAKEFILE_OPTIONS); |
| 713 | print "nPhyRAMsize = $phyRAMsize\n"; |
| 714 | |
| 715 | <OUTPUT> |
| 716 | |
| 717 | nPhyROMsize = 0 |
| 718 | |
| 719 | 10. Get ROM regions |
| 720 | |
| 721 | use systemInfo; |
| 722 | use FileInfoParser; |
| 723 | |
| 724 | my $makeFile = "/proj/[usrID]/[path]/MT6280_R7R8_HSPA(FULL_VERSION).mak"; |
| 725 | my $BB_PATH = "/proj/[usrID]/[path]/mcu/build/[project]/[flavor]/custom/system"; |
| 726 | my $file = "/proj/[usrID]/[path]/ldsMT6280_R7R8.txt"; |
| 727 | my %MAKEFILE_OPTIONS; |
| 728 | my %ROM_region; |
| 729 | my $nROMnum = 0; |
| 730 | |
| 731 | &FileInfo::Parse_MAKEFILE($makeFile, \%MAKEFILE_OPTIONS); #Must run this subroutine first for other activities |
| 732 | $nROMnum = &sysInfo::GetROMregion($BB_PATH, $file, \%ROM_region, \%MAKEFILE_OPTIONS); |
| 733 | |
| 734 | print "nROMnum = $nROMnum\n"; |
| 735 | foreach my $strROMname (keys %ROM_region) |
| 736 | { |
| 737 | print "ROMregion = $strROMname\n"; |
| 738 | } |
| 739 | |
| 740 | <OUTPUT> |
| 741 | |
| 742 | nROMnum = 0 |
| 743 | |
| 744 | NOTE: This function can not be applied to 11B branch. |
| 745 | for MOLY, all regions will be moved to RAM. |
| 746 | |
| 747 | =cut |
| 748 | |
| 749 | |