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 | #* vivaConfig.pl
|
| 40 | #*
|
| 41 | #* Project:
|
| 42 | #* --------
|
| 43 | #* Maui_Software
|
| 44 | #*
|
| 45 | #* Description:
|
| 46 | #* ------------
|
| 47 | #* This file implemented the VIVA auto configure process
|
| 48 | #*
|
| 49 | #*
|
| 50 | #* Author:
|
| 51 | #* -------
|
| 52 | #* Ke-Ting Chen (mtk03141)
|
| 53 | #*
|
| 54 | #*****************************************************************************
|
| 55 |
|
| 56 | #****************************************************************************
|
| 57 | # Included Modules
|
| 58 | #****************************************************************************
|
| 59 | use strict;
|
| 60 | use warnings;
|
| 61 | BEGIN { push @INC, "pcore/" , '.\\pcore\\tools\\' } # add additional library path
|
| 62 | use auto_adjust_mem; #pm file name without case sensitivity
|
| 63 | use File::Copy;
|
| 64 | use File::Basename;
|
| 65 | use vivaHelper;
|
| 66 |
|
| 67 | #****************************************************************************
|
| 68 | # History
|
| 69 | #****************************************************************************
|
| 70 | my $VIVA_CONFIG_VERNO = " v1.03";
|
| 71 | # v1.03: Phase in ZIMAGE_FAVOR_ROM
|
| 72 | # v1.02: Phase in BOOT_ZIMAGE
|
| 73 | # v1.01: Add AUTOCONFIG_SELF_MODIFY_SUCCESS error code support
|
| 74 | # v1.00: Phase in VIVA
|
| 75 |
|
| 76 | #****************************************************************************
|
| 77 | # Constants
|
| 78 | #****************************************************************************
|
| 79 | my $DEBUG = 1;
|
| 80 |
|
| 81 | # Path
|
| 82 | my $templateFolderPath = "custom\\system\\Template";
|
| 83 | my $objectListGenFolderPath = "scat_config\\FeatureBased\\ObjListGen";
|
| 84 |
|
| 85 | # Binary
|
| 86 | my $bootZImageBinaryName = "BOOT_ZIMAGE_ER";
|
| 87 | my $zImageBinaryName = "ZIMAGE_ER";
|
| 88 | my $dcmcmpBinaryName = "DYNAMIC_COMP_CODE";
|
| 89 | my $aliceBinaryName = "ALICE";
|
| 90 |
|
| 91 | # Normal scatter
|
| 92 | my $objectROM1ListFileName = "objectROM1.list";
|
| 93 | my $objectBootZImageListFileName = "objectBOOT_ZIMAGE.list";
|
| 94 | my $objectZImageListFileName = "objectZIMAGE.list";
|
| 95 | my $objectAliceListFileName = "objectALICE.list";
|
| 96 |
|
| 97 | # Dummy scatter
|
| 98 | my $objectROM1DummyListFileName = "objectROM1_dummy.list";
|
| 99 | my $objectBootZImageDummyListFileName = "objectBOOT_ZIMAGE_dummy.list";
|
| 100 | my $objectZImageDummyListFileName = "objectZIMAGE_dummy.list";
|
| 101 | my $objectAliceDummyListFileName = "objectALICE_dummy.list";
|
| 102 | my $objectAliceForbidDummyListFileName = "objectALICE_FORBID_dummy.list";
|
| 103 |
|
| 104 | # Alignment
|
| 105 | my $bootZImageSizeAlignment = 256;
|
| 106 | my $zImageSizeAlignment = 256;
|
| 107 | my $dcmcmpSizeAlignment = 256;
|
| 108 | my $aliceSizeAlignment = 256;
|
| 109 |
|
| 110 | my $veneerReserveRatio = 0.05;
|
| 111 | my $smallestSplitableRAMSize = 10240;
|
| 112 |
|
| 113 | my $separateLine = "=============================================================";
|
| 114 |
|
| 115 | use constant CONFIG_FAIL_INSUFFICIENT_RAM => 0;
|
| 116 | use constant CONFIG_FAIL_ZIMAGE_OVERFLOW => 1;
|
| 117 | use constant CONFIG_FAIL_FEATURE_NOT_ENABLED => 2;
|
| 118 | use constant CONFIG_FAIL_NO_CONFIG_CHANGED => 3;
|
| 119 | use constant CONFIG_FAIL_INSUFFICIENT_FLASH_SIZE => 4;
|
| 120 | use constant CONFIG_FAIL_INSUFFICIENT_RAM_FOR_BOOT_ZIMAGE => 5;
|
| 121 |
|
| 122 | #****************************************************************************
|
| 123 | # Arguments
|
| 124 | #****************************************************************************
|
| 125 | &vivaHelper::ErrorHandler("Insufficient arguments!", __LINE__, __FILE__)
|
| 126 | unless scalar(@ARGV) == 7;
|
| 127 |
|
| 128 | my $lisFilePath = $ARGV[0];
|
| 129 | my $dummyBinaryFolder = $ARGV[1];
|
| 130 | my $customFolder = $ARGV[2];
|
| 131 | my $makefilePath = $ARGV[3];
|
| 132 | my $flashConfigFilePath = $ARGV[4];
|
| 133 | my $intermediateFilePath = $ARGV[5];
|
| 134 | my $aapmcLogFilePath = $ARGV[6];
|
| 135 |
|
| 136 | # To align error message file name format
|
| 137 | $lisFilePath =~ s/^.\\|^\\//;
|
| 138 | $dummyBinaryFolder =~ s/^.\\|^\\//;
|
| 139 | $customFolder =~ s/^.\\|^\\//;
|
| 140 | $makefilePath =~ s/^.\\|^\\//;
|
| 141 | $flashConfigFilePath =~ s/^.\\|^\\//;
|
| 142 | $intermediateFilePath =~ s/^.\\|^\\//;
|
| 143 | $aapmcLogFilePath =~ s/^.\\|^\\//;
|
| 144 |
|
| 145 | # Print out the arguments
|
| 146 | printLog($separateLine);
|
| 147 | printLog("Arguments:");
|
| 148 | printLog("LIS File: $lisFilePath");
|
| 149 | printLog("Dummy Binary Folder: $dummyBinaryFolder");
|
| 150 | printLog("Custom Folder: $customFolder");
|
| 151 | printLog("Makefile: $makefilePath");
|
| 152 | printLog("Flash Config File: $flashConfigFilePath");
|
| 153 | printLog("Intermediate File: $intermediateFilePath");
|
| 154 | printLog("");
|
| 155 |
|
| 156 | #****************************************************************************
|
| 157 | # Variables
|
| 158 | #****************************************************************************
|
| 159 | my $objectListFolder = "$customFolder\\$objectListGenFolderPath";
|
| 160 |
|
| 161 | my $featureConfigFilePath = "$customFolder\\custom_FeatureConfig.h";
|
| 162 |
|
| 163 | # Binary
|
| 164 | my $bootZImageBinary = "$dummyBinaryFolder\\$bootZImageBinaryName";
|
| 165 | my $zImageBinary = "$dummyBinaryFolder\\$zImageBinaryName";
|
| 166 | my $dcmcmpBinary = "$dummyBinaryFolder\\$dcmcmpBinaryName";
|
| 167 | my $aliceBinary = "$dummyBinaryFolder\\$aliceBinaryName";
|
| 168 |
|
| 169 | # Normal scatter
|
| 170 | my $objectROM1ListFile = "$objectListFolder\\$objectROM1ListFileName";
|
| 171 | my $objectBootZImageListFile = "$objectListFolder\\$objectBootZImageListFileName";
|
| 172 | my $objectZImageListFile = "$objectListFolder\\$objectZImageListFileName";
|
| 173 | my $objectAliceListFile = "$objectListFolder\\$objectAliceListFileName";
|
| 174 |
|
| 175 | # Dummy scatter
|
| 176 | my $objectROM1DummyListFile = "$objectListFolder\\$objectROM1DummyListFileName";
|
| 177 | my $objectBootZImageDummyListFile = "$objectListFolder\\$objectBootZImageDummyListFileName";
|
| 178 | my $objectZImageDummyListFile = "$objectListFolder\\$objectZImageDummyListFileName";
|
| 179 | my $objectAliceDummyListFile = "$objectListFolder\\$objectAliceDummyListFileName";
|
| 180 | my $objectAliceForbidDummyListFile = "$objectListFolder\\$objectAliceForbidDummyListFileName";
|
| 181 |
|
| 182 | #my $totalLISROMSize;
|
| 183 | my %featureConfig;
|
| 184 |
|
| 185 | # Feature switchs
|
| 186 | my $bootZImageEnabled = 0;
|
| 187 | my $zImageEnabled = 0;
|
| 188 | my $dcmcmpEnabled = 0;
|
| 189 | my $aliceEnabled = 0;
|
| 190 | my $mbaEnabled = 0;
|
| 191 |
|
| 192 | my $zImageFavorROM = 0;
|
| 193 |
|
| 194 | # Output configurations
|
| 195 | my $bootZImageMaxCompressedSize = 0;
|
| 196 |
|
| 197 | my $zImageMaxCompressedSize = 0;
|
| 198 |
|
| 199 | my $dcmcmpMaxCompressedSize = 0;
|
| 200 | my $dcmcmpUsedROM = 0;
|
| 201 | my $dcmcmpUsedRAM = 0;
|
| 202 |
|
| 203 | my $aliceMaxCompressedSize = 0;
|
| 204 |
|
| 205 | # Output object lists
|
| 206 | my @rom1List;
|
| 207 | my @bootZImageList;
|
| 208 | my @zImageList;
|
| 209 | my @aliceList;
|
| 210 |
|
| 211 | # Configure changed
|
| 212 | my $configChanged = 0;
|
| 213 | my $objectListChanged = 0;
|
| 214 |
|
| 215 | #****************************************************************************
|
| 216 | # Initialize
|
| 217 | #****************************************************************************
|
| 218 | printLog($separateLine);
|
| 219 | printLog("[Start initializing stage]");
|
| 220 |
|
| 221 | # Initialize VIVA helper for makefile parsing and LIS parsing
|
| 222 | &vivaHelper::Initialize(vivaHelper::CONFIG_TYPE, $makefilePath, $lisFilePath);
|
| 223 |
|
| 224 | # Check the feature set
|
| 225 | {
|
| 226 | printLog("Checking feature set...");
|
| 227 |
|
| 228 | my $bootZImageOption = &vivaHelper::GetMakefileOption("BOOT_ZIMAGE_SUPPORT");
|
| 229 | my $zImageOption = &vivaHelper::GetMakefileOption("ZIMAGE_SUPPORT");
|
| 230 | my $dcmcmpOption = &vivaHelper::GetMakefileOption("DCM_COMPRESSION_SUPPORT");
|
| 231 | my $aliceOption = &vivaHelper::GetMakefileOption("ALICE_SUPPORT");
|
| 232 | my $mbaOption = &vivaHelper::GetMakefileOption("MULTIPLE_BINARY_FILES");
|
| 233 |
|
| 234 | my $zImageFavorROMOption = &vivaHelper::GetMakefileOption("ZIMAGE_FAVOR_ROM");
|
| 235 |
|
| 236 | if (defined $bootZImageOption and $bootZImageOption eq "TRUE")
|
| 237 | {
|
| 238 | $bootZImageEnabled = 1;
|
| 239 | debugLog("BOOT_ZIMAGE is enabled");
|
| 240 | }
|
| 241 |
|
| 242 | if (defined $zImageOption and $zImageOption eq "TRUE")
|
| 243 | {
|
| 244 | $zImageEnabled = 1;
|
| 245 | debugLog("ZIMAGE is enabled");
|
| 246 | }
|
| 247 |
|
| 248 | if (defined $dcmcmpOption and $dcmcmpOption eq "TRUE")
|
| 249 | {
|
| 250 | $dcmcmpEnabled = 1;
|
| 251 | debugLog("DCM with Compression is enabled");
|
| 252 | }
|
| 253 |
|
| 254 | if (defined $aliceOption and $aliceOption eq "TRUE")
|
| 255 | {
|
| 256 | $aliceEnabled = 1;
|
| 257 | debugLog("ALICE is enabled");
|
| 258 | }
|
| 259 |
|
| 260 | if (defined $zImageFavorROMOption and $zImageFavorROMOption eq "TRUE")
|
| 261 | {
|
| 262 | $zImageFavorROM = 1;
|
| 263 | debugLog("ZIMAGE_FAVOR_ROM is enabled");
|
| 264 | }
|
| 265 |
|
| 266 | if (defined $mbaOption and $mbaOption eq "TRUE")
|
| 267 | {
|
| 268 | $mbaEnabled = 1;
|
| 269 | debugLog("MBA is enabled");
|
| 270 | }
|
| 271 |
|
| 272 | &configFail(CONFIG_FAIL_FEATURE_NOT_ENABLED)
|
| 273 | unless $zImageEnabled or $bootZImageEnabled or $aliceEnabled or $dcmcmpEnabled;
|
| 274 | }
|
| 275 |
|
| 276 | # Parse feature config file
|
| 277 | printLog("Parsing feature configuration file");
|
| 278 | &parseFeatureConfigFile(\%featureConfig);
|
| 279 |
|
| 280 | printLog("[End initializing stage]\n");
|
| 281 |
|
| 282 | #****************************************************************************
|
| 283 | # Configure
|
| 284 | #****************************************************************************
|
| 285 | printLog($separateLine);
|
| 286 | printLog("[Start configuration stage]");
|
| 287 |
|
| 288 | # Note DCMCMP should be configured before BOOT_ZIMAGE, ZIMAGE, and ALICE
|
| 289 | if($dcmcmpEnabled)
|
| 290 | {
|
| 291 | $configChanged = &configDcmcmp() || $configChanged;
|
| 292 | }
|
| 293 |
|
| 294 | printLog("");
|
| 295 |
|
| 296 | if ($bootZImageEnabled and $zImageEnabled and $aliceEnabled)
|
| 297 | {
|
| 298 | my ($configChangedTemp, $objectListChangedTemp);
|
| 299 | if ($zImageFavorROM)
|
| 300 | {
|
| 301 | ($configChangedTemp, $objectListChangedTemp) = configBootZImage_ZImage_Alice_FavorROM();
|
| 302 | }
|
| 303 | else
|
| 304 | {
|
| 305 | ($configChangedTemp, $objectListChangedTemp) = configBootZImage_ZImage_Alice();
|
| 306 | }
|
| 307 | $configChanged = $configChangedTemp || $configChanged;
|
| 308 | $objectListChanged = $objectListChangedTemp || $objectListChanged;
|
| 309 | }
|
| 310 | elsif ($zImageEnabled and $aliceEnabled)
|
| 311 | {
|
| 312 | my ($configChangedTemp, $objectListChangedTemp);
|
| 313 |
|
| 314 | if ($zImageFavorROM)
|
| 315 | {
|
| 316 | ($configChangedTemp, $objectListChangedTemp) = configZImage_Alice_FavorROM();
|
| 317 | }
|
| 318 | else
|
| 319 | {
|
| 320 | ($configChangedTemp, $objectListChangedTemp) = configZImage_Alice();
|
| 321 | }
|
| 322 | $configChanged = $configChangedTemp || $configChanged;
|
| 323 | $objectListChanged = $objectListChangedTemp || $objectListChanged;
|
| 324 | }
|
| 325 | elsif ($zImageEnabled)
|
| 326 | {
|
| 327 | my ($configChangedTemp, $objectListChangedTemp);
|
| 328 |
|
| 329 | if ($zImageFavorROM)
|
| 330 | {
|
| 331 | ($configChangedTemp, $objectListChangedTemp) = configZImage_FavorROM();
|
| 332 | }
|
| 333 | else
|
| 334 | {
|
| 335 | ($configChangedTemp, $objectListChangedTemp) = configZImage();
|
| 336 | }
|
| 337 | $configChanged = $configChangedTemp || $configChanged;
|
| 338 | $objectListChanged = $objectListChangedTemp || $objectListChanged;
|
| 339 | }
|
| 340 | elsif ($aliceEnabled)
|
| 341 | {
|
| 342 | $configChanged = &configAlice() || $configChanged;
|
| 343 | }
|
| 344 | else
|
| 345 | {
|
| 346 | #&configFail(CONFIG_FAIL_FEATURE_NOT_ENABLED);
|
| 347 | }
|
| 348 |
|
| 349 | printLog("[End configuration stage]\n");
|
| 350 |
|
| 351 | #****************************************************************************
|
| 352 | # Output
|
| 353 | #****************************************************************************
|
| 354 | printLog($separateLine);
|
| 355 | printLog("[Start output stage]");
|
| 356 |
|
| 357 | my $outputMessage;
|
| 358 | my %changeList;
|
| 359 | my $result;
|
| 360 |
|
| 361 | # Get original settings
|
| 362 | {
|
| 363 | $outputMessage = "[Before auto adjustment]\n";
|
| 364 |
|
| 365 | if ($zImageEnabled)
|
| 366 | {
|
| 367 | my $zImageMaxCompressedSizeOriginal = &vivaHelper::DecToHex($featureConfig{"CONFIG_ZIMAGE_MAX_COMPRESSED_SIZE"});
|
| 368 | $outputMessage .= "CONFIG_ZIMAGE_MAX_COMPRESSED_SIZE=$zImageMaxCompressedSizeOriginal\n";
|
| 369 | }
|
| 370 |
|
| 371 | if ($bootZImageEnabled)
|
| 372 | {
|
| 373 | my $bootZImageMaxCompressedSizeOriginal = &vivaHelper::DecToHex($featureConfig{"CONFIG_BOOT_ZIMAGE_MAX_COMPRESSED_SIZE"});
|
| 374 | $outputMessage .= "CONFIG_BOOT_ZIMAGE_MAX_COMPRESSED_SIZE=$bootZImageMaxCompressedSizeOriginal\n";
|
| 375 | }
|
| 376 |
|
| 377 | if ($dcmcmpEnabled)
|
| 378 | {
|
| 379 | my $dcmcmpMaxCompressedSizeOriginal = &vivaHelper::DecToHex($featureConfig{"CONFIG_DCMP_MAX_COMPRESSED_SIZE"});
|
| 380 | $outputMessage .= "CONFIG_DCMP_MAX_COMPRESSED_SIZE=$dcmcmpMaxCompressedSizeOriginal\n";
|
| 381 | }
|
| 382 |
|
| 383 | if ($aliceEnabled)
|
| 384 | {
|
| 385 | my $aliceMaxCompressedSizeOriginal = &vivaHelper::DecToHex($featureConfig{"CONFIG_ALICE_MAX_COMPRESSED_SIZE"});
|
| 386 | $outputMessage .= "CONFIG_ALICE_MAX_COMPRESSED_SIZE=$aliceMaxCompressedSizeOriginal\n";
|
| 387 | }
|
| 388 | }
|
| 389 |
|
| 390 | # Get new settings and change list
|
| 391 | {
|
| 392 | $outputMessage .= "[After auto adjustment]\n";
|
| 393 |
|
| 394 | if ($zImageEnabled)
|
| 395 | {
|
| 396 | my $zImageMaxCompressedSizeHex = &vivaHelper::DecToHex($zImageMaxCompressedSize);
|
| 397 | $outputMessage .= "CONFIG_ZIMAGE_MAX_COMPRESSED_SIZE=$zImageMaxCompressedSizeHex\n";
|
| 398 | $changeList{"CONFIG_ZIMAGE_MAX_COMPRESSED_SIZE"} = $zImageMaxCompressedSizeHex;
|
| 399 | }
|
| 400 |
|
| 401 | if ($bootZImageEnabled)
|
| 402 | {
|
| 403 | my $bootZImageMaxCompressedSizeHex = &vivaHelper::DecToHex($bootZImageMaxCompressedSize);
|
| 404 | $outputMessage .= "CONFIG_BOOT_ZIMAGE_MAX_COMPRESSED_SIZE=$bootZImageMaxCompressedSizeHex\n";
|
| 405 | $changeList{"CONFIG_BOOT_ZIMAGE_MAX_COMPRESSED_SIZE"} = $bootZImageMaxCompressedSizeHex;
|
| 406 | }
|
| 407 |
|
| 408 | if ($dcmcmpEnabled)
|
| 409 | {
|
| 410 | my $dcmcmpMaxCompressedSizeHex = &vivaHelper::DecToHex($dcmcmpMaxCompressedSize);
|
| 411 | $outputMessage .= "CONFIG_DCMP_MAX_COMPRESSED_SIZE=$dcmcmpMaxCompressedSizeHex\n";
|
| 412 | $changeList{"CONFIG_DCMP_MAX_COMPRESSED_SIZE"} = $dcmcmpMaxCompressedSizeHex;
|
| 413 | }
|
| 414 |
|
| 415 | if ($aliceEnabled)
|
| 416 | {
|
| 417 | my $aliceMaxCompressedSizeHex = &vivaHelper::DecToHex($aliceMaxCompressedSize);
|
| 418 | $outputMessage .= "CONFIG_ALICE_MAX_COMPRESSED_SIZE=$aliceMaxCompressedSizeHex\n";
|
| 419 | $changeList{"CONFIG_ALICE_MAX_COMPRESSED_SIZE"} = $aliceMaxCompressedSizeHex;
|
| 420 | }
|
| 421 | }
|
| 422 |
|
| 423 | printLog("Configuration results:");
|
| 424 | printLog($outputMessage);
|
| 425 |
|
| 426 | if (&isAutoConfigEnable())
|
| 427 | {
|
| 428 | printLog("Auto adjusting...");
|
| 429 |
|
| 430 | if ($configChanged)
|
| 431 | {
|
| 432 | $result = &AAPMCLogParser::Open($aapmcLogFilePath);
|
| 433 |
|
| 434 | if (ERR::AAPMCLOG_SUCCESS != $result)
|
| 435 | {
|
| 436 | printLog("Cannot open AAPMC log parser!");
|
| 437 | return $result;
|
| 438 | }
|
| 439 | else
|
| 440 | {
|
| 441 | my $p4InfoRef = &AUTO_ADJUST::CreateP4InfoTemplate("mtk03141", "", "VIVA auto config", $outputMessage);
|
| 442 | my $aapmcResult;
|
| 443 |
|
| 444 | $result = &AAPMCLogParser::AddOneChangeRecord($featureConfigFilePath, \%changeList, \%$p4InfoRef);
|
| 445 |
|
| 446 | if (ERR::AAPMCLOG_SUCCESS == $result)
|
| 447 | {
|
| 448 | printLog("Modification succeeded!");
|
| 449 | &printIntermediateFile($outputMessage);
|
| 450 | }
|
| 451 | elsif (ERR::ERR_MODIFYDUPLICATED == $result)
|
| 452 | {
|
| 453 | printLog("Modification duplicated!");
|
| 454 | }
|
| 455 | else
|
| 456 | {
|
| 457 | printLog("Modification failed!");
|
| 458 | }
|
| 459 |
|
| 460 | $aapmcResult = &AAPMCLogParser::Close($aapmcLogFilePath);
|
| 461 |
|
| 462 | if (ERR::AAPMCLOG_SUCCESS != $aapmcResult)
|
| 463 | {
|
| 464 | printLog("Cannot close AAPMC log parser!");
|
| 465 | return $aapmcResult;
|
| 466 | }
|
| 467 | }
|
| 468 | }
|
| 469 | else
|
| 470 | {
|
| 471 | # Only object lists are changed
|
| 472 | $result = ERR::AUTOCONFIG_SELF_MODIFY_SUCCESS;
|
| 473 | &printIntermediateFile($outputMessage);
|
| 474 | }
|
| 475 |
|
| 476 | if ($objectListChanged)
|
| 477 | {
|
| 478 | printLog("Adjusting object list");
|
| 479 |
|
| 480 | debugLog("Adjust ROM1 object list");
|
| 481 | &backupFile($objectROM1ListFile);
|
| 482 | &vivaHelper::SortObjectList(\@rom1List);
|
| 483 | &vivaHelper::OutputObjectListToFile($objectROM1ListFile, \@rom1List);
|
| 484 |
|
| 485 | if ($bootZImageEnabled)
|
| 486 | {
|
| 487 | debugLog("Adjust BOOT_ZIMAGE object list");
|
| 488 | &backupFile($objectBootZImageListFile);
|
| 489 | &vivaHelper::SortObjectList(\@bootZImageList);
|
| 490 | &vivaHelper::OutputObjectListToFile($objectBootZImageListFile, \@bootZImageList);
|
| 491 | }
|
| 492 |
|
| 493 | if ($zImageEnabled)
|
| 494 | {
|
| 495 | debugLog("Adjust ZIMAGE object list");
|
| 496 | &backupFile($objectZImageListFile);
|
| 497 | &vivaHelper::SortObjectList(\@zImageList);
|
| 498 | &vivaHelper::OutputObjectListToFile($objectZImageListFile, \@zImageList);
|
| 499 | }
|
| 500 |
|
| 501 | if ($aliceEnabled)
|
| 502 | {
|
| 503 | debugLog("Adjust ALICE object list");
|
| 504 | &backupFile($objectAliceListFile);
|
| 505 | &vivaHelper::SortObjectList(\@aliceList);
|
| 506 | &vivaHelper::OutputObjectListToFile($objectAliceListFile, \@aliceList);
|
| 507 | }
|
| 508 |
|
| 509 | printLog("Adjusting object list done");
|
| 510 | }
|
| 511 | }
|
| 512 | else
|
| 513 | {
|
| 514 | &printIntermediateFile($outputMessage);
|
| 515 | $result = ERR::NO_MODIFY;
|
| 516 | }
|
| 517 |
|
| 518 | printLog("Result: $result");
|
| 519 | printLog("[End output stage]");
|
| 520 | exit $result;
|
| 521 |
|
| 522 | #****************************************************************************
|
| 523 | # subroutine: configDcmcmp
|
| 524 | # description: Perform the DCMCMP configuration
|
| 525 | # input: None
|
| 526 | # output: DCMCMP max compressed size, changed,
|
| 527 | # DCMCMP used ROM size, DCMCMP used RAM size
|
| 528 | #****************************************************************************
|
| 529 | sub configDcmcmp
|
| 530 | {
|
| 531 | printLog("Configuring DCMCMP...");
|
| 532 |
|
| 533 | # Assumption: same category should be put together
|
| 534 | my @dcmcmpRegionInfo = (
|
| 535 | # feature name category load region on value
|
| 536 | #['BT_AUDIO_VIA_SCO', 'SharePool1', 'DYNAMIC_COMP_RESAMPLE', 'TRUE'],
|
| 537 | ['BT_A2DP_PROFILE', 'SharePool1', 'DYNAMIC_COMP_SBC', 'TRUE'],
|
| 538 | ['BES_LOUDNESS_SUPPORT', 'SharePool2', 'DYNAMIC_COMP_BESLOUDNESS', 'TRUE'],
|
| 539 | ['MP4_DECODE', 'SharePool3', 'DYNAMIC_COMP_MP4DEC', 'SP'],
|
| 540 | ['H264_DECODE', 'SharePool3', 'DYNAMIC_COMP_H264DEC', 'TRUE'],
|
| 541 | ['MP4_ENCODE', 'SharePool3', 'DYNAMIC_COMP_MP4ENC', 'TRUE'],
|
| 542 | ['MP4_DECODE_PROFILE', 'SharePool3', 'DYNAMIC_COMP_MP4ASPDEC', 'ASP'],
|
| 543 | ['VP8_DECODE', 'SharePool3', 'DYNAMIC_COMP_VP8DEC', 'TRUE'],
|
| 544 | ['VIDEO_PLAYER_RECORDER_W_DCM', 'SharePool4', 'DYNAMIC_COMP_VEENC', 'TRUE'],
|
| 545 | ['VIDEO_PLAYER_RECORDER_W_DCM', 'SharePool4', 'DYNAMIC_COMP_VEDEC', 'TRUE'],
|
| 546 | ['DAF_DECODE', 'SharePool5', 'DYNAMIC_COMP_DAF', 'TRUE'],
|
| 547 | ['MELODY_VER', 'SharePool5', 'DYNAMIC_COMP_WAVETABLE', 'DSP_WT_SYN'],
|
| 548 | );
|
| 549 | use constant FEATURE_NAME => 0;
|
| 550 | use constant CATEGORY => 1;
|
| 551 | use constant LOAD_REGION => 2;
|
| 552 | use constant ON_VALUE => 3;
|
| 553 |
|
| 554 | my %regionInfo;
|
| 555 | my $currentCategory = $dcmcmpRegionInfo[0][CATEGORY];
|
| 556 | my $categoryMaxRAM = 0;
|
| 557 |
|
| 558 | # Get the actual size
|
| 559 | foreach my $region (@dcmcmpRegionInfo)
|
| 560 | {
|
| 561 | my $option = &vivaHelper::GetMakefileOption($region->[FEATURE_NAME]);
|
| 562 | if (defined $option and $option eq $region->[ON_VALUE])
|
| 563 | {
|
| 564 | my %regionSize;
|
| 565 |
|
| 566 | &vivaHelper::GetLISLoadRegionInfo($region->[LOAD_REGION], \%regionInfo);
|
| 567 |
|
| 568 | $dcmcmpUsedROM += $regionInfo{"max_size"};
|
| 569 |
|
| 570 | debugLog("$region->[FEATURE_NAME], $region->[CATEGORY], $region->[LOAD_REGION], $region->[ON_VALUE], $regionInfo{max_size}");
|
| 571 |
|
| 572 | if ($currentCategory ne $region->[CATEGORY])
|
| 573 | {
|
| 574 | $dcmcmpUsedRAM += $categoryMaxRAM;
|
| 575 | $categoryMaxRAM = $regionInfo{"max_size"};
|
| 576 | $currentCategory = $region->[CATEGORY];
|
| 577 | }
|
| 578 | elsif ($categoryMaxRAM < $regionInfo{"max_size"})
|
| 579 | {
|
| 580 | $categoryMaxRAM = $regionInfo{"max_size"};
|
| 581 | }
|
| 582 | }
|
| 583 | }
|
| 584 |
|
| 585 | # Last category used RAM
|
| 586 | $dcmcmpUsedRAM += $categoryMaxRAM;
|
| 587 |
|
| 588 | # Get the compressed size
|
| 589 | $dcmcmpMaxCompressedSize = -s $dcmcmpBinary or
|
| 590 | &vivaHelper::ErrorHandler("Cannot get file size $dcmcmpBinary: $!", __FILE__, __LINE__);
|
| 591 |
|
| 592 | $dcmcmpMaxCompressedSize =
|
| 593 | &vivaHelper::RoundUpToAlignment($dcmcmpMaxCompressedSize, $dcmcmpSizeAlignment);
|
| 594 |
|
| 595 | debugLog("Used ROM: $dcmcmpUsedROM");
|
| 596 | debugLog("Used RAM: $dcmcmpUsedRAM");
|
| 597 | printLog("DCMCMP Max Compressed Size: ".vivaHelper::DecToHex($dcmcmpMaxCompressedSize));
|
| 598 |
|
| 599 | # Check whether the cofiguration is changed
|
| 600 | if ($featureConfig{"CONFIG_DCMP_MAX_COMPRESSED_SIZE"} == $dcmcmpMaxCompressedSize)
|
| 601 | {
|
| 602 | debugLog("DCMCMP config not changed");
|
| 603 | return 0;
|
| 604 | }
|
| 605 | else
|
| 606 | {
|
| 607 | debugLog("DCMCMP config changed");
|
| 608 | return 1;
|
| 609 | }
|
| 610 | }
|
| 611 |
|
| 612 | sub configBootZImage_ZImage_Alice
|
| 613 | {
|
| 614 | printLog("Configuring BOOT_ZIMAGE, ZIMAGE, and ALICE...");
|
| 615 |
|
| 616 | my $rom1RegionSize;
|
| 617 | my $bootZImageRegionSize;
|
| 618 | my $zImageRegionSize;
|
| 619 | my $aliceRegionSize;
|
| 620 |
|
| 621 | my @bootZImageDummyList;
|
| 622 | my @aliceForbidDummyList;
|
| 623 | my @anyCodeDummyList;
|
| 624 | my @anyDataDummyList;
|
| 625 |
|
| 626 | my $bootZImageDummyRegionPadding;
|
| 627 | my $aliceForbidDummyRegionPadding;
|
| 628 | my $anyCodeDummyRegionPadding;
|
| 629 | my $anyDataDummyRegionPadding;
|
| 630 |
|
| 631 | my $rom1DummyRegionSize;
|
| 632 | my $bootZImageDummyRegionSize;
|
| 633 | my $zImageDummyRegionSize;
|
| 634 | my $aliceDummyRegionSize;
|
| 635 | my $aliceForbidDummyRegionSize;
|
| 636 | my $anyCodeDummyRegionSize;
|
| 637 | my $anyDataDummyRegionSize;
|
| 638 |
|
| 639 | my $freeRAMSize;
|
| 640 |
|
| 641 | my $availableRAM;
|
| 642 |
|
| 643 | my %variables =
|
| 644 | (
|
| 645 | '$dcmcmpUsedRAM' => ["DCMCMP Used RAM", \$dcmcmpUsedRAM],
|
| 646 | '$veneerReserveRatio' => ["Veneer Reserve Ratio", \$veneerReserveRatio],
|
| 647 | '$rom1RegionSize' => ["ROM1 Region Size", \$rom1RegionSize],
|
| 648 | '$bootZImageRegionSize' => ["BOOT_ZIMAGE Region Size", \$bootZImageRegionSize],
|
| 649 | '$zImageRegionSize' => ["ZIMAGE Region Size", \$zImageRegionSize],
|
| 650 | '$aliceRegionSize' => ["ALICE Region Size", \$aliceRegionSize],
|
| 651 | '$bootZImageDummyRegionPadding' => ["BOOT_ZIMAGE Dummy Region Padding", \$bootZImageDummyRegionPadding],
|
| 652 | '$aliceForbidDummyRegionPadding' => ["ALICE_FORBID Dummy Region Padding", \$aliceForbidDummyRegionPadding],
|
| 653 | '$anyCodeDummyRegionPadding' => ["ANY_CODE Dummy Region Padding", \$anyCodeDummyRegionPadding],
|
| 654 | '$anyDataDummyRegionPadding' => ["ANY_DATA Dummy Region Padding", \$anyDataDummyRegionPadding],
|
| 655 | '$rom1DummyRegionSize' => ["ROM1 Dummy Region Size", \$rom1DummyRegionSize],
|
| 656 | '$bootZImageDummyRegionSize' => ["BOOT_ZIMAGE Dummy Region Size", \$bootZImageDummyRegionSize],
|
| 657 | '$zImageDummyRegionSize' => ["ZIMAGE Dummy Region Size", \$zImageDummyRegionSize],
|
| 658 | '$aliceDummyRegionSize' => ["ALICE Dummy Region Size", \$aliceDummyRegionSize],
|
| 659 | '$aliceForbidDummyRegionSize' => ["ALICE_FORBID Dummy Region Size", \$aliceForbidDummyRegionSize],
|
| 660 | '$anyCodeDummyRegionSize' => ["ANY_CODE Dummy Region Size", \$anyCodeDummyRegionSize],
|
| 661 | '$anyDataDummyRegionSize' => ["ANY_DATA Dummy Region Size", \$anyDataDummyRegionSize],
|
| 662 | '$freeRAMSize' => ["Free RAM Size", \$freeRAMSize],
|
| 663 | '$availableRAM' => ["Available RAM", \$availableRAM],
|
| 664 | );
|
| 665 |
|
| 666 | my %objectLists =
|
| 667 | (
|
| 668 | '@rom1List' => ["ROM1 List", \@rom1List, '$rom1RegionSize',],
|
| 669 | '@bootZImageList' => ["BOOT_ZIMAGE List", \@bootZImageList, '$bootZImageRegionSize',],
|
| 670 | '@zImageList' => ["ZIMAGE List", \@zImageList, '$zImageRegionSize',],
|
| 671 | '@aliceList' => ["ALICE List", \@aliceList, '$aliceRegionSize',],
|
| 672 | '@bootZImageDummyList' => ["BOOT_ZIMAGE Dummy List", \@bootZImageDummyList, '$bootZImageDummyRegionSize', '$bootZImageDummyRegionPadding'],
|
| 673 | '@aliceForbidDummyList' => ["ALICE_FORBID Dummy List", \@aliceForbidDummyList, '$aliceForbidDummyRegionSize', '$aliceForbidDummyRegionPadding'],
|
| 674 | '@anyCodeDummyList' => ["ANY_CODE Dummy List", \@anyCodeDummyList, '$anyCodeDummyRegionSize', '$anyCodeDummyRegionPadding'],
|
| 675 | '@anyDataDummyList' => ["ANY_DATA Dummy List", \@anyDataDummyList, '$anyDataDummyRegionSize', '$anyDataDummyRegionPadding']
|
| 676 | );
|
| 677 |
|
| 678 | printLog("Get dummy scatter object lists");
|
| 679 | {
|
| 680 | # Basic
|
| 681 | &_inputObjectListFromFile($objectROM1DummyListFile, \@rom1List, "ROM1");
|
| 682 | &_inputObjectListFromFile($objectBootZImageDummyListFile, \@bootZImageList, "BOOT_ZIMAGE");
|
| 683 | &_inputObjectListFromFile($objectZImageDummyListFile, \@zImageList, "ZIMAGE");
|
| 684 | &_inputObjectListFromFile($objectAliceDummyListFile, \@aliceList, "ALICE");
|
| 685 |
|
| 686 | # To be added
|
| 687 | $bootZImageDummyRegionPadding = &_inputObjectListFromExecutionRegion("BOOT_ZIMAGE_ER", \@bootZImageDummyList, "+RO", "BOOT_ZIMAGE list");
|
| 688 | $aliceForbidDummyRegionPadding = &_inputObjectListFromExecutionRegion("ALICE_FORBID", \@aliceForbidDummyList, "+RO", "ALICE_FORBID list");
|
| 689 | $anyCodeDummyRegionPadding = &_inputObjectListFromExecutionRegion("ZIMAGE_DUMMY_CODE", \@anyCodeDummyList, "+RO-CODE", "ANY_CODE list");
|
| 690 | $anyDataDummyRegionPadding = &_inputObjectListFromExecutionRegion("ZIMAGE_DUMMY_DATA", \@anyDataDummyList, "+RO-DATA", "ANY_DATA list");
|
| 691 | }
|
| 692 |
|
| 693 | printLog("Get size information");
|
| 694 | {
|
| 695 | $rom1DummyRegionSize = &_getExecutionRegionInfo("ROM1", "actual_size");
|
| 696 | $bootZImageDummyRegionSize = &_getExecutionRegionInfo("BOOT_ZIMAGE_ER", "actual_size");
|
| 697 | $zImageDummyRegionSize = &_getExecutionRegionInfo("ZIMAGE_ER", "actual_size");
|
| 698 | $aliceDummyRegionSize = &_getExecutionRegionInfo("ALICE", "actual_size");
|
| 699 | $aliceForbidDummyRegionSize = &_getExecutionRegionInfo("ALICE_FORBID", "actual_size");
|
| 700 | $anyCodeDummyRegionSize = &_getExecutionRegionInfo("ZIMAGE_DUMMY_CODE", "actual_size");
|
| 701 | $anyDataDummyRegionSize = &_getExecutionRegionInfo("ZIMAGE_DUMMY_DATA", "actual_size");
|
| 702 |
|
| 703 | $rom1RegionSize = $rom1DummyRegionSize;
|
| 704 | $bootZImageRegionSize = $bootZImageDummyRegionSize;
|
| 705 | $zImageRegionSize = $zImageDummyRegionSize;
|
| 706 | $aliceRegionSize = $aliceDummyRegionSize;
|
| 707 |
|
| 708 | $freeRAMSize = &getFreeRAMSize();
|
| 709 | }
|
| 710 |
|
| 711 | # Configure
|
| 712 | {
|
| 713 | printLog("Compute Available RAM");
|
| 714 |
|
| 715 | &_evaluateAssignment('$availableRAM = ($freeRAMSize - $dcmcmpUsedRAM - $zImageDummyRegionSize) * (1 - $veneerReserveRatio)', \%variables);
|
| 716 | $availableRAM = int($availableRAM);
|
| 717 |
|
| 718 | if ($availableRAM < 0)
|
| 719 | {
|
| 720 | &configFail(CONFIG_FAIL_INSUFFICIENT_RAM, -1 * $availableRAM);
|
| 721 | }
|
| 722 | elsif ($availableRAM < $anyDataDummyRegionSize + $aliceForbidDummyRegionSize)
|
| 723 | {
|
| 724 | &configFail(CONFIG_FAIL_INSUFFICIENT_RAM_FOR_BOOT_ZIMAGE, $anyDataDummyRegionSize + $aliceForbidDummyRegionSize - $availableRAM);
|
| 725 | }
|
| 726 |
|
| 727 | # When BOOT_ZIMAGE enabled, all ALICE_FORBID and ANY_DATA list should be in ZIMAGE
|
| 728 | printLog("Push ALICE_FORBID List and ANY_DATA List to ZIMAGE");
|
| 729 | {
|
| 730 | &_pushToObjectList('@zImageList', '@aliceForbidDummyList', \%variables, \%objectLists);
|
| 731 | &_pushToObjectList('@zImageList', '@anyDataDummyList', \%variables, \%objectLists);
|
| 732 |
|
| 733 | &_evaluateAssignment('$availableRAM = $availableRAM - ($aliceForbidDummyRegionSize + $anyDataDummyRegionSize)', \%variables);
|
| 734 | }
|
| 735 |
|
| 736 | # The rest RAM size is then used by BOOT_ZIMAGE
|
| 737 | printLog("Push BOOT_ZIMAGE");
|
| 738 | if ($availableRAM >= $bootZImageDummyRegionSize)
|
| 739 | {
|
| 740 | debugLog("Available RAM >= BOOT_ZIMAGE_ER size");
|
| 741 |
|
| 742 | # All BOOT_ZIMAGE region can be put in RAM
|
| 743 | # No change of BOOT_ZIMAGE object list
|
| 744 | debugLog("BOOT_ZIMAGE list = BOOT_ZIMAGE dummy list");
|
| 745 | debugLog("BOOT_ZIMAGE region size = BOOT_ZIMAGE dummy size = $bootZImageDummyRegionSize");
|
| 746 |
|
| 747 | &_evaluateAssignment('$availableRAM = $availableRAM - $bootZImageDummyRegionSize', \%variables);
|
| 748 | }
|
| 749 | else
|
| 750 | {
|
| 751 | debugLog("Available RAM < BOOT_ZIMAGE_ER size");
|
| 752 |
|
| 753 | # Should split BOOT_ZIMAGE dummy list
|
| 754 | &vivaHelper::ChangeObjectListAttributeListByObjectList(\@bootZImageDummyList, \@bootZImageList);
|
| 755 | @bootZImageList = ();
|
| 756 | $bootZImageRegionSize = 0;
|
| 757 |
|
| 758 | &_splitObjectListAndPush('@bootZImageDummyList', '@bootZImageList', '@rom1List',
|
| 759 | '$availableRAM', \%variables, \%objectLists);
|
| 760 |
|
| 761 | if (0 == scalar(@bootZImageList))
|
| 762 | {
|
| 763 | &configFail(CONFIG_FAIL_INSUFFICIENT_RAM_FOR_BOOT_ZIMAGE, $bootZImageDummyList[-1]->{"size"});
|
| 764 | }
|
| 765 |
|
| 766 | $availableRAM = 0;
|
| 767 | debugLog("Available RAM = 0");
|
| 768 | }
|
| 769 |
|
| 770 | # Finally, the rest RAM is used by ZIMAGE for ANY_CODE
|
| 771 | printLog("Push ANY_CODE to ZIMAGE and ALICE");
|
| 772 | {
|
| 773 | &_splitObjectListAndPushByAvailableRAM('@anyCodeDummyList', '@zImageList', '@aliceList',
|
| 774 | \%variables, \%objectLists);
|
| 775 | }
|
| 776 |
|
| 777 | printLog("Compute the Max Compressed Size");
|
| 778 | {
|
| 779 | $bootZImageMaxCompressedSize = &_getRegionMaxCompressedSize("BOOT_ZIMAGE", $bootZImageRegionSize, $bootZImageDummyRegionSize, $bootZImageBinary);
|
| 780 | $zImageMaxCompressedSize = &_getRegionMaxCompressedSize("ZIMAGE", $zImageRegionSize, $zImageDummyRegionSize + $anyCodeDummyRegionSize + $anyDataDummyRegionSize, $zImageBinary);
|
| 781 | $aliceMaxCompressedSize = &_getRegionMaxCompressedSize("ALICE", $aliceRegionSize, $aliceDummyRegionSize, $aliceBinary);
|
| 782 | }
|
| 783 |
|
| 784 | $bootZImageMaxCompressedSize =
|
| 785 | &vivaHelper::RoundUpToAlignment($bootZImageMaxCompressedSize, $bootZImageSizeAlignment);
|
| 786 | $zImageMaxCompressedSize =
|
| 787 | &vivaHelper::RoundDownToAlignment($zImageMaxCompressedSize, $zImageSizeAlignment);
|
| 788 | $aliceMaxCompressedSize =
|
| 789 | &vivaHelper::RoundUpToAlignment($aliceMaxCompressedSize, $aliceSizeAlignment);
|
| 790 |
|
| 791 | printLog("BOOT_ZIMAGE Max Compressed Size: ".vivaHelper::DecToHex($bootZImageMaxCompressedSize));
|
| 792 | printLog("ZIMAGE Max Compressed Size: ".vivaHelper::DecToHex($zImageMaxCompressedSize));
|
| 793 | printLog("ALICE Max Compressed Size: ".vivaHelper::DecToHex($aliceMaxCompressedSize));
|
| 794 | }
|
| 795 |
|
| 796 | # Check whether the configurations are changed
|
| 797 | {
|
| 798 | if ($featureConfig{"CONFIG_BOOT_ZIMAGE_MAX_COMPRESSED_SIZE"} == $bootZImageMaxCompressedSize and
|
| 799 | $featureConfig{"CONFIG_ZIMAGE_MAX_COMPRESSED_SIZE"} == $zImageMaxCompressedSize and
|
| 800 | $featureConfig{"CONFIG_ALICE_MAX_COMPRESSED_SIZE"} == $aliceMaxCompressedSize)
|
| 801 | {
|
| 802 | debugLog("Config not changed");
|
| 803 | $configChanged = 0;
|
| 804 | }
|
| 805 | else
|
| 806 | {
|
| 807 | debugLog("Config changed");
|
| 808 | $configChanged = 1;
|
| 809 | }
|
| 810 |
|
| 811 | if (&_isObjectListChanged($objectROM1ListFile, \@rom1List) or
|
| 812 | &_isObjectListChanged($objectBootZImageListFile, \@bootZImageList) or
|
| 813 | &_isObjectListChanged($objectZImageListFile, \@zImageList) or
|
| 814 | &_isObjectListChanged($objectAliceListFile, \@aliceList))
|
| 815 | {
|
| 816 | debugLog("Object list changed");
|
| 817 | $objectListChanged = 1;
|
| 818 | }
|
| 819 | else
|
| 820 | {
|
| 821 | debugLog("Object list not changed");
|
| 822 | $objectListChanged = 0;
|
| 823 | }
|
| 824 | }
|
| 825 |
|
| 826 | return ($configChanged, $objectListChanged);
|
| 827 | }
|
| 828 |
|
| 829 | sub configZImage_Alice
|
| 830 | {
|
| 831 | printLog("Configuring ZIMAGE and ALICE...");
|
| 832 |
|
| 833 | my $rom1RegionSize;
|
| 834 | my $zImageRegionSize;
|
| 835 | my $aliceRegionSize;
|
| 836 |
|
| 837 | my @aliceForbidDummyList;
|
| 838 | my @anyCodeDummyList;
|
| 839 | my @anyDataDummyList;
|
| 840 |
|
| 841 | my $aliceForbidDummyRegionPadding;
|
| 842 | my $anyCodeDummyRegionPadding;
|
| 843 | my $anyDataDummyRegionPadding;
|
| 844 |
|
| 845 | my $rom1DummyRegionSize;
|
| 846 | my $zImageDummyRegionSize;
|
| 847 | my $aliceDummyRegionSize;
|
| 848 | my $aliceForbidDummyRegionSize;
|
| 849 | my $anyCodeDummyRegionSize;
|
| 850 | my $anyDataDummyRegionSize;
|
| 851 |
|
| 852 | my $freeRAMSize;
|
| 853 |
|
| 854 | my $availableRAM;
|
| 855 |
|
| 856 | my %variables =
|
| 857 | (
|
| 858 | '$dcmcmpUsedRAM' => ["DCMCMP Used RAM", \$dcmcmpUsedRAM],
|
| 859 | '$veneerReserveRatio' => ["Veneer Reserve Ratio", \$veneerReserveRatio],
|
| 860 | '$rom1RegionSize' => ["ROM1 Region Size", \$rom1RegionSize],
|
| 861 | '$zImageRegionSize' => ["ZIMAGE Region Size", \$zImageRegionSize],
|
| 862 | '$aliceRegionSize' => ["ALICE Region Size", \$aliceRegionSize],
|
| 863 | '$aliceForbidDummyRegionPadding' => ["ALICE_FORBID Dummy Region Padding", \$aliceForbidDummyRegionPadding],
|
| 864 | '$anyCodeDummyRegionPadding' => ["ANY_CODE Dummy Region Padding", \$anyCodeDummyRegionPadding],
|
| 865 | '$anyDataDummyRegionPadding' => ["ANY_DATA Dummy Region Padding", \$anyDataDummyRegionPadding],
|
| 866 | '$rom1DummyRegionSize' => ["ROM1 Dummy Region Size", \$rom1DummyRegionSize],
|
| 867 | '$zImageDummyRegionSize' => ["ZIMAGE Dummy Region Size", \$zImageDummyRegionSize],
|
| 868 | '$aliceDummyRegionSize' => ["ALICE Dummy Region Size", \$aliceDummyRegionSize],
|
| 869 | '$aliceForbidDummyRegionSize' => ["ALICE_FORBID Dummy Region Size", \$aliceForbidDummyRegionSize],
|
| 870 | '$anyCodeDummyRegionSize' => ["ANY_CODE Dummy Region Size", \$anyCodeDummyRegionSize],
|
| 871 | '$anyDataDummyRegionSize' => ["ANY_DATA Dummy Region Size", \$anyDataDummyRegionSize],
|
| 872 | '$freeRAMSize' => ["Free RAM Size", \$freeRAMSize],
|
| 873 | '$availableRAM' => ["Available RAM", \$availableRAM],
|
| 874 | );
|
| 875 |
|
| 876 | my %objectLists =
|
| 877 | (
|
| 878 | '@rom1List' => ["ROM1 List", \@rom1List, '$rom1RegionSize',],
|
| 879 | '@zImageList' => ["ZIMAGE List", \@zImageList, '$zImageRegionSize',],
|
| 880 | '@aliceList' => ["ALICE List", \@aliceList, '$aliceRegionSize',],
|
| 881 | '@aliceForbidDummyList' => ["ALICE_FORBID Dummy List", \@aliceForbidDummyList, '$aliceForbidDummyRegionSize', '$aliceForbidDummyRegionPadding'],
|
| 882 | '@anyCodeDummyList' => ["ANY_CODE Dummy List", \@anyCodeDummyList, '$anyCodeDummyRegionSize', '$anyCodeDummyRegionPadding'],
|
| 883 | '@anyDataDummyList' => ["ANY_DATA Dummy List", \@anyDataDummyList, '$anyDataDummyRegionSize', '$anyDataDummyRegionPadding']
|
| 884 | );
|
| 885 |
|
| 886 | printLog("Get dummy scatter object lists");
|
| 887 | {
|
| 888 | # Basic
|
| 889 | &_inputObjectListFromFile($objectROM1DummyListFile, \@rom1List, "ROM1");
|
| 890 | &_inputObjectListFromFile($objectZImageDummyListFile, \@zImageList, "ZIMAGE");
|
| 891 | &_inputObjectListFromFile($objectAliceDummyListFile, \@aliceList, "ALICE");
|
| 892 |
|
| 893 | # To be added
|
| 894 | $aliceForbidDummyRegionPadding = &_inputObjectListFromExecutionRegion("ALICE_FORBID", \@aliceForbidDummyList, "+RO", "ALICE_FORBID list");
|
| 895 | $anyCodeDummyRegionPadding = &_inputObjectListFromExecutionRegion("ZIMAGE_DUMMY_CODE", \@anyCodeDummyList, "+RO-CODE", "ANY_CODE list");
|
| 896 | $anyDataDummyRegionPadding = &_inputObjectListFromExecutionRegion("ZIMAGE_DUMMY_DATA", \@anyDataDummyList, "+RO-DATA", "ANY_DATA list");
|
| 897 | }
|
| 898 |
|
| 899 | printLog("Get size information");
|
| 900 | {
|
| 901 | $rom1DummyRegionSize = &_getExecutionRegionInfo("ROM1", "actual_size");
|
| 902 | $zImageDummyRegionSize = &_getExecutionRegionInfo("ZIMAGE_ER", "actual_size");
|
| 903 | $aliceDummyRegionSize = &_getExecutionRegionInfo("ALICE", "actual_size");
|
| 904 | $aliceForbidDummyRegionSize = &_getExecutionRegionInfo("ALICE_FORBID", "actual_size");
|
| 905 | $anyCodeDummyRegionSize = &_getExecutionRegionInfo("ZIMAGE_DUMMY_CODE", "actual_size");
|
| 906 | $anyDataDummyRegionSize = &_getExecutionRegionInfo("ZIMAGE_DUMMY_DATA", "actual_size");
|
| 907 |
|
| 908 | $rom1RegionSize = $rom1DummyRegionSize;
|
| 909 | $zImageRegionSize = $zImageDummyRegionSize;
|
| 910 | $aliceRegionSize = $aliceDummyRegionSize;
|
| 911 |
|
| 912 | $freeRAMSize = &getFreeRAMSize();
|
| 913 | }
|
| 914 |
|
| 915 | # Configure
|
| 916 | {
|
| 917 | printLog("Compute Available RAM");
|
| 918 |
|
| 919 | &_evaluateAssignment('$availableRAM = ($freeRAMSize - $dcmcmpUsedRAM - $zImageDummyRegionSize) * (1 - $veneerReserveRatio)', \%variables);
|
| 920 | $availableRAM = int($availableRAM);
|
| 921 |
|
| 922 | if ($availableRAM < 0)
|
| 923 | {
|
| 924 | &configFail(CONFIG_FAIL_INSUFFICIENT_RAM, -1 * $availableRAM);
|
| 925 | }
|
| 926 |
|
| 927 | # The available RAM is first used to compress ALICE_FORBID list
|
| 928 | printLog("Push ALICE_FORBID List to ZIMAGE and ROM1");
|
| 929 | {
|
| 930 | &_splitObjectListAndPushByAvailableRAM('@aliceForbidDummyList', '@zImageList', '@rom1List',
|
| 931 | \%variables, \%objectLists);
|
| 932 | }
|
| 933 |
|
| 934 | # The rest RAM size is then used by ANY_DATA
|
| 935 | printLog("Push ANY_DATA to ZIMAGE and ROM1");
|
| 936 | {
|
| 937 | &_splitObjectListAndPushByAvailableRAM('@anyDataDummyList', '@zImageList', '@rom1List',
|
| 938 | \%variables, \%objectLists);
|
| 939 | }
|
| 940 |
|
| 941 | # Finally, the rest RAM is used by ZIMAGE for ANY_CODE
|
| 942 | printLog("Push ANY_CODE to ZIMAGE or ALICE");
|
| 943 | {
|
| 944 | &_splitObjectListAndPushByAvailableRAM('@anyCodeDummyList', '@zImageList', '@aliceList',
|
| 945 | \%variables, \%objectLists);
|
| 946 | }
|
| 947 |
|
| 948 | printLog("Compute the Max Compressed Size");
|
| 949 | {
|
| 950 | $zImageMaxCompressedSize = &_getRegionMaxCompressedSize("ZIMAGE", $zImageRegionSize, $zImageDummyRegionSize + $anyCodeDummyRegionSize + $anyDataDummyRegionSize, $zImageBinary);
|
| 951 | $aliceMaxCompressedSize = &_getRegionMaxCompressedSize("ALICE", $aliceRegionSize, $aliceDummyRegionSize, $aliceBinary);
|
| 952 | }
|
| 953 |
|
| 954 | $zImageMaxCompressedSize =
|
| 955 | &vivaHelper::RoundDownToAlignment($zImageMaxCompressedSize, $zImageSizeAlignment);
|
| 956 | $aliceMaxCompressedSize =
|
| 957 | &vivaHelper::RoundUpToAlignment($aliceMaxCompressedSize, $aliceSizeAlignment);
|
| 958 |
|
| 959 | printLog("ZIMAGE Max Compressed Size: ".vivaHelper::DecToHex($zImageMaxCompressedSize));
|
| 960 | printLog("ALICE Max Compressed Size: ".vivaHelper::DecToHex($aliceMaxCompressedSize));
|
| 961 | }
|
| 962 |
|
| 963 | # Check whether the configurations are changed
|
| 964 | {
|
| 965 | if ($featureConfig{"CONFIG_ZIMAGE_MAX_COMPRESSED_SIZE"} == $zImageMaxCompressedSize and
|
| 966 | $featureConfig{"CONFIG_ALICE_MAX_COMPRESSED_SIZE"} == $aliceMaxCompressedSize)
|
| 967 | {
|
| 968 | debugLog("Config not changed");
|
| 969 | $configChanged = 0;
|
| 970 | }
|
| 971 | else
|
| 972 | {
|
| 973 | debugLog("Config changed");
|
| 974 | $configChanged = 1;
|
| 975 | }
|
| 976 |
|
| 977 | if (&_isObjectListChanged($objectROM1ListFile, \@rom1List) or
|
| 978 | &_isObjectListChanged($objectZImageListFile, \@zImageList) or
|
| 979 | &_isObjectListChanged($objectAliceListFile, \@aliceList))
|
| 980 | {
|
| 981 | debugLog("Object list changed");
|
| 982 | $objectListChanged = 1;
|
| 983 | }
|
| 984 | else
|
| 985 | {
|
| 986 | debugLog("Object list not changed");
|
| 987 | $objectListChanged = 0;
|
| 988 | }
|
| 989 | }
|
| 990 |
|
| 991 | return ($configChanged, $objectListChanged);
|
| 992 | }
|
| 993 |
|
| 994 | sub configZImage
|
| 995 | {
|
| 996 | printLog("Configuring ZIMAGE");
|
| 997 |
|
| 998 | my $rom1RegionSize;
|
| 999 | my $zImageRegionSize;
|
| 1000 |
|
| 1001 | my @anyCodeDummyList;
|
| 1002 | my @anyDataDummyList;
|
| 1003 |
|
| 1004 | my $anyCodeDummyRegionPadding;
|
| 1005 | my $anyDataDummyRegionPadding;
|
| 1006 |
|
| 1007 | my $rom1DummyRegionSize;
|
| 1008 | my $zImageDummyRegionSize;
|
| 1009 | my $anyCodeDummyRegionSize;
|
| 1010 | my $anyDataDummyRegionSize;
|
| 1011 |
|
| 1012 | my $freeRAMSize;
|
| 1013 |
|
| 1014 | my $availableRAM;
|
| 1015 |
|
| 1016 | my %variables =
|
| 1017 | (
|
| 1018 | '$dcmcmpUsedRAM' => ["DCMCMP Used RAM", \$dcmcmpUsedRAM],
|
| 1019 | '$veneerReserveRatio' => ["Veneer Reserve Ratio", \$veneerReserveRatio],
|
| 1020 | '$rom1RegionSize' => ["ROM1 Region Size", \$rom1RegionSize],
|
| 1021 | '$zImageRegionSize' => ["ZIMAGE Region Size", \$zImageRegionSize],
|
| 1022 | '$anyCodeDummyRegionPadding' => ["ANY_CODE Dummy Region Padding", \$anyCodeDummyRegionPadding],
|
| 1023 | '$anyDataDummyRegionPadding' => ["ANY_DATA Dummy Region Padding", \$anyDataDummyRegionPadding],
|
| 1024 | '$rom1DummyRegionSize' => ["ROM1 Dummy Region Size", \$rom1DummyRegionSize],
|
| 1025 | '$zImageDummyRegionSize' => ["ZIMAGE Dummy Region Size", \$zImageDummyRegionSize],
|
| 1026 | '$anyCodeDummyRegionSize' => ["ANY_CODE Dummy Region Size", \$anyCodeDummyRegionSize],
|
| 1027 | '$anyDataDummyRegionSize' => ["ANY_DATA Dummy Region Size", \$anyDataDummyRegionSize],
|
| 1028 | '$freeRAMSize' => ["Free RAM Size", \$freeRAMSize],
|
| 1029 | '$availableRAM' => ["Available RAM", \$availableRAM],
|
| 1030 | );
|
| 1031 |
|
| 1032 | my %objectLists =
|
| 1033 | (
|
| 1034 | '@rom1List' => ["ROM1 List", \@rom1List, '$rom1RegionSize',],
|
| 1035 | '@zImageList' => ["ZIMAGE List", \@zImageList, '$zImageRegionSize',],
|
| 1036 | '@anyCodeDummyList' => ["ANY_CODE Dummy List", \@anyCodeDummyList, '$anyCodeDummyRegionSize', '$anyCodeDummyRegionPadding'],
|
| 1037 | '@anyDataDummyList' => ["ANY_DATA Dummy List", \@anyDataDummyList, '$anyDataDummyRegionSize', '$anyDataDummyRegionPadding']
|
| 1038 | );
|
| 1039 |
|
| 1040 | printLog("Get dummy scatter object lists");
|
| 1041 | {
|
| 1042 | # Basic
|
| 1043 | &_inputObjectListFromFile($objectROM1DummyListFile, \@rom1List, "ROM1");
|
| 1044 | &_inputObjectListFromFile($objectZImageDummyListFile, \@zImageList, "ZIMAGE");
|
| 1045 |
|
| 1046 | # To be added
|
| 1047 | $anyCodeDummyRegionPadding = &_inputObjectListFromExecutionRegion("ZIMAGE_DUMMY_CODE", \@anyCodeDummyList, "+RO-CODE", "ANY_CODE list");
|
| 1048 | $anyDataDummyRegionPadding = &_inputObjectListFromExecutionRegion("ZIMAGE_DUMMY_DATA", \@anyDataDummyList, "+RO-DATA", "ANY_DATA list");
|
| 1049 | }
|
| 1050 |
|
| 1051 | printLog("Get size information");
|
| 1052 | {
|
| 1053 | $rom1DummyRegionSize = &_getExecutionRegionInfo("ROM1", "actual_size");
|
| 1054 | $zImageDummyRegionSize = &_getExecutionRegionInfo("ZIMAGE_ER", "actual_size");
|
| 1055 | $anyCodeDummyRegionSize = &_getExecutionRegionInfo("ZIMAGE_DUMMY_CODE", "actual_size");
|
| 1056 | $anyDataDummyRegionSize = &_getExecutionRegionInfo("ZIMAGE_DUMMY_DATA", "actual_size");
|
| 1057 |
|
| 1058 | $rom1RegionSize = $rom1DummyRegionSize;
|
| 1059 | $zImageRegionSize = $zImageDummyRegionSize;
|
| 1060 |
|
| 1061 | $freeRAMSize = &getFreeRAMSize();
|
| 1062 | }
|
| 1063 |
|
| 1064 | # Configure
|
| 1065 | {
|
| 1066 | printLog("Compute Available RAM");
|
| 1067 | &_evaluateAssignment('$availableRAM = int(($freeRAMSize - $dcmcmpUsedRAM - $zImageDummyRegionSize) * (1 - $veneerReserveRatio))', \%variables);
|
| 1068 |
|
| 1069 | if ($availableRAM < 0)
|
| 1070 | {
|
| 1071 | &configFail(CONFIG_FAIL_INSUFFICIENT_RAM, -1 * $availableRAM);
|
| 1072 | }
|
| 1073 |
|
| 1074 | # The rest RAM size is first used by ANY_DATA
|
| 1075 | printLog("Push ANY_DATA to ZIMAGE and ROM1");
|
| 1076 | {
|
| 1077 | &_splitObjectListAndPushByAvailableRAM('@anyDataDummyList', '@zImageList', '@rom1List',
|
| 1078 | \%variables, \%objectLists);
|
| 1079 | }
|
| 1080 |
|
| 1081 | # Finally, the rest RAM is used by ZIMAGE for ANY_CODE
|
| 1082 | printLog("Push ANY_CODE to ZIMAGE or ROM1");
|
| 1083 | {
|
| 1084 | &_splitObjectListAndPushByAvailableRAM('@anyCodeDummyList', '@zImageList', '@rom1List',
|
| 1085 | \%variables, \%objectLists);
|
| 1086 | }
|
| 1087 |
|
| 1088 | printLog("Compute the Max Compressed Size");
|
| 1089 | {
|
| 1090 | $zImageMaxCompressedSize = &_getRegionMaxCompressedSize("ZIMAGE", $zImageRegionSize, $zImageDummyRegionSize + $anyCodeDummyRegionSize + $anyDataDummyRegionSize, $zImageBinary);
|
| 1091 | }
|
| 1092 |
|
| 1093 | $zImageMaxCompressedSize =
|
| 1094 | &vivaHelper::RoundDownToAlignment($zImageMaxCompressedSize, $zImageSizeAlignment);
|
| 1095 |
|
| 1096 | printLog("ZIMAGE Max Compressed Size: ".vivaHelper::DecToHex($zImageMaxCompressedSize));
|
| 1097 | }
|
| 1098 |
|
| 1099 | # Check whether the configurations are changed
|
| 1100 | {
|
| 1101 | if ($featureConfig{"CONFIG_ZIMAGE_MAX_COMPRESSED_SIZE"} == $zImageMaxCompressedSize)
|
| 1102 | {
|
| 1103 | debugLog("Config not changed");
|
| 1104 | $configChanged = 0;
|
| 1105 | }
|
| 1106 | else
|
| 1107 | {
|
| 1108 | debugLog("Config changed");
|
| 1109 | $configChanged = 1;
|
| 1110 | }
|
| 1111 |
|
| 1112 | if (&_isObjectListChanged($objectROM1ListFile, \@rom1List) or
|
| 1113 | &_isObjectListChanged($objectZImageListFile, \@zImageList))
|
| 1114 | {
|
| 1115 | debugLog("Object list changed");
|
| 1116 | $objectListChanged = 1;
|
| 1117 | }
|
| 1118 | else
|
| 1119 | {
|
| 1120 | debugLog("Object list not changed");
|
| 1121 | $objectListChanged = 0;
|
| 1122 | }
|
| 1123 | }
|
| 1124 |
|
| 1125 | return ($configChanged, $objectListChanged);
|
| 1126 | }
|
| 1127 |
|
| 1128 | sub configAlice
|
| 1129 | {
|
| 1130 | printLog("Configuring ZIMAGE");
|
| 1131 |
|
| 1132 | my $aliceDummyRegionSize = &_getExecutionRegionInfo("ALICE", "actual_size");
|
| 1133 | $aliceMaxCompressedSize = &_getRegionMaxCompressedSize("ALICE", $aliceDummyRegionSize, $aliceDummyRegionSize, $aliceBinary);
|
| 1134 |
|
| 1135 | if ($mbaEnabled)
|
| 1136 | {
|
| 1137 | $aliceMaxCompressedSize = $aliceMaxCompressedSize * (1 + 0.02);
|
| 1138 | debugLog("MBA is enabled");
|
| 1139 | debugLog("Alice Max Compressed Size = Alice Max Compressed Size * (1 + Veneer Reserved Ratio)");
|
| 1140 | debugLog(" = $aliceMaxCompressedSize");
|
| 1141 | }
|
| 1142 |
|
| 1143 | $aliceMaxCompressedSize =
|
| 1144 | &vivaHelper::RoundUpToAlignment($aliceMaxCompressedSize, $aliceSizeAlignment);
|
| 1145 |
|
| 1146 | printLog("ALICE Max Compressed Size: ".vivaHelper::DecToHex($aliceMaxCompressedSize));
|
| 1147 | if ($featureConfig{"CONFIG_ALICE_MAX_COMPRESSED_SIZE"} == $aliceMaxCompressedSize)
|
| 1148 | {
|
| 1149 | debugLog("Config not changed");
|
| 1150 | $configChanged = 0;
|
| 1151 | }
|
| 1152 | else
|
| 1153 | {
|
| 1154 | debugLog("Config changed");
|
| 1155 | $configChanged = 1;
|
| 1156 | }
|
| 1157 |
|
| 1158 | return $configChanged;
|
| 1159 | }
|
| 1160 |
|
| 1161 | sub _inputObjectListFromFile
|
| 1162 | {
|
| 1163 | my $filename = shift;
|
| 1164 | my $listRef = shift;
|
| 1165 | my $listName = shift;
|
| 1166 | my @filePath = fileparse($filename);
|
| 1167 |
|
| 1168 | &vivaHelper::InputObjectListFromFile($filename, $listRef);
|
| 1169 | debugLog("Input $listName list from $filePath[0]");
|
| 1170 | }
|
| 1171 |
|
| 1172 | sub _inputObjectListFromExecutionRegion
|
| 1173 | {
|
| 1174 | my $regionName = shift;
|
| 1175 | my $listRef = shift;
|
| 1176 | my $defaultAttribute = shift;
|
| 1177 | my $defaultCategory = shift;
|
| 1178 | my $padding = 0;
|
| 1179 |
|
| 1180 | $padding = &vivaHelper::GetLISExecutionRegionObjectList($regionName, $listRef, $defaultAttribute, $defaultCategory);
|
| 1181 | debugLog("Get $regionName list from LIS execution region, padding = $padding");
|
| 1182 | return $padding;
|
| 1183 | }
|
| 1184 |
|
| 1185 | sub _getExecutionRegionInfo
|
| 1186 | {
|
| 1187 | my $regionName = shift;
|
| 1188 | my $infoName = shift;
|
| 1189 | my %regionInfo;
|
| 1190 | my $result;
|
| 1191 |
|
| 1192 | &vivaHelper::GetLISExecutionRegionInfo($regionName, \%regionInfo);
|
| 1193 | $result = $regionInfo{$infoName};
|
| 1194 | debugLog("$regionName execution region $infoName = $result");
|
| 1195 |
|
| 1196 | return $result;
|
| 1197 | }
|
| 1198 |
|
| 1199 | sub _getRegionMaxCompressedSize
|
| 1200 | {
|
| 1201 | my $regionName = shift;
|
| 1202 | my $regionSize = shift;
|
| 1203 | my $dummyRegionSize = shift;
|
| 1204 | my $dummyCompressedBinary = shift;
|
| 1205 |
|
| 1206 | my $dummyCompressedSize = -s $dummyCompressedBinary or
|
| 1207 | &vivaHelper::ErrorHandler("Cannot get file size $dummyCompressedBinary: $!", __FILE__, __LINE__);
|
| 1208 | #debugLog("$regionName Dummy Region Size = $dummyRegionSize");
|
| 1209 | #debugLog("$regionName Dummy Compressed Binary Size = $dummyCompressedSize");
|
| 1210 |
|
| 1211 | my $compressionRatio = $dummyCompressedSize / $dummyRegionSize;
|
| 1212 | #debugLog("$regionName Compression Ratio = $regionName Dummy Compressed Binary Size / $regionName Dummy Region Size");
|
| 1213 | #debugLog(" = $dummyCompressedSize / $dummyRegionSize");
|
| 1214 | #debugLog(" = $compressionRatio");
|
| 1215 |
|
| 1216 | my $maxCompressedSize = int($regionSize * $compressionRatio + 0.99);
|
| 1217 | debugLog("$regionName max compressed size = $regionName Region Size * $regionName Compression Ratio");
|
| 1218 | debugLog(" = $regionSize * $compressionRatio");
|
| 1219 | debugLog(" = $maxCompressedSize");
|
| 1220 |
|
| 1221 | return $maxCompressedSize;
|
| 1222 | }
|
| 1223 |
|
| 1224 | sub _pushToObjectList
|
| 1225 | {
|
| 1226 | my $targetList = shift;
|
| 1227 | my $sourceList = shift;
|
| 1228 |
|
| 1229 | my $variables = shift;
|
| 1230 | my $objectLists = shift;
|
| 1231 |
|
| 1232 | push @{$objectLists->{$targetList}[1]}, @{$objectLists->{$sourceList}[1]};
|
| 1233 | debugLog("$objectLists->{$targetList}[0] += $objectLists->{$sourceList}[0]");
|
| 1234 | _evaluateAssignment("$objectLists->{$targetList}[2] = $objectLists->{$targetList}[2] + $objectLists->{$sourceList}[2]", $variables);
|
| 1235 | }
|
| 1236 |
|
| 1237 | sub _splitObjectListAndPush
|
| 1238 | {
|
| 1239 | my $sourceList = shift;
|
| 1240 | my $firstList = shift;
|
| 1241 | my $secondList = shift;
|
| 1242 |
|
| 1243 | my $splitSize = shift;
|
| 1244 |
|
| 1245 | my $variables = shift;
|
| 1246 | my $objectLists = shift;
|
| 1247 |
|
| 1248 | my $splitSizeWithVeneer;
|
| 1249 | my $actualSplitSize;
|
| 1250 |
|
| 1251 | my @list1;
|
| 1252 | my @list2;
|
| 1253 |
|
| 1254 | $variables->{'$splitSizeWithVeneer'} = ["Splitted Size with Veneer", \$splitSizeWithVeneer];
|
| 1255 | $variables->{'$actualSplitSize'} = ["Actual Splitted Size", \$actualSplitSize];
|
| 1256 |
|
| 1257 | #$objectLists->{'@list1'} = ["Splitted List", \@list1, '$actualSplitSize * (1 + $veneerReserveRatio)'];
|
| 1258 | $objectLists->{'@list1'} = ["Splitted List", \@list1, '$actualSplitSize + '."$objectLists->{$sourceList}[3]"];
|
| 1259 | $objectLists->{'@list2'} = ["Rest List", \@list2, "$objectLists->{$sourceList}[2]".' - $actualSplitSize'];
|
| 1260 |
|
| 1261 | debugLog("Split $objectLists->{$sourceList}[0]");
|
| 1262 |
|
| 1263 | #&_evaluateAssignment('$splitSizeWithVeneer = '."$splitSize".' * (1 + $veneerReserveRatio)', $variables);
|
| 1264 | &_evaluateAssignment('$splitSizeWithVeneer = '."$splitSize", $variables);
|
| 1265 | $splitSizeWithVeneer = int($splitSizeWithVeneer);
|
| 1266 |
|
| 1267 | $actualSplitSize = &vivaHelper::SplitObjectListBySize($objectLists->{$sourceList}[1], $splitSizeWithVeneer,
|
| 1268 | \@list1, \@list2);
|
| 1269 | debugLog("Actual Splitted Size = $actualSplitSize");
|
| 1270 |
|
| 1271 | &_pushToObjectList($firstList, '@list1', $variables, $objectLists);
|
| 1272 | &_pushToObjectList($secondList, '@list2', $variables, $objectLists);
|
| 1273 |
|
| 1274 | delete $variables->{'$splitSizeWithVeneer'};
|
| 1275 | delete $variables->{'$actualSplitSize'};
|
| 1276 |
|
| 1277 | delete $objectLists->{'@list1'};
|
| 1278 | delete $objectLists->{'@list2'};
|
| 1279 |
|
| 1280 | return $actualSplitSize;
|
| 1281 | }
|
| 1282 |
|
| 1283 | sub _splitObjectListAndPushByAvailableRAM
|
| 1284 | {
|
| 1285 | my $sourceList = shift;
|
| 1286 | my $firstList = shift;
|
| 1287 | my $secondList = shift;
|
| 1288 |
|
| 1289 | my $variables = shift;
|
| 1290 | my $objectLists = shift;
|
| 1291 |
|
| 1292 | if (${$variables->{'$availableRAM'}[1]} < $smallestSplitableRAMSize and ${$variables->{'$availableRAM'}[1]} != 0)
|
| 1293 | {
|
| 1294 | debugLog("Available RAM < Smallest Splitable RAM");
|
| 1295 | debugLog(" = $smallestSplitableRAMSize");
|
| 1296 | ${$variables->{'$availableRAM'}[1]} = 0;
|
| 1297 | debugLog("Available RAM = 0");
|
| 1298 | }
|
| 1299 |
|
| 1300 | &_splitObjectListAndPush($sourceList, $firstList, $secondList,
|
| 1301 | '$availableRAM', $variables, $objectLists);
|
| 1302 |
|
| 1303 | if (${$variables->{'$availableRAM'}[1]} >= ${$variables->{$objectLists->{$sourceList}[2]}[1]})
|
| 1304 | {
|
| 1305 | &_evaluateAssignment('$availableRAM = $availableRAM - '."$objectLists->{$sourceList}[2]", $variables);
|
| 1306 | }
|
| 1307 | else
|
| 1308 | {
|
| 1309 | ${$variables->{'$availableRAM'}[1]} = 0;
|
| 1310 | debugLog("Available RAM = 0");
|
| 1311 | }
|
| 1312 | }
|
| 1313 |
|
| 1314 | sub _evaluateAssignment
|
| 1315 | {
|
| 1316 | my $assignmentString = shift;
|
| 1317 | my $variables = shift;
|
| 1318 | my @assignment = split(/=/, $assignmentString);
|
| 1319 |
|
| 1320 | my $symbolString = $assignmentString;
|
| 1321 |
|
| 1322 | $assignment[0] =~ s/(?:^ +)||(?: +$)//g;
|
| 1323 | $assignment[1] =~ s/(?:^ +)||(?: +$)//g;
|
| 1324 |
|
| 1325 | my $evaluationString = $assignment[1];
|
| 1326 |
|
| 1327 | while (my ($key, $value)= each %$variables)
|
| 1328 | {
|
| 1329 | my $matchSymbol = "\\$key";
|
| 1330 | $symbolString =~ s/$matchSymbol/$value->[0]/g;
|
| 1331 | $evaluationString =~ s/$matchSymbol/${$value->[1]}/g;
|
| 1332 | }
|
| 1333 |
|
| 1334 | my $intermediate = eval{$evaluationString};
|
| 1335 | my $assigneeRef = $variables->{$assignment[0]}[1];
|
| 1336 |
|
| 1337 | $$assigneeRef = eval ($evaluationString);
|
| 1338 |
|
| 1339 | debugLog($symbolString);
|
| 1340 | debugLog(" = $intermediate");
|
| 1341 | debugLog(" = $$assigneeRef");
|
| 1342 | }
|
| 1343 |
|
| 1344 | sub _isObjectListChanged
|
| 1345 | {
|
| 1346 | my $objectListFile = shift;
|
| 1347 | my $objectListRef = shift;
|
| 1348 |
|
| 1349 | my @objectListOriginal;
|
| 1350 |
|
| 1351 | &vivaHelper::InputObjectListFromFile($objectListFile, \@objectListOriginal);
|
| 1352 |
|
| 1353 | if (&vivaHelper::CompareObjectList(\@objectListOriginal, $objectListRef) == 0)
|
| 1354 | {
|
| 1355 | return 0;
|
| 1356 | }
|
| 1357 | else
|
| 1358 | {
|
| 1359 | return 1;
|
| 1360 | }
|
| 1361 | }
|
| 1362 |
|
| 1363 | sub configBootZImage_ZImage_Alice_FavorROM
|
| 1364 | {
|
| 1365 | printLog("Configuring BOOT_ZIMAGE, ZIMAGE, and ALICE favoring ROM...");
|
| 1366 |
|
| 1367 | my $rom1RegionSize;
|
| 1368 | my $bootZImageRegionSize;
|
| 1369 | my $zImageRegionSize;
|
| 1370 | my $aliceRegionSize;
|
| 1371 |
|
| 1372 | my @bootZImageDummyList;
|
| 1373 | my @aliceForbidDummyList;
|
| 1374 | my @anyCodeDummyList;
|
| 1375 | my @anyDataDummyList;
|
| 1376 |
|
| 1377 | my $bootZImageDummyRegionPadding;
|
| 1378 | my $aliceForbidDummyRegionPadding;
|
| 1379 | my $anyCodeDummyRegionPadding;
|
| 1380 | my $anyDataDummyRegionPadding;
|
| 1381 |
|
| 1382 | my $rom1DummyRegionSize;
|
| 1383 | my $bootZImageDummyRegionSize;
|
| 1384 | my $zImageDummyRegionSize;
|
| 1385 | my $aliceDummyRegionSize;
|
| 1386 | my $aliceForbidDummyRegionSize;
|
| 1387 | my $anyCodeDummyRegionSize;
|
| 1388 | my $anyDataDummyRegionSize;
|
| 1389 |
|
| 1390 | my $bootZImageDummyCompressionRatio;
|
| 1391 | my $zImageDummyCompressionRatio;
|
| 1392 | my $aliceDummyCompressionRatio;
|
| 1393 |
|
| 1394 | my $freeRAMSize;
|
| 1395 |
|
| 1396 | my $availableRAM;
|
| 1397 |
|
| 1398 | my $exceedROMSize;
|
| 1399 |
|
| 1400 | my $targetSplitSize;
|
| 1401 |
|
| 1402 | my %variables =
|
| 1403 | (
|
| 1404 | '$dcmcmpUsedRAM' => ["DCMCMP Used RAM", \$dcmcmpUsedRAM],
|
| 1405 | '$veneerReserveRatio' => ["Veneer Reserve Ratio", \$veneerReserveRatio],
|
| 1406 | '$rom1RegionSize' => ["ROM1 Region Size", \$rom1RegionSize],
|
| 1407 | '$bootZImageRegionSize' => ["BOOT_ZIMAGE Region Size", \$bootZImageRegionSize],
|
| 1408 | '$zImageRegionSize' => ["ZIMAGE Region Size", \$zImageRegionSize],
|
| 1409 | '$aliceRegionSize' => ["ALICE Region Size", \$aliceRegionSize],
|
| 1410 | '$bootZImageDummyRegionPadding' => ["BOOT_ZIMAGE Dummy Region Padding", \$bootZImageDummyRegionPadding],
|
| 1411 | '$aliceForbidDummyRegionPadding' => ["ALICE_FORBID Dummy Region Padding", \$aliceForbidDummyRegionPadding],
|
| 1412 | '$anyCodeDummyRegionPadding' => ["ANY_CODE Dummy Region Padding", \$anyCodeDummyRegionPadding],
|
| 1413 | '$anyDataDummyRegionPadding' => ["ANY_DATA Dummy Region Padding", \$anyDataDummyRegionPadding],
|
| 1414 | '$rom1DummyRegionSize' => ["ROM1 Dummy Region Size", \$rom1DummyRegionSize],
|
| 1415 | '$bootZImageDummyRegionSize' => ["BOOT_ZIMAGE Dummy Region Size", \$bootZImageDummyRegionSize],
|
| 1416 | '$zImageDummyRegionSize' => ["ZIMAGE Dummy Region Size", \$zImageDummyRegionSize],
|
| 1417 | '$aliceDummyRegionSize' => ["ALICE Dummy Region Size", \$aliceDummyRegionSize],
|
| 1418 | '$aliceForbidDummyRegionSize' => ["ALICE_FORBID Dummy Region Size", \$aliceForbidDummyRegionSize],
|
| 1419 | '$anyCodeDummyRegionSize' => ["ANY_CODE Dummy Region Size", \$anyCodeDummyRegionSize],
|
| 1420 | '$anyDataDummyRegionSize' => ["ANY_DATA Dummy Region Size", \$anyDataDummyRegionSize],
|
| 1421 | '$bootZImageDummyCompressionRatio' => ["BOOT_ZIMAGE Dummy Compression Ratio", \$bootZImageDummyCompressionRatio],
|
| 1422 | '$zImageDummyCompressionRatio' => ["ZIMAGE Dummy Compression Ratio", \$zImageDummyCompressionRatio],
|
| 1423 | '$aliceDummyCompressionRatio' => ["ALICE Dummy Compression Ratio", \$aliceDummyCompressionRatio],
|
| 1424 | '$freeRAMSize' => ["Free RAM Size", \$freeRAMSize],
|
| 1425 | '$availableRAM' => ["Available RAM", \$availableRAM],
|
| 1426 | '$exceedROMSize' => ["Exceed ROM Size", \$exceedROMSize],
|
| 1427 | '$targetSplitSize' => ["Target Split Size", \$targetSplitSize],
|
| 1428 | );
|
| 1429 |
|
| 1430 | my %objectLists =
|
| 1431 | (
|
| 1432 | '@rom1List' => ["ROM1 List", \@rom1List, '$rom1RegionSize',],
|
| 1433 | '@bootZImageList' => ["BOOT_ZIMAGE List", \@bootZImageList, '$bootZImageRegionSize',],
|
| 1434 | '@zImageList' => ["ZIMAGE List", \@zImageList, '$zImageRegionSize',],
|
| 1435 | '@aliceList' => ["ALICE List", \@aliceList, '$aliceRegionSize',],
|
| 1436 | '@bootZImageDummyList' => ["BOOT_ZIMAGE Dummy List", \@bootZImageDummyList, '$bootZImageDummyRegionSize', '$bootZImageDummyRegionPadding'],
|
| 1437 | '@aliceForbidDummyList' => ["ALICE_FORBID Dummy List", \@aliceForbidDummyList, '$aliceForbidDummyRegionSize', '$aliceForbidDummyRegionPadding'],
|
| 1438 | '@anyCodeDummyList' => ["ANY_CODE Dummy List", \@anyCodeDummyList, '$anyCodeDummyRegionSize', '$anyCodeDummyRegionPadding'],
|
| 1439 | '@anyDataDummyList' => ["ANY_DATA Dummy List", \@anyDataDummyList, '$anyDataDummyRegionSize', '$anyDataDummyRegionPadding']
|
| 1440 | );
|
| 1441 |
|
| 1442 | printLog("Get dummy scatter object lists");
|
| 1443 | {
|
| 1444 | # Basic
|
| 1445 | &_inputObjectListFromFile($objectROM1DummyListFile, \@rom1List, "ROM1");
|
| 1446 | &_inputObjectListFromFile($objectBootZImageDummyListFile, \@bootZImageList, "BOOT_ZIMAGE");
|
| 1447 | &_inputObjectListFromFile($objectZImageDummyListFile, \@zImageList, "ZIMAGE");
|
| 1448 | &_inputObjectListFromFile($objectAliceDummyListFile, \@aliceList, "ALICE");
|
| 1449 |
|
| 1450 | # To be added
|
| 1451 | $bootZImageDummyRegionPadding = &_inputObjectListFromExecutionRegion("BOOT_ZIMAGE_ER", \@bootZImageDummyList, "+RO", "BOOT_ZIMAGE list");
|
| 1452 | $aliceForbidDummyRegionPadding = &_inputObjectListFromExecutionRegion("ALICE_FORBID", \@aliceForbidDummyList, "+RO", "ALICE_FORBID list");
|
| 1453 | $anyCodeDummyRegionPadding = &_inputObjectListFromExecutionRegion("ZIMAGE_DUMMY_CODE", \@anyCodeDummyList, "+RO-CODE", "ANY_CODE list");
|
| 1454 | $anyDataDummyRegionPadding = &_inputObjectListFromExecutionRegion("ZIMAGE_DUMMY_DATA", \@anyDataDummyList, "+RO-DATA", "ANY_DATA list");
|
| 1455 | }
|
| 1456 |
|
| 1457 | printLog("Get size information");
|
| 1458 | {
|
| 1459 | $rom1DummyRegionSize = &_getExecutionRegionInfo("ROM1", "actual_size");
|
| 1460 | $bootZImageDummyRegionSize = &_getExecutionRegionInfo("BOOT_ZIMAGE_ER", "actual_size");
|
| 1461 | $zImageDummyRegionSize = &_getExecutionRegionInfo("ZIMAGE_ER", "actual_size");
|
| 1462 | $aliceDummyRegionSize = &_getExecutionRegionInfo("ALICE", "actual_size");
|
| 1463 | $aliceForbidDummyRegionSize = &_getExecutionRegionInfo("ALICE_FORBID", "actual_size");
|
| 1464 | $anyCodeDummyRegionSize = &_getExecutionRegionInfo("ZIMAGE_DUMMY_CODE", "actual_size");
|
| 1465 | $anyDataDummyRegionSize = &_getExecutionRegionInfo("ZIMAGE_DUMMY_DATA", "actual_size");
|
| 1466 |
|
| 1467 | $rom1RegionSize = $rom1DummyRegionSize;
|
| 1468 | $bootZImageRegionSize = $bootZImageDummyRegionSize;
|
| 1469 | $zImageRegionSize = $zImageDummyRegionSize;
|
| 1470 | $aliceRegionSize = $aliceDummyRegionSize;
|
| 1471 |
|
| 1472 | $freeRAMSize = &getFreeRAMSize();
|
| 1473 |
|
| 1474 | $exceedROMSize = &getExceedROMSize();
|
| 1475 | }
|
| 1476 |
|
| 1477 | # Configure
|
| 1478 | {
|
| 1479 | printLog("Compute Available RAM");
|
| 1480 |
|
| 1481 | &_evaluateAssignment('$availableRAM = ($freeRAMSize - $dcmcmpUsedRAM - $zImageDummyRegionSize) * (1 - $veneerReserveRatio)', \%variables);
|
| 1482 | $availableRAM = int($availableRAM);
|
| 1483 |
|
| 1484 | if ($availableRAM < 0)
|
| 1485 | {
|
| 1486 | &configFail(CONFIG_FAIL_INSUFFICIENT_RAM, -1 * $availableRAM);
|
| 1487 | }
|
| 1488 |
|
| 1489 | # Compute the compression ratios
|
| 1490 | printLog("Compute the compression ratios");
|
| 1491 | {
|
| 1492 | $bootZImageDummyCompressionRatio = &_getCompressionRatio("BOOT_ZIMAGE", $bootZImageDummyRegionSize, $bootZImageBinary);
|
| 1493 | $zImageDummyCompressionRatio = &_getCompressionRatio("ZIMAGE", $zImageDummyRegionSize + $anyCodeDummyRegionSize + $anyDataDummyRegionSize, $zImageBinary);
|
| 1494 | $aliceDummyCompressionRatio = &_getCompressionRatio("ALICE", $aliceDummyRegionSize, $aliceBinary);
|
| 1495 | }
|
| 1496 |
|
| 1497 | # Assume ANY_CODE in ALICE
|
| 1498 | printLog("Assume ANY_CODE are all in ALICE");
|
| 1499 | {
|
| 1500 | &_evaluateAssignment('$exceedROMSize = int($exceedROMSize - $anyCodeDummyRegionSize * (1 - $aliceDummyCompressionRatio))', \%variables);
|
| 1501 |
|
| 1502 | if ($exceedROMSize > $availableRAM * (1 - $zImageDummyCompressionRatio))
|
| 1503 | {
|
| 1504 | debugLog("Exceed ROM Size > Available RAM * (1 - ZIMAGE Dummy Compression Ratio)");
|
| 1505 | debugLog(" = $availableRAM * (1 - $zImageDummyCompressionRatio)");
|
| 1506 | debugLog(" = ".($availableRAM * (1 - $zImageDummyCompressionRatio)));
|
| 1507 | &configFail(CONFIG_FAIL_INSUFFICIENT_RAM, $exceedROMSize / (1 - $zImageDummyCompressionRatio) - $availableRAM);
|
| 1508 | }
|
| 1509 | }
|
| 1510 |
|
| 1511 | # Push ALICE_FORBID to ZIMAGE or ROM1
|
| 1512 | &_splitObjectListAndPushByExceedROM('@aliceForbidDummyList', '@zImageList', '@rom1List',
|
| 1513 | '$zImageDummyCompressionRatio', \%variables, \%objectLists);
|
| 1514 |
|
| 1515 | # Push ANY_DATA to ZIMAGE or ROM1
|
| 1516 | &_splitObjectListAndPushByExceedROM('@anyDataDummyList', '@zImageList', '@rom1List',
|
| 1517 | '$zImageDummyCompressionRatio', \%variables, \%objectLists);
|
| 1518 |
|
| 1519 | # Push BOOT_ZIMAGE Dummy to BOOT_ZIMAGE or ROM1
|
| 1520 | &vivaHelper::ChangeObjectListAttributeListByObjectList(\@bootZImageDummyList, \@bootZImageList);
|
| 1521 | @bootZImageList = pop @bootZImageDummyList; # Push at least one entry to BOOT_ZIMAGE to prevent empty
|
| 1522 | $bootZImageRegionSize = 0;
|
| 1523 | &_splitObjectListAndPushByExceedROM('@bootZImageDummyList', '@bootZImageList', '@rom1List',
|
| 1524 | '$bootZImageDummyCompressionRatio', \%variables, \%objectLists);
|
| 1525 |
|
| 1526 | # Push ANY_CODE to ZIMAGE or ALICE
|
| 1527 | &_splitObjectListAndPushByExceedROM('@anyCodeDummyList', '@zImageList', '@aliceList',
|
| 1528 | '$aliceDummyCompressionRatio - $zImageDummyCompressionRatio', \%variables, \%objectLists);
|
| 1529 |
|
| 1530 | #if ($exceedROMSize > 0)
|
| 1531 | #{
|
| 1532 | # &configFail(CONFIG_FAIL_INSUFFICIENT_FLASH_SIZE, $exceedROMSize);
|
| 1533 | #}
|
| 1534 |
|
| 1535 | printLog("Compute the Max Compressed Size");
|
| 1536 | {
|
| 1537 | $bootZImageMaxCompressedSize = &_getRegionMaxCompressedSize("BOOT_ZIMAGE", $bootZImageRegionSize, $bootZImageDummyRegionSize, $bootZImageBinary);
|
| 1538 | $zImageMaxCompressedSize = &_getRegionMaxCompressedSize("ZIMAGE", $zImageRegionSize, $zImageDummyRegionSize + $anyCodeDummyRegionSize + $anyDataDummyRegionSize, $zImageBinary);
|
| 1539 | $aliceMaxCompressedSize = &_getRegionMaxCompressedSize("ALICE", $aliceRegionSize, $aliceDummyRegionSize, $aliceBinary);
|
| 1540 | }
|
| 1541 |
|
| 1542 | $bootZImageMaxCompressedSize =
|
| 1543 | &vivaHelper::RoundUpToAlignment($bootZImageMaxCompressedSize, $bootZImageSizeAlignment);
|
| 1544 | $zImageMaxCompressedSize =
|
| 1545 | &vivaHelper::RoundDownToAlignment($zImageMaxCompressedSize, $zImageSizeAlignment);
|
| 1546 | $aliceMaxCompressedSize =
|
| 1547 | &vivaHelper::RoundUpToAlignment($aliceMaxCompressedSize, $aliceSizeAlignment);
|
| 1548 |
|
| 1549 | printLog("BOOT_ZIMAGE Max Compressed Size: ".vivaHelper::DecToHex($bootZImageMaxCompressedSize));
|
| 1550 | printLog("ZIMAGE Max Compressed Size: ".vivaHelper::DecToHex($zImageMaxCompressedSize));
|
| 1551 | printLog("ALICE Max Compressed Size: ".vivaHelper::DecToHex($aliceMaxCompressedSize));
|
| 1552 | }
|
| 1553 |
|
| 1554 | # Check whether the configurations are changed
|
| 1555 | {
|
| 1556 | if ($featureConfig{"CONFIG_BOOT_ZIMAGE_MAX_COMPRESSED_SIZE"} == $bootZImageMaxCompressedSize and
|
| 1557 | $featureConfig{"CONFIG_ZIMAGE_MAX_COMPRESSED_SIZE"} == $zImageMaxCompressedSize and
|
| 1558 | $featureConfig{"CONFIG_ALICE_MAX_COMPRESSED_SIZE"} == $aliceMaxCompressedSize)
|
| 1559 | {
|
| 1560 | debugLog("Config not changed");
|
| 1561 | $configChanged = 0;
|
| 1562 | }
|
| 1563 | else
|
| 1564 | {
|
| 1565 | debugLog("Config changed");
|
| 1566 | $configChanged = 1;
|
| 1567 | }
|
| 1568 |
|
| 1569 | if (&_isObjectListChanged($objectROM1ListFile, \@rom1List) or
|
| 1570 | &_isObjectListChanged($objectBootZImageListFile, \@bootZImageList) or
|
| 1571 | &_isObjectListChanged($objectZImageListFile, \@zImageList) or
|
| 1572 | &_isObjectListChanged($objectAliceListFile, \@aliceList))
|
| 1573 | {
|
| 1574 | debugLog("Object list changed");
|
| 1575 | $objectListChanged = 1;
|
| 1576 | }
|
| 1577 | else
|
| 1578 | {
|
| 1579 | debugLog("Object list not changed");
|
| 1580 | $objectListChanged = 0;
|
| 1581 | }
|
| 1582 | }
|
| 1583 |
|
| 1584 | return ($configChanged, $objectListChanged);
|
| 1585 | }
|
| 1586 |
|
| 1587 | sub configZImage_Alice_FavorROM
|
| 1588 | {
|
| 1589 | printLog("Configuring ZIMAGE and ALICE favoring ROM...");
|
| 1590 |
|
| 1591 | my $rom1RegionSize;
|
| 1592 | my $zImageRegionSize;
|
| 1593 | my $aliceRegionSize;
|
| 1594 |
|
| 1595 | my @aliceForbidDummyList;
|
| 1596 | my @anyCodeDummyList;
|
| 1597 | my @anyDataDummyList;
|
| 1598 |
|
| 1599 | my $aliceForbidDummyRegionPadding;
|
| 1600 | my $anyCodeDummyRegionPadding;
|
| 1601 | my $anyDataDummyRegionPadding;
|
| 1602 |
|
| 1603 | my $rom1DummyRegionSize;
|
| 1604 | my $zImageDummyRegionSize;
|
| 1605 | my $aliceDummyRegionSize;
|
| 1606 | my $aliceForbidDummyRegionSize;
|
| 1607 | my $anyCodeDummyRegionSize;
|
| 1608 | my $anyDataDummyRegionSize;
|
| 1609 |
|
| 1610 | my $zImageDummyCompressionRatio;
|
| 1611 | my $aliceDummyCompressionRatio;
|
| 1612 |
|
| 1613 | my $freeRAMSize;
|
| 1614 |
|
| 1615 | my $availableRAM;
|
| 1616 |
|
| 1617 | my $exceedROMSize;
|
| 1618 |
|
| 1619 | my $targetSplitSize;
|
| 1620 |
|
| 1621 | my %variables =
|
| 1622 | (
|
| 1623 | '$dcmcmpUsedRAM' => ["DCMCMP Used RAM", \$dcmcmpUsedRAM],
|
| 1624 | '$veneerReserveRatio' => ["Veneer Reserve Ratio", \$veneerReserveRatio],
|
| 1625 | '$rom1RegionSize' => ["ROM1 Region Size", \$rom1RegionSize],
|
| 1626 | '$zImageRegionSize' => ["ZIMAGE Region Size", \$zImageRegionSize],
|
| 1627 | '$aliceRegionSize' => ["ALICE Region Size", \$aliceRegionSize],
|
| 1628 | '$aliceForbidDummyRegionPadding' => ["ALICE_FORBID Dummy Region Padding", \$aliceForbidDummyRegionPadding],
|
| 1629 | '$anyCodeDummyRegionPadding' => ["ANY_CODE Dummy Region Padding", \$anyCodeDummyRegionPadding],
|
| 1630 | '$anyDataDummyRegionPadding' => ["ANY_DATA Dummy Region Padding", \$anyDataDummyRegionPadding],
|
| 1631 | '$rom1DummyRegionSize' => ["ROM1 Dummy Region Size", \$rom1DummyRegionSize],
|
| 1632 | '$zImageDummyRegionSize' => ["ZIMAGE Dummy Region Size", \$zImageDummyRegionSize],
|
| 1633 | '$aliceDummyRegionSize' => ["ALICE Dummy Region Size", \$aliceDummyRegionSize],
|
| 1634 | '$aliceForbidDummyRegionSize' => ["ALICE_FORBID Dummy Region Size", \$aliceForbidDummyRegionSize],
|
| 1635 | '$anyCodeDummyRegionSize' => ["ANY_CODE Dummy Region Size", \$anyCodeDummyRegionSize],
|
| 1636 | '$anyDataDummyRegionSize' => ["ANY_DATA Dummy Region Size", \$anyDataDummyRegionSize],
|
| 1637 | '$zImageDummyCompressionRatio' => ["ZIMAGE Dummy Compression Ratio", \$zImageDummyCompressionRatio],
|
| 1638 | '$aliceDummyCompressionRatio' => ["ALICE Dummy Compression Ratio", \$aliceDummyCompressionRatio],
|
| 1639 | '$freeRAMSize' => ["Free RAM Size", \$freeRAMSize],
|
| 1640 | '$availableRAM' => ["Available RAM", \$availableRAM],
|
| 1641 | '$exceedROMSize' => ["Exceed ROM Size", \$exceedROMSize],
|
| 1642 | '$targetSplitSize' => ["Target Split Size", \$targetSplitSize],
|
| 1643 | );
|
| 1644 |
|
| 1645 | my %objectLists =
|
| 1646 | (
|
| 1647 | '@rom1List' => ["ROM1 List", \@rom1List, '$rom1RegionSize',],
|
| 1648 | '@zImageList' => ["ZIMAGE List", \@zImageList, '$zImageRegionSize',],
|
| 1649 | '@aliceList' => ["ALICE List", \@aliceList, '$aliceRegionSize',],
|
| 1650 | '@aliceForbidDummyList' => ["ALICE_FORBID Dummy List", \@aliceForbidDummyList, '$aliceForbidDummyRegionSize', '$aliceForbidDummyRegionPadding'],
|
| 1651 | '@anyCodeDummyList' => ["ANY_CODE Dummy List", \@anyCodeDummyList, '$anyCodeDummyRegionSize', '$anyCodeDummyRegionPadding'],
|
| 1652 | '@anyDataDummyList' => ["ANY_DATA Dummy List", \@anyDataDummyList, '$anyDataDummyRegionSize', '$anyDataDummyRegionPadding']
|
| 1653 | );
|
| 1654 |
|
| 1655 | printLog("Get dummy scatter object lists");
|
| 1656 | {
|
| 1657 | # Basic
|
| 1658 | &_inputObjectListFromFile($objectROM1DummyListFile, \@rom1List, "ROM1");
|
| 1659 | &_inputObjectListFromFile($objectZImageDummyListFile, \@zImageList, "ZIMAGE");
|
| 1660 | &_inputObjectListFromFile($objectAliceDummyListFile, \@aliceList, "ALICE");
|
| 1661 |
|
| 1662 | # To be added
|
| 1663 | $aliceForbidDummyRegionPadding = &_inputObjectListFromExecutionRegion("ALICE_FORBID", \@aliceForbidDummyList, "+RO", "ALICE_FORBID list");
|
| 1664 | $anyCodeDummyRegionPadding = &_inputObjectListFromExecutionRegion("ZIMAGE_DUMMY_CODE", \@anyCodeDummyList, "+RO-CODE", "ANY_CODE list");
|
| 1665 | $anyDataDummyRegionPadding = &_inputObjectListFromExecutionRegion("ZIMAGE_DUMMY_DATA", \@anyDataDummyList, "+RO-DATA", "ANY_DATA list");
|
| 1666 | }
|
| 1667 |
|
| 1668 | printLog("Get size information");
|
| 1669 | {
|
| 1670 | $rom1DummyRegionSize = &_getExecutionRegionInfo("ROM1", "actual_size");
|
| 1671 | $zImageDummyRegionSize = &_getExecutionRegionInfo("ZIMAGE_ER", "actual_size");
|
| 1672 | $aliceDummyRegionSize = &_getExecutionRegionInfo("ALICE", "actual_size");
|
| 1673 | $aliceForbidDummyRegionSize = &_getExecutionRegionInfo("ALICE_FORBID", "actual_size");
|
| 1674 | $anyCodeDummyRegionSize = &_getExecutionRegionInfo("ZIMAGE_DUMMY_CODE", "actual_size");
|
| 1675 | $anyDataDummyRegionSize = &_getExecutionRegionInfo("ZIMAGE_DUMMY_DATA", "actual_size");
|
| 1676 |
|
| 1677 | $rom1RegionSize = $rom1DummyRegionSize;
|
| 1678 | $zImageRegionSize = $zImageDummyRegionSize;
|
| 1679 | $aliceRegionSize = $aliceDummyRegionSize;
|
| 1680 |
|
| 1681 | $freeRAMSize = &getFreeRAMSize();
|
| 1682 |
|
| 1683 | $exceedROMSize = &getExceedROMSize();
|
| 1684 | }
|
| 1685 |
|
| 1686 | # Configure
|
| 1687 | {
|
| 1688 | printLog("Compute Available RAM");
|
| 1689 | &_evaluateAssignment('$availableRAM = int(($freeRAMSize - $dcmcmpUsedRAM - $zImageDummyRegionSize) * (1 - $veneerReserveRatio))', \%variables);
|
| 1690 |
|
| 1691 | if ($availableRAM < 0)
|
| 1692 | {
|
| 1693 | &configFail(CONFIG_FAIL_INSUFFICIENT_RAM, -1 * $availableRAM);
|
| 1694 | }
|
| 1695 |
|
| 1696 | # Compute the compression ratios
|
| 1697 | printLog("Compute the compression ratios");
|
| 1698 | {
|
| 1699 | $zImageDummyCompressionRatio = &_getCompressionRatio("ZIMAGE", $zImageDummyRegionSize + $anyCodeDummyRegionSize + $anyDataDummyRegionSize, $zImageBinary);
|
| 1700 | $aliceDummyCompressionRatio = &_getCompressionRatio("ALICE", $aliceDummyRegionSize, $aliceBinary);
|
| 1701 | }
|
| 1702 |
|
| 1703 | # Assume ANY_CODE in ALICE
|
| 1704 | printLog("Assume ANY_CODE are all in ALICE");
|
| 1705 | {
|
| 1706 | &_evaluateAssignment('$exceedROMSize = int($exceedROMSize - $anyCodeDummyRegionSize * (1 - $aliceDummyCompressionRatio))', \%variables);
|
| 1707 |
|
| 1708 | if ($exceedROMSize > $availableRAM * (1 - $zImageDummyCompressionRatio))
|
| 1709 | {
|
| 1710 | debugLog("Exceed ROM Size > Available RAM * (1 - ZIMAGE Dummy Compression Ratio)");
|
| 1711 | debugLog(" = $availableRAM * (1 - $zImageDummyCompressionRatio)");
|
| 1712 | debugLog(" = ".($availableRAM * (1 - $zImageDummyCompressionRatio)));
|
| 1713 | &configFail(CONFIG_FAIL_INSUFFICIENT_RAM, $exceedROMSize / (1 - $zImageDummyCompressionRatio) - $availableRAM);
|
| 1714 | }
|
| 1715 | }
|
| 1716 |
|
| 1717 | # Push ALICE_FORBID to ZIMAGE or ROM1
|
| 1718 | &_splitObjectListAndPushByExceedROM('@aliceForbidDummyList', '@zImageList', '@rom1List',
|
| 1719 | '$zImageDummyCompressionRatio', \%variables, \%objectLists);
|
| 1720 |
|
| 1721 | # Push ANY_DATA to ZIMAGE or ROM1
|
| 1722 | &_splitObjectListAndPushByExceedROM('@anyDataDummyList', '@zImageList', '@rom1List',
|
| 1723 | '$zImageDummyCompressionRatio', \%variables, \%objectLists);
|
| 1724 |
|
| 1725 | # Push ANY_CODE to ZIMAGE or ALICE
|
| 1726 | &_splitObjectListAndPushByExceedROM('@anyCodeDummyList', '@zImageList', '@aliceList',
|
| 1727 | '$aliceDummyCompressionRatio - $zImageDummyCompressionRatio', \%variables, \%objectLists);
|
| 1728 |
|
| 1729 | #if ($exceedROMSize > 0)
|
| 1730 | #{
|
| 1731 | # &configFail(CONFIG_FAIL_INSUFFICIENT_FLASH_SIZE, $exceedROMSize);
|
| 1732 | #}
|
| 1733 |
|
| 1734 | printLog("Compute the Max Compressed Size");
|
| 1735 | {
|
| 1736 | $zImageMaxCompressedSize = &_getRegionMaxCompressedSize("ZIMAGE", $zImageRegionSize, $zImageDummyRegionSize + $anyCodeDummyRegionSize + $anyDataDummyRegionSize, $zImageBinary);
|
| 1737 | $aliceMaxCompressedSize = &_getRegionMaxCompressedSize("ALICE", $aliceRegionSize, $aliceDummyRegionSize, $aliceBinary);
|
| 1738 | }
|
| 1739 |
|
| 1740 | $zImageMaxCompressedSize =
|
| 1741 | &vivaHelper::RoundDownToAlignment($zImageMaxCompressedSize, $zImageSizeAlignment);
|
| 1742 | $aliceMaxCompressedSize =
|
| 1743 | &vivaHelper::RoundUpToAlignment($aliceMaxCompressedSize, $aliceSizeAlignment);
|
| 1744 |
|
| 1745 | printLog("ZIMAGE Max Compressed Size: ".vivaHelper::DecToHex($zImageMaxCompressedSize));
|
| 1746 | printLog("ALICE Max Compressed Size: ".vivaHelper::DecToHex($aliceMaxCompressedSize));
|
| 1747 | }
|
| 1748 |
|
| 1749 | # Check whether the configurations are changed
|
| 1750 | {
|
| 1751 | if ($featureConfig{"CONFIG_ZIMAGE_MAX_COMPRESSED_SIZE"} == $zImageMaxCompressedSize and
|
| 1752 | $featureConfig{"CONFIG_ALICE_MAX_COMPRESSED_SIZE"} == $aliceMaxCompressedSize)
|
| 1753 | {
|
| 1754 | debugLog("Config not changed");
|
| 1755 | $configChanged = 0;
|
| 1756 | }
|
| 1757 | else
|
| 1758 | {
|
| 1759 | debugLog("Config changed");
|
| 1760 | $configChanged = 1;
|
| 1761 | }
|
| 1762 |
|
| 1763 | if (&_isObjectListChanged($objectROM1ListFile, \@rom1List) or
|
| 1764 | &_isObjectListChanged($objectZImageListFile, \@zImageList) or
|
| 1765 | &_isObjectListChanged($objectAliceListFile, \@aliceList))
|
| 1766 | {
|
| 1767 | debugLog("Object list changed");
|
| 1768 | $objectListChanged = 1;
|
| 1769 | }
|
| 1770 | else
|
| 1771 | {
|
| 1772 | debugLog("Object list not changed");
|
| 1773 | $objectListChanged = 0;
|
| 1774 | }
|
| 1775 | }
|
| 1776 |
|
| 1777 | return ($configChanged, $objectListChanged);
|
| 1778 | }
|
| 1779 |
|
| 1780 | sub configZImage_FavorROM
|
| 1781 | {
|
| 1782 | printLog("Configuring ZIMAGE favoring ROM...");
|
| 1783 |
|
| 1784 | my $rom1RegionSize;
|
| 1785 | my $zImageRegionSize;
|
| 1786 |
|
| 1787 | my @anyCodeDummyList;
|
| 1788 | my @anyDataDummyList;
|
| 1789 |
|
| 1790 | my $anyCodeDummyRegionPadding;
|
| 1791 | my $anyDataDummyRegionPadding;
|
| 1792 |
|
| 1793 | my $rom1DummyRegionSize;
|
| 1794 | my $zImageDummyRegionSize;
|
| 1795 | my $anyCodeDummyRegionSize;
|
| 1796 | my $anyDataDummyRegionSize;
|
| 1797 |
|
| 1798 | my $zImageDummyCompressionRatio;
|
| 1799 |
|
| 1800 | my $freeRAMSize;
|
| 1801 |
|
| 1802 | my $availableRAM;
|
| 1803 |
|
| 1804 | my $exceedROMSize;
|
| 1805 |
|
| 1806 | my $targetSplitSize;
|
| 1807 |
|
| 1808 | my %variables =
|
| 1809 | (
|
| 1810 | '$dcmcmpUsedRAM' => ["DCMCMP Used RAM", \$dcmcmpUsedRAM],
|
| 1811 | '$veneerReserveRatio' => ["Veneer Reserve Ratio", \$veneerReserveRatio],
|
| 1812 | '$rom1RegionSize' => ["ROM1 Region Size", \$rom1RegionSize],
|
| 1813 | '$zImageRegionSize' => ["ZIMAGE Region Size", \$zImageRegionSize],
|
| 1814 | '$anyCodeDummyRegionPadding' => ["ANY_CODE Dummy Region Padding", \$anyCodeDummyRegionPadding],
|
| 1815 | '$anyDataDummyRegionPadding' => ["ANY_DATA Dummy Region Padding", \$anyDataDummyRegionPadding],
|
| 1816 | '$rom1DummyRegionSize' => ["ROM1 Dummy Region Size", \$rom1DummyRegionSize],
|
| 1817 | '$zImageDummyRegionSize' => ["ZIMAGE Dummy Region Size", \$zImageDummyRegionSize],
|
| 1818 | '$anyCodeDummyRegionSize' => ["ANY_CODE Dummy Region Size", \$anyCodeDummyRegionSize],
|
| 1819 | '$anyDataDummyRegionSize' => ["ANY_DATA Dummy Region Size", \$anyDataDummyRegionSize],
|
| 1820 | '$zImageDummyCompressionRatio' => ["ZIMAGE Dummy Compression Ratio", \$zImageDummyCompressionRatio],
|
| 1821 | '$freeRAMSize' => ["Free RAM Size", \$freeRAMSize],
|
| 1822 | '$availableRAM' => ["Available RAM", \$availableRAM],
|
| 1823 | '$exceedROMSize' => ["Exceed ROM Size", \$exceedROMSize],
|
| 1824 | '$targetSplitSize' => ["Target Split Size", \$targetSplitSize],
|
| 1825 | );
|
| 1826 |
|
| 1827 | my %objectLists =
|
| 1828 | (
|
| 1829 | '@rom1List' => ["ROM1 List", \@rom1List, '$rom1RegionSize',],
|
| 1830 | '@zImageList' => ["ZIMAGE List", \@zImageList, '$zImageRegionSize',],
|
| 1831 | '@anyCodeDummyList' => ["ANY_CODE Dummy List", \@anyCodeDummyList, '$anyCodeDummyRegionSize', '$anyCodeDummyRegionPadding'],
|
| 1832 | '@anyDataDummyList' => ["ANY_DATA Dummy List", \@anyDataDummyList, '$anyDataDummyRegionSize', '$anyDataDummyRegionPadding']
|
| 1833 | );
|
| 1834 |
|
| 1835 | printLog("Get dummy scatter object lists");
|
| 1836 | {
|
| 1837 | # Basic
|
| 1838 | &_inputObjectListFromFile($objectROM1DummyListFile, \@rom1List, "ROM1");
|
| 1839 | &_inputObjectListFromFile($objectZImageDummyListFile, \@zImageList, "ZIMAGE");
|
| 1840 |
|
| 1841 | # To be added
|
| 1842 | $anyCodeDummyRegionPadding = &_inputObjectListFromExecutionRegion("ZIMAGE_DUMMY_CODE", \@anyCodeDummyList, "+RO-CODE", "ANY_CODE list");
|
| 1843 | $anyDataDummyRegionPadding = &_inputObjectListFromExecutionRegion("ZIMAGE_DUMMY_DATA", \@anyDataDummyList, "+RO-DATA", "ANY_DATA list");
|
| 1844 | }
|
| 1845 |
|
| 1846 | printLog("Get size information");
|
| 1847 | {
|
| 1848 | $rom1DummyRegionSize = &_getExecutionRegionInfo("ROM1", "actual_size");
|
| 1849 | $zImageDummyRegionSize = &_getExecutionRegionInfo("ZIMAGE_ER", "actual_size");
|
| 1850 | $anyCodeDummyRegionSize = &_getExecutionRegionInfo("ZIMAGE_DUMMY_CODE", "actual_size");
|
| 1851 | $anyDataDummyRegionSize = &_getExecutionRegionInfo("ZIMAGE_DUMMY_DATA", "actual_size");
|
| 1852 |
|
| 1853 | $rom1RegionSize = $rom1DummyRegionSize;
|
| 1854 | $zImageRegionSize = $zImageDummyRegionSize;
|
| 1855 |
|
| 1856 | $freeRAMSize = &getFreeRAMSize();
|
| 1857 |
|
| 1858 | $exceedROMSize = &getExceedROMSize();
|
| 1859 | }
|
| 1860 |
|
| 1861 | # Configure
|
| 1862 | {
|
| 1863 | printLog("Compute Available RAM");
|
| 1864 | &_evaluateAssignment('$availableRAM = int(($freeRAMSize - $dcmcmpUsedRAM - $zImageDummyRegionSize) * (1 - $veneerReserveRatio))', \%variables);
|
| 1865 |
|
| 1866 | if ($availableRAM < 0)
|
| 1867 | {
|
| 1868 | &configFail(CONFIG_FAIL_INSUFFICIENT_RAM, -1 * $availableRAM);
|
| 1869 | }
|
| 1870 |
|
| 1871 | # Compute the compression ratios
|
| 1872 | printLog("Compute the compression ratios");
|
| 1873 | {
|
| 1874 | $zImageDummyCompressionRatio = &_getCompressionRatio("ZIMAGE", $zImageDummyRegionSize + $anyCodeDummyRegionSize + $anyDataDummyRegionSize, $zImageBinary);
|
| 1875 | }
|
| 1876 |
|
| 1877 | # Push ANY_DATA to ZIMAGE
|
| 1878 | &_splitObjectListAndPushByExceedROM('@anyDataDummyList', '@zImageList', '@rom1List',
|
| 1879 | '$zImageDummyCompressionRatio', \%variables, \%objectLists);
|
| 1880 |
|
| 1881 | # Push ANY_CODE to ZIMAGE
|
| 1882 | &_splitObjectListAndPushByExceedROM('@anyCodeDummyList', '@zImageList', '@rom1List',
|
| 1883 | '$zImageDummyCompressionRatio', \%variables, \%objectLists);
|
| 1884 |
|
| 1885 | #if ($exceedROMSize > 0)
|
| 1886 | #{
|
| 1887 | # &configFail(CONFIG_FAIL_INSUFFICIENT_FLASH_SIZE, $exceedROMSize);
|
| 1888 | #}
|
| 1889 |
|
| 1890 | printLog("Compute the Max Compressed Size");
|
| 1891 | {
|
| 1892 | $zImageMaxCompressedSize = &_getRegionMaxCompressedSize("ZIMAGE", $zImageRegionSize, $zImageDummyRegionSize + $anyCodeDummyRegionSize + $anyDataDummyRegionSize, $zImageBinary);
|
| 1893 | }
|
| 1894 |
|
| 1895 | $zImageMaxCompressedSize =
|
| 1896 | &vivaHelper::RoundDownToAlignment($zImageMaxCompressedSize, $zImageSizeAlignment);
|
| 1897 |
|
| 1898 | printLog("ZIMAGE Max Compressed Size: ".vivaHelper::DecToHex($zImageMaxCompressedSize));
|
| 1899 | }
|
| 1900 |
|
| 1901 | # Check whether the configurations are changed
|
| 1902 | {
|
| 1903 | if ($featureConfig{"CONFIG_ZIMAGE_MAX_COMPRESSED_SIZE"} == $zImageMaxCompressedSize)
|
| 1904 | {
|
| 1905 | debugLog("Config not changed");
|
| 1906 | $configChanged = 0;
|
| 1907 | }
|
| 1908 | else
|
| 1909 | {
|
| 1910 | debugLog("Config changed");
|
| 1911 | $configChanged = 1;
|
| 1912 | }
|
| 1913 |
|
| 1914 | if (&_isObjectListChanged($objectROM1ListFile, \@rom1List) or
|
| 1915 | &_isObjectListChanged($objectZImageListFile, \@zImageList))
|
| 1916 | {
|
| 1917 | debugLog("Object list changed");
|
| 1918 | $objectListChanged = 1;
|
| 1919 | }
|
| 1920 | else
|
| 1921 | {
|
| 1922 | debugLog("Object list not changed");
|
| 1923 | $objectListChanged = 0;
|
| 1924 | }
|
| 1925 | }
|
| 1926 |
|
| 1927 | return ($configChanged, $objectListChanged);
|
| 1928 | }
|
| 1929 |
|
| 1930 | sub _getCompressionRatio
|
| 1931 | {
|
| 1932 | my $regionName = shift;
|
| 1933 | my $dummyRegionSize = shift;
|
| 1934 | my $dummyCompressedBinary = shift;
|
| 1935 |
|
| 1936 | my $dummyCompressedSize = -s $dummyCompressedBinary or
|
| 1937 | &vivaHelper::ErrorHandler("Cannot get file size $dummyCompressedBinary: $!", __FILE__, __LINE__);
|
| 1938 | #debugLog("$regionName Dummy Region Size = $dummyRegionSize");
|
| 1939 | #debugLog("$regionName Dummy Compressed Binary Size = $dummyCompressedSize");
|
| 1940 |
|
| 1941 | my $compressionRatio = $dummyCompressedSize / $dummyRegionSize;
|
| 1942 | debugLog("$regionName Compression Ratio = $regionName Dummy Compressed Binary Size / $regionName Dummy Region Size");
|
| 1943 | debugLog(" = $dummyCompressedSize / $dummyRegionSize");
|
| 1944 | debugLog(" = $compressionRatio");
|
| 1945 |
|
| 1946 | return $compressionRatio;
|
| 1947 | }
|
| 1948 |
|
| 1949 | sub _splitObjectListAndPushByExceedROM
|
| 1950 | {
|
| 1951 | my $sourceList = shift;
|
| 1952 | my $firstList = shift;
|
| 1953 | my $secondList = shift;
|
| 1954 |
|
| 1955 | my $compressionRatio = shift;
|
| 1956 |
|
| 1957 | my $variables = shift;
|
| 1958 | my $objectLists = shift;
|
| 1959 |
|
| 1960 | if (${$variables->{'$exceedROMSize'}[1]} > 0)
|
| 1961 | {
|
| 1962 | printLog("Split $objectLists->{$sourceList}[0] to $objectLists->{$firstList}[0] and $objectLists->{$secondList}[0]");
|
| 1963 |
|
| 1964 | &_evaluateAssignment('$targetSplitSize = min($availableRAM, '."$objectLists->{$sourceList}[2]".')', $variables);
|
| 1965 | &_evaluateAssignment('$targetSplitSize = min($targetSplitSize, int($exceedROMSize / (1 - '."$compressionRatio".')))', $variables);
|
| 1966 |
|
| 1967 | ${$variables->{'$targetSplitSize'}[1]} = &_splitObjectListAndPush("$sourceList", "$firstList", "$secondList",
|
| 1968 | '$targetSplitSize', $variables, $objectLists);
|
| 1969 |
|
| 1970 | &_evaluateAssignment('$availableRAM = $availableRAM - $targetSplitSize - '."$objectLists->{$sourceList}[3]", $variables);
|
| 1971 | &_evaluateAssignment('$exceedROMSize = int($exceedROMSize - $targetSplitSize * (1 - '."$compressionRatio".'))', $variables);
|
| 1972 | }
|
| 1973 | else
|
| 1974 | {
|
| 1975 | printLog("Push $objectLists->{$sourceList}[0] to $objectLists->{$secondList}[0]");
|
| 1976 | &_pushToObjectList($secondList, $sourceList, $variables, $objectLists);
|
| 1977 | }
|
| 1978 | }
|
| 1979 |
|
| 1980 | #****************************************************************************
|
| 1981 | # subroutine: parseFeatureConfigFile
|
| 1982 | # description: Get the settings in the feature config file
|
| 1983 | # input: The setting hash ref
|
| 1984 | # output: The settings
|
| 1985 | #****************************************************************************
|
| 1986 | sub parseFeatureConfigFile
|
| 1987 | {
|
| 1988 | my $featureConfigRef = shift;
|
| 1989 | my $filename = $featureConfigFilePath;
|
| 1990 |
|
| 1991 | open my $input, "<$filename" or
|
| 1992 | &vivaHelper::ErrorHandler("Cannot open file $filename: $!", __FILE__, __LINE__);
|
| 1993 |
|
| 1994 | while (<$input>)
|
| 1995 | {
|
| 1996 | chomp;
|
| 1997 | if (/^\s*\#define\s+(\S+)\s+(\S+)/)
|
| 1998 | {
|
| 1999 | $featureConfigRef->{$1} = hex($2);
|
| 2000 | }
|
| 2001 | }
|
| 2002 |
|
| 2003 | close $input;
|
| 2004 | }
|
| 2005 |
|
| 2006 | #****************************************************************************
|
| 2007 | # subroutine: getFreeRAMSize
|
| 2008 | # description: Get the free RAM size.
|
| 2009 | # input: None
|
| 2010 | # output: Free RAM size
|
| 2011 | #****************************************************************************
|
| 2012 | sub getFreeRAMSize
|
| 2013 | {
|
| 2014 | # TODO: Move this to LISInfo.pm
|
| 2015 | my $externalRAMSize = &getExternalRAMSize();
|
| 2016 | my $usedRAM;
|
| 2017 | my $cacheDummyEndSize = 4;
|
| 2018 | my $result;
|
| 2019 |
|
| 2020 | my %regionInfo;
|
| 2021 | &vivaHelper::GetLISExecutionRegionInfo("DYNAMIC_CACHEABLE_EXTSRAM_DEFAULT_CACHEABLE_ZI", \%regionInfo);
|
| 2022 | $usedRAM = ($regionInfo{"base_address"} & hex("0x07FFFFFF")) + $regionInfo{"actual_size"};
|
| 2023 | debugLog("End of cacheable ZI = $usedRAM");
|
| 2024 |
|
| 2025 | &vivaHelper::GetLISExecutionRegionInfo("EXTSRAM_DSP_TX", \%regionInfo);
|
| 2026 | $usedRAM += $regionInfo{"max_size"};
|
| 2027 | debugLog("DSP TX RAM = ".$regionInfo{"max_size"});
|
| 2028 |
|
| 2029 | &vivaHelper::GetLISExecutionRegionInfo("EXTSRAM_DSP_RX", \%regionInfo);
|
| 2030 | $usedRAM += $regionInfo{"max_size"};
|
| 2031 | debugLog("DSP RX RAM = ".$regionInfo{"max_size"});
|
| 2032 |
|
| 2033 | debugLog("Cache dummy end size = $cacheDummyEndSize");
|
| 2034 |
|
| 2035 | $result = $externalRAMSize - $usedRAM - $cacheDummyEndSize;
|
| 2036 |
|
| 2037 | debugLog("Free RAM size = External Total RAM Size - (End of cacheable ZI + DSP TX RAM + DSP RX RAM) - Cache Dummy End Size");
|
| 2038 | debugLog(" = $result");
|
| 2039 |
|
| 2040 | return $result;
|
| 2041 | }
|
| 2042 |
|
| 2043 | #****************************************************************************
|
| 2044 | # subroutine: getTotalLISROMSize
|
| 2045 | # description: Get total ROM size in LIS file.
|
| 2046 | # input: None
|
| 2047 | # output: Total ROM size in LIS file
|
| 2048 | #****************************************************************************
|
| 2049 | sub getTotalLISROMSize
|
| 2050 | {
|
| 2051 | my %totalSizeInfo;
|
| 2052 | &vivaHelper::GetLISTotalSize(\%totalSizeInfo);
|
| 2053 |
|
| 2054 | my $totalLISROMSize = $totalSizeInfo{"ROM"};
|
| 2055 |
|
| 2056 | debugLog("Total LIS ROM size = $totalLISROMSize");
|
| 2057 |
|
| 2058 | return $totalLISROMSize;
|
| 2059 | }
|
| 2060 |
|
| 2061 | #****************************************************************************
|
| 2062 | # subroutine: getFileSystemBaseAddress
|
| 2063 | # description: Get the file system base address.
|
| 2064 | # input: None
|
| 2065 | # output: File system base address
|
| 2066 | #****************************************************************************
|
| 2067 | sub getFileSystemBaseAddress
|
| 2068 | {
|
| 2069 | my $result;
|
| 2070 |
|
| 2071 | open my $input, "<$flashConfigFilePath" or
|
| 2072 | &vivaHelper::ErrorHandler("Cannot open file $flashConfigFilePath: $!", __FILE__, __LINE__);
|
| 2073 |
|
| 2074 | while (<$input>)
|
| 2075 | {
|
| 2076 | if (/int flash_base_address\s+=\s+((\S|\s)+);/)
|
| 2077 | {
|
| 2078 | $result = eval($1);
|
| 2079 | last;
|
| 2080 | }
|
| 2081 | }
|
| 2082 | close ($input);
|
| 2083 |
|
| 2084 | debugLog("File System Base Address = $result");
|
| 2085 |
|
| 2086 | return $result;
|
| 2087 | }
|
| 2088 |
|
| 2089 | #****************************************************************************
|
| 2090 | # subroutine: getExceedROMSize
|
| 2091 | # description: Get the bytes exceed maximum ROM size.
|
| 2092 | # input: None
|
| 2093 | # output: Byte exceeded
|
| 2094 | #****************************************************************************
|
| 2095 | sub getExceedROMSize
|
| 2096 | {
|
| 2097 | my $fsBaseAddress = &getFileSystemBaseAddress();
|
| 2098 | my $totalLISROMSize = &getTotalLISROMSize();
|
| 2099 | my $scatterReservedSize = &vivaHelper::GetScatterReservedSize($fsBaseAddress);
|
| 2100 | debugLog("Scatter Reserved Size = $scatterReservedSize");
|
| 2101 |
|
| 2102 | my $exceedROMSize = $totalLISROMSize + $scatterReservedSize - $fsBaseAddress;
|
| 2103 |
|
| 2104 | debugLog("Exceed ROM Size = Total LIS ROM size + Scatter Reserved Size - File System Base Address");
|
| 2105 | debugLog(" = $totalLISROMSize + $scatterReservedSize - $fsBaseAddress");
|
| 2106 | debugLog(" = $exceedROMSize");
|
| 2107 |
|
| 2108 | return $exceedROMSize;
|
| 2109 | }
|
| 2110 |
|
| 2111 | #****************************************************************************
|
| 2112 | # subroutine: getExternalRAMSize
|
| 2113 | # description: Get the external RAM size.
|
| 2114 | # input: None
|
| 2115 | # output: External RAM size
|
| 2116 | #****************************************************************************
|
| 2117 | sub getExternalRAMSize
|
| 2118 | {
|
| 2119 | my $filename = "$customFolder\\custom_EMI_release.h";
|
| 2120 | my $result;
|
| 2121 |
|
| 2122 | open my $input, "<$filename" or
|
| 2123 | &vivaHelper::ErrorHandler("Cannot open file $flashConfigFilePath: $!", __FILE__, __LINE__);
|
| 2124 |
|
| 2125 | while (<$input>)
|
| 2126 | {
|
| 2127 | if (/\#define EMI_EXTSRAM_SIZE ((\S|\s)+)/)
|
| 2128 | {
|
| 2129 | $result = eval($1);
|
| 2130 | last;
|
| 2131 | }
|
| 2132 | }
|
| 2133 | close ($input);
|
| 2134 |
|
| 2135 | debugLog("External Total RAM Size = $result");
|
| 2136 |
|
| 2137 | return $result;
|
| 2138 | }
|
| 2139 |
|
| 2140 | #****************************************************************************
|
| 2141 | # subroutine: isAutoConfigEnable
|
| 2142 | # description: See if the auto configuration mechanism is enabled or not.
|
| 2143 | # input: None
|
| 2144 | # output: 1: enabled; 0: not enabled
|
| 2145 | #****************************************************************************
|
| 2146 | sub isAutoConfigEnable
|
| 2147 | {
|
| 2148 | my $autoConfig = &vivaHelper::GetMakefileOption("ZIMAGE_AUTO_CONFIG");
|
| 2149 |
|
| 2150 | if (not defined $autoConfig or $autoConfig eq "TRUE")
|
| 2151 | {
|
| 2152 | return 1;
|
| 2153 | }
|
| 2154 | else
|
| 2155 | {
|
| 2156 | return 0;
|
| 2157 | }
|
| 2158 | }
|
| 2159 |
|
| 2160 | #****************************************************************************
|
| 2161 | # subroutine: printIntermediateFile
|
| 2162 | # description: Print to intermediate file.
|
| 2163 | # input: Message
|
| 2164 | # output: None
|
| 2165 | #****************************************************************************
|
| 2166 | sub printIntermediateFile
|
| 2167 | {
|
| 2168 | my $message = shift;
|
| 2169 |
|
| 2170 | open my $output, ">$intermediateFilePath" or
|
| 2171 | &vivaHelper::ErrorHandler("Cannot open file $intermediateFilePath: $!", __FILE__, __LINE__);
|
| 2172 |
|
| 2173 | print $output $message;
|
| 2174 |
|
| 2175 | close $output;
|
| 2176 | }
|
| 2177 |
|
| 2178 | #****************************************************************************
|
| 2179 | # subroutine: configFailLog
|
| 2180 | # description: Output the config fail information.
|
| 2181 | # input: Fail reason message, recommendation message
|
| 2182 | # output: None
|
| 2183 | #****************************************************************************
|
| 2184 | sub configFailLog
|
| 2185 | {
|
| 2186 | my ($failReason, $recommend) = @_;
|
| 2187 |
|
| 2188 | my $message = "Error: $failReason\nRecommend: $recommend\n";
|
| 2189 | printLog("\n$message");
|
| 2190 |
|
| 2191 | open (FILE_HANDLE, ">$intermediateFilePath") or
|
| 2192 | &vivaHelper::ErrorHandler("Cannot open file $intermediateFilePath: $!", __FILE__, __LINE__);
|
| 2193 | print FILE_HANDLE $message;
|
| 2194 | close FILE_HANDLE;
|
| 2195 |
|
| 2196 | exit ERR::CANNOT_ADJUST;
|
| 2197 | }
|
| 2198 |
|
| 2199 | #****************************************************************************
|
| 2200 | # subroutine: configFail
|
| 2201 | # description: Indicate the configuration is failed.
|
| 2202 | # input: Fail code (constant with CONFIG_FAIL_XXXX)
|
| 2203 | # output: None
|
| 2204 | #****************************************************************************
|
| 2205 | sub configFail
|
| 2206 | {
|
| 2207 | my $failCode = shift;
|
| 2208 | my $failReason;
|
| 2209 | my $recommend;
|
| 2210 |
|
| 2211 | if ($failCode == CONFIG_FAIL_INSUFFICIENT_RAM)
|
| 2212 | {
|
| 2213 | my $exceeded = shift;
|
| 2214 | $failReason = "Insufficient RAM space. ($exceeded bytes exceeded)";
|
| 2215 | $recommend = "Please turn off some features. (e.g. DCM_COMPRESSION_SUPPORT)";
|
| 2216 | }
|
| 2217 | elsif ($failCode == CONFIG_FAIL_ZIMAGE_OVERFLOW)
|
| 2218 | {
|
| 2219 | my $exceeded = shift;
|
| 2220 | $failReason = "ZIMAGE overflow. ($exceeded bytes exceeded)";
|
| 2221 | $recommend = "Please either\n (1) remove xxx.lib/xxx.obj from ZIMAGE, or\n (2) turn off some features"
|
| 2222 | }
|
| 2223 | elsif ($failCode == CONFIG_FAIL_FEATURE_NOT_ENABLED)
|
| 2224 | {
|
| 2225 | $failReason = "No configurable feature is enabled.";
|
| 2226 | $recommend = "Please turn off some features and refer to build\\[BB]\\VIVA_DEBUG\\[BB].error for more information.";
|
| 2227 | }
|
| 2228 | elsif ($failCode == CONFIG_FAIL_NO_CONFIG_CHANGED)
|
| 2229 | {
|
| 2230 | $failReason = "The configuration is not changed.";
|
| 2231 | $recommend = "Please turn off some features."
|
| 2232 | }
|
| 2233 | elsif ($failCode == CONFIG_FAIL_INSUFFICIENT_FLASH_SIZE)
|
| 2234 | {
|
| 2235 | my $exceeded = shift;
|
| 2236 | $failReason = "Insufficient flash space. ($exceeded bytes exceeded)";
|
| 2237 | $recommend = "Please turn off some features."
|
| 2238 | }
|
| 2239 | elsif ($failCode == CONFIG_FAIL_INSUFFICIENT_RAM_FOR_BOOT_ZIMAGE)
|
| 2240 | {
|
| 2241 | my $exceeded = shift;
|
| 2242 | $failReason = "Insufficient RAM space for BOOT_ZIMAGE. ($exceeded bytes exceeded)";
|
| 2243 | $recommend = "Please turn off some features. (e.g. DCM_COMPRESSION_SUPPORT)";
|
| 2244 | }
|
| 2245 | else
|
| 2246 | {
|
| 2247 | $failReason = "Unknown.";
|
| 2248 | $recommend = "Please call for help";
|
| 2249 | }
|
| 2250 |
|
| 2251 | &configFailLog($failReason, $recommend);
|
| 2252 | }
|
| 2253 |
|
| 2254 | #****************************************************************************
|
| 2255 | # subroutine: min
|
| 2256 | # description: Get the minimum one in the two input.
|
| 2257 | # input: Number 1, number 2
|
| 2258 | # output: Minimum number
|
| 2259 | #****************************************************************************
|
| 2260 | sub min
|
| 2261 | {
|
| 2262 | my ($m, $n) = @_;
|
| 2263 |
|
| 2264 | if ($m < $n) {
|
| 2265 | $m
|
| 2266 | }
|
| 2267 | else {
|
| 2268 | $n
|
| 2269 | }
|
| 2270 | }
|
| 2271 |
|
| 2272 | #****************************************************************************
|
| 2273 | # subroutine: getTimeStamp
|
| 2274 | # description: Get a time stamp.
|
| 2275 | # input: None
|
| 2276 | # output: The time stamp
|
| 2277 | #****************************************************************************
|
| 2278 | sub getTimeStamp
|
| 2279 | {
|
| 2280 | return time().".".int(rand(1000));
|
| 2281 | }
|
| 2282 |
|
| 2283 |
|
| 2284 | #****************************************************************************
|
| 2285 | # subroutine: backupFile
|
| 2286 | # description: Backup file with a timestamp appended.
|
| 2287 | # input: Filename
|
| 2288 | # output: None
|
| 2289 | #****************************************************************************
|
| 2290 | sub backupFile
|
| 2291 | {
|
| 2292 | my $filename = shift;
|
| 2293 | my $backupFilename = $filename.".beforeAutoAdj".getTimeStamp();
|
| 2294 |
|
| 2295 | copy($filename, $backupFilename) or
|
| 2296 | &vivaHelper::ErrorHandler("Cannot backup file $filename: $!", __FILE__, __LINE__);
|
| 2297 | }
|
| 2298 |
|
| 2299 |
|
| 2300 | sub printLog
|
| 2301 | {
|
| 2302 | print "$_[0]\n";
|
| 2303 | }
|
| 2304 |
|
| 2305 | sub debugLog
|
| 2306 | {
|
| 2307 | if ($DEBUG)
|
| 2308 | {
|
| 2309 | printLog("\t$_[0]");
|
| 2310 | }
|
| 2311 | }
|
| 2312 |
|
| 2313 | # DEBUG command
|
| 2314 | # tools\vivaConfig.pl .\build\KHAN50D_V11_DEMO\VIVA_DEBUG\KHAN50D_V11_DEMO_PCB01_gprs_MT6250_S00.lis.dummy .\build\KHAN50D_V11_DEMO\VIVA_DEBUG\KHAN50D_V11_DEMO_PCB01_gprs_MT6250_S00.MAUI_11BW1132SP_W12_15.bin_dummy .\custom\system\KHAN50D_V11_DEMO_BB .\make\KHAN50D_V11_DEMO_GPRS.mak ~flash_cfg_tmp.c intermediate.log aapmc.log > build\KHAN50D_V11_DEMO\log\vivaConfig.log
|