xref: /openbmc/phosphor-time-manager/main.cpp (revision 3c2f4496)
1 #include "config.h"
2 
3 #include "bmc_epoch.hpp"
4 #include "manager.hpp"
5 
6 #include <sdbusplus/bus.hpp>
7 
8 int main()
9 {
10     auto bus = sdbusplus::bus::new_default();
11     sd_event* event = nullptr;
12 
13     auto eventDeleter = [](sd_event* e) { 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::manager bmcEpochObjManager(bus, OBJPATH_BMC);
26 
27     phosphor::time::Manager manager(bus);
28     phosphor::time::BmcEpoch bmc(bus, OBJPATH_BMC);
29 
30     manager.addListener(&bmc);
31 
32     bus.request_name(BUSNAME);
33 
34     // Start event loop for all sd-bus events and timer event
35     sd_event_loop(bus.get_event());
36 
37     bus.detach_event();
38 
39     return 0;
40 }
41