blob: a26fa3cd76e766521bb958d0c5632417bb64a3a9 [file] [log] [blame]
Vishwanatha Subbanna2180b2d2017-06-28 14:05:57 +05301#include "config.h"
Deepak Kodihalli92a63412017-03-17 05:01:00 -05002
Gunnar Mills94df8c92018-09-14 14:50:03 -05003#include "elog-errors.hpp"
4#include "occ_events.hpp"
5#include "occ_manager.hpp"
George Liuf3b75142021-06-10 11:22:50 +08006#include "utils.hpp"
Gunnar Mills94df8c92018-09-14 14:50:03 -05007
8#include <org/open_power/OCC/Device/error.hpp>
9#include <phosphor-logging/elog.hpp>
10#include <phosphor-logging/log.hpp>
11#include <xyz/openbmc_project/Common/error.hpp>
12
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053013using namespace phosphor::logging;
14
15using namespace sdbusplus::org::open_power::OCC::Device::Error;
Gunnar Mills94df8c92018-09-14 14:50:03 -050016using InternalFailure =
17 sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053018
Deepak Kodihalli92a63412017-03-17 05:01:00 -050019int main(int argc, char* argv[])
20{
George Liuf3b75142021-06-10 11:22:50 +080021 auto& bus = open_power::occ::utils::getBus();
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053022
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)
Deepak Kodihalli92a63412017-03-17 05:01:00 -050027 {
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053028 log<level::ERR>("Error creating a default sd_event handler");
29 return r;
Deepak Kodihalli6b492fb2017-03-18 01:09:28 -050030 }
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053031 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 sdbusplus::server::manager::manager objManager(bus, OCC_CONTROL_ROOT);
George Liuf3b75142021-06-10 11:22:50 +080038 open_power::occ::Manager mgr(eventP);
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053039
40 // Claim the bus since all the house keeping is done now
41 bus.request_name(OCC_CONTROL_BUSNAME);
42
43 // Wait for requests
44 sd_event_loop(eventP.get());
Deepak Kodihalli92a63412017-03-17 05:01:00 -050045
46 return 0;
47}