diff options
Diffstat (limited to 'src/include/runtime/hbrt_utilities.H')
-rw-r--r-- | src/include/runtime/hbrt_utilities.H | 90 |
1 files changed, 28 insertions, 62 deletions
diff --git a/src/include/runtime/hbrt_utilities.H b/src/include/runtime/hbrt_utilities.H index 649677422..2ee2172df 100644 --- a/src/include/runtime/hbrt_utilities.H +++ b/src/include/runtime/hbrt_utilities.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2017,2018 */ +/* Contributors Listed Below - COPYRIGHT 2017,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -29,7 +29,16 @@ #define HBRT_TRACE_NAME "HBRT" -#include "interface.h" +extern trace_desc_t *g_trac_runtime; + +#include <vector> + +#include "interface.h" // hostInterfaces +#include "generic_hbrt_fsp_message.H" // GenericFspMboxMessage_t, AttributeSetter_t +#include "targeting/common/attributeTank.H" // TARGETING::AttributeTank::Attribute +#include <initservice/initserviceif.H> // INITSERVICE +#include "util/runtime/rt_fwreq_helper.H" // firmware_request_helper +#include "runtime/runtime_reasoncodes.H" // MOD_XXX and RC_XXX /** @file hbrt_utilities.H * @brief A file to put HBRT Interface utilities @@ -54,9 +63,9 @@ * to newly created data.) * * @post The request/response messages point to a valid struct, - * the request/response message size are equal to each other - * and contain the size of the request/response messages - * respectively upon a successful call else all the output + * the request/response messages' size are equal to each other, request + * message is initalized (data size is set) and response message is + * zeroed out, upon a successful call else all the output * parameters will either be NULL or 0 based on type. * * @note Use this function iff hbrt_fw_msg::io_type is of type @@ -65,7 +74,7 @@ * @note Caller is responsible for deleting (use delete []) the * allocated memory * - * @param[in] i_fspReqPayloadSize The size of the payload that will + * @param[in] i_fspReqPayloadSize The size of the payload that will * populate GenericFspMboxMessage_t::data * @param[out] o_fspMsgSize Return the size of the * GenericFspMboxMessage_t, adjusted to @@ -76,66 +85,23 @@ * will be equal to the request msg size * @param[out] o_responseMsg The allocated response message (not * NULL), zeroed out + * @return true if NO issue allocating memory for request/response messages, + * else false */ -void createGenericFspMsg(uint32_t i_fspReqPayloadSize, - uint32_t &o_fspMsgSize, - uint64_t &o_requestMsgSize, - hostInterfaces::hbrt_fw_msg* &o_requestMsg, - uint64_t &o_responseMsgSize, - hostInterfaces::hbrt_fw_msg* &o_responseMsg) -{ - // Do some quick initialization of the output data - o_fspMsgSize = o_requestMsgSize = o_responseMsgSize = 0; - o_requestMsg = o_responseMsg = nullptr; - - // Calculate the total size of the Generic FSP Message. - o_fspMsgSize = GENERIC_FSP_MBOX_MESSAGE_BASE_SIZE + - i_fspReqPayloadSize; - - // The total Generic FSP Message size must be at a minimum the - // size of the FSP generic message (sizeof(GenericFspMboxMessage_t)) - if (o_fspMsgSize < sizeof(GenericFspMboxMessage_t)) - { - o_fspMsgSize = sizeof(GenericFspMboxMessage_t); - } +bool createGenericFspMsg(uint32_t i_fspReqPayloadSize, + uint32_t &o_fspMsgSize, + uint64_t &o_requestMsgSize, + hostInterfaces::hbrt_fw_msg* &o_requestMsg, + uint64_t &o_responseMsgSize, + hostInterfaces::hbrt_fw_msg* &o_responseMsg); - // Calculate the total size of the hbrt_fw_msgs which - // means only adding hostInterfaces::HBRT_FW_MSG_BASE_SIZE to - // the previous calculated Generic FSP Message size. - o_requestMsgSize = o_responseMsgSize = - hostInterfaces::HBRT_FW_MSG_BASE_SIZE + o_fspMsgSize; - // Create the hbrt_fw_msgs - o_responseMsg = reinterpret_cast<hostInterfaces::hbrt_fw_msg *> - (new uint8_t[o_responseMsgSize]); - o_requestMsg = reinterpret_cast<hostInterfaces::hbrt_fw_msg *> - (new uint8_t[o_requestMsgSize]); - - // If anyone of these two message's memory can't be allocated, then - // delete both messages (in case one did allocate memory), set both - // messages to NULL pointers and set their respective sizes to zero. - if (!o_responseMsg || !o_requestMsg) - { - // OK to delete a NULL pointer if it happens - delete []o_responseMsg; - delete []o_requestMsg; - - // Return output data zeroed out - o_responseMsg = o_requestMsg = nullptr; - o_fspMsgSize = o_requestMsgSize = o_responseMsgSize = 0; - } - else - { - // Initialize/zero out hbrt_fw_msgs - o_requestMsg->generic_msg.initialize(); - memset(o_responseMsg, 0, o_responseMsgSize); +/** + * @brief Serializes a list of Attributes to be sent to FSP + */ +errlHndl_t sendAttributes(const std::vector<TARGETING::AttributeTank::Attribute>& + i_attributeList); - // We can at least set these parameters based on current usage - o_requestMsg->io_type = hostInterfaces::HBRT_FW_MSG_HBRT_FSP_REQ; - o_requestMsg->generic_msg.dataSize = o_fspMsgSize; - o_requestMsg->generic_msg.__req = GenericFspMboxMessage_t::REQUEST; - } -} // end createGenericFspMsg #endif //__HOSTBOOT_RUNTIME_INTERFACE_VERSION_ONLY #endif // __RUNTIME__UTILITIES_H |