summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app.cpp9
-rw-r--r--configure.ac12
-rw-r--r--file.hpp3
-rw-r--r--occ_manager.hpp91
-rw-r--r--occ_pass_through.cpp3
-rw-r--r--occ_pass_through.hpp93
6 files changed, 102 insertions, 109 deletions
diff --git a/app.cpp b/app.cpp
index 4b73e51..449bea3 100644
--- a/app.cpp
+++ b/app.cpp
@@ -1,18 +1,19 @@
#include <phosphor-logging/log.hpp>
#include <exception>
-#include "occ_pass_through.hpp"
+#include "occ_manager.hpp"
+#include "config.h"
int main(int argc, char* argv[])
{
try
{
auto bus = sdbusplus::bus::new_default();
- bus.request_name(OCC_PASS_THROUGH_BUSNAME);
+ bus.request_name(OCC_CONTROL_BUSNAME);
sdbusplus::server::manager::manager objManager(bus,
- OCC_PASS_THROUGH_ROOT);
+ OCC_CONTROL_ROOT);
- open_power::occ::pass_through::manager::Manager mgr(bus);
+ open_power::occ::Manager mgr(bus);
while (true)
{
diff --git a/configure.ac b/configure.ac
index 676dc0d..94673da 100644
--- a/configure.ac
+++ b/configure.ac
@@ -31,13 +31,13 @@ AS_IF([test "x$SDBUSPLUSPLUS" == "x"], AC_MSG_ERROR([Cannot find sdbus++]))
AX_CXX_COMPILE_STDCXX_14([noext])
AX_APPEND_COMPILE_FLAGS([-Wall -Werror], [CXXFLAGS])
-AC_ARG_VAR(OCC_PASS_THROUGH_BUSNAME, [The Dbus busname to own])
-AS_IF([test "x$OCC_PASS_THROUGH_BUSNAME" == "x"], [OCC_PASS_THROUGH_BUSNAME="org.open_power.OCC.PassThrough"])
-AC_DEFINE_UNQUOTED([OCC_PASS_THROUGH_BUSNAME], ["$OCC_PASS_THROUGH_BUSNAME"], [The DBus busname to own])
+AC_ARG_VAR(OCC_CONTROL_BUSNAME, [The Dbus busname to own])
+AS_IF([test "x$OCC_CONTROL_BUSNAME" == "x"], [OCC_CONTROL_BUSNAME="org.open_power.OCC.Control"])
+AC_DEFINE_UNQUOTED([OCC_CONTROL_BUSNAME], ["$OCC_CONTROL_BUSNAME"], [The DBus busname to own])
-AC_ARG_VAR(OCC_PASS_THROUGH_ROOT, [The Dbus root])
-AS_IF([test "x$OCC_PASS_THROUGH_ROOT" == "x"], [OCC_PASS_THROUGH_ROOT="/xyz/openbmc_project/occ/pass_through"])
-AC_DEFINE_UNQUOTED([OCC_PASS_THROUGH_ROOT], ["$OCC_PASS_THROUGH_ROOT"], [The Dbus root])
+AC_ARG_VAR(OCC_CONTROL_ROOT, [The Dbus root])
+AS_IF([test "x$OCC_CONTROL_ROOT" == "x"], [OCC_CONTROL_ROOT="/org/open_power/control"])
+AC_DEFINE_UNQUOTED([OCC_CONTROL_ROOT], ["$OCC_CONTROL_ROOT"], [The Dbus root])
AC_ARG_VAR(INVENTORY_ITEM_INTERFACE, [The Inventory.Item interface])
AS_IF([test "x$INVENTORY_ITEM_INTERFACE" == "x"], [INVENTORY_ITEM_INTERFACE="xyz.openbmc_project.Inventory.Item"])
diff --git a/file.hpp b/file.hpp
index 4d0a83c..bc5450f 100644
--- a/file.hpp
+++ b/file.hpp
@@ -5,8 +5,6 @@ namespace open_power
{
namespace occ
{
-namespace pass_through
-{
/** @class FileDescriptor
* @brief Responsible for handling file descriptor
*/
@@ -46,6 +44,5 @@ class FileDescriptor
}
};
-} // namespace pass_through
} // namespace occ
} // namespace open-power
diff --git a/occ_manager.hpp b/occ_manager.hpp
new file mode 100644
index 0000000..067a6d2
--- /dev/null
+++ b/occ_manager.hpp
@@ -0,0 +1,91 @@
+#pragma once
+
+#include <cstring>
+#include <vector>
+#include <experimental/filesystem>
+#include <functional>
+#include <sdbusplus/bus.hpp>
+#include "occ_pass_through.hpp"
+#include "config.h"
+
+namespace sdbusRule = sdbusplus::bus::match::rules;
+
+namespace open_power
+{
+namespace occ
+{
+
+/** @class Manager
+ * @brief Builds and manages OCC objects
+ */
+struct Manager
+{
+ public:
+ Manager() = delete;
+ Manager(const Manager&) = delete;
+ Manager& operator=(const Manager&) = delete;
+ Manager(Manager&&) = default;
+ Manager& operator=(Manager&&) = default;
+ ~Manager() = default;
+
+ /** @brief Ctor - Add OCC pass-through objects on the bus. Create
+ * OCC objects when corresponding CPU inventory is created.
+ * @param[in] bus - handle to the bus
+ */
+ Manager(sdbusplus::bus::bus& bus):
+ bus(bus)
+ {
+ for (auto id = 0; id < MAX_CPUS; ++id)
+ {
+ auto path = std::string(CPU_PATH) + std::to_string(id);
+ cpuMatches.emplace_back(
+ bus,
+ sdbusRule::interfacesAdded() +
+ sdbusRule::argNpath(0, path),
+ std::bind(std::mem_fn(&Manager::cpuCreated),
+ this, std::placeholders::_1));
+ }
+ }
+
+ /** @brief Callback that responds to cpu creation in the inventory -
+ * by creating the occ passthrough and status objects.
+ *
+ * @param[in] msg - bus message
+ *
+ * @returns 0 to indicate success
+ */
+ int cpuCreated(sdbusplus::message::message& msg)
+ {
+ namespace fs = std::experimental::filesystem;
+
+ sdbusplus::message::object_path o;
+ msg.read(o);
+ fs::path cpuPath(std::string(std::move(o)));
+ auto cpu = cpuPath.filename();
+
+ std::string name{cpu.c_str()};
+ auto index = name.find(CPU_NAME);
+ name.replace(index, std::strlen(CPU_NAME), OCC_NAME);
+
+ auto path = fs::path(OCC_CONTROL_ROOT) / name;
+ objects.emplace_back(
+ std::make_unique<PassThrough>(
+ bus,
+ path.c_str()));
+
+ return 0;
+ }
+
+ private:
+ /** @brief reference to the bus */
+ sdbusplus::bus::bus& bus;
+
+ /** @brief OCC pass-through objects */
+ std::vector<std::unique_ptr<PassThrough>> objects;
+
+ /** @brief sbdbusplus match objects */
+ std::vector<sdbusplus::bus::match_t> cpuMatches;
+};
+
+} // namespace occ
+} // namespace open_power
diff --git a/occ_pass_through.cpp b/occ_pass_through.cpp
index 911dd85..fbb98c2 100644
--- a/occ_pass_through.cpp
+++ b/occ_pass_through.cpp
@@ -11,8 +11,6 @@ namespace open_power
{
namespace occ
{
-namespace pass_through
-{
PassThrough::PassThrough(
sdbusplus::bus::bus& bus,
@@ -107,6 +105,5 @@ std::vector<int32_t> PassThrough::send(std::vector<int32_t> command)
return response;
}
-} // namespace pass_through
} // namespace occ
} // namespace open_power
diff --git a/occ_pass_through.hpp b/occ_pass_through.hpp
index c9f6566..f2f78c7 100644
--- a/occ_pass_through.hpp
+++ b/occ_pass_through.hpp
@@ -1,107 +1,15 @@
#pragma once
#include <string>
-#include <cstring>
-#include <map>
-#include <vector>
-#include <experimental/filesystem>
-#include <unistd.h>
#include <sdbusplus/bus.hpp>
-#include <functional>
#include <sdbusplus/server/object.hpp>
#include <org/open_power/OCC/PassThrough/server.hpp>
-#include "config.h"
#include "file.hpp"
-namespace sdbusRule = sdbusplus::bus::match::rules;
-
namespace open_power
{
namespace occ
{
-namespace pass_through
-{
-
-class PassThrough;
-
-namespace manager
-{
-
-/** @class Manager
- * @brief Builds and manages OCC pass-through objects
- */
-struct Manager
-{
- public:
- Manager() = delete;
- Manager(const Manager&) = delete;
- Manager& operator=(const Manager&) = delete;
- Manager(Manager&&) = default;
- Manager& operator=(Manager&&) = default;
- ~Manager() = default;
-
- /** @brief Ctor - Add OCC pass-through objects on the bus. Create
- * OCC objects when corresponding CPU inventory is created.
- * @param[in] bus - handle to the bus
- */
- Manager(sdbusplus::bus::bus& bus):
- bus(bus)
- {
- for (auto id = 0; id < MAX_CPUS; ++id)
- {
- auto path = std::string(CPU_PATH) + std::to_string(id);
- cpuMatches.emplace_back(
- bus,
- sdbusRule::interfacesAdded() +
- sdbusRule::argNpath(0, path),
- std::bind(std::mem_fn(&Manager::cpuCreated),
- this, std::placeholders::_1));
- }
- }
-
- /** @brief Callback that responds to cpu creation in the inventory -
- * by creating the occ passthrough object.
- *
- * @param[in] msg - bus message
- *
- * @returns 0 to indicate success
- */
- int cpuCreated(sdbusplus::message::message& msg)
- {
- namespace fs = std::experimental::filesystem;
-
- sdbusplus::message::object_path o;
- msg.read(o);
- fs::path cpuPath(std::string(std::move(o)));
- auto cpu = cpuPath.filename();
-
- auto occPath = fs::path(OCC_PASS_THROUGH_ROOT);
- std::string name{cpu.c_str()};
- auto index = name.find(CPU_NAME);
- name.replace(index, std::strlen(CPU_NAME), OCC_NAME);
- occPath /= name;
-
- objects.emplace_back(
- std::make_unique<PassThrough>(
- bus,
- occPath.c_str()));
-
- return 0;
- }
-
- private:
- /** @brief reference to the bus */
- sdbusplus::bus::bus& bus;
-
- /** @brief OCC pass-through objects */
- std::vector<std::unique_ptr<PassThrough>> objects;
-
- /** @brief sbdbusplus match objects */
- std::vector<sdbusplus::bus::match_t> cpuMatches;
-};
-
-} // namespace manager
-
using Iface = sdbusplus::server::object::object<
sdbusplus::org::open_power::OCC::server::PassThrough>;
@@ -153,6 +61,5 @@ class PassThrough : public Iface
int openDevice();
};
-} // namespace pass_through
} // namespace occ
} // namespace open_power
OpenPOWER on IntegriCloud