1 /* -------------------------------- Arctic Core ------------------------------
\r
2 * Arctic Core - the open source AUTOSAR platform http://arccore.com
\r
4 * Copyright (C) 2009 ArcCore AB <contact@arccore.com>
\r
6 * This source code is free software; you can redistribute it and/or modify it
\r
7 * under the terms of the GNU General Public License version 2 as published by the
\r
8 * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.
\r
10 * This program is distributed in the hope that it will be useful, but
\r
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
\r
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
\r
14 * -------------------------------- Arctic Core ------------------------------*/
\r
16 /* Configure "rules"
\r
17 * - Don't pollute the namespace with the generator tools. The tools should
\r
18 * ONLY know the GEN_xxx macros.
\r
19 * - If something is a container with multiplicity 1 and above, make it a pointer.
\r
23 #ifndef _OS_CONFIG_MACROS_H
\r
24 #define _OS_CONFIG_MACROS_H
\r
26 #include "Std_Types.h"
\r
32 #define ARRAY_SIZE(_x) (sizeof(_x)/sizeof((_x)[0]))
\r
36 // +1 here.. easy to have a reference..
\r
37 #define GEN_TRUSTEDFUNCTIONS_LIST trusted_func_t os_cfg_trusted_list[OS_SERVICE_CNT];
\r
39 #define GEN_APPLICATION_HEAD const OsAppConstType Os_AppConst[OS_APPLICATION_CNT]
\r
41 #define GEN_APPLICATION( _id, _name, _trusted, _core, _startuphook, _shutdownhook, _errorhook, \
\r
47 .trusted = _trusted, \
\r
48 .StartupHook = _startuphook, \
\r
49 .ShutdownHook = _shutdownhook, \
\r
50 .ErrorHook = _errorhook, \
\r
51 .restartTaskId = _restart_task \
\r
54 #define GEN_TASK_HEAD const OsTaskConstType Os_TaskConstList[OS_TASK_CNT]
\r
60 * _priority The task priority
\r
61 * _autostart true/false
\r
62 * _resource_int_p Pointer to internal resource.
\r
63 * NULL - if no internal resource or scheduling==NON
\r
65 * _scheduling FULL or NON
\r
66 * _resource_mask Mask of the resources used. Applies to STANDARD and LINKED (NOT INTERNAL)
\r
67 * For example if this task would use resource with id 2 and 4 the mask would
\r
68 * become (1<<2)|(1<<4) = 0x14 (limits resources to 32).
\r
69 * Currently used for calculating the ceiling priority.
\r
71 #define GEN_ETASK( _id, _name, _priority, _scheduling, \
\r
72 _autostart, _resource_int_p, _resource_mask, _event_mask, \
\r
73 _appl_owner, _accessing_appl_mask ) \
\r
75 .pid = TASK_ID_ ## _id, \
\r
78 .prio = _priority, \
\r
79 .proc_type = PROC_EXTENDED, \
\r
80 .stack.size = sizeof stack_##_id, \
\r
81 .stack.top = stack_##_id, \
\r
82 .autostart = _autostart, \
\r
83 .resourceIntPtr = _resource_int_p, \
\r
84 .scheduling = _scheduling, \
\r
85 .resourceAccess = _resource_mask, \
\r
86 .eventMask = _event_mask, \
\r
87 .activationLimit = 1, \
\r
88 .applOwnerId = _appl_owner, \
\r
89 .accessingApplMask = _accessing_appl_mask, \
\r
92 #define GEN_BTASK( _id, _name, _priority, _scheduling, \
\r
93 _autostart, _resource_int_p, _resource_mask, \
\r
94 _activation_limit, _appl_owner, _accessing_appl_mask ) \
\r
96 .pid = TASK_ID_ ## _id, \
\r
99 .prio = _priority, \
\r
100 .proc_type = PROC_BASIC, \
\r
101 .stack.size = sizeof stack_##_id, \
\r
102 .stack.top = stack_##_id, \
\r
103 .autostart = _autostart, \
\r
104 .resourceIntPtr = _resource_int_p, \
\r
105 .scheduling = _scheduling, \
\r
106 .resourceAccess = _resource_mask, \
\r
107 .activationLimit = _activation_limit, \
\r
108 .applOwnerId = _appl_owner, \
\r
109 .accessingApplMask = _accessing_appl_mask, \
\r
112 #define GEN_ISR_HEAD const OsIsrConstType Os_IsrConstList[OS_ISR_CNT]
\r
114 #define GEN_ISR1( _name, _vector, _priority, _entry, _appOwner ) \
\r
116 .vector = _vector, \
\r
117 .type = ISR_TYPE_1, \
\r
118 .priority = _priority, \
\r
121 .resourceMask = 0, \
\r
122 .appOwner = _appOwner, \
\r
125 #define GEN_ISR2( _name, _vector, _priority, _entry, _appOwner, _resourceMask ) \
\r
127 .vector = _vector, \
\r
128 .type = ISR_TYPE_2, \
\r
129 .priority = _priority, \
\r
132 .resourceMask = _resourceMask, \
\r
133 .appOwner = _appOwner, \
\r
137 #define GEN_ISR_MAP uint8_t Os_VectorToIsr[NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS]
\r
140 #define GEN_RESOURCE_HEAD OsResourceType resource_list[OS_RESOURCE_CNT]
\r
145 * _type RESOURCE_TYPE_STANDARD, RESOURCE_TYPE_LINKED or RESOURCE_TYPE_INTERNAL
\r
146 * _ceiling_priority The calculated ceiling priority
\r
148 #define GEN_RESOURCE( _id, _type, _ceiling_priority, _appl_owner, _accessing_appl_mask ) \
\r
152 .ceiling_priority = _ceiling_priority, \
\r
154 .applOwnerId = _appl_owner, \
\r
155 .accessingApplMask = _accessing_appl_mask \
\r
162 * Name of the alarm, string
\r
165 * COUNTER_TYPE_HARD or COUNTER_TYPE_SOFT
\r
168 * COUNTER_UNIT_TICKS or COUNTER_UNIT_NANO
\r
180 * NOT USED. Set to 0
\r
183 #define GEN_COUNTER_HEAD OsCounterType counter_list[OS_COUNTER_CNT]
\r
184 #define GEN_COUNTER( _id, _name, _type, _unit, \
\r
185 _maxallowedvalue, \
\r
190 _accessing_appl_mask ) \
\r
194 .alarm_base.maxallowedvalue = _maxallowedvalue, \
\r
195 .alarm_base.tickperbase = _ticksperbase, \
\r
196 .alarm_base.mincycle = _mincycle, \
\r
197 .applOwnerId = _appl_owner, \
\r
198 .accessingApplMask = _accessing_appl_mask, \
\r
201 #define GEN_ALARM_AUTOSTART_NAME(_id) &(Os_AlarmAutoStart_ ## _id)
\r
208 * _app_mode Mask of the application modes.
\r
210 #define GEN_ALARM_AUTOSTART(_id, _type, _alarm_time, _cycle_time, _app_mode ) \
\r
211 const OsAlarmAutostartType Os_AlarmAutoStart_ ## _id = \
\r
213 .autostartType = _type, \
\r
214 .alarmTime = _alarm_time, \
\r
215 .cycleTime = _cycle_time, \
\r
216 .appModeRef = _app_mode \
\r
219 #define GEN_ALARM_HEAD OsAlarmType alarm_list[OS_ALARM_CNT]
\r
226 * Name of the alarm, string
\r
229 * The id of the counter to drive the alarm
\r
233 * _X_type - Any of:
\r
234 * ALARM_ACTION_ACTIVATETASK
\r
235 * ALARM_ACTION_SETEVENT
\r
236 * ALARM_ACTION_ALARMCALLBACK
\r
237 * ALARM_ACTION_INCREMENTCOUNTER
\r
239 * _X_task_id - The task ID to activate if _X_type is:
\r
240 * ALARM_ACTION_ACTIVATETASK or
\r
241 * ALARM_ACTION_SETEVENT
\r
243 * _X_event_id - The event ID if type is ALARM_ACTION_SETEVENT
\r
245 * _X_counter_id - The counter ID if type is ALARM_ACTION_INCREMENTCOUNTER
\r
248 #define GEN_ALARM( _id, _name, _counter_id, \
\r
252 _action_event_id, \
\r
253 _action_counter_id, \
\r
255 _accessing_appl_mask ) \
\r
258 .counter = &counter_list[_counter_id], \
\r
259 .counter_id = _counter_id, \
\r
260 .autostartPtr = _autostart_ref, \
\r
262 .type = _action_type, \
\r
263 .task_id = _action_task_id, \
\r
264 .event_id = _action_event_id, \
\r
265 .counter_id = _action_counter_id \
\r
267 .applOwnerId = _appl_owner, \
\r
268 .accessingApplMask = _accessing_appl_mask, \
\r
272 *---------------------- SCHEDULE TABLES -----------------------------------
\r
275 #define GEN_SCHTBL_EXPIRY_POINT_HEAD(_id ) \
\r
276 OsScheduleTableExpiryPointType Os_SchTblExpPointList_##_id[] =
\r
278 #define GEN_SCHTBL_EXPIRY_POINT_W_TASK_EVENT(_id, _offset ) \
\r
280 .offset = _offset, \
\r
281 .taskList = Os_SchTblTaskList_ ## _id ## _ ## _offset, \
\r
282 .taskListCnt = ARRAY_SIZE(Os_SchTblTaskList_ ## _id ## _ ## _offset), \
\r
283 .eventList = Os_SchTblEventList_ ## _id ## _ ## _offset, \
\r
284 .eventListCnt = ARRAY_SIZE(Os_SchTblEventList_ ## _id ## _ ## _offset) \
\r
287 #define GEN_SCHTBL_EXPIRY_POINT_W_TASK(_id, _offset ) \
\r
289 .offset = _offset, \
\r
290 .taskList = Os_SchTblTaskList_ ## _id ## _ ## _offset, \
\r
291 .taskListCnt = ARRAY_SIZE(Os_SchTblTaskList_ ## _id ## _ ## _offset), \
\r
294 #define GEN_SCHTBL_EXPIRY_POINT_W_EVENT(_id, _offset ) \
\r
296 .offset = _offset, \
\r
297 .eventList = Os_SchTblEventList_ ## _id ## _ ## _offset, \
\r
298 .eventListCnt = ARRAY_SIZE(Os_SchTblEventList_ ## _id ## _ ## _offset) \
\r
301 #define GEN_SCHTBL_TASK_LIST_HEAD( _id, _offset ) \
\r
302 const TaskType Os_SchTblTaskList_ ## _id ## _ ## _offset[] =
\r
304 #define GEN_SCHTBL_EVENT_LIST_HEAD( _id, _offset ) \
\r
305 const OsScheduleTableEventSettingType Os_SchTblEventList_ ## _id ## _ ## _offset[] =
\r
307 #define GEN_SCHTBL_AUTOSTART(_id, _type, _offset, _app_mode ) \
\r
308 const struct OsSchTblAutostart Os_SchTblAutoStart_ ## _id = \
\r
311 .offset = _offset, \
\r
312 .appMode = _app_mode, \
\r
315 #define GEN_SCHTBL_AUTOSTART_NAME(_id) &(Os_SchTblAutoStart_ ## _id)
\r
317 #define GEN_SCHTBL_HEAD OsSchTblType sched_list[OS_SCHTBL_CNT]
\r
324 * Name of the alarm, string
\r
327 * Pointer to the counter that drives the table
\r
330 * SINGLE_SHOT or REPEATING
\r
333 * The duration of the schedule table
\r
336 * Pointer to autostart configuration.
\r
337 * If autostart is desired set name to GEN_SCHTBL_AUTOSTART_NAME(<id>). It also
\r
338 * requires that GEN_SCHTBL_AUTOSTART(...) is set.
\r
339 * Set to NULL if not autostart configuration is desired.
\r
341 * The usage of the macro requires that GEN_SCHTBL_EXPIRY_POINT_HEAD(<id>) is also
\r
345 #define GEN_SCHEDULETABLE( _id, _name, _counter_id, _repeating, \
\r
349 _accessing_appl_mask ) \
\r
352 .counter = &counter_list[_counter_id], \
\r
353 .repeating = _repeating, \
\r
354 .duration = _duration, \
\r
355 .expirePointList = { \
\r
356 .data = (void *)( Os_SchTblExpPointList_ ## _id ), \
\r
357 .cnt = ARRAY_SIZE(Os_SchTblExpPointList_ ## _id), \
\r
359 .autostartPtr = _autostart_ref,\
\r
360 .applOwnerId = _appl_owner, \
\r
361 .accessingApplMask = _accessing_appl_mask, \
\r
365 #define GEN_HOOKS( _startup, _protection, _shutdown, _error, _pretask, _posttask ) \
\r
366 struct OsHooks os_conf_global_hooks = { \
\r
367 .StartupHook = _startup, \
\r
368 .ProtectionHook = _protection, \
\r
369 .ShutdownHook = _shutdown, \
\r
370 .ErrorHook = _error, \
\r
371 .PreTaskHook = _pretask, \
\r
372 .PostTaskHook = _posttask \
\r
375 #define ALIGN_16(x) (((x)>>4)<<4)
\r
377 #define DECLARE_STACK(_name,_size) \
\r
378 uint8_t stack_##_name[_size]
\r
380 #define SECTION_BSS_SUPER __attribute__ ((aligned (16),section(".bss")))
\r
381 #define SECTION_BSS_USER __attribute__ ((aligned (16),section(".bss")))
\r