blob: 2e05a185a8ad2c35ecfefd40722509515a804411 [file] [log] [blame]
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -05001#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 */
18int 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 Srivastavade581eb2025-03-18 10:49:56 +053052 vpd::logging::logMessage("VPD-Manager service failed to start.");
Sunny Srivastavaf574c3d2025-03-27 13:41:22 +053053 vpd::EventLogger::createSyncPel(
Sunny Srivastavade581eb2025-03-18 10:49:56 +053054 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 Srivastavafa5e4d32023-03-12 11:59:49 -050058 }
59 exit(EXIT_FAILURE);
60}