blob: ee02949bbdd12e934135298858efa45fe37e4d39 [file] [log] [blame]
Deepak Kodihalli6b492fb2017-03-18 01:09:28 -05001#include <phosphor-logging/log.hpp>
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +05302#include <phosphor-logging/elog.hpp>
3#include <xyz/openbmc_project/Common/error.hpp>
4#include <org/open_power/OCC/Device/error.hpp>
Vishwanatha Subbanna2180b2d2017-06-28 14:05:57 +05305#include "occ_manager.hpp"
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +05306#include "occ_events.hpp"
7#include "elog-errors.hpp"
Vishwanatha Subbanna2180b2d2017-06-28 14:05:57 +05308#include "config.h"
Deepak Kodihalli92a63412017-03-17 05:01:00 -05009
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053010using namespace phosphor::logging;
11
12using namespace sdbusplus::org::open_power::OCC::Device::Error;
13using InternalFailure = sdbusplus::xyz::openbmc_project::Common::
14 Error::InternalFailure;
15
Deepak Kodihalli92a63412017-03-17 05:01:00 -050016int main(int argc, char* argv[])
17{
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053018 auto bus = sdbusplus::bus::new_default();
19
20 // Need sd_event to watch for OCC device errors
21 sd_event* event = nullptr;
22 auto r = sd_event_default(&event);
23 if (r < 0)
Deepak Kodihalli92a63412017-03-17 05:01:00 -050024 {
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053025 log<level::ERR>("Error creating a default sd_event handler");
26 return r;
Deepak Kodihalli6b492fb2017-03-18 01:09:28 -050027 }
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053028 open_power::occ::EventPtr eventP{event};
29 event = nullptr;
30
31 // Attach the bus to sd_event to service user requests
32 bus.attach_event(eventP.get(), SD_EVENT_PRIORITY_NORMAL);
33
34 sdbusplus::server::manager::manager objManager(bus, OCC_CONTROL_ROOT);
35 open_power::occ::Manager mgr(bus, eventP);
36
37 // Claim the bus since all the house keeping is done now
38 bus.request_name(OCC_CONTROL_BUSNAME);
39
40 // Wait for requests
41 sd_event_loop(eventP.get());
Deepak Kodihalli92a63412017-03-17 05:01:00 -050042
43 return 0;
44}