|
10 | 10 | #include <stdbool.h> |
11 | 11 | #include <stddef.h> |
12 | 12 | #include "esp_err.h" |
| 13 | +#include "esp_idf_version.h" |
| 14 | + |
| 15 | +#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(6, 0, 0)) |
| 16 | +#include "esp_blockdev.h" |
| 17 | +#endif // (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(6, 0, 0)) |
13 | 18 |
|
14 | 19 | #if __has_include(<bsd/sys/queue.h>) |
15 | 20 | #include <bsd/sys/queue.h> |
@@ -209,6 +214,54 @@ esp_err_t esp_ext_part_list_signature_get(esp_ext_part_list_t *part_list, void * |
209 | 214 | */ |
210 | 215 | esp_err_t esp_ext_part_list_signature_set(esp_ext_part_list_t *part_list, const void *signature, esp_ext_part_signature_type_t type); |
211 | 216 |
|
| 217 | +#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(6, 0, 0)) |
| 218 | +/** |
| 219 | + * @brief Read a aprtition table and from a block device handle and parse it. |
| 220 | + * |
| 221 | + * This function reads the partition table from the specified block device and populates the provided partition list structure. |
| 222 | + * The type of partition table to read is specified by the 'type' parameter. |
| 223 | + * Additional arguments for parsing can be provided through the 'extra_args' parameter. |
| 224 | + * |
| 225 | + * @note This function is not thread-safe. |
| 226 | + * |
| 227 | + * @param[in] handle Block device handle to read from. |
| 228 | + * @param[out] part_list Pointer to the partition list structure to populate from the partition table. |
| 229 | + * @param[in] type Type of partition table to read (e.g., MBR). |
| 230 | + * @param[in] extra_args Pointer to additional arguments for parsing dependent on the partition type (optional, can be NULL). |
| 231 | + * |
| 232 | + * @return |
| 233 | + * - ESP_OK: Partition list was successfully loaded. |
| 234 | + * - ESP_ERR_INVALID_ARG: `handle` or `part_list` is NULL. |
| 235 | + * - ESP_ERR_NOT_SUPPORTED: Unsupported partition table type. |
| 236 | + * - ESP_ERR_NO_MEM: Memory allocation failed. |
| 237 | + * - propagated errors from BDL operations or partition table parsing functions. |
| 238 | + */ |
| 239 | +esp_err_t esp_ext_part_list_read(esp_blockdev_handle_t handle, esp_ext_part_list_t *part_list, esp_ext_part_signature_type_t type, void *extra_args); |
| 240 | + |
| 241 | +/** |
| 242 | + * @brief Generate a partition table and write it to a block device handle. |
| 243 | + * |
| 244 | + * This function writes the provided partition list to the specified block device. |
| 245 | + * The type of partition table to write is specified by the 'type' parameter. |
| 246 | + * Additional arguments for generation can be provided through the 'extra_args' parameter. |
| 247 | + * |
| 248 | + * @note This function is not thread-safe. |
| 249 | + * |
| 250 | + * @param[in] handle Block device handle to write to. |
| 251 | + * @param[in] part_list Pointer to the partition list structure generate the partition table from. |
| 252 | + * @param[in] type Type of partition table to write (e.g., MBR). |
| 253 | + * @param[in] extra_args Pointer to additional arguments for generation dependent on the partition type (optional, can be NULL). |
| 254 | + * |
| 255 | + * @return |
| 256 | + * - ESP_OK: Partition list was successfully written. |
| 257 | + * - ESP_ERR_INVALID_ARG: `handle` or `part_list` is NULL. |
| 258 | + * - ESP_ERR_NOT_SUPPORTED: Unsupported partition table type. |
| 259 | + * - ESP_ERR_NO_MEM: Memory allocation failed. |
| 260 | + * - propagated errors from BDL operations or partition table generation functions. |
| 261 | + */ |
| 262 | +esp_err_t esp_ext_part_list_write(esp_blockdev_handle_t handle, esp_ext_part_list_t *part_list, esp_ext_part_signature_type_t type, void *extra_args); |
| 263 | +#endif // (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(6, 0, 0)) |
| 264 | + |
212 | 265 | #ifdef __cplusplus |
213 | 266 | } |
214 | 267 | #endif |
0 commit comments