• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * @file hi_config.h
3  *
4  * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef __HI_CONFIG_H__
19 #define __HI_CONFIG_H__
20 /*****************************************************************************/
21 #include <hi_types_base.h>
22 
23 /*
24  * Global module/submodule ID setting.CNcomment:全局模块/子模块ID设置
25  * Note that HI_MOD_MAX_NUM needs to be increased or decreased after the number of modules is increased or decreased.
26  * CNcomment:注意增减模块个数后,需要增减 HI_MOD_MAX_NUM
27  * SAL : [200, 300)
28  * BSP : [300, 400)   -- [12c, 190)
29  * MAC : [500, 600)   -- [1F4, 258)
30  * APP : [800, 900)   -- [320, 384)
31  */
32 #ifndef PRODUCT_CFG_DIAG_MODULE_ID_MAX_NUM
33 #define PRODUCT_CFG_DIAG_MODULE_ID_MAX_NUM 60
34 #endif
35 #define HI_MOD_MAX_NUM    (PRODUCT_CFG_DIAG_MODULE_ID_MAX_NUM) /* Number of Modules */
36 
37 /* SAL: [200,  300) */
38 #define HI_MOD_ID_SAL_SYS    201
39 #define HI_MOD_ID_SAL_NVM    203
40 #define HI_MOD_ID_SAL_DIAG   204
41 #define HI_MOD_ID_SAL_DFX    205
42 #define HI_MOD_ID_CPUP_DFX   210
43 #define HI_MOD_ID_CIPHER     211
44 
45 /* BSP: [300, 400) */
46 #define HI_MOD_ID_DRV        300 /* 0x12C */
47 #define HI_MOD_ID_DRV_SPI    307 /* 0x133 */
48 #define HI_MOD_ID_DRV_DMA    316 /* 0x13c */
49 #define HI_MOD_ID_UPG        317
50 #define HI_MOD_ID_CRYPTO     318
51 #define HI_MOD_ID_I2S        319
52 #define HI_MOD_ID_UART       320
53 #define HI_MOD_ID_WIFI_DRV       400 /* 0x190 */
54 
55 /* APP : [800, 900) */
56 #define HI_MOD_ID_APP_COMMON 812 /* 32C */
57 #define HI_MOD_ID_APP_AT     813 /* 32C */
58 
59 /* Module name size in bytes */
60 #define HI_SYS_MOD_NAME_LEN 16
61 #ifdef __NEW_FILE_ID__
62 #define HI_DIAG_LOG_MSG_MOD_ID  __NEW_MOD_ID__
63 #define HI_DIAG_LOG_MSG_FILE_ID __NEW_FILE_ID__
64 #else
65 #define HI_DIAG_LOG_MSG_MOD_ID  0
66 #define HI_DIAG_LOG_MSG_FILE_ID 0
67 #endif
68 
69 /* Maximum size of a single DIAG packet buffer.CNcomment:DIAG包缓存单包最大大小设置 */
70 #define HI_DIAG_BUFFERING_MSG_MAX_LEN 100
71 #define HI_DIAG_BUFFERING_CMD_MAX_LEN 100
72 
73 /* Sets the buffer queue size in a DAIG channel. CNcomment:DAIG 通道中缓存队列大小设置 */
74 /* Messages,if the memory usage is greater than the threshold, the memory is dynamically allocated.
75    CNcomment:消息 大于该门限则动态分配内存 */
76 #define HI_DIAG_BUFFERING_MSG_NUM 5
77 /* Command,if the memory usage is greater than the threshold, the memory is dynamically allocated.
78    CNcomment:命令 大于该门限则动态分配内存 */
79 #define HI_DIAG_BUFFERING_CMD_NUM 2
80 
81 
82 /*****************************************************************************
83  Global Static Settings
84  *****************************************************************************/
85 #define HI_MAC_ADDR_LEN      6
86 
87 /* Maximum size of the received DIAG packet, including the channel frame header and payload.
88    CNcomment:接收DIAG包最大大小,包括通道帧头和payload */
89 #define HI_DIAG_PACKET_REQ_CACHE_MAX_SIZE 320
90 #define HI_DIAG_PACKET_ACK_MAX_SIZE       1024
91 #define HI_DIAG_PACKET_REQ_DATA_MAX_SIZE  320
92 
93 /* Task waiting exception. */
94 #define HI_SYS_TASK_WAIT_EXCEPTION_TIME_OUT 10000
95 
96 /* The total size of the RAM */
97 HI_EXTERN hi_u32 g_halSectorsRamSize;
98 /* The start address of RAM */
99 HI_EXTERN hi_void *g_halSectorsRamStart;
100 
101 #define hi_is_valid_ram_addr(_x) (((hi_u32)(_x) >= (hi_u32)(uintptr_t)g_halSectorsRamStart) && \
102     ((hi_u32)(_x) < ((hi_u32)(uintptr_t)g_halSectorsRamStart + (uintptr_t)g_halSectorsRamSize)))
103 #define hi_is_valid_code_addr(_x) (_x)
104 
105 
106 /*******************************************************************************
107    NV range
108  *****************************************************************************/
109 /**
110 * @ingroup  iot_nv
111 *
112 * Factory NV area start ID (including this ID).CNcomment:工厂NV区起始ID(包含此ID)。CNend
113 */
114 #define HI_NV_FACTORY_ID_START      0x0
115 
116 /**
117 * @ingroup  iot_nv
118 *
119 * Factory NV area end ID (not included).CNcomment:工厂NV区结束ID(不包含此ID)。CNend
120 */
121 #define HI_NV_FACTORY_ID_END        0x16
122 
123 /**
124 * @ingroup  iot_nv
125 *
126 * Factory NV user area start ID (including this ID).CNcomment:工厂NV区用户区起始ID(包含此ID)。CNend
127 */
128 #define HI_NV_FACTORY_USR_ID_START   HI_NV_FACTORY_ID_END
129 
130 /**
131 * @ingroup  iot_nv
132 *
133 * Factory NV user area end ID (not included).CNcomment:工厂NV区用户区结束ID(不包含此ID)。CNend
134 */
135 #define HI_NV_FACTORY_USR_ID_END    0x20
136 
137 /**
138 * @ingroup  iot_nv
139 *
140 * Non factory NV area start ID (including this ID).CNcomment:非工厂NV区起始ID(包含此ID)。CNend
141 */
142 #define HI_NV_NORMAL_ID_START        HI_NV_FACTORY_USR_ID_END
143 
144 /**
145 * @ingroup  iot_nv
146 *
147 * Non factory NV user area end ID (not included).CNcomment:非工厂NV区结束ID(不包含此ID)。CNend
148 */
149 #define HI_NV_NORMAL_ID_END          0x80
150 
151 /**
152 * @ingroup  iot_nv
153 *
154 * Non factory NV Upgrade Reserved area start ID (including this ID).CNcomment:非工厂NV升级保留区起始ID(包含此ID)。CNend
155 */
156 #define HI_NV_STABLE_ID_START         HI_NV_NORMAL_ID_END
157 
158 /**
159 * @ingroup  iot_nv
160 *
161 * Non factory NV Upgrade Reserved area end ID (not included).CNcomment:非工厂NV升级保留区结束ID(不包含此ID)。CNend
162 */
163 #define HI_NV_STABLE_ID_END           0x98
164 
165 /**
166 * @ingroup  hct_nv
167 *
168 * Non factory NV user Upgrade Reserved area start ID (including this ID).
169   CNcomment:非工厂NV升级保留区用户区起始ID(包含此ID)。CNend
170 */
171 #define HI_NV_STABLE_USR_ID_START     HI_NV_STABLE_ID_END
172 
173 /**
174 * @ingroup  iot_nv
175 *
176 * Non factory NV user Upgrade Reserved area end ID (not included).
177   CNcomment:非工厂NV升级保留区用户区结束ID(不包含此ID)。CNend
178 */
179 #define HI_NV_STABLE_USR_ID_END       0xA0
180 
181 /**
182 * @ingroup  iot_nv
183 *
184 * Non factory NV user Reserved area start ID (including this ID).CNcomment:非工厂NV区用户预留区起始ID(包含此ID)。CNend
185 */
186 #define HI_NV_NORMAL_USR_ID_START     HI_NV_STABLE_USR_ID_END
187 
188 /**
189 * @ingroup  hct_nv
190 *
191 * Non factory NV user Reserved area end ID (including this ID).CNcomment:非工厂NV区用户预留区结束ID(包含此ID)。CNend
192 */
193 #define HI_NV_NORMAL_USR_ID_END       0xFF
194 
195 /*****************************************************************************
196  Channel Settings
197 *****************************************************************************/
198 /* UART port number supported by the DIAG channel. The value must be smaller than the value of
199    HI_DMS_CHL_UART_PORT_NUM_MAX. CNcomment:DIAG通道支持的UART端口号, 必须小于 HI_DMS_CHL_UART_PORT_NUM_MAX */
200 #define HI_DMS_CHL_UART_PORT_DIAG 1 /*  */
201 #define HI_DMS_CHL_PORT_ANY     0xFFF0
202 
203 #define HI_DIAG_CHL_UART_BLOCK_WRITE_TIMEOUT 10    /* ms block write timeout */
204 #define HI_DMS_CHL_UART_BLOCK_WRITE_TIMEOUT  10    /* ms block write timeout */
205 #define HI_DMS_CHL_EXCEPTION_POLLING_WAIT    5000  /* ms task read dev task waiting exception Sleep */
206 #define HI_DMS_CHL_FLASH_BLOCK_WRITE_TIMEOUT 10    /* ms block write timeout */
207 #define HI_DMS_UART_EXCEPTION_POLLING_WAIT   1000  /* ms UART waiting exception Sleep */
208 #define HI_DMS_CHL_CONNECT_DETECT_NUM        3     /* Number of client detection failures in heartbeat
209                                                       mode after the channel is connected */
210 #define HI_DMS_CHL_REPORT_PACKET_TIMEOUT     10    /* Batch report delay */
211 #define HI_DIAG_MODULE_SYS                   5     /* MSG SYS numbers of configurable categories */
212 #define HI_DIAG_MODULE_DEV                   30    /* MSG DEV numbers of configurable Module */
213 #define HI_DIAG_MODULE_USR                   5     /* MSG USR numbers of configurable categories */
214 
215 #ifndef PRODUCT_CFG_DIAG_MSG_CFG_MAX_NUM
216 #define PRODUCT_CFG_DIAG_MSG_CFG_MAX_NUM     10
217 #endif
218 #define HI_DIAG_MSG_ID_NUM (PRODUCT_CFG_DIAG_MSG_CFG_MAX_NUM)  /* Number of configuration messages */
219 
220 #define HI_DIAG_WAIT_MESSAGE_TIMEOUT         50  /* ms */
221 #define HI_DIAG_WAI_DIAG_MESSAGE_TIMEOUT     100 /* Minimum interval for reporting DIAG packets. ms */
222 
223 /* Definition range of system diagnosis IDs.CNcomment:系统诊断ID定义范围 */
224 #define HI_DFX_STAT_ID_BASE_SYS 0xA000  /* SYS STAT的包ID范围: [0xA000, 0xF000) */
225 #define HI_DFX_STAT_ID_MAX_SYS  0xF000
226 
227 /* MSG SYS USR Subcategory Definition(16bit) */
228 #define HI_MSG_SYS_L0 0xff10 // MSG SYS Level0
229 #define HI_MSG_SYS_L1 0xff20 // MSG SYS Level1
230 #define HI_MSG_SYS_L2 0xff01 // MSG SYS Level2
231 
232 #define HI_MSG_USR_L0 0xf3e8 // MSG USR Level0
233 #define HI_MSG_USR_L1 0xf3e9 // MSG USR Level1
234 #define HI_MSG_USR_L2 0xf3ea // MSG USR Level2
235 #define HI_MSG_USR_L3 0xf3eb // MSG USR Level3
236 #define HI_MSG_USR_L4 0xf3ec // MSG USR Level4
237 
238 #define DIAG_PROC_TASK_STACK_SIZE    2048
239 #define DIAG_UART_TASK_STACK_SIZE    1536
240 #define FLASH_PROTECT_TASK_STACK_SIZE 1024
241 #define DATA_COLLECT_TASK_STACK_SIZE 2048    /* this statck will destroy after dc finish */
242 
243 #ifdef HI_BOARD_ASIC
244 #define DIAG_QUEUE_MSG_NUM           48
245 #else
246 #define DIAG_QUEUE_MSG_NUM           100
247 #endif
248 #define DIAG_PROC_TASK_PRIO          25
249 #define DIAG_UART_TASK_PRIO          20
250 #define FLASH_PROTECT_TASK_PRIO      1
251 #define DATA_COLLECT_TASK_PRIO       21
252 
253 #define HI_MILLISECOND_PER_TICK  10
254 
255 #define PRODUCT_CFG_FLASH_BLOCK_SIZE             0x1000
256 #define PRODUCT_CFG_AUTO_WDG_RESET_SYSTEM_TIMEOUT    30000
257 
258 #if (PRODUCT_CFG_AUTO_WDG_RESET_SYSTEM_TIMEOUT < 6500)
259 #error "watchdog timeout value must be more than 6500ms!"
260 #endif
261 
262 #define PRODUCT_CFG_DEEP_SLEEP_DEFAULT_MAX_MS    (0xFFFFFFFF / 64)
263 
264 #endif /* __HI_CONFIG_H__ */
265 
266