/**
 ***********************************************************************************************************************
 * Copyright (c) 2020, China Mobile Communications Group Co.,Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 *
 * @file        fal_part.h
 *
 * @brief       fal_part
 *
 * @revision
 * Date         Author          Notes
 * 2020-02-20   OneOS Team      First Version
 ***********************************************************************************************************************
 */

#ifndef __FAL_PART_H__
#define __FAL_PART_H__


#include "fal.h"

#ifndef FAL_DEV_NAME_MAX
#define FAL_DEV_NAME_MAX 16
#endif

//#define FAL_PART_INFO_FLAGS_LOCKED   (1 << 0)
//#define FAL_PART_INFO_FLAGS_UNLOCKED (0 << 0)

typedef struct fal_part_info
{
    char *name;
    char *flash_name;
    uint32_t offset;  /*! part分区基于存储器某个物理基地址的偏移量*/
    uint32_t size;    /*! part分区的大小*/

} fal_part_info_t;

typedef struct fal_part
{
    fal_part_info_t *info;
    fal_flash_t     *flash;

} fal_part_t;

fal_part_t *fal_part_find(const char *name);
int fal_part_read(fal_part_t *part, uint32_t offset, uint8_t *buf, size_t size);
int fal_part_write(fal_part_t *part, uint32_t offset, uint8_t *buf, size_t size);
int fal_part_erase(fal_part_t *part, uint32_t blkId, size_t blkNum);
int fal_part_erase_all(fal_part_t *part);
uint32_t fal_part_get_phyaddr(fal_part_t *part);

void fal_show_part_table(void);



#endif /* __FAL_PART_H__ */
