1*671fc7f3SJayanth Othayoth #include <sdbusplus/bus.hpp> 2a320c7caSJayanth Othayoth #include <phosphor-logging/elog-errors.hpp> 3a320c7caSJayanth Othayoth 4a320c7caSJayanth Othayoth #include "xyz/openbmc_project/Common/error.hpp" 5224882b0SJayanth Othayoth #include "config.h" 6a320c7caSJayanth Othayoth #include "dump_manager.hpp" 7a320c7caSJayanth Othayoth #include "dump_internal.hpp" 8224882b0SJayanth Othayoth 9224882b0SJayanth Othayoth int main(int argc, char* argv[]) 10224882b0SJayanth Othayoth { 11a320c7caSJayanth Othayoth using namespace phosphor::logging; 12a320c7caSJayanth Othayoth using InternalFailure = 13a320c7caSJayanth Othayoth sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure; 14a320c7caSJayanth Othayoth 15*671fc7f3SJayanth Othayoth auto bus = sdbusplus::bus::new_default(); 16a320c7caSJayanth Othayoth sd_event* event = nullptr; 17a320c7caSJayanth Othayoth auto rc = sd_event_default(&event); 18a320c7caSJayanth Othayoth if (rc < 0) 19a320c7caSJayanth Othayoth { 20a320c7caSJayanth Othayoth log<level::ERR>("Error occurred during the sd_event_default", 21a320c7caSJayanth Othayoth entry("rc=%d", rc)); 22a320c7caSJayanth Othayoth report<InternalFailure>(); 23a320c7caSJayanth Othayoth return rc; 24a320c7caSJayanth Othayoth } 25a320c7caSJayanth Othayoth phosphor::dump::EventPtr eventP{event}; 26a320c7caSJayanth Othayoth event = nullptr; 27224882b0SJayanth Othayoth 28224882b0SJayanth Othayoth // Add sdbusplus ObjectManager for the 'root' path of the DUMP manager. 29224882b0SJayanth Othayoth sdbusplus::server::manager::manager objManager(bus, DUMP_OBJPATH); 30224882b0SJayanth Othayoth bus.request_name(DUMP_BUSNAME); 31224882b0SJayanth Othayoth 32a320c7caSJayanth Othayoth try 33224882b0SJayanth Othayoth { 34a320c7caSJayanth Othayoth phosphor::dump::Manager manager(bus, eventP, DUMP_OBJPATH); 35a320c7caSJayanth Othayoth phosphor::dump::internal::Manager mgr(bus, OBJ_INTERNAL); 36a320c7caSJayanth Othayoth bus.attach_event(eventP.get(), SD_EVENT_PRIORITY_NORMAL); 37a320c7caSJayanth Othayoth auto rc = sd_event_loop(eventP.get()); 38a320c7caSJayanth Othayoth if (rc < 0) 39a320c7caSJayanth Othayoth { 40a320c7caSJayanth Othayoth log<level::ERR>("Error occurred during the sd_event_loop", 41a320c7caSJayanth Othayoth entry("rc=%d", rc)); 42a320c7caSJayanth Othayoth elog<InternalFailure>(); 43a320c7caSJayanth Othayoth } 44a320c7caSJayanth Othayoth } 45a320c7caSJayanth Othayoth catch (InternalFailure& e) 46a320c7caSJayanth Othayoth { 47a320c7caSJayanth Othayoth commit<InternalFailure>(); 48a320c7caSJayanth Othayoth return -1; 49224882b0SJayanth Othayoth } 50224882b0SJayanth Othayoth 51224882b0SJayanth Othayoth return 0; 52224882b0SJayanth Othayoth } 53