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 * Description: NV Storage Library Restore factory settings interface 15 */ 16 17 #ifndef NV_RESET_H_ 18 #define NV_RESET_H_ 19 20 #include "nv.h" 21 #include "nv_key.h" 22 #include "errcode.h" 23 24 #ifdef __cplusplus 25 #if __cplusplus 26 extern "C" { 27 #endif /* __cplusplus */ 28 #endif /* __cplusplus */ 29 30 #define RESET_MODE_A 1 31 #define RESET_MODE_B 2 32 33 typedef struct { 34 uint8_t mode; 35 bool region_flag[KEY_ID_REGION_MAX_NUM]; 36 } nv_reset_mode_t; 37 38 errcode_t kv_backup_keys(const nv_backup_mode_t *backup_flag); 39 errcode_t kv_restore_all_keys(void); 40 errcode_t kv_enable_restore_flag(const nv_reset_mode_t *nv_reset_mode); 41 errcode_t kv_backup_copy_unused_page_to_dragpage(uint32_t dragpage_location, uint32_t unused_page_location); 42 43 errcode_t kv_restore_set_region_flag(const bool *flag); 44 errcode_t kv_backup_delete_repeat_key(void); 45 errcode_t kv_backup_write_key(void); 46 errcode_t kv_backup_set_invalid_key(const kv_key_handle_t *key); 47 errcode_t kv_backup_find_write_position(uint16_t required_space, uint32_t *write_position); 48 49 #ifdef __cplusplus 50 #if __cplusplus 51 } 52 #endif /* __cplusplus */ 53 #endif /* __cplusplus */ 54 55 #endif /* NV_RESET_H_ */ 56 57