1 /* 2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef __HI_LOADERBOOT_FLASH_H__ 17 #define __HI_LOADERBOOT_FLASH_H__ 18 #include "hi_boot_rom.h" 19 20 /** 21 * @ingroup hct_boot_flash 22 * @brief Flash初始化 23 * 24 * @par 描述: 25 * 初始化Flash模块。 26 * @attention 27 * @retval #0 success. 28 * @retval #非0 failed.详见hi_errno.h 29 * 30 * @par Dependency: 31 * <ul><li>hi_loaderboot_flash.h: 该接口声明所在的头文件.</li></ul> 32 * @see 33 */ 34 hi_u32 hi_flash_init(hi_void); 35 36 /** 37 * @ingroup hct_boot_flash 38 * @brief flash数据删除 39 * 40 * @par 描述: 41 * 删除flash上的数据内容。 42 * @attention 43 * 44 * @param flash_addr [IN] 类型 #hi_u32 待删除Flash的起始地址 45 * @param flash_erase_size [IN] 类型 #hi_u32 待删除的Flash内容长度 46 * 47 * @retval #0 success. 48 * @retval #非0 failed.详见hi_errno.h 49 * 50 * @par Dependency: 51 * <ul><li>hi_loaderboot_flash.h: 该接口声明所在的头文件.</li></ul> 52 * @see hi_flash_write|hi_flash_read 53 */ 54 hi_u32 hi_flash_erase(const hi_u32 flash_addr, hi_u32 flash_erase_size); 55 56 /** 57 * @ingroup hct_boot_flash 58 * @brief flash数据写入 59 * 60 * @par 描述: 61 * 向flash上的写入数据内容。 62 * @attention 63 * @li 只有在flash初始化时,配置flash回读比较空间才可以使用do_erase为HI_TRUE的选项。具体配置方法参考kernel下hi_flash_init实现。 64 * 65 * @param flash_addr [IN] 类型 #hi_u32 Flash的起始地址 66 * @param flash_write_size [IN] 类型 #hi_u32 待写入Flash的数据长度 67 * @param flash_write_data [IN] 类型 #hi_u8* 待写入Flash的数据内容 68 * @param do_erase [IN] 类型 #hi_bool HI_FALSE:直接写FLASH HI_TRUE:写之前擦除操作区域对应的sector空间,用户操作空间写用户数据其它空间回写历史数据。 69 * 70 * @retval #0 success. 71 * @retval #非0 failed.详见hi_errno.h 72 * 73 * @par Dependency: 74 * <ul><li>hi_loaderboot_flash.h: 该接口声明所在的头文件.</li></ul> 75 * @see hi_flash_erase|hi_flash_read 76 */ 77 hi_u32 hi_flash_write(hi_u32 flash_addr, hi_u32 flash_write_size, const hi_u8 *flash_write_data, hi_bool do_erase); 78 79 /** 80 * @ingroup hct_boot_flash 81 * @brief flash数据读取 82 * 83 * @par 描述: 84 * 从flash上的读取数据内容。 85 * @attention 86 * 87 * @param flash_addr [IN] 类型 #hi_u32 Flash的起始地址 88 * @param flash_read_size [IN] 类型 #hi_u32 待读取的数据长度 89 * @param flash_read_data [OUT] 类型 #hi_u8* 数据内容缓冲区,用于存放从Flash中读取到的数据 90 * 91 * @retval #0 success. 92 * @retval #非0 failed.详见hi_errno.h 93 * 94 * @par Dependency: 95 * <ul><li>hi_loaderboot_flash.h: 该接口声明所在的头文件.</li></ul> 96 * @see hi_flash_write|hi_flash_erase 97 */ 98 hi_u32 hi_flash_read(hi_u32 flash_addr, hi_u32 flash_read_size, hi_u8 *flash_read_data); 99 #endif 100 101