diff options
Diffstat (limited to 'occ_pass_through.hpp')
-rw-r--r-- | occ_pass_through.hpp | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/occ_pass_through.hpp b/occ_pass_through.hpp index f2f78c7..205fc04 100644 --- a/occ_pass_through.hpp +++ b/occ_pass_through.hpp @@ -4,7 +4,6 @@ #include <sdbusplus/bus.hpp> #include <sdbusplus/server/object.hpp> #include <org/open_power/OCC/PassThrough/server.hpp> -#include "file.hpp" namespace open_power { @@ -14,6 +13,9 @@ namespace occ using Iface = sdbusplus::server::object::object< sdbusplus::org::open_power::OCC::server::PassThrough>; +// For waiting on signals +namespace sdbusRule = sdbusplus::bus::match::rules; + /** @class PassThrough * @brief Implements org.open_power.OCC.PassThrough */ @@ -21,7 +23,6 @@ class PassThrough : public Iface { public: PassThrough() = delete; - ~PassThrough() = default; PassThrough(const PassThrough&) = delete; PassThrough& operator=(const PassThrough&) = delete; PassThrough(PassThrough&&) = default; @@ -34,6 +35,11 @@ class PassThrough : public Iface PassThrough(sdbusplus::bus::bus& bus, const char* path); + ~PassThrough() + { + closeDevice(); + } + /** @brief Pass through command to OCC * @param[in] command - command to pass-through * @returns OCC response as an array @@ -48,17 +54,33 @@ class PassThrough : public Iface /** @brief OCC device path * For now, here is the hard-coded mapping until * the udev rule is in. - * occ0 --> /dev/occfifo1 - * occ1 --> /dev/occfifo2 + * occ0 --> /dev/occ1 + * occ1 --> /dev/occ2 * ... */ - std::string devicePath = "/dev/occ"; + std::string devicePath; - /** @brief File descriptor manager */ - FileDescriptor fd; + /** brief file descriptor associated with occ device */ + int fd = -1; + + /** @brief Subscribe to OCC Status signal + * + * Once the OCC status gets to active, only then we will get /dev/occ2 + * populated and hence need to wait on that before opening that + */ + sdbusplus::bus::match_t activeStatusSignal; - /** Opens devicePath and returns file descritor */ - int openDevice(); + /** Opens devicePath and populates file descritor */ + void openDevice(); + + /** Closed the fd associated with opened device */ + void closeDevice(); + + /** @brief Callback function on OCC Status change signals + * + * @param[in] msg - Data associated with subscribed signal + */ + void activeStatusEvent(sdbusplus::message::message& msg); }; } // namespace occ |