blob: 9f68bce9341eac6b93c7df36a56fd0f6aeb19c11 [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
5int encode_bios_attribute_update_event_req(uint8_t instance_id,
6 uint8_t format_version, uint8_t tid,
7 uint8_t num_handles,
8 const uint8_t *list_of_handles,
9 size_t payload_length,
10 struct pldm_msg *msg)
11{
12 if (format_version != 1) {
13 return PLDM_ERROR_INVALID_DATA;
14 }
15
16 if (msg == NULL || list_of_handles == NULL) {
17 return PLDM_ERROR_INVALID_DATA;
18 }
19
20 if (num_handles == 0) {
21 return PLDM_ERROR_INVALID_DATA;
22 }
23
24 if (payload_length !=
25 (PLDM_PLATFORM_EVENT_MESSAGE_MIN_REQ_BYTES + sizeof(num_handles) +
26 (num_handles * sizeof(uint16_t)))) {
27 return PLDM_ERROR_INVALID_LENGTH;
28 }
29
Andrew Jeffery37dd6a32023-05-12 16:04:06 +093030 struct pldm_header_info header = { 0 };
Andrew Jeffery9c766792022-08-10 23:12:49 +093031 header.msg_type = PLDM_REQUEST;
32 header.instance = instance_id;
33 header.pldm_type = PLDM_PLATFORM;
34 header.command = PLDM_PLATFORM_EVENT_MESSAGE;
35 uint8_t rc = pack_pldm_header(&header, &(msg->hdr));
36 if (rc != PLDM_SUCCESS) {
37 return rc;
38 }
39
40 struct pldm_bios_attribute_update_event_req *request =
Andrew Jeffery37dd6a32023-05-12 16:04:06 +093041 (struct pldm_bios_attribute_update_event_req *)msg->payload;
Andrew Jeffery9c766792022-08-10 23:12:49 +093042 request->format_version = format_version;
43 request->tid = tid;
44 request->event_class = PLDM_EVENT_TYPE_OEM_EVENT_BIOS_ATTRIBUTE_UPDATE;
45 request->num_handles = num_handles;
46 memcpy(request->bios_attribute_handles, list_of_handles,
47 num_handles * sizeof(uint16_t));
48
49 return PLDM_SUCCESS;
50}