diff options
author | Mike Baiocchi <mbaiocch@us.ibm.com> | 2018-02-12 22:13:44 -0600 |
---|---|---|
committer | Daniel M. Crowell <dcrowell@us.ibm.com> | 2018-02-16 20:19:25 -0500 |
commit | 2d6ba11ae2fc6dd2aca923be277cb94ef7e95c92 (patch) | |
tree | 3b392be079a5b441e2844883b844bb0076b72078 /src/build/buildpnor/PnorUtils.pm | |
parent | 31b01f231f1ce478eff888f878d61b7291eca6c6 (diff) | |
download | talos-hostboot-2d6ba11ae2fc6dd2aca923be277cb94ef7e95c92.tar.gz talos-hostboot-2d6ba11ae2fc6dd2aca923be277cb94ef7e95c92.zip |
Add checks to PnorUtils.pm to look for errors in layout files
This commit adds a check that 2 PNOR sections do not start at
the same offset. It also checks that adjacent PNOR sections
do not have overlapping regions.
Change-Id: I57d3a545190e6c9cb47b58977b2b0ec002bf0452
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/54090
Reviewed-by: ILYA SMIRNOV <ismirno@us.ibm.com>
Reviewed-by: Nicholas E. Bofferding <bofferdn@us.ibm.com>
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@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 | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/src/build/buildpnor/PnorUtils.pm b/src/build/buildpnor/PnorUtils.pm index c02206b11..a4689f598 100644 --- a/src/build/buildpnor/PnorUtils.pm +++ b/src/build/buildpnor/PnorUtils.pm @@ -6,7 +6,7 @@ # # OpenPOWER HostBoot Project # -# Contributors Listed Below - COPYRIGHT 2016,2017 +# Contributors Listed Below - COPYRIGHT 2016,2018 # [+] International Business Machines Corp. # # @@ -174,6 +174,11 @@ sub loadPnorLayout die "ERROR: $this_func: Image size ($imageSize) smaller than $eyeCatch's offset + $eyeCatch's size (".($physicalOffset + $physicalRegionSize)."). Aborting! "; } + if (exists $$i_pnorLayoutRef{sections}{$physicalOffset}) + { + die "ERROR: $this_func: Region ".$$i_pnorLayoutRef{sections}{$physicalOffset}{eyeCatch}." already starts where $eyeCatch starts: ".sprintf("0x%X",$physicalOffset)."!"; + } + $$i_pnorLayoutRef{sections}{$physicalOffset}{description} = $description; $$i_pnorLayoutRef{sections}{$physicalOffset}{eyeCatch} = $eyeCatch; $$i_pnorLayoutRef{sections}{$physicalOffset}{physicalOffset} = $physicalOffset; @@ -205,7 +210,10 @@ sub loadPnorLayout $$i_physicalOffsets{side}{$side}{eyecatch}{$eyeCatch} = $physicalOffset; } } + # After all sections have been processed, check for overlaps among them + checkForOverlap($i_pnorLayoutRef); } + return 0; } @@ -521,6 +529,39 @@ sub checkFile } ############################################################################### +# Check For Overlap - Check For Overlaps Between PNOR Sections +################################################################################ +sub checkForOverlap +{ + my ($i_pnorLayoutRef) = @_; + my $curOffset = 0; + my $gapTotal = 0; + my $prevOffset = 0; + my $prevSize = 0; + my $prevEyeCatch = 0; + # Iterate through all sections of PNOR, including TOC's + foreach my $section (sort {$a <=> $b} keys %{$$i_pnorLayoutRef{sections}}) + { + # Get hex format for each value + my $offset = sprintf("0x%X",$$i_pnorLayoutRef{sections}{$section}{physicalOffset}); + 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: checkForOverlap: Previous Section $prevEyeCatch 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"; + } + $prevOffset = hex($offset); + $prevSize = hex($size); + $prevEyeCatch=$$i_pnorLayoutRef{sections}{$section}{eyeCatch}; + } +} + + +############################################################################### # Display Pnor Layout - Display XML pnor layout more simply ################################################################################ sub displayPnorLayout @@ -549,7 +590,7 @@ sub displayPnorLayout 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 "---- Error: Previous 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"; } |