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