143 lines
4.0 KiB
C
143 lines
4.0 KiB
C
/*================================================================
|
|
Copyright (c) 2021, Quectel Wireless Solutions Co., Ltd. All rights reserved.
|
|
Quectel Wireless Solutions Proprietary and Confidential.
|
|
=================================================================*/
|
|
#ifndef _QUEC_FLASHRW_H_
|
|
#define _QUEC_FLASHRW_H_
|
|
|
|
#define FLASH_RW_ERROR 1
|
|
|
|
|
|
/*****************************************************************
|
|
* Function: CHECK_FLASH_AREA_ADDR_CONFIG
|
|
*
|
|
* Description:
|
|
* 初始化被保护分区的分区信息
|
|
*
|
|
* Parameters:
|
|
* void
|
|
*
|
|
* Return:
|
|
* 0:初始化成功
|
|
*
|
|
*
|
|
*****************************************************************/
|
|
UINT32 CHECK_FLASH_AREA_ADDR_CONFIG(void);
|
|
|
|
//检查指定的Flash地址和大小是否可以被擦除
|
|
//flash_addr:要擦除Flash地址
|
|
//flash_size:擦除的大小
|
|
//rw_flag:是否记录此次擦除,0,不记录;1,记录
|
|
UINT32 FLASH_LIMIT_ALLOW_AREA(UINT32 flash_addr,UINT32 flash_size,BOOL rw_flag);
|
|
//记录flash_addr所在分区的第几个block,被擦除的次数
|
|
UINT32 Flash_erase_count_Set(UINT32 flash_addr,UINT32 size);
|
|
|
|
int quec_erase_block(int blk_index, unsigned int disable_protect);
|
|
|
|
/*****************************************************************
|
|
* Function: ql_norflash_get_addr
|
|
*
|
|
* Description:
|
|
* Get partition address
|
|
*
|
|
* Parameters:
|
|
* patition_name [in] partition name
|
|
* start_addr [out] partition addr
|
|
* src [out] partition size
|
|
*
|
|
* Return:
|
|
* NULL
|
|
*
|
|
*
|
|
*****************************************************************/
|
|
void quec_norflash_get_addr(unsigned char *patition_name, unsigned int *start_addr, unsigned int *size);
|
|
|
|
/*****************************************************************
|
|
* Function: ql_norflash_do_read
|
|
*
|
|
* Description:
|
|
* Read a section of a partition
|
|
*
|
|
* Parameters:
|
|
* patition_name [in] partition name
|
|
* start_addr [in] The address from which data is to be read
|
|
* buf_addr [out] Read the data storage address
|
|
* size [in] Read the data size
|
|
* Return:
|
|
* 0:sucess; 1:fail
|
|
*
|
|
*
|
|
*****************************************************************/
|
|
unsigned int quec_norflash_do_read(unsigned char *patition_name, unsigned int addr, unsigned int buf_addr, unsigned int size);
|
|
|
|
/*****************************************************************
|
|
* Function: ql_norflash_do_write
|
|
*
|
|
* Description:
|
|
* write a section of a partition
|
|
*
|
|
* Parameters:
|
|
* patition_name [in] partition name
|
|
* start_addr [in] The address from which data is to be write
|
|
* buf_addr [in] write the data address
|
|
* size [in] write the data size
|
|
* Return:
|
|
* 0:sucess; 1:fail
|
|
*
|
|
*
|
|
*****************************************************************/
|
|
unsigned int quec_norflash_do_write(unsigned char *patition_name, unsigned int addr, unsigned int buf_addr, unsigned int size);
|
|
|
|
/*****************************************************************
|
|
* Function: ql_norflash_do_erase
|
|
*
|
|
* Description:
|
|
* erase a section of a partition
|
|
*
|
|
* Parameters:
|
|
* patition_name [in] partition name
|
|
* start_addr [in] The address from which data is to be erase
|
|
* size [in] write the data size
|
|
*
|
|
* Return:
|
|
* NULL
|
|
*
|
|
*
|
|
*****************************************************************/
|
|
int quec_norflash_do_erase(unsigned char *patition_name, unsigned int addr, unsigned int size);
|
|
|
|
/*****************************************************************
|
|
* Function: ql_norflash_read_id
|
|
*
|
|
* Description:
|
|
* get flash id
|
|
*
|
|
* Parameters:
|
|
* NULL
|
|
*
|
|
*
|
|
*
|
|
* Return:
|
|
* NULL
|
|
*
|
|
*
|
|
*****************************************************************/
|
|
int quec_norflash_read_id(void);
|
|
UINT32 get_quec_cfg_start_address(void);
|
|
|
|
|
|
#ifdef QUEC_NORFLASH_ERASE_OPTIMIZE
|
|
#define CHIP_SECTOR_SIZE 0x1000 //erase 4k each times
|
|
#define CHIP_BLOCK_SIZE 0x10000 //erase 4k each times
|
|
typedef enum
|
|
{
|
|
Record_type_Block,
|
|
Record_type_Page
|
|
}quec_Record_type_enum;
|
|
int quec_repair_erase_get_parti_name_valid(char* parti_name);
|
|
#endif
|
|
|
|
|
|
#endif
|
|
|