summaryrefslogtreecommitdiffstats
path: root/src/build/buildpnor
diff options
context:
space:
mode:
Diffstat (limited to 'src/build/buildpnor')
-rw-r--r--src/build/buildpnor/PnorUtils.pm32
1 files changed, 27 insertions, 5 deletions
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;
OpenPOWER on IntegriCloud