blob: d8886c3a8a1679eb3c51a5192dda8510b1812d56 [file] [log] [blame]
Sampa Misra032bd502019-03-06 05:03:22 -06001#ifndef BIOS_H
2#define BIOS_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <asm/byteorder.h>
9#include <stddef.h>
10#include <stdint.h>
11
12#include "base.h"
13
14/* Response lengths are inclusive of completion code */
15#define PLDM_GET_DATE_TIME_RESP_BYTES 8
16
Sampa Misrab37be312019-07-03 02:26:41 -050017#define PLDM_GET_BIOS_TABLE_REQ_BYTES 6
18#define PLDM_GET_BIOS_TABLE_MIN_RESP_BYTES 6
19
20enum pldm_bios_completion_codes {
21 PLDM_BIOS_TABLE_UNAVAILABLE = 0x83,
22 PLDM_INVALID_BIOS_TABLE_DATA_INTEGRITY_CHECK = 0x84,
23 PLDM_INVALID_BIOS_TABLE_TYPE = 0x85,
24};
25enum pldm_bios_commands {
26 PLDM_GET_BIOS_TABLE = 0x01,
27 PLDM_GET_DATE_TIME = 0x0c
28};
Sampa Misra032bd502019-03-06 05:03:22 -060029
Deepak Kodihallicb7f2d42019-06-19 13:25:31 +053030enum pldm_bios_table_types {
31 PLDM_BIOS_STRING_TABLE,
32 PLDM_BIOS_ATTR_TABLE,
33 PLDM_BIOS_ATTR_VAL_TABLE,
34};
35
36struct pldm_bios_string_table_entry {
37 uint16_t string_handle;
38 uint16_t string_length;
39 char name[1];
40} __attribute__((packed));
41
42struct pldm_bios_attr_table_entry {
43 uint16_t attr_handle;
44 uint8_t attr_type;
45 uint16_t string_handle;
46 uint8_t metadata[1];
47} __attribute__((packed));
48
49struct pldm_bios_enum_attr {
50 uint8_t num_possible_values;
51 uint16_t indices[1];
52} __attribute__((packed));
53
54struct pldm_bios_attr_val_table_entry {
55 uint16_t attr_handle;
56 uint8_t attr_type;
57 uint8_t value[1];
58} __attribute__((packed));
59
Sampa Misrab37be312019-07-03 02:26:41 -050060enum pldm_bios_attribute_type {
61 PLDM_BIOS_ENUMERATION = 0x0,
62 PLDM_BIOS_STRING = 0x1,
63 PLDM_BIOS_PASSWORD = 0x2,
64 PLDM_BIOS_INTEGER = 0x3,
65 PLDM_BIOS_ENUMERATION_READ_ONLY = 0x80,
66 PLDM_BIOS_STRING_READ_ONLY = 0x81,
67 PLDM_BIOS_PASSWORD_READ_ONLY = 0x82,
68 PLDM_BIOS_INTEGER_READ_ONLY = 0x83,
69};
70
71/** @struct pldm_get_bios_table_req
72 *
73 * structure representing GetBIOSTable request packet
74 */
75struct pldm_get_bios_table_req {
76 uint32_t transfer_handle;
77 uint8_t transfer_op_flag;
78 uint8_t table_type;
79} __attribute__((packed));
80
81/** @struct pldm_get_bios_table_resp
82 *
83 * structure representing GetBIOSTable response packet
84 */
85struct pldm_get_bios_table_resp {
86 uint8_t completion_code;
87 uint32_t next_transfer_handle;
88 uint8_t transfer_flag;
89 uint8_t table_data[1];
90} __attribute__((packed));
91
Priyanga5dcd1802019-06-10 01:50:39 -050092/** @struct pldm_get_date_time_resp
93 *
94 * Structure representing PLDM get date time response
95 */
96struct pldm_get_date_time_resp {
97 uint8_t completion_code; //!< completion code
98 uint8_t seconds; //!< Seconds in BCD format
99 uint8_t minutes; //!< Minutes in BCD format
100 uint8_t hours; //!< Hours in BCD format
101 uint8_t day; //!< Day of the month in BCD format
102 uint8_t month; //!< Month in BCD format
103 uint16_t year; //!< Year in BCD format
104} __attribute__((packed));
105
Sampa Misra032bd502019-03-06 05:03:22 -0600106/* Requester */
107
108/* GetDateTime */
109
110/** @brief Create a PLDM request message for GetDateTime
111 *
112 * @param[in] instance_id - Message's instance id
113 * @param[out] msg - Message will be written to this
114 * @return pldm_completion_codes
115 * @note Caller is responsible for memory alloc and dealloc of param
116 * 'msg.body.payload'
117 */
118
119int encode_get_date_time_req(uint8_t instance_id, struct pldm_msg *msg);
120
121/** @brief Decode a GetDateTime response message
122 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500123 * @param[in] msg - Response message
vkaverapa6575b82019-04-03 05:33:52 -0500124 * @param[in] payload_length - Length of response message payload
Sampa Misra032bd502019-03-06 05:03:22 -0600125 * @param[out] completion_code - Pointer to response msg's PLDM completion code
126 * @param[out] seconds - Seconds in BCD format
127 * @param[out] minutes - minutes in BCD format
128 * @param[out] hours - hours in BCD format
129 * @param[out] day - day of month in BCD format
130 * @param[out] month - number of month in BCD format
131 * @param[out] year - year in BCD format
132 * @return pldm_completion_codes
133 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500134int decode_get_date_time_resp(const struct pldm_msg *msg, size_t payload_length,
Sampa Misra032bd502019-03-06 05:03:22 -0600135 uint8_t *completion_code, uint8_t *seconds,
136 uint8_t *minutes, uint8_t *hours, uint8_t *day,
137 uint8_t *month, uint16_t *year);
138
139/* Responder */
140
141/* GetDateTime */
142
143/** @brief Create a PLDM response message for GetDateTime
144 *
145 * @param[in] instance_id - Message's instance id
146 * @param[in] completion_code - PLDM completion code
147 * @param[in] seconds - seconds in BCD format
148 * @param[in] minutes - minutes in BCD format
149 * @param[in] hours - hours in BCD format
150 * @param[in] day - day of the month in BCD format
151 * @param[in] month - number of month in BCD format
152 * @param[in] year - year in BCD format
153 * @param[out] msg - Message will be written to this
154 * @return pldm_completion_codes
155 * @note Caller is responsible for memory alloc and dealloc of param
156 * 'msg.body.payload'
157 */
158
159int encode_get_date_time_resp(uint8_t instance_id, uint8_t completion_code,
160 uint8_t seconds, uint8_t minutes, uint8_t hours,
161 uint8_t day, uint8_t month, uint16_t year,
162 struct pldm_msg *msg);
163
Sampa Misrab37be312019-07-03 02:26:41 -0500164/* GetBIOSTable */
165
166/** @brief Create a PLDM response message for GetBIOSTable
167 *
168 * @param[in] instance_id - Message's instance id
169 * @param[in] completion_code - PLDM completion code
170 * @param[in] next_transfer_handle - handle to identify the next portion of the
171 * transfer
172 * @param[in] transfer_flag - To indicate what part of the transfer this
173 * response represents
174 * @param[in] table_data - BIOS Table type specific data
175 * @param[in] payload_length - Length of payload message
176 * @param[out] msg - Message will be written to this
177 * @return pldm_completion_codes
178 */
179int encode_get_bios_table_resp(uint8_t instance_id, uint8_t completion_code,
180 uint32_t next_transfer_handle,
181 uint8_t transfer_flag, uint8_t *table_data,
182 size_t payload_length, struct pldm_msg *msg);
183
184/** @brief Decode GetBIOSTable request packet
185 *
186 * @param[in] msg - Request message
187 * @param[in] payload_length - Length of request message payload
188 * @param[out] transfer_handle - Handle to identify a BIOS table transfer
189 * @param[out] transfer_op_flag - Flag to indicate the start of a multipart
190 * transfer
191 * @param[out] table_type - BIOS table type
192 * @return pldm_completion_codes
193 */
194int decode_get_bios_table_req(const struct pldm_msg *msg, size_t payload_length,
195 uint32_t *transfer_handle,
196 uint8_t *transfer_op_flag, uint8_t *table_type);
197
Sampa Misra032bd502019-03-06 05:03:22 -0600198#ifdef __cplusplus
199}
200#endif
201
202#endif /* BIOS_H */