Sampa Misra | 0db1dfa | 2019-03-19 00:15:31 -0500 | [diff] [blame] | 1 | #ifndef PLATFORM_H |
| 2 | #define PLATFORM_H |
| 3 | |
| 4 | #ifdef __cplusplus |
| 5 | extern "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 | |
| 18 | enum set_request { PLDM_NO_CHANGE = 0x00, PLDM_REQUEST_SET = 0x01 }; |
| 19 | |
| 20 | enum effecter_state { PLDM_INVALID_VALUE = 0xFF }; |
| 21 | |
| 22 | enum 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 | |
| 30 | typedef 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 | |
| 49 | int 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 |
| 56 | * @param[out] effecter_id - used to identify and access the effecter |
| 57 | * @param[out] comp_effecter_count - number of individual sets of effecter |
| 58 | * information. Upto eight sets of state effecter info can be accessed |
| 59 | * for a given effecter. |
| 60 | * @param[out] field - each unit is an instance of the stateFileld structure |
| 61 | * that is used to set the requested state for a particular effecter |
| 62 | * within the state effecter. This field holds the starting address of |
| 63 | * the stateField values. The user is responsible to allocate the |
| 64 | * memory prior to calling this command. Since the state field count is |
| 65 | * not known in advance, the user should allocate the maximum size |
| 66 | * always, which is 8 in number. |
| 67 | * @return pldm_completion_codes |
| 68 | */ |
| 69 | int decode_set_state_effecter_states_req(const struct pldm_msg_payload *msg, |
| 70 | uint16_t *effecter_id, |
| 71 | uint8_t *comp_effecter_count, |
| 72 | set_effecter_state_field *field); |
| 73 | |
| 74 | #ifdef __cplusplus |
| 75 | } |
| 76 | #endif |
| 77 | |
| 78 | #endif /* PLATFORM_H */ |