diff options
author | Andrew Geissler <andrewg@us.ibm.com> | 2017-03-20 14:20:49 -0500 |
---|---|---|
committer | Andrew Geissler <andrewg@us.ibm.com> | 2017-05-09 12:49:02 -0500 |
commit | 62817fa92d7a728e2b4d045019776cab0809289f (patch) | |
tree | fc8514b997ea82e4384696eac84dcaea8e53c39d /host-services.cpp | |
parent | dd2c6fdc50572c90d5919d0839f1dac82388c2ed (diff) | |
download | phosphor-host-ipmid-62817fa92d7a728e2b4d045019776cab0809289f.tar.gz phosphor-host-ipmid-62817fa92d7a728e2b4d045019776cab0809289f.zip |
Register new Control.Host bus in ipmid
This sets up the framework for future commits to implement
the required interfaces and signals in Control.Host
Change-Id: I43cd7d3047ed9cfbf1a01e7ba3a0310e9d47c307
Signed-off-by: Andrew Geissler <andrewg@us.ibm.com>
Diffstat (limited to 'host-services.cpp')
-rw-r--r-- | host-services.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/host-services.cpp b/host-services.cpp new file mode 100644 index 0000000..c78d90a --- /dev/null +++ b/host-services.cpp @@ -0,0 +1,39 @@ +#include <stdio.h> +#include <stdlib.h> +#include <errno.h> +#include <systemd/sd-bus.h> +#include <mapper.h> +#include "host-ipmid/ipmid-api.h" +#include "host-interface.hpp" +#include <config.h> + +void register_host_services() __attribute__((constructor)); + +//------------------------------------------------------ +// Callback register function +// ----------------------------------------------------- + +// Globals to keep the object alive during process life +std::unique_ptr<sdbusplus::bus::bus> sdbus = nullptr; +// TODO openbmc/openbmc#1581 - unique_ptr causes seg fault +phosphor::host::Host* host = nullptr; + +void register_host_services() +{ + // Gets a hook onto SYSTEM bus used by host-ipmid + sd_bus *bus = ipmid_get_sd_bus_connection(); + + sdbus = std::make_unique<sdbusplus::bus::bus>(bus); + + // Create new xyz.openbmc_project.host object on the bus + auto objPathInst = std::string{CONTROL_HOST_OBJPATH} + '0'; + + // Add sdbusplus ObjectManager. + sdbusplus::server::manager::manager objManager(*sdbus, + objPathInst.c_str()); + + host = new phosphor::host::Host(*sdbus, + objPathInst.c_str()); + + sdbus->request_name(CONTROL_HOST_BUSNAME); +} |