xref: /openbmc/phosphor-time-manager/main.cpp (revision 864e173e)
1 #include "config.h"
2 
3 #include "bmc_epoch.hpp"
4 #include "manager.hpp"
5 
6 #include <sdbusplus/bus.hpp>
7 
main()8 int main()
9 {
10     auto bus = sdbusplus::bus::new_default();
11     sd_event* event = nullptr;
12 
13     auto eventDeleter = [](sd_event* e) { sd_event_unref(e); };
14     using SdEvent = std::unique_ptr<sd_event, decltype(eventDeleter)>;
15 
16     // acquire a reference to the default event loop
17     sd_event_default(&event);
18     SdEvent sdEvent{event, eventDeleter};
19     event = nullptr;
20 
21     // attach bus to this event loop
22     bus.attach_event(sdEvent.get(), SD_EVENT_PRIORITY_NORMAL);
23 
24     // Add sdbusplus ObjectManager
25     sdbusplus::server::manager_t bmcEpochObjManager(bus, objpathBmc);
26 
27     phosphor::time::Manager manager(bus);
28     phosphor::time::BmcEpoch bmc(bus, objpathBmc, manager);
29 
30     bus.request_name(busname);
31 
32     // Start event loop for all sd-bus events and timer event
33     sd_event_loop(bus.get_event());
34 
35     bus.detach_event();
36 
37     return 0;
38 }
39