Andrew Jeffery | 4fe996c | 2018-02-27 12:16:48 +1030 | [diff] [blame] | 1 | /* SPDX-License-Identifier: Apache-2.0 */ |
| 2 | /* Copyright (C) 2018 IBM Corp. */ |
Deepak Kodihalli | b6a446f | 2017-04-29 13:01:49 -0500 | [diff] [blame] | 3 | #pragma once |
| 4 | |
| 5 | #ifdef VIRTUAL_PNOR_ENABLED |
| 6 | |
Ratan Gupta | 8441a39 | 2017-05-05 21:42:53 +0530 | [diff] [blame] | 7 | #include <limits.h> |
Deepak Kodihalli | b6a446f | 2017-04-29 13:01:49 -0500 | [diff] [blame] | 8 | #include "pnor_partition_defs.h" |
| 9 | |
| 10 | struct mbox_context; |
| 11 | struct vpnor_partition_table; |
| 12 | |
Ratan Gupta | 8441a39 | 2017-05-05 21:42:53 +0530 | [diff] [blame] | 13 | struct vpnor_partition_paths |
| 14 | { |
| 15 | char ro_loc[PATH_MAX]; |
Ratan Gupta | c0ef987 | 2017-06-06 14:31:37 +0530 | [diff] [blame] | 16 | char rw_loc[PATH_MAX]; |
| 17 | char prsv_loc[PATH_MAX]; |
Adriana Kobylak | c71dfd7 | 2017-07-22 11:10:43 -0500 | [diff] [blame] | 18 | char patch_loc[PATH_MAX]; |
Ratan Gupta | 8441a39 | 2017-05-05 21:42:53 +0530 | [diff] [blame] | 19 | }; |
| 20 | |
Deepak Kodihalli | b6a446f | 2017-04-29 13:01:49 -0500 | [diff] [blame] | 21 | #ifdef __cplusplus |
| 22 | extern "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 Jeffery | f96bd16 | 2018-02-26 13:05:00 +1030 | [diff] [blame] | 32 | * |
| 33 | * Returns 0 if the call succeeds, else a negative error code. |
Deepak Kodihalli | b6a446f | 2017-04-29 13:01:49 -0500 | [diff] [blame] | 34 | */ |
Andrew Jeffery | f96bd16 | 2018-02-26 13:05:00 +1030 | [diff] [blame] | 35 | int init_vpnor(struct mbox_context *context); |
Deepak Kodihalli | b6a446f | 2017-04-29 13:01:49 -0500 | [diff] [blame] | 36 | |
Ratan Gupta | 3214b51 | 2017-05-11 08:58:19 +0530 | [diff] [blame] | 37 | /** @brief Create a virtual PNOR partition table. |
| 38 | * |
| 39 | * @param[in] context - mbox context pointer |
Ratan Gupta | 3214b51 | 2017-05-11 08:58:19 +0530 | [diff] [blame] | 40 | * |
Andrew Jeffery | 742a1f6 | 2018-03-02 09:26:03 +1030 | [diff] [blame] | 41 | * This API is same as above one but requires context->path is initialised |
| 42 | * with all the necessary paths. |
Andrew Jeffery | f96bd16 | 2018-02-26 13:05:00 +1030 | [diff] [blame] | 43 | * |
| 44 | * Returns 0 if the call succeeds, else a negative error code. |
Ratan Gupta | 3214b51 | 2017-05-11 08:58:19 +0530 | [diff] [blame] | 45 | */ |
| 46 | |
Andrew Jeffery | 742a1f6 | 2018-03-02 09:26:03 +1030 | [diff] [blame] | 47 | int init_vpnor_from_paths(struct mbox_context *context); |
Ratan Gupta | 3214b51 | 2017-05-11 08:58:19 +0530 | [diff] [blame] | 48 | |
Deepak Kodihalli | 017e45c | 2017-07-12 01:06:30 -0500 | [diff] [blame] | 49 | /** @brief Copy bootloader partition (alongwith TOC) to LPC memory |
| 50 | * |
| 51 | * @param[in] context - mbox context pointer |
Andrew Jeffery | f96bd16 | 2018-02-26 13:05:00 +1030 | [diff] [blame] | 52 | * |
| 53 | * @returns 0 on success, negative error code on failure |
Deepak Kodihalli | 017e45c | 2017-07-12 01:06:30 -0500 | [diff] [blame] | 54 | */ |
Andrew Jeffery | f96bd16 | 2018-02-26 13:05:00 +1030 | [diff] [blame] | 55 | int vpnor_copy_bootloader_partition(const struct mbox_context *context); |
Deepak Kodihalli | 017e45c | 2017-07-12 01:06:30 -0500 | [diff] [blame] | 56 | |
Deepak Kodihalli | b6a446f | 2017-04-29 13:01:49 -0500 | [diff] [blame] | 57 | /** @brief Destroy partition table, if it exists. |
| 58 | * |
| 59 | * @param[in] context - mbox context pointer |
| 60 | */ |
Deepak Kodihalli | 64ec3e4 | 2017-07-17 06:15:16 -0500 | [diff] [blame] | 61 | void destroy_vpnor(struct mbox_context *context); |
Deepak Kodihalli | b6a446f | 2017-04-29 13:01:49 -0500 | [diff] [blame] | 62 | |
| 63 | #ifdef __cplusplus |
| 64 | } |
| 65 | #endif |
| 66 | |
| 67 | #endif |