blob: d29dc8ade480c413304d5913cc137a4092ebd964 [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
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -050026/** @brief PLDM PDR types
27 */
28enum pldm_pdr_types {
29 PLDM_STATE_EFFECTER_PDR = 11,
30};
31
32/** @brief PLDM effecter initialization schemes
33 */
34enum pldm_effecter_init {
35 PLDM_NO_INIT,
36 PLDM_USE_INIT_PDR,
37 PLDM_ENABLE_EFFECTER,
38 PLDM_DISABLE_EFECTER
39};
40
41/** @struct pldm_pdr_hdr
42 *
43 * Structure representing PLDM common PDR header
44 */
45struct pldm_pdr_hdr {
46 uint32_t record_handle;
47 uint8_t version;
48 uint8_t type;
49 uint16_t record_change_num;
50 uint16_t length;
51} __attribute__((packed));
52
53/** @struct pldm_state_effecter_pdr
54 *
55 * Structure representing PLDM state effecter PDR
56 */
57struct pldm_state_effecter_pdr {
58 struct pldm_pdr_hdr hdr;
59 uint16_t terminus_handle;
60 uint16_t effecter_id;
61 uint16_t entity_type;
62 uint16_t entity_instance;
63 uint16_t container_id;
64 uint16_t effecter_semantic_id;
65 uint8_t effecter_init;
66 bool8_t has_description_pdr;
67 uint8_t composite_effecter_count;
68 uint8_t possible_states[1];
69} __attribute__((packed));
70
71/** @struct state_effecter_possible_states
72 *
73 * Structure representing state enums for state effecter
74 */
75struct state_effecter_possible_states {
76 uint16_t state_set_id;
77 uint8_t possible_states_size;
78 bitfield8_t states[1];
79} __attribute__((packed));
80
Sampa Misra0db1dfa2019-03-19 00:15:31 -050081/** @struct set_effecter_state_field
82 *
83 * Structure representing a stateField in SetStateEffecterStates command */
84
85typedef struct state_field_for_state_effecter_set {
86 uint8_t set_request; //!< Whether to change the state
87 uint8_t effecter_state; //!< Expected state of the effecter
88} __attribute__((packed)) set_effecter_state_field;
89
Priyanga7257fdf2019-06-10 01:59:45 -050090/** @struct PLDM_SetStateEffecterStates_Request
91 *
92 * Structure representing PLDM set state effecter states request.
93 */
94struct pldm_set_state_effecter_states_req {
95 uint16_t effecter_id;
96 uint8_t comp_effecter_count;
97 set_effecter_state_field field[8];
98} __attribute__((packed));
99
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500100/* Responder */
101
102/* SetStateEffecterStates */
103
104/** @brief Create a PLDM response message for SetStateEffecterStates
105 *
106 * @param[in] instance_id - Message's instance id
107 * @param[in] completion_code - PLDM completion code
108 * @param[out] msg - Message will be written to this
109 * @return pldm_completion_codes
110 * @note Caller is responsible for memory alloc and dealloc of param
111 * 'msg.body.payload'
112 */
113
114int encode_set_state_effecter_states_resp(uint8_t instance_id,
115 uint8_t completion_code,
116 struct pldm_msg *msg);
117
118/** @brief Decode SetStateEffecterStates request data
119 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500120 * @param[in] msg - Request message
vkaverapa6575b82019-04-03 05:33:52 -0500121 * @param[in] payload_length - Length of request message payload
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500122 * @param[out] effecter_id - used to identify and access the effecter
123 * @param[out] comp_effecter_count - number of individual sets of effecter
124 * information. Upto eight sets of state effecter info can be accessed
125 * for a given effecter.
126 * @param[out] field - each unit is an instance of the stateFileld structure
127 * that is used to set the requested state for a particular effecter
128 * within the state effecter. This field holds the starting address of
129 * the stateField values. The user is responsible to allocate the
130 * memory prior to calling this command. Since the state field count is
131 * not known in advance, the user should allocate the maximum size
132 * always, which is 8 in number.
133 * @return pldm_completion_codes
134 */
vkaverapa6575b82019-04-03 05:33:52 -0500135
Zahed Hossain223a73d2019-07-04 12:46:18 -0500136int decode_set_state_effecter_states_req(const struct pldm_msg *msg,
vkaverapa6575b82019-04-03 05:33:52 -0500137 size_t payload_length,
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500138 uint16_t *effecter_id,
139 uint8_t *comp_effecter_count,
140 set_effecter_state_field *field);
141
vkaverap98a2c192019-04-03 05:33:52 -0500142/** @brief Create a PLDM request message for SetStateEffecterStates
143 *
144 * @param[in] instance_id - Message's instance id
145 * @param[in] effecter_id - used to identify and access the effecter
146 * @param[in] comp_effecter_count - number of individual sets of effecter
147 * information. Upto eight sets of state effecter info can be accessed
148 * for a given effecter.
149 * @param[in] field - each unit is an instance of the stateField structure
150 * that is used to set the requested state for a particular effecter
151 * within the state effecter. This field holds the starting address of
152 * the stateField values. The user is responsible to allocate the
153 * memory prior to calling this command. The user has to allocate the
154 * field parameter as sizeof(set_effecter_state_field) *
155 * comp_effecter_count
156 * @param[out] msg - Message will be written to this
157 * @return pldm_completion_codes
158 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500159 * 'msg.payload'
vkaverap98a2c192019-04-03 05:33:52 -0500160 */
161
162int encode_set_state_effecter_states_req(uint8_t instance_id,
163 uint16_t effecter_id,
164 uint8_t comp_effecter_count,
165 set_effecter_state_field *field,
166 struct pldm_msg *msg);
167
168/** @brief Decode SetStateEffecterStates response data
Zahed Hossain223a73d2019-07-04 12:46:18 -0500169 * @param[in] msg - Request message
vkaverapa6575b82019-04-03 05:33:52 -0500170 * @param[in] payload_length - Length of response message payload
vkaverap98a2c192019-04-03 05:33:52 -0500171 * @param[out] completion_code - PLDM completion code
172 * @return pldm_completion_codes
173 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500174int decode_set_state_effecter_states_resp(const struct pldm_msg *msg,
vkaverapa6575b82019-04-03 05:33:52 -0500175 size_t payload_length,
vkaverap98a2c192019-04-03 05:33:52 -0500176 uint8_t *completion_code);
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500177#ifdef __cplusplus
178}
179#endif
180
181#endif /* PLATFORM_H */