diff options
Diffstat (limited to 'src/build/buildpnor/genPnorImages.pl')
-rwxr-xr-x | src/build/buildpnor/genPnorImages.pl | 68 |
1 files changed, 60 insertions, 8 deletions
diff --git a/src/build/buildpnor/genPnorImages.pl b/src/build/buildpnor/genPnorImages.pl index 4782b7e8f..cc3b4f5e9 100755 --- a/src/build/buildpnor/genPnorImages.pl +++ b/src/build/buildpnor/genPnorImages.pl @@ -61,6 +61,11 @@ my $programName = File::Basename::basename $0; my @systemBinFiles = (); my %pnorLayout = (); my %PhysicalOffsets = (); +my %partitionUtilHash; + +# percentage utilization threshold, if crossed display warning message +# that partition is almost full +use constant CRITICAL_THRESHOLD => 85.00; # Truncate SHA to n bytes use constant SHA_TRUNCATE_SIZE => 32; @@ -74,6 +79,7 @@ use constant VFS_MODULE_TABLE_MAX_SIZE => VFS_EXTENDED_MODULE_MAX # Flag parameter string passed into signing tools # Note spaces before/after are critical. use constant OP_SIGNING_FLAG => " --flags "; +use constant SW_FLAG_HAS_A_HPT => 0x80000000; # Security bits HW flag strings use constant OP_BUILD_FLAG => 0x80000000; use constant FIPS_BUILD_FLAG => 0x40000000; @@ -120,6 +126,7 @@ my $sign_mode = $DEVELOPMENT; my $hwKeyHashFile = ""; my $hb_standalone=""; my $buildType=""; +my $editedLayoutLocation=""; # @TODO RTC 170650: Set default to 0 after all environments provide external # control over this policy, plus remove '!' from 'lab-security-override' @@ -142,6 +149,7 @@ GetOptions("binDir:s" => \$bin_dir, "lab-security-override!" => \$labSecurityOverride, "emit-eccless" => \$emitEccless, "build-type:s" => \$buildType, + "editedLayoutLocation:s" => \$editedLayoutLocation, "help" => \$help); if ($help) @@ -385,7 +393,8 @@ if ($build_all && $secureboot) } #Load PNOR Layout XML file -loadPnorLayout($pnorLayoutFile, \%pnorLayout, \%PhysicalOffsets, $testRun); +loadPnorLayout($pnorLayoutFile, \%pnorLayout, \%PhysicalOffsets, $testRun, + $editedLayoutLocation); # Generate final images for each system's bin files. foreach my $binFilesCSV (@systemBinFiles) @@ -408,6 +417,17 @@ foreach my $binFilesCSV (@systemBinFiles) manipulateImages(\%pnorLayout, \%binFiles, $system_target); } +# display percentage utilization data for each eyecatch +foreach my $key (keys %partitionUtilHash) { + + print "$key is $partitionUtilHash{$key}{pctUtilized} utilized ($partitionUtilHash{$key}{freeBytes} of $partitionUtilHash{$key}{physicalRegionSize} bytes free)\n"; + + # if percentage is greater than critical threshold, surface warning + if ($partitionUtilHash{$key}{pctUtilized} > CRITICAL_THRESHOLD) { + print "Warning: Percent utilization for $key shows that partition is almost full.\n"; + } +} + ################################################################################ # Subroutines ################################################################################ @@ -451,6 +471,7 @@ sub partitionDepSort ################################################################################ # manipulateImages - Perform any ECC/padding/sha/signing manipulations ################################################################################ + sub manipulateImages { my ($i_pnorLayoutRef, $i_binFilesRef, $system_target) = @_; @@ -464,7 +485,10 @@ sub manipulateImages # Partitions that have a hash page table at the beginning of the section # for secureboot purposes. - my %hashPageTablePartitions = (HBI => 1); + # TODO: add back SBE and HCODE as per story 209485 + my %hashPageTablePartitions = (HBI => 1, + WOFDATA => 1, + MEMD => 1); if($ENV{'RM_HASH_PAGE_TABLE'}) { undef %hashPageTablePartitions; @@ -483,7 +507,16 @@ sub manipulateImages instructionStartStackPointer => 0); my $layoutKey = findLayoutKeyByEyeCatch($key, \%$i_pnorLayoutRef); + + # Skip if binary file isn't included in the PNOR layout file + if ($layoutKey eq -1) + { + print "Warning: skipping $key since it is NOT in the PNOR layout file\n"; + next; + } + my $eyeCatch = $sectionHash{$layoutKey}{eyeCatch}; + my $physicalRegionSize = $sectionHash{$layoutKey}{physicalRegionSize}; my %tempImages = ( HDR_PHASE => "$bin_dir/$parallelPrefix.$eyeCatch.temp.hdr.bin", TEMP_SHA_IMG => "$bin_dir/$parallelPrefix.$eyeCatch.temp.sha.bin", @@ -506,24 +539,23 @@ sub manipulateImages # Sections that have secureboot support. Secureboot still must be # enabled for secureboot actions on these partitions to occur. my $isNormalSecure = ($eyeCatch eq "HBBL"); - $isNormalSecure ||= ($eyeCatch eq "SBE"); - $isNormalSecure ||= ($eyeCatch eq "MEMD"); $isNormalSecure ||= ($eyeCatch eq "HBRT"); $isNormalSecure ||= ($eyeCatch eq "PAYLOAD"); $isNormalSecure ||= ($eyeCatch eq "OCC"); - $isNormalSecure ||= ($eyeCatch eq "CAPP"); $isNormalSecure ||= ($eyeCatch eq "BOOTKERNEL"); - $isNormalSecure ||= ($eyeCatch eq "HCODE"); - $isNormalSecure ||= ($eyeCatch eq "CENHWIMG"); - $isNormalSecure ||= ($eyeCatch eq "WOFDATA"); $isNormalSecure ||= ($eyeCatch eq "IMA_CATALOG"); $isNormalSecure ||= ($eyeCatch eq "TESTRO"); $isNormalSecure ||= ($eyeCatch eq "TESTLOAD"); $isNormalSecure ||= ($eyeCatch eq "VERSION"); + $isNormalSecure ||= ($eyeCatch eq "CENHWIMG"); + $isNormalSecure ||= ($eyeCatch eq "SBE"); + $isNormalSecure ||= ($eyeCatch eq "HCODE"); my $isSpecialSecure = ($eyeCatch eq "HBB"); $isSpecialSecure ||= ($eyeCatch eq "HBD"); $isSpecialSecure ||= ($eyeCatch eq "HBI"); + $isSpecialSecure ||= ($eyeCatch eq "WOFDATA"); + $isSpecialSecure ||= ($eyeCatch eq "MEMD"); # Used to indicate security is supported in firmware my $secureSupported = $isNormalSecure || $isSpecialSecure; @@ -662,6 +694,9 @@ sub manipulateImages else { run_command("cp $tempImages{hashPageTable} $tempImages{PAYLOAD_TEXT}"); + # Hash table generated so need to set sw-flags + my $hex_sw_flag = sprintf("0x%08X", SW_FLAG_HAS_A_HPT); + $CUR_OPEN_SIGN_REQUEST .= " --sw-flags $hex_sw_flag "; } run_command("$CUR_OPEN_SIGN_REQUEST " @@ -734,6 +769,22 @@ sub manipulateImages setCallerHwHdrFields(\%callerHwHdrFields, $tempImages{HDR_PHASE}); + + # store binary file size + header size in hash + + # If section will passed through ecc, include this in size calculation + if( ($sectionHash{$layoutKey}{ecc} eq "yes") ) + { + $partitionUtilHash{$eyeCatch}{logicalFileSize} = $callerHwHdrFields{totalContainerSize} * (9/8); + } + else + { + $partitionUtilHash{$eyeCatch}{logicalFileSize} = $callerHwHdrFields{totalContainerSize}; + } + $partitionUtilHash{$eyeCatch}{pctUtilized} = sprintf("%.2f", $partitionUtilHash{$eyeCatch}{logicalFileSize} / $physicalRegionSize * 100); + $partitionUtilHash{$eyeCatch}{freeBytes} = $physicalRegionSize - $partitionUtilHash{$eyeCatch}{logicalFileSize}; + $partitionUtilHash{$eyeCatch}{physicalRegionSize} = $physicalRegionSize; + # Padding Phase if ($eyeCatch eq "HBI" && $testRun) { @@ -1258,6 +1309,7 @@ print <<"ENDUSAGE"; switch (separated with a space and not including the single quotes). OpenPower is the default. + --editedLayoutLocation <directory> Location to place edited layout file Current Limitations: - Issues with dependency on ENGD build for certain files such as SBE. This is why [--build-all | --install-all ] are used. |