diff options
author | Stephen Cprek <smcprek@us.ibm.com> | 2017-06-06 14:56:45 -0500 |
---|---|---|
committer | Daniel M. Crowell <dcrowell@us.ibm.com> | 2017-06-23 10:08:26 -0400 |
commit | b22bfa0529a673baea56805fa4fcc1ba65c29666 (patch) | |
tree | 115ab6fda1d253fa595a20be96f44cb7b3e3480d /src/build/buildpnor/PnorUtils.pm | |
parent | ea259b6658e294b19cbf13a5c3b5f2170c4d0617 (diff) | |
download | talos-hostboot-b22bfa0529a673baea56805fa4fcc1ba65c29666.tar.gz talos-hostboot-b22bfa0529a673baea56805fa4fcc1ba65c29666.zip |
Create script to test modifying a section's size in the pnor xml
This can be used to quickly check if a resize is valid and print
all the new offsets
Change-Id: I36108ca23f743673279b8bad82629b25f886e222
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/41445
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Reviewed-by: Nicholas E. Bofferding <bofferdn@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>
Reviewed-by: Michael Baiocchi <mbaiocch@us.ibm.com>
Reviewed-by: Martin Gloff <mgloff@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 | 71 |
1 files changed, 67 insertions, 4 deletions
diff --git a/src/build/buildpnor/PnorUtils.pm b/src/build/buildpnor/PnorUtils.pm index bcdf53af1..635af504c 100644 --- a/src/build/buildpnor/PnorUtils.pm +++ b/src/build/buildpnor/PnorUtils.pm @@ -30,8 +30,9 @@ use File::Basename; use Exporter 'import'; @EXPORT_OK = qw(loadPnorLayout getNumber traceErr trace run_command PAGE_SIZE loadBinFiles findLayoutKeyByEyeCatch checkSpaceConstraints - getSwSignatures getBinDataFromFile checkFile); + getSwSignatures getBinDataFromFile checkFile displayPnorLayout); use strict; +use Data::Dumper; my $TRAC_ERR = 0; # 0=errors, >0 for more traces, leaving at 1 to keep key milestone traces. @@ -89,7 +90,7 @@ sub loadPnorLayout my $numOfSides = scalar (@{$metadataEl->{side}}); my $sideSize = ($imageSize)/($numOfSides); - trace(1, " $this_func: metadata: imageSize = $imageSize, blockSize=$blockSize, arrangement = $arrangement, numOfSides: $numOfSides, sideSize: $sideSize, tocSize: $tocSize"); + trace(2, " $this_func: metadata: imageSize = $imageSize, blockSize=$blockSize, arrangement = $arrangement, numOfSides: $numOfSides, sideSize: $sideSize, tocSize: $tocSize"); #determine the TOC offsets from the arrangement and side Information #stored in the layout xml @@ -113,7 +114,7 @@ sub loadPnorLayout $$i_pnorLayoutRef{metadata}{sides}{$sideId}{golden} = $golden; $count = $count + 1; - trace(1, "A-B-D: side:$sideId primaryTOC:$primaryTOC, backupTOC:$backupTOC, golden: $golden"); + trace(2, "A-B-D: side:$sideId primaryTOC:$primaryTOC, backupTOC:$backupTOC, golden: $golden"); } } elsif ($arrangement eq "A-D-B") @@ -132,7 +133,7 @@ sub loadPnorLayout $$i_pnorLayoutRef{metadata}{sides}{$sideId}{toc}{backup} = $backupTOC; $$i_pnorLayoutRef{metadata}{sides}{$sideId}{golden} = $golden; $count = $count + 1; - trace(1, "A-D-B: side:$sideId, primaryTOC:$primaryTOC, backupTOC:$backupTOC, golden: $golden"); + trace(2, "A-D-B: side:$sideId, primaryTOC:$primaryTOC, backupTOC:$backupTOC, golden: $golden"); } } else @@ -507,4 +508,66 @@ sub checkFile } } +############################################################################### +# Display Pnor Layout - Display XML pnor layout more simply +################################################################################ +sub displayPnorLayout +{ + my ($i_pnorLayoutRef, $i_gaps, $i_verbose) = @_; + + if (!$i_verbose) + { + print "-------------------------------------------------------- \n"; + print "Name-physicalOffset-physicalRegionSize-physicalRegionEnd \n"; + print "-------------------------------------------------------- \n"; + } + + my $curOffset = 0; + my $totalFree = 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)); + + # Check if there is a gap between sections + if ($i_gaps && ($curOffset < hex($offset))) + { + print " > Gap Found: addr = ".sprintf("0x%X",$curOffset); + + # Display address and size of gap + my $gapSize = hex($offset)-$curOffset; + print " size = ".sprintf("0x%X",$gapSize)."\n"; + $totalFree += $gapSize; + $curOffset = hex($offset) + hex($size); + } + else + { + $curOffset += hex($size); + } + + # Print sections + if ($i_verbose) + { + print $$i_pnorLayoutRef{sections}{$section}{eyeCatch}."\n"; + print Dumper $$i_pnorLayoutRef{sections}{$section}; + print "\n"; + } + else + { + print $$i_pnorLayoutRef{sections}{$section}{eyeCatch}."-$offset-$size-$end\n"; + } + } + + # 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"; + print " (".$hexVal.")\n"; + } +} 1; |