TNeoKernel  v1.03
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
tn_cfg_default.h
Go to the documentation of this file.
1 /*******************************************************************************
2  *
3  * TNeoKernel: real-time kernel initially based on TNKernel
4  *
5  * TNKernel: copyright © 2004, 2013 Yuri Tiomkin.
6  * PIC32-specific routines: copyright © 2013, 2014 Anders Montonen.
7  * TNeoKernel: copyright © 2014 Dmitry Frank.
8  *
9  * TNeoKernel was born as a thorough review and re-implementation of
10  * TNKernel. The new kernel has well-formed code, inherited bugs are fixed
11  * as well as new features being added, and it is tested carefully with
12  * unit-tests.
13  *
14  * API is changed somewhat, so it's not 100% compatible with TNKernel,
15  * hence the new name: TNeoKernel.
16  *
17  * Permission to use, copy, modify, and distribute this software in source
18  * and binary forms and its documentation for any purpose and without fee
19  * is hereby granted, provided that the above copyright notice appear
20  * in all copies and that both that copyright notice and this permission
21  * notice appear in supporting documentation.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE DMITRY FRANK AND CONTRIBUTORS "AS IS"
24  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DMITRY FRANK OR CONTRIBUTORS BE
27  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
33  * THE POSSIBILITY OF SUCH DAMAGE.
34  *
35  ******************************************************************************/
36 
37 /**
38  * \file
39  *
40  * TNeoKernel default configuration file, to be copied as `tn_cfg.h`.
41  *
42  * This project is intended to be built as a library, separately from main
43  * project (although nothing prevents you from bundling things together, if you
44  * want to).
45  *
46  * There are various options available which affects API and behavior of the
47  * kernel. But these options are specific for particular project, and aren't
48  * related to the kernel itself, so we need to keep them separately.
49  *
50  * To this end, file `tn.h` (the main kernel header file) includes `tn_cfg.h`,
51  * which isn't included in the repository (even more, it is added to
52  * `.hgignore` list actually). Instead, default configuration file
53  * `tn_cfg_default.h` is provided, and when you just cloned the repository, you
54  * might want to copy it as `tn_cfg.h`. Or even better, if your filesystem
55  * supports symbolic links, copy it somewhere to your main project's directory
56  * (so that you can add it to your VCS there), and create symlink to it named
57  * `tn_cfg.h` in the TNeoKernel source directory, like this:
58  *
59  * $ cd /path/to/tneokernel/src
60  * $ cp ./tn_cfg_default.h /path/to/main/project/lib_cfg/tn_cfg.h
61  * $ ln -s /path/to/main/project/lib_cfg/tn_cfg.h ./tn_cfg.h
62  *
63  * Default configuration file contains detailed comments, so you can read them
64  * and configure behavior as you like.
65  */
66 
67 #ifndef _TN_CFG_DEFAULT_H
68 #define _TN_CFG_DEFAULT_H
69 
70 
71 /*******************************************************************************
72  * USER-DEFINED OPTIONS
73  ******************************************************************************/
74 
75 /**
76  * Number of priorities that can be used by application, plus one for idle task
77  * (which has the lowest priority). This value can't be higher than
78  * architecture-dependent value `#TN_PRIORITIES_MAX_CNT`, which typically
79  * equals to width of `int` type. So, for 32-bit systems, max number of
80  * priorities is 32.
81  *
82  * But usually, application needs much less: I can imagine **at most** 4-5
83  * different priorities, plus one for the idle task.
84  *
85  * Do note also that each possible priority level takes RAM: two pointers for
86  * linked list and one `short` for time slice value, so on 32-bit system it
87  * takes 10 bytes. So, with default value of 32 priorities available, it takes
88  * 320 bytes. If you set it, say, to 5, you save `270` bytes, which might be
89  * notable.
90  *
91  * Default: `#TN_PRIORITIES_MAX_CNT`.
92  */
93 #ifndef TN_PRIORITIES_CNT
94 # define TN_PRIORITIES_CNT TN_PRIORITIES_MAX_CNT
95 #endif
96 
97 /**
98  * Enables additional param checking for most of the system functions.
99  * It's surely useful for debug, but probably better to remove in release.
100  * If it is set, most of the system functions are able to return two additional
101  * codes:
102  *
103  * * `#TN_RC_WPARAM` if wrong params were given;
104  * * `#TN_RC_INVALID_OBJ` if given pointer doesn't point to a valid object.
105  * Object validity is checked by means of the special ID field of type
106  * `enum #TN_ObjId`.
107  *
108  * @see `enum #TN_ObjId`
109  */
110 #ifndef TN_CHECK_PARAM
111 # define TN_CHECK_PARAM 1
112 #endif
113 
114 /**
115  * Allows additional internal self-checking, useful to catch internal
116  * TNeoKernel bugs as well as illegal kernel usage (e.g. sleeping in the idle
117  * task callback). Produces a couple of extra instructions which usually just
118  * causes debugger to stop if something goes wrong.
119  */
120 #ifndef TN_DEBUG
121 # define TN_DEBUG 0
122 #endif
123 
124 /**
125  * Whether old TNKernel names (definitions, functions, etc) should be
126  * available. If you're porting your existing application written for
127  * TNKernel, it is definitely worth enabling. If you start new project with
128  * TNeoKernel from scratch, it's better to avoid old names.
129  */
130 #ifndef TN_OLD_TNKERNEL_NAMES
131 # define TN_OLD_TNKERNEL_NAMES 1
132 #endif
133 
134 /**
135  * Whether mutexes API should be available
136  */
137 #ifndef TN_USE_MUTEXES
138 # define TN_USE_MUTEXES 1
139 #endif
140 
141 /**
142  * Whether mutexes should allow recursive locking/unlocking
143  */
144 #ifndef TN_MUTEX_REC
145 # define TN_MUTEX_REC 1
146 #endif
147 
148 /**
149  * Whether RTOS should detect deadlocks and notify user about them
150  * via callback
151  *
152  * @see see `tn_callback_deadlock_set()`
153  */
154 #ifndef TN_MUTEX_DEADLOCK_DETECT
155 # define TN_MUTEX_DEADLOCK_DETECT 1
156 #endif
157 
158 /**
159  * Number of "tick" lists of timers, must be a power or two; minimum value:
160  * `2`; typical values: `4`, `8` or `16`.
161  *
162  * Refer to the \ref timers_implementation for details.
163  *
164  * Shortly: this value represents number of elements in the array of
165  * `struct TN_ListItem`, on 32-bit system each element takes 8 bytes.
166  *
167  * The larger value, the more memory is needed, and the faster
168  * $(TN_SYS_TIMER_LINK) ISR works. If your application has a lot of timers
169  * and/or sleeping tasks, consider incrementing this value; otherwise,
170  * default value should work for you.
171  */
172 #ifndef TN_TICK_LISTS_CNT
173 # define TN_TICK_LISTS_CNT 8
174 #endif
175 
176 
177 /**
178  * API option for `MAKE_ALIG()` macro.
179  *
180  * There is a terrible mess with `MAKE_ALIG()` macro: original TNKernel docs
181  * specify that the argument of it should be the size to align, but almost all
182  * ports, including "original" one, defined it so that it takes type, not size.
183  *
184  * But the port by AlexB implemented it differently
185  * (i.e. accordingly to the docs)
186  *
187  * When I was moving from the port by AlexB to another one, do you have any
188  * idea how much time it took me to figure out why do I have rare weird bug? :)
189  *
190  * So, available options:
191  *
192  * * `#TN_API_MAKE_ALIG_ARG__TYPE`:
193  * In this case, you should use macro like this:
194  * `TN_MAKE_ALIG(struct my_struct)`
195  * This way is used in the majority of TNKernel ports.
196  * (actually, in all ports except the one by AlexB)
197  *
198  * * `#TN_API_MAKE_ALIG_ARG__SIZE`:
199  * In this case, you should use macro like this:
200  * `TN_MAKE_ALIG(sizeof(struct my_struct))`
201  * This way is stated in TNKernel docs
202  * and used in the port for dsPIC/PIC24/PIC32 by AlexB.
203  */
204 #ifndef TN_API_MAKE_ALIG_ARG
205 # define TN_API_MAKE_ALIG_ARG TN_API_MAKE_ALIG_ARG__SIZE
206 #endif
207 
208 
209 #endif // _TN_CFG_DEFAULT_H
210 
211