blob: 738524b208ad1707997262aa3dfdc273d1b2370c [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];
Adriana Kobylakc71dfd72017-07-22 11:10:43 -050016 char patch_loc[PATH_MAX];
Ratan Gupta8441a392017-05-05 21:42:53 +053017};
18
Deepak Kodihallib6a446f2017-04-29 13:01:49 -050019#ifdef __cplusplus
20extern "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 Kodihalli64ec3e42017-07-17 06:15:16 -050031void init_vpnor(struct mbox_context *context);
Deepak Kodihallib6a446f2017-04-29 13:01:49 -050032
Ratan Gupta3214b512017-05-11 08:58:19 +053033/** @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
42void vpnor_create_partition_table_from_path(struct mbox_context *context,
43 const char* path);
44
Deepak Kodihallib6a446f2017-04-29 13:01:49 -050045
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 */
53size_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 */
63const 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 */
77const struct pnor_partition* vpnor_get_partition(
78 const struct mbox_context *context,
79 const size_t offset);
80
81
Deepak Kodihalli017e45c2017-07-12 01:06:30 -050082/** @brief Copy bootloader partition (alongwith TOC) to LPC memory
83 *
84 * @param[in] context - mbox context pointer
85 */
86void vpnor_copy_bootloader_partition(const struct mbox_context *context);
87
Deepak Kodihallib6a446f2017-04-29 13:01:49 -050088/** @brief Destroy partition table, if it exists.
89 *
90 * @param[in] context - mbox context pointer
91 */
Deepak Kodihalli64ec3e42017-07-17 06:15:16 -050092void destroy_vpnor(struct mbox_context *context);
Deepak Kodihallib6a446f2017-04-29 13:01:49 -050093
94#ifdef __cplusplus
95}
96#endif
97
98#endif