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: KV Storage Library definitions 15 */ 16 17 #ifndef NV_CONFIG_H 18 #define NV_CONFIG_H 19 20 #define NV_TASKS_MAX_NUM 64 /* 可支持的NV保存任务的最大数(多核系统使用) */ 21 #define NV_NORMAL_KVALUE_MAX_LEN 4060 /* 普通NV的最大数据长度 */ 22 #define NV_ENCRYPTED_KVALUE_MAX_LEN 4048 /* 加密NV的最大数据长度 */ 23 24 /* Flash 物理地址起始和结束 */ 25 #define FLASH_PHYSICAL_ADDR_START 0x200000 26 #define FLASH_PHYSICAL_ADDR_END 0xA00000 27 28 #define FLASH_MAPPED_ADDR_START 0x000000 29 #define FLASH_MAPPED_END 0x800000 30 31 #define FLASH_PAGE_SIZE 4096 32 #define KV_PAGE_SIZE FLASH_PAGE_SIZE 33 34 /* NV运行区默认起始地址(物理地址) */ 35 #define KV_STORE_START_ADDR 0x22C000 36 /* NV运行区page数 */ 37 #define KV_STORE_DATA_PAGE_NUM 4 38 /* NV运行区默认长度(不包含备份区) */ 39 #define KV_STORE_DATA_SIZE (KV_STORE_DATA_PAGE_NUM * KV_PAGE_SIZE) 40 41 /* NV备份区默认起始地址(物理地址) */ 42 #define KV_BACKUP_START_ADDR (KV_STORE_START_ADDR + KV_STORE_DATA_SIZE) 43 /* NV备份区page数 */ 44 #define KV_BACKUP_PAGE_NUM 4 45 /* NV备份区默认长度 */ 46 #define KV_BACKUP_DATA_SIZE (KV_BACKUP_PAGE_NUM * KV_PAGE_SIZE) 47 48 /** 49 * Fixed number of pages for each KV store 50 */ 51 /* Consider using NV region contents to determine actual number of pages and stores */ 52 #define KV_STORE_PAGES_SCPU 0 53 #define KV_STORE_PAGES_ACPU 3 54 55 #define MCORE_REGISTER_NV_NOTIFY_MAX_NUM 10 56 57 /* 58 * NV处理数据的块大小(取值范围[128 ~ 4096],必须为16字节倍数) 59 * 此长度影响NV内部处理数据所需的内存大小,如内存紧张,则不宜太大。 60 * 在需要加密NV但又不支持分段加解密的情况下,最好设置为最大值4096,以避免数据被分段处理。 61 */ 62 #define NV_KEY_DATA_CHUNK_LEN 128 63 64 /* 65 * NV支持异步存储时(CONFIG_NV_SUPPORT_ASYNCHRONOUS_STORE特性宏设置为NV_YES)相关配置项 66 * NV_QUEUE_MAX_SIZE:消息队列大小 67 * NV_THREAD_PRIORITY_NUM:NV异步存储线程优先级 68 * NV_BACKET_SIZE: 哈希桶大小 69 * 哈希桶大小建议配置为总NV数量/0.75 70 * 哈希桶过大占用内存较高,过小则影响查询效率 71 */ 72 #define NV_QUEUE_MAX_SIZE 64 73 #define NV_THREAD_PRIORITY_NUM 26 74 #define NV_BACKET_SIZE 22 75 76 /* ------------------------------------- 特性宏定义 ------------------------------------- */ 77 78 #define NV_YES 1 79 #define NV_NO 0 80 81 /* 特性: 支持NV升级 */ 82 #ifndef CONFIG_NV_SUPPORT_OTA_UPDATE 83 #define CONFIG_NV_SUPPORT_OTA_UPDATE NV_YES 84 #endif 85 86 /* 特性: 支持NV备份恢复 */ 87 #ifndef CONFIG_NV_SUPPORT_BACKUP_RESTORE 88 #define CONFIG_NV_SUPPORT_BACKUP_RESTORE NV_YES 89 #endif 90 91 /* 特性: 支持NV加密 */ 92 #ifndef CONFIG_NV_SUPPORT_ENCRYPT 93 #define CONFIG_NV_SUPPORT_ENCRYPT NV_NO 94 #endif 95 96 /* 特性: 支持NV跳过被破坏的NV项 */ 97 #ifndef CONFIG_NV_SUPPORT_SKIP_CORRUPT_KEY 98 #define CONFIG_NV_SUPPORT_SKIP_CORRUPT_KEY NV_YES 99 #endif 100 101 /* 特性: 加密NV使用HASH校验 */ 102 #ifndef CONFIG_NV_SUPPORT_HASH_FOR_CRYPT 103 #define CONFIG_NV_SUPPORT_HASH_FOR_CRYPT NV_NO 104 #endif 105 106 /* NV debug */ 107 #ifndef CONFIG_NV_SUPPORT_DEBUG 108 #define CONFIG_NV_SUPPORT_DEBUG NV_NO 109 #endif 110 111 /* 特性:NV异步存储 */ 112 #ifndef CONFIG_NV_SUPPORT_ASYNCHRONOUS_STORE 113 #define CONFIG_NV_SUPPORT_ASYNCHRONOUS_STORE NV_NO 114 #endif 115 116 /* 特性:NV使用CRC16替换CRC32 */ 117 #ifndef CONFIG_NV_SUPPORT_CRC16_VERIFY 118 #define CONFIG_NV_SUPPORT_CRC16_VERIFY NV_NO 119 #endif 120 121 /* 特性:NV备份单独存放 */ 122 #ifndef CONFIG_NV_SUPPORT_BACKUP_REGION 123 #define CONFIG_NV_SUPPORT_BACKUP_REGION NV_YES 124 #endif 125 126 /* 特性:NV备份区支持升级 */ 127 #ifndef CONFIG_NV_SUPPORT_BACKUP_UPGRADE 128 #define CONFIG_NV_SUPPORT_BACKUP_UPGRADE NV_NO 129 #endif 130 131 #endif /* NV_CONFIG_H */ 132 133