1 #include "config.h" 2 3 #include "elog-errors.hpp" 4 #include "occ_events.hpp" 5 #include "occ_manager.hpp" 6 #include "utils.hpp" 7 #ifdef POWER10 8 #include "powermode.hpp" 9 #endif 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 16 using namespace phosphor::logging; 17 18 using namespace sdbusplus::org::open_power::OCC::Device::Error; 19 using InternalFailure = 20 sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure; 21 22 int main(int /*argc*/, char** /*argv[]*/) 23 { 24 auto& bus = open_power::occ::utils::getBus(); 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) 30 { 31 log<level::ERR>("Error creating a default sd_event handler"); 32 return r; 33 } 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 40 // Add object manager interfaces (for mapper) 41 sdbusplus::server::manager_t objManager(bus, OCC_CONTROL_ROOT); 42 #ifdef READ_OCC_SENSORS 43 sdbusplus::server::manager_t objManagerXyz(bus, OCC_SENSORS_ROOT); 44 #endif 45 #ifdef POWER10 46 sdbusplus::server::manager_t objManagerXyzControl( 47 bus, "/xyz/openbmc_project/control"); 48 #endif 49 sdbusplus::server::manager_t objManagerXyzInventory( 50 bus, "/xyz/openbmc_project/inventory"); 51 open_power::occ::Manager mgr(eventP); 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()); 58 59 return 0; 60 } 61