blob: db7090aa5b6dfdf984b001ce209b17098f13f793 [file] [log] [blame]
Patrick Williams70a47ba2021-09-02 09:53:31 -05001#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 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
30 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) {
37 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;
Tom Joseph7f839f92020-09-21 10:20:44 +053050}