Deepak Kodihalli | 6b492fb | 2017-03-18 01:09:28 -0500 | [diff] [blame] | 1 | #include <phosphor-logging/log.hpp> |
Vishwanatha Subbanna | ee4d83d | 2017-06-29 18:35:00 +0530 | [diff] [blame] | 2 | #include <phosphor-logging/elog.hpp> |
| 3 | #include <xyz/openbmc_project/Common/error.hpp> |
| 4 | #include <org/open_power/OCC/Device/error.hpp> |
Vishwanatha Subbanna | 2180b2d | 2017-06-28 14:05:57 +0530 | [diff] [blame] | 5 | #include "occ_manager.hpp" |
Vishwanatha Subbanna | ee4d83d | 2017-06-29 18:35:00 +0530 | [diff] [blame] | 6 | #include "occ_events.hpp" |
| 7 | #include "elog-errors.hpp" |
Vishwanatha Subbanna | 2180b2d | 2017-06-28 14:05:57 +0530 | [diff] [blame] | 8 | #include "config.h" |
Deepak Kodihalli | 92a6341 | 2017-03-17 05:01:00 -0500 | [diff] [blame] | 9 | |
Vishwanatha Subbanna | ee4d83d | 2017-06-29 18:35:00 +0530 | [diff] [blame] | 10 | using namespace phosphor::logging; |
| 11 | |
| 12 | using namespace sdbusplus::org::open_power::OCC::Device::Error; |
| 13 | using InternalFailure = sdbusplus::xyz::openbmc_project::Common:: |
| 14 | Error::InternalFailure; |
| 15 | |
Deepak Kodihalli | 92a6341 | 2017-03-17 05:01:00 -0500 | [diff] [blame] | 16 | int main(int argc, char* argv[]) |
| 17 | { |
Vishwanatha Subbanna | ee4d83d | 2017-06-29 18:35:00 +0530 | [diff] [blame] | 18 | auto bus = sdbusplus::bus::new_default(); |
| 19 | |
| 20 | // Need sd_event to watch for OCC device errors |
| 21 | sd_event* event = nullptr; |
| 22 | auto r = sd_event_default(&event); |
| 23 | if (r < 0) |
Deepak Kodihalli | 92a6341 | 2017-03-17 05:01:00 -0500 | [diff] [blame] | 24 | { |
Vishwanatha Subbanna | ee4d83d | 2017-06-29 18:35:00 +0530 | [diff] [blame] | 25 | log<level::ERR>("Error creating a default sd_event handler"); |
| 26 | return r; |
Deepak Kodihalli | 6b492fb | 2017-03-18 01:09:28 -0500 | [diff] [blame] | 27 | } |
Vishwanatha Subbanna | ee4d83d | 2017-06-29 18:35:00 +0530 | [diff] [blame] | 28 | open_power::occ::EventPtr eventP{event}; |
| 29 | event = nullptr; |
| 30 | |
| 31 | // Attach the bus to sd_event to service user requests |
| 32 | bus.attach_event(eventP.get(), SD_EVENT_PRIORITY_NORMAL); |
| 33 | |
| 34 | sdbusplus::server::manager::manager objManager(bus, OCC_CONTROL_ROOT); |
| 35 | open_power::occ::Manager mgr(bus, eventP); |
| 36 | |
| 37 | // Claim the bus since all the house keeping is done now |
| 38 | bus.request_name(OCC_CONTROL_BUSNAME); |
| 39 | |
| 40 | // Wait for requests |
| 41 | sd_event_loop(eventP.get()); |
Deepak Kodihalli | 92a6341 | 2017-03-17 05:01:00 -0500 | [diff] [blame] | 42 | |
| 43 | return 0; |
| 44 | } |