blob: 452a87156befe7453747151d6f960571ab1a3114 [file] [log] [blame]
Deepak Kodihallib6a446f2017-04-29 13:01:49 -05001#pragma once
2
3#ifdef VIRTUAL_PNOR_ENABLED
4
Ratan Gupta8441a392017-05-05 21:42:53 +05305#include <limits.h>
Deepak Kodihallib6a446f2017-04-29 13:01:49 -05006#include "pnor_partition_defs.h"
7
8struct mbox_context;
9struct vpnor_partition_table;
10
Ratan Gupta8441a392017-05-05 21:42:53 +053011struct vpnor_partition_paths
12{
13 char ro_loc[PATH_MAX];
Ratan Guptac0ef9872017-06-06 14:31:37 +053014 char rw_loc[PATH_MAX];
15 char prsv_loc[PATH_MAX];
Ratan Gupta8441a392017-05-05 21:42:53 +053016};
17
Deepak Kodihallib6a446f2017-04-29 13:01:49 -050018#ifdef __cplusplus
19extern "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 */
Deepak Kodihalli64ec3e42017-07-17 06:15:16 -050030void init_vpnor(struct mbox_context *context);
Deepak Kodihallib6a446f2017-04-29 13:01:49 -050031
Ratan Gupta3214b512017-05-11 08:58:19 +053032/** @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
41void vpnor_create_partition_table_from_path(struct mbox_context *context,
42 const char* path);
43
Deepak Kodihallib6a446f2017-04-29 13:01:49 -050044
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 */
52size_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 */
62const 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 */
76const struct pnor_partition* vpnor_get_partition(
77 const struct mbox_context *context,
78 const size_t offset);
79
80
Deepak Kodihalli017e45c2017-07-12 01:06:30 -050081/** @brief Copy bootloader partition (alongwith TOC) to LPC memory
82 *
83 * @param[in] context - mbox context pointer
84 */
85void vpnor_copy_bootloader_partition(const struct mbox_context *context);
86
Deepak Kodihallib6a446f2017-04-29 13:01:49 -050087/** @brief Destroy partition table, if it exists.
88 *
89 * @param[in] context - mbox context pointer
90 */
Deepak Kodihalli64ec3e42017-07-17 06:15:16 -050091void destroy_vpnor(struct mbox_context *context);
Deepak Kodihallib6a446f2017-04-29 13:01:49 -050092
93#ifdef __cplusplus
94}
95#endif
96
97#endif