diff options
Diffstat (limited to 'src/include/runtime/hbrt_utilities.H')
-rw-r--r-- | src/include/runtime/hbrt_utilities.H | 122 |
1 files changed, 86 insertions, 36 deletions
diff --git a/src/include/runtime/hbrt_utilities.H b/src/include/runtime/hbrt_utilities.H index 87a9cc708..1764dedb1 100644 --- a/src/include/runtime/hbrt_utilities.H +++ b/src/include/runtime/hbrt_utilities.H @@ -184,8 +184,8 @@ errlHndl_t sendAttributes(const std::vector<TARGETING::AttributeTank::Attribute> // If caller passes in an empty list, then nothing to do if (!i_attributeList.size()) { - TRACFCOMP(g_trac_runtime, "sendAttributes: attribute list is empty," - "nothing to do ..."); + TRACFCOMP(g_trac_runtime, "sendAttributes: attribute list is " + "empty,nothing to do ..."); break; } @@ -210,28 +210,29 @@ errlHndl_t sendAttributes(const std::vector<TARGETING::AttributeTank::Attribute> * @custdesc Internal firmware error */ l_err = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE, - RUNTIME::MOD_RT_FIRMWARE_REQUEST, - RUNTIME::RC_FW_REQUEST_RT_NULL_PTR, - i_attributeList.size(), - 0, - ERRORLOG::ErrlEntry::ADD_SW_CALLOUT); + RUNTIME::MOD_RT_FIRMWARE_REQUEST, + RUNTIME::RC_FW_REQUEST_RT_NULL_PTR, + i_attributeList.size(), + 0, + ERRORLOG::ErrlEntry::ADD_SW_CALLOUT); break; } - /// Calculate the size requirements needed to serialize the Attribute info - // Start with the size of 'struct AttributeSetter_t' itself - uint16_t l_dataSize(sizeof(AttributeSetter_t)); - - // Then add in the individual attributes themselves + /// Calculate the size requirements needed to serialize + /// the Attribute info + // Aggregate the size of the incoming Attributes + uint32_t l_aggregatedAttributeSize(0); for (auto l_attribute: i_attributeList) { - // Add in the size of `struct AttributeHeader` - l_dataSize += sizeof(l_attribute.iv_hdr); - // Finally add in the size of the attribute value - l_dataSize += l_attribute.iv_hdr.iv_valSize; + l_aggregatedAttributeSize += l_attribute.getSize(); } + // Combine the size of the AttributeSetter_t itself to the size of + // incoming Attributes to get the full size requirement needed + uint32_t l_dataSize(sizeof(AttributeSetter_t) + + l_aggregatedAttributeSize); + // Create and initialize to zero a few needed variables uint32_t l_fullFspDataSize(0); uint64_t l_fwRequestMsgSize(0), l_fwResponseMsgSize(0); @@ -257,11 +258,11 @@ errlHndl_t sendAttributes(const std::vector<TARGETING::AttributeTank::Attribute> * @custdesc Internal firmware error */ l_err = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE, - RUNTIME::MOD_SEND_ATTRIBUTES_TO_FSP, - RUNTIME::RC_NULL_FIRMWARE_MSG_PTR, - i_attributeList.size(), - 0, - ERRORLOG::ErrlEntry::ADD_SW_CALLOUT); + RUNTIME::MOD_SEND_ATTRIBUTES_TO_FSP, + RUNTIME::RC_NULL_FIRMWARE_MSG_PTR, + i_attributeList.size(), + 0, + ERRORLOG::ErrlEntry::ADD_SW_CALLOUT); break; } @@ -269,7 +270,7 @@ errlHndl_t sendAttributes(const std::vector<TARGETING::AttributeTank::Attribute> // Populate the 'message queue' and 'message type' for this message l_fwRequestMsg->generic_msg.msgq = MBOX::FSP_NVDIMM_KEYS_MSGQ_ID; l_fwRequestMsg->generic_msg.msgType = - GenericFspMboxMessage_t::MSG_DECONFIG_TARGET; + GenericFspMboxMessage_t::MSG_DECONFIG_TARGET; // Create a useful struct to populate the generic_msg::data field AttributeSetter_t* l_attributeSetter = @@ -286,22 +287,71 @@ errlHndl_t sendAttributes(const std::vector<TARGETING::AttributeTank::Attribute> // Retrieve the individual attributes (header and value) // Create a useful struct to poulate attribute data uint8_t* l_attributeData = l_attributeSetter->iv_attrData; + uint32_t l_sizeOfDataCopied(0); for (const auto & l_attribute: i_attributeList) { - // Copy the attribute header - memcpy(l_attributeData, - &(l_attribute.iv_hdr), - sizeof(l_attribute.iv_hdr)); - // Advance pointer, one beyond the attribute header - l_attributeData += sizeof(l_attribute.iv_hdr); - - // Copy the attribute value - memcpy(l_attributeData, - l_attribute.iv_pVal, - l_attribute.iv_hdr.iv_valSize); - // Advance pointer, one beyond the attribute value - l_attributeData += l_attribute.iv_hdr.iv_valSize; - } + if (l_aggregatedAttributeSize >= l_attribute.getSize()) + { + l_sizeOfDataCopied = l_attribute.serialize( + l_attributeData, l_aggregatedAttributeSize); + + if (!l_sizeOfDataCopied) + { + TRACFCOMP(g_trac_runtime, ERR_MRK"sendAttributes: " + "Serialization of an Attribute failed, " + "should never happen") + + /*@ + * @errortype + * @severity ERRL_SEV_UNRECOVERABLE + * @moduleid MOD_SEND_ATTRIBUTES_TO_FSP + * @reasoncode RC_SERIALIZE_ATTRIBUTE_FAILED + * @userdata1 Number of Attributes to serialize and send + * @devdesc Serialization of an Attribute Failed + * @custdesc Internal firmware error + */ + l_err = new ERRORLOG::ErrlEntry( + ERRORLOG::ERRL_SEV_UNRECOVERABLE, + RUNTIME::MOD_SEND_ATTRIBUTES_TO_FSP, + RUNTIME::RC_SERIALIZE_ATTRIBUTE_FAILED, + i_attributeList.size(), + 0, + ERRORLOG::ErrlEntry::ADD_SW_CALLOUT); + + break; + } // end if (!l_sizeOfDataCopied) + } + else + { + TRACFCOMP(g_trac_runtime, ERR_MRK"sendAttributes: " + "Miscalculation of aggregated size of attributes, " + "should never happen") + + /*@ + * @errortype + * @severity ERRL_SEV_UNRECOVERABLE + * @moduleid MOD_SEND_ATTRIBUTES_TO_FSP + * @reasoncode RC_NO_SPACE_FOR_ATTRIBUTE_SERIALIZATION + * @userdata1 Number of Attributes to serialize and send + * @devdesc Serialization data of Attribute to large + * for given buffer + * @custdesc Internal firmware error + */ + l_err = new ERRORLOG::ErrlEntry( + ERRORLOG::ERRL_SEV_UNRECOVERABLE, + RUNTIME::MOD_SEND_ATTRIBUTES_TO_FSP, + RUNTIME::RC_NO_SPACE_FOR_ATTRIBUTE_SERIALIZATION, + i_attributeList.size(), + 0, + ERRORLOG::ErrlEntry::ADD_SW_CALLOUT); + + break; + } + + // Decrement/increment our counters/pointers + l_aggregatedAttributeSize -= l_sizeOfDataCopied; + l_attributeData += l_sizeOfDataCopied; + } // end for (const auto & l_attribute: i_attributeList) // Make the firmware_request call l_err = firmware_request_helper(l_fwRequestMsgSize, |