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 | |
| 62 | /** @brief Get the total number of possible values for the entry |
| 63 | * @param[in] entry - Pointer to bios attribute table entry |
| 64 | * @return total number of possible values |
| 65 | */ |
| 66 | uint8_t pldm_bios_table_attr_entry_enum_decode_pv_num( |
| 67 | const struct pldm_bios_attr_table_entry *entry); |
| 68 | |
| 69 | /** @brief Get the total number of possible values for the entry and check the |
| 70 | * validity of the parameters |
| 71 | * @param[in] entry - Pointer to bios attribute table entry |
| 72 | * @param[out] pv_num - Pointer to total number of possible values |
| 73 | * @return pldm_completion_codes |
| 74 | */ |
| 75 | int pldm_bios_table_attr_entry_enum_decode_pv_num_check( |
| 76 | const struct pldm_bios_attr_table_entry *entry, uint8_t *pv_num); |
| 77 | |
| 78 | /** @brief Get the total number of default values for the entry |
| 79 | * @param[in] entry - Pointer to bios attribute table entry |
| 80 | * @return total number of default values |
| 81 | */ |
| 82 | uint8_t pldm_bios_table_attr_entry_enum_decode_def_num( |
| 83 | const struct pldm_bios_attr_table_entry *entry); |
| 84 | |
| 85 | /** @brief Get the total number of default values for the entry and check the |
| 86 | * validity of the parameters |
| 87 | * @param[in] entry - Pointer to bios attribute table entry |
| 88 | * @param[out] def_num - Pointer to total number of default values |
| 89 | * @return pldm_completion_codes |
| 90 | */ |
| 91 | int pldm_bios_table_attr_entry_enum_decode_def_num_check( |
| 92 | const struct pldm_bios_attr_table_entry *entry, uint8_t *def_num); |
| 93 | |
| 94 | /** @brief Get the length of default string in bytes for the entry |
| 95 | * @param[in] entry - Pointer to bios attribute table entry |
| 96 | * @return length of default string in bytes |
| 97 | */ |
| 98 | uint16_t pldm_bios_table_attr_entry_string_decode_def_string_length( |
| 99 | const struct pldm_bios_attr_table_entry *entry); |
| 100 | |
| 101 | /** @brief Get the length of default string in bytes for the entry and check the |
| 102 | * validity of the parameters |
| 103 | * @param[in] entry - Pointer to bios attribute table entry |
| 104 | * @param[out] def_string_length Pointer to length of default string in bytes |
| 105 | * @return pldm_completion_codes |
| 106 | */ |
| 107 | int pldm_bios_table_attr_entry_string_decode_def_string_length_check( |
| 108 | const struct pldm_bios_attr_table_entry *entry, |
| 109 | uint16_t *def_string_length); |
| 110 | |
| 111 | #ifdef __cplusplus |
| 112 | } |
| 113 | #endif |
| 114 | |
| 115 | #endif |