Vishwanatha Subbanna | 2180b2d | 2017-06-28 14:05:57 +0530 | [diff] [blame] | 1 | #include "config.h" |
Deepak Kodihalli | 92a6341 | 2017-03-17 05:01:00 -0500 | [diff] [blame] | 2 | |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 3 | #include "elog-errors.hpp" |
| 4 | #include "occ_events.hpp" |
| 5 | #include "occ_manager.hpp" |
George Liu | f3b7514 | 2021-06-10 11:22:50 +0800 | [diff] [blame] | 6 | #include "utils.hpp" |
Chris Cain | 1be4337 | 2021-12-09 19:29:37 -0600 | [diff] [blame] | 7 | #ifdef POWER10 |
| 8 | #include "powermode.hpp" |
| 9 | #endif |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 10 | |
| 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 Subbanna | ee4d83d | 2017-06-29 18:35:00 +0530 | [diff] [blame] | 16 | using namespace phosphor::logging; |
| 17 | |
| 18 | using namespace sdbusplus::org::open_power::OCC::Device::Error; |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 19 | using InternalFailure = |
| 20 | sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure; |
Vishwanatha Subbanna | ee4d83d | 2017-06-29 18:35:00 +0530 | [diff] [blame] | 21 | |
George Liu | d0345ae | 2021-09-10 13:13:28 +0800 | [diff] [blame] | 22 | int main(int /*argc*/, char** /*argv[]*/) |
Deepak Kodihalli | 92a6341 | 2017-03-17 05:01:00 -0500 | [diff] [blame] | 23 | { |
George Liu | f3b7514 | 2021-06-10 11:22:50 +0800 | [diff] [blame] | 24 | auto& bus = open_power::occ::utils::getBus(); |
Vishwanatha Subbanna | ee4d83d | 2017-06-29 18:35:00 +0530 | [diff] [blame] | 25 | |
| 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 Kodihalli | 92a6341 | 2017-03-17 05:01:00 -0500 | [diff] [blame] | 30 | { |
Vishwanatha Subbanna | ee4d83d | 2017-06-29 18:35:00 +0530 | [diff] [blame] | 31 | log<level::ERR>("Error creating a default sd_event handler"); |
| 32 | return r; |
Deepak Kodihalli | 6b492fb | 2017-03-18 01:09:28 -0500 | [diff] [blame] | 33 | } |
Vishwanatha Subbanna | ee4d83d | 2017-06-29 18:35:00 +0530 | [diff] [blame] | 34 | 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 Cain | c86d80f | 2023-05-04 15:49:18 -0500 | [diff] [blame] | 40 | // Add object manager interfaces (for mapper) |
Patrick Williams | af40808 | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 41 | sdbusplus::server::manager_t objManager(bus, OCC_CONTROL_ROOT); |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 42 | #ifdef READ_OCC_SENSORS |
Patrick Williams | af40808 | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 43 | sdbusplus::server::manager_t objManagerXyz(bus, OCC_SENSORS_ROOT); |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 44 | #endif |
Chris Cain | 1be4337 | 2021-12-09 19:29:37 -0600 | [diff] [blame] | 45 | #ifdef POWER10 |
Patrick Williams | af40808 | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 46 | sdbusplus::server::manager_t objManagerXyzControl( |
Chris Cain | 1be4337 | 2021-12-09 19:29:37 -0600 | [diff] [blame] | 47 | bus, "/xyz/openbmc_project/control"); |
| 48 | #endif |
Chris Cain | c86d80f | 2023-05-04 15:49:18 -0500 | [diff] [blame] | 49 | sdbusplus::server::manager_t objManagerXyzInventory( |
| 50 | bus, "/xyz/openbmc_project/inventory"); |
George Liu | f3b7514 | 2021-06-10 11:22:50 +0800 | [diff] [blame] | 51 | open_power::occ::Manager mgr(eventP); |
Vishwanatha Subbanna | ee4d83d | 2017-06-29 18:35:00 +0530 | [diff] [blame] | 52 | |
| 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 Kodihalli | 92a6341 | 2017-03-17 05:01:00 -0500 | [diff] [blame] | 58 | |
| 59 | return 0; |
| 60 | } |