• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
3  * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice, this list of
9  *    conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12  *    of conditions and the following disclaimer in the documentation and/or other materials
13  *    provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its contributors may be used
16  *    to endorse or promote products derived from this software without specific prior written
17  *    permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 /**
33  * @defgroup los_config System configuration items
34  */
35 
36 #ifndef _LOS_CONFIG_H
37 #define _LOS_CONFIG_H
38 
39 #include "los_tick.h"
40 #include "los_vm_zone.h"
41 
42 #ifdef __cplusplus
43 #if __cplusplus
44 extern "C" {
45 #endif /* __cplusplus */
46 #endif /* __cplusplus */
47 
48 /**
49  * @ingroup los_config
50  * int stack start addr
51  */
52 extern CHAR __int_stack_start;
53 extern CHAR __rodata_start;
54 extern CHAR __rodata_end;
55 extern CHAR __bss_start;
56 extern CHAR __bss_end;
57 extern CHAR __text_start;
58 extern CHAR __text_end;
59 extern CHAR __ram_data_start;
60 extern CHAR __ram_data_end;
61 extern UINT32 __heap_start;
62 extern UINT32 __heap_end;
63 
64 /****************************** System clock module configuration ****************************/
65 /**
66  * @ingroup los_config
67  * System clock (unit: HZ)
68  */
69 #ifndef OS_SYS_CLOCK
70 #define OS_SYS_CLOCK (get_bus_clk())
71 #endif
72 /**
73  * @ingroup los_config
74  * time timer clock (unit: HZ)
75  */
76 #ifndef OS_TIME_TIMER_CLOCK
77 #define OS_TIME_TIMER_CLOCK OS_SYS_CLOCK
78 #endif
79 
80 /**
81  * @ingroup los_config
82  * limit addr range when search for  'func local(frame pointer)' or 'func name'
83  */
84 #ifndef OS_SYS_FUNC_ADDR_START
85 #define OS_SYS_FUNC_ADDR_START ((UINTPTR)&__int_stack_start)
86 #endif
87 #ifndef OS_SYS_FUNC_ADDR_END
88 #define OS_SYS_FUNC_ADDR_END (KERNEL_VMM_BASE + SYS_MEM_SIZE_DEFAULT)
89 #endif
90 
91 /**
92  * @ingroup los_config
93  * Number of Ticks in one second
94  */
95 #ifndef LOSCFG_BASE_CORE_TICK_PER_SECOND
96 #define LOSCFG_BASE_CORE_TICK_PER_SECOND  1000  /* 1ms per tick */
97 #endif
98 
99 /**
100  * @ingroup los_config
101  * Minimum response error accuracy of tick interrupts, number of ticks in one second
102  */
103 #ifndef LOSCFG_BASE_CORE_TICK_PER_SECOND_MINI
104 #define LOSCFG_BASE_CORE_TICK_PER_SECOND_MINI  1000UL  /* 1ms */
105 #endif
106 
107 #if (LOSCFG_BASE_CORE_TICK_PER_SECOND > LOSCFG_BASE_CORE_TICK_PER_SECOND_MINI)
108     #error "LOSCFG_BASE_CORE_TICK_PER_SECOND_MINI must be greater than LOSCFG_BASE_CORE_TICK_PER_SECOND"
109 #endif
110 
111 #if (LOSCFG_BASE_CORE_TICK_PER_SECOND_MINI > 1000UL)
112     #error "LOSCFG_BASE_CORE_TICK_PER_SECOND_MINI must be less than or equal to 1000"
113 #endif
114 
115 /**
116  * @ingroup los_config
117  * Microseconds of adjtime in one second
118  */
119 #ifndef LOSCFG_BASE_CORE_ADJ_PER_SECOND
120 #define LOSCFG_BASE_CORE_ADJ_PER_SECOND 500
121 #endif
122 
123 /**
124  * @ingroup los_config
125  * Sched clock interval
126  */
127 #define SCHED_CLOCK_INTETRVAL_TICKS  LOSCFG_BASE_CORE_TICK_PER_SECOND
128 
129 /**
130  * @ingroup los_config
131  * External configuration item for timer tailoring
132  */
133 #if defined(LOSCFG_BASE_CORE_TICK_HW_TIME) && (LOSCFG_BASE_CORE_TICK_HW_TIME == 0)
134 #undef LOSCFG_BASE_CORE_TICK_HW_TIME
135 #endif
136 /****************************** Hardware interrupt module configuration ******************************/
137 /**
138  * @ingroup los_config
139  * Configuration item for hardware interrupt tailoring
140  */
141 #ifndef LOSCFG_PLATFORM_HWI
142 #define LOSCFG_PLATFORM_HWI
143 #endif
144 
145 /**
146  * @ingroup los_config
147  * Maximum number of used hardware interrupts, including Tick timer interrupts.
148  */
149 #ifndef LOSCFG_PLATFORM_HWI_LIMIT
150 #define LOSCFG_PLATFORM_HWI_LIMIT 96
151 #endif
152 
153 /**
154  * @ingroup los_config
155  * The binary point value decide the maximum preemption level.
156  * If preemption supported, the config value is [0, 1, 2, 3, 4, 5, 6],
157  * to the corresponding preemption level value is [128, 64, 32, 16, 8, 4, 2].
158  */
159 #ifdef LOSCFG_ARCH_INTERRUPT_PREEMPTION
160 #ifndef MAX_BINARY_POINT_VALUE
161 #define MAX_BINARY_POINT_VALUE  4
162 #endif
163 #endif
164 
165 /****************************** Task module configuration ********************************/
166 /**
167  * @ingroup los_config
168  * Minimum stack size.
169  *
170  * 0x800 bytes, aligned on a boundary of 8.
171  * 0x800 bytes, aligned on a boundary of 4.
172  */
173 #ifndef LOS_TASK_MIN_STACK_SIZE
174 #ifdef __LP64__
175 #define LOS_TASK_MIN_STACK_SIZE (ALIGN(0x800, 8))
176 #else
177 #define LOS_TASK_MIN_STACK_SIZE (ALIGN(0x800, 4))
178 #endif
179 #endif
180 
181 /**
182  * @ingroup los_config
183  * Default task priority
184  */
185 #ifndef LOSCFG_BASE_CORE_TSK_DEFAULT_PRIO
186 #define LOSCFG_BASE_CORE_TSK_DEFAULT_PRIO 10
187 #endif
188 
189 /**
190  * @ingroup los_config
191  * Maximum supported number of tasks except the idle task rather than the number of usable tasks
192  */
193 #ifndef LOSCFG_BASE_CORE_TSK_LIMIT
194 #define LOSCFG_BASE_CORE_TSK_LIMIT 128
195 #endif
196 
197 /**
198  * @ingroup los_config
199  * Maximum supported number of process rather than the number of usable processes.
200  */
201 #ifndef LOSCFG_BASE_CORE_PROCESS_LIMIT
202 #define LOSCFG_BASE_CORE_PROCESS_LIMIT 64
203 #endif
204 
205 #if (LOSCFG_BASE_CORE_TSK_LIMIT < LOSCFG_BASE_CORE_PROCESS_LIMIT)
206 #error "The number of tasks must be greater than or equal to the number of processes!"
207 #endif
208 
209 /**
210  * @ingroup los_config
211  * Size of the idle task stack
212  */
213 #ifndef LOSCFG_BASE_CORE_TSK_IDLE_STACK_SIZE
214 #define LOSCFG_BASE_CORE_TSK_IDLE_STACK_SIZE SIZE(0x800)
215 #endif
216 
217 /**
218  * @ingroup los_config
219  * Default task stack size
220  */
221 #ifndef LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE
222 #define LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE SIZE(0x4000)
223 #endif
224 
225 /**
226  * @ingroup los_config
227  * Longest execution time of tasks with the same priorities
228  */
229 #ifndef LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT
230 #define LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT  20000 /* 20ms */
231 #endif
232 
233 /**
234  * @ingroup los_config
235  * Configuration item for task (stack) monitoring module tailoring
236  */
237 #ifndef LOSCFG_BASE_CORE_TSK_MONITOR
238 #define LOSCFG_BASE_CORE_TSK_MONITOR
239 #endif
240 
241 /****************************** Semaphore module configuration ******************************/
242 /**
243  * @ingroup los_config
244  * Configuration item for semaphore module tailoring
245  */
246 #ifndef LOSCFG_BASE_IPC_SEM
247 #define LOSCFG_BASE_IPC_SEM
248 #endif
249 
250 /**
251  * @ingroup los_config
252  * Maximum supported number of semaphores
253  */
254 #ifndef LOSCFG_BASE_IPC_SEM_LIMIT
255 #define LOSCFG_BASE_IPC_SEM_LIMIT 1024
256 #endif
257 
258 /**
259  * @ingroup los_config
260  * Maximum number of semaphores.
261  */
262 #ifndef OS_SEM_COUNT_MAX
263 #define OS_SEM_COUNT_MAX 0xFFFE
264 #endif
265 
266 /****************************** Mutex module configuration ******************************/
267 /**
268  * @ingroup los_config
269  * Configuration item for mutex module tailoring
270  */
271 #ifndef LOSCFG_BASE_IPC_MUX
272 #define LOSCFG_BASE_IPC_MUX
273 #endif
274 
275 /****************************** Queue module configuration ********************************/
276 /**
277  * @ingroup los_config
278  * Configuration item for queue module tailoring
279  */
280 #ifndef LOSCFG_BASE_IPC_QUEUE
281 #define LOSCFG_BASE_IPC_QUEUE
282 #endif
283 
284 /**
285  * @ingroup los_config
286  * Maximum supported number of queues rather than the number of usable queues
287  */
288 #ifndef LOSCFG_BASE_IPC_QUEUE_LIMIT
289 #define LOSCFG_BASE_IPC_QUEUE_LIMIT 1024
290 #endif
291 /****************************** Software timer module configuration **************************/
292 #ifdef LOSCFG_BASE_IPC_QUEUE
293 
294 /**
295  * @ingroup los_config
296  * Configuration item for software timer module tailoring
297  */
298 #ifndef LOSCFG_BASE_CORE_SWTMR_ENABLE
299 #define LOSCFG_BASE_CORE_SWTMR_ENABLE
300 #endif
301 
302 #ifdef LOSCFG_BASE_CORE_SWTMR_ENABLE
303 #define LOSCFG_BASE_CORE_SWTMR 1
304 #else
305 #define LOSCFG_BASE_CORE_SWTMR 0
306 #endif
307 
308 /**
309  * @ingroup los_config
310  * Maximum supported number of software timers rather than the number of usable software timers
311  */
312 #ifndef LOSCFG_BASE_CORE_SWTMR_LIMIT
313 #define LOSCFG_BASE_CORE_SWTMR_LIMIT 1024
314 #endif
315 /**
316  * @ingroup los_config
317  * Max number of software timers ID
318  *
319  * 0xFFFF: max number of all software timers
320  */
321 #ifndef OS_SWTMR_MAX_TIMERID
322 #define OS_SWTMR_MAX_TIMERID ((0xFFFF / LOSCFG_BASE_CORE_SWTMR_LIMIT) * LOSCFG_BASE_CORE_SWTMR_LIMIT)
323 #endif
324 /**
325  * @ingroup los_config
326  * Maximum size of a software timer queue
327  */
328 #ifndef OS_SWTMR_HANDLE_QUEUE_SIZE
329 #define OS_SWTMR_HANDLE_QUEUE_SIZE LOSCFG_BASE_CORE_SWTMR_LIMIT
330 #endif
331 #endif
332 
333 
334 /****************************** Memory module configuration **************************/
335 /**
336  * @ingroup los_config
337  * Starting address of the system memory
338  */
339 #ifndef OS_SYS_MEM_ADDR
340 #define OS_SYS_MEM_ADDR                        (&m_aucSysMem1[0])
341 #endif
342 
343 /**
344  * @ingroup los_config
345  * Memory size
346  */
347 #ifndef OS_SYS_MEM_SIZE
348 #define OS_SYS_MEM_SIZE \
349     ((OS_SYS_FUNC_ADDR_END) - (((UINTPTR)&__bss_end + (64 - 1)) & ~(64 - 1)))
350 #endif
351 
352 /****************************** SMP module configuration **************************/
353 #ifdef LOSCFG_KERNEL_SMP
354 #define LOSCFG_KERNEL_CORE_NUM                          LOSCFG_KERNEL_SMP_CORE_NUM
355 #else
356 #define LOSCFG_KERNEL_CORE_NUM                          1
357 #endif
358 
359 #define LOSCFG_KERNEL_CPU_MASK                          ((1 << LOSCFG_KERNEL_CORE_NUM) - 1)
360 
361 /**
362  * @ingroup los_config
363  * Version number
364  */
365 #define _T(x)                                   x
366 #define KERNEL_NAME                            "Huawei LiteOS"
367 #define KERNEL_SEP                             " "
368 #define _V(v)                                  _T(KERNEL_NAME)_T(KERNEL_SEP)_T(v)
369 
370 /**
371  * @ingroup los_config
372  * The Version number of Public
373  */
374 #define KERNEL_MAJOR                     2
375 #define KERNEL_MINOR                     0
376 #define KERNEL_PATCH                     0
377 #define KERNEL_ITRE                      37
378 
379 #define VERSION_NUM(a, b, c, d) (((a) << 24) | ((b) << 16) | (c) << 8 | (d))
380 #define KERNEL_OPEN_VERSION_NUM VERSION_NUM(KERNEL_MAJOR, KERNEL_MINOR, KERNEL_PATCH, KERNEL_ITRE)
381 
382 /****************************** Exception information configuration ******************************/
383 #ifdef LOSCFG_SAVE_EXCINFO
384 /**
385  * @ingroup los_config
386  * the size of space for recording exception information
387  */
388 #define EXCINFO_RECORD_BUF_SIZE (16 * 1024)
389 
390 /**
391  * @ingroup los_config
392  * the address of space for recording exception information
393  * @attention
394  * <ul>
395  * <li> if uses, the address must be valid in flash, and it should not overlap with other addresses
396  * used to store valid information. </li>
397  * </ul>
398  *
399  */
400 #define EXCINFO_RECORD_ADDR (0xffffffff)
401 
402 /**
403  * @ingroup los_config
404  * @brief  define the type of functions for reading or writing exception information.
405  *
406  * @par Description:
407  * <ul>
408  * <li>This definition is used to declare the type of functions for reading or writing exception information</li>
409  * </ul>
410  * @attention
411  * <ul>
412  * <li> "startAddr" must be left to save the exception address space, the size of "buf" is "space"  </li>
413  * </ul>
414  *
415  * @param startAddr    [IN] Address of storage ,its must be left to save the exception address space
416  * @param space        [IN] size of storage.its is also the size of "buf"
417  * @param rwFlag       [IN] writer-read flag, 0 for writing,1 for reading, other number is to do nothing.
418  * @param buf          [IN] the buffer of storing data.
419  *
420  * @retval none.
421  * @par Dependency:
422  * <ul><li>los_config.h: the header file that contains the type definition.</li></ul>
423  * @see
424  */
425 typedef VOID (*log_read_write_fn)(UINT32 startAddr, UINT32 space, UINT32 rwFlag, CHAR *buf);
426 
427 /**
428  * @ingroup los_config
429  * @brief Register recording exception information function.
430  *
431  * @par Description:
432  * <ul>
433  * <li>This API is used to Register recording exception information function,
434  * and specify location and space and size</li>
435  * </ul>
436  * @attention
437  * <ul>
438  * <li> "startAddr" must be left to save the exception address space, the size of "buf" is "space",
439  * the space of "buf" is malloc or free in user's code  </li>
440  * </ul>
441  *
442  * @param startAddr    [IN] Address of storage, it must be left to save the exception address space
443  * @param space        [IN] size of storage space, it is also the size of "buf"
444  * @param buf          [IN] the buffer of storing exception information, the space of "buf" is malloc or free
445                             in user's code
446  * @param hook         [IN] the function for reading or writing exception information.
447  *
448  * @retval none.
449  * @par Dependency:
450  * <ul><li>los_config.h: the header file that contains the API declaration.</li></ul>
451  * @see
452  */
453 VOID LOS_ExcInfoRegHook(UINT32 startAddr, UINT32 space, CHAR *buf, log_read_write_fn hook);
454 #endif
455 
456 extern UINT32 OsMain(VOID);
457 
458 typedef VOID (*SystemRebootFunc)(VOID);
459 VOID OsSetRebootHook(SystemRebootFunc func);
460 SystemRebootFunc OsGetRebootHook(VOID);
461 
462 #ifdef __cplusplus
463 #if __cplusplus
464 }
465 #endif /* __cplusplus */
466 #endif /* __cplusplus */
467 
468 #endif /* _LOS_CONFIG_H */
469