| Sunny Srivastava | fa5e4d3 | 2023-03-12 11:59:49 -0500 | [diff] [blame] | 1 | #include "config.h" | 
|  | 2 |  | 
|  | 3 | #include "bios_handler.hpp" | 
| Anupama B R | da9806b | 2025-08-29 02:41:10 -0500 | [diff] [blame] | 4 | #include "constants.hpp" | 
| Sunny Srivastava | fa5e4d3 | 2023-03-12 11:59:49 -0500 | [diff] [blame] | 5 | #include "event_logger.hpp" | 
|  | 6 | #include "exceptions.hpp" | 
|  | 7 | #include "logger.hpp" | 
|  | 8 | #include "manager.hpp" | 
|  | 9 | #include "types.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 |  | 
| Anupama B R | da9806b | 2025-08-29 02:41:10 -0500 | [diff] [blame] | 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); | 
| Sunny Srivastava | fa5e4d3 | 2023-03-12 11:59:49 -0500 | [diff] [blame] | 37 |  | 
| Sunny Srivastava | 5de031d | 2025-09-02 23:58:02 -0500 | [diff] [blame] | 38 | try | 
|  | 39 | { | 
|  | 40 | // TODO: Take this under conditional compilation for IBM | 
|  | 41 | auto biosHandler = | 
|  | 42 | std::make_shared<vpd::BiosHandler<vpd::IbmBiosHandler>>( | 
|  | 43 | connection, vpdManager); | 
|  | 44 | biosHandler->checkAndListenPldmService(); | 
|  | 45 | } | 
|  | 46 | catch (const std::exception& l_ex) | 
|  | 47 | { | 
|  | 48 | // Cathcing exception here explicitly to let VPD-Manager service | 
|  | 49 | // continue even when bios handler fails. | 
|  | 50 | const std::string& l_errMsg = | 
|  | 51 | "Instantiation of BIOS Handler failed. { " + | 
|  | 52 | std::string(l_ex.what()) + std::string(" }"); | 
|  | 53 |  | 
|  | 54 | vpd::EventLogger::createSyncPel( | 
|  | 55 | vpd::types::ErrorType::FirmwareError, | 
|  | 56 | vpd::types::SeverityType::Warning, __FILE__, __FUNCTION__, 0, | 
|  | 57 | l_errMsg, std::nullopt, std::nullopt, std::nullopt, | 
|  | 58 | std::nullopt); | 
|  | 59 | } | 
| Sunny Srivastava | fa5e4d3 | 2023-03-12 11:59:49 -0500 | [diff] [blame] | 60 |  | 
|  | 61 | interface->initialize(); | 
| Anupama B R | da9806b | 2025-08-29 02:41:10 -0500 | [diff] [blame] | 62 | progressInf->initialize(); | 
| Sunny Srivastava | fa5e4d3 | 2023-03-12 11:59:49 -0500 | [diff] [blame] | 63 |  | 
|  | 64 | vpd::logging::logMessage("Start VPD-Manager event loop"); | 
|  | 65 |  | 
|  | 66 | // Grab the bus name | 
|  | 67 | connection->request_name(BUSNAME); | 
|  | 68 |  | 
|  | 69 | // Start event loop. | 
|  | 70 | io_con->run(); | 
|  | 71 |  | 
|  | 72 | exit(EXIT_SUCCESS); | 
|  | 73 | } | 
|  | 74 | catch (const std::exception& l_ex) | 
|  | 75 | { | 
| Sunny Srivastava | de581eb | 2025-03-18 10:49:56 +0530 | [diff] [blame] | 76 | vpd::logging::logMessage("VPD-Manager service failed to start."); | 
| Sunny Srivastava | f574c3d | 2025-03-27 13:41:22 +0530 | [diff] [blame] | 77 | vpd::EventLogger::createSyncPel( | 
| Sunny Srivastava | de581eb | 2025-03-18 10:49:56 +0530 | [diff] [blame] | 78 | vpd::EventLogger::getErrorType(l_ex), | 
|  | 79 | vpd::types::SeverityType::Critical, __FILE__, __FUNCTION__, 0, | 
|  | 80 | vpd::EventLogger::getErrorMsg(l_ex), std::nullopt, std::nullopt, | 
|  | 81 | std::nullopt, std::nullopt); | 
| Sunny Srivastava | fa5e4d3 | 2023-03-12 11:59:49 -0500 | [diff] [blame] | 82 | } | 
|  | 83 | exit(EXIT_FAILURE); | 
|  | 84 | } |