blob: fe1a147f37bbbd4c1773cdd78d02edeb95cc0ffc [file] [log] [blame]
Jayanth Othayotha320c7c2017-06-14 07:17:21 -05001#include "config.h"
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -05002
Jayanth Othayotha320c7c2017-06-14 07:17:21 -05003#include "dump_internal.hpp"
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -05004#include "dump_manager.hpp"
Jayanth Othayothd0f00642017-09-04 06:26:30 -05005#include "elog_watch.hpp"
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -05006#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 Othayotha320c7c2017-06-14 07:17:21 -050011
12int main(int argc, char* argv[])
Jayanth Othayoth224882b2017-05-04 05:46:45 -050013{
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050014 using namespace phosphor::logging;
15 using InternalFailure =
16 sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
17
Jayanth Othayoth671fc7f2017-06-14 08:01:41 -050018 auto bus = sdbusplus::bus::new_default();
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050019 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 Mills11eaab72017-10-19 16:07:31 -050024 entry("RC=%d", rc));
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050025 report<InternalFailure>();
26 return rc;
27 }
28 phosphor::dump::EventPtr eventP{event};
29 event = nullptr;
Jayanth Othayoth224882b2017-05-04 05:46:45 -050030
31 // Add sdbusplus ObjectManager for the 'root' path of the DUMP manager.
32 sdbusplus::server::manager::manager objManager(bus, DUMP_OBJPATH);
Jayanth Othayoth224882b2017-05-04 05:46:45 -050033 bus.request_name(DUMP_BUSNAME);
34
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050035 try
Jayanth Othayoth224882b2017-05-04 05:46:45 -050036 {
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050037 phosphor::dump::Manager manager(bus, eventP, DUMP_OBJPATH);
Jayanth Othayothcb65ffc2018-10-16 08:29:32 -050038 // Restore dump d-bus objects.
Jayanth Othayoth43096592017-07-20 02:17:37 -050039 manager.restore();
Jayanth Othayothd3273ea2017-07-12 22:55:32 -050040 phosphor::dump::internal::Manager mgr(bus, manager, OBJ_INTERNAL);
Jayanth Othayothd0f00642017-09-04 06:26:30 -050041 phosphor::dump::elog::Watch eWatch(bus, mgr);
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050042 bus.attach_event(eventP.get(), SD_EVENT_PRIORITY_NORMAL);
Jayanth Othayothbcb174b2017-07-02 06:29:24 -050043
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050044 auto rc = sd_event_loop(eventP.get());
45 if (rc < 0)
46 {
47 log<level::ERR>("Error occurred during the sd_event_loop",
Gunnar Mills11eaab72017-10-19 16:07:31 -050048 entry("RC=%d", rc));
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050049 elog<InternalFailure>();
50 }
51 }
Jayanth Othayotha320c7c2017-06-14 07:17:21 -050052 catch (InternalFailure& e)
53 {
54 commit<InternalFailure>();
55 return -1;
Jayanth Othayoth224882b2017-05-04 05:46:45 -050056 }
57
58 return 0;
59}