Tony Lee | 84d430c | 2019-06-13 15:26:15 +0800 | [diff] [blame] | 1 | #include "nvme_manager.hpp" |
| 2 | |
Tony Lee | 6c59501 | 2019-06-19 10:54:59 +0800 | [diff] [blame] | 3 | #include <string.h> |
| 4 | |
| 5 | #include <fstream> |
| 6 | #include <phosphor-logging/elog-errors.hpp> |
| 7 | #include <phosphor-logging/log.hpp> |
Tony Lee | 84d430c | 2019-06-13 15:26:15 +0800 | [diff] [blame] | 8 | #include <sdbusplus/bus.hpp> |
| 9 | #include <sdbusplus/sdbus.hpp> |
| 10 | #include <sdbusplus/server/manager.hpp> |
Tony Lee | 6c59501 | 2019-06-19 10:54:59 +0800 | [diff] [blame] | 11 | using namespace phosphor::logging; |
Tony Lee | 84d430c | 2019-06-13 15:26:15 +0800 | [diff] [blame] | 12 | |
| 13 | int 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 | } |