blob: 18453bb6f7a2928c73ea0ecc1eb3066a83fa8066 [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 "occ_events.hpp"
4#include "occ_manager.hpp"
George Liuf3b75142021-06-10 11:22:50 +08005#include "utils.hpp"
Patrick Williamsd8aab2a2023-04-21 11:15:54 -05006
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>
Patrick Williamsd8aab2a2023-04-21 11:15:54 -050012#include <phosphor-logging/elog-errors.hpp>
Gunnar Mills94df8c92018-09-14 14:50:03 -050013#include <phosphor-logging/elog.hpp>
14#include <phosphor-logging/log.hpp>
15#include <xyz/openbmc_project/Common/error.hpp>
16
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053017using namespace phosphor::logging;
18
19using namespace sdbusplus::org::open_power::OCC::Device::Error;
Gunnar Mills94df8c92018-09-14 14:50:03 -050020using InternalFailure =
21 sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053022
George Liud0345ae2021-09-10 13:13:28 +080023int main(int /*argc*/, char** /*argv[]*/)
Deepak Kodihalli92a63412017-03-17 05:01:00 -050024{
George Liuf3b75142021-06-10 11:22:50 +080025 auto& bus = open_power::occ::utils::getBus();
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053026
27 // Need sd_event to watch for OCC device errors
28 sd_event* event = nullptr;
29 auto r = sd_event_default(&event);
30 if (r < 0)
Deepak Kodihalli92a63412017-03-17 05:01:00 -050031 {
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053032 log<level::ERR>("Error creating a default sd_event handler");
33 return r;
Deepak Kodihalli6b492fb2017-03-18 01:09:28 -050034 }
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053035 open_power::occ::EventPtr eventP{event};
36 event = nullptr;
37
38 // Attach the bus to sd_event to service user requests
39 bus.attach_event(eventP.get(), SD_EVENT_PRIORITY_NORMAL);
40
Chris Cainc86d80f2023-05-04 15:49:18 -050041 // Add object manager interfaces (for mapper)
Patrick Williamsaf408082022-07-22 19:26:54 -050042 sdbusplus::server::manager_t objManager(bus, OCC_CONTROL_ROOT);
Chicago Duanbb895cb2021-06-18 19:37:16 +080043#ifdef READ_OCC_SENSORS
Patrick Williamsaf408082022-07-22 19:26:54 -050044 sdbusplus::server::manager_t objManagerXyz(bus, OCC_SENSORS_ROOT);
Chicago Duanbb895cb2021-06-18 19:37:16 +080045#endif
Chris Cain1be43372021-12-09 19:29:37 -060046#ifdef POWER10
Patrick Williamsaf408082022-07-22 19:26:54 -050047 sdbusplus::server::manager_t objManagerXyzControl(
Chris Cain1be43372021-12-09 19:29:37 -060048 bus, "/xyz/openbmc_project/control");
49#endif
Chris Cainc86d80f2023-05-04 15:49:18 -050050 sdbusplus::server::manager_t objManagerXyzInventory(
51 bus, "/xyz/openbmc_project/inventory");
George Liuf3b75142021-06-10 11:22:50 +080052 open_power::occ::Manager mgr(eventP);
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053053
54 // Claim the bus since all the house keeping is done now
55 bus.request_name(OCC_CONTROL_BUSNAME);
56
57 // Wait for requests
58 sd_event_loop(eventP.get());
Deepak Kodihalli92a63412017-03-17 05:01:00 -050059
60 return 0;
61}