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