Revert original implementation in favor of blob-based approach
Revert original implementation of the in-band firmware update to
pivot to using a blob-based implementation.
Blob-based design is under review here:
https://gerrit.openbmc-project.xyz/14444
Revert "tools: starting burn_my_bmc host utility"
This reverts commit 7dc4670d4be4884e0c6486ca4f0e799116935096.
Revert "phosphor-ipmi-flash: main: move to iana header"
This reverts commit e39f2b3a9a19b8e788a7225a0d291716325b77ee.
Revert "update clang-format"
This reverts commit 1aedab2391cd883e95ebde0129fcaf88d7f16233.
Revert "Build as c++17"
This reverts commit 004fb909202e39b34cb72d31390facd525b04c9b.
Revert "clang-format: always break template declarations"
This reverts commit ff0ee70f0fb8e0c2173f826f4d96fbfced09ca14.
Revert "clang-format-6.0 bump fixes"
This reverts commit 8f378c927a5789f30ba625595153bc1422d511dc.
Revert "flash-ipmi: implement flashAbort"
This reverts commit 605f75f7c026b5c2f454de155f6f211b2c3b187f.
Revert "flash-ipmi: implement flashDataVerify"
This reverts commit 9c6baad43fe7d1db8e449766eed35865ce6a2e4b.
Revert "flash-ipmi: implement flashVerifyCheck"
This reverts commit 7fc66de0d5465f4d25033d6baf48b6489f843331.
Revert "ipmi: start implementing flashVerifyCheck"
This reverts commit fdc65b2524bee544d35a6e2cbeef4c2f68aeb8fd.
Revert "flash-ipmi: implement flashHashFinish"
This reverts commit d5f590f955a67715e7903a04c3a8028f1d4f2664.
Revert "flash-ipmi: implement flashHashData"
This reverts commit cbe51498953d7bd29f516cdfcdb654706b463d2e.
Revert "flash-ipmi: implement flashStartHash"
This reverts commit 6f17bd2220d723fd349077ccd96845a5652403e0.
Revert "flash-ipmi: implement flashDataFinish"
This reverts commit 57703664cd76c2744adf4c5fa504388909efa824.
Revert "flash-ipmi: implement flashDataBlock"
This reverts commit 3c086f2f649d1c4cc7926cbd9375a39dd23e6997.
Revert "update copyright year"
This reverts commit 514f648b76c1a855a356e5a4ca83fd5bf6c53b3f.
Revert "flash-ipmi: implement flashStartTransfer"
This reverts commit 8ec019fdc15cb021f2c7d4cefb85a8ccd3581159.
Revert "ipmi: start implementing flashAbort"
This reverts commit 5c251ca550f56722280dcf17b8c48832ace07142.
Revert "ipmi: start implementing flashDataVerify"
This reverts commit 1cb87d25f79cfb905611b81348fbccb362f5e29a.
Revert "main: cleanup command handling"
This reverts commit 9a5a79a0797294ba9f5c7b2ab79e4dcbacac0c44.
Revert "test: rework ipmi validate test as table"
This reverts commit 39b3a82609511e2d855a2182f22361cc1332bb25.
Revert "ipmi: start implementing flashHashFinish"
This reverts commit fbc7d191eb6d49ff93379e90f372960b799b25c4.
Revert "ipmi: start implementing flashHashData"
This reverts commit cfe66877a5d7cc64bcce5c8789ca164edf9f1c56.
Revert "ipmi: start implementing flashStartHash"
This reverts commit 8d9f7322f46afaab81e32d1999f5bc000f1ba9a6.
Revert "ipmi: start implementing flashDataFinish"
This reverts commit 2c1205db94647c196c154bae0e106933b9ff526e.
Revert "ipmi: promote min length check to earlier"
This reverts commit a53a7b35085ddd41ef3cc47b084d29a1f413e818.
Revert "ipmi: start implementing flashDataBlock"
This reverts commit 79e131fce6e308f7e0f96bc71b07a7f0ebeeffcd.
Revert "ipmi: start implementing flashStartTransfer"
This reverts commit 54c3b53c0d0c7991469ab1be97bdf4e3f301e8f5.
Revert "add flash-ipmi header defining sub-commands"
This reverts commit 3d1786bcd038e4d042d268737a9b874fd667bf84.
Revert "main: start with no-op handler"
This reverts commit accc91799d6a1de4726313b907e5dfa7555bf919.
Change-Id: I1c4dc9dcd2bf7d110240a028a329fcb1e01a4e5b
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/.clang-format b/.clang-format
deleted file mode 100644
index ea71ad6..0000000
--- a/.clang-format
+++ /dev/null
@@ -1,99 +0,0 @@
----
-Language: Cpp
-# BasedOnStyle: LLVM
-AccessModifierOffset: -2
-AlignAfterOpenBracket: Align
-AlignConsecutiveAssignments: false
-AlignConsecutiveDeclarations: false
-AlignEscapedNewlinesLeft: false
-AlignOperands: true
-AlignTrailingComments: true
-AllowAllParametersOfDeclarationOnNextLine: true
-AllowShortBlocksOnASingleLine: false
-AllowShortCaseLabelsOnASingleLine: false
-AllowShortFunctionsOnASingleLine: None
-AllowShortIfStatementsOnASingleLine: false
-AllowShortLoopsOnASingleLine: false
-AlwaysBreakAfterDefinitionReturnType: None
-AlwaysBreakAfterReturnType: None
-AlwaysBreakBeforeMultilineStrings: false
-AlwaysBreakTemplateDeclarations: true
-BinPackArguments: true
-BinPackParameters: true
-BraceWrapping:
- AfterClass: true
- AfterControlStatement: true
- AfterEnum: true
- AfterFunction: true
- AfterNamespace: true
- AfterObjCDeclaration: true
- AfterStruct: true
- AfterUnion: true
- BeforeCatch: true
- BeforeElse: true
- IndentBraces: false
-BreakBeforeBinaryOperators: None
-BreakBeforeBraces: Custom
-BreakBeforeTernaryOperators: true
-BreakConstructorInitializers: AfterColon
-ColumnLimit: 80
-CommentPragmas: '^ IWYU pragma:'
-ConstructorInitializerAllOnOneLineOrOnePerLine: false
-ConstructorInitializerIndentWidth: 4
-ContinuationIndentWidth: 4
-Cpp11BracedListStyle: true
-DerivePointerAlignment: false
-PointerAlignment: Left
-DisableFormat: false
-ExperimentalAutoDetectBinPacking: false
-FixNamespaceComments: true
-ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
-IncludeBlocks: Regroup
-IncludeCategories:
- - Regex: '^[<"](gtest|gmock)'
- Priority: 5
- - Regex: '^"config.h"'
- Priority: -1
- - Regex: '^".*\.hpp"'
- Priority: 1
- - Regex: '^<.*\.h>'
- Priority: 2
- - Regex: '^<.*'
- Priority: 3
- - Regex: '.*'
- Priority: 4
-IndentCaseLabels: true
-IndentWidth: 4
-IndentWrappedFunctionNames: true
-KeepEmptyLinesAtTheStartOfBlocks: true
-MacroBlockBegin: ''
-MacroBlockEnd: ''
-MaxEmptyLinesToKeep: 1
-NamespaceIndentation: None
-ObjCBlockIndentWidth: 2
-ObjCSpaceAfterProperty: false
-ObjCSpaceBeforeProtocolList: true
-PenaltyBreakBeforeFirstCallParameter: 19
-PenaltyBreakComment: 300
-PenaltyBreakFirstLessLess: 120
-PenaltyBreakString: 1000
-PenaltyExcessCharacter: 1000000
-PenaltyReturnTypeOnItsOwnLine: 60
-ReflowComments: true
-SortIncludes: true
-SortUsingDeclarations: true
-SpaceAfterCStyleCast: false
-SpaceBeforeAssignmentOperators: true
-SpaceBeforeParens: ControlStatements
-SpaceInEmptyParentheses: false
-SpacesBeforeTrailingComments: 1
-SpacesInAngles: false
-SpacesInContainerLiterals: true
-SpacesInCStyleCastParentheses: false
-SpacesInParentheses: false
-SpacesInSquareBrackets: false
-Standard: Cpp11
-TabWidth: 4
-UseTab: Never
-...
-
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 9615c76..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,35 +0,0 @@
-*~
-*.o
-*.lo
-*.la
-*.sw*
-Makefile
-Makefile.in
-configure
-.deps
-.libs
-aclocal.m4
-ar-lib
-arm-openbmc-linux-gnueabi-libtool
-autom4te.cache/
-compile
-config.guess
-config.h
-config.h.in
-config.log
-config.status
-config.sub
-depcomp
-install-sh
-libtool
-ltmain.sh
-missing
-stamp-h1
-test-driver
-.dirstamp
-x86_64-libtool
-*_unittest
-*_unittest.log
-*_unittest.trs
-test-suite.log
-tools/burn_my_bmc
diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644
index 0555b5c..0000000
--- a/.gitmodules
+++ /dev/null
@@ -1,3 +0,0 @@
-[submodule "tools/libs/ipmitool"]
- path = tools/libs/ipmitool
- url = https://github.com/ipmitool/ipmitool
diff --git a/COPYING.apache-2.0 b/COPYING.apache-2.0
deleted file mode 100644
index 261eeb9..0000000
--- a/COPYING.apache-2.0
+++ /dev/null
@@ -1,201 +0,0 @@
- 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/COPYING.bsd-3 b/COPYING.bsd-3
deleted file mode 100644
index b332da7..0000000
--- a/COPYING.bsd-3
+++ /dev/null
@@ -1,30 +0,0 @@
-Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-
-Redistribution of source code must retain the above copyright
-notice, this list of conditions and the following disclaimer.
-
-Redistribution in binary form must reproduce the above copyright
-notice, this list of conditions and the following disclaimer in the
-documentation and/or other materials provided with the distribution.
-
-Neither the name of Sun Microsystems, Inc. or the names of
-contributors may be used to endorse or promote products derived
-from this software without specific prior written permission.
-
-This software is provided "AS IS," without a warranty of any kind.
-ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
-INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
-PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.
-SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE
-FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
-OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
-SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA,
-OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
-PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
-LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
-EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
-
diff --git a/LICENSE b/LICENSE
index 753c392..261eeb9 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,7 +1,201 @@
-Different components of phosphor-ipmi-flash are under different licenses (a mix
-of BSD-3 and Apache-2.0). Please see:
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
-COPYING.Apache-2.0
-COPYING.bsd-3 (3-Clause BSD)
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-All source is Apache-2.0 licensed unless otherwise stated.
+ 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/Makefile.am b/Makefile.am
deleted file mode 100644
index 60848e8..0000000
--- a/Makefile.am
+++ /dev/null
@@ -1,19 +0,0 @@
-AM_DEFAULT_SOURCE_EXT = .cpp
-
-libflashcmdsdir = ${libdir}/ipmid-providers
-libflashcmds_LTLIBRARIES = libflashcmds.la
-libflashcmds_la_SOURCES = main.cpp \
- flash-ipmi.cpp \
- ipmi.cpp
-
-libflashcmds_la_LDFLAGS = $(SYSTEMD_LIBS) \
- $(SDBUSPLUS_LIBS) \
- $(PHOSPHOR_DBUS_INTERFACES_LIBS) \
- $(PHOSPHOR_LOGGING_LIBS) \
- -version-info 0:0:0 -shared
-libflashcmds_la_CXXFLAGS = $(SYSTEMD_CFLAGS) \
- $(SDBUSPLUS_CFLAGS) \
- $(PHOSPHOR_DBUS_INTERFACES_CFLAGS) \
- $(PHOSPHOR_LOGGING_CFLAGS)
-
-SUBDIRS = . test tools
diff --git a/bootstrap.sh b/bootstrap.sh
deleted file mode 100755
index 728db88..0000000
--- a/bootstrap.sh
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/sh
-
-AUTOCONF_FILES="Makefile.in aclocal.m4 ar-lib autom4te.cache compile \
- config.guess config.h.in config.sub configure depcomp install-sh \
- ltmain.sh missing *libtool test-driver"
-
-case $1 in
- clean)
- test -f Makefile && make maintainer-clean
- for file in ${AUTOCONF_FILES}; do
- find -name "$file" | xargs -r rm -rf
- done
- exit 0
- ;;
-esac
-
-autoreconf -i
-git submodule init
-git submodule update
-echo 'Run "./configure ${CONFIGURE_FLAGS} && make"'
-
diff --git a/configure.ac b/configure.ac
deleted file mode 100644
index 6e85381..0000000
--- a/configure.ac
+++ /dev/null
@@ -1,86 +0,0 @@
-
-# Initialization
-AC_PREREQ([2.69])
-AC_INIT([phosphor-ipmi-flash], [1.0], [https://www.github.com/openbmc/phosphor-ipmi-flash/issues])
-AC_LANG([C++])
-AC_CONFIG_HEADERS([config.h])
-AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror foreign dist-xz])
-AM_SILENT_RULES([yes])
-
-# Checks for programs.
-AC_PROG_CXX
-AM_PROG_AR
-AC_PROG_INSTALL
-AC_PROG_MAKE_SET
-
-# Checks for typedefs, structures, and compiler characteristics.
-AX_CXX_COMPILE_STDCXX_17([noext])
-AX_APPEND_COMPILE_FLAGS([-Wall], [CXXFLAGS])
-
-# Checks for libraries.
-PKG_CHECK_MODULES([SYSTEMD], [libsystemd >= 221], [], [AC_MSG_ERROR(["systemd required and not found"])])
-PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus], ,[AC_MSG_ERROR([The openbmc/sdbusplus package is required])])
-PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging], ,[AC_MSG_ERROR([The openbmc/phosphor-logging package is required])])
-PKG_CHECK_MODULES([PHOSPHOR_DBUS_INTERFACES], [phosphor-dbus-interfaces], [], [AC_MSG_ERROR(["phosphor-dbus-interfaces required and not found."])])
-AC_CHECK_HEADER([host-ipmid], [AC_MSG_ERROR(["phosphor-host-ipmid required and not found."])])
-AC_CHECK_HEADER(experimental/filesystem, ,[AC_MSG_ERROR([Could not find experimental/filesystem...libstdc++fs development package required])])
-
-# Checks for library functions.
-LT_INIT # Required for systemd linking
-
-# Check/set gtest specific functions.
-PKG_CHECK_MODULES([GTEST], [gtest], [], [AC_MSG_NOTICE([gtest not found, tests will not build])])
-PKG_CHECK_MODULES([GMOCK], [gmock], [], [AC_MSG_NOTICE([gmock not found, tests will not build])])
-PKG_CHECK_MODULES([GTEST_MAIN], [gtest_main], [], [AC_MSG_NOTICE([gtest_main not found, tests will not build])])
-
-# Do you want to register as a Google OEM IPMI handler as well as firmware?
-AC_ARG_ENABLE([google],
- AS_HELP_STRING([--enable-google], [Enable registration as Google OEM IPMI Handler])
-)
-
-AC_ARG_VAR(ENABLE_GOOGLE, [Enable registration as Google OEM IPMI Handler])
-
-AS_IF([test "x$enable_google" == "xyes"],
- [ENABLE_GOOGLE="yes"]
- AC_DEFINE_UNQUOTED([ENABLE_GOOGLE], ["$ENABLE_GOOGLE"], [Enable registration as Google OEM IPMI Handler])
-)
-
-# Add --enable-oe-sdk flag to configure script
-AC_ARG_ENABLE([oe-sdk],
- AS_HELP_STRING([--enable-oe-sdk], [Link testcases absolutely against OE SDK so they can be ran within it.])
-)
-
-# Check for OECORE_TARGET_SYSROOT in the environment.
-AC_ARG_VAR(OECORE_TARGET_SYSROOT,
- [Path to the OE SDK SYSROOT])
-
-# Configure OESDK_TESTCASE_FLAGS environment variable, which will be later
-# used in test/Makefile.am
-AS_IF([test "x$enable_oe_sdk" == "xyes"],
- AS_IF([test "x$OECORE_TARGET_SYSROOT" == "x"],
- AC_MSG_ERROR([OECORE_TARGET_SYSROOT must be set with --enable-oe-sdk])
- )
- AC_MSG_NOTICE([Enabling OE-SDK at $OECORE_TARGET_SYSROOT])
- [
- testcase_flags="-Wl,-rpath,\${OECORE_TARGET_SYSROOT}/lib"
- testcase_flags="${testcase_flags} -Wl,-rpath,\${OECORE_TARGET_SYSROOT}/usr/lib"
- testcase_flags="${testcase_flags} -Wl,-dynamic-linker,`find \${OECORE_TARGET_SYSROOT}/lib/ld-*.so | sort -r -n | head -n1`"
- ]
- AC_SUBST([OESDK_TESTCASE_FLAGS], [$testcase_flags])
-)
-
-AC_ARG_VAR(STAGING_PATH, [The staging path for the flash image.])
-AS_IF([test "x$STAGING_PATH" == "x"], [STAGING_PATH="/run/initramfs/bmc-image"])
-AC_DEFINE_UNQUOTED([STAGING_PATH], ["$STAGING_PATH"], [The staging path for the flash image.])
-
-AC_ARG_VAR(HASH_PATH, [The path for the hash file.])
-AS_IF([test "x$HASH_PATH" == "x"], [HASH_PATH="/tmp/bmc.sig"])
-AC_DEFINE_UNQUOTED([HASH_PATH], ["$HASH_PATH"], [The path for the hash file.])
-
-AC_ARG_VAR(STATUS_PATH, [The path for the verification status file.])
-AS_IF([test "x$STATUS_PATH" == "x"], [STATUS_PATH="/tmp/bmc.verify"])
-AC_DEFINE_UNQUOTED([STATUS_PATH], ["$STATUS_PATH"], [The path for the verification status file.])
-
-# Create configured output
-AC_CONFIG_FILES([Makefile test/Makefile tools/Makefile tools/test/Makefile])
-AC_OUTPUT
diff --git a/flash-ipmi.cpp b/flash-ipmi.cpp
deleted file mode 100644
index 19e8a3d..0000000
--- a/flash-ipmi.cpp
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Copyright 2018 Google Inc.
- *
- * 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.
- */
-
-#include "flash-ipmi.hpp"
-
-#include <cstdio>
-#include <fstream>
-#include <phosphor-logging/log.hpp>
-#include <sdbusplus/bus.hpp>
-
-/* systemd service to kick start a service. */
-static constexpr auto systemdService = "org.freedesktop.systemd1";
-static constexpr auto systemdRoot = "/org/freedesktop/systemd1";
-static constexpr auto systemdInterface = "org.freedesktop.systemd1.Manager";
-static constexpr auto verifyTarget = "verify_image.service";
-
-using namespace phosphor::logging;
-
-namespace
-{
-
-/**
- * Close a file pointer and set to null.
- *
- * @param[in] fd a pointer to your file handle.
- */
-void closeFile(std::FILE** fd)
-{
- if (!fd)
- {
- return;
- }
-
- if (*fd)
- {
- std::fclose(*fd);
- (*fd) = nullptr;
- }
-}
-} // namespace
-
-void FlashUpdate::closeEverything()
-{
- closeFile(&flashFd);
- closeFile(&hashFd);
-}
-
-void FlashUpdate::deleteEverything()
-{
- /* Assumes you've called closeEverything() already */
-
- (void)std::remove(tmpPath.c_str());
- (void)std::remove(verifyPath.c_str());
-
- /* hashPath is optional. */
- if (!hashPath.empty())
- {
- (void)std::remove(hashPath.c_str());
- }
-}
-
-FlashUpdate::~FlashUpdate()
-{
- /* Close without deleting. This object can only be destroyed if the ipmi
- * daemon unloads it, by closing down. In this event, we want the verified
- * file to live on.
- */
- closeEverything();
-}
-
-void FlashUpdate::abortEverything()
-{
- closeEverything();
-
- /* Stop the systemd unit if it was running. */
- auto method = bus.new_method_call(systemdService, systemdRoot,
- systemdInterface, "StopUnit");
- method.append(verifyTarget);
- method.append("replace");
- bus.call_noreply(method);
-
- deleteEverything();
- return;
-}
-
-bool FlashUpdate::openEverything()
-{
- flashFd = std::fopen(tmpPath.c_str(), "wb");
- if (flashFd == nullptr)
- {
- log<level::INFO>("Unable to open staging path",
- entry("PATH=%s", tmpPath.c_str()));
- return false;
- }
-
- /* hash path is basically optional. */
- if (!hashPath.empty())
- {
- hashFd = std::fopen(hashPath.c_str(), "wb");
- if (hashFd == nullptr)
- {
- log<level::INFO>("Unable to open hash storage path",
- entry("PATH=%s", hashPath.c_str()));
- closeFile(&flashFd);
- return false;
- }
- }
-
- return true;
-}
-
-/* Prepare to receive a BMC image and then a signature. */
-bool FlashUpdate::start(uint32_t length)
-{
- /* Close out and delete everything. */
- abortEverything();
-
- /* TODO: Validate request->length */
- flashLength = length;
-
- /* Start over! */
- return openEverything();
-}
-
-bool FlashUpdate::writeBlock(std::FILE* fd, uint32_t offset,
- const std::vector<uint8_t>& bytes)
-{
- /* Seek into position, let's assume fseek won't call if offset matches
- * position.
- */
- if (std::fseek(fd, offset, SEEK_SET))
- {
- log<level::ERR>("Unable to seek into file to write bytes.");
- return false;
- }
-
- /* Write the bytes. */
- auto written = std::fwrite(bytes.data(), 1, bytes.size(), fd);
-
- if (written != bytes.size())
- {
- log<level::ERR>("Unable to write all the bytes requested.");
- return false;
- }
-
- (void)std::fflush(fd);
- return true;
-}
-
-bool FlashUpdate::flashData(uint32_t offset, const std::vector<uint8_t>& bytes)
-{
- if (flashFd)
- {
- return writeBlock(flashFd, offset, bytes);
- }
-
- return false;
-}
-
-bool FlashUpdate::flashFinish()
-{
- /* If it's open, close it. */
- if (flashFd)
- {
- closeFile(&flashFd);
- return true;
- }
-
- return false;
-}
-
-bool FlashUpdate::startHash(uint32_t length)
-{
- if (!hashFd)
- {
- return false;
- }
-
- hashLength = length;
- return true;
-}
-
-bool FlashUpdate::hashData(uint32_t offset, const std::vector<uint8_t>& bytes)
-{
- if (hashFd)
- {
- return writeBlock(hashFd, offset, bytes);
- }
-
- return false;
-}
-
-bool FlashUpdate::hashFinish()
-{
- if (hashFd)
- {
- closeFile(&hashFd);
- return true;
- }
-
- return false;
-}
-
-bool FlashUpdate::startDataVerification()
-{
- auto method = bus.new_method_call(systemdService, systemdRoot,
- systemdInterface, "StartUnit");
- method.append(verifyTarget);
- method.append("replace");
- bus.call_noreply(method);
-
- return false;
-}
-
-bool FlashUpdate::abortUpdate()
-{
- abortEverything();
- return true;
-}
-
-VerifyCheckResponse FlashUpdate::checkVerify()
-{
- auto result = VerifyCheckResponse::other;
- std::ifstream ifs;
- ifs.open(verifyPath);
- if (ifs.good())
- {
- std::string status;
- /*
- * Check for the contents of the file, excepting:
- * running, success, or failed.
- */
- ifs >> status;
- if (status == "running")
- {
- result = VerifyCheckResponse::running;
- }
- else if (status == "success")
- {
- result = VerifyCheckResponse::success;
- }
- else if (status == "failed")
- {
- result = VerifyCheckResponse::failed;
- }
- }
-
- return result;
-}
diff --git a/flash-ipmi.hpp b/flash-ipmi.hpp
deleted file mode 100644
index 908963c..0000000
--- a/flash-ipmi.hpp
+++ /dev/null
@@ -1,256 +0,0 @@
-#pragma once
-
-#include <cstdio>
-#include <sdbusplus/bus.hpp>
-#include <string>
-#include <vector>
-
-#include "host-ipmid/ipmid-api.h"
-
-/* Clearer way to represent the subcommand size. */
-#define SUBCMD_SZ sizeof(uint8_t)
-
-/*
- * These are the codes we return over IPMI when the host checks for the status
- * of the asynchronous verification call.
- */
-enum VerifyCheckResponse
-{
- running = 0x00,
- success = 0x01,
- failed = 0x02,
- other = 0x03,
-};
-
-/*
- * flashStartTransfer -- starts file upload.
- * flashDataBlock -- adds data to image file.
- * flashDataFinish -- closes the file.
- *
- * flashStartHash -- starts uploading hash.
- * flashDataHash -- adds data to the hash.
- * flashDataVerify -- triggers verification.
- *
- * flashAbort -- abort everything.
- *
- * flashVerifyCheck -- Check if the verification has completed.
- *
- * flashVersion -- Get the version of this OEM Handler.
- *
- * flashRequestRegion -- Request the physical address for decode (bridge)
- * flashDataExtBlock -- Provide image data via a bridge
- * flashHashExtData -- Provide hash data via a bridge
- */
-enum FlashSubCmds
-{
- /* Start a transfer. */
- flashStartTransfer = 0,
- /* Data block. */
- flashDataBlock = 1,
- /* Close file. */
- flashDataFinish = 2,
-
- /* Start a hash transfer. */
- flashStartHash = 3,
- /* Add data to the hash. */
- flashHashData = 4,
- /* Close out the hash file. */
- flashHashFinish = 5,
-
- /* Verify the flash image against the hast sent. */
- flashDataVerify = 6,
-
- /* Abort. */
- flashAbort = 7,
-
- /*
- * Check if the verification is ready and was successful.
- * If the response from the IPMI command is OK, check the
- * response bytes to know if it's ready or still computing,
- * or failed.
- */
- flashVerifyCheck = 8,
-
- flashVersion = 9,
- flashRequestRegion = 10,
- flashDataExtBlock = 11,
- flashHashExtData = 12,
- flashMapRegionLpc = 13,
-};
-
-/*
- * StartTransfer expects a basic structure providing some information.
- */
-struct StartTx
-{
- uint8_t cmd;
- uint32_t length; /* Maximum image length is 4GiB (little-endian) */
-} __attribute__((packed));
-
-struct ChunkHdr
-{
- uint8_t cmd;
- uint32_t offset; /* 0-based write offset */
- uint8_t data[];
-} __attribute__((packed));
-
-class UpdateInterface
-{
- public:
- virtual ~UpdateInterface() = default;
-
- /**
- * Prepare to receive a BMC image and then a signature.
- *
- * @param[in] length - the size of the flash image.
- * @return true on success, false otherwise.
- */
- virtual bool start(uint32_t length) = 0;
-
- /**
- * Attempt to write the bytes at the offset.
- *
- * @param[in] offset - the 0-based byte offset into the flash image.
- * @param[in] bytes - the bytes to write.
- * @return true on success, false otherwise.
- */
- virtual bool flashData(uint32_t offset,
- const std::vector<uint8_t>& bytes) = 0;
-
- /**
- * Called to indicate the host is done sending the flash bytes.
- */
- virtual bool flashFinish() = 0;
-
- /**
- * Prepare to receive a BMC image signature.
- *
- * @param[in] length - length of signature in bytes.
- * @return true on success, false otherwise.
- */
- virtual bool startHash(uint32_t length) = 0;
-
- /**
- * Attempt to write the bytes at the offset.
- *
- * @param[in] offset - the 0-based byte offset into the flash image.
- * @param[in] bytes - the bytes to write.
- * @return true on success, false otherwise.
- */
- virtual bool hashData(uint32_t offset,
- const std::vector<uint8_t>& bytes) = 0;
-
- /**
- * Called to indicate the host is done sending the hash bytes.
- */
- virtual bool hashFinish() = 0;
-
- /**
- * Kick off the flash image verification process.
- *
- * @return true if it was started succesfully.
- */
- virtual bool startDataVerification() = 0;
-
- /**
- * Attempt to abort everything.
- *
- * @return true if aborted, false if unable or failed.
- */
- virtual bool abortUpdate() = 0;
-
- /**
- * Check if the verification result is available and return.
- *
- * @return the verification response.
- */
- virtual VerifyCheckResponse checkVerify() = 0;
-};
-
-class FlashUpdate : public UpdateInterface
-{
- public:
- FlashUpdate(sdbusplus::bus::bus&& bus, const std::string& stagingPath,
- const std::string& verifyPath, const std::string& hash = "") :
- bus(std::move(bus)),
- flashLength(0), flashFd(nullptr), tmpPath(stagingPath), hashLength(0),
- hashFd(nullptr), hashPath(hash), verifyPath(verifyPath){};
- ~FlashUpdate();
-
- FlashUpdate(const FlashUpdate&) = delete;
- FlashUpdate& operator=(const FlashUpdate&) = delete;
- FlashUpdate(FlashUpdate&&) = default;
- FlashUpdate& operator=(FlashUpdate&&) = default;
-
- bool start(uint32_t length) override;
- bool flashData(uint32_t offset, const std::vector<uint8_t>& bytes) override;
- bool flashFinish() override;
-
- bool startHash(uint32_t length) override;
- bool hashData(uint32_t offset, const std::vector<uint8_t>& bytes) override;
- bool hashFinish() override;
-
- bool startDataVerification() override;
- bool abortUpdate() override;
- VerifyCheckResponse checkVerify() override;
-
- private:
- /**
- * Attempt to write the bytes at the offset.
- *
- * @param[in] fd - the file stream pointer.
- * @param[in] offset - the 0-based byte offset into the flash image.
- * @param[in] bytes - the bytes to write.
- * @return true on success, false otherwise.
- */
- bool writeBlock(std::FILE* fd, uint32_t offset,
- const std::vector<uint8_t>& bytes);
-
- /**
- * Tries to delete everything.
- */
- void deleteEverything();
-
- /**
- * Tries to close out everything.
- */
- void closeEverything();
-
- /**
- * Tries to close out and delete anything staged.
- */
- void abortEverything();
-
- /**
- * Open all staged file handles you expect to use.
- *
- * @return false on failure.
- */
- bool openEverything();
-
- /* A bus. */
- sdbusplus::bus::bus bus;
-
- /* The length of the flash image in bytes. */
- uint32_t flashLength;
-
- /* The file handle to the flash staging file. */
- std::FILE* flashFd;
-
- /* Where the bytes are written before verification. */
- const std::string tmpPath;
-
- /* The length of the hash in bytes. */
- uint32_t hashLength;
-
- /* The file handle to the hash file. */
- std::FILE* hashFd;
-
- /* Where we write the hash bytes. Only required if your verification
- * process uses a separate signature.
- */
- const std::string hashPath;
-
- /* The path to read the status of the signature verification. */
- const std::string verifyPath;
-};
diff --git a/ipmi.cpp b/ipmi.cpp
deleted file mode 100644
index 6e28625..0000000
--- a/ipmi.cpp
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Copyright 2018 Google Inc.
- *
- * 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.
- */
-
-#include "ipmi.hpp"
-
-#include "flash-ipmi.hpp"
-
-#include <cstring>
-#include <unordered_map>
-
-IpmiFlashHandler getCommandHandler(FlashSubCmds command)
-{
- static const std::unordered_map<FlashSubCmds, IpmiFlashHandler>
- subHandlers = {
- {FlashSubCmds::flashStartTransfer, startTransfer},
- {FlashSubCmds::flashDataBlock, dataBlock},
- {FlashSubCmds::flashDataFinish, dataFinish},
- {FlashSubCmds::flashStartHash, startHash},
- {FlashSubCmds::flashHashData, hashBlock},
- {FlashSubCmds::flashHashFinish, hashFinish},
- {FlashSubCmds::flashDataVerify, dataVerify},
- {FlashSubCmds::flashAbort, abortUpdate},
- {FlashSubCmds::flashVerifyCheck, checkVerify},
- };
-
- auto results = subHandlers.find(command);
- if (results == subHandlers.end())
- {
- return nullptr;
- }
-
- return results->second;
-}
-
-bool validateRequestLength(FlashSubCmds command, size_t requestLen)
-{
- static const std::unordered_map<FlashSubCmds, size_t> minimumLengths = {
- {FlashSubCmds::flashStartTransfer, sizeof(struct StartTx)},
- {FlashSubCmds::flashDataBlock, sizeof(struct ChunkHdr) + 1},
- {FlashSubCmds::flashStartHash, sizeof(struct StartTx)},
- {FlashSubCmds::flashHashData, sizeof(struct ChunkHdr) + 1},
- };
-
- auto results = minimumLengths.find(command);
- if (results == minimumLengths.end())
- {
- /* Valid length by default if we don't care. */
- return true;
- }
-
- /* If the request is shorter than the minimum, it's invalid. */
- if (requestLen < results->second)
- {
- return false;
- }
-
- return true;
-}
-
-ipmi_ret_t startTransfer(UpdateInterface* updater, const uint8_t* reqBuf,
- uint8_t* replyBuf, size_t* dataLen)
-{
- auto request = reinterpret_cast<const struct StartTx*>(reqBuf);
-
- if (!updater->start(request->length))
- {
- return IPMI_CC_INVALID;
- }
-
- /* We were successful and set the response byte to 0. */
- replyBuf[0] = 0x00;
- (*dataLen) = 1;
- return IPMI_CC_OK;
-}
-
-ipmi_ret_t dataBlock(UpdateInterface* updater, const uint8_t* reqBuf,
- uint8_t* replyBuf, size_t* dataLen)
-{
- struct ChunkHdr hdr;
- std::memcpy(&hdr, reqBuf, sizeof(hdr));
-
- auto requestLength = *dataLen;
-
- /* Grab the bytes from the packet. */
- auto bytesLength = requestLength - sizeof(struct ChunkHdr);
- std::vector<uint8_t> bytes(bytesLength);
- std::memcpy(bytes.data(), &reqBuf[sizeof(struct ChunkHdr)], bytesLength);
-
- if (!updater->flashData(hdr.offset, bytes))
- {
- return IPMI_CC_INVALID;
- }
-
- /* We were successful and set the response byte to 0. */
- replyBuf[0] = 0x00;
- (*dataLen) = 1;
- return IPMI_CC_OK;
-}
-
-ipmi_ret_t dataFinish(UpdateInterface* updater, const uint8_t* reqBuf,
- uint8_t* replyBuf, size_t* dataLen)
-{
- if (!updater->flashFinish())
- {
- return IPMI_CC_INVALID;
- }
-
- /* TODO: If all commands return this on success, handle it in one place. */
-
- /* We were successful and set the response byte to 0. */
- replyBuf[0] = 0x00;
- (*dataLen) = 1;
- return IPMI_CC_OK;
-}
-
-ipmi_ret_t startHash(UpdateInterface* updater, const uint8_t* reqBuf,
- uint8_t* replyBuf, size_t* dataLen)
-{
- auto request = reinterpret_cast<const struct StartTx*>(reqBuf);
-
- if (!updater->startHash(request->length))
- {
- return IPMI_CC_INVALID;
- }
-
- /* We were successful and set the response byte to 0. */
- replyBuf[0] = 0x00;
- (*dataLen) = 1;
- return IPMI_CC_OK;
-}
-
-ipmi_ret_t hashBlock(UpdateInterface* updater, const uint8_t* reqBuf,
- uint8_t* replyBuf, size_t* dataLen)
-{
- struct ChunkHdr hdr;
- std::memcpy(&hdr, reqBuf, sizeof(hdr));
-
- auto requestLength = *dataLen;
-
- /* Grab the bytes from the packet. */
- auto bytesLength = requestLength - sizeof(struct ChunkHdr);
- std::vector<uint8_t> bytes(bytesLength);
- std::memcpy(bytes.data(), &reqBuf[sizeof(struct ChunkHdr)], bytesLength);
-
- /* TODO: Refactor this and dataBlock for re-use. */
-
- if (!updater->hashData(hdr.offset, bytes))
- {
- return IPMI_CC_INVALID;
- }
-
- /* We were successful and set the response byte to 0. */
- replyBuf[0] = 0x00;
- (*dataLen) = 1;
- return IPMI_CC_OK;
-}
-
-ipmi_ret_t hashFinish(UpdateInterface* updater, const uint8_t* reqBuf,
- uint8_t* replyBuf, size_t* dataLen)
-{
- if (!updater->hashFinish())
- {
- return IPMI_CC_INVALID;
- }
-
- /* We were successful and set the response byte to 0. */
- replyBuf[0] = 0x00;
- (*dataLen) = 1;
- return IPMI_CC_OK;
-}
-
-ipmi_ret_t dataVerify(UpdateInterface* updater, const uint8_t* reqBuf,
- uint8_t* replyBuf, size_t* dataLen)
-{
- if (!updater->startDataVerification())
- {
- return IPMI_CC_INVALID;
- }
-
- /* We were successful and set the response byte to 0. */
- replyBuf[0] = 0x00;
- (*dataLen) = 1;
- return IPMI_CC_OK;
-}
-
-ipmi_ret_t abortUpdate(UpdateInterface* updater, const uint8_t* reqBuf,
- uint8_t* replyBuf, size_t* dataLen)
-{
- /* TODO: May make sense to work all the pass-through commands into one
- * piece of code
- */
- if (!updater->abortUpdate())
- {
- return IPMI_CC_INVALID;
- }
-
- /* We were successful and set the response byte to 0. */
- replyBuf[0] = 0x00;
- (*dataLen) = 1;
- return IPMI_CC_OK;
-}
-
-ipmi_ret_t checkVerify(UpdateInterface* updater, const uint8_t* reqBuf,
- uint8_t* replyBuf, size_t* dataLen)
-{
- auto value = updater->checkVerify();
- replyBuf[0] = static_cast<uint8_t>(value);
- (*dataLen) = 1;
- return IPMI_CC_OK;
-}
diff --git a/ipmi.hpp b/ipmi.hpp
deleted file mode 100644
index 5950ec5..0000000
--- a/ipmi.hpp
+++ /dev/null
@@ -1,145 +0,0 @@
-#pragma once
-
-#include "flash-ipmi.hpp"
-
-#include <functional>
-
-#include "host-ipmid/ipmid-api.h"
-
-using IpmiFlashHandler =
- std::function<ipmi_ret_t(UpdateInterface* updater, const uint8_t* reqBuf,
- uint8_t* replyBuf, size_t* dataLen)>;
-
-/**
- * Retrieve the IPMI command handler.
- *
- * @param[in] subcommand - the command
- * @return the function to call or nullptr on error.
- */
-IpmiFlashHandler getCommandHandler(FlashSubCmds command);
-
-/**
- * Validate the minimum request length if there is one.
- *
- * @param[in] subcommand - the command
- * @param[in] requestLength - the length of the request
- * @return bool - true if valid.
- */
-bool validateRequestLength(FlashSubCmds command, size_t requestLen);
-
-/**
- * Prepare to receive a BMC image and then a signature.
- *
- * @param[in] updater - Pointer to Updater object.
- * @param[in] reqBuf - the IPMI packet.
- * @param[in] replyBuf - Pointer to buffer for any response.
- * @param[in,out] dataLen - Initially reqBuf length, set to replyBuf
- * length when done.
- * @return corresponding IPMI return code.
- */
-ipmi_ret_t startTransfer(UpdateInterface* updater, const uint8_t* reqBuf,
- uint8_t* replyBuf, size_t* dataLen);
-
-/**
- * Receive a flash image data block and store it.
- *
- * @param[in] updater - Pointer to Updater object.
- * @param[in] reqBuf - the IPMI packet.
- * @param[in] replyBuf - Pointer to buffer for any response.
- * @param[in,out] dataLen - Initially reqBuf length, set to replyBuf
- * length when done.
- * @return corresponding IPMI return code.
- */
-ipmi_ret_t dataBlock(UpdateInterface* updater, const uint8_t* reqBuf,
- uint8_t* replyBuf, size_t* dataLen);
-
-/**
- * Indicate all flash data has been sent.
- *
- * @param[in] updater - Pointer to Updater object.
- * @param[in] reqBuf - the IPMI packet.
- * @param[in] replyBuf - Pointer to buffer for any response.
- * @param[in,out] dataLen - Initially reqBuf length, set to replyBuf
- * length when done.
- * @return corresponding IPMI return code.
- */
-ipmi_ret_t dataFinish(UpdateInterface* updater, const uint8_t* reqBuf,
- uint8_t* replyBuf, size_t* dataLen);
-
-/**
- * Prepare to receive a BMC image signature.
- *
- * @param[in] updater - Pointer to Updater object.
- * @param[in] reqBuf - the IPMI packet.
- * @param[in] replyBuf - Pointer to buffer for any response.
- * @param[in,out] dataLen - Initially reqBuf length, set to replyBuf
- * length when done.
- * @return corresponding IPMI return code.
- */
-ipmi_ret_t startHash(UpdateInterface* updater, const uint8_t* reqBuf,
- uint8_t* replyBuf, size_t* dataLen);
-
-/**
- * Receive a flash hash data block and store it.
- *
- * @param[in] updater - Pointer to Updater object.
- * @param[in] reqBuf - the IPMI packet.
- * @param[in] replyBuf - Pointer to buffer for any response.
- * @param[in,out] dataLen - Initially reqBuf length, set to replyBuf
- * length when done.
- * @return corresponding IPMI return code.
- */
-ipmi_ret_t hashBlock(UpdateInterface* updater, const uint8_t* reqBuf,
- uint8_t* replyBuf, size_t* dataLen);
-
-/**
- * Indicate all hash data has been sent.
- *
- * @param[in] updater - Pointer to Updater object.
- * @param[in] reqBuf - the IPMI packet.
- * @param[in] replyBuf - Pointer to buffer for any response.
- * @param[in,out] dataLen - Initially reqBuf length, set to replyBuf
- * length when done.
- * @return corresponding IPMI return code.
- */
-ipmi_ret_t hashFinish(UpdateInterface* updater, const uint8_t* reqBuf,
- uint8_t* replyBuf, size_t* dataLen);
-
-/**
- * Start the flash image verification process (whatever that is).
- *
- * @param[in] updater - Pointer to Updater object.
- * @param[in] reqBuf - the IPMI packet.
- * @param[in] replyBuf - Pointer to buffer for any response.
- * @param[in,out] dataLen - Initially reqBuf length, set to replyBuf
- * length when done.
- * @return corresponding IPMI return code.
- */
-ipmi_ret_t dataVerify(UpdateInterface* updater, const uint8_t* reqBuf,
- uint8_t* replyBuf, size_t* dataLen);
-
-/**
- * Abort the image update process.
- *
- * @param[in] updater - Pointer to Updater object.
- * @param[in] reqBuf - the IPMI packet.
- * @param[in] replyBuf - Pointer to buffer for any response.
- * @param[in,out] dataLen - Initially reqBuf length, set to replyBuf
- * length when done.
- * @return corresponding IPMI return code.
- */
-ipmi_ret_t abortUpdate(UpdateInterface* updater, const uint8_t* reqBuf,
- uint8_t* replyBuf, size_t* dataLen);
-
-/**
- * Check on the status of the verification process.
- *
- * @param[in] updater - Pointer to Updater object.
- * @param[in] reqBuf - the IPMI packet.
- * @param[in] replyBuf - Pointer to buffer for any response.
- * @param[in,out] dataLen - Initially reqBuf length, set to replyBuf
- * length when done.
- * @return corresponding IPMI return code.
- */
-ipmi_ret_t checkVerify(UpdateInterface* updater, const uint8_t* reqBuf,
- uint8_t* replyBuf, size_t* dataLen);
diff --git a/main.cpp b/main.cpp
deleted file mode 100644
index 7720f33..0000000
--- a/main.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright 2018 Google Inc.
- *
- * 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.
- */
-
-#include "config.h"
-
-#include "flash-ipmi.hpp"
-#include "ipmi.hpp"
-
-#include <host-ipmid/ipmid-api.h>
-
-#include <host-ipmid/iana.hpp>
-#include <host-ipmid/oemrouter.hpp>
-#include <memory>
-
-static constexpr auto stagingPath = STAGING_PATH;
-static constexpr auto hashPath = HASH_PATH;
-static constexpr auto statusPath = STATUS_PATH;
-
-/* TODO: Once OEM IPMI number placement is settled, point to that. */
-namespace oem
-{
-namespace google
-{
-constexpr int flashOverBTCmd = 127;
-} // namespace google
-} // namespace oem
-
-/* We have one instance of the FlashUpdate object tracking commands. */
-std::unique_ptr<FlashUpdate> flashUpdateSingleton;
-
-static ipmi_ret_t flashControl(ipmi_cmd_t cmd, const uint8_t* reqBuf,
- uint8_t* replyCmdBuf, size_t* dataLen)
-{
- size_t requestLength = (*dataLen);
-
- /* Verify it's at least as long as the shortest message. */
- if (requestLength < 1)
- {
- return IPMI_CC_INVALID;
- }
-
- auto subCmd = static_cast<FlashSubCmds>(reqBuf[0]);
-
- /* Validate the minimum request length for the command. */
- if (!validateRequestLength(subCmd, requestLength))
- {
- return IPMI_CC_INVALID;
- }
-
- auto handler = getCommandHandler(subCmd);
- if (handler)
- {
- return handler(flashUpdateSingleton.get(), reqBuf, replyCmdBuf,
- dataLen);
- }
-
- return IPMI_CC_INVALID;
-}
-
-static ipmi_ret_t ipmiFlashControl(ipmi_netfn_t netFn, ipmi_cmd_t cmd,
- ipmi_request_t request,
- ipmi_response_t response,
- ipmi_data_len_t dataLen,
- ipmi_context_t context)
-{
- /* request_t, response_t are void*. ipmi_data_len_t is a size_t* */
- auto reqBuf = static_cast<const uint8_t*>(request);
- auto replyCmdBuf = static_cast<uint8_t*>(response);
-
- return flashControl(cmd, reqBuf, replyCmdBuf, dataLen);
-}
-
-void setupGlobalOemFlashControl() __attribute__((constructor));
-
-void setupGlobalOemFlashControl()
-{
- flashUpdateSingleton = std::make_unique<FlashUpdate>(
- sdbusplus::bus::new_default(), stagingPath, statusPath, hashPath);
-
-#ifdef ENABLE_GOOGLE
- oem::Router* router = oem::mutableRouter();
-
- fprintf(stderr, "Registering OEM:[%#08X], Cmd:[%#04X] for Flash Update\n",
- oem::googOemNumber, oem::google::flashOverBTCmd);
-
- router->registerHandler(oem::googOemNumber, oem::google::flashOverBTCmd,
- flashControl);
-#endif
-
- ipmi_register_callback(NETFUN_FIRMWARE, oem::google::flashOverBTCmd, NULL,
- ipmiFlashControl, PRIVILEGE_USER);
-}
diff --git a/test/Makefile.am b/test/Makefile.am
deleted file mode 100644
index c6f2bc2..0000000
--- a/test/Makefile.am
+++ /dev/null
@@ -1,90 +0,0 @@
-AM_CPPFLAGS = -I$(top_srcdir)/ \
- $(GTEST_CFLAGS) \
- $(GMOCK_CFLAGS)
-AM_CXXFLAGS = \
- $(GTEST_MAIN_CFLAGS)
-AM_LDFLAGS = \
- $(GMOCK_LIBS) \
- $(GTEST_MAIN_LIBS) \
- $(OESDK_TESTCASE_FLAGS)
-
-# Run all 'check' test programs
-check_PROGRAMS = \
- ipmi_starttransfer_unittest \
- ipmi_flashdata_unittest \
- ipmi_flashfinish_unittest \
- ipmi_starthash_unittest \
- ipmi_hashdata_unittest \
- ipmi_hashfinish_unittest \
- ipmi_startverify_unittest \
- ipmi_abort_unittest \
- ipmi_validate_unittest \
- ipmi_command_unittest \
- ipmi_verifycheck_unittest \
- flash_start_unittest \
- flash_flashdata_unittest \
- flash_flashfinish_unittest \
- flash_hashstart_unittest \
- flash_hashdata_unittest \
- flash_hashfinish_unittest \
- flash_checkverify_unittest \
- flash_flashabort_unittest
-
-TESTS = $(check_PROGRAMS)
-
-ipmi_starttransfer_unittest_SOURCES = ipmi_starttransfer_unittest.cpp
-ipmi_starttransfer_unittest_LDADD = $(top_builddir)/ipmi.o
-
-ipmi_flashdata_unittest_SOURCES = ipmi_flashdata_unittest.cpp
-ipmi_flashdata_unittest_LDADD = $(top_builddir)/ipmi.o
-
-ipmi_flashfinish_unittest_SOURCES = ipmi_flashfinish_unittest.cpp
-ipmi_flashfinish_unittest_LDADD = $(top_builddir)/ipmi.o
-
-ipmi_starthash_unittest_SOURCES = ipmi_starthash_unittest.cpp
-ipmi_starthash_unittest_LDADD = $(top_builddir)/ipmi.o
-
-ipmi_hashdata_unittest_SOURCES = ipmi_hashdata_unittest.cpp
-ipmi_hashdata_unittest_LDADD = $(top_builddir)/ipmi.o
-
-ipmi_hashfinish_unittest_SOURCES = ipmi_hashfinish_unittest.cpp
-ipmi_hashfinish_unittest_LDADD = $(top_builddir)/ipmi.o
-
-ipmi_startverify_unittest_SOURCES = ipmi_startverify_unittest.cpp
-ipmi_startverify_unittest_LDADD = $(top_builddir)/ipmi.o
-
-ipmi_abort_unittest_SOURCES = ipmi_abort_unittest.cpp
-ipmi_abort_unittest_LDADD = $(top_builddir)/ipmi.o
-
-ipmi_validate_unittest_SOURCES = ipmi_validate_unittest.cpp
-ipmi_validate_unittest_LDADD = $(top_builddir)/ipmi.o
-
-ipmi_command_unittest_SOURCES = ipmi_command_unittest.cpp
-ipmi_command_unittest_LDADD = $(top_builddir)/ipmi.o
-
-ipmi_verifycheck_unittest_SOURCES = ipmi_verifycheck_unittest.cpp
-ipmi_verifycheck_unittest_LDADD = $(top_builddir)/ipmi.o
-
-flash_start_unittest_SOURCES = flash_start_unittest.cpp
-flash_start_unittest_LDADD = $(top_builddir)/flash-ipmi.o $(SDBUSPLUS_LIBS)
-
-flash_flashdata_unittest_SOURCES = flash_flashdata_unittest.cpp
-flash_flashdata_unittest_LDADD = $(top_builddir)/flash-ipmi.o $(SDBUSPLUS_LIBS)
-
-flash_flashfinish_unittest_SOURCES = flash_flashfinish_unittest.cpp
-flash_flashfinish_unittest_LDADD = $(top_builddir)/flash-ipmi.o $(SDBUSPLUS_LIBS)
-
-flash_hashstart_unittest_SOURCES = flash_hashstart_unittest.cpp
-flash_hashstart_unittest_LDADD = $(top_builddir)/flash-ipmi.o $(SDBUSPLUS_LIBS)
-
-flash_hashdata_unittest_SOURCES = flash_hashdata_unittest.cpp
-flash_hashdata_unittest_LDADD = $(top_builddir)/flash-ipmi.o $(SDBUSPLUS_LIBS)
-
-flash_hashfinish_unittest_SOURCES = flash_hashfinish_unittest.cpp
-flash_hashfinish_unittest_LDADD = $(top_builddir)/flash-ipmi.o $(SDBUSPLUS_LIBS)
-
-flash_checkverify_unittest_SOURCES = flash_checkverify_unittest.cpp
-flash_checkverify_unittest_LDADD = $(top_builddir)/flash-ipmi.o $(SDBUSPLUS_LIBS)
-
-flash_flashabort_unittest_SOURCES = flash_flashabort_unittest.cpp
-flash_flashabort_unittest_LDADD = $(top_builddir)/flash-ipmi.o $(SDBUSPLUS_LIBS)
diff --git a/test/flash_checkverify_unittest.cpp b/test/flash_checkverify_unittest.cpp
deleted file mode 100644
index f55beff..0000000
--- a/test/flash_checkverify_unittest.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-#include "flash-ipmi.hpp"
-
-#include <cstdio>
-#include <fstream>
-#include <sdbusplus/test/sdbus_mock.hpp>
-#include <string>
-#include <vector>
-
-#include <gtest/gtest.h>
-
-class FlashIpmiCheckVerifyTest : public ::testing::Test
-{
- protected:
- FlashIpmiCheckVerifyTest() = default;
-
- void SetUp() override
- {
- name = std::tmpnam(nullptr);
- }
- void TearDown() override
- {
- (void)std::remove(name.c_str());
- }
-
- std::string name;
-};
-
-TEST_F(FlashIpmiCheckVerifyTest, VerifyItReturnsFileContents)
-{
- // If the file is present, the value can be a string and we convert it to
- // an enum.
-
- struct Expect
- {
- std::string value;
- VerifyCheckResponse response;
- };
-
- std::vector<Expect> tests = {
- {"running", VerifyCheckResponse::running},
- {"success", VerifyCheckResponse::success},
- {"failed", VerifyCheckResponse::failed},
- {"asdf", VerifyCheckResponse::other},
- };
-
- std::string vname = std::tmpnam(nullptr);
-
- sdbusplus::SdBusMock sdbus_mock;
- auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock);
-
- FlashUpdate updater(std::move(bus_mock), name, vname);
-
- for (const auto& test : tests)
- {
- std::ofstream out;
- out.open(vname);
- out << test.value << std::endl;
- out.close();
-
- EXPECT_EQ(test.response, updater.checkVerify());
-
- (void)std::remove(vname.c_str());
- }
-}
diff --git a/test/flash_flashabort_unittest.cpp b/test/flash_flashabort_unittest.cpp
deleted file mode 100644
index e077aa6..0000000
--- a/test/flash_flashabort_unittest.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-#include "flash-ipmi.hpp"
-
-#include <cstdio>
-#include <cstring>
-#include <sdbusplus/test/sdbus_mock.hpp>
-#include <string>
-
-#include <gtest/gtest.h>
-
-#define THIRTYTWO_MIB 33554432
-
-using ::testing::IsNull;
-using ::testing::NotNull;
-using ::testing::Return;
-using ::testing::StrEq;
-
-TEST(FlashIpmiAbortTest, VerifyItDeletesAndStopsServiced)
-{
- // Verify that once everything is started, the image and hash are deleted
- // and it will try to stop the verification service.
-
- std::string iname = std::tmpnam(nullptr);
- std::string vname = std::tmpnam(nullptr);
- std::string hname = std::tmpnam(nullptr);
-
- sdbusplus::SdBusMock sdbus_mock;
- auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock);
-
- FlashUpdate updater(std::move(bus_mock), iname, vname, hname);
-
- std::vector<uint8_t> ibytes = {0xaa, 0x55};
- std::vector<uint8_t> hbytes = {0xcc, 0x65};
-
- // Send the bytes up for the image.
- EXPECT_TRUE(updater.start(THIRTYTWO_MIB));
- EXPECT_TRUE(updater.flashData(0, ibytes));
- EXPECT_TRUE(updater.flashFinish());
-
- // Send the bytes up for the hash.
- EXPECT_TRUE(updater.startHash(THIRTYTWO_MIB));
- EXPECT_TRUE(updater.hashData(0, hbytes));
- EXPECT_TRUE(updater.hashFinish());
-
- // Verify the image bytes.
- auto file = std::fopen(iname.c_str(), "r");
- EXPECT_TRUE(file);
- uint8_t buffer[2];
- auto read = std::fread(buffer, 1, ibytes.size(), file);
- EXPECT_EQ(read, ibytes.size());
- EXPECT_EQ(0, std::memcmp(buffer, ibytes.data(), ibytes.size()));
- std::fclose(file);
-
- // Verify the hash bytes.
- file = std::fopen(hname.c_str(), "r");
- EXPECT_TRUE(file);
- read = std::fread(buffer, 1, hbytes.size(), file);
- EXPECT_EQ(read, hbytes.size());
- EXPECT_EQ(0, std::memcmp(buffer, hbytes.data(), hbytes.size()));
- std::fclose(file);
-
- EXPECT_CALL(sdbus_mock,
- sd_bus_message_new_method_call(
- IsNull(), NotNull(), StrEq("org.freedesktop.systemd1"),
- StrEq("/org/freedesktop/systemd1"),
- StrEq("org.freedesktop.systemd1.Manager"),
- StrEq("StopUnit")))
- .WillOnce(Return(0));
-
- // Send the abort.
- EXPECT_TRUE(updater.abortUpdate());
-
- // Verify the files are gone.
- file = std::fopen(iname.c_str(), "r");
- EXPECT_FALSE(file);
- file = std::fopen(hname.c_str(), "r");
- EXPECT_FALSE(file);
-}
diff --git a/test/flash_flashdata_unittest.cpp b/test/flash_flashdata_unittest.cpp
deleted file mode 100644
index 6b12873..0000000
--- a/test/flash_flashdata_unittest.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-#include "flash-ipmi.hpp"
-
-#include <cstdio>
-#include <cstring>
-#include <sdbusplus/test/sdbus_mock.hpp>
-#include <string>
-#include <vector>
-
-#include <gtest/gtest.h>
-
-#define THIRTYTWO_MIB 33554432
-
-class FlashIpmiFlashDataTest : public ::testing::Test
-{
- protected:
- FlashIpmiFlashDataTest() = default;
-
- void SetUp() override
- {
- name = std::tmpnam(nullptr);
- }
- void TearDown() override
- {
- (void)std::remove(name.c_str());
- }
-
- std::string name;
-};
-
-TEST_F(FlashIpmiFlashDataTest, CalledOutOfSequenceFails)
-{
- // Verify that there is sanity checking.
- std::vector<uint8_t> bytes = {0xaa, 0x55};
-
- sdbusplus::SdBusMock sdbus_mock;
- auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock);
-
- FlashUpdate updater(std::move(bus_mock), name, "");
- EXPECT_FALSE(updater.flashData(0, bytes));
-
- // Verify the file doesn't exist.
- auto file = std::fopen(name.c_str(), "r");
- EXPECT_FALSE(file);
-}
-
-TEST_F(FlashIpmiFlashDataTest, CalledWithDataSucceeds)
-{
- // Verify that under normal usage it writes the bytes.
- std::vector<uint8_t> bytes = {0xaa, 0x55};
-
- sdbusplus::SdBusMock sdbus_mock;
- auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock);
-
- FlashUpdate updater(std::move(bus_mock), name, "");
- updater.start(THIRTYTWO_MIB);
- EXPECT_TRUE(updater.flashData(0, bytes));
-
- auto file = std::fopen(name.c_str(), "r");
- EXPECT_TRUE(file);
-
- uint8_t buffer[2];
- auto read = std::fread(buffer, 1, bytes.size(), file);
- EXPECT_EQ(read, bytes.size());
- EXPECT_EQ(0, std::memcmp(buffer, bytes.data(), bytes.size()));
- std::fclose(file);
-}
-
-TEST_F(FlashIpmiFlashDataTest, CalledNonZeroOffsetSucceeds)
-{
- // Skipping bytes in POSIX can create a sparse file. In this case,
- // let's allow the behavior. If we'd rather, we can have writeBlock
- // check that the offset is where we expect.
-
- std::vector<uint8_t> bytes = {0xaa, 0x55};
-
- sdbusplus::SdBusMock sdbus_mock;
- auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock);
-
- FlashUpdate updater(std::move(bus_mock), name, "");
- updater.start(THIRTYTWO_MIB);
- EXPECT_TRUE(updater.flashData(2, bytes));
-
- auto file = std::fopen(name.c_str(), "r");
- EXPECT_TRUE(file);
-
- uint8_t buffer[4];
- auto read = std::fread(buffer, 1, sizeof(buffer), file);
- EXPECT_EQ(read, sizeof(buffer));
- EXPECT_EQ(0, std::memcmp(&buffer[2], bytes.data(), bytes.size()));
- std::fclose(file);
-}
diff --git a/test/flash_flashfinish_unittest.cpp b/test/flash_flashfinish_unittest.cpp
deleted file mode 100644
index cf03864..0000000
--- a/test/flash_flashfinish_unittest.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-#include "flash-ipmi.hpp"
-
-#include <cstdio>
-#include <cstring>
-#include <sdbusplus/test/sdbus_mock.hpp>
-#include <string>
-#include <vector>
-
-#include <gtest/gtest.h>
-
-#define THIRTYTWO_MIB 33554432
-
-class FlashIpmiFlashDataTest : public ::testing::Test
-{
- protected:
- FlashIpmiFlashDataTest() = default;
-
- void SetUp() override
- {
- name = std::tmpnam(nullptr);
- }
- void TearDown() override
- {
- (void)std::remove(name.c_str());
- }
-
- std::string name;
-};
-
-TEST_F(FlashIpmiFlashDataTest, CalledOutOfSequenceFails)
-{
- // Verify that there is sanity checking
- std::vector<uint8_t> bytes = {0xaa, 0x55};
-
- sdbusplus::SdBusMock sdbus_mock;
- auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock);
-
- FlashUpdate updater(std::move(bus_mock), name, "");
- EXPECT_FALSE(updater.flashFinish());
-
- // Verify the file doesn't exist.
- auto file = std::fopen(name.c_str(), "r");
- EXPECT_FALSE(file);
-}
-
-TEST_F(FlashIpmiFlashDataTest, CalledInSequenceSucceeds)
-{
- // Verify that under normal usage it closes the file.
- std::vector<uint8_t> bytes = {0xaa, 0x55};
-
- sdbusplus::SdBusMock sdbus_mock;
- auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock);
-
- FlashUpdate updater(std::move(bus_mock), name, "");
- updater.start(THIRTYTWO_MIB);
- EXPECT_TRUE(updater.flashFinish());
-
- // Verify we can open the file, so we know it didn't get deleted.
- auto file = std::fopen(name.c_str(), "r");
- EXPECT_TRUE(file);
- std::fclose(file);
-}
-
-TEST_F(FlashIpmiFlashDataTest, CalledTwiceFails)
-{
- // Verify that under normal usage it closes the file, and therefore cannot
- // be closed twice.
- std::vector<uint8_t> bytes = {0xaa, 0x55};
-
- sdbusplus::SdBusMock sdbus_mock;
- auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock);
-
- FlashUpdate updater(std::move(bus_mock), name, "");
- updater.start(THIRTYTWO_MIB);
- EXPECT_TRUE(updater.flashFinish());
-
- EXPECT_FALSE(updater.flashFinish());
-
- // Verify we can open the file, so we know it didn't get deleted.
- auto file = std::fopen(name.c_str(), "r");
- EXPECT_TRUE(file);
- std::fclose(file);
-}
diff --git a/test/flash_hashdata_unittest.cpp b/test/flash_hashdata_unittest.cpp
deleted file mode 100644
index a438be7..0000000
--- a/test/flash_hashdata_unittest.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-#include "flash-ipmi.hpp"
-
-#include <cstdio>
-#include <cstring>
-#include <sdbusplus/test/sdbus_mock.hpp>
-#include <string>
-#include <vector>
-
-#include <gtest/gtest.h>
-
-#define THIRTYTWO_MIB 33554432
-
-class FlashIpmiHashDataTest : public ::testing::Test
-{
- protected:
- FlashIpmiHashDataTest() = default;
-
- void SetUp() override
- {
- name = std::tmpnam(nullptr);
- name2 = std::tmpnam(nullptr);
- }
- void TearDown() override
- {
- (void)std::remove(name.c_str());
- (void)std::remove(name2.c_str());
- }
-
- std::string name;
- std::string name2;
-};
-
-TEST_F(FlashIpmiHashDataTest, CalledOutOfSequenceFails)
-{
- // Verify that if you try to write to the hash before starting, it'll fail.
- // Presently, start() will open the hash file.
-
- std::vector<uint8_t> bytes = {0xaa, 0x55};
-
- sdbusplus::SdBusMock sdbus_mock;
- auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock);
-
- FlashUpdate updater(std::move(bus_mock), name, "", name2);
- EXPECT_FALSE(updater.hashData(0, bytes));
-}
-
-TEST_F(FlashIpmiHashDataTest, CalledWithDataSucceeds)
-{
- // Verify the normal use case works.
- std::vector<uint8_t> bytes = {0xaa, 0x55};
-
- sdbusplus::SdBusMock sdbus_mock;
- auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock);
-
- FlashUpdate updater(std::move(bus_mock), name, "", name2);
- EXPECT_TRUE(updater.start(THIRTYTWO_MIB));
- EXPECT_TRUE(updater.startHash(THIRTYTWO_MIB));
- EXPECT_TRUE(updater.hashData(0, bytes));
-
- auto file = std::fopen(name2.c_str(), "r");
- EXPECT_TRUE(file);
-
- uint8_t buffer[2];
- auto read = std::fread(buffer, 1, bytes.size(), file);
- EXPECT_EQ(read, bytes.size());
- EXPECT_EQ(0, std::memcmp(buffer, bytes.data(), bytes.size()));
- std::fclose(file);
-}
-
-TEST_F(FlashIpmiHashDataTest, CalledNonZeroOffsetSucceeds)
-{
- // Skipping bytes in POSIX can create a sparse file. In this case,
- // let's allow the behavior. If we'd rather, we can have writeBlock
- // check that the offset is where we expect.
-
- std::vector<uint8_t> bytes = {0xaa, 0x55};
-
- sdbusplus::SdBusMock sdbus_mock;
- auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock);
-
- FlashUpdate updater(std::move(bus_mock), name, "", name2);
- EXPECT_TRUE(updater.start(THIRTYTWO_MIB));
- EXPECT_TRUE(updater.startHash(THIRTYTWO_MIB));
- EXPECT_TRUE(updater.hashData(2, bytes));
-
- auto file = std::fopen(name2.c_str(), "r");
- EXPECT_TRUE(file);
-
- uint8_t buffer[4];
- auto read = std::fread(buffer, 1, sizeof(buffer), file);
- EXPECT_EQ(read, sizeof(buffer));
- EXPECT_EQ(0, std::memcmp(&buffer[2], bytes.data(), bytes.size()));
- std::fclose(file);
-}
diff --git a/test/flash_hashfinish_unittest.cpp b/test/flash_hashfinish_unittest.cpp
deleted file mode 100644
index 3bc36b4..0000000
--- a/test/flash_hashfinish_unittest.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-#include "flash-ipmi.hpp"
-
-#include <cstdio>
-#include <cstring>
-#include <sdbusplus/test/sdbus_mock.hpp>
-#include <string>
-#include <vector>
-
-#include <gtest/gtest.h>
-
-#define THIRTYTWO_MIB 33554432
-
-class FlashIpmiHashDataTest : public ::testing::Test
-{
- protected:
- FlashIpmiHashDataTest() = default;
-
- void SetUp() override
- {
- name = std::tmpnam(nullptr);
- name2 = std::tmpnam(nullptr);
- }
- void TearDown() override
- {
- (void)std::remove(name.c_str());
- (void)std::remove(name2.c_str());
- }
-
- std::string name;
- std::string name2;
-};
-
-TEST_F(FlashIpmiHashDataTest, CalledOutOfSequenceFails)
-{
- // Verify that there is sanity checking
- std::vector<uint8_t> bytes = {0xaa, 0x55};
-
- sdbusplus::SdBusMock sdbus_mock;
- auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock);
-
- FlashUpdate updater(std::move(bus_mock), name, "", name2);
- EXPECT_FALSE(updater.hashFinish());
-
- // Verify the file doesn't exist.
- auto file = std::fopen(name2.c_str(), "r");
- EXPECT_FALSE(file);
-}
-
-TEST_F(FlashIpmiHashDataTest, CalledInSequenceSucceeds)
-{
- // Verify that under normal usage it closes the file.
- std::vector<uint8_t> bytes = {0xaa, 0x55};
-
- sdbusplus::SdBusMock sdbus_mock;
- auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock);
-
- FlashUpdate updater(std::move(bus_mock), name, "", name2);
- EXPECT_TRUE(updater.start(THIRTYTWO_MIB));
- EXPECT_TRUE(updater.startHash(THIRTYTWO_MIB));
- EXPECT_TRUE(updater.hashFinish());
-
- // Verify we can open the file, so we know it didn't get deleted.
- auto file = std::fopen(name2.c_str(), "r");
- EXPECT_TRUE(file);
- std::fclose(file);
-}
-
-TEST_F(FlashIpmiHashDataTest, CalledTwiceFails)
-{
- // Verify that under normal usage it closes the file, and therefore cannot
- // be closed twice.
- std::vector<uint8_t> bytes = {0xaa, 0x55};
-
- sdbusplus::SdBusMock sdbus_mock;
- auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock);
-
- FlashUpdate updater(std::move(bus_mock), name, "", name2);
- EXPECT_TRUE(updater.start(THIRTYTWO_MIB));
- EXPECT_TRUE(updater.startHash(THIRTYTWO_MIB));
- EXPECT_TRUE(updater.hashFinish());
-
- EXPECT_FALSE(updater.hashFinish());
-
- // Verify we can open the file, so we know it didn't get deleted.
- auto file = std::fopen(name2.c_str(), "r");
- EXPECT_TRUE(file);
- std::fclose(file);
-}
diff --git a/test/flash_hashstart_unittest.cpp b/test/flash_hashstart_unittest.cpp
deleted file mode 100644
index d8c1d24..0000000
--- a/test/flash_hashstart_unittest.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-#include "flash-ipmi.hpp"
-
-#include <cstdio>
-#include <sdbusplus/test/sdbus_mock.hpp>
-#include <string>
-
-#include <gtest/gtest.h>
-
-#define THIRTYTWO_MIB 33554432
-
-TEST(FlashIpmiHashStartTest, OutofSequenceFails)
-{
- // Verify that the image must be started first. (can change).
-
- std::string name = std::tmpnam(nullptr);
- std::string name2 = std::tmpnam(nullptr);
-
- sdbusplus::SdBusMock sdbus_mock;
- auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock);
-
- FlashUpdate updater(std::move(bus_mock), name, "", name2);
- EXPECT_FALSE(updater.startHash(THIRTYTWO_MIB));
-
- (void)std::remove(name.c_str());
- (void)std::remove(name2.c_str());
-}
-
-TEST(FlashIpmiHashStartTest, VerifyHashFileCreated)
-{
- // Verify that it's happy.
-
- std::string name = std::tmpnam(nullptr);
- std::string name2 = std::tmpnam(nullptr);
-
- sdbusplus::SdBusMock sdbus_mock;
- auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock);
-
- FlashUpdate updater(std::move(bus_mock), name, "", name2);
- EXPECT_TRUE(updater.start(THIRTYTWO_MIB));
- EXPECT_TRUE(updater.startHash(THIRTYTWO_MIB));
-
- (void)std::remove(name.c_str());
- (void)std::remove(name2.c_str());
-}
diff --git a/test/flash_start_unittest.cpp b/test/flash_start_unittest.cpp
deleted file mode 100644
index 8bf4ba1..0000000
--- a/test/flash_start_unittest.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-#include "flash-ipmi.hpp"
-
-#include <cstdio>
-#include <sdbusplus/test/sdbus_mock.hpp>
-#include <string>
-
-#include <gtest/gtest.h>
-
-#define THIRTYTWO_MIB 33554432
-
-TEST(FlashIpmiStartTest, VerifiesFieldsAndAction)
-{
- // The interface does not currently support failure injection, so let's
- // simply verify it does what we think it should.
-
- sdbusplus::SdBusMock sdbus_mock;
- auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock);
-
- std::string name = std::tmpnam(nullptr);
-
- FlashUpdate updater(std::move(bus_mock), name, "");
- updater.start(THIRTYTWO_MIB);
-
- auto file = std::fopen(name.c_str(), "r");
- EXPECT_TRUE(file);
- std::fclose(file);
- (void)std::remove(name.c_str());
-}
diff --git a/test/ipmi_abort_unittest.cpp b/test/ipmi_abort_unittest.cpp
deleted file mode 100644
index 9c334ec..0000000
--- a/test/ipmi_abort_unittest.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-#include "flash-ipmi.hpp"
-#include "ipmi.hpp"
-#include "updater_mock.hpp"
-
-#include <gtest/gtest.h>
-
-using ::testing::Return;
-using ::testing::StrictMock;
-
-// ipmid.hpp isn't installed where we can grab it and this value is per BMC
-// SoC.
-#define MAX_IPMI_BUFFER 64
-
-TEST(IpmiAbortTest, CallPassedOn)
-{
- // The abort call is another pass-through command.
-
- StrictMock<UpdaterMock> updater;
-
- size_t dataLen;
- uint8_t request[MAX_IPMI_BUFFER] = {0};
- uint8_t reply[MAX_IPMI_BUFFER] = {0};
-
- dataLen = 1; // request is only the command.
- request[0] = FlashSubCmds::flashAbort;
-
- EXPECT_CALL(updater, abortUpdate()).WillOnce(Return(true));
- EXPECT_EQ(IPMI_CC_OK, abortUpdate(&updater, request, reply, &dataLen));
- EXPECT_EQ(sizeof(uint8_t), dataLen);
- EXPECT_EQ(0, reply[0]);
-}
diff --git a/test/ipmi_command_unittest.cpp b/test/ipmi_command_unittest.cpp
deleted file mode 100644
index f0eb8ef..0000000
--- a/test/ipmi_command_unittest.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-#include "ipmi.hpp"
-
-#include <gtest/gtest.h>
-
-namespace
-{
-
-void EqualFunctions(IpmiFlashHandler lhs, IpmiFlashHandler rhs)
-{
- EXPECT_FALSE(lhs == nullptr);
- EXPECT_FALSE(rhs == nullptr);
- ipmi_ret_t (*const* lPtr)(UpdateInterface*, const uint8_t*, uint8_t*,
- size_t*) =
- lhs.target<ipmi_ret_t (*)(UpdateInterface*, const uint8_t*, uint8_t*,
- size_t*)>();
- ipmi_ret_t (*const* rPtr)(UpdateInterface*, const uint8_t*, uint8_t*,
- size_t*) =
- rhs.target<ipmi_ret_t (*)(UpdateInterface*, const uint8_t*, uint8_t*,
- size_t*)>();
- EXPECT_TRUE(lPtr);
- EXPECT_TRUE(rPtr);
- EXPECT_EQ(*lPtr, *rPtr);
- return;
-}
-} // namespace
-
-TEST(IpmiCommandTest, VerifyCommandReturnsExpected)
-{
- // Given a subcommand that's valid, make sure it returns the expected
- // pointer.
-
- auto result = getCommandHandler(FlashSubCmds::flashHashFinish);
- EqualFunctions(hashFinish, result);
-}
-
-TEST(IpmiCommandTest, VerifyInvalidCommandReturnsNull)
-{
- // Given a subcommand that's invalid, make sure it returns the nullptr.
-
- auto result = getCommandHandler(static_cast<FlashSubCmds>(25));
- EXPECT_EQ(result, nullptr);
-}
diff --git a/test/ipmi_flashdata_unittest.cpp b/test/ipmi_flashdata_unittest.cpp
deleted file mode 100644
index f4af2a2..0000000
--- a/test/ipmi_flashdata_unittest.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-#include "flash-ipmi.hpp"
-#include "ipmi.hpp"
-#include "updater_mock.hpp"
-
-#include <cstring>
-
-#include <gtest/gtest.h>
-
-using ::testing::ElementsAreArray;
-using ::testing::Return;
-using ::testing::StrictMock;
-
-// ipmid.hpp isn't installed where we can grab it and this value is per BMC
-// SoC.
-#define MAX_IPMI_BUFFER 64
-
-TEST(IpmiFlashData, DataReceivedIsPassedOnOk)
-{
- // If valid data was passed in, it'll pass it onto the update handler.
-
- StrictMock<UpdaterMock> updater;
-
- size_t dataLen;
- uint8_t request[MAX_IPMI_BUFFER] = {0};
- uint8_t reply[MAX_IPMI_BUFFER] = {0};
-
- struct ChunkHdr tx;
- tx.cmd = FlashSubCmds::flashDataBlock;
- tx.offset = 0x00;
- std::memcpy(request, &tx, sizeof(tx));
-
- uint8_t bytes[] = {0x04, 0x05};
- std::memcpy(&request[sizeof(struct ChunkHdr)], bytes, sizeof(bytes));
-
- dataLen = sizeof(struct ChunkHdr) + sizeof(bytes);
-
- EXPECT_CALL(updater,
- flashData(0x00, ElementsAreArray(bytes, sizeof(bytes))))
- .WillOnce(Return(true));
-
- EXPECT_EQ(IPMI_CC_OK, dataBlock(&updater, request, reply, &dataLen));
- EXPECT_EQ(sizeof(uint8_t), dataLen);
- EXPECT_EQ(0, reply[0]);
-}
diff --git a/test/ipmi_flashfinish_unittest.cpp b/test/ipmi_flashfinish_unittest.cpp
deleted file mode 100644
index f28ff56..0000000
--- a/test/ipmi_flashfinish_unittest.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-#include "flash-ipmi.hpp"
-#include "ipmi.hpp"
-#include "updater_mock.hpp"
-
-#include <cstring>
-
-#include <gtest/gtest.h>
-
-using ::testing::Return;
-using ::testing::StrictMock;
-
-// ipmid.hpp isn't installed where we can grab it and this value is per BMC
-// SoC.
-#define MAX_IPMI_BUFFER 64
-
-TEST(IpmiFlashFinish, CallPassedOn)
-{
- // The data finish command does no validation as the input is empty, and
- // simply relies on the flash manager to do work.
-
- StrictMock<UpdaterMock> updater;
-
- size_t dataLen;
- uint8_t request[MAX_IPMI_BUFFER] = {0};
- uint8_t reply[MAX_IPMI_BUFFER] = {0};
-
- dataLen = 1; // request is only the command.
- request[0] = FlashSubCmds::flashDataFinish;
-
- EXPECT_CALL(updater, flashFinish()).WillOnce(Return(true));
- EXPECT_EQ(IPMI_CC_OK, dataFinish(&updater, request, reply, &dataLen));
- EXPECT_EQ(sizeof(uint8_t), dataLen);
- EXPECT_EQ(0, reply[0]);
-}
diff --git a/test/ipmi_hashdata_unittest.cpp b/test/ipmi_hashdata_unittest.cpp
deleted file mode 100644
index 9725183..0000000
--- a/test/ipmi_hashdata_unittest.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-#include "flash-ipmi.hpp"
-#include "ipmi.hpp"
-#include "updater_mock.hpp"
-
-#include <cstring>
-
-#include <gtest/gtest.h>
-
-using ::testing::ElementsAreArray;
-using ::testing::Return;
-using ::testing::StrictMock;
-
-// ipmid.hpp isn't installed where we can grab it and this value is per BMC
-// SoC.
-#define MAX_IPMI_BUFFER 64
-
-TEST(IpmiHashData, DataReceivedIsPassedOnOk)
-{
- // If valid data was passed in, it'll pass it onto the update handler.
-
- StrictMock<UpdaterMock> updater;
-
- size_t dataLen;
- uint8_t request[MAX_IPMI_BUFFER] = {0};
- uint8_t reply[MAX_IPMI_BUFFER] = {0};
-
- struct ChunkHdr tx;
- tx.cmd = FlashSubCmds::flashHashData;
- tx.offset = 0x00;
- std::memcpy(request, &tx, sizeof(tx));
-
- uint8_t bytes[] = {0x04, 0x05};
- std::memcpy(&request[sizeof(struct ChunkHdr)], bytes, sizeof(bytes));
-
- dataLen = sizeof(struct ChunkHdr) + sizeof(bytes);
-
- EXPECT_CALL(updater, hashData(0x00, ElementsAreArray(bytes, sizeof(bytes))))
- .WillOnce(Return(true));
-
- EXPECT_EQ(IPMI_CC_OK, hashBlock(&updater, request, reply, &dataLen));
- EXPECT_EQ(sizeof(uint8_t), dataLen);
- EXPECT_EQ(0, reply[0]);
-}
diff --git a/test/ipmi_hashfinish_unittest.cpp b/test/ipmi_hashfinish_unittest.cpp
deleted file mode 100644
index a0d40b8..0000000
--- a/test/ipmi_hashfinish_unittest.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-#include "flash-ipmi.hpp"
-#include "ipmi.hpp"
-#include "updater_mock.hpp"
-
-#include <cstring>
-
-#include <gtest/gtest.h>
-
-using ::testing::Return;
-using ::testing::StrictMock;
-
-// ipmid.hpp isn't installed where we can grab it and this value is per BMC
-// SoC.
-#define MAX_IPMI_BUFFER 64
-
-TEST(IpmiHashFinish, CallPassedOn)
-{
- // The data finish command does no validation as the input is empty, and
- // simply relies on the flash manager to do work.
-
- StrictMock<UpdaterMock> updater;
-
- size_t dataLen;
- uint8_t request[MAX_IPMI_BUFFER] = {0};
- uint8_t reply[MAX_IPMI_BUFFER] = {0};
-
- dataLen = 1; // request is only the command.
- request[0] = FlashSubCmds::flashHashFinish;
-
- EXPECT_CALL(updater, hashFinish()).WillOnce(Return(true));
- EXPECT_EQ(IPMI_CC_OK, hashFinish(&updater, request, reply, &dataLen));
- EXPECT_EQ(sizeof(uint8_t), dataLen);
- EXPECT_EQ(0, reply[0]);
-}
diff --git a/test/ipmi_starthash_unittest.cpp b/test/ipmi_starthash_unittest.cpp
deleted file mode 100644
index 695a8ff..0000000
--- a/test/ipmi_starthash_unittest.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-#include "flash-ipmi.hpp"
-#include "ipmi.hpp"
-#include "updater_mock.hpp"
-
-#include <cstring>
-
-#include <gtest/gtest.h>
-
-using ::testing::Return;
-using ::testing::StrictMock;
-
-// ipmid.hpp isn't installed where we can grab it and this value is per BMC
-// SoC.
-#define MAX_IPMI_BUFFER 64
-#define HASH_SIZE 512
-
-TEST(IpmiStartHashTest, ValidBoringCaseReturnsSuccess)
-{
- // This is also mostly a pass-thru command such that the real validation is
- // done elsewhere.
-
- StrictMock<UpdaterMock> updater;
-
- size_t dataLen;
- uint8_t request[MAX_IPMI_BUFFER] = {0};
- uint8_t reply[MAX_IPMI_BUFFER] = {0};
-
- struct StartTx tx;
- tx.cmd = FlashSubCmds::flashStartHash;
- tx.length = HASH_SIZE;
- std::memcpy(request, &tx, sizeof(tx));
-
- dataLen = sizeof(tx);
-
- EXPECT_CALL(updater, startHash(HASH_SIZE)).WillOnce(Return(true));
-
- EXPECT_EQ(IPMI_CC_OK, startHash(&updater, request, reply, &dataLen));
- EXPECT_EQ(sizeof(uint8_t), dataLen);
- EXPECT_EQ(0, reply[0]);
-}
diff --git a/test/ipmi_starttransfer_unittest.cpp b/test/ipmi_starttransfer_unittest.cpp
deleted file mode 100644
index 2f9f953..0000000
--- a/test/ipmi_starttransfer_unittest.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-#include "flash-ipmi.hpp"
-#include "ipmi.hpp"
-#include "updater_mock.hpp"
-
-#include <cstring>
-
-#include <gtest/gtest.h>
-
-using ::testing::NotNull;
-using ::testing::Return;
-using ::testing::StrictMock;
-
-// ipmid.hpp isn't installed where we can grab it and this value is per BMC
-// SoC.
-#define MAX_IPMI_BUFFER 64
-#define THIRTYTWO_MIB 33554432
-
-TEST(IpmiStartTransferTest, ValidRequestBoringCase)
-{
- // Verify that if the request is valid it calls into the flash updater.
-
- StrictMock<UpdaterMock> updater;
-
- size_t dataLen;
- uint8_t request[MAX_IPMI_BUFFER] = {0};
- uint8_t reply[MAX_IPMI_BUFFER] = {0};
-
- struct StartTx tx;
- tx.cmd = FlashSubCmds::flashStartTransfer;
- tx.length = THIRTYTWO_MIB;
- std::memcpy(request, &tx, sizeof(tx));
-
- dataLen = sizeof(tx);
-
- EXPECT_CALL(updater, start(THIRTYTWO_MIB)).WillOnce(Return(true));
-
- EXPECT_EQ(IPMI_CC_OK, startTransfer(&updater, request, reply, &dataLen));
- EXPECT_EQ(sizeof(uint8_t), dataLen);
- EXPECT_EQ(0, reply[0]);
-}
diff --git a/test/ipmi_startverify_unittest.cpp b/test/ipmi_startverify_unittest.cpp
deleted file mode 100644
index a46077a..0000000
--- a/test/ipmi_startverify_unittest.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-#include "ipmi.hpp"
-#include "updater_mock.hpp"
-
-#include <gtest/gtest.h>
-
-using ::testing::Return;
-using ::testing::StrictMock;
-
-// ipmid.hpp isn't installed where we can grab it and this value is per BMC
-// SoC.
-#define MAX_IPMI_BUFFER 64
-
-TEST(IpmiStartDataVerifyTest, CallPassedOn)
-{
- // The IPMI handler in this case just passes on the call and returns the
- // result without any extra validation.
-
- StrictMock<UpdaterMock> updater;
-
- size_t dataLen;
- uint8_t request[MAX_IPMI_BUFFER] = {0};
- uint8_t reply[MAX_IPMI_BUFFER] = {0};
-
- dataLen = 1; // request is only the command.
- request[0] = FlashSubCmds::flashDataVerify;
-
- EXPECT_CALL(updater, startDataVerification()).WillOnce(Return(true));
- EXPECT_EQ(IPMI_CC_OK, dataVerify(&updater, request, reply, &dataLen));
- EXPECT_EQ(sizeof(uint8_t), dataLen);
- EXPECT_EQ(0, reply[0]);
-}
diff --git a/test/ipmi_validate_unittest.cpp b/test/ipmi_validate_unittest.cpp
deleted file mode 100644
index f733c5e..0000000
--- a/test/ipmi_validate_unittest.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-#include "ipmi.hpp"
-
-#include <gtest/gtest.h>
-
-TEST(IpmiValidateTest, VerifyCommandMinimumLengths)
-{
- struct TestCases
- {
- FlashSubCmds cmd;
- size_t len;
- bool expect;
- };
-
- std::vector<TestCases> tests = {
- {FlashSubCmds::flashStartTransfer, sizeof(struct StartTx), true},
- {FlashSubCmds::flashStartTransfer, sizeof(struct StartTx) - 1, false},
- {FlashSubCmds::flashDataBlock, sizeof(struct ChunkHdr) - 1, false},
- {FlashSubCmds::flashDataBlock, sizeof(struct ChunkHdr), false},
- {FlashSubCmds::flashStartHash, sizeof(struct StartTx) - 1, false},
- {FlashSubCmds::flashHashData, sizeof(struct ChunkHdr) - 1, false},
- };
-
- for (const auto& test : tests)
- {
- bool result = validateRequestLength(test.cmd, test.len);
- EXPECT_EQ(result, test.expect);
- }
-}
diff --git a/test/ipmi_verifycheck_unittest.cpp b/test/ipmi_verifycheck_unittest.cpp
deleted file mode 100644
index 309333a..0000000
--- a/test/ipmi_verifycheck_unittest.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-#include "ipmi.hpp"
-#include "updater_mock.hpp"
-
-#include <gtest/gtest.h>
-
-using ::testing::Return;
-using ::testing::StrictMock;
-
-// ipmid.hpp isn't installed where we can grab it and this value is per BMC
-// SoC.
-#define MAX_IPMI_BUFFER 64
-
-TEST(IpmiCheckVerifyTest, CallPassedOn)
-{
- // This IPMI handler just bundles the response.
-
- StrictMock<UpdaterMock> updater;
-
- size_t dataLen;
- uint8_t request[MAX_IPMI_BUFFER] = {0};
- uint8_t reply[MAX_IPMI_BUFFER] = {0};
-
- dataLen = 1; // request is only the command.
- request[0] = FlashSubCmds::flashVerifyCheck;
-
- EXPECT_CALL(updater, checkVerify())
- .WillOnce(Return(VerifyCheckResponse::running));
- EXPECT_EQ(IPMI_CC_OK, checkVerify(&updater, request, reply, &dataLen));
- EXPECT_EQ(sizeof(uint8_t), dataLen);
- EXPECT_EQ(VerifyCheckResponse::running, reply[0]);
-}
diff --git a/test/updater_mock.hpp b/test/updater_mock.hpp
deleted file mode 100644
index ce64a54..0000000
--- a/test/updater_mock.hpp
+++ /dev/null
@@ -1,23 +0,0 @@
-#pragma once
-
-#include "flash-ipmi.hpp"
-
-#include <vector>
-
-#include <gmock/gmock.h>
-
-class UpdaterMock : public UpdateInterface
-{
- public:
- virtual ~UpdaterMock() = default;
-
- MOCK_METHOD1(start, bool(uint32_t));
- MOCK_METHOD2(flashData, bool(uint32_t, const std::vector<uint8_t>&));
- MOCK_METHOD0(flashFinish, bool());
- MOCK_METHOD1(startHash, bool(uint32_t));
- MOCK_METHOD2(hashData, bool(uint32_t, const std::vector<uint8_t>&));
- MOCK_METHOD0(hashFinish, bool());
- MOCK_METHOD0(startDataVerification, bool());
- MOCK_METHOD0(abortUpdate, bool());
- MOCK_METHOD0(checkVerify, VerifyCheckResponse());
-};
diff --git a/tools/Makefile.am b/tools/Makefile.am
deleted file mode 100644
index 471d138..0000000
--- a/tools/Makefile.am
+++ /dev/null
@@ -1,30 +0,0 @@
-noinst_PROGRAMS = burn_my_bmc
-
-AM_CPPFLAGS = -I./bt -I./interface -I./ipmi -I./libs -I./libs/ipmitool/include
-
-burn_my_bmc_SOURCES = main.cpp
-burn_my_bmc_LDADD = libupdater.la
-burn_my_bmc_CXXFLAGS =
-
-noinst_LTLIBRARIES = libupdater.la libipmi.la libipmitool.la
-libupdater_la_LDFLAGS = -static
-libupdater_la_LIBADD = libipmi.la \
- -lstdc++fs
-libupdater_la_SOURCES = \
- updater.cpp
-
-libipmi_la_LDFLAGS = -static
-libipmi_la_LIBADD = libipmitool.la
-libipmi_la_SOURCES = \
- ipmi/raw.cpp \
- bt/bt.cpp \
- ipmi/updatehelper.cpp
-
-libipmitool_la_LDFLAGS = -static
-libipmitool_la_LIBADD =
-libipmitool_la_SOURCES = \
- libs/ipmitoolintf.c \
- libs/ipmitool.c \
- libs/ipmitool/src/plugins/open/open.c
-
-SUBDIRS = . test
diff --git a/tools/bt/bt.cpp b/tools/bt/bt.cpp
deleted file mode 100644
index 6add8df..0000000
--- a/tools/bt/bt.cpp
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "bt.hpp"
-
-void BtDataHandler::SendData(std::ifstream input, int command)
-{
- /* TODO: implement this. */
-}
diff --git a/tools/bt/bt.hpp b/tools/bt/bt.hpp
deleted file mode 100644
index a8879d4..0000000
--- a/tools/bt/bt.hpp
+++ /dev/null
@@ -1,22 +0,0 @@
-#pragma once
-
-#include "interface.hpp"
-#include "updatehelper.hpp"
-
-class BtDataHandler : public DataInterface
-{
- public:
- explicit BtDataHandler(UpdateHelperInterface* helper) : helper(helper)
- {
- }
-
- void SendData(std::ifstream input, int command) override;
-
- bool External() override
- {
- return false;
- }
-
- private:
- UpdateHelperInterface* helper;
-};
diff --git a/tools/interface/interface.hpp b/tools/interface/interface.hpp
deleted file mode 100644
index 94e7048..0000000
--- a/tools/interface/interface.hpp
+++ /dev/null
@@ -1,24 +0,0 @@
-#pragma once
-
-#include <fstream>
-
-// Abstract Base Class for the Data Interface.
-// The DataInterface defines the required methods for sending data down through
-// a data channel. This can allow the data to be written anywhere as long as
-// the BMC side knows how to read it. The data can also be sent down over IPMI
-// however, it still must follow this interface.
-class DataInterface
-{
- public:
- virtual ~DataInterface() = default;
-
- /* Try to send the file data.
- * @param[in] input : File stream containing the data content to be
- * transmitted
- * @param[in] command : The command corresponding to the data.
- */
- virtual void SendData(std::ifstream input, int command) = 0;
-
- /* Return true if your data is carried outside the IPMI channel. */
- virtual bool External() = 0;
-};
diff --git a/tools/ipmi/raw.cpp b/tools/ipmi/raw.cpp
deleted file mode 100644
index c38f634..0000000
--- a/tools/ipmi/raw.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2018 Google Inc.
- *
- * 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.
- */
-
-#include "raw.hpp"
-
-#include <stdexcept>
-
-struct IpmiResponse IpmiRaw::Raw(const std::vector<uint8_t>& buffer)
-{
- struct IpmiResponse response;
- int rc = ipmiSendCommand(buffer.data(), buffer.size(), &response);
- if (rc)
- {
- throw std::runtime_error("Failure sending IPMI packet.");
- }
-
- return response;
-}
-
-struct IpmiResponse IpmiRaw::RawWithTries(const std::vector<uint8_t>& buffer,
- int tries)
-{
- int count = 0;
- struct IpmiResponse response;
-
- /* If tries is 0, it'll run once. */
- do
- {
- try
- {
- response = Raw(buffer);
- }
- catch (const std::runtime_error& e)
- {
- continue;
- }
-
- count++;
- if (count >= tries)
- {
- throw std::runtime_error("Failure sending IPMI packet.");
- }
- } while (count < tries);
-
- return response;
-}
diff --git a/tools/ipmi/raw.hpp b/tools/ipmi/raw.hpp
deleted file mode 100644
index 6e96816..0000000
--- a/tools/ipmi/raw.hpp
+++ /dev/null
@@ -1,27 +0,0 @@
-#pragma once
-
-#include <vector>
-
-extern "C" {
-#include "ipmitoolintf.h"
-} // extern "C"
-
-class RawInterface
-{
- public:
- virtual ~RawInterface() = default;
-
- virtual struct IpmiResponse Raw(const std::vector<uint8_t>& buffer) = 0;
- virtual struct IpmiResponse RawWithTries(const std::vector<uint8_t>& buffer,
- int tries) = 0;
-};
-
-class IpmiRaw : public RawInterface
-{
- public:
- IpmiRaw() = default;
-
- struct IpmiResponse Raw(const std::vector<uint8_t>& buffer) override;
- struct IpmiResponse RawWithTries(const std::vector<uint8_t>& buffer,
- int tries) override;
-};
diff --git a/tools/ipmi/updatehelper.cpp b/tools/ipmi/updatehelper.cpp
deleted file mode 100644
index 2be224a..0000000
--- a/tools/ipmi/updatehelper.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2018 Google Inc.
- *
- * 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.
- */
-
-#include "config.h"
-
-#include "updatehelper.hpp"
-
-#include <cstring>
-#include <vector>
-
-namespace
-{
-// Output a vector of bytes consisted of the command header and given input.
-// Precondition: packet must be preallocated with kFlashCommandHdrSizeBytes.
-void constructFlashIpmiPacket(int command, const uint8_t* payload,
- int payload_size, std::vector<uint8_t>* packet)
-{
- struct CommandHdr hdr;
- std::memset(&hdr, 0, sizeof(hdr));
-
- hdr.command = OEM_FLASH_UPDATE_BT_COMMAND;
- hdr.subcommand = command;
-
-#ifdef ENABLE_GOOGLE
- hdr.netfn = NETFN_OEM;
- std::memcpy(&hdr.oen, OEN_GOOGLE, sizeof(OEN_GOOGLE));
-#else
- hdr.netfn = NETFN_FIRMWARE;
-#endif
-
- std::memcpy(packet->data(), &hdr, sizeof(hdr));
-
- if (payload != nullptr && payload_size > 0)
- {
- packet->insert(packet->end(), payload, payload + payload_size);
- }
-}
-} // namespace
-
-/*
- * For use with BT Flash commands with payloads
- */
-struct IpmiResponse
- IpmiUpdateHelper::SendCommand(int command,
- const std::vector<uint8_t>& payload)
-{
- std::vector<uint8_t> packet(kFlashCommandHdrSizeBytes);
- constructFlashIpmiPacket(command, payload.data(), payload.size(), &packet);
-
- return raw->Raw(packet);
-}
-
-/*
- * For use with BT Flash commands that are only the command itself.
- */
-struct IpmiResponse IpmiUpdateHelper::SendEmptyCommand(int command)
-{
- return SendCommand(command, {});
-}
diff --git a/tools/ipmi/updatehelper.hpp b/tools/ipmi/updatehelper.hpp
deleted file mode 100644
index c502216..0000000
--- a/tools/ipmi/updatehelper.hpp
+++ /dev/null
@@ -1,90 +0,0 @@
-#pragma once
-
-#include "config.h"
-
-#include "raw.hpp"
-
-#include <vector>
-
-constexpr int OEM_FLASH_UPDATE_BT_COMMAND = 127;
-constexpr uint8_t NETFN_FIRMWARE = 0x08;
-
-#ifdef ENABLE_GOOGLE
-
-constexpr int OEN_SIZE = 3;
-
-// OEM Command Netfn for IPMI.
-constexpr uint8_t NETFN_OEM = 0x2e;
-
-// OEM Group identifier for OpenBMC.
-constexpr uint8_t OEN_OPENBMC[OEN_SIZE] = {0xcf, 0xc2, 0x00};
-constexpr uint8_t OEN_GOOGLE[OEN_SIZE] = {0x79, 0x2b, 0x00};
-
-/* The header for the IPMI Raw command with a subcommand leading byte. */
-struct CommandHdr
-{
- uint8_t netfn;
- uint8_t command;
- uint8_t oen[OEN_SIZE];
- /* This is labeled subcommand but anything after padding is data. */
- uint8_t subcommand;
-} __attribute__((packed));
-
-#else
-
-/* If not using the GOOGLE OEM, it uses the Firmware Netfn. */
-
-struct CommandHdr
-{
- uint8_t netfn;
- uint8_t command;
- uint8_t subcommand;
-} __attribute__((packed));
-
-#endif
-
-constexpr int kFlashCommandHdrSizeBytes = sizeof(CommandHdr);
-
-/* This interface defines an interface of helper calls that'll deal with the
- * details for sending the updater ipmi commands. This also enables testing via
- * injection.
- */
-class UpdateHelperInterface
-{
- public:
- ~UpdateHelperInterface() = default;
-
- /**
- * Try to send an IPMI update firmware command that is only the command and
- * no payload.
- *
- * @param[in] command : the command byte to send.
- * @return the IPMI response.
- */
- virtual struct IpmiResponse SendEmptyCommand(int command) = 0;
-
- /**
- * Try to send an IPMI update firmware command, possibly with payload.
- *
- * @param[in] command : the command byte to send.
- * @param[in] payload : the payload bytes.
- * @return the IPMI response.
- */
- virtual struct IpmiResponse
- SendCommand(int command, const std::vector<uint8_t>& payload) = 0;
-};
-
-class IpmiUpdateHelper : public UpdateHelperInterface
-{
- public:
- IpmiUpdateHelper(RawInterface* raw) : raw(raw)
- {
- }
-
- struct IpmiResponse SendEmptyCommand(int command) override;
- struct IpmiResponse
- SendCommand(int command, const std::vector<uint8_t>& payload) override;
-
- private:
- RawInterface* raw;
-};
diff --git a/tools/ipmitool.LICENSE b/tools/ipmitool.LICENSE
deleted file mode 100644
index b332da7..0000000
--- a/tools/ipmitool.LICENSE
+++ /dev/null
@@ -1,30 +0,0 @@
-Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-
-Redistribution of source code must retain the above copyright
-notice, this list of conditions and the following disclaimer.
-
-Redistribution in binary form must reproduce the above copyright
-notice, this list of conditions and the following disclaimer in the
-documentation and/or other materials provided with the distribution.
-
-Neither the name of Sun Microsystems, Inc. or the names of
-contributors may be used to endorse or promote products derived
-from this software without specific prior written permission.
-
-This software is provided "AS IS," without a warranty of any kind.
-ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
-INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
-PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.
-SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE
-FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
-OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
-SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA,
-OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
-PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
-LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
-EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
-
diff --git a/tools/libs/ipmitool b/tools/libs/ipmitool
deleted file mode 160000
index 232773d..0000000
--- a/tools/libs/ipmitool
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 232773d171a8f5a929d02744e952bbfbe87c1b8e
diff --git a/tools/libs/ipmitool.c b/tools/libs/ipmitool.c
deleted file mode 100644
index 3b64a35..0000000
--- a/tools/libs/ipmitool.c
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
-Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-
-Redistribution of source code must retain the above copyright
-notice, this list of conditions and the following disclaimer.
-
-Redistribution in binary form must reproduce the above copyright
-notice, this list of conditions and the following disclaimer in the
-documentation and/or other materials provided with the distribution.
-
-Neither the name of Sun Microsystems, Inc. or the names of
-contributors may be used to endorse or promote products derived
-from this software without specific prior written permission.
-
-This software is provided "AS IS," without a warranty of any kind.
-ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
-INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
-PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.
-SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE
-FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
-OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
-SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA,
-OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
-PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
-LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
-EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- */
-#include <ipmitool/ipmi_intf.h>
-#include <ipmitool/ipmi_mc.h>
-#include <ipmitool/log.h>
-
-/* Duplicate this into our memory space. Nothing in our code path calls this
- * in a critical path.
- */
-static IPMI_OEM sel_iana = IPMI_OEM_UNKNOWN;
-
-const struct valstr completion_code_vals[] = {
- {0x00, "Command completed normally"},
- {0xc0, "Node busy"},
- {0xc1, "Invalid command"},
- {0xc2, "Invalid command on LUN"},
- {0xc3, "Timeout"},
- {0xc4, "Out of space"},
- {0xc5, "Reservation cancelled or invalid"},
- {0xc6, "Request data truncated"},
- {0xc7, "Request data length invalid"},
- {0xc8, "Request data field length limit exceeded"},
- {0xc9, "Parameter out of range"},
- {0xca, "Cannot return number of requested data bytes"},
- {0xcb, "Requested sensor, data, or record not found"},
- {0xcc, "Invalid data field in request"},
- {0xcd, "Command illegal for specified sensor or record type"},
- {0xce, "Command response could not be provided"},
- {0xcf, "Cannot execute duplicated request"},
- {0xd0, "SDR Repository in update mode"},
- {0xd1, "Device firmeware in update mode"},
- {0xd2, "BMC initialization in progress"},
- {0xd3, "Destination unavailable"},
- {0xd4, "Insufficient privilege level"},
- {0xd5, "Command not supported in present state"},
- {0xd6, "Cannot execute command, command disabled"},
- {0xff, "Unspecified error"},
- {0x00, NULL}};
-
-const char* val2str(uint16_t val, const struct valstr* vs)
-{
- static char un_str[32];
- int i;
-
- for (i = 0; vs[i].str != NULL; i++)
- {
- if (vs[i].val == val)
- return vs[i].str;
- }
-
- memset(un_str, 0, 32);
- snprintf(un_str, 32, "Unknown (0x%02X)", val);
-
- return un_str;
-}
-
-void ipmi_intf_session_set_timeout(struct ipmi_intf* intf, uint32_t timeout)
-{
- intf->ssn_params.timeout = timeout;
-}
-
-void ipmi_intf_session_set_retry(struct ipmi_intf* intf, int retry)
-{
- intf->ssn_params.retry = retry;
-}
-
-/* Nullify the methods we don't care about. */
-void lprintf(int level, const char* format, ...)
-{
- return;
-}
-void lperror(int level, const char* format, ...)
-{
- return;
-}
-
-int verbose = 0;
-
-const char* buf2str_extended(const uint8_t* buf, int len, const char* sep)
-{
- static char str[BUF2STR_MAXIMUM_OUTPUT_SIZE];
- char* cur;
- int i;
- int sz;
- int left;
- int sep_len;
-
- if (buf == NULL)
- {
- snprintf(str, sizeof(str), "<NULL>");
- return (const char*)str;
- }
- cur = str;
- left = sizeof(str);
- if (sep)
- {
- sep_len = strlen(sep);
- }
- else
- {
- sep_len = 0;
- }
- for (i = 0; i < len; i++)
- {
- /* may return more than 2, depending on locale */
- sz = snprintf(cur, left, "%2.2x", buf[i]);
- if (sz >= left)
- {
- /* buffer overflow, truncate */
- break;
- }
- cur += sz;
- left -= sz;
- /* do not write separator after last byte */
- if (sep && i != (len - 1))
- {
- if (sep_len >= left)
- {
- break;
- }
- strncpy(cur, sep, left - sz);
- cur += sep_len;
- left -= sep_len;
- }
- }
- *cur = '\0';
-
- return (const char*)str;
-}
-
-const char* buf2str(const uint8_t* buf, int len)
-{
- return buf2str_extended(buf, len, NULL);
-}
-
-uint8_t ipmi_csum(uint8_t* d, int s)
-{
- uint8_t c = 0;
- for (; s > 0; s--, d++)
- c += *d;
- return -c;
-}
-
-void printbuf(const uint8_t* buf, int len, const char* desc)
-{
- int i;
-
- if (len <= 0)
- return;
-
- if (verbose < 1)
- return;
-
- fprintf(stderr, "%s (%d bytes)\n", desc, len);
- for (i = 0; i < len; i++)
- {
- if (((i % 16) == 0) && (i != 0))
- fprintf(stderr, "\n");
- fprintf(stderr, " %2.2x", buf[i]);
- }
- fprintf(stderr, "\n");
-}
-
-IPMI_OEM
-ipmi_get_oem(struct ipmi_intf* intf)
-{
- /* Execute a Get Device ID command to determine the OEM */
- struct ipmi_rs* rsp;
- struct ipmi_rq req;
- struct ipm_devid_rsp* devid;
-
- if (intf->fd == 0)
- {
- if (sel_iana != IPMI_OEM_UNKNOWN)
- {
- return sel_iana;
- }
- return IPMI_OEM_UNKNOWN;
- }
-
- /*
- * Return the cached manufacturer id if the device is open and
- * we got an identified OEM owner. Otherwise just attempt to read
- * it.
- */
- if (intf->opened && intf->manufacturer_id != IPMI_OEM_UNKNOWN)
- {
- return intf->manufacturer_id;
- }
-
- memset(&req, 0, sizeof(req));
- req.msg.netfn = IPMI_NETFN_APP;
- req.msg.cmd = BMC_GET_DEVICE_ID;
- req.msg.data_len = 0;
-
- rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL)
- {
- lprintf(LOG_ERR, "Get Device ID command failed");
- return IPMI_OEM_UNKNOWN;
- }
- if (rsp->ccode > 0)
- {
- lprintf(LOG_ERR, "Get Device ID command failed: %#x %s", rsp->ccode,
- val2str(rsp->ccode, completion_code_vals));
- return IPMI_OEM_UNKNOWN;
- }
-
- devid = (struct ipm_devid_rsp*)rsp->data;
-
- lprintf(LOG_DEBUG, "Iana: %u",
- IPM_DEV_MANUFACTURER_ID(devid->manufacturer_id));
-
- return IPM_DEV_MANUFACTURER_ID(devid->manufacturer_id);
-}
diff --git a/tools/libs/ipmitoolintf.c b/tools/libs/ipmitoolintf.c
deleted file mode 100644
index b68d454..0000000
--- a/tools/libs/ipmitoolintf.c
+++ /dev/null
@@ -1,65 +0,0 @@
-#include "ipmitoolintf.h"
-
-#include <ipmitool/ipmi_intf.h>
-#include <string.h>
-
-extern struct ipmi_intf ipmi_open_intf;
-
-int ipmiSendCommand(const uint8_t* bytes, int length, struct IpmiResponse* resp)
-{
- struct ipmi_intf* intf = &ipmi_open_intf;
-
- /* The length needs to be at least two bytes [netfn][cmd] */
- if (length < 2)
- {
- return -1;
- }
-
- uint8_t data[MAX_PIPELINE_BANDWIDTH];
- struct ipmi_rq request;
- memset(&data[0], 0, sizeof(data));
- memset(&request, 0, sizeof(request));
-
- ipmi_intf_session_set_timeout(intf, 15);
- /* The retry here isn't used for the normal BT interface comms it appears.
- * Only references found in sol and serial, and lan.
- */
- ipmi_intf_session_set_retry(intf, 1);
-
- request.msg.netfn = bytes[0];
- request.msg.lun = 0x00;
- request.msg.cmd = bytes[1];
- request.msg.data = &data[0];
-
- /* Can you fit the request in the buffer? */
- if ((length - 2) > sizeof(data))
- {
- return -1;
- }
-
- /* Skip beyond netfn and command. */
- memcpy(request.msg.data, &bytes[2], length - 2);
- request.msg.data_len = length - 2;
-
- /* Actually send the command and check for a response. */
- struct ipmi_rs* response = intf->sendrecv(intf, &request);
- if (!response)
- {
- return -1;
- }
-
- /* If the caller wanted the response back. */
- if (resp)
- {
- resp->ccode = response->ccode;
- if (response->data_len <= sizeof(resp->data))
- {
- memcpy(resp->data, response->data, response->data_len);
- resp->dataLen = response->data_len;
- return 0;
- }
- /* TODO: deal with truncation... */
- }
-
- return 0;
-}
diff --git a/tools/libs/ipmitoolintf.h b/tools/libs/ipmitoolintf.h
deleted file mode 100644
index c4994fd..0000000
--- a/tools/libs/ipmitoolintf.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#pragma once
-
-/* The Aspeed AST2400 & AST2500 have 64 bytes of SRAM as the FIFO for each
- * direction, of which 2 bytes are reserved for len and for seq by upper layer
- * ipmi driver.
- */
-#define MAX_PIPELINE_BANDWIDTH 62
-#define IPMI_BUF_SIZE 1024
-
-#include <stdint.h>
-
-struct IpmiResponse
-{
- uint8_t ccode;
- uint8_t data[IPMI_BUF_SIZE];
- int dataLen;
-};
-
-/**
- * Call into the ipmitool source to send the IPMI packet.
- *
- * @param[in] bytes - the IPMI packet contents.
- * @param[in] length - the number of bytes.
- * @param[in,out] resp - a pointer to write the response.
- * @return 0 on success.
- */
-int ipmiSendCommand(const uint8_t* bytes, int length,
- struct IpmiResponse* resp);
diff --git a/tools/main.cpp b/tools/main.cpp
deleted file mode 100644
index 9976a65..0000000
--- a/tools/main.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright 2018 Google Inc.
- *
- * 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.
- */
-
-#include "updater.hpp"
-
-#include <getopt.h>
-
-#include <cstdio>
-#include <set>
-#include <stdexcept>
-#include <string>
-
-static void usage(const char* name)
-{
- std::fprintf(
- stderr,
- "Usage: %s -c <COMMAND> -i <INTERFACE> -m <IMAGE> -s <SIGNATURE>\n"
- " -c, --command <COMMAND> the command to run 'update', 'reboot', "
- "'ping'\n"
- " -i, --interface <INTERFACE> the interface to use, 'ipmibt'\n"
- " -m, --imaage <IMAGE> the image file\n"
- " -s, --signature <SIGNATURE> the signature file\n"
- "\n"
- " If command is update, you must specify an interface, image, and "
- "signature.\n",
- name);
-}
-
-int main(int argc, char* argv[])
-{
- int opt;
-
- // clang-format off
- static const struct option long_options[] = {
- {"command", required_argument, NULL, 'c'},
- {"interface", required_argument, NULL, 'i'},
- {"image", required_argument, NULL, 'm'},
- {"signature", required_argument, NULL, 's'},
- {0, 0, 0, 0}
- };
- // clang-format on
- const char* pm = "c:i:m:s:";
-
- std::string command, interface, image, signature;
-
- while ((opt = getopt_long(argc, argv, pm, long_options, NULL)) != -1)
- {
- switch (opt)
- {
- case 0:
- break;
- case 'c':
- command = optarg;
- break;
- case 'i':
- interface = optarg;
- break;
- case 'm':
- image = optarg;
- break;
- case 's':
- signature = optarg;
- break;
- default:
- usage(argv[0]);
- exit(EXIT_FAILURE);
- }
- }
-
- if (command.empty())
- {
- usage(argv[0]);
- exit(EXIT_FAILURE);
- }
-
- static const std::set<std::string> supportedCommands = {"update"};
- if (!supportedCommands.count(command))
- {
- usage(argv[0]);
- exit(EXIT_FAILURE);
- }
-
- if (command == "update")
- {
- if (interface.empty() || image.empty() || signature.empty())
- {
- usage(argv[0]);
- exit(EXIT_FAILURE);
- }
-
- try
- {
- UpdaterMain(interface, image, signature);
- return 0;
- }
- catch (const std::runtime_error& e)
- {
- fprintf(stderr, "runtime error: %s\n", e.what());
- exit(EXIT_FAILURE);
- }
- }
-
- return 0;
-}
diff --git a/tools/test/Makefile.am b/tools/test/Makefile.am
deleted file mode 100644
index 1d3fa25..0000000
--- a/tools/test/Makefile.am
+++ /dev/null
@@ -1,7 +0,0 @@
-AM_CPPFLAGS =
-AM_CXXFLAGS =
-AM_LDFLAGS =
-
-# Run all 'check' test programs
-check_PROGRAMS =
-TESTS = $(check_PROGRAMS)
diff --git a/tools/test/interface_mock.hpp b/tools/test/interface_mock.hpp
deleted file mode 100644
index 4b3aeec..0000000
--- a/tools/test/interface_mock.hpp
+++ /dev/null
@@ -1,10 +0,0 @@
-#pragma once
-
-#include "interface.hpp"
-
-class MockData : public DataInterface
-{
- public:
- MOCK_METHOD2(SendData, void(std::FILE*, int));
- MOCK_METHOD0(External, bool());
-};
diff --git a/tools/test/raw_mock.hpp b/tools/test/raw_mock.hpp
deleted file mode 100644
index bfcb90b..0000000
--- a/tools/test/raw_mock.hpp
+++ /dev/null
@@ -1,11 +0,0 @@
-#pragma once
-
-#include "raw.hpp"
-
-class MockRaw : public RawInterface
-{
- public:
- MOCK_METHOD1(Raw, struct IpmiResponse(const std::vector<uint8_t>&));
- MOCK_METHOD2(RawWithTries,
- struct IpmiResponse(const std::vector<uint8_t>&, int));
-};
diff --git a/tools/updater.cpp b/tools/updater.cpp
deleted file mode 100644
index c012c76..0000000
--- a/tools/updater.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2018 Google Inc.
- *
- * 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.
- */
-
-#include "updater.hpp"
-
-#include "bt.hpp"
-#include "raw.hpp"
-#include "updatehelper.hpp"
-
-#include <experimental/filesystem>
-#include <fstream>
-#include <memory>
-#include <set>
-#include <stdexcept>
-
-extern "C" {
-#include "ipmitoolintf.h"
-} // extern "C"
-
-std::unique_ptr<UploadManager> UploadManager::BuildUploadMgr(
- const std::string& image, const std::string& hash,
- UpdateHelperInterface* helper, DataInterface* dintf)
-{
- std::ifstream imageStream, hashStream;
-
- imageStream.open(image);
- hashStream.open(hash);
- if (imageStream.bad() || hashStream.bad())
- {
- return nullptr;
- }
-
- int32_t imageSize = std::experimental::filesystem::file_size(image);
- int32_t hashSize = std::experimental::filesystem::file_size(hash);
-
- return std::make_unique<UploadManager>(std::move(imageStream),
- std::move(hashStream), imageSize,
- hashSize, helper, dintf);
-}
-
-void UploadManager::UpdateBMC()
-{
- /* Let's build the raw command input.
- *
- * The sequence is:
- * FLASH_START_TRANSFER,
- * FLASH_DATA_BLOCK x times. (or FLASH_EXTERNAL_DATA_BLOCK)
- * FLASH_DATA_FINISH
- * FLASH_START_HASH
- * FLASH_HASH_DATA x times. (or FLASH_EXTERNAL_HASH_BLOCK)
- * FLASH_HASH_FINISH
- * FLASH_DATA_VERIFY
- * FLASH_VERIFY_CHECK x times.
- */
-
- /* TODO: implement this. */
-
- /* UploadImage() */
- /* UploadHash() */
-
- /*
- * FLASH_DATA_VERIFY - The verify command will trigger verification of the
- * image against the signature file sent down.
- */
- // ret = helper_->SendEmptyCommand(FLASH_DATA_VERIFY, nullptr);
- // if (!ret.ok()) return ret;
-
- return;
-}
-
-void UpdaterMain(const std::string& interface, const std::string& image,
- const std::string& signature)
-{
- static const std::set<std::string> supportedInterfaces = {"ipmibt"};
-
- /* Check if interface is supported. */
- if (!supportedInterfaces.count(interface))
- {
- throw std::runtime_error("Unsupported interface");
- }
-
- /* NOTE: Presently, the hash signature being separate is optional on the BMC
- * but isn't here, for now.
- */
-
- /* There are three key components to the process. There's the data handler,
- * which deals with sending the data, and it uses a convenience method to
- * package the specific IPMI firmware update commands, and those commands
- * are then routed through a convenience layer that will handle calling into
- * the C-library.
- */
- IpmiRaw raw;
- IpmiUpdateHelper ipmih(&raw);
- std::unique_ptr<DataInterface> handler;
-
- if (interface == "ipmibt")
- {
- handler = std::make_unique<BtDataHandler>(&ipmih);
- }
-
- if (handler == nullptr)
- {
- throw std::runtime_error("Unable to build interface handler.");
- }
-
- auto updater =
- UploadManager::BuildUploadMgr(image, signature, &ipmih, handler.get());
-
- if (updater == nullptr)
- {
- throw std::runtime_error("Unable to build update manager.");
- }
-
- updater->UpdateBMC();
-
- return;
-}
diff --git a/tools/updater.hpp b/tools/updater.hpp
deleted file mode 100644
index 561e6c7..0000000
--- a/tools/updater.hpp
+++ /dev/null
@@ -1,53 +0,0 @@
-#pragma once
-
-#include "interface.hpp"
-#include "updatehelper.hpp"
-
-#include <fstream>
-#include <memory>
-#include <string>
-
-class UploadManager
-{
- public:
- UploadManager(std::ifstream&& image, std::ifstream&& hash,
- int32_t imageSize, int32_t hashSize,
- UpdateHelperInterface* helper, DataInterface* dintf) :
- imageStream(std::move(image)),
- hashStream(std::move(hash)), imageSize(imageSize), hashSize(hashSize),
- helper(helper), dintf(dintf)
- {
- }
-
- /**
- * Instantiate an UploadManager if the parameters check out.
- *
- * @param[in] image - path to the firmware image.
- * @param[in] hash - path to the image's hash.
- * @param[in] helper - pointer to an UpdateHelperInterface.
- * @param[in] dintf - pointer to the data interface to use.
- * @return UploadManager if valid or nullptr if invalid.
- */
- static std::unique_ptr<UploadManager>
- BuildUploadMgr(const std::string& image, const std::string& hash,
- UpdateHelperInterface* helper, DataInterface* dintf);
-
- /**
- * Try to update the BMC flash image over IPMI through BT.
- */
- void UpdateBMC();
-
- private:
- std::ifstream imageStream;
- std::ifstream hashStream;
- int32_t imageSize;
- int32_t hashSize;
- UpdateHelperInterface* helper;
- DataInterface* dintf;
-};
-
-// Main entry point for the update command.
-// Update uploads and verifies the image.
-// throws exception on errors.
-void UpdaterMain(const std::string& interface, const std::string& image,
- const std::string& signature);