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