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/lg2.hpp> 13 #include <xyz/openbmc_project/Common/error.hpp> 14 15 using namespace sdbusplus::org::open_power::OCC::Device::Error; 16 using InternalFailure = 17 sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure; 18 main(int,char **)19int main(int /*argc*/, char** /*argv[]*/) 20 { 21 auto& bus = open_power::occ::utils::getBus(); 22 23 // Need sd_event to watch for OCC device errors 24 sd_event* event = nullptr; 25 auto r = sd_event_default(&event); 26 if (r < 0) 27 { 28 lg2::error("Error creating a default sd_event handler"); 29 return r; 30 } 31 open_power::occ::EventPtr eventP{event}; 32 event = nullptr; 33 34 // Attach the bus to sd_event to service user requests 35 bus.attach_event(eventP.get(), SD_EVENT_PRIORITY_NORMAL); 36 37 // Add object manager interfaces (for mapper) 38 sdbusplus::server::manager_t objManager(bus, OCC_CONTROL_ROOT); 39 #ifdef READ_OCC_SENSORS 40 sdbusplus::server::manager_t objManagerXyz(bus, OCC_SENSORS_ROOT); 41 #endif 42 #ifdef POWER10 43 sdbusplus::server::manager_t objManagerXyzControl( 44 bus, "/xyz/openbmc_project/control"); 45 #endif 46 sdbusplus::server::manager_t objManagerXyzInventory( 47 bus, "/xyz/openbmc_project/inventory"); 48 open_power::occ::Manager mgr(eventP); 49 mgr.createPldmHandle(); 50 51 // Claim the bus since all the house keeping is done now 52 bus.request_name(OCC_CONTROL_BUSNAME); 53 54 // Wait for requests 55 sd_event_loop(eventP.get()); 56 57 return 0; 58 } 59