blob: ade107383c31261d037df3ff20405f9683f25f25 [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 Othayotha320c7c2017-06-14 07:17:21 -05009
10int main(int argc, char* argv[])
Jayanth Othayoth224882b2017-05-04 05:46:45 -050011{
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050012 using namespace phosphor::logging;
13 using InternalFailure =
14 sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
15
Jayanth Othayoth671fc7f2017-06-14 08:01:41 -050016 auto bus = sdbusplus::bus::new_default();
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050017 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 Othayoth224882b2017-05-04 05:46:45 -050028
29 // Add sdbusplus ObjectManager for the 'root' path of the DUMP manager.
30 sdbusplus::server::manager::manager objManager(bus, DUMP_OBJPATH);
Jayanth Othayoth224882b2017-05-04 05:46:45 -050031 bus.request_name(DUMP_BUSNAME);
32
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050033 try
Jayanth Othayoth224882b2017-05-04 05:46:45 -050034 {
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050035 phosphor::dump::Manager manager(bus, eventP, DUMP_OBJPATH);
Jayanth Othayoth43096592017-07-20 02:17:37 -050036 //Restore dump d-bus objects.
37 manager.restore();
Jayanth Othayothd3273ea2017-07-12 22:55:32 -050038 phosphor::dump::internal::Manager mgr(bus, manager, OBJ_INTERNAL);
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050039 bus.attach_event(eventP.get(), SD_EVENT_PRIORITY_NORMAL);
Jayanth Othayothbcb174b2017-07-02 06:29:24 -050040
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050041 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 Othayotha320c7c2017-06-14 07:17:21 -050049 catch (InternalFailure& e)
50 {
51 commit<InternalFailure>();
52 return -1;
Jayanth Othayoth224882b2017-05-04 05:46:45 -050053 }
54
55 return 0;
56}