John Wang | 0270040 | 2019-10-06 16:34:29 +0800 | [diff] [blame] | 1 | #ifndef BIOS_TABLE_H__ |
| 2 | #define BIOS_TABLE_H__ |
| 3 | |
| 4 | #ifdef __cplusplus |
| 5 | extern "C" { |
| 6 | #endif |
| 7 | |
| 8 | #include "bios.h" |
| 9 | #include <stdbool.h> |
| 10 | #include <stddef.h> |
| 11 | #include <stdint.h> |
| 12 | |
| 13 | /** @struct pldm_bios_table_iter |
| 14 | * structure representing bios table iterator |
| 15 | */ |
| 16 | struct pldm_bios_table_iter; |
| 17 | |
| 18 | /** @brief Create a bios table iterator |
| 19 | * @param[in] table - Pointer to table data |
| 20 | * @param[in] length - Length of table data |
| 21 | * @param[in] type - Type of pldm bios table |
| 22 | * @return Iterator to the beginning |
| 23 | */ |
| 24 | struct pldm_bios_table_iter * |
| 25 | pldm_bios_table_iter_create(const void *table, size_t length, |
| 26 | enum pldm_bios_table_types type); |
| 27 | |
| 28 | /** @brief Release a bios table iterator |
| 29 | * @param[in] iter - Pointer to bios table iterator |
| 30 | */ |
| 31 | void pldm_bios_table_iter_free(struct pldm_bios_table_iter *iter); |
| 32 | |
| 33 | /** @brief Check if the iterator reaches the end of the bios table |
| 34 | * @param[in] iter - Pointer to the bios table iterator |
| 35 | * @return true if iterator reaches the end |
| 36 | * @note *end* is a position after the last entry. |
| 37 | */ |
| 38 | bool pldm_bios_table_iter_is_end(const struct pldm_bios_table_iter *iter); |
| 39 | |
| 40 | /** @brief Get iterator to next entry |
| 41 | * @param[in] iter - Pointer the bios table iterator |
| 42 | */ |
| 43 | void pldm_bios_table_iter_next(struct pldm_bios_table_iter *iter); |
| 44 | |
| 45 | /** @brief Get the bios table entry that the iterator points to |
| 46 | * @param[in] iter - Pointer to the bios table iterator |
| 47 | * @return Pointer to an entry in bios table |
| 48 | */ |
| 49 | const void *pldm_bios_table_iter_value(struct pldm_bios_table_iter *iter); |
| 50 | |
| 51 | /** @brief Get the bios attribute table entry that the iterator points to |
| 52 | * @param[in] iter - Pointer the bios attribute table iterator |
| 53 | * @return Pointer to an entry in bios attribute table |
| 54 | */ |
| 55 | static inline const struct pldm_bios_attr_table_entry * |
| 56 | pldm_bios_table_iter_attr_entry_value(struct pldm_bios_table_iter *iter) |
| 57 | { |
| 58 | return (const struct pldm_bios_attr_table_entry *) |
| 59 | pldm_bios_table_iter_value(iter); |
| 60 | } |
| 61 | |
John Wang | dd9a628 | 2019-10-11 18:52:46 +0800 | [diff] [blame] | 62 | /** @brief Get the bios string table entry that the iterator ponit to |
| 63 | * @param[in] iter - Pointer the bios string table iterator |
| 64 | * @return Pointer to an entry in bios string table |
| 65 | */ |
| 66 | static inline const struct pldm_bios_string_table_entry * |
| 67 | pldm_bios_table_iter_string_entry_value(struct pldm_bios_table_iter *iter) |
| 68 | { |
| 69 | return (const struct pldm_bios_string_table_entry *) |
| 70 | pldm_bios_table_iter_value(iter); |
| 71 | } |
| 72 | |
John Wang | 49484a1 | 2019-12-02 14:21:53 +0800 | [diff] [blame] | 73 | /** @brief Get the bios attribute value table entry that the iterator ponit to |
| 74 | * @param[in] iter - Pointer the bios attribute value table iterator |
| 75 | * @return Pointer to an entry in bios attribute value table |
| 76 | */ |
| 77 | static inline const struct pldm_bios_attr_val_table_entry * |
| 78 | pldm_bios_table_iter_attr_value_entry_value(struct pldm_bios_table_iter *iter) |
| 79 | { |
| 80 | return (const struct pldm_bios_attr_val_table_entry *) |
| 81 | pldm_bios_table_iter_value(iter); |
| 82 | } |
| 83 | |
John Wang | dd9a628 | 2019-10-11 18:52:46 +0800 | [diff] [blame] | 84 | /** @brief Get the length of an entry in the BIOS String Table |
| 85 | * @param[in] string_length - Length of string |
| 86 | * @return Length of an entry in bytes |
| 87 | */ |
| 88 | size_t pldm_bios_table_string_entry_encode_length(uint16_t string_length); |
| 89 | |
| 90 | /** @brief Create an entry of BIOS String Table |
| 91 | * @param[out] entry - Pointer to a buffer to create an entry |
| 92 | * @param[in] entry_length - Length of the buffer to create an entry |
| 93 | * @param[in] str - String itself |
| 94 | * @param[in] str_length - Length of the string |
| 95 | */ |
| 96 | void pldm_bios_table_string_entry_encode(void *entry, size_t entry_length, |
| 97 | const char *str, uint16_t str_length); |
| 98 | |
| 99 | /** @brief Create an entry of BIOS String Table and check the validity of the |
| 100 | * parameters |
| 101 | * @param[out] entry - Pointer to a buffer to create an entry |
| 102 | * @param[in] entry_length - Length of the buffer to create an entry |
| 103 | * @param[in] str - String itself |
| 104 | * @param[in] str_length - Length of the string |
| 105 | * @return pldm_completion_codes |
| 106 | */ |
| 107 | int pldm_bios_table_string_entry_encode_check(void *entry, size_t entry_length, |
| 108 | const char *str, |
| 109 | uint16_t str_length); |
| 110 | |
| 111 | /** @brief Get the string handle for the entry |
| 112 | * @param[in] entry - Pointer to a bios string table entry |
| 113 | * @return Handle to identify a string in the bios string table |
| 114 | */ |
| 115 | uint16_t pldm_bios_table_string_entry_decode_handle( |
| 116 | const struct pldm_bios_string_table_entry *entry); |
| 117 | |
| 118 | /** @brief Get the string length for the entry |
| 119 | * @param[in] entry - Pointer to a bios string table entry |
| 120 | * @return Length of string in bytes |
| 121 | */ |
| 122 | uint16_t pldm_bios_table_string_entry_decode_string_length( |
| 123 | const struct pldm_bios_string_table_entry *entry); |
| 124 | |
| 125 | /** @brief Get the string(at most one less than *size* characters) from the |
| 126 | * entry |
| 127 | * @param[in] entry - Pointer to a bios string table entry |
| 128 | * @param[out] buffer - Pointer to a buffer to store the string |
| 129 | * @param[in] size - Size of the buffer to store the string |
| 130 | * @return Length of the string decoded |
| 131 | */ |
| 132 | uint16_t pldm_bios_table_string_entry_decode_string( |
| 133 | const struct pldm_bios_string_table_entry *entry, char *buffer, |
| 134 | size_t size); |
| 135 | |
| 136 | /** @brief Get the string from the entry and check the validity of the |
| 137 | * parameters |
| 138 | * @param[in] entry - Pointer to a bios string table entry |
| 139 | * @param[out] buffer - Pointer to a buffer to store the string |
| 140 | * @param[in] size - Size of the buffer to store the string |
| 141 | * @return pldm_completion_codes |
| 142 | */ |
| 143 | int pldm_bios_table_string_entry_decode_string_check( |
| 144 | const struct pldm_bios_string_table_entry *entry, char *buffer, |
| 145 | size_t size); |
| 146 | |
| 147 | /** @brief Find an entry in bios string table by string |
| 148 | * @param[in] table - The BIOS String Table |
| 149 | * @param[in] length - Length of the BIOS String Table |
| 150 | * @param[in] str - String itself |
| 151 | * @return Pointer to an entry in the bios string table |
| 152 | */ |
| 153 | const struct pldm_bios_string_table_entry * |
| 154 | pldm_bios_table_string_find_by_string(const void *table, size_t length, |
| 155 | const char *str); |
| 156 | /** @brief Find an entry in bios string table by handle |
| 157 | * @param[in] table - The BIOS String Table |
| 158 | * @param[in] length - Length of the BIOS String Table |
| 159 | * @param[in] handle - Handle to identify a string in the bios string table |
| 160 | * @return Pointer to an entry in the bios string table |
| 161 | */ |
| 162 | const struct pldm_bios_string_table_entry * |
| 163 | pldm_bios_table_string_find_by_handle(const void *table, size_t length, |
| 164 | uint16_t handle); |
| 165 | |
John Wang | ccc0455 | 2019-10-14 14:28:25 +0800 | [diff] [blame] | 166 | /** @struct pldm_bios_table_attr_entry_enum_info |
| 167 | * |
| 168 | * An auxiliary structure for passing parameters to @ref |
| 169 | * pldm_bios_table_attr_entry_enum_encode |
| 170 | * |
| 171 | */ |
| 172 | struct pldm_bios_table_attr_entry_enum_info { |
| 173 | uint16_t name_handle; //!< attribute name handle |
| 174 | bool read_only; //!< indicate whether the attribute is read-only |
| 175 | uint8_t pv_num; //!< number of possible values |
| 176 | const uint16_t *pv_handle; //!< handles of possible values |
| 177 | uint8_t def_num; //!< nnumber of default values |
| 178 | const uint8_t *def_index; //!< indices of default values. |
| 179 | }; |
| 180 | |
| 181 | /** @brief Get length that an attribute entry(type: enum) will take |
| 182 | * @param[in] pv_num - Number of possible values |
| 183 | * @param[in] def_num - Number of default values |
| 184 | * @return The length that an entry(type: enum) will take |
| 185 | */ |
| 186 | size_t pldm_bios_table_attr_entry_enum_encode_length(uint8_t pv_num, |
| 187 | uint8_t def_num); |
| 188 | |
| 189 | /** @brief Create an entry of BIOS Attribute Table (type: enum) |
| 190 | * @param[out] entry - Pointer to a buffer to create an entry |
| 191 | * @param[in] entry_length - Length of the buffer to create an entry |
| 192 | * @param[in] info - Pointer to an auxiliary structure @ref |
| 193 | * pldm_bios_table_attr_entry_enum_info |
| 194 | */ |
| 195 | void pldm_bios_table_attr_entry_enum_encode( |
| 196 | void *entry, size_t entry_length, |
| 197 | const struct pldm_bios_table_attr_entry_enum_info *info); |
| 198 | |
| 199 | /** @brief Create an entry of BIOS Attribute Table (type: enum) and check the |
| 200 | * validity of the parameters |
| 201 | * @param[out] entry - Pointer to a buffer to create an entry |
| 202 | * @param[in] entry_length - Length of the buffer to create an entry |
| 203 | * @param[in] info - Pointer to an auxiliary structure @ref |
| 204 | * pldm_bios_table_attr_entry_enum_info |
| 205 | * @return pldm_completion_codes |
| 206 | */ |
| 207 | int pldm_bios_table_attr_entry_enum_encode_check( |
| 208 | void *entry, size_t entry_length, |
| 209 | const struct pldm_bios_table_attr_entry_enum_info *info); |
| 210 | |
John Wang | 0270040 | 2019-10-06 16:34:29 +0800 | [diff] [blame] | 211 | /** @brief Get the total number of possible values for the entry |
| 212 | * @param[in] entry - Pointer to bios attribute table entry |
| 213 | * @return total number of possible values |
| 214 | */ |
| 215 | uint8_t pldm_bios_table_attr_entry_enum_decode_pv_num( |
| 216 | const struct pldm_bios_attr_table_entry *entry); |
| 217 | |
| 218 | /** @brief Get the total number of possible values for the entry and check the |
| 219 | * validity of the parameters |
| 220 | * @param[in] entry - Pointer to bios attribute table entry |
| 221 | * @param[out] pv_num - Pointer to total number of possible values |
| 222 | * @return pldm_completion_codes |
| 223 | */ |
| 224 | int pldm_bios_table_attr_entry_enum_decode_pv_num_check( |
| 225 | const struct pldm_bios_attr_table_entry *entry, uint8_t *pv_num); |
| 226 | |
| 227 | /** @brief Get the total number of default values for the entry |
| 228 | * @param[in] entry - Pointer to bios attribute table entry |
| 229 | * @return total number of default values |
| 230 | */ |
| 231 | uint8_t pldm_bios_table_attr_entry_enum_decode_def_num( |
| 232 | const struct pldm_bios_attr_table_entry *entry); |
| 233 | |
| 234 | /** @brief Get the total number of default values for the entry and check the |
| 235 | * validity of the parameters |
| 236 | * @param[in] entry - Pointer to bios attribute table entry |
| 237 | * @param[out] def_num - Pointer to total number of default values |
| 238 | * @return pldm_completion_codes |
| 239 | */ |
| 240 | int pldm_bios_table_attr_entry_enum_decode_def_num_check( |
| 241 | const struct pldm_bios_attr_table_entry *entry, uint8_t *def_num); |
| 242 | |
John Wang | 3ad2175 | 2019-10-06 16:42:21 +0800 | [diff] [blame] | 243 | /** @brief Get possible values string handles |
| 244 | * @param[in] entry - Pointer to bios attribute table entry |
| 245 | * @param[out] pv_hdls - Pointer to a buffer to stroe |
| 246 | * PossibleValuesStringHandles |
| 247 | * @param[in] pv_num - Number of PossibleValuesStringHandles expected |
| 248 | * @return pldm_completion_codes |
| 249 | */ |
| 250 | uint8_t pldm_bios_table_attr_entry_enum_decode_pv_hdls( |
| 251 | const struct pldm_bios_attr_table_entry *entry, uint16_t *pv_hdls, |
| 252 | uint8_t pv_num); |
| 253 | |
| 254 | /** @brief Get possible values string handles and check the validity of the |
| 255 | * parameters |
| 256 | * @param[in] entry - Pointer to bios attribute table entry |
| 257 | * @param[out] pv_hdls - Pointer to a buffer to stroe |
| 258 | * PossibleValuesStringHandles |
| 259 | * @param[in] pv_num - Number of PossibleValuesStringHandles the buffer can |
| 260 | * stroe |
| 261 | * @return Number of PossibleValuesStringHandles decoded |
| 262 | */ |
| 263 | int pldm_bios_table_attr_entry_enum_decode_pv_hdls_check( |
| 264 | const struct pldm_bios_attr_table_entry *entry, uint16_t *pv_hdls, |
| 265 | uint8_t pv_num); |
| 266 | |
John Wang | ccc0455 | 2019-10-14 14:28:25 +0800 | [diff] [blame] | 267 | /** @struct pldm_bios_table_attr_entry_string_info |
| 268 | * |
| 269 | * An auxiliary structure for passing parameters to @ref |
| 270 | * pldm_bios_table_attr_entry_string_encode |
| 271 | * |
| 272 | */ |
| 273 | struct pldm_bios_table_attr_entry_string_info { |
| 274 | uint16_t name_handle; //!< attribute name handle |
| 275 | bool read_only; //!< indicate whether the attribute is read-only |
| 276 | uint8_t string_type; //!< The type of the string |
| 277 | uint16_t min_length; //!< The minimum length of the string in bytes |
| 278 | uint16_t max_length; //!< The maximum length of the string in bytes |
| 279 | uint16_t def_length; //!< The length of the defaut string in bytes |
| 280 | const char *def_string; //!< The default string itself |
| 281 | }; |
| 282 | |
John Wang | 827c5de | 2019-11-07 18:27:27 +0800 | [diff] [blame] | 283 | /** @brief Check fields in @ref pldm_bios_table_attr_entry_string_info |
| 284 | * @param[in] info - Pointer to the pldm_bios_table_attr_entry_string_info |
| 285 | * @param[out] errmsg - Pointer to an errmsg stored in the statically allocated |
| 286 | * memory |
| 287 | * @return pldm_completion_codes |
| 288 | */ |
| 289 | int pldm_bios_table_attr_entry_string_info_check( |
| 290 | const struct pldm_bios_table_attr_entry_string_info *info, |
| 291 | const char **errmsg); |
| 292 | |
John Wang | ccc0455 | 2019-10-14 14:28:25 +0800 | [diff] [blame] | 293 | /** @brief Get length that an attribute entry(type: string) will take |
| 294 | * @param[in] def_str_len - Length of default string |
| 295 | * @return The length that an entry(type: string) will take |
| 296 | */ |
| 297 | size_t pldm_bios_table_attr_entry_string_encode_length(uint16_t def_str_len); |
| 298 | |
| 299 | /** @brief Create an entry of BIOS Attribute Table (type: string) |
| 300 | * @param[out] entry - Pointer to a buffer to create an entry |
| 301 | * @param[in] entry_length - Length of the buffer to create an entry |
| 302 | * @param[in] info - Pointer to an auxiliary structure @ref |
| 303 | * pldm_bios_table_attr_entry_string_info |
| 304 | */ |
| 305 | void pldm_bios_table_attr_entry_string_encode( |
| 306 | void *entry, size_t entry_length, |
| 307 | const struct pldm_bios_table_attr_entry_string_info *info); |
| 308 | |
| 309 | /** @brief Create an entry of BIOS Attribute Table (type: string) and check the |
| 310 | * validity of the parameters |
| 311 | * @param[out] entry - Pointer to a buffer to create an entry |
| 312 | * @param[in] entry_length - Length of the buffer to create an entry |
| 313 | * @param[in] info - Pointer to an auxiliary structure @ref |
| 314 | * pldm_bios_table_attr_entry_string_info |
| 315 | * @return pldm_completion_codes |
| 316 | */ |
| 317 | int pldm_bios_table_attr_entry_string_encode_check( |
| 318 | void *entry, size_t entry_length, |
| 319 | const struct pldm_bios_table_attr_entry_string_info *info); |
| 320 | |
John Wang | 0270040 | 2019-10-06 16:34:29 +0800 | [diff] [blame] | 321 | /** @brief Get the length of default string in bytes for the entry |
| 322 | * @param[in] entry - Pointer to bios attribute table entry |
| 323 | * @return length of default string in bytes |
| 324 | */ |
| 325 | uint16_t pldm_bios_table_attr_entry_string_decode_def_string_length( |
| 326 | const struct pldm_bios_attr_table_entry *entry); |
| 327 | |
| 328 | /** @brief Get the length of default string in bytes for the entry and check the |
| 329 | * validity of the parameters |
| 330 | * @param[in] entry - Pointer to bios attribute table entry |
| 331 | * @param[out] def_string_length Pointer to length of default string in bytes |
| 332 | * @return pldm_completion_codes |
| 333 | */ |
| 334 | int pldm_bios_table_attr_entry_string_decode_def_string_length_check( |
| 335 | const struct pldm_bios_attr_table_entry *entry, |
| 336 | uint16_t *def_string_length); |
| 337 | |
John Wang | ca23082 | 2019-10-16 11:39:27 +0800 | [diff] [blame] | 338 | /** @struct pldm_bios_table_attr_entry_integer_info |
| 339 | * |
| 340 | * An auxiliary structure for passing parameters to @ref |
| 341 | * pldm_bios_table_attr_entry_integer_encode |
| 342 | * |
| 343 | */ |
| 344 | struct pldm_bios_table_attr_entry_integer_info { |
| 345 | uint16_t name_handle; //!< attribute name handle |
| 346 | bool read_only; //!< indicate whether the attribute is read-only |
| 347 | uint64_t lower_bound; //!< The lower bound on the integer value |
| 348 | uint64_t upper_bound; //!< The upper bound on the integer value |
| 349 | uint32_t scalar_increment; //!< The scalar value that is used for the |
| 350 | //!< increments to this integer |
| 351 | uint64_t default_value; //!< The default value of the integer |
| 352 | }; |
| 353 | |
John Wang | 827c5de | 2019-11-07 18:27:27 +0800 | [diff] [blame] | 354 | /** @brief Check fields in @ref pldm_bios_table_attr_entry_integer_info |
| 355 | * @param[in] info - Pointer to the pldm_bios_table_attr_entry_integer_info |
| 356 | * @param[out] errmsg - Pointer to an errmsg stored in the statically allocated |
| 357 | * memory |
| 358 | * @return pldm_completion_codes |
| 359 | */ |
| 360 | int pldm_bios_table_attr_entry_integer_info_check( |
| 361 | const struct pldm_bios_table_attr_entry_integer_info *info, |
| 362 | const char **errmsg); |
| 363 | |
John Wang | ca23082 | 2019-10-16 11:39:27 +0800 | [diff] [blame] | 364 | /** @brief Get length that an attribute entry(type: integer) will take |
| 365 | * @return The length that an entry(type: integer) will take |
| 366 | */ |
| 367 | size_t pldm_bios_table_attr_entry_integer_encode_length(); |
| 368 | |
| 369 | /** @brief Create an entry of BIOS Attribute Table (type: integer) |
| 370 | * @param[out] entry - Pointer to a buffer to create an entry |
| 371 | * @param[in] entry_length - Length of the buffer to create an entry |
| 372 | * @param[in] info - Pointer to an auxiliary structure @ref |
| 373 | * pldm_bios_table_attr_entry_integer_info |
| 374 | */ |
| 375 | void pldm_bios_table_attr_entry_integer_encode( |
| 376 | void *entry, size_t entry_length, |
| 377 | const struct pldm_bios_table_attr_entry_integer_info *info); |
| 378 | |
| 379 | /** @brief Create an entry of BIOS Attribute Table (type: integer) and check the |
| 380 | * validity of the parameters |
| 381 | * @param[out] entry - Pointer to a buffer to create an entry |
| 382 | * @param[in] entry_length - Length of the buffer to create an entry |
| 383 | * @param[in] info - Pointer to an auxiliary structure @ref |
| 384 | * pldm_bios_table_attr_entry_integer_info |
| 385 | * @return pldm_completion_codes |
| 386 | */ |
| 387 | int pldm_bios_table_attr_entry_integer_encode_check( |
| 388 | void *entry, size_t entry_length, |
| 389 | const struct pldm_bios_table_attr_entry_integer_info *info); |
| 390 | |
John Wang | 3ad2175 | 2019-10-06 16:42:21 +0800 | [diff] [blame] | 391 | /** @brief Get length that an attribute value entry(type: enum) will take |
| 392 | * @param[in] count - Total number of current values for this enumeration |
| 393 | * @return The length that an entry(type: enum) will take |
| 394 | */ |
| 395 | size_t pldm_bios_table_attr_value_entry_encode_enum_length(uint8_t count); |
| 396 | |
| 397 | /** @brief Create an attribute value entry(type: enum) |
| 398 | * @param[out] entry - Pointer to bios attribute value entry |
| 399 | * @param[in] entry_length - Length of attribute value entry |
| 400 | * @param[in] attr_handle - This handle points to an attribute in the |
| 401 | * BIOS Attribute Vlaue Table. |
| 402 | * @param[in] attr_type - Type of this attribute in the BIOS Attribute Value |
| 403 | * Table |
| 404 | * @param[in] count - Total number of current values for this enum attribute |
| 405 | * @param[in] handle_indexes - Index into the array(provided in the BIOS |
| 406 | * Attribute Table) of the possible values of string handles for this attribute. |
| 407 | */ |
| 408 | void pldm_bios_table_attr_value_entry_encode_enum( |
| 409 | void *entry, size_t entry_length, uint16_t attr_handle, uint8_t attr_type, |
| 410 | uint8_t count, uint8_t *handle_indexes); |
| 411 | |
John Wang | 49484a1 | 2019-12-02 14:21:53 +0800 | [diff] [blame] | 412 | /** @brief Get number of current values for the enum entry |
| 413 | * @param[in] entry - Pointer to bios attribute value table entry |
| 414 | * @return Total number of current values for this enumeration |
| 415 | */ |
| 416 | uint8_t pldm_bios_table_attr_value_entry_enum_decode_number( |
| 417 | const struct pldm_bios_attr_val_table_entry *entry); |
| 418 | |
John Wang | 3ad2175 | 2019-10-06 16:42:21 +0800 | [diff] [blame] | 419 | /** @brief Create an attribute value entry(type: enum) and check the validity of |
| 420 | * the parameters |
| 421 | * @param[out] entry - Pointer to bios attribute value entry |
| 422 | * @param[in] entry_length - Length of attribute value entry |
| 423 | * @param[in] attr_handle - This handle points to an attribute in the |
| 424 | * BIOS Attribute Vlaue Table. |
| 425 | * @param[in] attr_type - Type of this attribute in the BIOS Attribute Value |
| 426 | * Table |
| 427 | * @param[in] count - Total number of current values for this enum attribute |
| 428 | * @param[in] handle_indexes - Index into the array(provided in the BIOS |
| 429 | * Attribute Table) of the possible values of string handles for this attribute. |
| 430 | * @return pldm_completion_codes |
| 431 | */ |
| 432 | int pldm_bios_table_attr_value_entry_encode_enum_check( |
| 433 | void *entry, size_t entry_length, uint16_t attr_handle, uint8_t attr_type, |
| 434 | uint8_t count, uint8_t *handle_indexes); |
| 435 | |
| 436 | /** @brief Get length that an attribute value entry(type: string) will take |
| 437 | * @param[in] string_length - Length of the current string in byte, 0 indicates |
| 438 | * that the current string value is not set. |
| 439 | * @return The length that an entry(type: string) will take |
| 440 | */ |
| 441 | size_t |
| 442 | pldm_bios_table_attr_value_entry_encode_string_length(uint16_t string_length); |
| 443 | |
| 444 | /** @brief Create an attribute value entry(type: string) |
| 445 | * @param[out] entry - Pointer to bios attribute value entry |
| 446 | * @param[in] entry_length - Length of attribute value entry |
| 447 | * @param[in] attr_handle - This handle points to an attribute in the |
| 448 | * BIOS Attribute Vlaue Table. |
| 449 | * @param[in] attr_type - Type of this attribute in the BIOS Attribute Value |
| 450 | * Table |
| 451 | * @param[in] string_length - Length of current string in bytes. 0 indicates |
| 452 | * that the current string value is not set. |
| 453 | * @param[in] string - The current string itsel |
| 454 | */ |
| 455 | void pldm_bios_table_attr_value_entry_encode_string( |
| 456 | void *entry, size_t entry_length, uint16_t attr_handle, uint8_t attr_type, |
| 457 | uint16_t string_length, const char *string); |
John Wang | 49484a1 | 2019-12-02 14:21:53 +0800 | [diff] [blame] | 458 | |
| 459 | /** @brief Get length of the current string in bytes |
| 460 | * @param [in] entry - Pointer to bios attribute value table entry |
| 461 | * @return The length of the current string in bytes |
| 462 | */ |
| 463 | uint16_t pldm_bios_table_attr_value_entry_string_decode_length( |
| 464 | const struct pldm_bios_attr_val_table_entry *entry); |
| 465 | |
John Wang | 3ad2175 | 2019-10-06 16:42:21 +0800 | [diff] [blame] | 466 | /** @brief Create an attribute value entry(type: string) and check the validity |
| 467 | * of the parameters |
| 468 | * @param[out] entry - Pointer to bios attribute value entry |
| 469 | * @param[in] entry_length - Length of attribute value entry |
| 470 | * @param[in] attr_handle - This handle points to an attribute in the |
| 471 | * BIOS Attribute Vlaue Table. |
| 472 | * @param[in] attr_type - Type of this attribute in the BIOS Attribute Value |
| 473 | * Table |
| 474 | * @param[in] string_length - Length of current string in bytes. 0 indicates |
| 475 | * that the current string value is not set. |
| 476 | * @param[in] string - The current string itsel |
| 477 | * @return pldm_completion_codes |
| 478 | */ |
| 479 | int pldm_bios_table_attr_value_entry_encode_string_check( |
| 480 | void *entry, size_t entry_length, uint16_t attr_handle, uint8_t attr_type, |
| 481 | uint16_t string_length, const char *string); |
| 482 | |
John Wang | ca23082 | 2019-10-16 11:39:27 +0800 | [diff] [blame] | 483 | /** @brief Get length that an attribute value entry(type: integer) will take |
| 484 | * @return The length that an entry(type: integer) will take |
| 485 | */ |
| 486 | size_t pldm_bios_table_attr_value_entry_encode_integer_length(); |
| 487 | |
| 488 | /** @brief Create an attribute value entry(type: integer) |
| 489 | * @param[out] entry - Pointer to bios attribute value entry |
| 490 | * @param[in] entry_length - Length of attribute value entry |
| 491 | * @param[in] attr_handle - This handle points to an attribute in the |
| 492 | * BIOS Attribute Vlaue Table. |
| 493 | * @param[in] attr_type - Type of this attribute in the BIOS Attribute Value |
| 494 | * Table |
| 495 | * @param[in] cv - Current Value |
| 496 | */ |
| 497 | void pldm_bios_table_attr_value_entry_encode_integer(void *entry, |
| 498 | size_t entry_length, |
| 499 | uint16_t attr_handle, |
| 500 | uint8_t attr_type, |
| 501 | uint64_t cv); |
| 502 | |
| 503 | /** @brief Create an attribute value entry(type: integer) and check the validity |
| 504 | * of the parameters |
| 505 | * @param[out] entry - Pointer to bios attribute value entry |
| 506 | * @param[in] entry_length - Length of attribute value entry |
| 507 | * @param[in] attr_handle - This handle points to an attribute in the |
| 508 | * BIOS Attribute Vlaue Table. |
| 509 | * @param[in] attr_type - Type of this attribute in the BIOS Attribute Value |
| 510 | * Table |
| 511 | * @param[in] cv - Current Value |
| 512 | * @return pldm_completion_codes |
| 513 | */ |
| 514 | int pldm_bios_table_attr_value_entry_encode_integer_check(void *entry, |
| 515 | size_t entry_length, |
| 516 | uint16_t attr_handle, |
| 517 | uint8_t attr_type, |
| 518 | uint64_t cv); |
John Wang | 79c37f1 | 2019-10-31 15:46:31 +0800 | [diff] [blame] | 519 | |
| 520 | /** @brief Get the size of pad and checksum |
| 521 | * @param[in] size_without_pad - Table size without pad |
| 522 | * @return The size of pad and checksum |
| 523 | */ |
| 524 | size_t pldm_bios_table_pad_checksum_size(size_t size_without_pad); |
| 525 | |
| 526 | /** @brief Append pad and checksum at the end of the table |
| 527 | * @param[in,out] table - Pointer to a buffer of a bios table |
| 528 | * @param[in] size - Size of the buffer of a bios table |
| 529 | * @param[in] size_without_pad - Table size without pad and checksum |
| 530 | */ |
| 531 | void pldm_bios_table_append_pad_checksum(void *table, size_t size, |
| 532 | size_t size_without_pad); |
| 533 | |
John Wang | 0270040 | 2019-10-06 16:34:29 +0800 | [diff] [blame] | 534 | #ifdef __cplusplus |
| 535 | } |
| 536 | #endif |
| 537 | |
| 538 | #endif |