From 8b3989a2a90d6e86a0f1bbf52bc3f58c142f014a Mon Sep 17 00:00:00 2001 From: Stephen Cprek Date: Tue, 27 Jun 2017 14:25:38 -0500 Subject: Check if PNOR sections overlap and display total free size Total free size = Gaps + Space at the end of the image Change-Id: Ie061430074cf14dce4235ac8ff52ee1c3873eedf Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/42509 Tested-by: Jenkins Server Reviewed-by: Martin Gloff Tested-by: Jenkins OP Build CI Reviewed-by: Nicholas E. Bofferding Reviewed-by: Daniel M. Crowell --- src/build/buildpnor/PnorUtils.pm | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'src/build/buildpnor') diff --git a/src/build/buildpnor/PnorUtils.pm b/src/build/buildpnor/PnorUtils.pm index 635af504c..4c7e0a9fe 100644 --- a/src/build/buildpnor/PnorUtils.pm +++ b/src/build/buildpnor/PnorUtils.pm @@ -523,7 +523,9 @@ sub displayPnorLayout } my $curOffset = 0; - my $totalFree = 0; + my $gapTotal = 0; + my $prevOffset = 0; + my $prevSize = 0; # Iterate through all sections of PNOR, including TOC's foreach my $section (sort {$a <=> $b} keys %{$$i_pnorLayoutRef{sections}}) { @@ -532,6 +534,14 @@ sub displayPnorLayout my $size = sprintf("0x%X",$$i_pnorLayoutRef{sections}{$section}{physicalRegionSize}); my $end = sprintf("0x%X",hex($offset)+hex($size)); + if ($prevOffset+$prevSize > hex($offset)) + { + my $hexEndPrevSection = sprintf("0x%X",$prevOffset+$prevSize); + print "---- Error: Prevoius Section ends at offset $hexEndPrevSection which is after Current Offset $offset\n"; + print "---- Current Offset Section: ".$$i_pnorLayoutRef{sections}{$section}{eyeCatch}."-$offset-$size-$end\n"; + die ">>Error overlapping section\n"; + } + # Check if there is a gap between sections if ($i_gaps && ($curOffset < hex($offset))) { @@ -540,7 +550,7 @@ sub displayPnorLayout # Display address and size of gap my $gapSize = hex($offset)-$curOffset; print " size = ".sprintf("0x%X",$gapSize)."\n"; - $totalFree += $gapSize; + $gapTotal += $gapSize; $curOffset = hex($offset) + hex($size); } else @@ -548,6 +558,9 @@ sub displayPnorLayout $curOffset += hex($size); } + $prevOffset = hex($offset); + $prevSize = hex($size); + # Print sections if ($i_verbose) { @@ -564,10 +577,19 @@ sub displayPnorLayout # Display total free space if($i_gaps) { - my $hexVal = sprintf("0x%X",$totalFree); - my $kiloBytes = $totalFree/1024; - print "\n---Total Free Space = ".$totalFree." Bytes or ".$kiloBytes." KB"; + my $hexVal = sprintf("0x%X",$gapTotal); + my $kiloBytes = $gapTotal/1024; + print "\n---Total Gap(s) Free Space = ".$gapTotal." Bytes or ".$kiloBytes." KB"; print " (".$hexVal.")\n"; } + + my $endImageFree = $$i_pnorLayoutRef{metadata}{imageSize} - $curOffset; + $endImageFree = 0 if ($endImageFree < 0 ); + my $totalFree = $endImageFree + $gapTotal; + + my $hexVal = sprintf("0x%X",$totalFree); + my $kiloBytes = $totalFree/1024; + print "---Total Free Space = ".$totalFree." Bytes or ".$kiloBytes." KB"; + print " (".$hexVal.")\n"; } 1; -- cgit v1.2.1