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 Async Store Used Hash 15 */ 16 17 #ifndef NV_ASYNC_STORE_H 18 #define NV_ASYNC_STORE_H 19 20 #include "nv.h" 21 #include "nv_store.h" 22 23 #ifdef __cplusplus 24 #if __cplusplus 25 extern "C" { 26 #endif /* __cplusplus */ 27 #endif /* __cplusplus */ 28 29 typedef struct nv_key_map { 30 uint16_t key_id; /* Key ID */ 31 uint16_t key_len : 13; /* Key length */ 32 uint16_t permanent : 1; /* 是否是永久Key */ 33 uint16_t encrypted : 1; /* 是否是加密Key */ 34 uint16_t upgrade : 1; /* 是否可以升级 */ 35 uint8_t kvalue[0]; /* key value */ 36 } nv_key_map_t; 37 38 typedef struct { 39 uint16_t key_id; 40 uintptr_t key_ram_location; 41 } nv_queue_msg_handle_t; 42 43 errcode_t nv_async_read_with_attr(uint16_t key, uint16_t kvalue_max_length, 44 uint16_t *kvalue_length, uint8_t *kvalue, nv_key_attr_t *attr); 45 46 errcode_t nv_async_write_with_attr(uint16_t key, const uint8_t *kvalue, 47 uint16_t kvalue_length, nv_key_attr_t *attr, nv_storage_completed_callback func); 48 49 errcode_t nv_async_init(kv_store_t store, uint8_t num_pages); 50 errcode_t nv_async_flush(void); 51 52 errcode_t nv_key_map_init(kv_store_t store, uint8_t num_pages); 53 54 55 #ifdef __cplusplus 56 #if __cplusplus 57 } 58 #endif /* __cplusplus */ 59 #endif /* __cplusplus */ 60 61 #endif /* NV_ASYNC_STORE_H */