1 #include "config.h" 2 3 #include "bios_handler.hpp" 4 #include "constants.hpp" 5 #include "exceptions.hpp" 6 #include "logger.hpp" 7 #include "manager.hpp" 8 #include "types.hpp" 9 #include "utility/event_logger_utility.hpp" 10 11 #include <sdbusplus/asio/connection.hpp> 12 #include <sdbusplus/asio/object_server.hpp> 13 14 #include <iostream> 15 16 /** 17 * @brief Main function for VPD parser application. 18 */ 19 int main(int, char**) 20 { 21 try 22 { 23 auto io_con = std::make_shared<boost::asio::io_context>(); 24 auto connection = 25 std::make_shared<sdbusplus::asio::connection>(*io_con); 26 auto server = sdbusplus::asio::object_server(connection); 27 28 std::shared_ptr<sdbusplus::asio::dbus_interface> interface = 29 server.add_interface(OBJPATH, IFACE); 30 31 std::shared_ptr<sdbusplus::asio::dbus_interface> progressInf = 32 server.add_interface(OBJPATH, 33 vpd::constants::vpdCollectionInterface); 34 35 auto vpdManager = std::make_shared<vpd::Manager>( 36 io_con, interface, progressInf, connection); 37 38 // TODO: Take this under conditional compilation for IBM 39 [[maybe_unused]] auto biosHandler = 40 std::make_shared<vpd::BiosHandler<vpd::IbmBiosHandler>>( 41 connection, vpdManager); 42 43 interface->initialize(); 44 progressInf->initialize(); 45 46 vpd::Logger::getLoggerInstance()->logMessage( 47 "Start VPD-Manager event loop"); 48 49 // Grab the bus name 50 connection->request_name(BUSNAME); 51 52 // Start event loop. 53 io_con->run(); 54 55 exit(EXIT_SUCCESS); 56 } 57 catch (const std::exception& l_ex) 58 { 59 vpd::Logger::getLoggerInstance()->logMessage( 60 "VPD-Manager service failed to start."); 61 vpd::EventLogger::createSyncPel( 62 vpd::EventLogger::getErrorType(l_ex), 63 vpd::types::SeverityType::Critical, __FILE__, __FUNCTION__, 0, 64 vpd::EventLogger::getErrorMsg(l_ex), std::nullopt, std::nullopt, 65 std::nullopt, std::nullopt); 66 } 67 exit(EXIT_FAILURE); 68 } 69