blob: 1927f4e8bc35a40f9a78918c233ff165ce357f1e [file] [log] [blame]
Lei YU2f9c0cc2017-01-20 14:02:03 +08001#include "config.h"
Gunnar Millsab4cc6a2018-09-14 14:42:39 -05002
Lei YU96232822017-01-20 14:05:46 +08003#include "bmc_epoch.hpp"
Lei YU415b9642017-02-09 11:37:26 +08004#include "manager.hpp"
Lei YU2f9c0cc2017-01-20 14:02:03 +08005
Gunnar Millsab4cc6a2018-09-14 14:42:39 -05006#include <sdbusplus/bus.hpp>
7
Lei YU2f9c0cc2017-01-20 14:02:03 +08008int main()
9{
10 auto bus = sdbusplus::bus::new_default();
Lei YU7b218792017-02-09 12:10:13 +080011 sd_event* event = nullptr;
12
George Liu261525d2022-07-01 17:02:55 +080013 auto eventDeleter = [](sd_event* e) { sd_event_unref(e); };
Lei YU7b218792017-02-09 12:10:13 +080014 using SdEvent = std::unique_ptr<sd_event, decltype(eventDeleter)>;
15
Gunnar Mills7f25c532017-10-25 20:45:28 -050016 // acquire a reference to the default event loop
Lei YU7b218792017-02-09 12:10:13 +080017 sd_event_default(&event);
Gunnar Millsab4cc6a2018-09-14 14:42:39 -050018 SdEvent sdEvent{event, eventDeleter};
Lei YU7b218792017-02-09 12:10:13 +080019 event = nullptr;
20
21 // attach bus to this event loop
22 bus.attach_event(sdEvent.get(), SD_EVENT_PRIORITY_NORMAL);
Lei YU415b9642017-02-09 11:37:26 +080023
24 // Add sdbusplus ObjectManager
25 sdbusplus::server::manager::manager bmcEpochObjManager(bus, OBJPATH_BMC);
Lei YU415b9642017-02-09 11:37:26 +080026
Lei YU96232822017-01-20 14:05:46 +080027 phosphor::time::BmcEpoch bmc(bus, OBJPATH_BMC);
George Liu0a704522020-04-13 14:51:40 +080028 phosphor::time::Manager manager(bus);
Lei YU415b9642017-02-09 11:37:26 +080029
Lei YU2f9c0cc2017-01-20 14:02:03 +080030 bus.request_name(BUSNAME);
31
Lei YU7b218792017-02-09 12:10:13 +080032 // 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 YU2f9c0cc2017-01-20 14:02:03 +080037 return 0;
38}