1155c34fbSMatthew Barth #include "writefrudata.hpp" 2155c34fbSMatthew Barth 3*d847f508SPatrick Venture #include <CLI/CLI.hpp> 452f1f189SPatrick Venture #include <cstdlib> 552f1f189SPatrick Venture #include <cstring> 6c9508db8SPatrick Venture #include <iostream> 7c9508db8SPatrick Venture #include <memory> 807f635c8SPatrick Venture #include <phosphor-logging/log.hpp> 907f635c8SPatrick Venture 1007f635c8SPatrick Venture using namespace phosphor::logging; 11c9508db8SPatrick Venture 12155c34fbSMatthew Barth //-------------------------------------------------------------------------- 13155c34fbSMatthew Barth // This gets called by udev monitor soon after seeing hog plugs for EEPROMS. 14155c34fbSMatthew Barth //-------------------------------------------------------------------------- 15155c34fbSMatthew Barth int main(int argc, char** argv) 16155c34fbSMatthew Barth { 17155c34fbSMatthew Barth int rc = 0; 188f51109dSOskar Senft uint8_t fruid; 19*d847f508SPatrick Venture std::string eeprom_file; 20*d847f508SPatrick Venture const int MAX_FRU_ID = 0xfe; 21*d847f508SPatrick Venture 22*d847f508SPatrick Venture CLI::App app{"OpenBMC IPMI-FRU-Parser"}; 23*d847f508SPatrick Venture app.add_option("-e,--eeprom", eeprom_file, "Absolute file name of eeprom") 24*d847f508SPatrick Venture ->check(CLI::ExistingFile); 25*d847f508SPatrick Venture app.add_option("-f,--fruid", fruid, "valid fru id in integer") 26*d847f508SPatrick Venture ->check(CLI::Range(0, MAX_FRU_ID)); 27155c34fbSMatthew Barth 28155c34fbSMatthew Barth // Read the arguments. 29*d847f508SPatrick Venture CLI11_PARSE(app, argc, argv); 30155c34fbSMatthew Barth 31c9508db8SPatrick Venture // Now that we have the file that contains the eeprom data, go read it 32c9508db8SPatrick Venture // and update the Inventory DB. 33a8093a25SPatrick Venture auto bus = sdbusplus::bus::new_default(); 34155c34fbSMatthew Barth bool bmc_fru = true; 35a8093a25SPatrick Venture rc = validateFRUArea(fruid, eeprom_file.c_str(), bus, bmc_fru); 36155c34fbSMatthew Barth 37155c34fbSMatthew Barth return (rc < 0 ? EXIT_FAILURE : EXIT_SUCCESS); 38155c34fbSMatthew Barth } 39