blob: 1cf7e8648076f6edd35a555aa8000153846d7ce9 [file] [log] [blame]
Tom Joseph7f839f92020-09-21 10:20:44 +05301#include "platform_oem_ibm.h"
2#include "platform.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 struct pldm_header_info header = {0};
13 int rc = PLDM_SUCCESS;
14
15 header.msg_type = PLDM_REQUEST;
16 header.instance = instance_id;
17 header.pldm_type = PLDM_PLATFORM;
18 header.command = PLDM_PLATFORM_EVENT_MESSAGE;
19
20 if (format_version != 1) {
21 return PLDM_ERROR_INVALID_DATA;
22 }
23
24 if (msg == NULL || list_of_handles == NULL) {
25 return PLDM_ERROR_INVALID_DATA;
26 }
27
28 if (num_handles == 0) {
29 return PLDM_ERROR_INVALID_DATA;
30 }
31
32 if (payload_length !=
33 (PLDM_PLATFORM_EVENT_MESSAGE_MIN_REQ_BYTES + sizeof(num_handles) +
34 (num_handles * sizeof(uint16_t)))) {
35 return PLDM_ERROR_INVALID_LENGTH;
36 }
37
38 if ((rc = pack_pldm_header(&header, &(msg->hdr))) > 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}