blob: a5bfe4e787f6b8d1608c5242a22155014d00d461 [file] [log] [blame]
Sampa Misra0db1dfa2019-03-19 00:15:31 -05001#ifndef PLATFORM_H
2#define PLATFORM_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stddef.h>
9#include <stdint.h>
10
11#include "base.h"
12
13/* Maximum size for request */
14#define PLDM_SET_STATE_EFFECTER_STATES_REQ_BYTES 19
15/* Response lengths are inclusive of completion code */
16#define PLDM_SET_STATE_EFFECTER_STATES_RESP_BYTES 1
17
18enum set_request { PLDM_NO_CHANGE = 0x00, PLDM_REQUEST_SET = 0x01 };
19
20enum effecter_state { PLDM_INVALID_VALUE = 0xFF };
21
22enum pldm_platform_commands {
23 PLDM_SET_STATE_EFFECTER_STATES = 0x39,
24};
25
26/** @struct set_effecter_state_field
27 *
28 * Structure representing a stateField in SetStateEffecterStates command */
29
30typedef struct state_field_for_state_effecter_set {
31 uint8_t set_request; //!< Whether to change the state
32 uint8_t effecter_state; //!< Expected state of the effecter
33} __attribute__((packed)) set_effecter_state_field;
34
35/* Responder */
36
37/* SetStateEffecterStates */
38
39/** @brief Create a PLDM response message for SetStateEffecterStates
40 *
41 * @param[in] instance_id - Message's instance id
42 * @param[in] completion_code - PLDM completion code
43 * @param[out] msg - Message will be written to this
44 * @return pldm_completion_codes
45 * @note Caller is responsible for memory alloc and dealloc of param
46 * 'msg.body.payload'
47 */
48
49int encode_set_state_effecter_states_resp(uint8_t instance_id,
50 uint8_t completion_code,
51 struct pldm_msg *msg);
52
53/** @brief Decode SetStateEffecterStates request data
54 *
55 * @param[in] msg - Request message payload
vkaverapa6575b82019-04-03 05:33:52 -050056 * @param[in] payload_length - Length of request message payload
Sampa Misra0db1dfa2019-03-19 00:15:31 -050057 * @param[out] effecter_id - used to identify and access the effecter
58 * @param[out] comp_effecter_count - number of individual sets of effecter
59 * information. Upto eight sets of state effecter info can be accessed
60 * for a given effecter.
61 * @param[out] field - each unit is an instance of the stateFileld structure
62 * that is used to set the requested state for a particular effecter
63 * within the state effecter. This field holds the starting address of
64 * the stateField values. The user is responsible to allocate the
65 * memory prior to calling this command. Since the state field count is
66 * not known in advance, the user should allocate the maximum size
67 * always, which is 8 in number.
68 * @return pldm_completion_codes
69 */
vkaverapa6575b82019-04-03 05:33:52 -050070
71int decode_set_state_effecter_states_req(const uint8_t *msg,
72 size_t payload_length,
Sampa Misra0db1dfa2019-03-19 00:15:31 -050073 uint16_t *effecter_id,
74 uint8_t *comp_effecter_count,
75 set_effecter_state_field *field);
76
vkaverap98a2c192019-04-03 05:33:52 -050077/** @brief Create a PLDM request message for SetStateEffecterStates
78 *
79 * @param[in] instance_id - Message's instance id
80 * @param[in] effecter_id - used to identify and access the effecter
81 * @param[in] comp_effecter_count - number of individual sets of effecter
82 * information. Upto eight sets of state effecter info can be accessed
83 * for a given effecter.
84 * @param[in] field - each unit is an instance of the stateField structure
85 * that is used to set the requested state for a particular effecter
86 * within the state effecter. This field holds the starting address of
87 * the stateField values. The user is responsible to allocate the
88 * memory prior to calling this command. The user has to allocate the
89 * field parameter as sizeof(set_effecter_state_field) *
90 * comp_effecter_count
91 * @param[out] msg - Message will be written to this
92 * @return pldm_completion_codes
93 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -050094 * 'msg.payload'
vkaverap98a2c192019-04-03 05:33:52 -050095 */
96
97int encode_set_state_effecter_states_req(uint8_t instance_id,
98 uint16_t effecter_id,
99 uint8_t comp_effecter_count,
100 set_effecter_state_field *field,
101 struct pldm_msg *msg);
102
103/** @brief Decode SetStateEffecterStates response data
104 * @param[in] msg - Request message payload
vkaverapa6575b82019-04-03 05:33:52 -0500105 * @param[in] payload_length - Length of response message payload
vkaverap98a2c192019-04-03 05:33:52 -0500106 * @param[out] completion_code - PLDM completion code
107 * @return pldm_completion_codes
108 */
vkaverapa6575b82019-04-03 05:33:52 -0500109int decode_set_state_effecter_states_resp(const uint8_t *msg,
110 size_t payload_length,
vkaverap98a2c192019-04-03 05:33:52 -0500111 uint8_t *completion_code);
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500112#ifdef __cplusplus
113}
114#endif
115
116#endif /* PLATFORM_H */