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