Deepak Kodihalli | b6a446f | 2017-04-29 13:01:49 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #ifdef VIRTUAL_PNOR_ENABLED |
| 4 | |
| 5 | #include "pnor_partition_defs.h" |
| 6 | |
| 7 | struct mbox_context; |
| 8 | struct vpnor_partition_table; |
| 9 | |
| 10 | #ifdef __cplusplus |
| 11 | extern "C" { |
| 12 | #endif |
| 13 | |
| 14 | /** @brief Create a virtual PNOR partition table. |
| 15 | * |
| 16 | * @param[in] context - mbox context pointer |
| 17 | * |
| 18 | * This API should be called before calling any other APIs below. If a table |
| 19 | * already exists, this function will not do anything further. This function |
| 20 | * will not do anything if the context is NULL. |
| 21 | */ |
| 22 | void vpnor_create_partition_table(struct mbox_context *context); |
| 23 | |
| 24 | |
| 25 | /** @brief Get partition table size, in blocks (1 block = 4KB) |
| 26 | * |
| 27 | * @param[in] context - mbox context pointer |
| 28 | * |
| 29 | * @returns partition table size. 0 if no table exists, or if the |
| 30 | * context is NULL. |
| 31 | */ |
| 32 | size_t vpnor_get_partition_table_size(const struct mbox_context *context); |
| 33 | |
| 34 | |
| 35 | /** @brief Get virtual PNOR partition table with host-compatible byte-ordering |
| 36 | * |
| 37 | * @param[in] context - mbox context pointer |
| 38 | * |
| 39 | * @returns pointer to partition table, NULL if partition table doesn't |
| 40 | * exist or if the context is NULL. |
| 41 | */ |
| 42 | const struct pnor_partition_table* vpnor_get_partition_table( |
| 43 | const struct mbox_context *context); |
| 44 | |
| 45 | |
| 46 | /** @brief Get a specific partition, by PNOR offset. The returned |
| 47 | * partition is such that the offset lies in that partition's |
| 48 | * boundary. |
| 49 | * |
| 50 | * @param[in] context - mbox context pointer |
| 51 | * @param[in] offset - PNOR offset |
| 52 | * |
| 53 | * @returns const pointer to pnor_partition, NULL if partition table doesn't |
| 54 | * exist or if the context is NULL |
| 55 | */ |
| 56 | const struct pnor_partition* vpnor_get_partition( |
| 57 | const struct mbox_context *context, |
| 58 | const size_t offset); |
| 59 | |
| 60 | |
| 61 | /** @brief Destroy partition table, if it exists. |
| 62 | * |
| 63 | * @param[in] context - mbox context pointer |
| 64 | */ |
| 65 | |
| 66 | void vpnor_destroy_partition_table(struct mbox_context *context); |
| 67 | |
| 68 | #ifdef __cplusplus |
| 69 | } |
| 70 | #endif |
| 71 | |
| 72 | #endif |