dcmi : implement get temperature readings
This commit implements the plumbing around the 'Get Temperature
Readings' command. It doesn't read the temperatures from the relevant
sensors. That code is coming up in a subsequent commit.
Change-Id: I4514b65eb3ca65d52dd35185338a2c397e9a76ca
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
diff --git a/dcmihandler.hpp b/dcmihandler.hpp
index 288e4d7..a7cfe8a 100644
--- a/dcmihandler.hpp
+++ b/dcmihandler.hpp
@@ -20,6 +20,7 @@
SET_ASSET_TAG = 0x08,
GET_MGMNT_CTRL_ID_STR = 0x09,
SET_MGMNT_CTRL_ID_STR = 0x0A,
+ GET_TEMP_READINGS = 0x10,
};
static constexpr auto propIntf = "org.freedesktop.DBus.Properties";
@@ -32,6 +33,7 @@
static constexpr auto networkConfigIntf =
"xyz.openbmc_project.Network.SystemConfiguration";
static constexpr auto hostNameProp = "HostName";
+static constexpr auto temperatureSensorType = 0x01;
namespace assettag
{
@@ -43,6 +45,33 @@
} //namespace assettag
+namespace temp_readings
+{
+ static constexpr auto maxDataSets = 8;
+ static constexpr auto maxInstances = 255;
+ static constexpr auto maxTemp = 128; // degrees C
+
+ /** @struct Response
+ *
+ * DCMI payload for Get Temperature Readings response
+ */
+ struct Response
+ {
+#if BYTE_ORDER == LITTLE_ENDIAN
+ uint8_t temperature: 7; //!< Temperature reading in Celsius
+ uint8_t sign: 1; //!< Sign bit
+#endif
+#if BYTE_ORDER == BIG_ENDIAN
+ uint8_t sign: 1; //!< Sign bit
+ uint8_t temperature: 7; //!< Temperature reading in Celsius
+#endif
+ uint8_t instance; //!< Entity instance number
+ } __attribute__((packed));
+
+ using ResponseList = std::vector<Response>;
+ using NumInstances = size_t;
+}
+
static constexpr auto groupExtId = 0xDC;
static constexpr auto assetTagMaxOffset = 62;
@@ -320,6 +349,59 @@
using DCMICaps = std::map<DCMICapParameters, DCMICapEntry>;
+/** @struct GetTempReadingsRequest
+ *
+ * DCMI payload for Get Temperature Readings request
+ */
+struct GetTempReadingsRequest
+{
+ uint8_t groupID; //!< Group extension identification.
+ uint8_t sensorType; //!< Type of the sensor
+ uint8_t entityId; //!< Entity ID
+ uint8_t entityInstance; //!< Entity Instance (0 means all instances)
+ uint8_t instanceStart; //!< Instance start (used if instance is 0)
+} __attribute__((packed));
+
+/** @struct GetTempReadingsResponse
+ *
+ * DCMI header for Get Temperature Readings response
+ */
+struct GetTempReadingsResponseHdr
+{
+ uint8_t groupID; //!< Group extension identification.
+ uint8_t numInstances; //!< No. of instances for requested id
+ uint8_t numDataSets; //!< No. of sets of temperature data
+} __attribute__((packed));
+
+namespace temp_readings
+{
+ /** @brief Read temperatures and fill up DCMI response for the Get
+ * Temperature Readings command. This looks at a specific
+ * instance.
+ *
+ * @param[in] type - one of "inlet", "cpu", "baseboard"
+ * @param[in] instance - A non-zero Entity instance number
+ *
+ * @return A tuple, containing a temperature reading and the
+ * number of instances.
+ */
+ std::tuple<Response, NumInstances> read (const std::string& type,
+ uint8_t instance);
+
+ /** @brief Read temperatures and fill up DCMI response for the Get
+ * Temperature Readings command. This looks at a range of
+ * instances.
+ *
+ * @param[in] type - one of "inlet", "cpu", "baseboard"
+ * @param[in] instanceStart - Entity instance start index
+ *
+ * @return A tuple, containing a list of temperature readings and the
+ * number of instances.
+ */
+ std::tuple<ResponseList, NumInstances> readAll(const std::string& type,
+ uint8_t instanceStart);
+}
+
} // namespace dcmi
#endif