Matthew Barth | 155c34f | 2016-10-18 14:33:17 -0500 | [diff] [blame] | 1 | #include "writefrudata.hpp" |
vishwa | 13555bd | 2015-11-10 12:10:38 -0600 | [diff] [blame] | 2 | |
Patrick Venture | d847f50 | 2019-03-26 11:12:39 -0700 | [diff] [blame^] | 3 | #include <CLI/CLI.hpp> |
Patrick Venture | 52f1f18 | 2018-10-17 13:05:03 -0700 | [diff] [blame] | 4 | #include <cstdlib> |
| 5 | #include <cstring> |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 6 | #include <iostream> |
| 7 | #include <memory> |
Patrick Venture | 07f635c | 2018-10-19 09:19:39 -0700 | [diff] [blame] | 8 | #include <phosphor-logging/log.hpp> |
| 9 | |
| 10 | using namespace phosphor::logging; |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 11 | |
vishwa | 13555bd | 2015-11-10 12:10:38 -0600 | [diff] [blame] | 12 | //-------------------------------------------------------------------------- |
vishwa | c93d6d4 | 2015-12-16 11:55:16 -0600 | [diff] [blame] | 13 | // This gets called by udev monitor soon after seeing hog plugs for EEPROMS. |
vishwa | 13555bd | 2015-11-10 12:10:38 -0600 | [diff] [blame] | 14 | //-------------------------------------------------------------------------- |
Patrick Venture | c9508db | 2018-10-16 17:18:43 -0700 | [diff] [blame] | 15 | int main(int argc, char** argv) |
vishwa | 13555bd | 2015-11-10 12:10:38 -0600 | [diff] [blame] | 16 | { |
| 17 | int rc = 0; |
Oskar Senft | 8f51109 | 2018-12-04 13:53:16 -0500 | [diff] [blame] | 18 | uint8_t fruid; |
Patrick Venture | d847f50 | 2019-03-26 11:12:39 -0700 | [diff] [blame^] | 19 | std::string eeprom_file; |
| 20 | const int MAX_FRU_ID = 0xfe; |
| 21 | |
| 22 | CLI::App app{"OpenBMC IPMI-FRU-Parser"}; |
| 23 | app.add_option("-e,--eeprom", eeprom_file, "Absolute file name of eeprom") |
| 24 | ->check(CLI::ExistingFile); |
| 25 | app.add_option("-f,--fruid", fruid, "valid fru id in integer") |
| 26 | ->check(CLI::Range(0, MAX_FRU_ID)); |
vishwa | 13555bd | 2015-11-10 12:10:38 -0600 | [diff] [blame] | 27 | |
vishwa | 13555bd | 2015-11-10 12:10:38 -0600 | [diff] [blame] | 28 | // Read the arguments. |
Patrick Venture | d847f50 | 2019-03-26 11:12:39 -0700 | [diff] [blame^] | 29 | CLI11_PARSE(app, argc, argv); |
vishwa | 13555bd | 2015-11-10 12:10:38 -0600 | [diff] [blame] | 30 | |
Patrick Venture | a8093a2 | 2018-10-21 09:07:11 -0700 | [diff] [blame] | 31 | // Now that we have the file that contains the eeprom data, go read it |
| 32 | // and update the Inventory DB. |
| 33 | auto bus = sdbusplus::bus::new_default(); |
| 34 | bool bmc_fru = true; |
| 35 | rc = validateFRUArea(fruid, eeprom_file.c_str(), bus, bmc_fru); |
vishwa | 13555bd | 2015-11-10 12:10:38 -0600 | [diff] [blame] | 36 | |
| 37 | return (rc < 0 ? EXIT_FAILURE : EXIT_SUCCESS); |
| 38 | } |