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