blob: 500d1d8e9ed9acc3bda11f89e55740c46c56210c [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 Williamscfa96af2023-05-10 07:50:26 -05004#include <phosphor-logging/log.hpp>
5
Patrick Venture52f1f182018-10-17 13:05:03 -07006#include <cstdlib>
7#include <cstring>
Patrick Venturec9508db2018-10-16 17:18:43 -07008#include <iostream>
9#include <memory>
Patrick Venture07f635c2018-10-19 09:19:39 -070010
11using namespace phosphor::logging;
Patrick Venturec9508db2018-10-16 17:18:43 -070012
vishwa13555bd2015-11-10 12:10:38 -060013//--------------------------------------------------------------------------
vishwac93d6d42015-12-16 11:55:16 -060014// This gets called by udev monitor soon after seeing hog plugs for EEPROMS.
vishwa13555bd2015-11-10 12:10:38 -060015//--------------------------------------------------------------------------
Patrick Venturec9508db2018-10-16 17:18:43 -070016int main(int argc, char** argv)
vishwa13555bd2015-11-10 12:10:38 -060017{
18 int rc = 0;
Oskar Senft8f511092018-12-04 13:53:16 -050019 uint8_t fruid;
Patrick Ventured847f502019-03-26 11:12:39 -070020 std::string eeprom_file;
21 const int MAX_FRU_ID = 0xfe;
22
23 CLI::App app{"OpenBMC IPMI-FRU-Parser"};
24 app.add_option("-e,--eeprom", eeprom_file, "Absolute file name of eeprom")
25 ->check(CLI::ExistingFile);
26 app.add_option("-f,--fruid", fruid, "valid fru id in integer")
27 ->check(CLI::Range(0, MAX_FRU_ID));
vishwa13555bd2015-11-10 12:10:38 -060028
vishwa13555bd2015-11-10 12:10:38 -060029 // Read the arguments.
Patrick Ventured847f502019-03-26 11:12:39 -070030 CLI11_PARSE(app, argc, argv);
vishwa13555bd2015-11-10 12:10:38 -060031
Patrick Venturea8093a22018-10-21 09:07:11 -070032 // Now that we have the file that contains the eeprom data, go read it
33 // and update the Inventory DB.
34 auto bus = sdbusplus::bus::new_default();
35 bool bmc_fru = true;
36 rc = validateFRUArea(fruid, eeprom_file.c_str(), bus, bmc_fru);
vishwa13555bd2015-11-10 12:10:38 -060037
38 return (rc < 0 ? EXIT_FAILURE : EXIT_SUCCESS);
39}