TNeo  v1.06
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
tn_cfg_dispatch.h
Go to the documentation of this file.
1 /*******************************************************************************
2  *
3  * TNeo: 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  * TNeo: copyright © 2014 Dmitry Frank.
8  *
9  * TNeo 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: TNeo.
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  * Dispatch configuration: set predefined options, include user-provided cfg
41  * file as well as default cfg file.
42  *
43  */
44 
45 #ifndef _TN_CFG_DISPATCH_H
46 #define _TN_CFG_DISPATCH_H
47 
48 #include "../arch/tn_arch_detect.h"
49 
50 //-- Configuration constants
51 /**
52  * In this case, you should use macro like this: `#TN_MAKE_ALIG(struct my_struct)`.
53  * This way is used in the majority of TNKernel ports. (actually, in all ports
54  * except the one by AlexB)
55  */
56 #define TN_API_MAKE_ALIG_ARG__TYPE 1
57 
58 /**
59  * In this case, you should use macro like this: `#TN_MAKE_ALIG(sizeof(struct
60  * my_struct))`. This way is stated in TNKernel docs and used in the port for
61  * dsPIC/PIC24/PIC32 by AlexB.
62  */
63 #define TN_API_MAKE_ALIG_ARG__SIZE 2
64 
65 
66 //--- As a starting point, you might want to copy tn_cfg_default.h -> tn_cfg.h,
67 // and then edit it if you want to change default configuration.
68 // NOTE: the file tn_cfg.h is specified in .hgignore file, in order to not include
69 // project-specific configuration in the common TNKernel repository.
70 #include "tn_cfg.h"
71 
72 //-- Probably a bit of hack, but anyway:
73 // tn_cfg.h might just be a modified copy from existing tn_cfg_default.h,
74 // and then, _TN_CFG_DEFAULT_H is probably defined there.
75 // But we need to set some defaults, so, let's undef it.
76 // Anyway, tn_cfg_default.h checks whether each particular option is already
77 // defined, so it works nice.
78 #undef _TN_CFG_DEFAULT_H
79 
80 //--- default cfg file is included too, so that you are free to not set
81 // all available options in your tn_cfg.h file.
82 #include "tn_cfg_default.h"
83 
84 //-- check that all options specified {{{
85 
86 #if !defined(TN_CHECK_BUILD_CFG)
87 # error TN_CHECK_BUILD_CFG is not defined
88 #endif
89 
90 #if !defined(TN_PRIORITIES_CNT)
91 # error TN_PRIORITIES_CNT is not defined
92 #endif
93 
94 
95 #if !defined(TN_CHECK_PARAM)
96 # error TN_CHECK_PARAM is not defined
97 #endif
98 
99 #if !defined(TN_DEBUG)
100 # error TN_DEBUG is not defined
101 #endif
102 
103 #if !defined(TN_OLD_TNKERNEL_NAMES)
104 # error TN_OLD_TNKERNEL_NAMES is not defined
105 #endif
106 
107 #if !defined(TN_USE_MUTEXES)
108 # error TN_USE_MUTEXES is not defined
109 #endif
110 
111 #if TN_USE_MUTEXES
112 # if !defined(TN_MUTEX_REC)
113 # error TN_MUTEX_REC is not defined
114 # endif
115 # if !defined(TN_MUTEX_DEADLOCK_DETECT)
116 # error TN_MUTEX_DEADLOCK_DETECT is not defined
117 # endif
118 #endif
119 
120 #if !defined(TN_TICK_LISTS_CNT)
121 # error TN_TICK_LISTS_CNT is not defined
122 #endif
123 
124 #if !defined(TN_API_MAKE_ALIG_ARG)
125 # error TN_API_MAKE_ALIG_ARG is not defined
126 #endif
127 
128 #if !defined(TN_PROFILER)
129 # error TN_PROFILER is not defined
130 #endif
131 
132 #if !defined(TN_PROFILER_WAIT_TIME)
133 # error TN_PROFILER_WAIT_TIME is not defined
134 #endif
135 
136 #if !defined(TN_STACK_OVERFLOW_CHECK)
137 # error TN_STACK_OVERFLOW_CHECK is not defined
138 #endif
139 
140 #if defined (__TN_ARCH_PIC24_DSPIC__)
141 # if !defined(TN_P24_SYS_IPL)
142 # error TN_P24_SYS_IPL is not defined
143 # endif
144 
145 # if !defined(TN_P24_SYS_IPL_STR)
146 # error TN_P24_SYS_IPL_STR is not defined
147 # endif
148 #endif
149 
150 #if !defined(TN_DYNAMIC_TICK)
151 # error TN_DYNAMIC_TICK is not defined
152 #endif
153 
154 #if !defined(TN_OLD_EVENT_API)
155 # error TN_OLD_EVENT_API is not defined
156 #endif
157 
158 
159 // }}}
160 
161 
162 
163 //-- check TN_P24_SYS_IPL: should be 1 .. 6.
164 #if defined (__TN_ARCH_PIC24_DSPIC__)
165 # if TN_P24_SYS_IPL >= 7
166 # error TN_P24_SYS_IPL must be less than 7
167 # endif
168 # if TN_P24_SYS_IPL <= 0
169 # error TN_P24_SYS_IPL must be more than 0
170 # endif
171 #endif
172 
173 //-- NOTE: TN_TICK_LISTS_CNT is checked in tn_timer_static.c
174 //-- NOTE: TN_PRIORITIES_CNT is checked in tn_sys.c
175 //-- NOTE: TN_API_MAKE_ALIG_ARG is checked in tn_common.h
176 
177 
178 /**
179  * Internal kernel definition: set to non-zero if `_tn_sys_on_context_switch()`
180  * should be called on context switch.
181  *
182  * Currently, the only actual handler is available: profiler (see
183  * #TN_PROFILER). In the future, software stack overflow check will be
184  * implemented as well.
185  */
186 #if TN_PROFILER || TN_STACK_OVERFLOW_CHECK
187 # define _TN_ON_CONTEXT_SWITCH_HANDLER 1
188 #else
189 # define _TN_ON_CONTEXT_SWITCH_HANDLER 0
190 #endif
191 
192 /**
193  * If `#TN_STACK_OVERFLOW_CHECK` is set, we have 1-word overhead for each
194  * task stack.
195  */
196 #define _TN_STACK_OVERFLOW_SIZE_ADD (TN_STACK_OVERFLOW_CHECK ? 1 : 0)
197 
198 #endif // _TN_CFG_DISPATCH_H
199 
200 
TNeo default configuration file, to be copied as tn_cfg.h.