blob: 7090f95895101a4bd3382fa55d5364ba789c9d85 [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{
Tom Joseph7f839f92020-09-21 10:20:44 +053012 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
George Liub7095ff2021-06-14 16:01:57 +080030 struct pldm_header_info header = {0};
31 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) {
Tom Joseph7f839f92020-09-21 10:20:44 +053037 return rc;
38 }
39
40 struct pldm_bios_attribute_update_event_req *request =
41 (struct pldm_bios_attribute_update_event_req *)msg->payload;
42 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}