blob: 042044fd9bf3246db6b71d25f445f59d1e1a7ebc [file] [log] [blame]
Patrick Williams691668f2023-11-01 08:19:10 -05001/* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */
Andrew Jefferyb0c1d202023-11-07 22:08:44 +10302#include <libpldm/platform.h>
3#include <libpldm/oem/ibm/libpldm/platform_oem_ibm.h>
4
Andrew Jeffery9c766792022-08-10 23:12:49 +09305#include <string.h>
6
Andrew Jeffery9d2a1c62023-06-05 13:02:16 +09307LIBPLDM_ABI_STABLE
Andrew Jeffery9c766792022-08-10 23:12:49 +09308int encode_bios_attribute_update_event_req(uint8_t instance_id,
9 uint8_t format_version, uint8_t tid,
10 uint8_t num_handles,
11 const uint8_t *list_of_handles,
12 size_t payload_length,
13 struct pldm_msg *msg)
14{
15 if (format_version != 1) {
16 return PLDM_ERROR_INVALID_DATA;
17 }
18
19 if (msg == NULL || list_of_handles == NULL) {
20 return PLDM_ERROR_INVALID_DATA;
21 }
22
23 if (num_handles == 0) {
24 return PLDM_ERROR_INVALID_DATA;
25 }
26
27 if (payload_length !=
28 (PLDM_PLATFORM_EVENT_MESSAGE_MIN_REQ_BYTES + sizeof(num_handles) +
29 (num_handles * sizeof(uint16_t)))) {
30 return PLDM_ERROR_INVALID_LENGTH;
31 }
32
Andrew Jeffery37dd6a32023-05-12 16:04:06 +093033 struct pldm_header_info header = { 0 };
Andrew Jeffery9c766792022-08-10 23:12:49 +093034 header.msg_type = PLDM_REQUEST;
35 header.instance = instance_id;
36 header.pldm_type = PLDM_PLATFORM;
37 header.command = PLDM_PLATFORM_EVENT_MESSAGE;
38 uint8_t rc = pack_pldm_header(&header, &(msg->hdr));
39 if (rc != PLDM_SUCCESS) {
40 return rc;
41 }
42
43 struct pldm_bios_attribute_update_event_req *request =
Andrew Jeffery37dd6a32023-05-12 16:04:06 +093044 (struct pldm_bios_attribute_update_event_req *)msg->payload;
Andrew Jeffery9c766792022-08-10 23:12:49 +093045 request->format_version = format_version;
46 request->tid = tid;
47 request->event_class = PLDM_EVENT_TYPE_OEM_EVENT_BIOS_ATTRIBUTE_UPDATE;
48 request->num_handles = num_handles;
49 memcpy(request->bios_attribute_handles, list_of_handles,
50 num_handles * sizeof(uint16_t));
51
52 return PLDM_SUCCESS;
53}