diff options
Diffstat (limited to 'src/build/buildpnor')
-rw-r--r-- | src/build/buildpnor/PnorUtils.pm | 151 | ||||
-rwxr-xr-x | src/build/buildpnor/buildpnor.pl | 388 | ||||
-rw-r--r-- | src/build/buildpnor/defaultPnorLayout.xml | 10 | ||||
-rwxr-xr-x | src/build/buildpnor/genPnorImages.pl | 48 | ||||
-rw-r--r-- | src/build/buildpnor/pnorLayoutFSP.xml | 10 | ||||
-rw-r--r-- | src/build/buildpnor/pnorLayoutFake.xml | 2 |
6 files changed, 130 insertions, 479 deletions
diff --git a/src/build/buildpnor/PnorUtils.pm b/src/build/buildpnor/PnorUtils.pm index 4c167d5c0..dcb524167 100644 --- a/src/build/buildpnor/PnorUtils.pm +++ b/src/build/buildpnor/PnorUtils.pm @@ -64,83 +64,24 @@ sub loadPnorLayout #parse the input XML file my $xs = new XML::Simple(keyattr=>[], forcearray => 1); my $xml = $xs->XMLin($i_pnorFile); + my $imageSize = 0; + my $chipSize = 0; - #Iterate over the <section> elements. - foreach my $sectionEl (@{$xml->{section}}) - { - my $description = $sectionEl->{description}[0]; - my $eyeCatch = $sectionEl->{eyeCatch}[0]; - my $physicalOffset = $sectionEl->{physicalOffset}[0]; - my $physicalRegionSize = $sectionEl->{physicalRegionSize}[0]; - my $side = $sectionEl->{side}[0]; - my $testonly = $sectionEl->{testonly}[0]; - my $ecc = (exists $sectionEl->{ecc} ? "yes" : "no"); - my $sha512Version = (exists $sectionEl->{sha512Version} ? "yes" : "no"); - my $sha512perEC = (exists $sectionEl->{sha512perEC} ? "yes" : "no"); - my $preserved = (exists $sectionEl->{preserved} ? "yes" : "no"); - my $reprovision = (exists $sectionEl->{reprovision} ? "yes" : "no"); - my $readOnly = (exists $sectionEl->{readOnly} ? "yes" : "no"); - my $xz = ""; - my $xzSize = 0; - if((exists $sectionEl->{compressed}) && - ($sectionEl->{compressed}[0]->{algorithm}[0] eq "xz")) - { - $xz = "xz"; - $xzSize = $sectionEl->{compressed}[0]->{uncompressedSize}[0]; - } - if (($i_testRun == 0) && ($sectionEl->{testonly}[0] eq "yes")) - { - next; - } - - trace(3, "$this_func: description = $description, eyeCatch=$eyeCatch, physicalOffset = $physicalOffset, physicalRegionSize=$physicalRegionSize, side=$side"); - - $physicalOffset = getNumber($physicalOffset); - $physicalRegionSize = getNumber($physicalRegionSize); - - $$i_pnorLayoutRef{sections}{$physicalOffset}{description} = $description; - $$i_pnorLayoutRef{sections}{$physicalOffset}{eyeCatch} = $eyeCatch; - $$i_pnorLayoutRef{sections}{$physicalOffset}{physicalOffset} = $physicalOffset; - $$i_pnorLayoutRef{sections}{$physicalOffset}{physicalRegionSize} = $physicalRegionSize; - $$i_pnorLayoutRef{sections}{$physicalOffset}{side} = $side; - $$i_pnorLayoutRef{sections}{$physicalOffset}{ecc} = $ecc; - $$i_pnorLayoutRef{sections}{$physicalOffset}{sha512Version} = $sha512Version; - $$i_pnorLayoutRef{sections}{$physicalOffset}{sha512perEC} = $sha512perEC; - $$i_pnorLayoutRef{sections}{$physicalOffset}{preserved} = $preserved; - $$i_pnorLayoutRef{sections}{$physicalOffset}{reprovision} = $reprovision; - $$i_pnorLayoutRef{sections}{$physicalOffset}{readOnly} = $readOnly; - $$i_pnorLayoutRef{sections}{$physicalOffset}{compressed}{algorithm} = $xz; - $$i_pnorLayoutRef{sections}{$physicalOffset}{compressed}{uncompressedSize} = $xzSize; - - #store the physical offsets of each section in a hash, so, it is easy - #to search physicalOffsets based on the name of the section (eyecatch) - if ($side eq "sideless") - { - foreach my $metadata (@{$xml->{metadata}}) - { - foreach my $sides (@{$metadata->{side}}) - { - $$i_physicalOffsets{side}{$sides->{id}[0]}{eyecatch}{$eyeCatch} = $physicalOffset; - } - } - } - else - { - $$i_physicalOffsets{side}{$side}{eyecatch}{$eyeCatch} = $physicalOffset; - } - } # Save the metadata - imageSize, blockSize, toc Information etc. foreach my $metadataEl (@{$xml->{metadata}}) { # Get meta data - my $imageSize = $metadataEl->{imageSize}[0]; + $imageSize = $metadataEl->{imageSize}[0]; + $chipSize = $metadataEl->{chipSize}[0]; my $blockSize = $metadataEl->{blockSize}[0]; my $tocSize = $metadataEl->{tocSize}[0]; my $arrangement = $metadataEl->{arrangement}[0]; $imageSize = getNumber($imageSize); + $chipSize = getNumber($chipSize); $blockSize = getNumber($blockSize); $tocSize = getNumber($tocSize); $$i_pnorLayoutRef{metadata}{imageSize} = $imageSize; + $$i_pnorLayoutRef{metadata}{chipSize} = $chipSize; $$i_pnorLayoutRef{metadata}{blockSize} = $blockSize; $$i_pnorLayoutRef{metadata}{tocSize} = $tocSize; $$i_pnorLayoutRef{metadata}{arrangement} = $arrangement; @@ -155,7 +96,8 @@ sub loadPnorLayout # #Arrangement A-B-D means that the layout had Primary TOC (A), then backup TOC (B), then Data (pnor section information). #Similaryly, arrangement A-D-B means that primary toc is followed by the data (section information) and then - #the backup TOC. + #the backup TOC. In order for the parsing tools to find the TOC, the TOCs must be at TOP_OF_FLASH-(2) * TOC_SIZE + # and the other at 0x0 of flash memory. if ($arrangement eq "A-B-D") { my $count = 0; @@ -176,18 +118,21 @@ sub loadPnorLayout } elsif ($arrangement eq "A-D-B") { + my $count = 0; foreach my $side (@{$metadataEl->{side}}) { my $golden = (exists $side->{golden} ? "yes" : "no"); my $sideId = $side->{id}[0]; - my $hbbAddr = $$i_physicalOffsets{side}{$sideId}{eyecatch}{"HBB"}; - my $primaryTOC = align_down($hbbAddr, $sideSize); - my $backupTOC = align_up($hbbAddr, $sideSize) - $tocSize; + #Leave 1 block sized pad because the top addr of flash special + # and simics broke we had the toc touching it + my $primaryTOC = ($sideSize)*($count + 1) - ($tocSize + $blockSize) ; + my $backupTOC = ($sideSize)*($count); $$i_pnorLayoutRef{metadata}{sides}{$sideId}{toc}{primary} = $primaryTOC; $$i_pnorLayoutRef{metadata}{sides}{$sideId}{toc}{backup} = $backupTOC; $$i_pnorLayoutRef{metadata}{sides}{$sideId}{golden} = $golden; - trace(1, "A-D-B: side:$sideId HBB:$hbbAddr, primaryTOC:$primaryTOC, backupTOC:$backupTOC, golden: $golden"); + $count = $count + 1; + trace(1, "A-D-B: side:$sideId, primaryTOC:$primaryTOC, backupTOC:$backupTOC, golden: $golden"); } } else @@ -195,6 +140,64 @@ sub loadPnorLayout trace(0, "Arrangement:$arrangement is not supported"); exit(1); } + + #Iterate over the <section> elements. + foreach my $sectionEl (@{$xml->{section}}) + { + my $description = $sectionEl->{description}[0]; + my $eyeCatch = $sectionEl->{eyeCatch}[0]; + my $physicalOffset = $sectionEl->{physicalOffset}[0]; + my $physicalRegionSize = $sectionEl->{physicalRegionSize}[0]; + my $side = $sectionEl->{side}[0]; + my $testonly = $sectionEl->{testonly}[0]; + my $ecc = (exists $sectionEl->{ecc} ? "yes" : "no"); + my $sha512Version = (exists $sectionEl->{sha512Version} ? "yes" : "no"); + my $sha512perEC = (exists $sectionEl->{sha512perEC} ? "yes" : "no"); + my $preserved = (exists $sectionEl->{preserved} ? "yes" : "no"); + my $readOnly = (exists $sectionEl->{readOnly} ? "yes" : "no"); + if (($i_testRun == 0) && ($sectionEl->{testonly}[0] eq "yes")) + { + next; + } + + trace(3, "$this_func: description = $description, eyeCatch=$eyeCatch, physicalOffset = $physicalOffset, physicalRegionSize=$physicalRegionSize, side=$side"); + + $physicalOffset = getNumber($physicalOffset); + $physicalRegionSize = getNumber($physicalRegionSize); + + if($physicalRegionSize + $physicalOffset > $imageSize) + { + die "ERROR: $this_func: Image size ($imageSize) smaller than $eyeCatch's offset + $eyeCatch's size (".($physicalOffset + $physicalRegionSize)."). Aborting! "; + } + + $$i_pnorLayoutRef{sections}{$physicalOffset}{description} = $description; + $$i_pnorLayoutRef{sections}{$physicalOffset}{eyeCatch} = $eyeCatch; + $$i_pnorLayoutRef{sections}{$physicalOffset}{physicalOffset} = $physicalOffset; + $$i_pnorLayoutRef{sections}{$physicalOffset}{physicalRegionSize} = $physicalRegionSize; + $$i_pnorLayoutRef{sections}{$physicalOffset}{side} = $side; + $$i_pnorLayoutRef{sections}{$physicalOffset}{ecc} = $ecc; + $$i_pnorLayoutRef{sections}{$physicalOffset}{sha512Version} = $sha512Version; + $$i_pnorLayoutRef{sections}{$physicalOffset}{sha512perEC} = $sha512perEC; + $$i_pnorLayoutRef{sections}{$physicalOffset}{preserved} = $preserved; + $$i_pnorLayoutRef{sections}{$physicalOffset}{readOnly} = $readOnly; + + #store the physical offsets of each section in a hash, so, it is easy + #to search physicalOffsets based on the name of the section (eyecatch) + if ($side eq "sideless") + { + foreach my $metadata (@{$xml->{metadata}}) + { + foreach my $sides (@{$metadata->{side}}) + { + $$i_physicalOffsets{side}{$sides->{id}[0]}{eyecatch}{$eyeCatch} = $physicalOffset; + } + } + } + else + { + $$i_physicalOffsets{side}{$side}{eyecatch}{$eyeCatch} = $physicalOffset; + } + } } return 0; } @@ -225,11 +228,11 @@ sub getNumber my $inVal = shift; if($inVal =~ "0x") { - return oct($inVal); + return oct($inVal); } else { - return $inVal; + return $inVal; } } @@ -255,11 +258,11 @@ sub trace #traceLevel 0 is for errors if($i_traceLevel == 0) { - print "ERROR: ".$i_string."\n"; + print "ERROR: ".$i_string."\n"; } elsif ($g_trace >= $i_traceLevel) { - print "TRACE: ".$i_string."\n"; + print "TRACE: ".$i_string."\n"; } } diff --git a/src/build/buildpnor/buildpnor.pl b/src/build/buildpnor/buildpnor.pl index a3693396c..138f86533 100755 --- a/src/build/buildpnor/buildpnor.pl +++ b/src/build/buildpnor/buildpnor.pl @@ -30,39 +30,19 @@ # number fields must be 4 or 8 bytes # numbers cannot be over 32 bits - use strict; -use XML::Simple; use Data::Dumper; use File::Basename; - -# Digest::SHA1 module is now Digest::SHA in newer version of perl. Need to -# do the below eval blocks to support both modules. -BEGIN -{ - eval "use Digest::SHA;"; - if ($@) - { - eval "use Digest::SHA1;"; - die $@ if $@; - } -} - -################################################################################ -# Set PREFERRED_PARSER to XML::Parser. Otherwise it uses XML::SAX which contains -# bugs that result in XML parse errors that can be fixed by adjusting white- -# space (i.e. parse errors that do not make sense). -################################################################################ -$XML::Simple::PREFERRED_PARSER = 'XML::Parser'; - -my $TRAC_ERR = 0; -# 0=errors, >0 for more traces, leaving at 1 to keep key milestone traces. -my $g_trace = 1; +use Cwd qw(abs_path); +use lib dirname abs_path($0); +use PnorUtils qw(loadPnorLayout getNumber traceErr trace run_command + findLayoutKeyByEyeCatch checkSpaceConstraints); my $programName = File::Basename::basename $0; my %pnorLayout; my %PhysicalOffsets; my %binFiles; +my %finalBinFiles=(); my $pnorLayoutFile; my $pnorBinName = ""; my $tocVersion = 0x1; @@ -76,7 +56,6 @@ my %SideOptions = ( B => "B", sideless => "sideless", ); -use constant PAGE_SIZE => 4096; if ($#ARGV < 0) { usage(); @@ -133,16 +112,13 @@ if (-e $pnorBinName) } #Load PNOR Layout XML file -loadPnorLayout($pnorLayoutFile, \%pnorLayout, \%PhysicalOffsets); +loadPnorLayout($pnorLayoutFile, \%pnorLayout, \%PhysicalOffsets, $testRun); #Verify all the section files exist verifyFilesExist(\%pnorLayout, \%binFiles); -#Perform any data integrity manipulation (ECC, shaw-hash, etc) -robustifyImgs(\%pnorLayout, \%binFiles); - -checkSpaceConstraints(\%pnorLayout, \%binFiles); -trace(1, "Done checkSpaceConstraints"); +# Make sure provided files will fit in their sections +checkSpaceConstraints(\%pnorLayout, \%binFiles, $testRun); # Create all Partition Tables at each TOC offset # Each side has 2 TOC's created at different offsets for backup purposes. @@ -176,8 +152,7 @@ foreach my $sideId ( keys %{$pnorLayout{metadata}{sides}} ) { my $tocOffset = $pnorLayout{metadata}{sides}{$sideId}{toc}{primary}; - fillPnorImage($pnorBinName, \%pnorLayout, \%binFiles, $sideId, - $tocOffset); + fillPnorImage($pnorBinName, \%pnorLayout, \%binFiles, $sideId, $tocOffset); } exit 0; @@ -185,162 +160,6 @@ exit 0; ######################### Begin Utility Subroutines ########################### ################################################################################ -# loadPnorLayout -################################################################################ -sub loadPnorLayout -{ - my ($i_pnorFile, $i_pnorLayoutRef, $i_physicalOffsets) = @_; - my $this_func = (caller(0))[3]; - - unless(-e $i_pnorFile) - { - traceErr("$this_func: File not found: $i_pnorFile"); - return -1; - } - - #parse the input XML file - my $xs = new XML::Simple(keyattr=>[], forcearray => 1); - my $xml = $xs->XMLin($i_pnorFile); - my $imageSize = 0; - my $chipSize = 0; - # Save the metadata - imageSize, blockSize, toc Information etc. - foreach my $metadataEl (@{$xml->{metadata}}) - { - # Get meta data - $imageSize = $metadataEl->{imageSize}[0]; - $chipSize = $metadataEl->{chipSize}[0]; - my $blockSize = $metadataEl->{blockSize}[0]; - my $tocSize = $metadataEl->{tocSize}[0]; - my $arrangement = $metadataEl->{arrangement}[0]; - $chipSize = getNumber($chipSize); - $imageSize = getNumber($imageSize); - $blockSize = getNumber($blockSize); - $tocSize = getNumber($tocSize); - $$i_pnorLayoutRef{metadata}{chipSize} = $chipSize; - $$i_pnorLayoutRef{metadata}{imageSize} = $imageSize; - $$i_pnorLayoutRef{metadata}{blockSize} = $blockSize; - $$i_pnorLayoutRef{metadata}{tocSize} = $tocSize; - $$i_pnorLayoutRef{metadata}{arrangement} = $arrangement; - - 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"); - - #determine the TOC offsets from the arrangement and side Information - #stored in the layout xml - # - #Arrangement A-B-D means that the layout had Primary TOC (A), then backup TOC (B), then Data (pnor section information). - #Similaryly, arrangement A-D-B means that primary toc is followed by the data (section information) and then - #the backup TOC. In order for the parsing tools to find the TOC, the TOCs must be at TOP_OF_FLASH-(2) * TOC_SIZE - # and the other at 0x0 of flash memory. - if ($arrangement eq "A-B-D") - { - my $count = 0; - foreach my $side (@{$metadataEl->{side}}) - { - my $golden = (exists $side->{golden} ? "yes" : "no"); - my $sideId = $side->{id}[0]; - my $primaryTOC = ($sideSize)*($count); - my $backupTOC = ($primaryTOC)+($tocSize); - - $$i_pnorLayoutRef{metadata}{sides}{$sideId}{toc}{primary} = $primaryTOC; - $$i_pnorLayoutRef{metadata}{sides}{$sideId}{toc}{backup} = $backupTOC; - $$i_pnorLayoutRef{metadata}{sides}{$sideId}{golden} = $golden; - - $count = $count + 1; - trace(1, "A-B-D: side:$sideId primaryTOC:$primaryTOC, backupTOC:$backupTOC, golden: $golden"); - } - } - elsif ($arrangement eq "A-D-B") - { - my $count = 0; - foreach my $side (@{$metadataEl->{side}}) - { - my $golden = (exists $side->{golden} ? "yes" : "no"); - my $sideId = $side->{id}[0]; - - #Leave 1 block sized pad because the top addr of flash special - # and simics broke we had the toc touching it - my $primaryTOC = ($sideSize)*($count + 1) - ($tocSize + $blockSize) ; - my $backupTOC = ($sideSize)*($count); - - $$i_pnorLayoutRef{metadata}{sides}{$sideId}{toc}{primary} = $primaryTOC; - $$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"); - } - } - else - { - trace(0, "Arrangement:$arrangement is not supported"); - exit(1); - } - - #Iterate over the <section> elements. - foreach my $sectionEl (@{$xml->{section}}) - { - my $description = $sectionEl->{description}[0]; - my $eyeCatch = $sectionEl->{eyeCatch}[0]; - my $physicalOffset = $sectionEl->{physicalOffset}[0]; - my $physicalRegionSize = $sectionEl->{physicalRegionSize}[0]; - my $side = $sectionEl->{side}[0]; - my $testonly = $sectionEl->{testonly}[0]; - my $ecc = (exists $sectionEl->{ecc} ? "yes" : "no"); - my $sha512Version = (exists $sectionEl->{sha512Version} ? "yes" : "no"); - my $sha512perEC = (exists $sectionEl->{sha512perEC} ? "yes" : "no"); - my $preserved = (exists $sectionEl->{preserved} ? "yes" : "no"); - my $readOnly = (exists $sectionEl->{readOnly} ? "yes" : "no"); - if (($testRun == 0) && ($sectionEl->{testonly}[0] eq "yes")) - { - next; - } - - trace(3, "$this_func: description = $description, eyeCatch=$eyeCatch, physicalOffset = $physicalOffset, physicalRegionSize=$physicalRegionSize, side=$side"); - - $physicalOffset = getNumber($physicalOffset); - $physicalRegionSize = getNumber($physicalRegionSize); - - if($physicalRegionSize + $physicalOffset > $imageSize) - { - die "ERROR: $this_func: Image size ($imageSize) smaller than $eyeCatch's offset + $eyeCatch's size (".($physicalOffset + $physicalRegionSize)."). Aborting! "; - } - - $$i_pnorLayoutRef{sections}{$physicalOffset}{description} = $description; - $$i_pnorLayoutRef{sections}{$physicalOffset}{eyeCatch} = $eyeCatch; - $$i_pnorLayoutRef{sections}{$physicalOffset}{physicalOffset} = $physicalOffset; - $$i_pnorLayoutRef{sections}{$physicalOffset}{physicalRegionSize} = $physicalRegionSize; - $$i_pnorLayoutRef{sections}{$physicalOffset}{side} = $side; - $$i_pnorLayoutRef{sections}{$physicalOffset}{ecc} = $ecc; - $$i_pnorLayoutRef{sections}{$physicalOffset}{sha512Version} = $sha512Version; - $$i_pnorLayoutRef{sections}{$physicalOffset}{sha512perEC} = $sha512perEC; - $$i_pnorLayoutRef{sections}{$physicalOffset}{preserved} = $preserved; - $$i_pnorLayoutRef{sections}{$physicalOffset}{readOnly} = $readOnly; - - #store the physical offsets of each section in a hash, so, it is easy - #to search physicalOffsets based on the name of the section (eyecatch) - if ($side eq "sideless") - { - foreach my $metadata (@{$xml->{metadata}}) - { - foreach my $sides (@{$metadata->{side}}) - { - $$i_physicalOffsets{side}{$sides->{id}[0]}{eyecatch}{$eyeCatch} = $physicalOffset; - } - } - } - else - { - $$i_physicalOffsets{side}{$side}{eyecatch}{$eyeCatch} = $physicalOffset; - } - } - - } - return 0; -} - -################################################################################ # createPnorImg - Create PNOR image based on input data. ################################################################################ sub createPnorImg @@ -416,6 +235,10 @@ sub addUserData { $miscFlags |= 0x40; } + if( ($i_sectionHash{$i_key}{reprovision} eq "yes") ) + { + $miscFlags |= 0x10; + } #First User Data Word #[1:chip][1:compressType][2:dataInteg] @@ -428,6 +251,7 @@ sub addUserData my $userflags1 = ($verCheck << 24) | ($miscFlags << 16); + trace(2, "$g_fpartCmd --target $i_pnorBinName --partition-offset $i_offset --user 0 --name $eyeCatch --value userflags0=$userflags0"); system("$g_fpartCmd --target $i_pnorBinName --partition-offset $i_offset --user 0 --name $eyeCatch --value $userflags0"); die "ERROR: $this_func: Call to add userdata to $eyeCatch failed. Aborting!" if($?); @@ -435,6 +259,7 @@ sub addUserData trace(2, "$g_fpartCmd --target $i_pnorBinName --partition-offset $i_offset --user 1 --name $eyeCatch --value userflags1=$userflags1"); system("$g_fpartCmd --target $i_pnorBinName --partition-offset $i_offset --user 1 --name $eyeCatch --value $userflags1"); die "ERROR: $this_func: Call to add userdata to $eyeCatch failed. Aborting!" if($?); + } ################################################################################ @@ -580,59 +405,6 @@ sub addTOCInfo $sideShift = $sideShift + $numOfTOCs; } } -################################################################################ -# robustifyImgs - Perform any ECC or ShawHash manipulations -################################################################################ -sub robustifyImgs -{ - my ($i_pnorLayoutRef, $i_binFiles) = @_; - my $this_func = (caller(0))[3]; - - #@TODO: ECC Correction - #@TODO: maybe a little SHA hashing? - - return 0; -} - -################################################################################ -# align_down: Align the input to the lower end of the PNOR side -################################################################################ -sub align_down -{ - my ($addr,$n) = @_; - return (($addr) - ($addr)%($n)); -} - -################################################################################ -# align_up: Align the input address to the higher end of the PNOR side -################################################################################ -sub align_up -{ - my ($addr,$n) = @_; - return ((($addr) + ($n-1)) & ~($n-1)); -} - -################################################################################ -# findLayoutKeyByEyeCatch - Figure out hash key based on eyeCatcher -################################################################################ -sub findLayoutKeyByEyeCatch -{ - my $layoutKey = -1; - my($eyeCatch, $i_pnorLayoutRef) = @_; - my $key; - - my %sectionHash = %{$$i_pnorLayoutRef{sections}}; - for $key ( keys %sectionHash) - { - if($sectionHash{$key}{eyeCatch} eq $eyeCatch) - { - $layoutKey = $key; - last; - } - } - - return $layoutKey; -} ################################################################################ # verifyFilesExist - Verify all the input files exist @@ -659,89 +431,6 @@ sub verifyFilesExist my %sectionHash = %{$$i_pnorLayoutRef{sections}}; } -################################################################################ -# checkSpaceConstraints - Make sure provided files will fit in their sections -################################################################################ -sub checkSpaceConstraints -{ - my ($i_pnorLayoutRef, $i_binFiles) = @_; - my $this_func = (caller(0))[3]; - my $key; - - my %sectionHash = %{$$i_pnorLayoutRef{sections}}; - - for $key ( keys %{$i_binFiles}) - { - my $filesize = -s $$i_binFiles{$key}; - - my $layoutKey = findLayoutKeyByEyeCatch($key, \%$i_pnorLayoutRef); - if( $layoutKey == -1) - { - die "ERROR: $this_func: entry not found in PNOR layout for file $$i_binFiles{$key}, under eyecatcher $key" if($?); - } - - my $eyeCatch = $sectionHash{$layoutKey}{eyeCatch}; - my $physicalRegionSize = $sectionHash{$layoutKey}{physicalRegionSize}; - - if($filesize > $physicalRegionSize) - { - # If this is a test run increase HBI size by PAGE_SIZE until all test - # cases fit - if ($testRun && $eyeCatch eq "HBI") - { - print "Adjusting HBI size - ran out of space for test cases\n"; - my $hbbKey = findLayoutKeyByEyeCatch("HBB", \%$i_pnorLayoutRef); - adjustHbiPhysSize(\%sectionHash, $layoutKey, $filesize, $hbbKey); - } - else - { - die "ERROR: $this_func: Image provided ($$i_binFiles{$eyeCatch}) has size ($filesize) which is greater than allocated space ($physicalRegionSize) for section=$eyeCatch. Aborting!"; - } - } - } -} - -############################################################################### -# adjustHbiPhysSize - Adjust HBI physical size when running test cases and fix -# up physical offsets of partitions between HBI and HBB -################################################################################ -sub adjustHbiPhysSize -{ - my ($i_sectionHashRef, $i_hbiKey, $i_filesize, $i_hbbKey) = @_; - - my %sectionHash = %$i_sectionHashRef; - - # Increment HBI physical size by PAGE_SIZE until the HBI file can fit - my $hbi_old = $sectionHash{$i_hbiKey}{physicalRegionSize}; - while ($i_filesize > $sectionHash{$i_hbiKey}{physicalRegionSize}) - { - $sectionHash{$i_hbiKey}{physicalRegionSize} += PAGE_SIZE; - } - my $hbi_move = $sectionHash{$i_hbiKey}{physicalRegionSize} - $hbi_old; - my $hbi_end = $sectionHash{$i_hbiKey}{physicalRegionSize} + $hbi_move; - - # Fix up physical offset affected by HBI size change - foreach my $section (keys %sectionHash) - { - # Only fix partitions after HBI and before HBB - if ( ( $sectionHash{$section}{physicalOffset} > - $sectionHash{$i_hbiKey}{physicalOffset} ) && - ( $sectionHash{$section}{physicalOffset} < - $sectionHash{$i_hbbKey}{physicalOffset} ) - ) - { - $sectionHash{$section}{physicalOffset} += $hbi_move; - # Ensure section adjustment does not cause an overlap with HBB - if ($sectionHash{$section}{physicalOffset} > - $sectionHash{$i_hbbKey}{physicalOffset}) - { - die "Error detected $sectionHash{$section}{eyeCatch}'s adjusted size overlaps HBB"; - } - } - } -} - - ############################################################################### # fillPnorImage - Load actual PNOR image with data using the provided input images ################################################################################ @@ -828,52 +517,6 @@ sub insertPadBytes } ################################################################################ -# getNumber - handle hex or decimal input string -################################################################################ -sub getNumber -{ - my $inVal = shift; - if($inVal =~ "0x") - { - return oct($inVal); - } - else - { - return $inVal; - } -} - -################################################################################ -# trace -################################################################################ -sub traceErr -{ - my $i_string = shift; - trace($TRAC_ERR, $i_string); -} - -################################################################################ -# trace -################################################################################ -sub trace -{ - my $i_traceLevel; - my $i_string; - - ($i_traceLevel, $i_string) = @_; - - #traceLevel 0 is for errors - if($i_traceLevel == 0) - { - print "ERROR: ".$i_string."\n"; - } - elsif ($g_trace >= $i_traceLevel) - { - print "TRACE: ".$i_string."\n"; - } -} - -################################################################################ # getSideInfo - return side info of certain sections and determine if value is # a supported value ################################################################################ @@ -930,7 +573,6 @@ sub getOtherSide return $other_side; } - ################################################################################ # print usage instructions ################################################################################ diff --git a/src/build/buildpnor/defaultPnorLayout.xml b/src/build/buildpnor/defaultPnorLayout.xml index c6858edba..587fc85a2 100644 --- a/src/build/buildpnor/defaultPnorLayout.xml +++ b/src/build/buildpnor/defaultPnorLayout.xml @@ -148,7 +148,7 @@ Layout Description <side>sideless</side> <ecc/> </section> - <!-- @fixme - Put this back later (RTC:154286) + <!-- #@TODO RTC:163810 - Put this back later if needed <section> <description>Centaur SBE (576K)</description> <eyeCatch>SBEC</eyeCatch> @@ -238,4 +238,12 @@ Layout Description <side>sideless</side> <ecc/> </section> + <section> + <description>SecureBoot Key Transition Partition (16K)</description> + <eyeCatch>SBKT</eyeCatch> + <physicalOffset>0x2ACF000</physicalOffset> + <physicalRegionSize>0x4000</physicalRegionSize> + <side>sideless</side> + <ecc/> + </section> </pnor> diff --git a/src/build/buildpnor/genPnorImages.pl b/src/build/buildpnor/genPnorImages.pl index 2ac721bbe..911e56aaa 100755 --- a/src/build/buildpnor/genPnorImages.pl +++ b/src/build/buildpnor/genPnorImages.pl @@ -471,7 +471,6 @@ sub manipulateImages my $eyeCatch = $sectionHash{$layoutKey}{eyeCatch}; my %tempImages = ( HDR_PHASE => "$bin_dir/$parallelPrefix.$eyeCatch.temp.hdr.bin", - PREFIX_PHASE => "$bin_dir/$parallelPrefix.$eyeCatch.temp.hdr.prefix.bin", TEMP_SHA_IMG => "$bin_dir/$parallelPrefix.$eyeCatch.temp.sha.bin", PAD_PHASE => "$bin_dir/$parallelPrefix.$eyeCatch.temp.pad.bin", ECC_PHASE => "$bin_dir/$parallelPrefix.$eyeCatch.temp.bin.ecc", @@ -495,14 +494,15 @@ sub manipulateImages # Sections that have secureboot support. Secureboot still must be # enabled for secureboot actions on these partitions to occur. - my $isNormalSecure = ($eyeCatch eq "SBE") - || ($eyeCatch eq "SBEC") - || ($eyeCatch eq "PAYLOAD") - || ($eyeCatch eq "SBKT") - || ($eyeCatch eq "OCC") - || ($eyeCatch eq "HBRT") - || ($eyeCatch eq "CAPP") - || ($eyeCatch eq "BOOTKERNEL"); + # @TODO securebootp9 re-enable with SBE/SBEC/PAYLOAD secureboot ports + my $isNormalSecure = ($eyeCatch eq "SBKT") + || ($eyeCatch eq "HBRT"); + #|| ($eyeCatch eq "SBE") + #|| ($eyeCatch eq "SBEC") + #|| ($eyeCatch eq "PAYLOAD") + #|| ($eyeCatch eq "OCC") + #|| ($eyeCatch eq "CAPP") + #|| ($eyeCatch eq "BOOTKERNEL"); my $isSpecialSecure = ($eyeCatch eq "HBB") || ($eyeCatch eq "HBI") @@ -539,7 +539,8 @@ sub manipulateImages if ($secureboot) { $callerHwHdrFields{configure} = 1; - if (exists $hashPageTablePartitions{$eyeCatch}) + # @TODO securebootp9 re-enable hash page table with vfs page table port + if (0) #exists $hashPageTablePartitions{$eyeCatch}) { if ($eyeCatch eq "HBI") { @@ -553,7 +554,8 @@ sub manipulateImages } } # Add hash page table - if ($tempImages{hashPageTable} ne "" && -e $tempImages{hashPageTable}) + # @TODO securebootp9 re-enable hash page table with vfs page table port + if (0) #$tempImages{hashPageTable} ne "" && -e $tempImages{hashPageTable}) { trace(1,"Adding hash page table for $eyeCatch"); my $hashPageTableSize = -s $tempImages{hashPageTable}; @@ -665,9 +667,10 @@ sub manipulateImages run_command("cat $bin_file >> $tempImages{HDR_PHASE}"); } } - elsif($secureboot - && ( ($sectionHash{$layoutKey}{sha512perEC} eq "yes") - || ($isNormalSecure))) + # @TODO securebootp9 re-enable with SBE/SBEC secureboot ports + elsif(0) #$secureboot + #&& ( ($sectionHash{$layoutKey}{sha512perEC} eq "yes") + # || ($isNormalSecure))) { $callerHwHdrFields{configure} = 1; if($openSigningTool) @@ -689,30 +692,17 @@ sub manipulateImages setCallerHwHdrFields(\%callerHwHdrFields, $tempImages{HDR_PHASE}); - # Prefix phase - # Add SBE header to HBB - if($eyeCatch eq "HBB") - { - run_command("echo \"00000000001800000000000008000000000000000007EF80\" | xxd -r -ps - $tempImages{PREFIX_PHASE}"); - run_command("cat $tempImages{HDR_PHASE} >> $tempImages{PREFIX_PHASE}"); - } - # Otherwise propagate image to next phase - else - { - run_command("mv $tempImages{HDR_PHASE} $tempImages{PREFIX_PHASE}"); - } - # Padding Phase if ($eyeCatch eq "HBI" && $testRun) { # If "--test" flag set do not pad as the test HBI images is # possibly larger than partition size and does not need to be # fully padded. Size adjustments made in checkSpaceConstraints - run_command("dd if=$tempImages{PREFIX_PHASE} of=$tempImages{PAD_PHASE} ibs=4k conv=sync"); + run_command("dd if=$tempImages{HDR_PHASE} of=$tempImages{PAD_PHASE} ibs=4k conv=sync"); } else { - run_command("dd if=$tempImages{PREFIX_PHASE} of=$tempImages{PAD_PHASE} ibs=$size conv=sync"); + run_command("dd if=$tempImages{HDR_PHASE} of=$tempImages{PAD_PHASE} ibs=$size conv=sync"); } # Create .header.bin file for FSP diff --git a/src/build/buildpnor/pnorLayoutFSP.xml b/src/build/buildpnor/pnorLayoutFSP.xml index a16ea8645..751e2e917 100644 --- a/src/build/buildpnor/pnorLayoutFSP.xml +++ b/src/build/buildpnor/pnorLayoutFSP.xml @@ -149,7 +149,7 @@ Layout Description <side>sideless</side> <ecc/> </section> - <!-- @fixme - Put this back later (RTC:154286) + <!-- #@TODO RTC:163810 - Put this back later if needed <section> <description>Centaur SBE (576K)</description> <eyeCatch>SBEC</eyeCatch> @@ -202,4 +202,12 @@ Layout Description <side>sideless</side> <ecc/> </section> + <section> + <description>SecureBoot Key Transition Partition (16K)</description> + <eyeCatch>SBKT</eyeCatch> + <physicalOffset>0x1D3D000</physicalOffset> + <physicalRegionSize>0x4000</physicalRegionSize> + <side>sideless</side> + <ecc/> + </section> </pnor> diff --git a/src/build/buildpnor/pnorLayoutFake.xml b/src/build/buildpnor/pnorLayoutFake.xml index 3a2570832..e8a319c11 100644 --- a/src/build/buildpnor/pnorLayoutFake.xml +++ b/src/build/buildpnor/pnorLayoutFake.xml @@ -128,7 +128,7 @@ Layout Description </section> <section> <!-- NOTE: smaller than official layout for fake-PNOR --> - <description>Hostboot Extended image (3MB)</description> + <description>Hostboot Extended image (4.96MB)</description> <eyeCatch>HBI</eyeCatch> <physicalOffset>0x10A000</physicalOffset> <physicalRegionSize>0x4F6000</physicalRegionSize> |