12180b2daSVishwanatha Subbanna #include "config.h" 292a6341eSDeepak Kodihalli 394df8c90SGunnar Mills #include "elog-errors.hpp" 494df8c90SGunnar Mills #include "occ_events.hpp" 594df8c90SGunnar Mills #include "occ_manager.hpp" 6f3b7514eSGeorge Liu #include "utils.hpp" 71be4337bSChris Cain #ifdef POWER10 81be4337bSChris Cain #include "powermode.hpp" 91be4337bSChris Cain #endif 1094df8c90SGunnar Mills 1194df8c90SGunnar Mills #include <org/open_power/OCC/Device/error.hpp> 1294df8c90SGunnar Mills #include <phosphor-logging/elog.hpp> 1394df8c90SGunnar Mills #include <phosphor-logging/log.hpp> 1494df8c90SGunnar Mills #include <xyz/openbmc_project/Common/error.hpp> 1594df8c90SGunnar Mills 16ee4d83dfSVishwanatha Subbanna using namespace phosphor::logging; 17ee4d83dfSVishwanatha Subbanna 18ee4d83dfSVishwanatha Subbanna using namespace sdbusplus::org::open_power::OCC::Device::Error; 1994df8c90SGunnar Mills using InternalFailure = 2094df8c90SGunnar Mills sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure; 21ee4d83dfSVishwanatha Subbanna 22d0345ae0SGeorge Liu int main(int /*argc*/, char** /*argv[]*/) 2392a6341eSDeepak Kodihalli { 24f3b7514eSGeorge Liu auto& bus = open_power::occ::utils::getBus(); 25ee4d83dfSVishwanatha Subbanna 26ee4d83dfSVishwanatha Subbanna // Need sd_event to watch for OCC device errors 27ee4d83dfSVishwanatha Subbanna sd_event* event = nullptr; 28ee4d83dfSVishwanatha Subbanna auto r = sd_event_default(&event); 29ee4d83dfSVishwanatha Subbanna if (r < 0) 30ee4d83dfSVishwanatha Subbanna { 31ee4d83dfSVishwanatha Subbanna log<level::ERR>("Error creating a default sd_event handler"); 32ee4d83dfSVishwanatha Subbanna return r; 33ee4d83dfSVishwanatha Subbanna } 34ee4d83dfSVishwanatha Subbanna open_power::occ::EventPtr eventP{event}; 35ee4d83dfSVishwanatha Subbanna event = nullptr; 36ee4d83dfSVishwanatha Subbanna 37ee4d83dfSVishwanatha Subbanna // Attach the bus to sd_event to service user requests 38ee4d83dfSVishwanatha Subbanna bus.attach_event(eventP.get(), SD_EVENT_PRIORITY_NORMAL); 39ee4d83dfSVishwanatha Subbanna 40*af40808fSPatrick Williams sdbusplus::server::manager_t objManager(bus, OCC_CONTROL_ROOT); 41bb895cb8SChicago Duan #ifdef READ_OCC_SENSORS 42*af40808fSPatrick Williams sdbusplus::server::manager_t objManagerXyz(bus, OCC_SENSORS_ROOT); 43bb895cb8SChicago Duan #endif 441be4337bSChris Cain #ifdef POWER10 45*af40808fSPatrick Williams sdbusplus::server::manager_t objManagerXyzControl( 461be4337bSChris Cain bus, "/xyz/openbmc_project/control"); 471be4337bSChris Cain #endif 48f3b7514eSGeorge Liu open_power::occ::Manager mgr(eventP); 49ee4d83dfSVishwanatha Subbanna 50ee4d83dfSVishwanatha Subbanna // Claim the bus since all the house keeping is done now 512180b2daSVishwanatha Subbanna bus.request_name(OCC_CONTROL_BUSNAME); 52fd358d18SDeepak Kodihalli 53ee4d83dfSVishwanatha Subbanna // Wait for requests 54ee4d83dfSVishwanatha Subbanna sd_event_loop(eventP.get()); 5592a6341eSDeepak Kodihalli 5692a6341eSDeepak Kodihalli return 0; 5792a6341eSDeepak Kodihalli } 58