1 #include "config.h"
2 
3 #include "dump_internal.hpp"
4 #include "dump_manager.hpp"
5 #include "elog_watch.hpp"
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>
11 
12 int main(int argc, char* argv[])
13 {
14     using namespace phosphor::logging;
15     using InternalFailure =
16         sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
17 
18     auto bus = sdbusplus::bus::new_default();
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",
24                         entry("RC=%d", rc));
25         report<InternalFailure>();
26         return rc;
27     }
28     phosphor::dump::EventPtr eventP{event};
29     event = nullptr;
30 
31     // Add sdbusplus ObjectManager for the 'root' path of the DUMP manager.
32     sdbusplus::server::manager::manager objManager(bus, DUMP_OBJPATH);
33     bus.request_name(DUMP_BUSNAME);
34 
35     try
36     {
37         phosphor::dump::Manager manager(bus, eventP, DUMP_OBJPATH);
38         // Restore dump d-bus objects.
39         manager.restore();
40         phosphor::dump::internal::Manager mgr(bus, manager, OBJ_INTERNAL);
41         phosphor::dump::elog::Watch eWatch(bus, mgr);
42         bus.attach_event(eventP.get(), SD_EVENT_PRIORITY_NORMAL);
43 
44         auto rc = sd_event_loop(eventP.get());
45         if (rc < 0)
46         {
47             log<level::ERR>("Error occurred during the sd_event_loop",
48                             entry("RC=%d", rc));
49             elog<InternalFailure>();
50         }
51     }
52     catch (InternalFailure& e)
53     {
54         commit<InternalFailure>();
55         return -1;
56     }
57 
58     return 0;
59 }
60