blob: d13a2d2f3aa706f7106a7e3604ea250074b6e273 [file] [log] [blame]
Andrew Jeffery4fe996c2018-02-27 12:16:48 +10301/* SPDX-License-Identifier: Apache-2.0 */
2/* Copyright (C) 2018 IBM Corp. */
Deepak Kodihallib6a446f2017-04-29 13:01:49 -05003#pragma once
4
5#ifdef VIRTUAL_PNOR_ENABLED
6
Ratan Gupta8441a392017-05-05 21:42:53 +05307#include <limits.h>
Deepak Kodihallib6a446f2017-04-29 13:01:49 -05008#include "pnor_partition_defs.h"
9
10struct mbox_context;
11struct vpnor_partition_table;
12
Ratan Gupta8441a392017-05-05 21:42:53 +053013struct vpnor_partition_paths
14{
15 char ro_loc[PATH_MAX];
Ratan Guptac0ef9872017-06-06 14:31:37 +053016 char rw_loc[PATH_MAX];
17 char prsv_loc[PATH_MAX];
Adriana Kobylakc71dfd72017-07-22 11:10:43 -050018 char patch_loc[PATH_MAX];
Ratan Gupta8441a392017-05-05 21:42:53 +053019};
20
Deepak Kodihallib6a446f2017-04-29 13:01:49 -050021#ifdef __cplusplus
22extern "C" {
23#endif
24
25/** @brief Create a virtual PNOR partition table.
26 *
27 * @param[in] context - mbox context pointer
28 *
29 * This API should be called before calling any other APIs below. If a table
30 * already exists, this function will not do anything further. This function
31 * will not do anything if the context is NULL.
Andrew Jefferyf96bd162018-02-26 13:05:00 +103032 *
33 * Returns 0 if the call succeeds, else a negative error code.
Deepak Kodihallib6a446f2017-04-29 13:01:49 -050034 */
Andrew Jefferyf96bd162018-02-26 13:05:00 +103035int init_vpnor(struct mbox_context *context);
Deepak Kodihallib6a446f2017-04-29 13:01:49 -050036
Ratan Gupta3214b512017-05-11 08:58:19 +053037/** @brief Create a virtual PNOR partition table.
38 *
39 * @param[in] context - mbox context pointer
Ratan Gupta3214b512017-05-11 08:58:19 +053040 *
Andrew Jeffery742a1f62018-03-02 09:26:03 +103041 * This API is same as above one but requires context->path is initialised
42 * with all the necessary paths.
Andrew Jefferyf96bd162018-02-26 13:05:00 +103043 *
44 * Returns 0 if the call succeeds, else a negative error code.
Ratan Gupta3214b512017-05-11 08:58:19 +053045 */
46
Andrew Jeffery742a1f62018-03-02 09:26:03 +103047int init_vpnor_from_paths(struct mbox_context *context);
Ratan Gupta3214b512017-05-11 08:58:19 +053048
Deepak Kodihalli017e45c2017-07-12 01:06:30 -050049/** @brief Copy bootloader partition (alongwith TOC) to LPC memory
50 *
51 * @param[in] context - mbox context pointer
Andrew Jefferyf96bd162018-02-26 13:05:00 +103052 *
53 * @returns 0 on success, negative error code on failure
Deepak Kodihalli017e45c2017-07-12 01:06:30 -050054 */
Andrew Jefferyf96bd162018-02-26 13:05:00 +103055int vpnor_copy_bootloader_partition(const struct mbox_context *context);
Deepak Kodihalli017e45c2017-07-12 01:06:30 -050056
Deepak Kodihallib6a446f2017-04-29 13:01:49 -050057/** @brief Destroy partition table, if it exists.
58 *
59 * @param[in] context - mbox context pointer
60 */
Deepak Kodihalli64ec3e42017-07-17 06:15:16 -050061void destroy_vpnor(struct mbox_context *context);
Deepak Kodihallib6a446f2017-04-29 13:01:49 -050062
63#ifdef __cplusplus
64}
65#endif
66
67#endif