blob: ab1d3741c069bd3595150d2159486fa1d6c03bca [file] [log] [blame]
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -05001#include "config.h"
2
3#include "bios_handler.hpp"
Anupama B Rda9806b2025-08-29 02:41:10 -05004#include "constants.hpp"
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -05005#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 */
19int 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 Rda9806b2025-08-29 02:41:10 -050031 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 Srivastavafa5e4d32023-03-12 11:59:49 -050037
38 // TODO: Take this under conditional compilation for IBM
39 auto biosHandler =
40 std::make_shared<vpd::BiosHandler<vpd::IbmBiosHandler>>(
41 connection, vpdManager);
42
43 interface->initialize();
Anupama B Rda9806b2025-08-29 02:41:10 -050044 progressInf->initialize();
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -050045
46 vpd::logging::logMessage("Start VPD-Manager event loop");
47
48 // Grab the bus name
49 connection->request_name(BUSNAME);
50
51 // Start event loop.
52 io_con->run();
53
54 exit(EXIT_SUCCESS);
55 }
56 catch (const std::exception& l_ex)
57 {
Sunny Srivastavade581eb2025-03-18 10:49:56 +053058 vpd::logging::logMessage("VPD-Manager service failed to start.");
Sunny Srivastavaf574c3d2025-03-27 13:41:22 +053059 vpd::EventLogger::createSyncPel(
Sunny Srivastavade581eb2025-03-18 10:49:56 +053060 vpd::EventLogger::getErrorType(l_ex),
61 vpd::types::SeverityType::Critical, __FILE__, __FUNCTION__, 0,
62 vpd::EventLogger::getErrorMsg(l_ex), std::nullopt, std::nullopt,
63 std::nullopt, std::nullopt);
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -050064 }
65 exit(EXIT_FAILURE);
66}