Jayanth Othayoth | 671fc7f | 2017-06-14 08:01:41 -0500 | [diff] [blame] | 1 | #include <sdbusplus/bus.hpp> |
Jayanth Othayoth | a320c7c | 2017-06-14 07:17:21 -0500 | [diff] [blame] | 2 | #include <phosphor-logging/elog-errors.hpp> |
Jayanth Othayoth | 224882b | 2017-05-04 05:46:45 -0500 | [diff] [blame] | 3 | |
Jayanth Othayoth | a320c7c | 2017-06-14 07:17:21 -0500 | [diff] [blame] | 4 | #include "xyz/openbmc_project/Common/error.hpp" |
| 5 | #include "config.h" |
| 6 | #include "dump_manager.hpp" |
| 7 | #include "dump_internal.hpp" |
Jayanth Othayoth | bcb174b | 2017-07-02 06:29:24 -0500 | [diff] [blame] | 8 | #include "watch.hpp" |
Jayanth Othayoth | a320c7c | 2017-06-14 07:17:21 -0500 | [diff] [blame] | 9 | |
| 10 | int main(int argc, char* argv[]) |
Jayanth Othayoth | 224882b | 2017-05-04 05:46:45 -0500 | [diff] [blame] | 11 | { |
Jayanth Othayoth | a320c7c | 2017-06-14 07:17:21 -0500 | [diff] [blame] | 12 | using namespace phosphor::logging; |
| 13 | using InternalFailure = |
| 14 | sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure; |
| 15 | |
Jayanth Othayoth | 671fc7f | 2017-06-14 08:01:41 -0500 | [diff] [blame] | 16 | auto bus = sdbusplus::bus::new_default(); |
Jayanth Othayoth | a320c7c | 2017-06-14 07:17:21 -0500 | [diff] [blame] | 17 | sd_event* event = nullptr; |
| 18 | auto rc = sd_event_default(&event); |
| 19 | if (rc < 0) |
| 20 | { |
| 21 | log<level::ERR>("Error occurred during the sd_event_default", |
| 22 | entry("rc=%d", rc)); |
| 23 | report<InternalFailure>(); |
| 24 | return rc; |
| 25 | } |
| 26 | phosphor::dump::EventPtr eventP{event}; |
| 27 | event = nullptr; |
Jayanth Othayoth | 224882b | 2017-05-04 05:46:45 -0500 | [diff] [blame] | 28 | |
| 29 | // Add sdbusplus ObjectManager for the 'root' path of the DUMP manager. |
| 30 | sdbusplus::server::manager::manager objManager(bus, DUMP_OBJPATH); |
Jayanth Othayoth | 224882b | 2017-05-04 05:46:45 -0500 | [diff] [blame] | 31 | bus.request_name(DUMP_BUSNAME); |
| 32 | |
Jayanth Othayoth | a320c7c | 2017-06-14 07:17:21 -0500 | [diff] [blame] | 33 | try |
Jayanth Othayoth | 224882b | 2017-05-04 05:46:45 -0500 | [diff] [blame] | 34 | { |
Jayanth Othayoth | a320c7c | 2017-06-14 07:17:21 -0500 | [diff] [blame] | 35 | phosphor::dump::Manager manager(bus, eventP, DUMP_OBJPATH); |
Jayanth Othayoth | 4309659 | 2017-07-20 02:17:37 -0500 | [diff] [blame] | 36 | //Restore dump d-bus objects. |
| 37 | manager.restore(); |
Jayanth Othayoth | d3273ea | 2017-07-12 22:55:32 -0500 | [diff] [blame] | 38 | phosphor::dump::internal::Manager mgr(bus, manager, OBJ_INTERNAL); |
Jayanth Othayoth | a320c7c | 2017-06-14 07:17:21 -0500 | [diff] [blame] | 39 | bus.attach_event(eventP.get(), SD_EVENT_PRIORITY_NORMAL); |
Jayanth Othayoth | bcb174b | 2017-07-02 06:29:24 -0500 | [diff] [blame] | 40 | |
Jayanth Othayoth | a320c7c | 2017-06-14 07:17:21 -0500 | [diff] [blame] | 41 | auto rc = sd_event_loop(eventP.get()); |
| 42 | if (rc < 0) |
| 43 | { |
| 44 | log<level::ERR>("Error occurred during the sd_event_loop", |
| 45 | entry("rc=%d", rc)); |
| 46 | elog<InternalFailure>(); |
| 47 | } |
| 48 | } |
Jayanth Othayoth | a320c7c | 2017-06-14 07:17:21 -0500 | [diff] [blame] | 49 | catch (InternalFailure& e) |
| 50 | { |
| 51 | commit<InternalFailure>(); |
| 52 | return -1; |
Jayanth Othayoth | 224882b | 2017-05-04 05:46:45 -0500 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | return 0; |
| 56 | } |