| Deepak Kodihalli | b6a446f | 2017-04-29 13:01:49 -0500 | [diff] [blame] | 1 | #pragma once | 
|  | 2 |  | 
|  | 3 | #ifdef VIRTUAL_PNOR_ENABLED | 
|  | 4 |  | 
| Ratan Gupta | 8441a39 | 2017-05-05 21:42:53 +0530 | [diff] [blame] | 5 | #include <limits.h> | 
| Deepak Kodihalli | b6a446f | 2017-04-29 13:01:49 -0500 | [diff] [blame] | 6 | #include "pnor_partition_defs.h" | 
|  | 7 |  | 
|  | 8 | struct mbox_context; | 
|  | 9 | struct vpnor_partition_table; | 
|  | 10 |  | 
| Ratan Gupta | 8441a39 | 2017-05-05 21:42:53 +0530 | [diff] [blame] | 11 | struct vpnor_partition_paths | 
|  | 12 | { | 
|  | 13 | char ro_loc[PATH_MAX]; | 
| Ratan Gupta | c0ef987 | 2017-06-06 14:31:37 +0530 | [diff] [blame] | 14 | char rw_loc[PATH_MAX]; | 
|  | 15 | char prsv_loc[PATH_MAX]; | 
| Ratan Gupta | 8441a39 | 2017-05-05 21:42:53 +0530 | [diff] [blame] | 16 | }; | 
|  | 17 |  | 
| Deepak Kodihalli | b6a446f | 2017-04-29 13:01:49 -0500 | [diff] [blame] | 18 | #ifdef __cplusplus | 
|  | 19 | extern "C" { | 
|  | 20 | #endif | 
|  | 21 |  | 
|  | 22 | /** @brief Create a virtual PNOR partition table. | 
|  | 23 | * | 
|  | 24 | *  @param[in] context - mbox context pointer | 
|  | 25 | * | 
|  | 26 | *  This API should be called before calling any other APIs below. If a table | 
|  | 27 | *  already exists, this function will not do anything further. This function | 
|  | 28 | *  will not do anything if the context is NULL. | 
|  | 29 | */ | 
|  | 30 | void vpnor_create_partition_table(struct mbox_context *context); | 
|  | 31 |  | 
| Ratan Gupta | 3214b51 | 2017-05-11 08:58:19 +0530 | [diff] [blame] | 32 | /** @brief Create a virtual PNOR partition table. | 
|  | 33 | * | 
|  | 34 | *  @param[in] context - mbox context pointer | 
|  | 35 | *  @param[in] path - location of the partition file | 
|  | 36 | * | 
|  | 37 | *  This API is same as above one but it reads the partition file from | 
|  | 38 | *  from the given location(path). | 
|  | 39 | */ | 
|  | 40 |  | 
|  | 41 | void vpnor_create_partition_table_from_path(struct mbox_context *context, | 
|  | 42 | const char* path); | 
|  | 43 |  | 
| Deepak Kodihalli | b6a446f | 2017-04-29 13:01:49 -0500 | [diff] [blame] | 44 |  | 
|  | 45 | /** @brief Get partition table size, in blocks (1 block = 4KB) | 
|  | 46 | * | 
|  | 47 | *  @param[in] context - mbox context pointer | 
|  | 48 | * | 
|  | 49 | *  @returns partition table size. 0 if no table exists, or if the | 
|  | 50 | *           context is NULL. | 
|  | 51 | */ | 
|  | 52 | size_t vpnor_get_partition_table_size(const struct mbox_context *context); | 
|  | 53 |  | 
|  | 54 |  | 
|  | 55 | /** @brief Get virtual PNOR partition table with host-compatible byte-ordering | 
|  | 56 | * | 
|  | 57 | *  @param[in] context - mbox context pointer | 
|  | 58 | * | 
|  | 59 | *  @returns pointer to partition table, NULL if partition table doesn't | 
|  | 60 | *           exist or if the context is NULL. | 
|  | 61 | */ | 
|  | 62 | const struct pnor_partition_table* vpnor_get_partition_table( | 
|  | 63 | const struct mbox_context *context); | 
|  | 64 |  | 
|  | 65 |  | 
|  | 66 | /** @brief Get a specific partition, by PNOR offset. The returned | 
|  | 67 | *         partition is such that the offset lies in that partition's | 
|  | 68 | *         boundary. | 
|  | 69 | * | 
|  | 70 | *  @param[in] context - mbox context pointer | 
|  | 71 | *  @param[in] offset - PNOR offset | 
|  | 72 | * | 
|  | 73 | *  @returns const pointer to pnor_partition, NULL if partition table doesn't | 
|  | 74 | *           exist or if the context is NULL | 
|  | 75 | */ | 
|  | 76 | const struct pnor_partition* vpnor_get_partition( | 
|  | 77 | const struct mbox_context *context, | 
|  | 78 | const size_t offset); | 
|  | 79 |  | 
|  | 80 |  | 
|  | 81 | /** @brief Destroy partition table, if it exists. | 
|  | 82 | * | 
|  | 83 | *  @param[in] context - mbox context pointer | 
|  | 84 | */ | 
|  | 85 |  | 
|  | 86 | void vpnor_destroy_partition_table(struct mbox_context *context); | 
|  | 87 |  | 
|  | 88 | #ifdef __cplusplus | 
|  | 89 | } | 
|  | 90 | #endif | 
|  | 91 |  | 
|  | 92 | #endif |