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 #include "sys_config.h" 42 43 #ifdef __cplusplus 44 #if __cplusplus 45 extern "C" { 46 #endif /* __cplusplus */ 47 #endif /* __cplusplus */ 48 49 /** 50 * @ingroup los_config 51 * int stack start addr 52 */ 53 extern CHAR __int_stack_start; 54 extern CHAR __rodata_start; 55 extern CHAR __rodata_end; 56 extern CHAR __bss_start; 57 extern CHAR __bss_end; 58 extern CHAR __text_start; 59 extern CHAR __text_end; 60 extern CHAR __ram_data_start; 61 extern CHAR __ram_data_end; 62 extern UINT32 __heap_start; 63 extern UINT32 __heap_end; 64 65 /****************************** System clock module configuration ****************************/ 66 /** 67 * @ingroup los_config 68 * System clock (unit: HZ) 69 */ 70 #ifndef OS_SYS_CLOCK 71 #define OS_SYS_CLOCK (get_bus_clk()) 72 #endif 73 /** 74 * @ingroup los_config 75 * time timer clock (unit: HZ) 76 */ 77 #ifndef OS_TIME_TIMER_CLOCK 78 #define OS_TIME_TIMER_CLOCK OS_SYS_CLOCK 79 #endif 80 81 /** 82 * @ingroup los_config 83 * limit addr range when search for 'func local(frame pointer)' or 'func name' 84 */ 85 #ifndef OS_SYS_FUNC_ADDR_START 86 #define OS_SYS_FUNC_ADDR_START ((UINTPTR)&__int_stack_start) 87 #endif 88 #ifndef OS_SYS_FUNC_ADDR_END 89 #define OS_SYS_FUNC_ADDR_END (KERNEL_VMM_BASE + SYS_MEM_SIZE_DEFAULT) 90 #endif 91 92 /** 93 * @ingroup los_config 94 * Number of Ticks in one second 95 */ 96 #ifndef LOSCFG_BASE_CORE_TICK_PER_SECOND 97 #define LOSCFG_BASE_CORE_TICK_PER_SECOND 1000 /* 1ms per tick */ 98 #endif 99 100 /** 101 * @ingroup los_config 102 * Minimum response error accuracy of tick interrupts, number of ticks in one second 103 */ 104 #ifndef LOSCFG_BASE_CORE_TICK_PER_SECOND_MINI 105 #define LOSCFG_BASE_CORE_TICK_PER_SECOND_MINI 1000UL /* 1ms */ 106 #endif 107 108 #if (LOSCFG_BASE_CORE_TICK_PER_SECOND > LOSCFG_BASE_CORE_TICK_PER_SECOND_MINI) 109 #error "LOSCFG_BASE_CORE_TICK_PER_SECOND_MINI must be greater than LOSCFG_BASE_CORE_TICK_PER_SECOND" 110 #endif 111 112 #if (LOSCFG_BASE_CORE_TICK_PER_SECOND_MINI > 1000UL) 113 #error "LOSCFG_BASE_CORE_TICK_PER_SECOND_MINI must be less than or equal to 1000" 114 #endif 115 116 /** 117 * @ingroup los_config 118 * Microseconds of adjtime in one second 119 */ 120 #ifndef LOSCFG_BASE_CORE_ADJ_PER_SECOND 121 #define LOSCFG_BASE_CORE_ADJ_PER_SECOND 500 122 #endif 123 124 /** 125 * @ingroup los_config 126 * Sched clck interval 127 */ 128 #define SCHED_CLOCK_INTETRVAL_TICKS LOSCFG_BASE_CORE_TICK_PER_SECOND 129 130 /** 131 * @ingroup los_config 132 * External configuration item for timer tailoring 133 */ 134 #if defined(LOSCFG_BASE_CORE_TICK_HW_TIME) && (LOSCFG_BASE_CORE_TICK_HW_TIME == 0) 135 #undef LOSCFG_BASE_CORE_TICK_HW_TIME 136 #endif 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 * 0x800 bytes, aligned on a boundary of 8. 172 * 0x800 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) 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) 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 267 /****************************** Mutex module configuration ******************************/ 268 /** 269 * @ingroup los_config 270 * Configuration item for mutex module tailoring 271 */ 272 #ifndef LOSCFG_BASE_IPC_MUX 273 #define LOSCFG_BASE_IPC_MUX 274 #endif 275 276 /****************************** Queue module configuration ********************************/ 277 /** 278 * @ingroup los_config 279 * Configuration item for queue module tailoring 280 */ 281 #ifndef LOSCFG_BASE_IPC_QUEUE 282 #define LOSCFG_BASE_IPC_QUEUE 283 #endif 284 285 /** 286 * @ingroup los_config 287 * Maximum supported number of queues rather than the number of usable queues 288 */ 289 #ifndef LOSCFG_BASE_IPC_QUEUE_LIMIT 290 #define LOSCFG_BASE_IPC_QUEUE_LIMIT 1024 291 #endif 292 /****************************** Software timer module configuration **************************/ 293 #ifdef LOSCFG_BASE_IPC_QUEUE 294 295 /** 296 * @ingroup los_config 297 * Configuration item for software timer module tailoring 298 */ 299 #ifndef LOSCFG_BASE_CORE_SWTMR_ENABLE 300 #define LOSCFG_BASE_CORE_SWTMR_ENABLE 301 #endif 302 303 #ifdef LOSCFG_BASE_CORE_SWTMR_ENABLE 304 #define LOSCFG_BASE_CORE_SWTMR 1 305 #else 306 #define LOSCFG_BASE_CORE_SWTMR 0 307 #endif 308 309 /** 310 * @ingroup los_config 311 * Maximum supported number of software timers rather than the number of usable software timers 312 */ 313 #ifndef LOSCFG_BASE_CORE_SWTMR_LIMIT 314 #define LOSCFG_BASE_CORE_SWTMR_LIMIT 1024 315 #endif 316 /** 317 * @ingroup los_config 318 * Max number of software timers ID 319 * 320 * 0xFFFF: max number of all software timers 321 */ 322 #ifndef OS_SWTMR_MAX_TIMERID 323 #define OS_SWTMR_MAX_TIMERID ((0xFFFF / LOSCFG_BASE_CORE_SWTMR_LIMIT) * LOSCFG_BASE_CORE_SWTMR_LIMIT) 324 #endif 325 /** 326 * @ingroup los_config 327 * Maximum size of a software timer queue 328 */ 329 #ifndef OS_SWTMR_HANDLE_QUEUE_SIZE 330 #define OS_SWTMR_HANDLE_QUEUE_SIZE LOSCFG_BASE_CORE_SWTMR_LIMIT 331 #endif 332 #endif 333 334 335 /****************************** Memory module configuration **************************/ 336 /** 337 * @ingroup los_config 338 * Starting address of the system memory 339 */ 340 #ifndef OS_SYS_MEM_ADDR 341 #define OS_SYS_MEM_ADDR (&m_aucSysMem1[0]) 342 #endif 343 344 /** 345 * @ingroup los_config 346 * Memory size 347 */ 348 #ifndef OS_SYS_MEM_SIZE 349 #define OS_SYS_MEM_SIZE \ 350 ((OS_SYS_FUNC_ADDR_END) - (((UINTPTR)&__bss_end + (64 - 1)) & ~(64 - 1))) 351 #endif 352 353 /****************************** SMP module configuration **************************/ 354 #ifdef LOSCFG_KERNEL_SMP 355 #define LOSCFG_KERNEL_CORE_NUM LOSCFG_KERNEL_SMP_CORE_NUM 356 #else 357 #define LOSCFG_KERNEL_CORE_NUM 1 358 #endif 359 360 #define LOSCFG_KERNEL_CPU_MASK ((1 << LOSCFG_KERNEL_CORE_NUM) - 1) 361 362 /** 363 * @ingroup los_config 364 * Version number 365 */ 366 #define _T(x) x 367 #define KERNEL_NAME "Huawei LiteOS" 368 #define KERNEL_SEP " " 369 #define _V(v) _T(KERNEL_NAME)_T(KERNEL_SEP)_T(v) 370 371 /** 372 * @ingroup los_config 373 * The Version number of Public 374 */ 375 #define KERNEL_MAJOR 2 376 #define KERNEL_MINOR 0 377 #define KERNEL_PATCH 0 378 #define KERNEL_ITRE 37 379 380 #define VERSION_NUM(a, b, c, d) (((a) << 24) | ((b) << 16) | (c) << 8 | (d)) 381 #define KERNEL_OPEN_VERSION_NUM VERSION_NUM(KERNEL_MAJOR, KERNEL_MINOR, KERNEL_PATCH, KERNEL_ITRE) 382 383 /****************************** Exception information configuration ******************************/ 384 #ifdef LOSCFG_SAVE_EXCINFO 385 /** 386 * @ingroup los_config 387 * the size of space for recording exception information 388 */ 389 #define EXCINFO_RECORD_BUF_SIZE (16 * 1024) 390 391 /** 392 * @ingroup los_config 393 * the address of space for recording exception information 394 * @attention 395 * <ul> 396 * <li> if uses, the address must be valid in flash, and it should not overlap with other addresses 397 * used to store valid information. </li> 398 * </ul> 399 * 400 */ 401 #define EXCINFO_RECORD_ADDR (0xffffffff) 402 403 /** 404 * @ingroup los_config 405 * @brief define the type of functions for reading or writing exception information. 406 * 407 * @par Description: 408 * <ul> 409 * <li>This defination is used to declare the type of functions for reading or writing exception information</li> 410 * </ul> 411 * @attention 412 * <ul> 413 * <li> "startAddr" must be left to save the exception address space, the size of "buf" is "space" </li> 414 * </ul> 415 * 416 * @param startAddr [IN] Address of storage ,its must be left to save the exception address space 417 * @param space [IN] size of storage.its is also the size of "buf" 418 * @param rwFlag [IN] writer-read flag, 0 for writing,1 for reading, other number is to do nothing. 419 * @param buf [IN] the buffer of storing data. 420 * 421 * @retval none. 422 * @par Dependency: 423 * <ul><li>los_config.h: the header file that contains the type defination.</li></ul> 424 * @see 425 */ 426 typedef VOID (*log_read_write_fn)(UINT32 startAddr, UINT32 space, UINT32 rwFlag, CHAR *buf); 427 428 /** 429 * @ingroup los_config 430 * @brief Register recording exception information function. 431 * 432 * @par Description: 433 * <ul> 434 * <li>This API is used to Register recording exception information function, 435 * and specify location and space and size</li> 436 * </ul> 437 * @attention 438 * <ul> 439 * <li> "startAddr" must be left to save the exception address space, the size of "buf" is "space", 440 * the space of "buf" is malloc or free in user's code </li> 441 * </ul> 442 * 443 * @param startAddr [IN] Address of storage, it must be left to save the exception address space 444 * @param space [IN] size of storage space, it is also the size of "buf" 445 * @param buf [IN] the buffer of storing exception information, the space of "buf" is malloc or free 446 in user's code 447 * @param hook [IN] the function for reading or writing exception information. 448 * 449 * @retval none. 450 * @par Dependency: 451 * <ul><li>los_config.h: the header file that contains the API declaration.</li></ul> 452 * @see 453 */ 454 VOID LOS_ExcInfoRegHook(UINT32 startAddr, UINT32 space, CHAR *buf, log_read_write_fn hook); 455 #endif 456 457 extern INT32 OsMain(VOID); 458 459 typedef VOID (*SystemRebootFunc)(VOID); 460 VOID OsSetRebootHook(SystemRebootFunc func); 461 SystemRebootFunc OsGetRebootHook(VOID); 462 463 #ifdef __cplusplus 464 #if __cplusplus 465 } 466 #endif /* __cplusplus */ 467 #endif /* __cplusplus */ 468 469 #endif /* _LOS_CONFIG_H */ 470