ChibiOS/RT Architecture - Reference Manual - Guides |
00001 /* 00002 ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. 00003 00004 This file is part of ChibiOS/RT. 00005 00006 ChibiOS/RT is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 3 of the License, or 00009 (at your option) any later version. 00010 00011 ChibiOS/RT is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 00019 --- 00020 00021 A special exception to the GPL can be applied should you wish to distribute 00022 a combined work that includes ChibiOS/RT, without being obliged to provide 00023 the source code for any proprietary components. See the file exception.txt 00024 for full details of how and when the exception can be applied. 00025 */ 00026 00027 /** 00028 * @file templates/chconf.h 00029 * @brief Configuration file template. 00030 * @details A copy of this file must be placed in each project directory, it 00031 * contains the application specific kernel settings. 00032 * 00033 * @addtogroup config 00034 * @details Kernel related settings and hooks. 00035 * @{ 00036 */ 00037 00038 #ifndef _CHCONF_H_ 00039 #define _CHCONF_H_ 00040 00041 /*===========================================================================*/ 00042 /* Kernel parameters. */ 00043 /*===========================================================================*/ 00044 00045 /** 00046 * @brief System tick frequency. 00047 * @details Frequency of the system timer that drives the system ticks. This 00048 * setting also defines the system tick time unit. 00049 */ 00050 #if !defined(CH_FREQUENCY) || defined(__DOXYGEN__) 00051 #define CH_FREQUENCY 1000 00052 #endif 00053 00054 /** 00055 * @brief Round robin interval. 00056 * @details This constant is the number of system ticks allowed for the 00057 * threads before preemption occurs. Setting this value to zero 00058 * disables the preemption for threads with equal priority and the 00059 * round robin becomes cooperative. Note that higher priority 00060 * threads can still preempt, the kernel is always preemptive. 00061 * 00062 * @note Disabling the round robin preemption makes the kernel more compact 00063 * and generally faster. 00064 */ 00065 #if !defined(CH_TIME_QUANTUM) || defined(__DOXYGEN__) 00066 #define CH_TIME_QUANTUM 20 00067 #endif 00068 00069 /** 00070 * @brief Nested locks. 00071 * @details If enabled then the use of nested @p chSysLock() / @p chSysUnlock() 00072 * operations is allowed.<br> 00073 * For performance and code size reasons the recommended setting 00074 * is to leave this option disabled.<br> 00075 * You may use this option if you need to merge ChibiOS/RT with 00076 * external libraries that require nested lock/unlock operations. 00077 * 00078 * @note T he default is @p FALSE. 00079 */ 00080 #if !defined(CH_USE_NESTED_LOCKS) || defined(__DOXYGEN__) 00081 #define CH_USE_NESTED_LOCKS FALSE 00082 #endif 00083 00084 /** 00085 * @brief Managed RAM size. 00086 * @details Size of the RAM area to be managed by the OS. If set to zero 00087 * then the whole available RAM is used. The core memory is made 00088 * available to the heap allocator and/or can be used directly through 00089 * the simplified core memory allocator. 00090 * 00091 * @note In order to let the OS manage the whole RAM the linker script must 00092 * provide the @p __heap_base__ and @p __heap_end__ symbols. 00093 * @note Requires @p CH_USE_COREMEM. 00094 */ 00095 #if !defined(CH_MEMCORE_SIZE) || defined(__DOXYGEN__) 00096 #define CH_MEMCORE_SIZE 0 00097 #endif 00098 00099 /*===========================================================================*/ 00100 /* Performance options. */ 00101 /*===========================================================================*/ 00102 00103 /** 00104 * @brief OS optimization. 00105 * @details If enabled then time efficient rather than space efficient code 00106 * is used when two possible implementations exist. 00107 * 00108 * @note This is not related to the compiler optimization options. 00109 * @note The default is @p TRUE. 00110 */ 00111 #if !defined(CH_OPTIMIZE_SPEED) || defined(__DOXYGEN__) 00112 #define CH_OPTIMIZE_SPEED TRUE 00113 #endif 00114 00115 /** 00116 * @brief Exotic optimization. 00117 * @details If defined then a CPU register is used as storage for the global 00118 * @p currp variable. Caching this variable in a register greatly 00119 * improves both space and time OS efficiency. A side effect is that 00120 * one less register has to be saved during the context switch 00121 * resulting in lower RAM usage and faster context switch. 00122 * 00123 * @note This option is only usable with the GCC compiler and is only useful 00124 * on processors with many registers like ARM cores. 00125 * @note If this option is enabled then ALL the libraries linked to the 00126 * ChibiOS/RT code <b>must</b> be recompiled with the GCC option @p 00127 * -ffixed-@<reg@>. 00128 * @note This option must be enabled in the Makefile, it is listed here for 00129 * documentation only. 00130 */ 00131 #if defined(__DOXYGEN__) 00132 #define CH_CURRP_REGISTER_CACHE "reg" 00133 #endif 00134 00135 /*===========================================================================*/ 00136 /* Subsystem options. */ 00137 /*===========================================================================*/ 00138 00139 /** 00140 * @brief Threads registry APIs. 00141 * @details If enabled then the registry APIs are included in the kernel. 00142 * 00143 * @note The default is @p TRUE. 00144 */ 00145 #if !defined(CH_USE_REGISTRY) || defined(__DOXYGEN__) 00146 #define CH_USE_REGISTRY TRUE 00147 #endif 00148 00149 /** 00150 * @brief Threads synchronization APIs. 00151 * @details If enabled then the @p chThdWait() function is included in 00152 * the kernel. 00153 * 00154 * @note The default is @p TRUE. 00155 */ 00156 #if !defined(CH_USE_WAITEXIT) || defined(__DOXYGEN__) 00157 #define CH_USE_WAITEXIT TRUE 00158 #endif 00159 00160 /** 00161 * @brief Semaphores APIs. 00162 * @details If enabled then the Semaphores APIs are included in the kernel. 00163 * 00164 * @note The default is @p TRUE. 00165 */ 00166 #if !defined(CH_USE_SEMAPHORES) || defined(__DOXYGEN__) 00167 #define CH_USE_SEMAPHORES TRUE 00168 #endif 00169 00170 /** 00171 * @brief Semaphores queuing mode. 00172 * @details If enabled then the threads are enqueued on semaphores by 00173 * priority rather than in FIFO order. 00174 * 00175 * @note The default is @p FALSE. Enable this if you have special requirements. 00176 * @note Requires @p CH_USE_SEMAPHORES. 00177 */ 00178 #if !defined(CH_USE_SEMAPHORES_PRIORITY) || defined(__DOXYGEN__) 00179 #define CH_USE_SEMAPHORES_PRIORITY FALSE 00180 #endif 00181 00182 /** 00183 * @brief Atomic semaphore API. 00184 * @details If enabled then the semaphores the @p chSemSignalWait() API 00185 * is included in the kernel. 00186 * 00187 * @note The default is @p TRUE. 00188 * @note Requires @p CH_USE_SEMAPHORES. 00189 */ 00190 #if !defined(CH_USE_SEMSW) || defined(__DOXYGEN__) 00191 #define CH_USE_SEMSW TRUE 00192 #endif 00193 00194 /** 00195 * @brief Mutexes APIs. 00196 * @details If enabled then the mutexes APIs are included in the kernel. 00197 * 00198 * @note The default is @p TRUE. 00199 */ 00200 #if !defined(CH_USE_MUTEXES) || defined(__DOXYGEN__) 00201 #define CH_USE_MUTEXES TRUE 00202 #endif 00203 00204 /** 00205 * @brief Conditional Variables APIs. 00206 * @details If enabled then the conditional variables APIs are included 00207 * in the kernel. 00208 * 00209 * @note The default is @p TRUE. 00210 * @note Requires @p CH_USE_MUTEXES. 00211 */ 00212 #if !defined(CH_USE_CONDVARS) || defined(__DOXYGEN__) 00213 #define CH_USE_CONDVARS TRUE 00214 #endif 00215 00216 /** 00217 * @brief Conditional Variables APIs with timeout. 00218 * @details If enabled then the conditional variables APIs with timeout 00219 * specification are included in the kernel. 00220 * 00221 * @note The default is @p TRUE. 00222 * @note Requires @p CH_USE_CONDVARS. 00223 */ 00224 #if !defined(CH_USE_CONDVARS_TIMEOUT) || defined(__DOXYGEN__) 00225 #define CH_USE_CONDVARS_TIMEOUT TRUE 00226 #endif 00227 00228 /** 00229 * @brief Events Flags APIs. 00230 * @details If enabled then the event flags APIs are included in the kernel. 00231 * 00232 * @note The default is @p TRUE. 00233 */ 00234 #if !defined(CH_USE_EVENTS) || defined(__DOXYGEN__) 00235 #define CH_USE_EVENTS TRUE 00236 #endif 00237 00238 /** 00239 * @brief Events Flags APIs with timeout. 00240 * @details If enabled then the events APIs with timeout specification 00241 * are included in the kernel. 00242 * 00243 * @note The default is @p TRUE. 00244 * @note Requires @p CH_USE_EVENTS. 00245 */ 00246 #if !defined(CH_USE_EVENTS_TIMEOUT) || defined(__DOXYGEN__) 00247 #define CH_USE_EVENTS_TIMEOUT TRUE 00248 #endif 00249 00250 /** 00251 * @brief Synchronous Messages APIs. 00252 * @details If enabled then the synchronous messages APIs are included 00253 * in the kernel. 00254 * 00255 * @note The default is @p TRUE. 00256 */ 00257 #if !defined(CH_USE_MESSAGES) || defined(__DOXYGEN__) 00258 #define CH_USE_MESSAGES TRUE 00259 #endif 00260 00261 /** 00262 * @brief Synchronous Messages queuing mode. 00263 * @details If enabled then messages are served by priority rather than in 00264 * FIFO order. 00265 * 00266 * @note The default is @p FALSE. Enable this if you have special requirements. 00267 * @note Requires @p CH_USE_MESSAGES. 00268 */ 00269 #if !defined(CH_USE_MESSAGES_PRIORITY) || defined(__DOXYGEN__) 00270 #define CH_USE_MESSAGES_PRIORITY FALSE 00271 #endif 00272 00273 /** 00274 * @brief Mailboxes APIs. 00275 * @details If enabled then the asynchronous messages (mailboxes) APIs are 00276 * included in the kernel. 00277 * 00278 * @note The default is @p TRUE. 00279 * @note Requires @p CH_USE_SEMAPHORES. 00280 */ 00281 #if !defined(CH_USE_MAILBOXES) || defined(__DOXYGEN__) 00282 #define CH_USE_MAILBOXES TRUE 00283 #endif 00284 00285 /** 00286 * @brief I/O Queues APIs. 00287 * @details If enabled then the I/O queues APIs are included in the kernel. 00288 * 00289 * @note The default is @p TRUE. 00290 * @note Requires @p CH_USE_SEMAPHORES. 00291 */ 00292 #if !defined(CH_USE_QUEUES) || defined(__DOXYGEN__) 00293 #define CH_USE_QUEUES TRUE 00294 #endif 00295 00296 /** 00297 * @brief Core Memory Manager APIs. 00298 * @details If enabled then the core memory manager APIs are included 00299 * in the kernel. 00300 * 00301 * @note The default is @p TRUE. 00302 */ 00303 #if !defined(CH_USE_MEMCORE) || defined(__DOXYGEN__) 00304 #define CH_USE_MEMCORE TRUE 00305 #endif 00306 00307 /** 00308 * @brief Heap Allocator APIs. 00309 * @details If enabled then the memory heap allocator APIs are included 00310 * in the kernel. 00311 * 00312 * @note The default is @p TRUE. 00313 * @note Requires @p CH_USE_COREMEM and either @p CH_USE_MUTEXES or 00314 * @p CH_USE_SEMAPHORES. 00315 * @note Mutexes are recommended. 00316 */ 00317 #if !defined(CH_USE_HEAP) || defined(__DOXYGEN__) 00318 #define CH_USE_HEAP TRUE 00319 #endif 00320 00321 /** 00322 * @brief C-runtime allocator. 00323 * @details If enabled the the heap allocator APIs just wrap the C-runtime 00324 * @p malloc() and @p free() functions. 00325 * 00326 * @note The default is @p FALSE. 00327 * @note Requires @p CH_USE_HEAP. 00328 * @note The C-runtime may or may not require @p CH_USE_COREMEM, see the 00329 * appropriate documentation. 00330 */ 00331 #if !defined(CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__) 00332 #define CH_USE_MALLOC_HEAP FALSE 00333 #endif 00334 00335 /** 00336 * @brief Memory Pools Allocator APIs. 00337 * @details If enabled then the memory pools allocator APIs are included 00338 * in the kernel. 00339 * 00340 * @note The default is @p TRUE. 00341 */ 00342 #if !defined(CH_USE_MEMPOOLS) || defined(__DOXYGEN__) 00343 #define CH_USE_MEMPOOLS TRUE 00344 #endif 00345 00346 /** 00347 * @brief Dynamic Threads APIs. 00348 * @details If enabled then the dynamic threads creation APIs are included 00349 * in the kernel. 00350 * 00351 * @note The default is @p TRUE. 00352 * @note Requires @p CH_USE_WAITEXIT. 00353 * @note Requires @p CH_USE_HEAP and/or @p CH_USE_MEMPOOLS. 00354 */ 00355 #if !defined(CH_USE_DYNAMIC) || defined(__DOXYGEN__) 00356 #define CH_USE_DYNAMIC TRUE 00357 #endif 00358 00359 /*===========================================================================*/ 00360 /* Debug options. */ 00361 /*===========================================================================*/ 00362 00363 /** 00364 * @brief Debug option, parameters checks. 00365 * @details If enabled then the checks on the API functions input 00366 * parameters are activated. 00367 * 00368 * @note The default is @p FALSE. 00369 */ 00370 #if !defined(CH_DBG_ENABLE_CHECKS) || defined(__DOXYGEN__) 00371 #define CH_DBG_ENABLE_CHECKS FALSE 00372 #endif 00373 00374 /** 00375 * @brief Debug option, consistency checks. 00376 * @details If enabled then all the assertions in the kernel code are 00377 * activated. This includes consistency checks inside the kernel, 00378 * runtime anomalies and port-defined checks. 00379 * 00380 * @note The default is @p FALSE. 00381 */ 00382 #if !defined(CH_DBG_ENABLE_ASSERTS) || defined(__DOXYGEN__) 00383 #define CH_DBG_ENABLE_ASSERTS FALSE 00384 #endif 00385 00386 /** 00387 * @brief Debug option, trace buffer. 00388 * @details If enabled then the context switch circular trace buffer is 00389 * activated. 00390 * 00391 * @note The default is @p FALSE. 00392 */ 00393 #if !defined(CH_DBG_ENABLE_TRACE) || defined(__DOXYGEN__) 00394 #define CH_DBG_ENABLE_TRACE FALSE 00395 #endif 00396 00397 /** 00398 * @brief Debug option, stack checks. 00399 * @details If enabled then a runtime stack check is performed. 00400 * 00401 * @note The default is @p FALSE. 00402 * @note The stack check is performed in a architecture/port dependent way. 00403 * It may not be implemented or some ports. 00404 * @note The default failure mode is to halt the system with the global 00405 * @p panic_msg variable set to @p NULL. 00406 */ 00407 #if !defined(CH_DBG_ENABLE_STACK_CHECK) || defined(__DOXYGEN__) 00408 #define CH_DBG_ENABLE_STACK_CHECK FALSE 00409 #endif 00410 00411 /** 00412 * @brief Debug option, stacks initialization. 00413 * @details If enabled then the threads working area is filled with a byte 00414 * value when a thread is created. This can be useful for the 00415 * runtime measurement of the used stack. 00416 * 00417 * @note The default is @p FALSE. 00418 */ 00419 #if !defined(CH_DBG_FILL_THREADS) || defined(__DOXYGEN__) 00420 #define CH_DBG_FILL_THREADS FALSE 00421 #endif 00422 00423 /** 00424 * @brief Debug option, threads profiling. 00425 * @details If enabled then a field is added to the @p Thread structure that 00426 * counts the system ticks occurred while executing the thread. 00427 * 00428 * @note The default is @p TRUE. 00429 * @note This debug option is defaulted to TRUE because it is required by 00430 * some test cases into the test suite. 00431 */ 00432 #if !defined(CH_DBG_THREADS_PROFILING) || defined(__DOXYGEN__) 00433 #define CH_DBG_THREADS_PROFILING TRUE 00434 #endif 00435 00436 /*===========================================================================*/ 00437 /* Kernel hooks. */ 00438 /*===========================================================================*/ 00439 00440 /** 00441 * @brief Threads descriptor structure hook. 00442 * @details User fields added to the end of the @p Thread structure. 00443 */ 00444 #if !defined(THREAD_EXT_FIELDS) || defined(__DOXYGEN__) 00445 #define THREAD_EXT_FIELDS \ 00446 struct { \ 00447 /* Add threads custom fields here.*/ \ 00448 }; 00449 #endif 00450 00451 /** 00452 * @brief Threads initialization hook. 00453 * @details User initialization code added to the @p chThdInit() API. 00454 * 00455 * @note It is invoked from within @p chThdInit() and implicitily from all 00456 * the threads creation APIs. 00457 */ 00458 #if !defined(THREAD_EXT_INIT) || defined(__DOXYGEN__) 00459 #define THREAD_EXT_INIT(tp) { \ 00460 /* Add threads initialization code here.*/ \ 00461 } 00462 #endif 00463 00464 /** 00465 * @brief Threads finalization hook. 00466 * @details User finalization code added to the @p chThdExit() API. 00467 * 00468 * @note It is inserted into lock zone. 00469 * @note It is also invoked when the threads simply return in order to 00470 * terminate. 00471 */ 00472 #if !defined(THREAD_EXT_EXIT) || defined(__DOXYGEN__) 00473 #define THREAD_EXT_EXIT(tp) { \ 00474 /* Add threads finalization code here.*/ \ 00475 } 00476 #endif 00477 00478 /** 00479 * @brief Idle Loop hook. 00480 * @details This hook is continuously invoked by the idle thread loop. 00481 */ 00482 #if !defined(IDLE_LOOP_HOOK) || defined(__DOXYGEN__) 00483 #define IDLE_LOOP_HOOK() { \ 00484 /* Idle loop code here.*/ \ 00485 } 00486 #endif 00487 00488 /*===========================================================================*/ 00489 /* Port-specific settings (override port settings defaulted in chcore.h). */ 00490 /*===========================================================================*/ 00491 00492 #endif /* _CHCONF_H_ */ 00493 00494 /** @} */