Lei YU | 2f9c0cc | 2017-01-20 14:02:03 +0800 | [diff] [blame] | 1 | #include "config.h" |
Gunnar Mills | ab4cc6a | 2018-09-14 14:42:39 -0500 | [diff] [blame] | 2 | |
Lei YU | 9623282 | 2017-01-20 14:05:46 +0800 | [diff] [blame] | 3 | #include "bmc_epoch.hpp" |
Lei YU | 415b964 | 2017-02-09 11:37:26 +0800 | [diff] [blame] | 4 | #include "manager.hpp" |
Lei YU | 2f9c0cc | 2017-01-20 14:02:03 +0800 | [diff] [blame] | 5 | |
Gunnar Mills | ab4cc6a | 2018-09-14 14:42:39 -0500 | [diff] [blame] | 6 | #include <sdbusplus/bus.hpp> |
7 | |||||
Lei YU | 2f9c0cc | 2017-01-20 14:02:03 +0800 | [diff] [blame] | 8 | int main() |
9 | { | ||||
10 | auto bus = sdbusplus::bus::new_default(); | ||||
Lei YU | 7b21879 | 2017-02-09 12:10:13 +0800 | [diff] [blame] | 11 | sd_event* event = nullptr; |
12 | |||||
George Liu | 261525d | 2022-07-01 17:02:55 +0800 | [diff] [blame] | 13 | auto eventDeleter = [](sd_event* e) { sd_event_unref(e); }; |
Lei YU | 7b21879 | 2017-02-09 12:10:13 +0800 | [diff] [blame] | 14 | using SdEvent = std::unique_ptr<sd_event, decltype(eventDeleter)>; |
15 | |||||
Gunnar Mills | 7f25c53 | 2017-10-25 20:45:28 -0500 | [diff] [blame] | 16 | // acquire a reference to the default event loop |
Lei YU | 7b21879 | 2017-02-09 12:10:13 +0800 | [diff] [blame] | 17 | sd_event_default(&event); |
Gunnar Mills | ab4cc6a | 2018-09-14 14:42:39 -0500 | [diff] [blame] | 18 | SdEvent sdEvent{event, eventDeleter}; |
Lei YU | 7b21879 | 2017-02-09 12:10:13 +0800 | [diff] [blame] | 19 | event = nullptr; |
20 | |||||
21 | // attach bus to this event loop | ||||
22 | bus.attach_event(sdEvent.get(), SD_EVENT_PRIORITY_NORMAL); | ||||
Lei YU | 415b964 | 2017-02-09 11:37:26 +0800 | [diff] [blame] | 23 | |
24 | // Add sdbusplus ObjectManager | ||||
Patrick Williams | 3867926 | 2022-07-22 19:26:55 -0500 | [diff] [blame] | 25 | sdbusplus::server::manager_t bmcEpochObjManager(bus, OBJPATH_BMC); |
Lei YU | 415b964 | 2017-02-09 11:37:26 +0800 | [diff] [blame] | 26 | |
Lei YU | 9623282 | 2017-01-20 14:05:46 +0800 | [diff] [blame] | 27 | phosphor::time::BmcEpoch bmc(bus, OBJPATH_BMC); |
George Liu | 0a70452 | 2020-04-13 14:51:40 +0800 | [diff] [blame] | 28 | phosphor::time::Manager manager(bus); |
Lei YU | 415b964 | 2017-02-09 11:37:26 +0800 | [diff] [blame] | 29 | |
Lei YU | 2f9c0cc | 2017-01-20 14:02:03 +0800 | [diff] [blame] | 30 | bus.request_name(BUSNAME); |
31 | |||||
Lei YU | 7b21879 | 2017-02-09 12:10:13 +0800 | [diff] [blame] | 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 | |||||
Lei YU | 2f9c0cc | 2017-01-20 14:02:03 +0800 | [diff] [blame] | 37 | return 0; |
38 | } |