blob: 174adc31ebd65cd48f8824ae43775a41c1ae0670 [file] [log] [blame]
Jayanth Othayoth671fc7f2017-06-14 08:01:41 -05001#include <sdbusplus/bus.hpp>
Jayanth Othayotha320c7c2017-06-14 07:17:21 -05002#include <phosphor-logging/elog-errors.hpp>
Jayanth Othayoth224882b2017-05-04 05:46:45 -05003
Jayanth Othayotha320c7c2017-06-14 07:17:21 -05004#include "xyz/openbmc_project/Common/error.hpp"
5#include "config.h"
6#include "dump_manager.hpp"
7#include "dump_internal.hpp"
Jayanth Othayothbcb174b2017-07-02 06:29:24 -05008#include "watch.hpp"
Jayanth Othayothd0f00642017-09-04 06:26:30 -05009#include "elog_watch.hpp"
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050010
11int main(int argc, char* argv[])
Jayanth Othayoth224882b2017-05-04 05:46:45 -050012{
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050013 using namespace phosphor::logging;
14 using InternalFailure =
15 sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
16
Jayanth Othayoth671fc7f2017-06-14 08:01:41 -050017 auto bus = sdbusplus::bus::new_default();
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050018 sd_event* event = nullptr;
19 auto rc = sd_event_default(&event);
20 if (rc < 0)
21 {
22 log<level::ERR>("Error occurred during the sd_event_default",
Gunnar Mills11eaab72017-10-19 16:07:31 -050023 entry("RC=%d", rc));
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050024 report<InternalFailure>();
25 return rc;
26 }
27 phosphor::dump::EventPtr eventP{event};
28 event = nullptr;
Jayanth Othayoth224882b2017-05-04 05:46:45 -050029
30 // Add sdbusplus ObjectManager for the 'root' path of the DUMP manager.
31 sdbusplus::server::manager::manager objManager(bus, DUMP_OBJPATH);
Jayanth Othayoth224882b2017-05-04 05:46:45 -050032 bus.request_name(DUMP_BUSNAME);
33
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050034 try
Jayanth Othayoth224882b2017-05-04 05:46:45 -050035 {
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050036 phosphor::dump::Manager manager(bus, eventP, DUMP_OBJPATH);
Jayanth Othayoth43096592017-07-20 02:17:37 -050037 //Restore dump d-bus objects.
38 manager.restore();
Jayanth Othayothd3273ea2017-07-12 22:55:32 -050039 phosphor::dump::internal::Manager mgr(bus, manager, OBJ_INTERNAL);
Jayanth Othayothd0f00642017-09-04 06:26:30 -050040 phosphor::dump::elog::Watch eWatch(bus, mgr);
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050041 bus.attach_event(eventP.get(), SD_EVENT_PRIORITY_NORMAL);
Jayanth Othayothbcb174b2017-07-02 06:29:24 -050042
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050043 auto rc = sd_event_loop(eventP.get());
44 if (rc < 0)
45 {
46 log<level::ERR>("Error occurred during the sd_event_loop",
Gunnar Mills11eaab72017-10-19 16:07:31 -050047 entry("RC=%d", rc));
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050048 elog<InternalFailure>();
49 }
50 }
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050051 catch (InternalFailure& e)
52 {
53 commit<InternalFailure>();
54 return -1;
Jayanth Othayoth224882b2017-05-04 05:46:45 -050055 }
56
57 return 0;
58}