From ac53c27a467b524a906ee4a92ff6a79759f77977 Mon Sep 17 00:00:00 2001 From: Sampa Misra Date: Mon, 8 Oct 2018 03:54:37 -0500 Subject: all scripts for hdat pnor partition Change-Id: Ied9c154d544d65eebfe5cfb0185ccb26545ee130 Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/67144 Tested-by: Jenkins Server Tested-by: Jenkins OP Build CI Tested-by: Jenkins OP HW Tested-by: FSP CI Jenkins Reviewed-by: Jayashankar Padath Reviewed-by: Daniel M. Crowell --- src/usr/hdat/genHdatBin.pl | 166 +++++++++++++++++++++++++++++++++++ src/usr/hdat/hdatBinLayout.xml | 193 +++++++++++++++++++++++++++++++++++++++++ src/usr/hdat/makefile | 3 +- 3 files changed, 360 insertions(+), 2 deletions(-) create mode 100644 src/usr/hdat/genHdatBin.pl create mode 100644 src/usr/hdat/hdatBinLayout.xml (limited to 'src/usr/hdat') diff --git a/src/usr/hdat/genHdatBin.pl b/src/usr/hdat/genHdatBin.pl new file mode 100644 index 000000000..e598486a8 --- /dev/null +++ b/src/usr/hdat/genHdatBin.pl @@ -0,0 +1,166 @@ +#!/usr/bin/perl +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: src/usr/hdat/genHdatBin.pl $ +# +# OpenPOWER HostBoot Project +# +# Contributors Listed Below - COPYRIGHT 2017,2018 +# [+] International Business Machines Corp. +# +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. +# +# IBM_PROLOG_END_TAG + +use strict; +use warnings; +use XML::LibXML; +use feature 'say'; +use Class::Struct; +use File::stat; +use File::Copy; + +my $cfgBigEndian = 1; + +################################################################################ +# Pack 2 byte value into a buffer using configured endianness +################################################################################ + +sub pack4byte { + my($value) = @_; + + my $binaryData; + if($cfgBigEndian) + { + $binaryData = pack("N",$value); + } + else # Little endian + { + $binaryData = pack("V",$value); + } + + return $binaryData; +} + +my $layoutFile = 'hdatBinLayout.xml'; +my $dom = XML::LibXML->load_xml(location => $layoutFile); + +# verify if collective bins size if less than max size + +validateMaxSize($dom); +my %toc = createToc($dom); +my $chkSum = createChecksum($dom); +my $ver = '104q'; +my $hdatBin = "hdat.bin"; +open ( my $hdatBinfh , '>', $hdatBin) + or die "Can't open > $hdatBin: $!"; +binmode($hdatBinfh); +print $hdatBinfh $ver; +print $hdatBinfh $chkSum; +foreach my $my_key ( sort keys %toc ) +{ + print $hdatBinfh $my_key; + print $hdatBinfh $toc{$my_key}; +} +seek($hdatBinfh,0x1014,0); + +my $tmpFile = "./tempFile"; +open my $totbinfh , '<', $tmpFile; +binmode($totbinfh); +local $/; +my $buffer = <$totbinfh>; +print $hdatBinfh $buffer; +close $totbinfh; +close $hdatBinfh; + +sub validateMaxSize +{ + my $dom = shift; + my $totSize = 0; + my $headerSize = 0x1014; #tocsize + checksum size + version size + foreach my $binFile ( $dom->findnodes('/hdat/section')) + { + if (-e $binFile->findvalue('./fileName')) + { + say $binFile->findvalue('./fileName'); + $totSize += (stat($binFile->findvalue('./fileName')))->size; + } + else + { + say $binFile->findvalue('./fileName'), "doesnt exist"; + } + } + my $maxsize = hex($dom->findvalue('/hdat/metadata/maxSize')); + say $maxsize; + if($maxsize < ($totSize + $headerSize)) + { + #say $dom->findvalue('/hdat/metaData/maxSize'); + #say ($totSize + $headerSize); + die " collective size of binaries is more than max size , $totSize"; + } + +} + +sub createToc +{ + my $dom = shift; + my %toc = (); + my $offset = 0x1014; + foreach my $binFile ( $dom->findnodes('/hdat/section')){ + if (-e $binFile->findvalue('./fileName')) + { + $toc{pack4byte($offset)} = pack4byte((stat($binFile->findvalue('./fileName')))->size); + $offset += ((stat($binFile->findvalue('./fileName')))->size); + } + else + { + $toc{pack4byte($offset)} = pack4byte(0); + $offset += 4; #its a hash, so bump up by 4 bytes for uniqueness + } + } + return %toc; +} + + + +sub createChecksum +{ + my $dom = shift; + my $tmpFile = "./tempFile"; + open my $totbinfh , '>', $tmpFile; + binmode($totbinfh); + foreach my $section ( $dom->findnodes('/hdat/section')){ + if (-e $section->findvalue('./fileName')) + { + local $/; + open my $sectBinfh, '<', $section->findvalue('./fileName'); + binmode($sectBinfh); + my $data = <$sectBinfh>; + print $totbinfh $data; + close $sectBinfh; + say $section->findvalue('./fileName'); + } + else + { + print $totbinfh pack4byte(0); # if the file doesn't exist,fill 4 byte 0's. + say $section->findvalue('./fileName'), "is empty"; + } + } + my @md5= split / /, `md5sum ./tempFile`; + close $tmpFile; + say 'checksum is'.$md5[0]; + return $md5[0]; +} + diff --git a/src/usr/hdat/hdatBinLayout.xml b/src/usr/hdat/hdatBinLayout.xml new file mode 100644 index 000000000..16431fefe --- /dev/null +++ b/src/usr/hdat/hdatBinLayout.xml @@ -0,0 +1,193 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0x4000 + 10.5d + 0x1000 + + +
+ Slot Map Table Area binary data + SLOTMAP_TABLE + proc0 + slotmapproc0 +
+
+ Slot Map Table Area binary data + SLOTMAP_TABLE + proc1 + slotmapproc1 +
+
+ Slot Map Table Area binary data + SLOTMAP_TABLE + proc2 + slotmapproc2 +
+
+ Slot Map Table Area binary data + SLOTMAP_TABLE + proc3 + slotmapproc3 +
+
+ Slot Map Entry details binary data + SLOTMAP_ENTRY + proc0 + slotdetailsproc0 +
+
+ Slot Map Entry details binary data + SLOTMAP_ENTRY + proc1 + slotdetailsproc1 +
+
+ Slot Map Entry details binary data + SLOTMAP_ENTRY + proc2 + slotdetailsproc2 +
+
+ Slot Map Entry details binary data + SLOTMAP_ENTRY + proc3 + slotdetailsproc3 +
+
+ SMP Link proc 0 6gpu binary data + SMPLINK_INFO_6GPU + proc0 + smplinkproc0_oc1 +
+
+ SMP Link proc 1 6gpu binary data + SMPLINK_INFO_6GPU + proc1 + smplinkproc1_oc1 +
+
+ SMP Link proc 2 6gpu binary data + SMPLINK_INFO_6GPU + proc2 + smplinkproc2_oc1 +
+
+ SMP Link proc 3 6gpu binary data + SMPLINK_INFO_6GPU + proc3 + smplinkproc3_oc1 +
+
+ SMP Link proc 0 4gpu binary data + SMPLINK_INFO_4GPU + proc0 + smplinkproc0_oc2 +
+
+ SMP Link proc 1 4gpu binary data + SMPLINK_INFO_4GPU + proc1 + smplinkproc1_oc2 +
+
+ SMP Link proc 2 4gpu binary data + SMPLINK_INFO_4GPU + proc2 + smplinkproc2_oc2 +
+
+ SMP Link proc 3 4gpu binary data + SMPLINK_INFO_4GPU + proc3 + smplinkproc3_oc2 +
+
+ I2c Map info binary data + I2CMAP_INFO + proc0 + i2cmapproc0 +
+
+ I2c Map info binary data + I2CMAP_INFO + proc1 + i2cmapproc1 +
+
+ I2c Map info binary data + I2CMAP_INFO + proc2 + i2cmapproc2 +
+
+ I2c Map info binary data + I2CMAP_INFO + proc3 + i2cmapproc3 +
+
+ SMP Link proc 0 data + SMPLINK_INFO + proc0 + smplinkproc0 +
+
+ SMP Link proc 1 data + SMPLINK_INFO + proc1 + smplinkproc1 +
+
+ SMP Link proc 2 data + SMPLINK_INFO + proc2 + smplinkproc2 +
+
+ SMP Link proc 3 data + SMPLINK_INFO + proc3 + smplinkproc3 +
+
+ diff --git a/src/usr/hdat/makefile b/src/usr/hdat/makefile index 9e9de6c74..b4add1b8e 100644 --- a/src/usr/hdat/makefile +++ b/src/usr/hdat/makefile @@ -5,7 +5,7 @@ # # OpenPOWER HostBoot Project # -# Contributors Listed Below - COPYRIGHT 2015,2017 +# Contributors Listed Below - COPYRIGHT 2015,2018 # [+] International Business Machines Corp. # # @@ -27,7 +27,6 @@ ROOTPATH = ../../.. MODULE = hdat EXTRAINCDIR += ../vpd -EXTRAINCDIR += ../../include/usr/vpd EXTRAINCDIR += ${ROOTPATH}/src/import/chips/p9/common/include OBJS += hdatutil.o -- cgit v1.2.1