summaryrefslogtreecommitdiffstats
path: root/occ_device.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'occ_device.hpp')
-rw-r--r--occ_device.hpp58
1 files changed, 56 insertions, 2 deletions
diff --git a/occ_device.hpp b/occ_device.hpp
index 7ffb0ef..fd30641 100644
--- a/occ_device.hpp
+++ b/occ_device.hpp
@@ -13,6 +13,7 @@ namespace occ
{
class Manager;
+class Status;
namespace fs = std::experimental::filesystem;
/** @class Device
@@ -38,18 +39,38 @@ class Device
Device(EventPtr& event,
const std::string& name,
const Manager& manager,
- std::function<void()> callBack = nullptr) :
+ Status& status,
+ std::function<void(bool)> callBack = nullptr) :
#ifdef I2C_OCC
config(name),
#else
config(name + '-' + "dev0"),
#endif
errorFile(fs::path(config) / "occ_error"),
+ statusObject(status),
error(event, errorFile, callBack),
presence(event,
fs::path(config) / "occs_present",
manager,
- callBack)
+ callBack),
+ throttleProcTemp(
+ event,
+ fs::path(config) / "occ_dvfs_ot",
+ std::bind(std::mem_fn(&Device::throttleProcTempCallback),
+ this,
+ std::placeholders::_1)),
+ throttleProcPower(
+ event,
+ fs::path(config) / "occ_dvfs_power",
+ std::bind(std::mem_fn(&Device::throttleProcPowerCallback),
+ this,
+ std::placeholders::_1)),
+ throttleMemTemp(
+ event,
+ fs::path(config) / "occ_mem_throttle",
+ std::bind(std::mem_fn(&Device::throttleMemTempCallback),
+ this,
+ std::placeholders::_1))
{
// Nothing to do here
}
@@ -89,6 +110,9 @@ class Device
presence.addWatch();
}
+ throttleProcTemp.addWatch();
+ throttleProcPower.addWatch();
+ throttleMemTemp.addWatch();
error.addWatch();
}
@@ -98,6 +122,10 @@ class Device
// we can always safely remove watch even if we don't add it
presence.removeWatch();
error.removeWatch();
+ error.removeWatch();
+ throttleMemTemp.removeWatch();
+ throttleProcPower.removeWatch();
+ throttleProcTemp.removeWatch();
}
private:
@@ -118,12 +146,20 @@ class Device
*/
static fs::path unBindPath;
+ /** Store the associated Status instance */
+ Status& statusObject;
+
/** Abstraction of error monitoring */
Error error;
/** Abstraction of OCC presence monitoring */
Presence presence;
+ /** Error instances for watching for throttling events */
+ Error throttleProcTemp;
+ Error throttleProcPower;
+ Error throttleMemTemp;
+
/** @brief file writer to achieve bind and unbind
*
* @param[in] filename - Name of file to be written
@@ -141,6 +177,24 @@ class Device
/** @brief Returns if device represents the master OCC */
bool master() const;
+
+ /** @brief callback for the proc temp throttle event
+ *
+ * @param[in] error - True if an error is reported, false otherwise
+ */
+ void throttleProcTempCallback(bool error);
+
+ /** @brief callback for the proc power throttle event
+ *
+ * @param[in] error - True if an error is reported, false otherwise
+ */
+ void throttleProcPowerCallback(bool error);
+
+ /** @brief callback for the proc temp throttle event
+ *
+ * @param[in] error - True if an error is reported, false otherwise
+ */
+ void throttleMemTempCallback(bool error);
};
} // namespace occ
OpenPOWER on IntegriCloud