Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 1 | #ifndef BASE_H |
| 2 | #define BASE_H |
| 3 | |
| 4 | #ifdef __cplusplus |
| 5 | extern "C" { |
| 6 | #endif |
| 7 | |
| 8 | #include <asm/byteorder.h> |
| 9 | #include <stddef.h> |
| 10 | #include <stdint.h> |
| 11 | |
Deepak Kodihalli | 97e0bd5 | 2019-02-21 03:54:22 -0600 | [diff] [blame] | 12 | #include "pldm_types.h" |
| 13 | |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 14 | /** @brief PLDM Types |
| 15 | */ |
| 16 | enum pldm_supported_types { |
| 17 | PLDM_BASE = 0x00, |
Sampa Misra | 0db1dfa | 2019-03-19 00:15:31 -0500 | [diff] [blame] | 18 | PLDM_PLATFORM = 0x02, |
Sampa Misra | 032bd50 | 2019-03-06 05:03:22 -0600 | [diff] [blame] | 19 | PLDM_BIOS = 0x03, |
Jinu Joy Thomas | f666db1 | 2019-05-29 05:22:31 -0500 | [diff] [blame] | 20 | PLDM_OEM = 0x3F, |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 21 | }; |
| 22 | |
| 23 | /** @brief PLDM Commands |
| 24 | */ |
| 25 | enum pldm_supported_commands { |
John Wang | 5c4f80d | 2019-07-29 11:12:18 +0800 | [diff] [blame] | 26 | PLDM_GET_TID = 0x2, |
Sampa Misra | 432e187 | 2019-02-13 03:49:43 -0600 | [diff] [blame] | 27 | PLDM_GET_PLDM_VERSION = 0x3, |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 28 | PLDM_GET_PLDM_TYPES = 0x4, |
| 29 | PLDM_GET_PLDM_COMMANDS = 0x5 |
| 30 | }; |
| 31 | |
| 32 | /** @brief PLDM base codes |
| 33 | */ |
| 34 | enum pldm_completion_codes { |
| 35 | PLDM_SUCCESS = 0x00, |
| 36 | PLDM_ERROR = 0x01, |
| 37 | PLDM_ERROR_INVALID_DATA = 0x02, |
| 38 | PLDM_ERROR_INVALID_LENGTH = 0x03, |
| 39 | PLDM_ERROR_NOT_READY = 0x04, |
| 40 | PLDM_ERROR_UNSUPPORTED_PLDM_CMD = 0x05, |
| 41 | PLDM_ERROR_INVALID_PLDM_TYPE = 0x20 |
| 42 | }; |
| 43 | |
Sampa Misra | 432e187 | 2019-02-13 03:49:43 -0600 | [diff] [blame] | 44 | enum transfer_op_flag { |
| 45 | PLDM_GET_NEXTPART = 0, |
| 46 | PLDM_GET_FIRSTPART = 1, |
| 47 | }; |
| 48 | |
| 49 | enum transfer_resp_flag { |
| 50 | PLDM_START = 0x01, |
| 51 | PLDM_MIDDLE = 0x02, |
| 52 | PLDM_END = 0x04, |
| 53 | PLDM_START_AND_END = 0x05, |
| 54 | }; |
| 55 | |
Tom Joseph | 4125104 | 2019-02-07 16:17:07 +0530 | [diff] [blame] | 56 | /** @enum MessageType |
| 57 | * |
| 58 | * The different message types supported by the PLDM specification. |
| 59 | */ |
| 60 | typedef enum { |
| 61 | PLDM_RESPONSE, //!< PLDM response |
| 62 | PLDM_REQUEST, //!< PLDM request |
| 63 | PLDM_RESERVED, //!< Reserved |
| 64 | PLDM_ASYNC_REQUEST_NOTIFY, //!< Unacknowledged PLDM request messages |
| 65 | } MessageType; |
| 66 | |
| 67 | #define PLDM_INSTANCE_MAX 31 |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 68 | #define PLDM_MAX_TYPES 64 |
| 69 | #define PLDM_MAX_CMDS_PER_TYPE 256 |
| 70 | |
| 71 | /* Message payload lengths */ |
| 72 | #define PLDM_GET_COMMANDS_REQ_BYTES 5 |
Sampa Misra | 432e187 | 2019-02-13 03:49:43 -0600 | [diff] [blame] | 73 | #define PLDM_GET_VERSION_REQ_BYTES 6 |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 74 | |
| 75 | /* Response lengths are inclusive of completion code */ |
| 76 | #define PLDM_GET_TYPES_RESP_BYTES 9 |
John Wang | 5c4f80d | 2019-07-29 11:12:18 +0800 | [diff] [blame] | 77 | #define PLDM_GET_TID_RESP_BYTES 2 |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 78 | #define PLDM_GET_COMMANDS_RESP_BYTES 33 |
Sampa Misra | 432e187 | 2019-02-13 03:49:43 -0600 | [diff] [blame] | 79 | /* Response data has only one version and does not contain the checksum */ |
| 80 | #define PLDM_GET_VERSION_RESP_BYTES 10 |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 81 | |
| 82 | /** @struct pldm_msg_hdr |
| 83 | * |
| 84 | * Structure representing PLDM message header fields |
| 85 | */ |
| 86 | struct pldm_msg_hdr { |
| 87 | #if defined(__LITTLE_ENDIAN_BITFIELD) |
| 88 | uint8_t instance_id : 5; //!< Instance ID |
| 89 | uint8_t reserved : 1; //!< Reserved |
| 90 | uint8_t datagram : 1; //!< Datagram bit |
| 91 | uint8_t request : 1; //!< Request bit |
| 92 | #elif defined(__BIG_ENDIAN_BITFIELD) |
| 93 | uint8_t request : 1; //!< Request bit |
| 94 | uint8_t datagram : 1; //!< Datagram bit |
| 95 | uint8_t reserved : 1; //!< Reserved |
| 96 | uint8_t instance_id : 5; //!< Instance ID |
| 97 | #endif |
| 98 | |
| 99 | #if defined(__LITTLE_ENDIAN_BITFIELD) |
| 100 | uint8_t type : 6; //!< PLDM type |
| 101 | uint8_t header_ver : 2; //!< Header version |
| 102 | #elif defined(__BIG_ENDIAN_BITFIELD) |
| 103 | uint8_t header_ver : 2; //!< Header version |
| 104 | uint8_t type : 6; //!< PLDM type |
| 105 | #endif |
| 106 | uint8_t command; //!< PLDM command code |
| 107 | } __attribute__((packed)); |
| 108 | |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 109 | /** @struct pldm_msg |
| 110 | * |
| 111 | * Structure representing PLDM message |
| 112 | */ |
| 113 | struct pldm_msg { |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 114 | struct pldm_msg_hdr hdr; //!< PLDM message header |
| 115 | uint8_t payload[1]; //!< &payload[0] is the beginning of the payload |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 116 | } __attribute__((packed)); |
| 117 | |
Tom Joseph | 4125104 | 2019-02-07 16:17:07 +0530 | [diff] [blame] | 118 | /** @struct pldm_header_info |
| 119 | * |
| 120 | * The information needed to prepare PLDM header and this is passed to the |
| 121 | * pack_pldm_header and unpack_pldm_header API. |
| 122 | */ |
| 123 | struct pldm_header_info { |
| 124 | MessageType msg_type; //!< PLDM message type |
| 125 | uint8_t instance; //!< PLDM instance id |
| 126 | uint8_t pldm_type; //!< PLDM type |
| 127 | uint8_t command; //!< PLDM command code |
| 128 | uint8_t completion_code; //!< PLDM completion code, applies for response |
| 129 | }; |
| 130 | |
Priyanga | 4b790ce | 2019-06-10 01:30:09 -0500 | [diff] [blame] | 131 | /** @struct pldm_get_types_resp |
| 132 | * |
| 133 | * Structure representing PLDM get types response. |
| 134 | */ |
| 135 | struct pldm_get_types_resp { |
| 136 | uint8_t completion_code; //!< completion code |
| 137 | bitfield8_t types[8]; //!< each bit represents whether a given PLDM Type |
| 138 | //!< is supported |
| 139 | } __attribute__((packed)); |
| 140 | |
| 141 | /** @struct pldm_get_commands_req |
| 142 | * |
| 143 | * Structure representing PLDM get commands request. |
| 144 | */ |
| 145 | struct pldm_get_commands_req { |
| 146 | uint8_t type; //!< PLDM Type for which command support information is |
| 147 | //!< being requested |
| 148 | ver32_t version; //!< version for the specified PLDM Type |
| 149 | } __attribute__((packed)); |
| 150 | |
| 151 | /** @struct pldm_get_commands_resp |
| 152 | * |
| 153 | * Structure representing PLDM get commands response. |
| 154 | */ |
| 155 | struct pldm_get_commands_resp { |
| 156 | uint8_t completion_code; //!< completion code |
| 157 | bitfield8_t commands[32]; //!< each bit represents whether a given PLDM |
| 158 | //!< command is supported |
| 159 | } __attribute__((packed)); |
| 160 | |
| 161 | /** @struct pldm_get_version_req |
| 162 | * |
| 163 | * Structure representing PLDM get version request. |
| 164 | */ |
| 165 | struct pldm_get_version_req { |
| 166 | uint32_t |
| 167 | transfer_handle; //!< handle to identify PLDM version data transfer |
| 168 | uint8_t transfer_opflag; //!< PLDM GetVersion operation flag |
| 169 | uint8_t type; //!< PLDM Type for which version information is being |
| 170 | //!< requested |
| 171 | } __attribute__((packed)); |
| 172 | |
| 173 | /** @struct pldm_get_version_resp |
| 174 | * |
| 175 | * Structure representing PLDM get version response. |
| 176 | */ |
| 177 | |
| 178 | struct pldm_get_version_resp { |
| 179 | uint8_t completion_code; //!< completion code |
| 180 | uint32_t next_transfer_handle; //!< next portion of PLDM version data |
| 181 | //!< transfer |
| 182 | uint8_t transfer_flag; //!< PLDM GetVersion transfer flag |
| 183 | uint8_t version_data[1]; //!< PLDM GetVersion version field |
| 184 | } __attribute__((packed)); |
| 185 | |
John Wang | 5c4f80d | 2019-07-29 11:12:18 +0800 | [diff] [blame] | 186 | /** @struct pldm_get_tid_resp |
| 187 | * |
| 188 | * Structure representing PLDM get tid response. |
| 189 | */ |
| 190 | |
| 191 | struct pldm_get_tid_resp { |
| 192 | uint8_t completion_code; //!< completion code |
| 193 | uint8_t tid; //!< PLDM GetTID TID field |
| 194 | } __attribute__((packed)); |
| 195 | |
Tom Joseph | 4125104 | 2019-02-07 16:17:07 +0530 | [diff] [blame] | 196 | /** |
| 197 | * @brief Populate the PLDM message with the PLDM header.The caller of this API |
| 198 | * allocates buffer for the PLDM header when forming the PLDM message. |
| 199 | * The buffer is passed to this API to pack the PLDM header. |
| 200 | * |
| 201 | * @param[in] hdr - Pointer to the PLDM header information |
| 202 | * @param[out] msg - Pointer to PLDM message header |
| 203 | * |
| 204 | * @return 0 on success, otherwise PLDM error codes. |
| 205 | */ |
| 206 | int pack_pldm_header(const struct pldm_header_info *hdr, |
| 207 | struct pldm_msg_hdr *msg); |
| 208 | |
| 209 | /** |
| 210 | * @brief Unpack the PLDM header from the PLDM message. |
| 211 | * |
| 212 | * @param[in] msg - Pointer to the PLDM message header |
| 213 | * @param[out] hdr - Pointer to the PLDM header information |
| 214 | * |
| 215 | * @return 0 on success, otherwise PLDM error codes. |
| 216 | */ |
| 217 | int unpack_pldm_header(const struct pldm_msg_hdr *msg, |
| 218 | struct pldm_header_info *hdr); |
| 219 | |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 220 | /* Requester */ |
| 221 | |
| 222 | /* GetPLDMTypes */ |
| 223 | |
| 224 | /** @brief Create a PLDM request message for GetPLDMTypes |
| 225 | * |
| 226 | * @param[in] instance_id - Message's instance id |
| 227 | * @param[in,out] msg - Message will be written to this |
| 228 | * @return pldm_completion_codes |
| 229 | * @note Caller is responsible for memory alloc and dealloc of param |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 230 | * 'msg.payload' |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 231 | */ |
| 232 | int encode_get_types_req(uint8_t instance_id, struct pldm_msg *msg); |
| 233 | |
| 234 | /** @brief Decode a GetPLDMTypes response message |
| 235 | * |
Zahed Hossain | 223a73d | 2019-07-04 12:46:18 -0500 | [diff] [blame] | 236 | * @param[in] msg - Response message |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 237 | * @param[in] payload_length - Length of response message payload |
Deepak Kodihalli | 8c64346 | 2019-02-21 10:43:36 -0600 | [diff] [blame] | 238 | * @param[out] completion_code - Pointer to response msg's PLDM completion code |
Deepak Kodihalli | 97e0bd5 | 2019-02-21 03:54:22 -0600 | [diff] [blame] | 239 | * @param[out] types - pointer to array bitfield8_t[8] containing supported |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 240 | * types (MAX_TYPES/8) = 8), as per DSP0240 |
| 241 | * @return pldm_completion_codes |
| 242 | */ |
Zahed Hossain | 223a73d | 2019-07-04 12:46:18 -0500 | [diff] [blame] | 243 | int decode_get_types_resp(const struct pldm_msg *msg, size_t payload_length, |
Deepak Kodihalli | 8c64346 | 2019-02-21 10:43:36 -0600 | [diff] [blame] | 244 | uint8_t *completion_code, bitfield8_t *types); |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 245 | |
| 246 | /* GetPLDMCommands */ |
| 247 | |
| 248 | /** @brief Create a PLDM request message for GetPLDMCommands |
| 249 | * |
| 250 | * @param[in] instance_id - Message's instance id |
| 251 | * @param[in] type - PLDM Type |
| 252 | * @param[in] version - Version for PLDM Type |
| 253 | * @param[in,out] msg - Message will be written to this |
| 254 | * @return pldm_completion_codes |
| 255 | * @note Caller is responsible for memory alloc and dealloc of param |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 256 | * 'msg.payload' |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 257 | */ |
Deepak Kodihalli | 97e0bd5 | 2019-02-21 03:54:22 -0600 | [diff] [blame] | 258 | int encode_get_commands_req(uint8_t instance_id, uint8_t type, ver32_t version, |
| 259 | struct pldm_msg *msg); |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 260 | |
| 261 | /** @brief Decode a GetPLDMCommands response message |
| 262 | * |
Zahed Hossain | 223a73d | 2019-07-04 12:46:18 -0500 | [diff] [blame] | 263 | * @param[in] msg - Response message |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 264 | * @param[in] payload_length - Length of reponse message payload |
Deepak Kodihalli | 8c64346 | 2019-02-21 10:43:36 -0600 | [diff] [blame] | 265 | * @param[out] completion_code - Pointer to response msg's PLDM completion code |
Deepak Kodihalli | 97e0bd5 | 2019-02-21 03:54:22 -0600 | [diff] [blame] | 266 | * @param[in] commands - pointer to array bitfield8_t[32] containing supported |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 267 | * commands (PLDM_MAX_CMDS_PER_TYPE/8) = 32), as per DSP0240 |
| 268 | * @return pldm_completion_codes |
| 269 | */ |
Zahed Hossain | 223a73d | 2019-07-04 12:46:18 -0500 | [diff] [blame] | 270 | int decode_get_commands_resp(const struct pldm_msg *msg, size_t payload_length, |
Deepak Kodihalli | 8c64346 | 2019-02-21 10:43:36 -0600 | [diff] [blame] | 271 | uint8_t *completion_code, bitfield8_t *commands); |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 272 | |
Sampa Misra | 432e187 | 2019-02-13 03:49:43 -0600 | [diff] [blame] | 273 | /* GetPLDMVersion */ |
| 274 | |
| 275 | /** @brief Create a PLDM request for GetPLDMVersion |
| 276 | * |
| 277 | * @param[in] instance_id - Message's instance id |
| 278 | * @param[in] transfer_handle - Handle to identify PLDM version data transfer. |
| 279 | * This handle is ignored by the responder when the |
| 280 | * transferop_flag is set to getFirstPart. |
| 281 | * @param[in] transfer_opflag - flag to indicate whether it is start of |
| 282 | * transfer |
| 283 | * @param[in] type - PLDM Type for which version is requested |
| 284 | * @param[in,out] msg - Message will be written to this |
| 285 | * @return pldm_completion_codes |
| 286 | * @note Caller is responsible for memory alloc and dealloc of param |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 287 | * 'msg.payload' |
Sampa Misra | 432e187 | 2019-02-13 03:49:43 -0600 | [diff] [blame] | 288 | */ |
| 289 | int encode_get_version_req(uint8_t instance_id, uint32_t transfer_handle, |
| 290 | uint8_t transfer_opflag, uint8_t type, |
| 291 | struct pldm_msg *msg); |
| 292 | |
| 293 | /** @brief Decode a GetPLDMVersion response message |
| 294 | * |
Zahed Hossain | 223a73d | 2019-07-04 12:46:18 -0500 | [diff] [blame] | 295 | * @param[in] msg - Response message |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 296 | * @param[in] payload_length - Length of reponse message payload |
Deepak Kodihalli | 8c64346 | 2019-02-21 10:43:36 -0600 | [diff] [blame] | 297 | * @param[out] completion_code - Pointer to response msg's PLDM completion code |
Sampa Misra | 432e187 | 2019-02-13 03:49:43 -0600 | [diff] [blame] | 298 | * @param[out] next_transfer_handle - the next handle for the next part of data |
| 299 | * @param[out] transfer_flag - flag to indicate the part of data |
| 300 | * @return pldm_completion_codes |
| 301 | */ |
Zahed Hossain | 223a73d | 2019-07-04 12:46:18 -0500 | [diff] [blame] | 302 | int decode_get_version_resp(const struct pldm_msg *msg, size_t payload_length, |
Deepak Kodihalli | 8c64346 | 2019-02-21 10:43:36 -0600 | [diff] [blame] | 303 | uint8_t *completion_code, |
Sampa Misra | 432e187 | 2019-02-13 03:49:43 -0600 | [diff] [blame] | 304 | uint32_t *next_transfer_handle, |
Deepak Kodihalli | 97e0bd5 | 2019-02-21 03:54:22 -0600 | [diff] [blame] | 305 | uint8_t *transfer_flag, ver32_t *version); |
Sampa Misra | 432e187 | 2019-02-13 03:49:43 -0600 | [diff] [blame] | 306 | |
John Wang | 5c4f80d | 2019-07-29 11:12:18 +0800 | [diff] [blame] | 307 | /* GetTID */ |
| 308 | |
| 309 | /** @brief Decode a GetTID response message |
| 310 | * |
| 311 | * @param[in] msg - Response message |
| 312 | * @param[in] payload_length - Length of response message payload |
| 313 | * @param[out] completion_code - Pointer to response msg's PLDM completion code |
| 314 | * @param[out] tid - Pointer to the terminus id |
| 315 | * @return pldm_completion_codes |
| 316 | */ |
| 317 | int decode_get_tid_resp(const struct pldm_msg *msg, size_t payload_length, |
| 318 | uint8_t *completion_code, uint8_t *tid); |
| 319 | |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 320 | /* Responder */ |
| 321 | |
| 322 | /* GetPLDMTypes */ |
| 323 | |
| 324 | /** @brief Create a PLDM response message for GetPLDMTypes |
| 325 | * |
| 326 | * @param[in] instance_id - Message's instance id |
| 327 | * @param[in] completion_code - PLDM completion code |
Deepak Kodihalli | 97e0bd5 | 2019-02-21 03:54:22 -0600 | [diff] [blame] | 328 | * @param[in] types - pointer to array bitfield8_t[8] containing supported |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 329 | * types (MAX_TYPES/8) = 8), as per DSP0240 |
| 330 | * @param[in,out] msg - Message will be written to this |
| 331 | * @return pldm_completion_codes |
| 332 | * @note Caller is responsible for memory alloc and dealloc of param |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 333 | * 'msg.payload' |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 334 | */ |
| 335 | int encode_get_types_resp(uint8_t instance_id, uint8_t completion_code, |
Deepak Kodihalli | 97e0bd5 | 2019-02-21 03:54:22 -0600 | [diff] [blame] | 336 | const bitfield8_t *types, struct pldm_msg *msg); |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 337 | |
| 338 | /* GetPLDMCommands */ |
| 339 | |
| 340 | /** @brief Decode GetPLDMCommands' request data |
| 341 | * |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 342 | * @param[in] msg - Request message |
| 343 | * @param[in] payload_length - Length of request message payload |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 344 | * @param[out] type - PLDM Type |
| 345 | * @param[out] version - Version for PLDM Type |
| 346 | * @return pldm_completion_codes |
| 347 | */ |
Zahed Hossain | 223a73d | 2019-07-04 12:46:18 -0500 | [diff] [blame] | 348 | int decode_get_commands_req(const struct pldm_msg *msg, size_t payload_length, |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 349 | uint8_t *type, ver32_t *version); |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 350 | |
| 351 | /** @brief Create a PLDM response message for GetPLDMCommands |
| 352 | * |
| 353 | * @param[in] instance_id - Message's instance id |
| 354 | * @param[in] completion_code - PLDM completion code |
Deepak Kodihalli | 97e0bd5 | 2019-02-21 03:54:22 -0600 | [diff] [blame] | 355 | * @param[in] commands - pointer to array bitfield8_t[32] containing supported |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 356 | * commands (PLDM_MAX_CMDS_PER_TYPE/8) = 32), as per DSP0240 |
| 357 | * @param[in,out] msg - Message will be written to this |
| 358 | * @return pldm_completion_codes |
| 359 | * @note Caller is responsible for memory alloc and dealloc of param |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 360 | * 'msg.payload' |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 361 | */ |
| 362 | int encode_get_commands_resp(uint8_t instance_id, uint8_t completion_code, |
Deepak Kodihalli | 97e0bd5 | 2019-02-21 03:54:22 -0600 | [diff] [blame] | 363 | const bitfield8_t *commands, struct pldm_msg *msg); |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 364 | |
Sampa Misra | 432e187 | 2019-02-13 03:49:43 -0600 | [diff] [blame] | 365 | /* GetPLDMVersion */ |
| 366 | |
| 367 | /** @brief Create a PLDM response for GetPLDMVersion |
| 368 | * |
| 369 | * @param[in] instance_id - Message's instance id |
| 370 | * @param[in] completion_code - PLDM completion code |
| 371 | * @param[in] next_transfer_handle - Handle to identify next portion of |
| 372 | * data transfer |
| 373 | * @param[in] transfer_flag - Represents the part of transfer |
| 374 | * @param[in] version_data - the version data |
| 375 | * @param[in] version_size - size of version data |
| 376 | * @param[in,out] msg - Message will be written to this |
| 377 | * @return pldm_completion_codes |
| 378 | * @note Caller is responsible for memory alloc and dealloc of param |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 379 | * 'msg.payload' |
Sampa Misra | 432e187 | 2019-02-13 03:49:43 -0600 | [diff] [blame] | 380 | */ |
| 381 | int encode_get_version_resp(uint8_t instance_id, uint8_t completion_code, |
| 382 | uint32_t next_transfer_handle, |
Deepak Kodihalli | 97e0bd5 | 2019-02-21 03:54:22 -0600 | [diff] [blame] | 383 | uint8_t transfer_flag, const ver32_t *version_data, |
Sampa Misra | 432e187 | 2019-02-13 03:49:43 -0600 | [diff] [blame] | 384 | size_t version_size, struct pldm_msg *msg); |
| 385 | |
| 386 | /** @brief Decode a GetPLDMVersion request message |
| 387 | * |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 388 | * @param[in] msg - Request message |
| 389 | * @param[in] payload_length - length of request message payload |
Sampa Misra | 432e187 | 2019-02-13 03:49:43 -0600 | [diff] [blame] | 390 | * @param[out] transfer_handle - the handle of data |
| 391 | * @param[out] transfer_opflag - Transfer Flag |
| 392 | * @param[out] type - PLDM type for which version is requested |
| 393 | * @return pldm_completion_codes |
| 394 | */ |
Zahed Hossain | 223a73d | 2019-07-04 12:46:18 -0500 | [diff] [blame] | 395 | int decode_get_version_req(const struct pldm_msg *msg, size_t payload_length, |
Sampa Misra | 432e187 | 2019-02-13 03:49:43 -0600 | [diff] [blame] | 396 | uint32_t *transfer_handle, uint8_t *transfer_opflag, |
| 397 | uint8_t *type); |
| 398 | |
John Wang | 5c4f80d | 2019-07-29 11:12:18 +0800 | [diff] [blame] | 399 | /* GetTID */ |
| 400 | |
| 401 | /** @brief Create a PLDM response message for GetTID |
| 402 | * |
| 403 | * @param[in] instance_id - Message's instance id |
| 404 | * @param[in] completion_code - PLDM completion code |
| 405 | * @param[in] tid - Terminus ID |
| 406 | * @param[in,out] msg - Message will be written to this |
| 407 | * @return pldm_completion_codes |
| 408 | * @note Caller is responsible for memory alloc and dealloc of param |
| 409 | * 'msg.payload' |
| 410 | */ |
| 411 | int encode_get_tid_resp(uint8_t instance_id, uint8_t completion_code, |
| 412 | uint8_t tid, struct pldm_msg *msg); |
| 413 | |
Deepak Kodihalli | 1b24f97 | 2019-02-01 04:09:13 -0600 | [diff] [blame] | 414 | #ifdef __cplusplus |
| 415 | } |
| 416 | #endif |
| 417 | |
| 418 | #endif /* BASE_H */ |