1 #include "config.h" 2 #include "libpldm/platform.h" 3 #include "libpldm/platform_oem_ibm.h" 4 #include <string.h> 5 6 LIBPLDM_ABI_STABLE 7 int encode_bios_attribute_update_event_req(uint8_t instance_id, 8 uint8_t format_version, uint8_t tid, 9 uint8_t num_handles, 10 const uint8_t *list_of_handles, 11 size_t payload_length, 12 struct pldm_msg *msg) 13 { 14 if (format_version != 1) { 15 return PLDM_ERROR_INVALID_DATA; 16 } 17 18 if (msg == NULL || list_of_handles == NULL) { 19 return PLDM_ERROR_INVALID_DATA; 20 } 21 22 if (num_handles == 0) { 23 return PLDM_ERROR_INVALID_DATA; 24 } 25 26 if (payload_length != 27 (PLDM_PLATFORM_EVENT_MESSAGE_MIN_REQ_BYTES + sizeof(num_handles) + 28 (num_handles * sizeof(uint16_t)))) { 29 return PLDM_ERROR_INVALID_LENGTH; 30 } 31 32 struct pldm_header_info header = { 0 }; 33 header.msg_type = PLDM_REQUEST; 34 header.instance = instance_id; 35 header.pldm_type = PLDM_PLATFORM; 36 header.command = PLDM_PLATFORM_EVENT_MESSAGE; 37 uint8_t rc = pack_pldm_header(&header, &(msg->hdr)); 38 if (rc != PLDM_SUCCESS) { 39 return rc; 40 } 41 42 struct pldm_bios_attribute_update_event_req *request = 43 (struct pldm_bios_attribute_update_event_req *)msg->payload; 44 request->format_version = format_version; 45 request->tid = tid; 46 request->event_class = PLDM_EVENT_TYPE_OEM_EVENT_BIOS_ATTRIBUTE_UPDATE; 47 request->num_handles = num_handles; 48 memcpy(request->bios_attribute_handles, list_of_handles, 49 num_handles * sizeof(uint16_t)); 50 51 return PLDM_SUCCESS; 52 } 53