blob: 462f378e907eefa0ceb579be5621fbec4f259d49 [file] [log] [blame]
Andrew Jeffery9c766792022-08-10 23:12:49 +09301#include "libpldm/platform.h"
2#include "libpldm/platform_oem_ibm.h"
3#include <string.h>
4
Andrew Jeffery9d2a1c62023-06-05 13:02:16 +09305LIBPLDM_ABI_STABLE
Andrew Jeffery9c766792022-08-10 23:12:49 +09306int 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 Jeffery37dd6a32023-05-12 16:04:06 +093031 struct pldm_header_info header = { 0 };
Andrew Jeffery9c766792022-08-10 23:12:49 +093032 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 Jeffery37dd6a32023-05-12 16:04:06 +093042 (struct pldm_bios_attribute_update_event_req *)msg->payload;
Andrew Jeffery9c766792022-08-10 23:12:49 +093043 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}