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