1671fc7f3SJayanth 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" 8bcb174bdSJayanth Othayoth #include "watch.hpp" 9224882b0SJayanth Othayoth 10224882b0SJayanth Othayoth int main(int argc, char* argv[]) 11224882b0SJayanth Othayoth { 12a320c7caSJayanth Othayoth using namespace phosphor::logging; 13a320c7caSJayanth Othayoth using InternalFailure = 14a320c7caSJayanth Othayoth sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure; 15a320c7caSJayanth Othayoth 16671fc7f3SJayanth Othayoth auto bus = sdbusplus::bus::new_default(); 17a320c7caSJayanth Othayoth sd_event* event = nullptr; 18a320c7caSJayanth Othayoth auto rc = sd_event_default(&event); 19a320c7caSJayanth Othayoth if (rc < 0) 20a320c7caSJayanth Othayoth { 21a320c7caSJayanth Othayoth log<level::ERR>("Error occurred during the sd_event_default", 22a320c7caSJayanth Othayoth entry("rc=%d", rc)); 23a320c7caSJayanth Othayoth report<InternalFailure>(); 24a320c7caSJayanth Othayoth return rc; 25a320c7caSJayanth Othayoth } 26a320c7caSJayanth Othayoth phosphor::dump::EventPtr eventP{event}; 27a320c7caSJayanth Othayoth event = nullptr; 28224882b0SJayanth Othayoth 29224882b0SJayanth Othayoth // Add sdbusplus ObjectManager for the 'root' path of the DUMP manager. 30224882b0SJayanth Othayoth sdbusplus::server::manager::manager objManager(bus, DUMP_OBJPATH); 31224882b0SJayanth Othayoth bus.request_name(DUMP_BUSNAME); 32224882b0SJayanth Othayoth 33a320c7caSJayanth Othayoth try 34224882b0SJayanth Othayoth { 35a320c7caSJayanth Othayoth phosphor::dump::Manager manager(bus, eventP, DUMP_OBJPATH); 36*d3273eadSJayanth Othayoth phosphor::dump::internal::Manager mgr(bus, manager, OBJ_INTERNAL); 37a320c7caSJayanth Othayoth bus.attach_event(eventP.get(), SD_EVENT_PRIORITY_NORMAL); 38bcb174bdSJayanth Othayoth 39a320c7caSJayanth Othayoth auto rc = sd_event_loop(eventP.get()); 40a320c7caSJayanth Othayoth if (rc < 0) 41a320c7caSJayanth Othayoth { 42a320c7caSJayanth Othayoth log<level::ERR>("Error occurred during the sd_event_loop", 43a320c7caSJayanth Othayoth entry("rc=%d", rc)); 44a320c7caSJayanth Othayoth elog<InternalFailure>(); 45a320c7caSJayanth Othayoth } 46a320c7caSJayanth Othayoth } 47a320c7caSJayanth Othayoth catch (InternalFailure& e) 48a320c7caSJayanth Othayoth { 49a320c7caSJayanth Othayoth commit<InternalFailure>(); 50a320c7caSJayanth Othayoth return -1; 51224882b0SJayanth Othayoth } 52224882b0SJayanth Othayoth 53224882b0SJayanth Othayoth return 0; 54224882b0SJayanth Othayoth } 55