1 /*
2  * Copyright 2017-2020 NXP
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef __MFLASH_FILE__
8 #define __MFLASH_FILE__
9 
10 #include "fsl_common.h"
11 
12 #include "mflash_drv.h"
13 
14 #define MFLASH_MAX_PATH_LEN 56
15 
16 /*
17  * Template for file record defines file path and size to be pre-allocated for that file.
18  * The actual size of the file shall not exceed the size defined in the template.
19  */
20 typedef struct
21 {
22     char *path;
23     uint32_t max_size;
24 } mflash_file_t;
25 
26 /*! @brief Initialization status of mflash subsystem */
27 bool mflash_is_initialized(void);
28 
29 /*! @brief Initializes mflash filesystem and driver. Creates new filesystem unless already in place. */
30 status_t mflash_init(const mflash_file_t *dir_template, bool init_drv);
31 
32 /*! @brief Saves data to file with given path. */
33 status_t mflash_file_save(char *path, uint8_t *data, uint32_t size);
34 
35 /*! @brief Returns pointer for direct memory mapped access to file data. */
36 status_t mflash_file_mmap(char *path, uint8_t **pdata, uint32_t *psize);
37 
38 #endif
39