1 /* 2 * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. 3 * Copyright (c) 2020-2022 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 /****************************** 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) 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 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 #ifdef LOSCFG_KERNEL_SMP 363 #define LOSCFG_KERNEL_CORE_NUM LOSCFG_KERNEL_SMP_CORE_NUM 364 #else 365 #define LOSCFG_KERNEL_CORE_NUM 1 366 #endif 367 368 #define LOSCFG_KERNEL_CPU_MASK ((1 << LOSCFG_KERNEL_CORE_NUM) - 1) 369 370 /** 371 * @ingroup los_config 372 * Version number 373 */ 374 #define _T(x) x 375 #define KERNEL_NAME "Huawei LiteOS" 376 #define KERNEL_SEP " " 377 #define _V(v) _T(KERNEL_NAME)_T(KERNEL_SEP)_T(v) 378 379 /** 380 * @ingroup los_config 381 * The Version number of Public 382 */ 383 #define KERNEL_MAJOR 2 384 #define KERNEL_MINOR 0 385 #define KERNEL_PATCH 0 386 #define KERNEL_ITRE 37 387 388 #define VERSION_NUM(a, b, c, d) (((a) << 24) | ((b) << 16) | (c) << 8 | (d)) 389 #define KERNEL_OPEN_VERSION_NUM VERSION_NUM(KERNEL_MAJOR, KERNEL_MINOR, KERNEL_PATCH, KERNEL_ITRE) 390 391 /****************************** Exception information configuration ******************************/ 392 #ifdef LOSCFG_SAVE_EXCINFO 393 /** 394 * @ingroup los_config 395 * the size of space for recording exception information 396 */ 397 #define EXCINFO_RECORD_BUF_SIZE (16 * 1024) 398 399 /** 400 * @ingroup los_config 401 * the address of space for recording exception information 402 * @attention 403 * <ul> 404 * <li> if uses, the address must be valid in flash, and it should not overlap with other addresses 405 * used to store valid information. </li> 406 * </ul> 407 * 408 */ 409 #define EXCINFO_RECORD_ADDR (0xffffffff) 410 411 /** 412 * @ingroup los_config 413 * @brief define the type of functions for reading or writing exception information. 414 * 415 * @par Description: 416 * <ul> 417 * <li>This definition is used to declare the type of functions for reading or writing exception information</li> 418 * </ul> 419 * @attention 420 * <ul> 421 * <li> "startAddr" must be left to save the exception address space, the size of "buf" is "space" </li> 422 * </ul> 423 * 424 * @param startAddr [IN] Address of storage ,its must be left to save the exception address space 425 * @param space [IN] size of storage.its is also the size of "buf" 426 * @param rwFlag [IN] writer-read flag, 0 for writing,1 for reading, other number is to do nothing. 427 * @param buf [IN] the buffer of storing data. 428 * 429 * @retval none. 430 * @par Dependency: 431 * <ul><li>los_config.h: the header file that contains the type definition.</li></ul> 432 * @see 433 */ 434 typedef VOID (*log_read_write_fn)(UINT32 startAddr, UINT32 space, UINT32 rwFlag, CHAR *buf); 435 436 /** 437 * @ingroup los_config 438 * @brief Register recording exception information function. 439 * 440 * @par Description: 441 * <ul> 442 * <li>This API is used to Register recording exception information function, 443 * and specify location and space and size</li> 444 * </ul> 445 * @attention 446 * <ul> 447 * <li> "startAddr" must be left to save the exception address space, the size of "buf" is "space", 448 * the space of "buf" is malloc or free in user's code </li> 449 * </ul> 450 * 451 * @param startAddr [IN] Address of storage, it must be left to save the exception address space 452 * @param space [IN] size of storage space, it is also the size of "buf" 453 * @param buf [IN] the buffer of storing exception information, the space of "buf" is malloc or free 454 in user's code 455 * @param hook [IN] the function for reading or writing exception information. 456 * 457 * @retval none. 458 * @par Dependency: 459 * <ul><li>los_config.h: the header file that contains the API declaration.</li></ul> 460 * @see 461 */ 462 VOID LOS_ExcInfoRegHook(UINT32 startAddr, UINT32 space, CHAR *buf, log_read_write_fn hook); 463 #endif 464 465 extern UINT32 OsMain(VOID); 466 467 typedef VOID (*SystemRebootFunc)(VOID); 468 VOID OsSetRebootHook(SystemRebootFunc func); 469 SystemRebootFunc OsGetRebootHook(VOID); 470 471 #ifdef __cplusplus 472 #if __cplusplus 473 } 474 #endif /* __cplusplus */ 475 #endif /* __cplusplus */ 476 477 #endif /* _LOS_CONFIG_H */ 478