blob: ec21923b89990aec9fc53be472f9a81c13256b0e [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
30
31/** @brief Get partition table size, in blocks (1 block = 4KB)
32 *
33 * @param[in] context - mbox context pointer
34 *
35 * @returns partition table size. 0 if no table exists, or if the
36 * context is NULL.
37 */
38size_t vpnor_get_partition_table_size(const struct mbox_context *context);
39
40
41/** @brief Get virtual PNOR partition table with host-compatible byte-ordering
42 *
43 * @param[in] context - mbox context pointer
44 *
45 * @returns pointer to partition table, NULL if partition table doesn't
46 * exist or if the context is NULL.
47 */
48const struct pnor_partition_table* vpnor_get_partition_table(
49 const struct mbox_context *context);
50
51
52/** @brief Get a specific partition, by PNOR offset. The returned
53 * partition is such that the offset lies in that partition's
54 * boundary.
55 *
56 * @param[in] context - mbox context pointer
57 * @param[in] offset - PNOR offset
58 *
59 * @returns const pointer to pnor_partition, NULL if partition table doesn't
60 * exist or if the context is NULL
61 */
62const struct pnor_partition* vpnor_get_partition(
63 const struct mbox_context *context,
64 const size_t offset);
65
66
67/** @brief Destroy partition table, if it exists.
68 *
69 * @param[in] context - mbox context pointer
70 */
71
72void vpnor_destroy_partition_table(struct mbox_context *context);
73
74#ifdef __cplusplus
75}
76#endif
77
78#endif