1 /* SPDX-License-Identifier: Apache-2.0 */ 2 /* Copyright (C) 2018 IBM Corp. */ 3 #pragma once 4 5 #ifdef VIRTUAL_PNOR_ENABLED 6 7 #include <limits.h> 8 #include "pnor_partition_defs.h" 9 10 struct mbox_context; 11 struct vpnor_partition_table; 12 13 struct vpnor_partition_paths 14 { 15 char ro_loc[PATH_MAX]; 16 char rw_loc[PATH_MAX]; 17 char prsv_loc[PATH_MAX]; 18 char patch_loc[PATH_MAX]; 19 }; 20 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. 32 * 33 * Returns 0 if the call succeeds, else a negative error code. 34 */ 35 int init_vpnor(struct mbox_context *context); 36 37 /** @brief Create a virtual PNOR partition table. 38 * 39 * @param[in] context - mbox context pointer 40 * 41 * This API is same as above one but requires context->path is initialised 42 * with all the necessary paths. 43 * 44 * Returns 0 if the call succeeds, else a negative error code. 45 */ 46 47 int init_vpnor_from_paths(struct mbox_context *context); 48 49 /** @brief Copy bootloader partition (alongwith TOC) to LPC memory 50 * 51 * @param[in] context - mbox context pointer 52 * 53 * @returns 0 on success, negative error code on failure 54 */ 55 int vpnor_copy_bootloader_partition(const struct mbox_context *context); 56 57 /** @brief Destroy partition table, if it exists. 58 * 59 * @param[in] context - mbox context pointer 60 */ 61 void destroy_vpnor(struct mbox_context *context); 62 63 #ifdef __cplusplus 64 } 65 #endif 66 67 #endif 68