blob: 2c74fbdc054e0c379856519eb11d3357af8b8f1d [file] [log] [blame]
Matthew Barth155c34f2016-10-18 14:33:17 -05001#include "writefrudata.hpp"
vishwa13555bd2015-11-10 12:10:38 -06002
Patrick Ventured847f502019-03-26 11:12:39 -07003#include <CLI/CLI.hpp>
Patrick Venture52f1f182018-10-17 13:05:03 -07004#include <cstdlib>
5#include <cstring>
Patrick Venturec9508db2018-10-16 17:18:43 -07006#include <iostream>
7#include <memory>
Patrick Venture07f635c2018-10-19 09:19:39 -07008#include <phosphor-logging/log.hpp>
9
10using namespace phosphor::logging;
Patrick Venturec9508db2018-10-16 17:18:43 -070011
vishwa13555bd2015-11-10 12:10:38 -060012//--------------------------------------------------------------------------
vishwac93d6d42015-12-16 11:55:16 -060013// This gets called by udev monitor soon after seeing hog plugs for EEPROMS.
vishwa13555bd2015-11-10 12:10:38 -060014//--------------------------------------------------------------------------
Patrick Venturec9508db2018-10-16 17:18:43 -070015int main(int argc, char** argv)
vishwa13555bd2015-11-10 12:10:38 -060016{
17 int rc = 0;
Oskar Senft8f511092018-12-04 13:53:16 -050018 uint8_t fruid;
Patrick Ventured847f502019-03-26 11:12:39 -070019 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));
vishwa13555bd2015-11-10 12:10:38 -060027
vishwa13555bd2015-11-10 12:10:38 -060028 // Read the arguments.
Patrick Ventured847f502019-03-26 11:12:39 -070029 CLI11_PARSE(app, argc, argv);
vishwa13555bd2015-11-10 12:10:38 -060030
Patrick Venturea8093a22018-10-21 09:07:11 -070031 // 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);
vishwa13555bd2015-11-10 12:10:38 -060036
37 return (rc < 0 ? EXIT_FAILURE : EXIT_SUCCESS);
38}