-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathapp.cpp
58 lines (47 loc) · 1.61 KB
/
app.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "config.h"
#include "occ_events.hpp"
#include "occ_manager.hpp"
#include "utils.hpp"
#ifdef POWER10
#include "powermode.hpp"
#endif
#include <org/open_power/OCC/Device/error.hpp>
#include <phosphor-logging/lg2.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
using namespace sdbusplus::org::open_power::OCC::Device::Error;
using InternalFailure =
sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
int main(int /*argc*/, char** /*argv[]*/)
{
auto& bus = open_power::occ::utils::getBus();
// Need sd_event to watch for OCC device errors
sd_event* event = nullptr;
auto r = sd_event_default(&event);
if (r < 0)
{
lg2::error("Error creating a default sd_event handler");
return r;
}
open_power::occ::EventPtr eventP{event};
event = nullptr;
// Attach the bus to sd_event to service user requests
bus.attach_event(eventP.get(), SD_EVENT_PRIORITY_NORMAL);
// Add object manager interfaces (for mapper)
sdbusplus::server::manager_t objManager(bus, OCC_CONTROL_ROOT);
#ifdef READ_OCC_SENSORS
sdbusplus::server::manager_t objManagerXyz(bus, OCC_SENSORS_ROOT);
#endif
#ifdef POWER10
sdbusplus::server::manager_t objManagerXyzControl(
bus, "/xyz/openbmc_project/control");
#endif
sdbusplus::server::manager_t objManagerXyzInventory(
bus, "/xyz/openbmc_project/inventory");
open_power::occ::Manager mgr(eventP);
mgr.createPldmHandle();
// Claim the bus since all the house keeping is done now
bus.request_name(OCC_CONTROL_BUSNAME);
// Wait for requests
sd_event_loop(eventP.get());
return 0;
}