Implement GetBIOSAttributeCurrentValueByHandle
Implement GetBIOSAttributeCurrentValueByHandle
in libpldmresponder
Tested:
tested with this json
https://github.com/openbmc/openbmc/blob/master/meta-ibm/meta-witherspoon/recipes-phosphor/pldm/pldm/enum_attrs.json
root@fp5280g2:/tmp# ./pldmtool raw --data 0x80 0x03 0x08 0x00 0x00 0x00 0x00 0x00 0x02 0x00
Encode request successfully
Request Message:
08 01 80 03 08 00 00 00 00 00 02 00
Success in creating the socket : RC = 3
Success in connecting to socket : RC = 0
Success in sending message type as pldm to mctp : RC = 0
Write to socket successful : RC = 12
Total length:12
Loopback response message:
08 01 80 03 08 00 00 00 00 00 02 00
On first recv(),response == request : RC = 0
Total length: 13
Shutdown Socket successful : RC = 0
Response Message:
08 01 00 03 08 00 00 00 00 00 05 01 00
root@fp5280g2:/tmp# ./pldmtool raw --data 0x80 0x03 0x08 0x00 0x00 0x00 0x00 0x00 0x03 0x00
Encode request successfully
Request Message:
08 01 80 03 08 00 00 00 00 00 03 00
Success in creating the socket : RC = 3
Success in connecting to socket : RC = 0
Success in sending message type as pldm to mctp : RC = 0
Write to socket successful : RC = 12
Total length:12
Loopback response message:
08 01 80 03 08 00 00 00 00 00 03 00
On first recv(),response == request : RC = 0
Total length: 13
Shutdown Socket successful : RC = 0
Response Message:
08 01 00 03 08 00 00 00 00 00 05 01 01
root@fp5280g2:/tmp# ./pldmtool raw --data 0x80 0x03 0x08 0x00 0x00 0x00 0x00 0x00 0x06 0x00
Encode request successfully
Request Message:
08 01 80 03 08 00 00 00 00 00 06 00
Success in creating the socket : RC = 3
Success in connecting to socket : RC = 0
Success in sending message type as pldm to mctp : RC = 0
Write to socket successful : RC = 12
Total length:12
Loopback response message:
08 01 80 03 08 00 00 00 00 00 06 00
On first recv(),response == request : RC = 0
Total length: 6
Shutdown Socket successful : RC = 0
Response Message:
08 01 00 03 08 88
Signed-off-by: John Wang <wangzqbj@inspur.com>
Change-Id: Ibb68cbb3c825184bd30bdf6cea9d84d91f3a3a16
diff --git a/libpldm/bios.h b/libpldm/bios.h
index d316b67..b020dea 100644
--- a/libpldm/bios.h
+++ b/libpldm/bios.h
@@ -19,11 +19,13 @@
#define PLDM_SET_BIOS_ATTR_CURR_VAL_MIN_REQ_BYTES 5
#define PLDM_SET_BIOS_ATTR_CURR_VAL_RESP_BYTES 5
#define PLDM_GET_BIOS_ATTR_CURR_VAL_BY_HANDLE_REQ_BYTES 7
+#define PLDM_GET_BIOS_ATTR_CURR_VAL_BY_HANDLE_MIN_RESP_BYTES 6
enum pldm_bios_completion_codes {
PLDM_BIOS_TABLE_UNAVAILABLE = 0x83,
PLDM_INVALID_BIOS_TABLE_DATA_INTEGRITY_CHECK = 0x84,
PLDM_INVALID_BIOS_TABLE_TYPE = 0x85,
+ PLDM_INVALID_BIOS_ATTR_HANDLE = 0x88,
};
enum pldm_bios_commands {
PLDM_GET_BIOS_TABLE = 0x01,
diff --git a/libpldmresponder/base.cpp b/libpldmresponder/base.cpp
index b9f5ff1..4d0c4f9 100644
--- a/libpldmresponder/base.cpp
+++ b/libpldmresponder/base.cpp
@@ -26,7 +26,10 @@
{PLDM_GET_TID, PLDM_GET_PLDM_VERSION, PLDM_GET_PLDM_TYPES,
PLDM_GET_PLDM_COMMANDS}},
{PLDM_PLATFORM, {PLDM_SET_STATE_EFFECTER_STATES}},
- {PLDM_BIOS, {PLDM_GET_DATE_TIME}}};
+ {PLDM_BIOS,
+ {PLDM_GET_DATE_TIME, PLDM_GET_BIOS_TABLE,
+ PLDM_GET_BIOS_ATTRIBUTE_CURRENT_VALUE_BY_HANDLE}},
+};
static const std::map<Type, ver32_t> versions{
{PLDM_BASE, {0xF1, 0xF0, 0xF0, 0x00}},
diff --git a/libpldmresponder/bios.cpp b/libpldmresponder/bios.cpp
index e9ed628..bc663f6 100644
--- a/libpldmresponder/bios.cpp
+++ b/libpldmresponder/bios.cpp
@@ -103,6 +103,11 @@
[this](const pldm_msg* request, size_t payloadLength) {
return this->getBIOSTable(request, payloadLength);
});
+ handlers.emplace(PLDM_GET_BIOS_ATTRIBUTE_CURRENT_VALUE_BY_HANDLE,
+ [this](const pldm_msg* request, size_t payloadLength) {
+ return this->getBIOSAttributeCurrentValueByHandle(
+ request, payloadLength);
+ });
}
Response Handler::getDateTime(const pldm_msg* request, size_t /*payloadLength*/)
@@ -808,6 +813,49 @@
return response;
}
+Response Handler::getBIOSAttributeCurrentValueByHandle(const pldm_msg* request,
+ size_t payloadLength)
+{
+ uint32_t transferHandle;
+ uint8_t transferOpFlag;
+ uint16_t attributeHandle;
+
+ auto rc = decode_get_bios_attribute_current_value_by_handle_req(
+ request, payloadLength, &transferHandle, &transferOpFlag,
+ &attributeHandle);
+ if (rc != PLDM_SUCCESS)
+ {
+ return ccOnlyResponse(request, rc);
+ }
+
+ fs::path attrValueTablePath(BIOS_TABLES_DIR);
+ attrValueTablePath /= attrValTableFile;
+ BIOSTable attributeValueTable(attrValueTablePath.c_str());
+
+ Response table;
+ attributeValueTable.load(table);
+
+ auto entry = pldm_bios_table_attr_value_find_by_handle(
+ table.data(), table.size(), attributeHandle);
+ if (entry == nullptr)
+ {
+ return ccOnlyResponse(request, PLDM_INVALID_BIOS_ATTR_HANDLE);
+ }
+
+ auto valueLength = pldm_bios_table_attr_value_entry_value_length(entry);
+ auto valuePtr = pldm_bios_table_attr_value_entry_value(entry);
+ Response response(sizeof(pldm_msg_hdr) +
+ PLDM_GET_BIOS_ATTR_CURR_VAL_BY_HANDLE_MIN_RESP_BYTES +
+ valueLength,
+ 0);
+ auto responsePtr = reinterpret_cast<pldm_msg*>(response.data());
+ encode_get_bios_current_value_by_handle_resp(
+ request->hdr.instance_id, PLDM_SUCCESS, 0, PLDM_START_AND_END, valuePtr,
+ valueLength, responsePtr);
+
+ return response;
+}
+
namespace internal
{
diff --git a/libpldmresponder/bios.hpp b/libpldmresponder/bios.hpp
index f9a3eff..41ac70c 100644
--- a/libpldmresponder/bios.hpp
+++ b/libpldmresponder/bios.hpp
@@ -67,6 +67,15 @@
* @param[return] Response - PLDM Response message
*/
Response getBIOSTable(const pldm_msg* request, size_t payloadLength);
+
+ /** @brief Handler for GetBIOSAttributeCurrentValueByHandle
+ *
+ * @param[in] request - Request message
+ * @param[in] payloadLength - Request message payload length
+ * @return Response - PLDM Response message
+ */
+ Response getBIOSAttributeCurrentValueByHandle(const pldm_msg* request,
+ size_t payloadLength);
};
} // namespace bios