1 /* 2 * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 */ 18 #ifndef __HI_CONFIG_H__ 19 #define __HI_CONFIG_H__ 20 /* *************************************************************************** */ 21 #include <hi_types.h> 22 23 /* 24 * 全局模块/子模块ID设置 25 * 注意增减模块个数后,需要增减 HI_MOD_MAX_NUM 26 * SAL : [200, 300) 27 * BSP : [300, 400) -- [12c, 190) 28 * MAC : [500, 600) -- [1F4, 258) 29 * APP : [800, 900) -- [320, 384) 30 */ 31 #ifndef PRODUCT_CFG_DIAG_MODULE_ID_MAX_NUM 32 #define PRODUCT_CFG_DIAG_MODULE_ID_MAX_NUM 60 33 #endif 34 #define HI_MOD_MAX_NUM (PRODUCT_CFG_DIAG_MODULE_ID_MAX_NUM) /* 模块个数 */ 35 36 /* SAL: [200, 300) */ 37 #define HI_MOD_ID_SAL_SYS 201 38 #define HI_MOD_ID_SAL_NVM 203 39 #define HI_MOD_ID_SAL_DIAG 204 40 #define HI_MOD_ID_SAL_DFX 205 41 #define HI_MOD_ID_CPUP_DFX 210 42 #define HI_MOD_ID_CIPHER 211 43 44 /* BSP: [300, 400) */ 45 #define HI_MOD_ID_DRV 300 /* 0x12C */ 46 #define HI_MOD_ID_DRV_SPI 307 /* 0x133 */ 47 #define HI_MOD_ID_DRV_DMA 316 /* 0x13c */ 48 #define HI_MOD_ID_UPG 317 49 #define HI_MOD_ID_WIFI_DRV 400 /* 0x190 */ 50 51 /* APP : [800, 900) */ 52 #define HI_MOD_ID_APP_COMMON 812 /* 32C */ 53 #define HI_MOD_ID_APP_AT 813 /* 32C */ 54 55 /* Module name size in bytes */ 56 #define HI_SYS_MOD_NAME_LEN 16 57 #ifdef __NEW_FILE_ID__ 58 #define HI_DIAG_LOG_MSG_MOD_ID __NEW_MOD_ID__ 59 #define HI_DIAG_LOG_MSG_FILE_ID __NEW_FILE_ID__ 60 #else 61 #define HI_DIAG_LOG_MSG_MOD_ID 0 62 #define HI_DIAG_LOG_MSG_FILE_ID 0 63 #endif 64 65 /* DIAG包缓存单包最大大小设置 */ 66 #define HI_DIAG_BUFFERING_MSG_MAX_LEN 100 67 #define HI_DIAG_BUFFERING_CMD_MAX_LEN 100 68 69 /* DAIG 通道 中 缓存队列 大小设置 */ 70 #define HI_DIAG_BUFFERING_MSG_NUM 5 /* 消息 大于该门限则动态分配内存 */ 71 #define HI_DIAG_BUFFERING_CMD_NUM 2 /* 命令 大于该门限则动态分配内存 */ 72 73 74 /* **************************************************************************** 75 全局静态设置 76 **************************************************************************** */ 77 /* HI_SYS_MSG_PARAM_NUM_MAX-1,由于HISO不支持宏-1,用HI_SYS_MSG_PARAM_NUM_MIN替代HI_SYS_MSG_PARAM_NUM_MIN-1 */ 78 #define HI_SYS_MSG_PARAM_NUM_MAX_AULDATA 2 79 80 #define HI_SYS_MSG_PARAM_NUM_MIN 4 81 #define HI_PLC_MAC_ADDR_LEN 6 82 #define HI_IPV4_ADDR_LEN 4 83 #define HI_PLC_RELAY_NUM_MAX 3 84 85 /* 接收DIAG包最大大小,包括通道帧头和payload */ 86 #define HI_DIAG_PACKET_REQ_CACHE_MAX_SIZE 320 /* 诊断子系统缓存大小,上位机传输数据大于该大小,将被丢弃 */ 87 #define HI_DIAG_PACKET_ACK_MAX_SIZE 1024 /* 限制ACK单包回复数据长度 */ 88 #define HI_DIAG_PACKET_REQ_DATA_MAX_SIZE 320 /* 由于升级传输包需要,必须大于312字节 */ 89 90 /* 任务等待异常 */ 91 #define HI_SYS_TASK_WAIT_EXCEPTION_TIME_OUT 10000 /* ms task wait 异常等待 Sleep */ 92 // ***************************************************************************** 93 #if !defined(HI_HAVE_CROSS_COMPILER_DIAB_AS) 94 #if defined(PRODUCT_CFG_HSO) 95 #undef PRODUCT_CFG_MCORE_RAM_LOW_ADDR 96 #define PRODUCT_CFG_MCORE_RAM_LOW_ADDR 0x0 97 #endif 98 99 // ***************************************************************************** 100 #define HI_SYS_RAM_MAX_ADDR (PRODUCT_CFG_MCORE_RAM_HIGH_ADDR) 101 #define HI_SYS_RAM_ADDR_LIMIT (PRODUCT_CFG_MCORE_RAM_LOW_ADDR) 102 #define HI_ADDR_RAM_BASE ((hi_u32)(HI_SYS_RAM_ADDR_LIMIT)) 103 104 // 可读写的起始地址 105 #if defined(PRODUCT_CFG_PLATFORM_WINDOWS) || defined(PRODUCT_CFG_FEATURE_UT) 106 #define HI_ADDR_USER_WR (0x00001000) 107 #else 108 #define HI_ADDR_USER_WR 0x10000000 109 #endif 110 111 #if defined(PRODUCT_CFG_PLATFORM_WINDOWS) || defined(PRODUCT_CFG_FEATURE_UT) 112 #define HI_ADDR_USER_RAM_START (0x00001000) 113 #undef HI_ADDR_RAM_BASE 114 #define HI_ADDR_RAM_BASE (0x00001000) 115 #define HI_ADDR_USER_RAM_MAX 0xFFFFFFFF 116 #define set_ram_addr(x) if (x == 0) \ 117 x = 0x02000000 118 #else 119 #if defined(PRODUCT_CFG_HSO) 120 #define HI_ADDR_USER_RAM_START (0x00001000) 121 #define HI_ADDR_USER_RAM_MAX 0xFFFFFFFF 122 #define set_ram_addr(x) if (x == 0) \ 123 x = 0x02000000 124 #else 125 #if defined(HI_HAVE_CROSS_COMPILER_DIAB) 126 HI_EXTERN hi_u32 g_wrs_kernel_text_end; 127 #define HI_ADDR_USER_RAM_START (hi_u32)((hi_u32 *)(&g_wrs_kernel_text_end)) 128 #else 129 #define HI_ADDR_USER_RAM_START ((hi_u32)(HI_ADDR_RAM_BASE)) 130 #endif 131 #define HI_ADDR_USER_RAM_MAX (PRODUCT_CFG_MCORE_RAM_MEM_MAX_ADDR) 132 #define set_ram_addr(x) 133 #endif 134 #endif 135 136 #define HI_ADDR_USER_RAM HI_ADDR_USER_RAM_START 137 #define HI_ADDR_CODE_RAM HI_SYS_RAM_ADDR_LIMIT 138 139 /* The total size of the RAM */ 140 HI_EXTERN hi_u32 g_halSectorsRamSize; 141 /* The start address of RAM */ 142 HI_EXTERN hi_void *g_halSectorsRamStart; 143 144 #if !defined(PRODUCT_CFG_FEATURE_UT) 145 #if defined(HAVE_PCLINT_CHECK) /* 底层接口适配, 不参与PCLINT检查 */ 146 #define HI_SYS_ADDR_USER_RAM (HI_SYS_RAM_ADDR_LIMIT) 147 #else 148 #define HI_SYS_ADDR_USER_RAM (((HI_ADDR_USER_RAM) < HI_SYS_RAM_ADDR_LIMIT) ? \ 149 (HI_SYS_RAM_ADDR_LIMIT) : (HI_ADDR_USER_RAM)) 150 #endif 151 #else 152 #define HI_SYS_ADDR_USER_RAM (HI_ADDR_USER_RAM_START) 153 #endif 154 155 #define hi_is_valid_ram_addr(_x) (((hi_u32)(_x) >= (hi_u32)(uintptr_t)g_halSectorsRamStart) && \ 156 ((hi_u32)(_x) < ((hi_u32)(uintptr_t)g_halSectorsRamStart + g_halSectorsRamSize))) 157 158 #define hi_is_valid_code_addr(_x) (_x) 159 160 #if defined(PRODUCT_CFG_MCORE_FLH_LOW_ADDR) 161 #define hi_is_valid_flh_addr(_x) (((hi_u32)(_x) >= (hi_u32)PRODUCT_CFG_MCORE_FLH_LOW_ADDR) && \ 162 ((hi_u32)(_x) < (hi_u32)HI_ADDR_USER_RAM_MAX)) 163 #else 164 #define hi_is_valid_flh_addr(_x) (_x) 165 #endif 166 167 /* 必须等于 HI_SYS_MTSK_MAX_NUM + HI_SYS_ATSK_MAX_NUM 之和, 由于HSO解析问题,这里不使用四则运算表达式 */ 168 #define HI_SYS_TSK_MAX_NUM 20 169 #define HI_SYS_HTSK_MAX_NUM 4 170 #define HI_SYS_MQ_MAX_NUM 10 171 #define HI_SYS_AQ_MAX_NUM 1 172 173 #define HI_SYS_MTSK_MAX_NUM 18 174 #define HI_SYS_ATSK_MAX_NUM 2 175 #define HI_DIAG_DBG_SYNC_SIZE_MAX 3 176 177 178 // ***************************************************************************** 179 // NV范围 180 // ***************************************************************************** 181 /* * 182 * @ingroup iot_nv 183 * 184 * Factory NV area start ID (including this ID).CNcomment:工厂NV区起始ID(包含此ID)。CNend 185 */ 186 #define HI_NV_FACTORY_ID_START 0x0 187 188 /* * 189 * @ingroup iot_nv 190 * 191 * Factory NV area end ID (not included).CNcomment:工厂NV区结束ID(不包含此ID)。CNend 192 */ 193 #define HI_NV_FACTORY_ID_END 0x16 194 195 /* * 196 * @ingroup iot_nv 197 * 198 * Factory NV user area start ID (including this ID).CNcomment:工厂NV区用户区起始ID(包含此ID)。CNend 199 */ 200 #define HI_NV_FACTORY_USR_ID_START HI_NV_FACTORY_ID_END 201 202 /* * 203 * @ingroup iot_nv 204 * 205 * Factory NV user area end ID (not included).CNcomment:工厂NV区用户区结束ID(不包含此ID)。CNend 206 */ 207 #define HI_NV_FACTORY_USR_ID_END 0x20 208 209 /* * 210 * @ingroup iot_nv 211 * 212 * Non factory NV area start ID (including this ID).CNcomment:非工厂NV区起始ID(包含此ID)。CNend 213 */ 214 #define HI_NV_NORMAL_ID_START HI_NV_FACTORY_USR_ID_END 215 216 /* * 217 * @ingroup iot_nv 218 * 219 * Non factory NV user area end ID (not included).CNcomment:非工厂NV区结束ID(不包含此ID)。CNend 220 */ 221 #define HI_NV_NORMAL_ID_END 0x80 222 223 /* **************************************************************************** 224 通道设置 225 **************************************************************************** */ 226 #define HI_DMS_CHL_UART_PORT_DIAG 1 /* DIAG通道支持的UART端口号, 必须小于 HI_DMS_CHL_UART_PORT_NUM_MAX */ 227 #define HI_DMS_CHL_UART_PORT_MAX 1 /* max. */ 228 229 #define HI_DMS_CHL_UART_PORT_NUM_MAX 3 230 #define HI_DMS_CHL_UART_PORT_NUM_MAX2 3 231 232 #define HI_DMS_CHL_MAC_PORT_MIN 0x10 233 234 #if defined(PRODUCT_CFG_SUPPORT_UPG_SEPARATE) 235 #define HI_DMS_CHL_MAC_PORT_UPG 0x12 236 #define HI_DMS_CHL_MAC_PORT_MAX 0x12 237 #else 238 #define HI_DMS_CHL_MAC_PORT_MAX 0x11 239 #endif 240 241 #define HI_DMS_CHL_PORT_ANY 0xFFF0 242 243 #define HI_DIAG_CHL_UART_BLOCK_WRITE_TIMEOUT 10 /* ms block写超时 */ 244 #define HI_DMS_CHL_UART_BLOCK_WRITE_TIMEOUT 10 /* ms block写超时 */ 245 #define HI_DMS_CHL_EXCEPTION_POLLING_WAIT 5000 /* ms task read dev 异常等待Sleep */ 246 #define HI_DMS_CHL_FLASH_BLOCK_WRITE_TIMEOUT 10 /* ms block写超时 */ 247 #define HI_DMS_UART_EXCEPTION_POLLING_WAIT 1000 /* ms UART异常等待Sleep */ 248 #define HI_DMS_CHL_CONNECT_DETECT_NUM 3 /* 通道连接后心跳方式检测客户端的失败的次数 */ 249 #define HI_DMS_CHL_REPORT_PACKET_TIMEOUT 10 /* 批量上报延时 */ 250 #define HI_DIAG_MODULE_SYS 5 /* MSG SYS可配置的类别个数 */ 251 #define HI_DIAG_MODULE_DEV 30 /* MSG DEV可配置的Module个数 */ 252 #define HI_DIAG_MODULE_USR 5 /* MSG USR可配置的类别个数 */ 253 254 #ifndef PRODUCT_CFG_DIAG_MSG_CFG_MAX_NUM 255 #define PRODUCT_CFG_DIAG_MSG_CFG_MAX_NUM 10 256 #endif 257 #define HI_DIAG_MSG_ID_NUM (PRODUCT_CFG_DIAG_MSG_CFG_MAX_NUM) /* 配置的消息个数 */ 258 259 #define HI_DIAG_WAIT_MESSAGE_TIMEOUT 50 /* ms */ 260 #define HI_DIAG_WAI_DIAG_MESSAGE_TIMEOUT 100 /* 上报 DIAG包的最小周期 ms */ 261 262 /* 系统诊断ID定义范围 */ 263 #define HI_DFX_STAT_ID_BASE_SYS 0xA000 /* SYS STAT的包ID范围: [0xA000, 0xF000) */ 264 #define HI_DFX_STAT_ID_MAX_SYS 0xF000 265 266 /* MSG SYS和USR子类别定义(16bit) */ 267 #define HI_MSG_SYS_L0 0xff10 // MSG SYS Level0 268 #define HI_MSG_SYS_L1 0xff20 // MSG SYS Level1 269 #define HI_MSG_SYS_L2 0xff01 // MSG SYS Level2 270 271 #define HI_MSG_USR_L0 0xf3e8 // MSG USR Level0 272 #define HI_MSG_USR_L1 0xf3e9 // MSG USR Level1 273 #define HI_MSG_USR_L2 0xf3ea // MSG USR Level2 274 #define HI_MSG_USR_L3 0xf3eb // MSG USR Level3 275 #define HI_MSG_USR_L4 0xf3ec // MSG USR Level4 276 #define hi_sys_inf_ver(_v, _r, _c, _b, _spc) ((((_v) & 0x07) << 29) | (((_r) & 0x07) << 26) | (((_c) & 0x3F) << 20) 277 278 #endif /* HI_HAVE_CROSS_COMPILER_DIAB_AS */ 279 280 #define DIAG_PROC_TASK_STACK_SIZE 2048 281 #define DIAG_UART_TASK_STACK_SIZE 1536 282 #define FLASH_PROTECT_TASK_STACK_SIZE 1024 283 #define DATA_COLLECT_TASK_STACK_SIZE 2048 /* this statck will destroy after dc finish */ 284 #ifdef HI_BOARD_ASIC 285 #define DIAG_QUEUE_MSG_NUM 48 286 #else 287 #define DIAG_QUEUE_MSG_NUM 100 288 #endif 289 #define DIAG_PROC_TASK_PRIO 25 290 #define DIAG_UART_TASK_PRIO 20 291 #define FLASH_PROTECT_TASK_PRIO 1 292 #define DATA_COLLECT_TASK_PRIO 21 293 294 #define HI_MILLISECOND_PER_TICK 10 295 296 #define PRODUCT_CFG_TASK_PRIO_SC_EXPMONITOR 30 297 #define PRODUCT_CFG_TASK_STACK_SIZE_SC_EXPMONITOR 2048 298 #define PRODUCT_CFG_FLASH_BLOCK_SIZE 0x1000 299 #define PRODUCT_CFG_AUTO_RESET_SYSTEM_TIMEOUT 30000 300 #define PRODUCT_CFG_DEEP_SLEEP_DEFAULT_MAX_MS 30000 301 302 #endif /* __HI_CONFIG_H__ */ 303