summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Hoffa <wghoffa@us.ibm.com>2014-06-30 22:51:52 -0500
committerPatrick Williams <iawillia@us.ibm.com>2014-07-02 21:57:58 -0500
commita7f9b25eb1e7fac405bc1a54597cfc812a07fb3f (patch)
treebaddab800aaaef2fb50a2965c20fef3cd6f5a8ca
downloadpnor-a7f9b25eb1e7fac405bc1a54597cfc812a07fb3f.tar.gz
pnor-a7f9b25eb1e7fac405bc1a54597cfc812a07fb3f.zip
Initial commit.
-rw-r--r--LICENSE202
-rw-r--r--NOTICE3
-rwxr-xr-xPalmettoPnorLayout.xml192
-rwxr-xr-xcreate_pnor_image.pl139
-rwxr-xr-xupdate_image_palmetto.pl131
5 files changed, 667 insertions, 0 deletions
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 0000000..cfca856
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,3 @@
+All files contained within are licensed under the terms of the Apache
+License v2.0. A copy may be obtained at:
+ http://www.apache.org/licenses/LICENSE-2.0
diff --git a/PalmettoPnorLayout.xml b/PalmettoPnorLayout.xml
new file mode 100755
index 0000000..519fbae
--- /dev/null
+++ b/PalmettoPnorLayout.xml
@@ -0,0 +1,192 @@
+<!-- IBM_PROLOG_BEGIN_TAG -->
+<!-- This is an automatically generated prolog. -->
+<!-- -->
+<!-- $Source: src/build/buildpnor/pnorLayoutRhesus.xml $ -->
+<!-- -->
+<!-- IBM CONFIDENTIAL -->
+<!-- -->
+<!-- COPYRIGHT International Business Machines Corp. 2013,2014 -->
+<!-- -->
+<!-- p1 -->
+<!-- -->
+<!-- Object Code Only (OCO) source materials -->
+<!-- Licensed Internal Code Source Materials -->
+<!-- IBM HostBoot Licensed Internal Code -->
+<!-- -->
+<!-- The source code for this program is not published or otherwise -->
+<!-- divested of its trade secrets, irrespective of what has been -->
+<!-- deposited with the U.S. Copyright Office. -->
+<!-- -->
+<!-- Origin: 30 -->
+<!-- -->
+<!-- IBM_PROLOG_END_TAG -->
+<!--
+Layout Description
+<metadata> Element -> Contains high-level information about
+ the PNOR layout.
+ <imageSize> -> Size of PNOR image in bytes.
+ <blockSize> -> size of erase blocks in bytes.
+ <sideAOffset> -> Location of Side A Partition Table
+ <sideBOffset> -> Location of Side B Partition Table
+<section> -> Contains information about a PNOR Partition
+ <description> -> Text description of the partition.
+ Does not have to be machine readable.
+ <eyeCatch> -> Name of the Partition
+ <physicalOffset> -> Offset of the Partition in PNOR
+ in bytes.
+ <physicalSize> -> Size of the Partition in bytes.
+ <side> -> Side the partition should be associated with.
+ This determines if the partition should be
+ added to the partition table at <sideAOffset>
+ or <sideBOffset>
+ <testonly/> Indicates partition is used for internal
+ testing only. Partition should be skipped
+ in production environments.
+ <ecc/> Indicates Partition should be ECC protected
+ <sha512Version/> Indicates Partition uses SHA512 for
+ version information.
+ <sha512perEC/> Indicates SHA512 is used to indicate
+ version for each EC-specific image
+ within the Partition.
+ <preserved/> Indicates Partition is preserved
+ across code updates.
+-->
+
+<pnor>
+ <metadata>
+ <imageSize>0x2000000</imageSize>
+ <blockSize>0x1000</blockSize>
+ <sideAOffset>0x0</sideAOffset>
+ <sideBOffset>0x8000</sideBOffset>
+ </metadata>
+ <section> <!-- WGH Verified -->
+ <description>Hostboot Extended image (5.625MB)</description>
+ <eyeCatch>HBI</eyeCatch>
+ <physicalOffset>0x10000</physicalOffset>
+ <physicalRegionSize>0x5A0000</physicalRegionSize>
+ <side>A</side> <!-- Choices: A, B -->
+ <sha512Version/>
+ <ecc/>
+ </section>
+ <section> <!-- WGH Verified -->
+ <description>Module VPD (576K)</description>
+ <eyeCatch>MVPD</eyeCatch>
+ <physicalOffset>0x5B0000</physicalOffset>
+ <physicalRegionSize>0x90000</physicalRegionSize>
+ <side>A</side>
+ <ecc/>
+ </section>
+ <section> <!-- WGH Verified -->
+ <description>Centaur VPD (288K)</description>
+ <eyeCatch>CVPD</eyeCatch>
+ <physicalOffset>0x640000</physicalOffset>
+ <physicalRegionSize>0x48000</physicalRegionSize>
+ <side>A</side>
+ <ecc/>
+ </section>
+ <section> <!-- WGH Verified -->
+ <description>DIMM JEDEC (288K)</description>
+ <eyeCatch>DJVPD</eyeCatch>
+ <physicalOffset>0x688000</physicalOffset>
+ <physicalRegionSize>0x48000</physicalRegionSize>
+ <side>A</side>
+ <ecc/>
+ </section>
+ <section> <!-- WGH NEED TO ADD ECC in update_image_palmetto.pl & use updated image in create_pnor_image -->
+ <description>Hostboot Data (1.125M)</description>
+ <eyeCatch>HBD</eyeCatch>
+ <physicalOffset>0x6D0000</physicalOffset>
+ <physicalRegionSize>0x120000</physicalRegionSize>
+ <side>A</side> <!-- Choices: A, B -->
+ <ecc/>
+ </section>
+ <section>
+ <description>Centaur SBE (576K)</description>
+ <eyeCatch>SBEC</eyeCatch>
+ <physicalOffset>0x7F0000</physicalOffset>
+ <physicalRegionSize>0x90000</physicalRegionSize>
+ <side>A</side> <!-- Choices: A, B -->
+ <sha512perEC/>
+ <ecc/>
+ </section>
+ <section>
+ <description>SBE-IPL (Staging Area) (288K)</description>
+ <eyeCatch>SBE</eyeCatch>
+ <physicalOffset>0x880000</physicalOffset>
+ <physicalRegionSize>0x48000</physicalRegionSize>
+ <side>A</side> <!-- Choices: A, B -->
+ <sha512perEC/>
+ <ecc/>
+ </section>
+ <section>
+ <description>Sleep Winkle Ref Image (1.125MB)</description>
+ <eyeCatch>WINK</eyeCatch>
+ <physicalOffset>0x910000</physicalOffset>
+ <physicalRegionSize>0x120000</physicalRegionSize>
+ <side>A</side> <!-- Choices: A, B -->
+ <sha512Version/>
+ <ecc/>
+ </section>
+ <section>
+ <description>Guard Data (20K)</description>
+ <eyeCatch>GUARD</eyeCatch>
+ <physicalOffset>0xA30000</physicalOffset>
+ <physicalRegionSize>0x5000</physicalRegionSize>
+ <side>A</side> <!-- Choices: A, B -->
+ <ecc/>
+ </section>
+ <section>
+ <description>Hostboot Error Logs (144K)</description>
+ <eyeCatch>HBEL</eyeCatch>
+ <physicalOffset>0xA35000</physicalOffset>
+ <physicalRegionSize>0x24000</physicalRegionSize>
+ <side>A</side> <!-- Choices: A, B -->
+ <ecc/>
+ </section>
+ <section> <!-- WGH DISCUSSION NEEDED ABOUT SHA512 + ECC, for now - neither -->
+ <description>Payload (16MB)</description>
+ <eyeCatch>PAYLOAD</eyeCatch>
+ <physicalOffset>0xA59000</physicalOffset>
+ <physicalRegionSize>0x1000000</physicalRegionSize>
+ <side>A</side> <!-- Choices: A, B -->
+ </section>
+ <section>
+ <description>Nvram (576K)</description>
+ <eyeCatch>NVRAM</eyeCatch>
+ <physicalOffset>0x1A59000</physicalOffset>
+ <physicalRegionSize>0x90000</physicalRegionSize>
+ <side>A</side>
+ <ecc/>
+ </section>
+ <section>
+ <description>Hostboot Runtime Services for Sapphire (2.25MB)</description>
+ <eyeCatch>HBRT</eyeCatch>
+ <physicalOffset>0x1AE9000</physicalOffset>
+ <physicalRegionSize>0x240000</physicalRegionSize>
+ <side>A</side>
+ <sha512Version/>
+ <ecc/>
+ </section>
+ <section>
+ <description>Hostboot Base (576K)</description>
+ <eyeCatch>HBB</eyeCatch>
+ <physicalOffset>0x1F67000</physicalOffset>
+ <physicalRegionSize>0x90000</physicalRegionSize>
+ <side>A</side> <!-- Choices: A, B -->
+ <sha512Version/>
+ <ecc/>
+ </section>
+</pnor>
+
+
+
+<!-- <section> -->
+<!-- <description>SBE-IPL (Staging Area) (576K)</description> -->
+<!-- <eyeCatch>SBE</eyeCatch> -->
+<!-- <physicalOffset>0x880000</physicalOffset> -->
+<!-- <physicalRegionSize>0x90000</physicalRegionSize> -->
+<!-- <side>A</side> -->
+<!-- <sha512perEC/> -->
+<!-- <ecc/> -->
+<!-- </section> -->
+
diff --git a/create_pnor_image.pl b/create_pnor_image.pl
new file mode 100755
index 0000000..8fc2aee
--- /dev/null
+++ b/create_pnor_image.pl
@@ -0,0 +1,139 @@
+#!/usr/bin/perl
+
+use strict;
+use File::Basename;
+
+my $program_name = File::Basename::basename $0;
+my $outdir = "";
+my $scratch_dir = "";
+my $pnor_data_dir = "";
+my $pnor_filename = "";
+my $payload = "";
+my $hb_image_dir = "";
+my $xml_layout_file = "";
+my $targeting_binary_filename = "";
+my $sbec_binary_filename = "";
+my $sbe_binary_filename = "";
+
+while (@ARGV > 0){
+ $_ = $ARGV[0];
+ chomp($_);
+ $_ = &trim_string($_);
+ if (/^-h$/i || /^-help$/i || /^--help$/i){
+ #print help content
+ usage();
+ exit 0;
+ }
+ elsif (/^-scratch_dir/i){
+ $scratch_dir = $ARGV[1] or die "Bad command line arg given: expecting a scratch dir path.\n";
+ shift;
+ }
+ elsif (/^-outdir/i){
+ $outdir = $ARGV[1] or die "Bad command line arg given: expecting a directory for output data.\n";
+ shift;
+ }
+ elsif (/^-pnor_data_dir/i){
+ $pnor_data_dir = $ARGV[1] or die "Bad command line arg given: expecting a directory containing pnor data.\n";
+ shift;
+ }
+ elsif (/^-pnor_filename/i){
+ $pnor_filename = $ARGV[1] or die "Bad command line arg given: expecting a pnor filename.\n";
+ shift;
+ }
+ elsif (/^-hb_image_dir/i){
+ $hb_image_dir = $ARGV[1] or die "Bad command line arg given: expecting an hb image dir path.\n";
+ shift;
+ }
+ elsif (/^-xml_layout_file/i){
+ $xml_layout_file = $ARGV[1] or die "Bad command line arg given: expecting an xml layout file.\n";
+ shift;
+ }
+ elsif (/^-payload/i){
+ $payload = $ARGV[1] or die "Bad command line arg given: expecting a filepath to payload binary file.\n";
+ shift;
+ }
+ elsif (/^-targeting_binary_filename/i){
+ $targeting_binary_filename = $ARGV[1] or die "Bad command line arg given: expecting a targeting binary filename.\n";
+ shift;
+ }
+ elsif (/^-sbe_binary_filename/i){
+ $sbe_binary_filename = $ARGV[1] or die "Bad command line arg given: expecting an sbe binary filename.\n";
+ shift;
+ }
+ elsif (/^-sbec_binary_filename/i){
+ $sbec_binary_filename = $ARGV[1] or die "Bad command line arg given: expecting an sbec binary filename.\n";
+ shift;
+ }
+ else {
+ print "Unrecognized command line arg: $_ \n";
+ print "To view all the options and help text run \'$program_name -h\' \n";
+ exit 1;
+ }
+ shift;
+}
+
+if ($outdir eq "") {
+ die "-outdir <path_to_directory_for_output_files> is a required command line variable. Please run again with this parameter.\n";
+}
+
+print "scratch_dir = $scratch_dir\n";
+print "pnor_data_dir = $pnor_data_dir\n";
+
+my $build_pnor_command = "$hb_image_dir/buildpnor.pl";
+$build_pnor_command .= " --pnorOutBin $pnor_filename --pnorLayout $xml_layout_file";
+$build_pnor_command .= " --binFile_HBD $scratch_dir/$targeting_binary_filename";
+$build_pnor_command .= " --binFile_SBE $scratch_dir/$sbe_binary_filename";
+$build_pnor_command .= " --binFile_SBEC $scratch_dir/$sbec_binary_filename";
+$build_pnor_command .= " --binFile_WINK $scratch_dir/p8.ref_image.hdr.bin.ecc";
+$build_pnor_command .= " --binFile_HBB $scratch_dir/hostboot.header.bin.ecc";
+$build_pnor_command .= " --binFile_HBI $scratch_dir/hostboot_extended.header.bin.ecc";
+$build_pnor_command .= " --binFile_HBRT $scratch_dir/hostboot_runtime.header.bin.ecc";
+$build_pnor_command .= " --binFile_HBEL $scratch_dir/hbel.bin.ecc";
+$build_pnor_command .= " --binFile_GUARD $scratch_dir/guard.bin.ecc";
+$build_pnor_command .= " --binFile_PAYLOAD $payload";
+$build_pnor_command .= " --binFile_NVRAM $scratch_dir/nvram.bin.ecc";
+$build_pnor_command .= " --binFile_MVPD $scratch_dir/mvpd_fill.bin.ecc";
+$build_pnor_command .= " --binFile_DJVPD $scratch_dir/djvpd_fill.bin.ecc";
+$build_pnor_command .= " --binFile_CVPD $scratch_dir/cvpd.bin.ecc";
+$build_pnor_command .= " --fpartCmd \"fpart\"";
+$build_pnor_command .= " --fcpCmd \"fcp\"";
+print "###############################";
+run_command("$build_pnor_command");
+
+#END MAIN
+#-------------------------------------------------------------------------
+sub usage {
+
+
+print <<"ENDUSAGE";
+
+
+ENDUSAGE
+
+;
+}
+
+
+sub parse_config_file {
+
+}
+
+
+#trim_string takes one string as input, trims leading and trailing whitespace
+# before returning that string
+sub trim_string {
+ my $str = shift;
+ $str =~ s/^\s+//;
+ $str =~ s/\s+$//;
+ return $str;
+}
+
+sub run_command {
+ my $command = shift;
+ print "$command\n";
+ my $rc = system($command);
+ if ($rc !=0 ){
+ die "Error running command: $command. Nonzero return code of ($rc) returned.\n";
+ }
+ return $rc;
+}
diff --git a/update_image_palmetto.pl b/update_image_palmetto.pl
new file mode 100755
index 0000000..2034e06
--- /dev/null
+++ b/update_image_palmetto.pl
@@ -0,0 +1,131 @@
+#!/usr/bin/perl
+
+use strict;
+use File::Basename;
+
+#my $ecc_tool_dir = "/opt/mcp/shared/fr_FLD8-1-20140528/opt/fsp/usr/bin"; #wh_todo
+
+my $op_target_dir = "";
+my $hb_image_dir = "";
+my $scratch_dir = "";
+my $hb_binary_dir = "";;
+
+while (@ARGV > 0){
+ $_ = $ARGV[0];
+ chomp($_);
+ $_ = &trim_string($_);
+ if (/^-h$/i || /^-help$/i || /^--help$/i){
+ usage(); #print help content
+ exit 0;
+ }
+ elsif (/^-op_target_dir/i){
+ $op_target_dir = $ARGV[1] or die "Bad command line arg given: expecting a config type.\n";
+ shift;
+ }
+ elsif (/^-hb_image_dir/i){
+ $hb_image_dir = $ARGV[1] or die "Bad command line arg given: expecting a config type.\n";
+ shift;
+ }
+ elsif (/^-scratch_dir/i){
+ $scratch_dir = $ARGV[1] or die "Bad command line arg given: expecting a config type.\n";
+ shift;
+ }
+ elsif (/^-hb_binary_dir/i){
+ $hb_binary_dir = $ARGV[1] or die "Bad command line arg given: expecting a config type.\n";
+ shift;
+ }
+ else {
+ print "Unrecognized command line arg: $_ \n";
+ #print "To view all the options and help text run \'$program_name -h\' \n";
+ exit 1;
+ }
+ shift;
+}
+
+#Pad Targeting binary to 4k page size, then add ECC data
+run_command("dd if=$op_target_dir/PALMETTO_HB.targeting.bin of=$scratch_dir/PALMETTO_HB.targeting.bin ibs=4k conv=sync");
+run_command("ecc --inject $scratch_dir/PALMETTO_HB.targeting.bin --output $scratch_dir/PALMETTO_HB.targeting.bin --p8");
+
+run_command("echo \"00000000001800000000000008000000000000000007EF80\" | xxd -r -ps - $scratch_dir/sbe.header");
+run_command("echo -en VERSION\\\\0 > $scratch_dir/hostboot.sha.bin");
+run_command("sha512sum $hb_image_dir/img/hostboot.bin | awk \'{print \$1}\' | xxd -pr -r >> $scratch_dir/hostboot.sha.bin");
+run_command("dd if=$scratch_dir/hostboot.sha.bin of=$scratch_dir/secureboot.header ibs=4k conv=sync");
+run_command("dd if=/dev/zero of=$scratch_dir/hbb.footer count=1 bs=128K");
+run_command("cat $scratch_dir/sbe.header $scratch_dir/secureboot.header $hb_image_dir/img/hostboot.bin $scratch_dir/hbb.footer > $scratch_dir/hostboot.stage.bin");
+run_command("head -c 524288 $scratch_dir/hostboot.stage.bin > $scratch_dir/hostboot.header.bin");
+
+run_command("ecc --inject $hb_image_dir/img/hostboot.bin --output $scratch_dir/hostboot.bin.ecc --p8");
+run_command("ecc --inject $scratch_dir/hostboot.header.bin --output $scratch_dir/hostboot.header.bin.ecc --p8");
+run_command("dd if=$hb_image_dir/img/hostboot_extended.bin of=$scratch_dir/hostboot_extended.bin.pad ibs=4k count=1280 conv=sync");
+run_command("ecc --inject $scratch_dir/hostboot_extended.bin.pad --output $scratch_dir/hostboot_extended.bin.ecc --p8");
+
+run_command("echo -en VERSION\\\\0 > $scratch_dir/hostboot_runtime.sha.bin");
+run_command("sha512sum $hb_image_dir/img/hostboot_runtime.bin | awk \'{print \$1}\' | xxd -pr -r >> $scratch_dir/hostboot_runtime.sha.bin");
+run_command("dd if=$scratch_dir/hostboot_runtime.sha.bin of=$scratch_dir/hostboot.temp.bin ibs=4k conv=sync");
+run_command("cat $hb_image_dir/img/hostboot_runtime.bin >> $scratch_dir/hostboot.temp.bin");
+run_command("dd if=$scratch_dir/hostboot.temp.bin of=$scratch_dir/hostboot_runtime.header.bin ibs=2048K conv=sync");
+run_command("ecc --inject $scratch_dir/hostboot_runtime.header.bin --output $scratch_dir/hostboot_runtime.header.bin.ecc --p8");
+
+run_command("echo -en VERSION\\\\0 > $scratch_dir/hostboot_extended.sha.bin");
+run_command("sha512sum $hb_image_dir/img/hostboot_extended.bin | awk \'{print \$1}\' | xxd -pr -r >> $scratch_dir/hostboot_extended.sha.bin");
+run_command("dd if=$scratch_dir/hostboot_extended.sha.bin of=$scratch_dir/hostboot.temp.bin ibs=4k conv=sync");
+run_command("cat $hb_image_dir/img/hostboot_extended.bin >> $scratch_dir/hostboot.temp.bin");
+run_command("dd if=$scratch_dir/hostboot.temp.bin of=$scratch_dir/hostboot_extended.header.bin ibs=5120k conv=sync");
+run_command("ecc --inject $scratch_dir/hostboot_extended.header.bin --output $scratch_dir/hostboot_extended.header.bin.ecc --p8");
+
+#Create blank binary file for HB Errorlogs (HBEL) Partition
+run_command("dd if=/dev/zero bs=128K count=1 | tr \"\\000\" \"\\377\" > $scratch_dir/hostboot.temp.bin");
+run_command("ecc --inject $scratch_dir/hostboot.temp.bin --output $scratch_dir/hbel.bin.ecc --p8");\
+
+#Create blank binary file for GUARD Data (GUARD) Partition
+run_command("dd if=/dev/zero bs=16K count=1 | tr \"\\000\" \"\\377\" > $scratch_dir/hostboot.temp.bin");
+run_command("ecc --inject $scratch_dir/hostboot.temp.bin --output $scratch_dir/guard.bin.ecc --p8");
+
+#Create blank binary file for NVRAM Data (NVRAM) Partition
+run_command("dd if=/dev/zero bs=512K count=1 | tr \"\\000\" \"\\377\" > $scratch_dir/hostboot.temp.bin");
+run_command("ecc --inject $scratch_dir/hostboot.temp.bin --output $scratch_dir/nvram.bin.ecc --p8");
+
+#Create blank binary file for MVPD Partition
+run_command("dd if=/dev/zero bs=512K count=1 | tr \"\\000\" \"\\377\" > $scratch_dir/hostboot.temp.bin");
+run_command("ecc --inject $scratch_dir/hostboot.temp.bin --output $scratch_dir/mvpd_fill.bin.ecc --p8");
+
+#Create blank binary file for DJVPD Partition
+run_command("dd if=/dev/zero bs=256K count=1 | tr \"\\000\" \"\\377\" > $scratch_dir/hostboot.temp.bin");
+run_command("ecc --inject $scratch_dir/hostboot.temp.bin --output $scratch_dir/djvpd_fill.bin.ecc --p8");
+
+#Add ECC Data to CVPD Data (CVPD) Partition
+run_command("ecc --inject $hb_binary_dir/cvpd.bin --output $scratch_dir/cvpd.bin.ecc --p8");
+
+#Copy Binary Data files for consistency
+run_command("cp $hb_binary_dir/palmetto_sbec_pad.img.ecc $scratch_dir/");
+run_command("cp $hb_binary_dir/palmetto_sbe.img.ecc $scratch_dir/");
+run_command("cp $hb_binary_dir/p8.ref_image.hdr.bin.ecc $scratch_dir/");
+
+#END MAIN
+#-------------------------------------------------------------------------
+
+
+
+
+
+############# HELPER FUNCTIONS #################################################
+# Function to first print, and then run a system command, erroring out if the
+# command does not complete successfully
+sub run_command {
+ my $command = shift;
+ print "$command\n";
+ my $rc = system($command);
+ if ($rc !=0 ){
+ die "Error running command: $command. Nonzero return code of ($rc) returned.\n";
+ }
+ return $rc;
+}
+
+# Function to remove leading and trailing whitespeace before returning that string
+sub trim_string {
+ my $str = shift;
+ $str =~ s/^\s+//;
+ $str =~ s/\s+$//;
+ return $str;
+}
+
OpenPOWER on IntegriCloud