blob: 790f1f587da1317baddb1ffd74aa475575c3a5da [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
Priyanga7257fdf2019-06-10 01:59:45 -050035/** @struct PLDM_SetStateEffecterStates_Request
36 *
37 * Structure representing PLDM set state effecter states request.
38 */
39struct pldm_set_state_effecter_states_req {
40 uint16_t effecter_id;
41 uint8_t comp_effecter_count;
42 set_effecter_state_field field[8];
43} __attribute__((packed));
44
Sampa Misra0db1dfa2019-03-19 00:15:31 -050045/* Responder */
46
47/* SetStateEffecterStates */
48
49/** @brief Create a PLDM response message for SetStateEffecterStates
50 *
51 * @param[in] instance_id - Message's instance id
52 * @param[in] completion_code - PLDM completion code
53 * @param[out] msg - Message will be written to this
54 * @return pldm_completion_codes
55 * @note Caller is responsible for memory alloc and dealloc of param
56 * 'msg.body.payload'
57 */
58
59int encode_set_state_effecter_states_resp(uint8_t instance_id,
60 uint8_t completion_code,
61 struct pldm_msg *msg);
62
63/** @brief Decode SetStateEffecterStates request data
64 *
65 * @param[in] msg - Request message payload
vkaverapa6575b82019-04-03 05:33:52 -050066 * @param[in] payload_length - Length of request message payload
Sampa Misra0db1dfa2019-03-19 00:15:31 -050067 * @param[out] effecter_id - used to identify and access the effecter
68 * @param[out] comp_effecter_count - number of individual sets of effecter
69 * information. Upto eight sets of state effecter info can be accessed
70 * for a given effecter.
71 * @param[out] field - each unit is an instance of the stateFileld structure
72 * that is used to set the requested state for a particular effecter
73 * within the state effecter. This field holds the starting address of
74 * the stateField values. The user is responsible to allocate the
75 * memory prior to calling this command. Since the state field count is
76 * not known in advance, the user should allocate the maximum size
77 * always, which is 8 in number.
78 * @return pldm_completion_codes
79 */
vkaverapa6575b82019-04-03 05:33:52 -050080
81int decode_set_state_effecter_states_req(const uint8_t *msg,
82 size_t payload_length,
Sampa Misra0db1dfa2019-03-19 00:15:31 -050083 uint16_t *effecter_id,
84 uint8_t *comp_effecter_count,
85 set_effecter_state_field *field);
86
vkaverap98a2c192019-04-03 05:33:52 -050087/** @brief Create a PLDM request message for SetStateEffecterStates
88 *
89 * @param[in] instance_id - Message's instance id
90 * @param[in] effecter_id - used to identify and access the effecter
91 * @param[in] comp_effecter_count - number of individual sets of effecter
92 * information. Upto eight sets of state effecter info can be accessed
93 * for a given effecter.
94 * @param[in] field - each unit is an instance of the stateField structure
95 * that is used to set the requested state for a particular effecter
96 * within the state effecter. This field holds the starting address of
97 * the stateField values. The user is responsible to allocate the
98 * memory prior to calling this command. The user has to allocate the
99 * field parameter as sizeof(set_effecter_state_field) *
100 * comp_effecter_count
101 * @param[out] msg - Message will be written to this
102 * @return pldm_completion_codes
103 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500104 * 'msg.payload'
vkaverap98a2c192019-04-03 05:33:52 -0500105 */
106
107int encode_set_state_effecter_states_req(uint8_t instance_id,
108 uint16_t effecter_id,
109 uint8_t comp_effecter_count,
110 set_effecter_state_field *field,
111 struct pldm_msg *msg);
112
113/** @brief Decode SetStateEffecterStates response data
114 * @param[in] msg - Request message payload
vkaverapa6575b82019-04-03 05:33:52 -0500115 * @param[in] payload_length - Length of response message payload
vkaverap98a2c192019-04-03 05:33:52 -0500116 * @param[out] completion_code - PLDM completion code
117 * @return pldm_completion_codes
118 */
vkaverapa6575b82019-04-03 05:33:52 -0500119int decode_set_state_effecter_states_resp(const uint8_t *msg,
120 size_t payload_length,
vkaverap98a2c192019-04-03 05:33:52 -0500121 uint8_t *completion_code);
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500122#ifdef __cplusplus
123}
124#endif
125
126#endif /* PLATFORM_H */