blob: c9e3a96b99361640fcc99822cf2224534d469460 [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
Patrick Williams7ce68bc2022-07-22 19:26:55 -050016 sdbusplus::bus_t bus = sdbusplus::bus::new_default();
Tony Lee84d430c2019-06-13 15:26:15 +080017
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
Patrick Williams7ce68bc2022-07-22 19:26:55 -050028 sdbusplus::server::manager_t objManager(bus, NVME_OBJ_PATH_ROOT);
Tony Lee84d430c2019-06-13 15:26:15 +080029
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}