blob: 1d0ece3d3222398e0601b3693d1585aea764f6e0 [file] [log] [blame]
Vishwanatha Subbanna2180b2d2017-06-28 14:05:57 +05301#include "config.h"
Deepak Kodihalli92a63412017-03-17 05:01:00 -05002
Gunnar Mills94df8c92018-09-14 14:50:03 -05003#include "elog-errors.hpp"
4#include "occ_events.hpp"
5#include "occ_manager.hpp"
George Liuf3b75142021-06-10 11:22:50 +08006#include "utils.hpp"
Chris Cain1be43372021-12-09 19:29:37 -06007#ifdef POWER10
8#include "powermode.hpp"
9#endif
Gunnar Mills94df8c92018-09-14 14:50:03 -050010
11#include <org/open_power/OCC/Device/error.hpp>
12#include <phosphor-logging/elog.hpp>
13#include <phosphor-logging/log.hpp>
14#include <xyz/openbmc_project/Common/error.hpp>
15
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053016using namespace phosphor::logging;
17
18using namespace sdbusplus::org::open_power::OCC::Device::Error;
Gunnar Mills94df8c92018-09-14 14:50:03 -050019using InternalFailure =
20 sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053021
George Liud0345ae2021-09-10 13:13:28 +080022int main(int /*argc*/, char** /*argv[]*/)
Deepak Kodihalli92a63412017-03-17 05:01:00 -050023{
George Liuf3b75142021-06-10 11:22:50 +080024 auto& bus = open_power::occ::utils::getBus();
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053025
26 // Need sd_event to watch for OCC device errors
27 sd_event* event = nullptr;
28 auto r = sd_event_default(&event);
29 if (r < 0)
Deepak Kodihalli92a63412017-03-17 05:01:00 -050030 {
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053031 log<level::ERR>("Error creating a default sd_event handler");
32 return r;
Deepak Kodihalli6b492fb2017-03-18 01:09:28 -050033 }
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053034 open_power::occ::EventPtr eventP{event};
35 event = nullptr;
36
37 // Attach the bus to sd_event to service user requests
38 bus.attach_event(eventP.get(), SD_EVENT_PRIORITY_NORMAL);
39
Chris Cainc86d80f2023-05-04 15:49:18 -050040 // Add object manager interfaces (for mapper)
Patrick Williamsaf408082022-07-22 19:26:54 -050041 sdbusplus::server::manager_t objManager(bus, OCC_CONTROL_ROOT);
Chicago Duanbb895cb2021-06-18 19:37:16 +080042#ifdef READ_OCC_SENSORS
Patrick Williamsaf408082022-07-22 19:26:54 -050043 sdbusplus::server::manager_t objManagerXyz(bus, OCC_SENSORS_ROOT);
Chicago Duanbb895cb2021-06-18 19:37:16 +080044#endif
Chris Cain1be43372021-12-09 19:29:37 -060045#ifdef POWER10
Patrick Williamsaf408082022-07-22 19:26:54 -050046 sdbusplus::server::manager_t objManagerXyzControl(
Chris Cain1be43372021-12-09 19:29:37 -060047 bus, "/xyz/openbmc_project/control");
48#endif
Chris Cainc86d80f2023-05-04 15:49:18 -050049 sdbusplus::server::manager_t objManagerXyzInventory(
50 bus, "/xyz/openbmc_project/inventory");
George Liuf3b75142021-06-10 11:22:50 +080051 open_power::occ::Manager mgr(eventP);
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053052
53 // Claim the bus since all the house keeping is done now
54 bus.request_name(OCC_CONTROL_BUSNAME);
55
56 // Wait for requests
57 sd_event_loop(eventP.get());
Deepak Kodihalli92a63412017-03-17 05:01:00 -050058
59 return 0;
60}