Sunny Srivastava | fa5e4d3 | 2023-03-12 11:59:49 -0500 | [diff] [blame] | 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 | { |
Sunny Srivastava | de581eb | 2025-03-18 10:49:56 +0530 | [diff] [blame] | 52 | vpd::logging::logMessage("VPD-Manager service failed to start."); |
Sunny Srivastava | f574c3d | 2025-03-27 13:41:22 +0530 | [diff] [blame] | 53 | vpd::EventLogger::createSyncPel( |
Sunny Srivastava | de581eb | 2025-03-18 10:49:56 +0530 | [diff] [blame] | 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); |
Sunny Srivastava | fa5e4d3 | 2023-03-12 11:59:49 -0500 | [diff] [blame] | 58 | } |
| 59 | exit(EXIT_FAILURE); |
| 60 | } |