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