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" 6*f3b7514eSGeorge Liu #include "utils.hpp" 794df8c90SGunnar Mills 894df8c90SGunnar Mills #include <org/open_power/OCC/Device/error.hpp> 994df8c90SGunnar Mills #include <phosphor-logging/elog.hpp> 1094df8c90SGunnar Mills #include <phosphor-logging/log.hpp> 1194df8c90SGunnar Mills #include <xyz/openbmc_project/Common/error.hpp> 1294df8c90SGunnar Mills 13ee4d83dfSVishwanatha Subbanna using namespace phosphor::logging; 14ee4d83dfSVishwanatha Subbanna 15ee4d83dfSVishwanatha Subbanna using namespace sdbusplus::org::open_power::OCC::Device::Error; 1694df8c90SGunnar Mills using InternalFailure = 1794df8c90SGunnar Mills sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure; 18ee4d83dfSVishwanatha Subbanna 1992a6341eSDeepak Kodihalli int main(int argc, char* argv[]) 2092a6341eSDeepak Kodihalli { 21*f3b7514eSGeorge Liu auto& bus = open_power::occ::utils::getBus(); 22ee4d83dfSVishwanatha Subbanna 23ee4d83dfSVishwanatha Subbanna // Need sd_event to watch for OCC device errors 24ee4d83dfSVishwanatha Subbanna sd_event* event = nullptr; 25ee4d83dfSVishwanatha Subbanna auto r = sd_event_default(&event); 26ee4d83dfSVishwanatha Subbanna if (r < 0) 27ee4d83dfSVishwanatha Subbanna { 28ee4d83dfSVishwanatha Subbanna log<level::ERR>("Error creating a default sd_event handler"); 29ee4d83dfSVishwanatha Subbanna return r; 30ee4d83dfSVishwanatha Subbanna } 31ee4d83dfSVishwanatha Subbanna open_power::occ::EventPtr eventP{event}; 32ee4d83dfSVishwanatha Subbanna event = nullptr; 33ee4d83dfSVishwanatha Subbanna 34ee4d83dfSVishwanatha Subbanna // Attach the bus to sd_event to service user requests 35ee4d83dfSVishwanatha Subbanna bus.attach_event(eventP.get(), SD_EVENT_PRIORITY_NORMAL); 36ee4d83dfSVishwanatha Subbanna 37ee4d83dfSVishwanatha Subbanna sdbusplus::server::manager::manager objManager(bus, OCC_CONTROL_ROOT); 38*f3b7514eSGeorge Liu open_power::occ::Manager mgr(eventP); 39ee4d83dfSVishwanatha Subbanna 40ee4d83dfSVishwanatha Subbanna // Claim the bus since all the house keeping is done now 412180b2daSVishwanatha Subbanna bus.request_name(OCC_CONTROL_BUSNAME); 42fd358d18SDeepak Kodihalli 43ee4d83dfSVishwanatha Subbanna // Wait for requests 44ee4d83dfSVishwanatha Subbanna sd_event_loop(eventP.get()); 4592a6341eSDeepak Kodihalli 4692a6341eSDeepak Kodihalli return 0; 4792a6341eSDeepak Kodihalli } 48