更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
los_config.h
浏览该文件的文档.
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
44extern "C" {
45#endif /* __cplusplus */
46#endif /* __cplusplus */
47
48/**
49 * @ingroup los_config
50 * int stack start addr | 值在链接时赋予,详见liteos.ld文件
51 */
52extern CHAR __int_stack_start; ///< 运行系统函数栈的开始地址 值来自于 liteos.ld中的 __int_stack_start = .;
53extern CHAR __rodata_start; ///< ROM开始地址 只读
54extern CHAR __rodata_end; ///< ROM结束地址
55extern CHAR __bss_start; ///< bss开始地址 __attribute__((section(".__bss_start")));
56extern CHAR __bss_end; ///< bss结束地址 __attribute__((section(".__bss_end")));
57extern CHAR __text_start; ///< 代码区开始地址
58extern CHAR __text_end; ///< 代码区结束地址
59extern CHAR __ram_data_start; ///< RAM开始地址 可读可写
60extern CHAR __ram_data_end; ///< RAM结束地址
61extern UINT32 __heap_start; ///< 堆区开始地址
62extern 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 ///< HZ:是每秒中的周期性变动重复次数的计量
70#define OS_SYS_CLOCK (get_bus_clk()) ///< 系统主时钟频率 例如:50000000 即20纳秒
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
137/****************************** Hardware interrupt module configuration ******************************/
138/**
139 * @ingroup los_config
140 * Configuration item for hardware interrupt tailoring
141 */
142#ifndef LOSCFG_PLATFORM_HWI ///< 硬件中断裁剪配置项
143#define LOSCFG_PLATFORM_HWI
144#endif
145
146/**
147 * @ingroup los_config
148 * Maximum number of used hardware interrupts, including Tick timer interrupts.
149 */
150#ifndef LOSCFG_PLATFORM_HWI_LIMIT
151#define LOSCFG_PLATFORM_HWI_LIMIT 96 ///< 硬件中断最大数量
152#endif
153
154/**
155 * @ingroup los_config
156 * The binary point value decide the maximum preemption level.
157 * If preemption supported, the config value is [0, 1, 2, 3, 4, 5, 6],
158 * to the corresponding preemption level value is [128, 64, 32, 16, 8, 4, 2].
159 */
160#ifdef LOSCFG_ARCH_INTERRUPT_PREEMPTION
161#ifndef MAX_BINARY_POINT_VALUE
162#define MAX_BINARY_POINT_VALUE 4
163#endif
164#endif
165
166/****************************** Task module configuration ********************************/
167/**
168 * @ingroup los_config
169 * Minimum stack size.
170 *
171 * 0x600 bytes, aligned on a boundary of 8.
172 * 0x600 bytes, aligned on a boundary of 4.
173 */
174#ifndef LOS_TASK_MIN_STACK_SIZE
175#ifdef __LP64__
176#define LOS_TASK_MIN_STACK_SIZE (ALIGN(0x800, 8))
177#else
178#define LOS_TASK_MIN_STACK_SIZE (ALIGN(0x800, 4))
179#endif
180#endif
181
182/**
183 * @ingroup los_config
184 * Default task priority
185 */
186#ifndef LOSCFG_BASE_CORE_TSK_DEFAULT_PRIO ///< 内核任务默认优先级
187#define LOSCFG_BASE_CORE_TSK_DEFAULT_PRIO 10
188#endif
189
190/**
191 * @ingroup los_config
192 * Maximum supported number of tasks except the idle task rather than the number of usable tasks
193 */
194#ifndef LOSCFG_BASE_CORE_TSK_LIMIT ///< 支持的最大任务数(空闲任务除外,而不是可用任务数)
195#define LOSCFG_BASE_CORE_TSK_LIMIT 128
196#endif
197
198/**
199 * @ingroup los_config
200 * Maximum supported number of process rather than the number of usable processes.
201 */
202#ifndef LOSCFG_BASE_CORE_PROCESS_LIMIT ///< 支持的最大进程数,而不是可用进程数
203#define LOSCFG_BASE_CORE_PROCESS_LIMIT 64
204#endif
205
206#if (LOSCFG_BASE_CORE_TSK_LIMIT < LOSCFG_BASE_CORE_PROCESS_LIMIT)
207#error "The number of tasks must be greater than or equal to the number of processes!"
208#endif
209
210/**
211 * @ingroup los_config
212 * Size of the idle task stack
213 */
214#ifndef LOSCFG_BASE_CORE_TSK_IDLE_STACK_SIZE ///< 空闲任务栈大小
215#define LOSCFG_BASE_CORE_TSK_IDLE_STACK_SIZE SIZE(0x800) ///< 2K
216#endif
217
218/**
219 * @ingroup los_config
220 * Default task stack size
221 */
222#ifndef LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE //内核默认任务栈大小
223#define LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE SIZE(0x4000) ///< 16K
224#endif
225
226/**
227 * @ingroup los_config
228 * Longest execution time of tasks with the same priorities
229 */
230#ifndef LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT //相同优先级任务的最长执行时间,时间片
231#define LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT 20000 /* 20ms */
232#endif
233
234/**
235 * @ingroup los_config
236 * Configuration item for task (stack) monitoring module tailoring
237 */
238#ifndef LOSCFG_BASE_CORE_TSK_MONITOR //任务(栈)监控模块裁剪配置项
239#define LOSCFG_BASE_CORE_TSK_MONITOR
240#endif
241
242/****************************** Semaphore module configuration ******************************/
243/**
244 * @ingroup los_config
245 * Configuration item for semaphore module tailoring
246 */
247#ifndef LOSCFG_BASE_IPC_SEM
248#define LOSCFG_BASE_IPC_SEM //信号量支持
249#endif
250
251/**
252 * @ingroup los_config
253 * Maximum supported number of semaphores
254 */
255#ifndef LOSCFG_BASE_IPC_SEM_LIMIT
256#define LOSCFG_BASE_IPC_SEM_LIMIT 1024 //信号量的最大个数
257#endif
258
259/**
260 * @ingroup los_config
261 * Maximum number of semaphores.
262 */
263#ifndef OS_SEM_COUNT_MAX
264#define OS_SEM_COUNT_MAX 0xFFFE
265#endif
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/****************************** rwlock module configuration ******************************/
276/**
277 * @ingroup los_config
278 * Configuration item for rwlock module tailoring
279 */
280#ifndef LOSCFG_BASE_IPC_RWLOCK
281#define LOSCFG_BASE_IPC_RWLOCK
282#endif
283
284/****************************** Queue module configuration ********************************/
285/**
286 * @ingroup los_config
287 * Configuration item for queue module tailoring
288 */
289#ifndef LOSCFG_BASE_IPC_QUEUE
290#define LOSCFG_BASE_IPC_QUEUE
291#endif
292
293/**
294 * @ingroup los_config
295 * Maximum supported number of queues rather than the number of usable queues
296 */
297#ifndef LOSCFG_BASE_IPC_QUEUE_LIMIT
298#define LOSCFG_BASE_IPC_QUEUE_LIMIT 1024 //队列个数
299#endif
300/****************************** Software timer module configuration **************************/
301#ifdef LOSCFG_BASE_IPC_QUEUE
302
303/**
304 * @ingroup los_config
305 * Configuration item for software timer module tailoring
306 */
307#ifndef LOSCFG_BASE_CORE_SWTMR_ENABLE
308#define LOSCFG_BASE_CORE_SWTMR_ENABLE
309#endif
310
311#ifdef LOSCFG_BASE_CORE_SWTMR_ENABLE
312#define LOSCFG_BASE_CORE_SWTMR 1
313#else
314#define LOSCFG_BASE_CORE_SWTMR 0
315#endif
316
317/**
318 * @ingroup los_config
319 * Maximum supported number of software timers rather than the number of usable software timers
320 */
321#ifndef LOSCFG_BASE_CORE_SWTMR_LIMIT
322#define LOSCFG_BASE_CORE_SWTMR_LIMIT 1024 // 最大支持的软件定时器数
323#endif
324/**
325 * @ingroup los_config
326 * Max number of software timers ID
327 *
328 * 0xFFFF: max number of all software timers | 所有软件定时器的最大数量
329 */
330#ifndef OS_SWTMR_MAX_TIMERID
331#define OS_SWTMR_MAX_TIMERID ((0xFFFF / LOSCFG_BASE_CORE_SWTMR_LIMIT) * LOSCFG_BASE_CORE_SWTMR_LIMIT) ///< 65535
332#endif
333/**
334 * @ingroup los_config
335 * Maximum size of a software timer queue
336 */
337#ifndef OS_SWTMR_HANDLE_QUEUE_SIZE
338#define OS_SWTMR_HANDLE_QUEUE_SIZE LOSCFG_BASE_CORE_SWTMR_LIMIT ///< 软时钟队列的大小
339#endif
340#endif
341
342
343/****************************** Memory module configuration **************************/
344/**
345 * @ingroup los_config
346 * Starting address of the system memory
347 */
348#ifndef OS_SYS_MEM_ADDR
349#define OS_SYS_MEM_ADDR (&m_aucSysMem1[0])//系统内存起始地址(指虚拟地址)
350#endif
351
352/**
353 * @ingroup los_config
354 * Memory size
355 */
356#ifndef OS_SYS_MEM_SIZE //系统动态内存池的大小(DDR自适应配置),以byte为单位,从bss段末尾至系统DDR末尾
357#define OS_SYS_MEM_SIZE \
358 ((OS_SYS_FUNC_ADDR_END) - (((UINTPTR)&__bss_end + (64 - 1)) & ~(64 - 1)))
359#endif
360
361/****************************** SMP module configuration **************************/
362//http://www.gotw.ca/publications/concurrency-ddj.htm 免费午餐结束了:软件并发的根本转变
363#ifdef LOSCFG_KERNEL_SMP
364#define LOSCFG_KERNEL_CORE_NUM LOSCFG_KERNEL_SMP_CORE_NUM //多核情况下支持的CPU核数
365#else
366#define LOSCFG_KERNEL_CORE_NUM 1 //单核配置
367#endif
368
369#define LOSCFG_KERNEL_CPU_MASK ((1 << LOSCFG_KERNEL_CORE_NUM) - 1) //CPU掩码,每一个核占用一个位,用于计算和定位具体CPU核
370
371/**
372 * @ingroup los_config
373 * Version number
374 */
375#define _T(x) x
376#define KERNEL_NAME "Huawei LiteOS"
377#define KERNEL_SEP " "
378#define _V(v) _T(KERNEL_NAME)_T(KERNEL_SEP)_T(v)
379
380/**
381 * @ingroup los_config
382 * The Version number of Public //Public的版本号 ,每个占8位,刚好一个字节
383 */
384#define KERNEL_MAJOR 2 //主版本号
385#define KERNEL_MINOR 0 //小版本号
386#define KERNEL_PATCH 0 //补丁版本号
387#define KERNEL_ITRE 37
388
389#define VERSION_NUM(a, b, c, d) (((a) << 24) | ((b) << 16) | (c) << 8 | (d))
390#define KERNEL_OPEN_VERSION_NUM VERSION_NUM(KERNEL_MAJOR, KERNEL_MINOR, KERNEL_PATCH, KERNEL_ITRE)
391
392/****************************** Exception information configuration ******************************/
393#ifdef LOSCFG_SAVE_EXCINFO
394/**
395 * @ingroup los_config
396 * the size of space for recording exception information
397 */
398#define EXCINFO_RECORD_BUF_SIZE (16 * 1024) //记录异常信息缓存大小 16K
399
400/**
401 * @ingroup los_config
402 * the address of space for recording exception information
403 * @attention
404 * <ul>
405 * <li> if uses, the address must be valid in flash, and it should not overlap with other addresses
406 * used to store valid information. </li>
407 * </ul>
408 *
409 */
410#define EXCINFO_RECORD_ADDR (0xffffffff) //记录异常信息的空间地址
411
412/**
413 * @ingroup los_config
414 * @brief define the type of functions for reading or writing exception information.
415 *
416 * @par Description:
417 * <ul>
418 * <li>This defination is used to declare the type of functions for reading or writing exception information</li>
419 * </ul>
420 * @attention
421 * <ul>
422 * <li> "startAddr" must be left to save the exception address space, the size of "buf" is "space" </li>
423 * </ul>
424 *
425 * @param startAddr [IN] Address of storage ,its must be left to save the exception address space
426 * @param space [IN] size of storage.its is also the size of "buf"
427 * @param rwFlag [IN] writer-read flag, 0 for writing,1 for reading, other number is to do nothing.
428 * @param buf [IN] the buffer of storing data.
429 *
430 * @retval none.
431 * @par Dependency:
432 * <ul><li>los_config.h: the header file that contains the type defination.</li></ul>
433 * @see
434 */ //定义用于读取或写入异常信息的指针函数类型
435typedef VOID (*log_read_write_fn)(UINT32 startAddr, UINT32 space, UINT32 rwFlag, CHAR *buf);
436
437/**
438 * @ingroup los_config
439 * @brief Register recording exception information function.
440 *
441 * @par Description:
442 * <ul>
443 * <li>This API is used to Register recording exception information function,
444 * and specify location and space and size</li>
445 * </ul>
446 * @attention
447 * <ul>
448 * <li> "startAddr" must be left to save the exception address space, the size of "buf" is "space",
449 * the space of "buf" is malloc or free in user's code </li>
450 * </ul>
451 *
452 * @param startAddr [IN] Address of storage, it must be left to save the exception address space
453 * @param space [IN] size of storage space, it is also the size of "buf"
454 * @param buf [IN] the buffer of storing exception information, the space of "buf" is malloc or free
455 in user's code
456 * @param hook [IN] the function for reading or writing exception information.
457 *
458 * @retval none.
459 * @par Dependency:
460 * <ul><li>los_config.h: the header file that contains the API declaration.</li></ul>
461 * @see
462 */
463/**
464* 此API用于注册记录异常信息函数,并指定位置、空间和大小
465* startAddr: 保存发送异常的地址信息的启始地址
466* space: buf的大小
467* buf: 缓存区
468* hook: 读写异常信息的函数
469*/
470VOID LOS_ExcInfoRegHook(UINT32 startAddr, UINT32 space, CHAR *buf, log_read_write_fn hook);
471#endif
472
473extern UINT32 OsMain(VOID);
474
475typedef VOID (*SystemRebootFunc)(VOID);
478#ifdef __cplusplus
479#if __cplusplus
480}
481#endif /* __cplusplus */
482#endif /* __cplusplus */
483
484#endif /* _LOS_CONFIG_H */
CHAR __int_stack_start
运行系统函数栈的开始地址 值来自于 liteos.ld中的 __int_stack_start = .;
VOID(* log_read_write_fn)(UINT32 startAddr, UINT32 space, UINT32 rwFlag, CHAR *buf)
define the type of functions for reading or writing exception information.
Definition: los_config.h:435
VOID LOS_ExcInfoRegHook(UINT32 startAddr, UINT32 space, CHAR *buf, log_read_write_fn hook)
Register recording exception information function.
Definition: los_excinfo.c:122
SystemRebootFunc OsGetRebootHook(VOID)
获取系统重启钩子函数
Definition: los_config.c:63
CHAR __text_end
代码区结束地址
CHAR __ram_data_end
RAM结束地址
VOID OsSetRebootHook(SystemRebootFunc func)
设置系统重启钩子函数
Definition: los_config.c:58
VOID(* SystemRebootFunc)(VOID)
Definition: los_config.h:475
CHAR __rodata_end
ROM结束地址
CHAR __bss_start
bss开始地址 attribute((section(".__bss_start")));
CHAR __ram_data_start
RAM开始地址 可读可写
UINT32 __heap_start
堆区开始地址
CHAR __bss_end
bss结束地址 attribute((section(".__bss_end")));
UINT32 __heap_end
堆区结束地址
CHAR __text_start
代码区开始地址
CHAR __rodata_start
ROM开始地址 只读
UINT32 OsMain(VOID)
由汇编调用,鸿蒙C语言层级的入口点
Definition: los_config.c:186
unsigned int UINT32
Definition: los_typedef.h:57
char CHAR
Definition: los_typedef.h:63