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