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