Skip to content

Commit

Permalink
Check if PNOR sections overlap and display total free size
Browse files Browse the repository at this point in the history
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 <pfd-jenkins+hostboot@us.ibm.com>
Reviewed-by: Martin Gloff <mgloff@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Reviewed-by: Nicholas E. Bofferding <bofferdn@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
  • Loading branch information
Stephen Cprek authored and dcrowell77 committed Jun 28, 2017
1 parent f2250d8 commit 8b3989a
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions src/build/buildpnor/PnorUtils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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}})
{
Expand All @@ -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)))
{
Expand All @@ -540,14 +550,17 @@ 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
{
$curOffset += hex($size);
}

$prevOffset = hex($offset);
$prevSize = hex($size);

# Print sections
if ($i_verbose)
{
Expand All @@ -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;

0 comments on commit 8b3989a

Please sign in to comment.