Andrew Jeffery | 4edb708 | 2023-04-05 19:09:52 +0930 | [diff] [blame] | 1 | #ifndef LIBPLDM_BIOS_TABLE_H |
| 2 | #define LIBPLDM_BIOS_TABLE_H |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 3 | |
| 4 | #ifdef __cplusplus |
| 5 | extern "C" { |
| 6 | #endif |
| 7 | |
| 8 | #include "bios.h" |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 9 | #include <stdbool.h> |
| 10 | #include <stddef.h> |
| 11 | #include <stdint.h> |
Manojkiran Eda | 9a8e497 | 2022-11-28 16:38:21 +0530 | [diff] [blame] | 12 | struct variable_field; |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 13 | |
| 14 | /** @struct pldm_bios_table_iter |
| 15 | * structure representing bios table iterator |
| 16 | */ |
| 17 | struct pldm_bios_table_iter; |
| 18 | |
| 19 | /** @brief Create a bios table iterator |
| 20 | * @param[in] table - Pointer to table data |
| 21 | * @param[in] length - Length of table data |
| 22 | * @param[in] type - Type of pldm bios table |
| 23 | * @return Iterator to the beginning |
| 24 | */ |
| 25 | struct pldm_bios_table_iter * |
| 26 | pldm_bios_table_iter_create(const void *table, size_t length, |
| 27 | enum pldm_bios_table_types type); |
| 28 | |
| 29 | /** @brief Release a bios table iterator |
| 30 | * @param[in] iter - Pointer to bios table iterator |
| 31 | */ |
| 32 | void pldm_bios_table_iter_free(struct pldm_bios_table_iter *iter); |
| 33 | |
| 34 | /** @brief Check if the iterator reaches the end of the bios table |
| 35 | * @param[in] iter - Pointer to the bios table iterator |
| 36 | * @return true if iterator reaches the end |
| 37 | * @note *end* is a position after the last entry. |
| 38 | */ |
| 39 | bool pldm_bios_table_iter_is_end(const struct pldm_bios_table_iter *iter); |
| 40 | |
| 41 | /** @brief Get iterator to next entry |
| 42 | * @param[in] iter - Pointer the bios table iterator |
| 43 | */ |
| 44 | void pldm_bios_table_iter_next(struct pldm_bios_table_iter *iter); |
| 45 | |
| 46 | /** @brief Get the bios table entry that the iterator points to |
| 47 | * @param[in] iter - Pointer to the bios table iterator |
| 48 | * @return Pointer to an entry in bios table |
| 49 | */ |
| 50 | const void *pldm_bios_table_iter_value(struct pldm_bios_table_iter *iter); |
| 51 | |
| 52 | /** @brief Get the bios attribute table entry that the iterator points to |
| 53 | * @param[in] iter - Pointer the bios attribute table iterator |
| 54 | * @return Pointer to an entry in bios attribute table |
| 55 | */ |
| 56 | static inline const struct pldm_bios_attr_table_entry * |
| 57 | pldm_bios_table_iter_attr_entry_value(struct pldm_bios_table_iter *iter) |
| 58 | { |
| 59 | return (const struct pldm_bios_attr_table_entry *) |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 60 | pldm_bios_table_iter_value(iter); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | /** @brief Get the bios string table entry that the iterator ponit to |
| 64 | * @param[in] iter - Pointer the bios string table iterator |
| 65 | * @return Pointer to an entry in bios string table |
| 66 | */ |
| 67 | static inline const struct pldm_bios_string_table_entry * |
| 68 | pldm_bios_table_iter_string_entry_value(struct pldm_bios_table_iter *iter) |
| 69 | { |
| 70 | return (const struct pldm_bios_string_table_entry *) |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 71 | pldm_bios_table_iter_value(iter); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | /** @brief Get the bios attribute value table entry that the iterator ponit to |
| 75 | * @param[in] iter - Pointer the bios attribute value table iterator |
| 76 | * @return Pointer to an entry in bios attribute value table |
| 77 | */ |
| 78 | static inline const struct pldm_bios_attr_val_table_entry * |
| 79 | pldm_bios_table_iter_attr_value_entry_value(struct pldm_bios_table_iter *iter) |
| 80 | { |
| 81 | return (const struct pldm_bios_attr_val_table_entry *) |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 82 | pldm_bios_table_iter_value(iter); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | /** @brief Get the length of an entry in the BIOS String Table |
| 86 | * @param[in] string_length - Length of string |
| 87 | * @return Length of an entry in bytes |
| 88 | */ |
| 89 | size_t pldm_bios_table_string_entry_encode_length(uint16_t string_length); |
| 90 | |
| 91 | /** @brief Create an entry of BIOS String Table |
| 92 | * @param[out] entry - Pointer to a buffer to create an entry |
| 93 | * @param[in] entry_length - Length of the buffer to create an entry |
| 94 | * @param[in] str - String itself |
| 95 | * @param[in] str_length - Length of the string |
| 96 | */ |
| 97 | void pldm_bios_table_string_entry_encode(void *entry, size_t entry_length, |
| 98 | const char *str, uint16_t str_length); |
| 99 | |
| 100 | /** @brief Create an entry of BIOS String Table and check the validity of the |
| 101 | * parameters |
Andrew Jeffery | 91f4b54 | 2023-06-13 20:59:51 +0930 | [diff] [blame] | 102 | * |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 103 | * @param[out] entry - Pointer to a buffer to create an entry |
| 104 | * @param[in] entry_length - Length of the buffer to create an entry |
| 105 | * @param[in] str - String itself |
| 106 | * @param[in] str_length - Length of the string |
Andrew Jeffery | 91f4b54 | 2023-06-13 20:59:51 +0930 | [diff] [blame] | 107 | * @return PLDM_SUCCESS on success, PLDM_ERROR_INVALID_DATA if entry or str are NULL, or |
| 108 | * PLDM_ERROR_INVALID_LENGTH if entry_length is insufficient for encoding str. An |
| 109 | * appropriate value for entry_length can be determined using |
| 110 | * @ref pldm_bios_table_string_entry_encode_length |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 111 | */ |
| 112 | int pldm_bios_table_string_entry_encode_check(void *entry, size_t entry_length, |
| 113 | const char *str, |
| 114 | uint16_t str_length); |
| 115 | |
| 116 | /** @brief Get the string handle for the entry |
| 117 | * @param[in] entry - Pointer to a bios string table entry |
| 118 | * @return Handle to identify a string in the bios string table |
| 119 | */ |
| 120 | uint16_t pldm_bios_table_string_entry_decode_handle( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 121 | const struct pldm_bios_string_table_entry *entry); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 122 | |
| 123 | /** @brief Get the string length for the entry |
| 124 | * @param[in] entry - Pointer to a bios string table entry |
| 125 | * @return Length of string in bytes |
| 126 | */ |
| 127 | uint16_t pldm_bios_table_string_entry_decode_string_length( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 128 | const struct pldm_bios_string_table_entry *entry); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 129 | |
| 130 | /** @brief Get the string(at most one less than *size* characters) from the |
| 131 | * entry |
| 132 | * @param[in] entry - Pointer to a bios string table entry |
| 133 | * @param[out] buffer - Pointer to a buffer to store the string |
| 134 | * @param[in] size - Size of the buffer to store the string |
| 135 | * @return Length of the string decoded |
| 136 | */ |
| 137 | uint16_t pldm_bios_table_string_entry_decode_string( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 138 | const struct pldm_bios_string_table_entry *entry, char *buffer, |
| 139 | size_t size); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 140 | |
| 141 | /** @brief Get the string from the entry and check the validity of the |
| 142 | * parameters |
| 143 | * @param[in] entry - Pointer to a bios string table entry |
| 144 | * @param[out] buffer - Pointer to a buffer to store the string |
| 145 | * @param[in] size - Size of the buffer to store the string |
Andrew Jeffery | 2325031 | 2023-06-13 21:07:46 +0930 | [diff] [blame] | 146 | * @return PLDM_SUCCESS on success, PLDM_ERROR_INVALID_DATA if entry or buffer are NULL, or |
| 147 | * PLDM_ERROR_INVALID_LENGTH if size is insufficient for the decoded string. An |
| 148 | * appropriate value for size can be determined using the expression |
| 149 | * `pldm_bios_table_string_entry_decode_string_length(entry) + 1`. |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 150 | */ |
| 151 | int pldm_bios_table_string_entry_decode_string_check( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 152 | const struct pldm_bios_string_table_entry *entry, char *buffer, |
| 153 | size_t size); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 154 | |
| 155 | /** @brief Find an entry in bios string table by string |
| 156 | * @param[in] table - The BIOS String Table |
| 157 | * @param[in] length - Length of the BIOS String Table |
| 158 | * @param[in] str - String itself |
| 159 | * @return Pointer to an entry in the bios string table |
| 160 | */ |
| 161 | const struct pldm_bios_string_table_entry * |
| 162 | pldm_bios_table_string_find_by_string(const void *table, size_t length, |
| 163 | const char *str); |
| 164 | /** @brief Find an entry in bios string table by handle |
| 165 | * @param[in] table - The BIOS String Table |
| 166 | * @param[in] length - Length of the BIOS String Table |
| 167 | * @param[in] handle - Handle to identify a string in the bios string table |
| 168 | * @return Pointer to an entry in the bios string table |
| 169 | */ |
| 170 | const struct pldm_bios_string_table_entry * |
| 171 | pldm_bios_table_string_find_by_handle(const void *table, size_t length, |
| 172 | uint16_t handle); |
| 173 | |
| 174 | /** @brief Get the attribute handle from the attribute table entry |
| 175 | * @param[in] entry - Pointer to bios attribute table entry |
| 176 | * @return handle to identify the attribute in the attribute table |
| 177 | */ |
| 178 | uint16_t pldm_bios_table_attr_entry_decode_attribute_handle( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 179 | const struct pldm_bios_attr_table_entry *entry); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 180 | |
| 181 | /** @brief Get the attribute type of the attribute table entry |
| 182 | * @param[in] entry - Pointer to bios attribute table entry |
| 183 | * @return Type of the attribute table entry |
| 184 | */ |
| 185 | uint8_t pldm_bios_table_attr_entry_decode_attribute_type( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 186 | const struct pldm_bios_attr_table_entry *entry); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 187 | |
| 188 | /** @brief Get the attribute name handle from the attribute table entry |
| 189 | * @param[in] entry - Pointer to bios attribute table entry |
| 190 | * @return handle to identify the name of the attribute, this handle points |
| 191 | * to a string in the bios string table. |
| 192 | */ |
| 193 | uint16_t pldm_bios_table_attr_entry_decode_string_handle( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 194 | const struct pldm_bios_attr_table_entry *entry); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 195 | |
| 196 | /** @brief Find an entry in attribute table by handle |
| 197 | * @param[in] table - The BIOS Attribute Table |
| 198 | * @param[in] length - Length of the BIOS Attribute Table |
| 199 | * @param[in] handle - handle to identify the attribute in the attribute table |
| 200 | * @return Pointer to the entry |
| 201 | */ |
| 202 | const struct pldm_bios_attr_table_entry * |
| 203 | pldm_bios_table_attr_find_by_handle(const void *table, size_t length, |
| 204 | uint16_t handle); |
| 205 | |
| 206 | /** @brief Find an entry in attribute table by string handle |
| 207 | * @param[in] table - The BIOS Attribute Table |
| 208 | * @param[in] length - Length of the BIOS Attribute Table |
| 209 | * @param[in] handle - The string handle |
| 210 | * @return Pointer to the entry |
| 211 | */ |
| 212 | const struct pldm_bios_attr_table_entry * |
| 213 | pldm_bios_table_attr_find_by_string_handle(const void *table, size_t length, |
| 214 | uint16_t handle); |
| 215 | |
| 216 | /** @struct pldm_bios_table_attr_entry_enum_info |
| 217 | * |
| 218 | * An auxiliary structure for passing parameters to @ref |
| 219 | * pldm_bios_table_attr_entry_enum_encode |
| 220 | * |
| 221 | */ |
| 222 | struct pldm_bios_table_attr_entry_enum_info { |
| 223 | uint16_t name_handle; //!< attribute name handle |
| 224 | bool read_only; //!< indicate whether the attribute is read-only |
| 225 | uint8_t pv_num; //!< number of possible values |
| 226 | const uint16_t *pv_handle; //!< handles of possible values |
| 227 | uint8_t def_num; //!< nnumber of default values |
| 228 | const uint8_t *def_index; //!< indices of default values. |
| 229 | }; |
| 230 | |
| 231 | /** @brief Get length that an attribute entry(type: enum) will take |
| 232 | * @param[in] pv_num - Number of possible values |
| 233 | * @param[in] def_num - Number of default values |
| 234 | * @return The length that an entry(type: enum) will take |
| 235 | */ |
| 236 | size_t pldm_bios_table_attr_entry_enum_encode_length(uint8_t pv_num, |
| 237 | uint8_t def_num); |
| 238 | |
| 239 | /** @brief Create an entry of BIOS Attribute Table (type: enum) |
| 240 | * @param[out] entry - Pointer to a buffer to create an entry |
| 241 | * @param[in] entry_length - Length of the buffer to create an entry |
| 242 | * @param[in] info - Pointer to an auxiliary structure @ref |
| 243 | * pldm_bios_table_attr_entry_enum_info |
| 244 | */ |
| 245 | void pldm_bios_table_attr_entry_enum_encode( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 246 | void *entry, size_t entry_length, |
| 247 | const struct pldm_bios_table_attr_entry_enum_info *info); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 248 | |
| 249 | /** @brief Create an entry of BIOS Attribute Table (type: enum) and check the |
| 250 | * validity of the parameters |
| 251 | * @param[out] entry - Pointer to a buffer to create an entry |
| 252 | * @param[in] entry_length - Length of the buffer to create an entry |
| 253 | * @param[in] info - Pointer to an auxiliary structure @ref |
| 254 | * pldm_bios_table_attr_entry_enum_info |
| 255 | * @return pldm_completion_codes |
| 256 | */ |
| 257 | int pldm_bios_table_attr_entry_enum_encode_check( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 258 | void *entry, size_t entry_length, |
| 259 | const struct pldm_bios_table_attr_entry_enum_info *info); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 260 | |
| 261 | /** @brief Get the total number of possible values for the entry |
| 262 | * @param[in] entry - Pointer to bios attribute table entry |
| 263 | * @return total number of possible values |
| 264 | */ |
| 265 | uint8_t pldm_bios_table_attr_entry_enum_decode_pv_num( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 266 | const struct pldm_bios_attr_table_entry *entry); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 267 | |
| 268 | /** @brief Get the total number of possible values for the entry and check the |
| 269 | * validity of the parameters |
| 270 | * @param[in] entry - Pointer to bios attribute table entry |
| 271 | * @param[out] pv_num - Pointer to total number of possible values |
Andrew Jeffery | 4f7ebda | 2023-06-13 21:49:38 +0930 | [diff] [blame] | 272 | * @return PLDM_SUCCESS on success, PLDM_ERROR_INVALID_DATA if entry or pv_num are NULL, or |
| 273 | * PLDM_ERROR_INVALID_DATA if entry is not a valid PLDM_BIOS_ENUMERATION |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 274 | */ |
| 275 | int pldm_bios_table_attr_entry_enum_decode_pv_num_check( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 276 | const struct pldm_bios_attr_table_entry *entry, uint8_t *pv_num); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 277 | |
| 278 | /** @brief Get the total number of default values for the entry |
| 279 | * @param[in] entry - Pointer to bios attribute table entry |
| 280 | * @return total number of default values |
| 281 | */ |
| 282 | uint8_t pldm_bios_table_attr_entry_enum_decode_def_num( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 283 | const struct pldm_bios_attr_table_entry *entry); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 284 | |
| 285 | /** @brief Get the total number of default values for the entry and check the |
| 286 | * validity of the parameters |
| 287 | * @param[in] entry - Pointer to bios attribute table entry |
| 288 | * @param[out] def_num - Pointer to total number of default values |
Andrew Jeffery | 437a83a | 2023-06-13 22:36:26 +0930 | [diff] [blame] | 289 | * @return PLDM_SUCCESS on success, otherwise PLDM_ERROR_INVALID_DATA if entry or def_num are NULL, |
| 290 | * or entry is not of type PLDM_BIOS_ENUMERATION. |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 291 | */ |
| 292 | int pldm_bios_table_attr_entry_enum_decode_def_num_check( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 293 | const struct pldm_bios_attr_table_entry *entry, uint8_t *def_num); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 294 | |
| 295 | /** @brief Get possible values string handles |
| 296 | * @param[in] entry - Pointer to bios attribute table entry |
Andrew Jeffery | 2ebec8d | 2023-06-13 22:16:08 +0930 | [diff] [blame] | 297 | * @param[out] pv_hdls - Pointer to a buffer to store |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 298 | * PossibleValuesStringHandles |
| 299 | * @param[in] pv_num - Number of PossibleValuesStringHandles expected |
| 300 | * @return pldm_completion_codes |
| 301 | */ |
| 302 | uint8_t pldm_bios_table_attr_entry_enum_decode_pv_hdls( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 303 | const struct pldm_bios_attr_table_entry *entry, uint16_t *pv_hdls, |
| 304 | uint8_t pv_num); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 305 | |
| 306 | /** @brief Get possible values string handles and check the validity of the |
| 307 | * parameters |
| 308 | * @param[in] entry - Pointer to bios attribute table entry |
Andrew Jeffery | 2ebec8d | 2023-06-13 22:16:08 +0930 | [diff] [blame] | 309 | * @param[out] pv_hdls - Pointer to a buffer to store |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 310 | * PossibleValuesStringHandles |
| 311 | * @param[in] pv_num - Number of PossibleValuesStringHandles the buffer can |
Andrew Jeffery | 2ebec8d | 2023-06-13 22:16:08 +0930 | [diff] [blame] | 312 | * store |
Andrew Jeffery | f3d851f | 2023-06-13 22:24:48 +0930 | [diff] [blame] | 313 | * @return PLDM_SUCCESS on success, otherwise PLDM_ERROR_INVALID_DATA if entry or pv_hdls are NULL, |
| 314 | * or entry is not of type PLDM_BIOS_ENUMERATION, or the number of possible values is not |
| 315 | * equal to pv_num. An appropriate value for pv_num can be determined using @ref |
| 316 | * pldm_bios_table_attr_entry_enum_decode_pv_num_check |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 317 | */ |
| 318 | int pldm_bios_table_attr_entry_enum_decode_pv_hdls_check( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 319 | const struct pldm_bios_attr_table_entry *entry, uint16_t *pv_hdls, |
| 320 | uint8_t pv_num); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 321 | |
| 322 | /** @brief Get Indices of default values |
| 323 | * @param[in] entry - Pointer to bios attribute table entry |
| 324 | * @param[out] def_indices - Pointer to a buffer to store |
| 325 | * default value indices |
| 326 | * @param[in] def_num - Number of DefaultValues the buffer can |
| 327 | * store |
| 328 | * @return Number of default values decoded |
| 329 | */ |
| 330 | uint8_t pldm_bios_table_attr_entry_enum_decode_def_indices( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 331 | const struct pldm_bios_attr_table_entry *entry, uint8_t *def_indices, |
| 332 | uint8_t def_num); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 333 | |
| 334 | /** @struct pldm_bios_table_attr_entry_string_info |
| 335 | * |
| 336 | * An auxiliary structure for passing parameters to @ref |
| 337 | * pldm_bios_table_attr_entry_string_encode |
| 338 | * |
| 339 | */ |
| 340 | struct pldm_bios_table_attr_entry_string_info { |
| 341 | uint16_t name_handle; //!< attribute name handle |
| 342 | bool read_only; //!< indicate whether the attribute is read-only |
| 343 | uint8_t string_type; //!< The type of the string |
| 344 | uint16_t min_length; //!< The minimum length of the string in bytes |
| 345 | uint16_t max_length; //!< The maximum length of the string in bytes |
| 346 | uint16_t def_length; //!< The length of the defaut string in bytes |
| 347 | const char *def_string; //!< The default string itself |
| 348 | }; |
| 349 | |
| 350 | /** @brief Check fields in @ref pldm_bios_table_attr_entry_string_info |
| 351 | * @param[in] info - Pointer to the pldm_bios_table_attr_entry_string_info |
| 352 | * @param[out] errmsg - Pointer to an errmsg stored in the statically allocated |
| 353 | * memory |
| 354 | * @return pldm_completion_codes |
| 355 | */ |
| 356 | int pldm_bios_table_attr_entry_string_info_check( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 357 | const struct pldm_bios_table_attr_entry_string_info *info, |
| 358 | const char **errmsg); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 359 | |
| 360 | /** @brief Get length that an attribute entry(type: string) will take |
| 361 | * @param[in] def_str_len - Length of default string |
| 362 | * @return The length that an entry(type: string) will take |
| 363 | */ |
| 364 | size_t pldm_bios_table_attr_entry_string_encode_length(uint16_t def_str_len); |
| 365 | |
| 366 | /** @brief Create an entry of BIOS Attribute Table (type: string) |
| 367 | * @param[out] entry - Pointer to a buffer to create an entry |
| 368 | * @param[in] entry_length - Length of the buffer to create an entry |
| 369 | * @param[in] info - Pointer to an auxiliary structure @ref |
| 370 | * pldm_bios_table_attr_entry_string_info |
| 371 | */ |
| 372 | void pldm_bios_table_attr_entry_string_encode( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 373 | void *entry, size_t entry_length, |
| 374 | const struct pldm_bios_table_attr_entry_string_info *info); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 375 | |
| 376 | /** @brief Create an entry of BIOS Attribute Table (type: string) and check the |
| 377 | * validity of the parameters |
| 378 | * @param[out] entry - Pointer to a buffer to create an entry |
| 379 | * @param[in] entry_length - Length of the buffer to create an entry |
| 380 | * @param[in] info - Pointer to an auxiliary structure @ref |
| 381 | * pldm_bios_table_attr_entry_string_info |
Andrew Jeffery | a5c3287 | 2023-06-13 21:34:26 +0930 | [diff] [blame] | 382 | * @return PLDM_SUCCESS on success, PLDM_ERROR_INVALID_DATA if entry or info are NULL or info |
| 383 | * contains logically inconsistent data, or PLDM_ERROR_INVALID_LENGTH if entry_length is |
| 384 | * not sufficient to encode info. An appropriate value for entry_length can be determined |
| 385 | * using @ref pldm_bios_table_attr_entry_string_encode_length |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 386 | */ |
| 387 | int pldm_bios_table_attr_entry_string_encode_check( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 388 | void *entry, size_t entry_length, |
| 389 | const struct pldm_bios_table_attr_entry_string_info *info); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 390 | |
| 391 | /** @brief Get the length of default string in bytes for the entry |
| 392 | * @param[in] entry - Pointer to bios attribute table entry |
| 393 | * @return length of default string in bytes |
| 394 | */ |
| 395 | uint16_t pldm_bios_table_attr_entry_string_decode_def_string_length( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 396 | const struct pldm_bios_attr_table_entry *entry); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 397 | |
| 398 | /** @brief Get the length of default string in bytes for the entry and check the |
| 399 | * validity of the parameters |
| 400 | * @param[in] entry - Pointer to bios attribute table entry |
| 401 | * @param[out] def_string_length Pointer to length of default string in bytes |
Andrew Jeffery | b9a8769 | 2023-06-13 22:36:43 +0930 | [diff] [blame^] | 402 | * @return PLDM_SUCCESS on success, otherwise PLDM_ERROR_INVALID_DATA if entry or def_string_length |
| 403 | * are NULL, or entry is not of type PLDM_BIOS_STRING |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 404 | */ |
| 405 | int pldm_bios_table_attr_entry_string_decode_def_string_length_check( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 406 | const struct pldm_bios_attr_table_entry *entry, |
| 407 | uint16_t *def_string_length); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 408 | |
| 409 | /** @brief Get the type of string of bios attribute table entry |
| 410 | * @param[in] entry - Pointer to bios attribute table entry |
| 411 | * @return Type of the string |
| 412 | */ |
| 413 | uint8_t pldm_bios_table_attr_entry_string_decode_string_type( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 414 | const struct pldm_bios_attr_table_entry *entry); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 415 | |
| 416 | /** @brief Get maximum length of the string from a bios attribute table entry in |
| 417 | * bytes |
| 418 | * @param[in] entry - Pointer to a bios attribute table entry |
| 419 | * @return Maximum length of the string |
| 420 | */ |
| 421 | uint16_t pldm_bios_table_attr_entry_string_decode_max_length( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 422 | const struct pldm_bios_attr_table_entry *entry); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 423 | |
| 424 | /** @brief Get minimum length of the string from a bios attribute table entry in |
| 425 | * bytes |
| 426 | * @param[in] entry - Pointer to a bios attribute table entry |
| 427 | * @return Minimum length of the string |
| 428 | */ |
| 429 | uint16_t pldm_bios_table_attr_entry_string_decode_min_length( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 430 | const struct pldm_bios_attr_table_entry *entry); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 431 | |
| 432 | /** @brief Get the default string from a bios attribute table entry |
| 433 | * @param[out] buffer - Pointer to a buffer to store the string |
| 434 | * @param[in] size - Size of the buffer to store the string |
| 435 | * @return Length of the string decoded |
| 436 | */ |
| 437 | uint16_t pldm_bios_table_attr_entry_string_decode_def_string( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 438 | const struct pldm_bios_attr_table_entry *entry, char *buffer, |
| 439 | size_t size); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 440 | |
| 441 | /** @struct pldm_bios_table_attr_entry_integer_info |
| 442 | * |
| 443 | * An auxiliary structure for passing parameters to @ref |
| 444 | * pldm_bios_table_attr_entry_integer_encode |
| 445 | * |
| 446 | */ |
| 447 | struct pldm_bios_table_attr_entry_integer_info { |
| 448 | uint16_t name_handle; //!< attribute name handle |
| 449 | bool read_only; //!< indicate whether the attribute is read-only |
| 450 | uint64_t lower_bound; //!< The lower bound on the integer value |
| 451 | uint64_t upper_bound; //!< The upper bound on the integer value |
| 452 | uint32_t scalar_increment; //!< The scalar value that is used for the |
| 453 | //!< increments to this integer |
| 454 | uint64_t default_value; //!< The default value of the integer |
| 455 | }; |
| 456 | |
| 457 | /** @brief Check fields in @ref pldm_bios_table_attr_entry_integer_info |
| 458 | * @param[in] info - Pointer to the pldm_bios_table_attr_entry_integer_info |
| 459 | * @param[out] errmsg - Pointer to an errmsg stored in the statically allocated |
| 460 | * memory |
| 461 | * @return pldm_completion_codes |
| 462 | */ |
| 463 | int pldm_bios_table_attr_entry_integer_info_check( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 464 | const struct pldm_bios_table_attr_entry_integer_info *info, |
| 465 | const char **errmsg); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 466 | |
| 467 | /** @brief Get length that an attribute entry(type: integer) will take |
| 468 | * @return The length that an entry(type: integer) will take |
| 469 | */ |
Andrew Jeffery | 319304f | 2023-04-05 13:53:18 +0930 | [diff] [blame] | 470 | size_t pldm_bios_table_attr_entry_integer_encode_length(void); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 471 | |
| 472 | /** @brief Create an entry of BIOS Attribute Table (type: integer) |
| 473 | * @param[out] entry - Pointer to a buffer to create an entry |
| 474 | * @param[in] entry_length - Length of the buffer to create an entry |
| 475 | * @param[in] info - Pointer to an auxiliary structure @ref |
| 476 | * pldm_bios_table_attr_entry_integer_info |
| 477 | */ |
| 478 | void pldm_bios_table_attr_entry_integer_encode( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 479 | void *entry, size_t entry_length, |
| 480 | const struct pldm_bios_table_attr_entry_integer_info *info); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 481 | |
| 482 | /** @brief Create an entry of BIOS Attribute Table (type: integer) and check the |
| 483 | * validity of the parameters |
| 484 | * @param[out] entry - Pointer to a buffer to create an entry |
| 485 | * @param[in] entry_length - Length of the buffer to create an entry |
| 486 | * @param[in] info - Pointer to an auxiliary structure @ref |
| 487 | * pldm_bios_table_attr_entry_integer_info |
| 488 | * @return pldm_completion_codes |
| 489 | */ |
| 490 | int pldm_bios_table_attr_entry_integer_encode_check( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 491 | void *entry, size_t entry_length, |
| 492 | const struct pldm_bios_table_attr_entry_integer_info *info); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 493 | |
| 494 | /** @brief Decode the specific fields(integer) of attribute table entry |
| 495 | * @param[in] entry - Pointer to an entry of attribute table |
| 496 | * @param[out] lower - The lower bound on the integer value |
| 497 | * @param[out] upper - The upper bound on the integer value |
| 498 | * @param[out] scalar - The scalar value that is used for the increments to |
| 499 | * this integer |
| 500 | * @param[out] def - The default value of the integer |
| 501 | */ |
| 502 | void pldm_bios_table_attr_entry_integer_decode( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 503 | const struct pldm_bios_attr_table_entry *entry, uint64_t *lower, |
| 504 | uint64_t *upper, uint32_t *scalar, uint64_t *def); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 505 | |
| 506 | /** @brief Get the attribute handle from the attribute value table entry |
| 507 | * @param[in] entry - Pointer to bios attribute value table entry |
| 508 | * @return handle to identify the attribute in the attribute value table |
| 509 | */ |
| 510 | uint16_t pldm_bios_table_attr_value_entry_decode_attribute_handle( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 511 | const struct pldm_bios_attr_val_table_entry *entry); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 512 | |
| 513 | /** @brief Get the attribute type from the attribute value table entry |
| 514 | * @param[in] entry - Pointer to bios attribute value table entry |
| 515 | * @return Type of the attribute value entry |
| 516 | */ |
| 517 | uint8_t pldm_bios_table_attr_value_entry_decode_attribute_type( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 518 | const struct pldm_bios_attr_val_table_entry *entry); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 519 | |
| 520 | /** @brief Get length that an attribute value entry(type: enum) will take |
| 521 | * @param[in] count - Total number of current values for this enumeration |
| 522 | * @return The length that an entry(type: enum) will take |
| 523 | */ |
| 524 | size_t pldm_bios_table_attr_value_entry_encode_enum_length(uint8_t count); |
| 525 | |
| 526 | /** @brief Create an attribute value entry(type: enum) |
| 527 | * @param[out] entry - Pointer to bios attribute value entry |
| 528 | * @param[in] entry_length - Length of attribute value entry |
| 529 | * @param[in] attr_handle - This handle points to an attribute in the |
| 530 | * BIOS Attribute Vlaue Table. |
| 531 | * @param[in] attr_type - Type of this attribute in the BIOS Attribute Value |
| 532 | * Table |
| 533 | * @param[in] count - Total number of current values for this enum attribute |
| 534 | * @param[in] handle_indexes - Index into the array(provided in the BIOS |
| 535 | * Attribute Table) of the possible values of string handles for this attribute. |
| 536 | */ |
| 537 | void pldm_bios_table_attr_value_entry_encode_enum( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 538 | void *entry, size_t entry_length, uint16_t attr_handle, |
| 539 | uint8_t attr_type, uint8_t count, const uint8_t *handles); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 540 | |
| 541 | /** @brief Get number of current values for the enum entry |
| 542 | * @param[in] entry - Pointer to bios attribute value table entry |
| 543 | * @return Total number of current values for this enumeration |
| 544 | */ |
| 545 | uint8_t pldm_bios_table_attr_value_entry_enum_decode_number( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 546 | const struct pldm_bios_attr_val_table_entry *entry); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 547 | |
| 548 | /** @brief Get CurrentValueStringHandleIndex |
| 549 | * @param[in] entry - Pointer to bios attribute value table entry |
| 550 | * @param[in, out] handles - Pointer to a buffer to store |
| 551 | * CurrentValueStringHandleIndex |
| 552 | * @param[in] number - Number of PossibleValuesStringHandles expected |
| 553 | * @return Number of CurrentValueStringHandleIndex decoded. |
| 554 | */ |
| 555 | uint8_t pldm_bios_table_attr_value_entry_enum_decode_handles( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 556 | const struct pldm_bios_attr_val_table_entry *entry, uint8_t *handles, |
| 557 | uint8_t number); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 558 | |
| 559 | /** @brief Create an attribute value entry(type: enum) and check the validity of |
| 560 | * the parameters |
| 561 | * @param[out] entry - Pointer to bios attribute value entry |
| 562 | * @param[in] entry_length - Length of attribute value entry |
| 563 | * @param[in] attr_handle - This handle points to an attribute in the |
| 564 | * BIOS Attribute Vlaue Table. |
| 565 | * @param[in] attr_type - Type of this attribute in the BIOS Attribute Value |
| 566 | * Table |
| 567 | * @param[in] count - Total number of current values for this enum attribute |
| 568 | * @param[in] handle_indexes - Index into the array(provided in the BIOS |
| 569 | * Attribute Table) of the possible values of string handles for this attribute. |
| 570 | * @return pldm_completion_codes |
| 571 | */ |
| 572 | int pldm_bios_table_attr_value_entry_encode_enum_check( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 573 | void *entry, size_t entry_length, uint16_t attr_handle, |
| 574 | uint8_t attr_type, uint8_t count, uint8_t *handles); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 575 | |
| 576 | /** @brief Get length that an attribute value entry(type: string) will take |
| 577 | * @param[in] string_length - Length of the current string in byte, 0 indicates |
| 578 | * that the current string value is not set. |
| 579 | * @return The length that an entry(type: string) will take |
| 580 | */ |
| 581 | size_t |
| 582 | pldm_bios_table_attr_value_entry_encode_string_length(uint16_t string_length); |
| 583 | |
| 584 | /** @brief Create an attribute value entry(type: string) |
| 585 | * @param[out] entry - Pointer to bios attribute value entry |
| 586 | * @param[in] entry_length - Length of attribute value entry |
| 587 | * @param[in] attr_handle - This handle points to an attribute in the |
| 588 | * BIOS Attribute Vlaue Table. |
| 589 | * @param[in] attr_type - Type of this attribute in the BIOS Attribute Value |
| 590 | * Table |
| 591 | * @param[in] string_length - Length of current string in bytes. 0 indicates |
| 592 | * that the current string value is not set. |
| 593 | * @param[in] string - The current string itsel |
| 594 | */ |
| 595 | void pldm_bios_table_attr_value_entry_encode_string( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 596 | void *entry, size_t entry_length, uint16_t attr_handle, |
| 597 | uint8_t attr_type, uint16_t str_length, const char *string); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 598 | |
| 599 | /** @brief Get length of the current string in bytes |
| 600 | * @param [in] entry - Pointer to bios attribute value table entry |
| 601 | * @return The length of the current string in bytes |
| 602 | */ |
| 603 | uint16_t pldm_bios_table_attr_value_entry_string_decode_length( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 604 | const struct pldm_bios_attr_val_table_entry *entry); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 605 | |
| 606 | /** @brief Get Current String Itself |
| 607 | * @param[in] entry - Pointer to bios attribute value table entry |
| 608 | * @param[in, out] current_string - Struct variable_field, contains a pointer |
| 609 | * to the CurrentString field in the buffer of |
| 610 | * \p entry, \p entry must be valid |
| 611 | * when \p current_string is used. |
| 612 | */ |
| 613 | void pldm_bios_table_attr_value_entry_string_decode_string( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 614 | const struct pldm_bios_attr_val_table_entry *entry, |
| 615 | struct variable_field *current_string); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 616 | |
| 617 | /** @brief Create an attribute value entry(type: string) and check the validity |
| 618 | * of the parameters |
| 619 | * @param[out] entry - Pointer to bios attribute value entry |
| 620 | * @param[in] entry_length - Length of attribute value entry |
| 621 | * @param[in] attr_handle - This handle points to an attribute in the |
| 622 | * BIOS Attribute Vlaue Table. |
| 623 | * @param[in] attr_type - Type of this attribute in the BIOS Attribute Value |
| 624 | * Table |
| 625 | * @param[in] string_length - Length of current string in bytes. 0 indicates |
| 626 | * that the current string value is not set. |
| 627 | * @param[in] string - The current string itsel |
| 628 | * @return pldm_completion_codes |
| 629 | */ |
| 630 | int pldm_bios_table_attr_value_entry_encode_string_check( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 631 | void *entry, size_t entry_length, uint16_t attr_handle, |
| 632 | uint8_t attr_type, uint16_t str_length, const char *string); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 633 | |
| 634 | /** @brief Get length that an attribute value entry(type: integer) will take |
| 635 | * @return The length that an entry(type: integer) will take |
| 636 | */ |
Andrew Jeffery | 319304f | 2023-04-05 13:53:18 +0930 | [diff] [blame] | 637 | size_t pldm_bios_table_attr_value_entry_encode_integer_length(void); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 638 | |
| 639 | /** @brief Create an attribute value entry(type: integer) |
| 640 | * @param[out] entry - Pointer to bios attribute value entry |
| 641 | * @param[in] entry_length - Length of attribute value entry |
| 642 | * @param[in] attr_handle - This handle points to an attribute in the |
| 643 | * BIOS Attribute Vlaue Table. |
| 644 | * @param[in] attr_type - Type of this attribute in the BIOS Attribute Value |
| 645 | * Table |
| 646 | * @param[in] cv - Current Value |
| 647 | */ |
| 648 | void pldm_bios_table_attr_value_entry_encode_integer(void *entry, |
| 649 | size_t entry_length, |
| 650 | uint16_t attr_handle, |
| 651 | uint8_t attr_type, |
| 652 | uint64_t cv); |
| 653 | |
| 654 | /** @brief Get current values for the integer entry |
| 655 | * @param[in] entry - Pointer to bios attribute value table entry |
| 656 | * @return Current Value |
| 657 | */ |
| 658 | uint64_t pldm_bios_table_attr_value_entry_integer_decode_cv( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 659 | const struct pldm_bios_attr_val_table_entry *entry); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 660 | |
| 661 | /** @brief Create an attribute value entry(type: integer) and check the validity |
| 662 | * of the parameters |
| 663 | * @param[out] entry - Pointer to bios attribute value entry |
| 664 | * @param[in] entry_length - Length of attribute value entry |
| 665 | * @param[in] attr_handle - This handle points to an attribute in the |
| 666 | * BIOS Attribute Vlaue Table. |
| 667 | * @param[in] attr_type - Type of this attribute in the BIOS Attribute Value |
| 668 | * Table |
| 669 | * @param[in] cv - Current Value |
| 670 | * @return pldm_completion_codes |
| 671 | */ |
| 672 | int pldm_bios_table_attr_value_entry_encode_integer_check(void *entry, |
| 673 | size_t entry_length, |
| 674 | uint16_t attr_handle, |
| 675 | uint8_t attr_type, |
| 676 | uint64_t cv); |
| 677 | |
| 678 | /** @brief Get the handle from the attribute value entry |
| 679 | * @param[in] entry - Pointer to bios attribute value entry |
| 680 | * @return handle to identify the attribute in the attribute value table |
| 681 | */ |
| 682 | uint16_t pldm_bios_table_attr_value_entry_decode_handle( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 683 | const struct pldm_bios_attr_val_table_entry *entry); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 684 | |
| 685 | /** @brief Get the length of the attribute value entry |
| 686 | * @param[in] entry - Pointer to bios attribute value entry |
| 687 | * @return Length of the entry |
| 688 | */ |
| 689 | size_t pldm_bios_table_attr_value_entry_length( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 690 | const struct pldm_bios_attr_val_table_entry *entry); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 691 | |
| 692 | /** @brief Find an entry in attribute value table by handle |
| 693 | * @param[in] table - The BIOS Attribute Value Table |
| 694 | * @param[in] length - Length of the BIOS Attribute Value Table |
| 695 | * @param[in] handle - handle to identify the attribute in the attribute value |
| 696 | * table |
| 697 | * @return Pointer to the entry |
| 698 | */ |
| 699 | const struct pldm_bios_attr_val_table_entry * |
| 700 | pldm_bios_table_attr_value_find_by_handle(const void *table, size_t length, |
| 701 | uint16_t handle); |
| 702 | |
| 703 | /** @brief Get the size of pad and checksum |
| 704 | * @param[in] size_without_pad - Table size without pad |
| 705 | * @return The size of pad and checksum |
| 706 | */ |
| 707 | size_t pldm_bios_table_pad_checksum_size(size_t size_without_pad); |
| 708 | |
| 709 | /** @brief Append pad and checksum at the end of the table |
| 710 | * @param[in,out] table - Pointer to a buffer of a bios table |
| 711 | * @param[in] size - Size of the buffer of a bios table |
| 712 | * @param[in] size_without_pad - Table size without pad and checksum |
| 713 | * @return Total size of the table |
| 714 | */ |
| 715 | size_t pldm_bios_table_append_pad_checksum(void *table, size_t size, |
| 716 | size_t size_without_pad); |
| 717 | |
| 718 | /** @brief Build a new table and update an entry |
| 719 | * @param[in] src_table - Pointer to the source table |
| 720 | * @param[in] src_length - Size of the source table |
| 721 | * @param[out] dest_table - Pointer to the buffer of destination table |
| 722 | * @param[in,out] dest_length - Buffer size of the destination table as input |
| 723 | * parameter and will be assigned the length of |
| 724 | * the new table, if the function returns |
| 725 | * PLDM_SUCCESS |
| 726 | * @param[in] entry - Pointer to an entry |
| 727 | * @param[in] entry_length - Size of the entry |
| 728 | * @return pldm_completion_codes |
| 729 | */ |
| 730 | int pldm_bios_table_attr_value_copy_and_update( |
Andrew Jeffery | 37dd6a3 | 2023-05-12 16:04:06 +0930 | [diff] [blame] | 731 | const void *src_table, size_t src_length, void *dest_table, |
| 732 | size_t *dest_length, const void *entry, size_t entry_length); |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 733 | |
| 734 | /** @brief Verify the crc value of the complete table |
| 735 | * @param[in] table - Pointer to a buffer of a bios table |
| 736 | * @param[in] size - Size of the buffer of a bios table |
| 737 | * @return true: crc value is correct |
| 738 | */ |
| 739 | bool pldm_bios_table_checksum(const uint8_t *table, size_t size); |
| 740 | |
| 741 | #ifdef __cplusplus |
| 742 | } |
| 743 | #endif |
| 744 | |
| 745 | #endif |