blob: 956e3747e4beff2269a09d07429e38a7f4c4111f [file] [log] [blame]
Tony Lee84d430c2019-06-13 15:26:15 +08001#include "nvme_manager.hpp"
2
3#include <sdbusplus/bus.hpp>
4#include <sdbusplus/sdbus.hpp>
5#include <sdbusplus/server/manager.hpp>
6
7int main(void)
8{
9
10 sdbusplus::bus::bus bus = sdbusplus::bus::new_default();
11
12 sd_event* event = nullptr;
13 auto eventDeleter = [](sd_event* e) { e = sd_event_unref(e); };
14 using SdEvent = std::unique_ptr<sd_event, decltype(eventDeleter)>;
15 // acquire a reference to the default event loop
16 sd_event_default(&event);
17 SdEvent sdEvent{event, eventDeleter};
18 event = nullptr;
19 // attach bus to this event loop
20 bus.attach_event(sdEvent.get(), SD_EVENT_PRIORITY_NORMAL);
21
22 sdbusplus::server::manager::manager objManager(bus, NVME_OBJ_PATH_ROOT);
23
24 phosphor::nvme::Nvme objMgr(bus);
25
26 bus.request_name(NVME_REQUEST_NAME);
27
28 objMgr.run();
29
30 // Start event loop for all sd-bus events
31
32 sd_event_loop(bus.get_event());
33
34 bus.detach_event();
35
36 return 0;
37}