diff options
author | Stephen Cprek <smcprek@us.ibm.com> | 2017-06-27 14:25:38 -0500 |
---|---|---|
committer | Daniel M. Crowell <dcrowell@us.ibm.com> | 2017-06-28 09:54:43 -0400 |
commit | 8b3989a2a90d6e86a0f1bbf52bc3f58c142f014a (patch) | |
tree | 93e0fe8c7b8297fca293287161f6fe36add25f2e /src/build/buildpnor/PnorUtils.pm | |
parent | f2250d8720223ea8fde4a7c0b6819eaebf070915 (diff) | |
download | talos-hostboot-8b3989a2a90d6e86a0f1bbf52bc3f58c142f014a.tar.gz talos-hostboot-8b3989a2a90d6e86a0f1bbf52bc3f58c142f014a.zip |
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 <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>
Diffstat (limited to 'src/build/buildpnor/PnorUtils.pm')
-rw-r--r-- | src/build/buildpnor/PnorUtils.pm | 32 |
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; |