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, \
\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 .activationLimit = 1, \
\r
87 .applOwnerId = _appl_owner, \
\r
88 .accessingApplMask = _accessing_appl_mask, \
\r
91 #define GEN_BTASK( _id, _name, _priority, _scheduling, \
\r
92 _autostart, _resource_int_p, _resource_mask, \
\r
93 _activation_limit, _appl_owner, _accessing_appl_mask ) \
\r
95 .pid = TASK_ID_ ## _id, \
\r
98 .prio = _priority, \
\r
99 .proc_type = PROC_BASIC, \
\r
100 .stack.size = sizeof stack_##_id, \
\r
101 .stack.top = stack_##_id, \
\r
102 .autostart = _autostart, \
\r
103 .resourceIntPtr = _resource_int_p, \
\r
104 .scheduling = _scheduling, \
\r
105 .resourceAccess = _resource_mask, \
\r
106 .activationLimit = _activation_limit, \
\r
107 .applOwnerId = _appl_owner, \
\r
108 .accessingApplMask = _accessing_appl_mask, \
\r
111 #define GEN_ISR_HEAD const OsIsrConstType Os_IsrConstList[OS_ISR_CNT]
\r
113 #define GEN_ISR1( _name, _vector, _priority, _entry, _appOwner ) \
\r
115 .vector = _vector, \
\r
116 .type = ISR_TYPE_1, \
\r
117 .priority = _priority, \
\r
120 .resourceMask = 0, \
\r
121 .appOwner = _appOwner, \
\r
124 #define GEN_ISR2( _name, _vector, _priority, _entry, _appOwner, _resourceMask ) \
\r
126 .vector = _vector, \
\r
127 .type = ISR_TYPE_1, \
\r
128 .priority = _priority, \
\r
131 .resourceMask = _resourceMask, \
\r
132 .appOwner = _appOwner, \
\r
136 #define GEN_ISR_MAP const uint8_t Os_VectorToIsr[NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS]
\r
140 #define GEN_ISR_2( _id, _name, _entry, _priority, _vector ) \
\r
145 .prio = _priority, \
\r
146 .proc_type = PROC_ISR2, \
\r
147 .vector = _vector, \
\r
151 #define GEN_ISR_1( _id, _name, _entry, _priority , _vector ) \
\r
156 .prio = _priority, \
\r
157 .proc_type = PROC_ISR1, \
\r
158 .vector = _vector, \
\r
163 //#define GEN_PCB_LIST() uint8_t Os_TaskVarList[PCB_T_SIZE*ARRAY_SIZE( Os_TaskConstList)];
\r
164 #define GEN_PCB_LIST() OsTaskVarType Os_TaskVarList[ARRAY_SIZE( Os_TaskConstList)];
\r
166 #define GEN_RESOURCE_HEAD OsResourceType resource_list[OS_RESOURCE_CNT]
\r
171 * _type RESOURCE_TYPE_STANDARD, RESOURCE_TYPE_LINKED or RESOURCE_TYPE_INTERNAL
\r
172 * _ceiling_priority The calculated ceiling priority
\r
174 #define GEN_RESOURCE( _id, _type, _ceiling_priority, _appl_owner, _accessing_appl_mask ) \
\r
178 .ceiling_priority = _ceiling_priority, \
\r
180 .applOwnerId = _appl_owner, \
\r
181 .accessingApplMask = _accessing_appl_mask \
\r
188 * Name of the alarm, string
\r
191 * COUNTER_TYPE_HARD or COUNTER_TYPE_SOFT
\r
194 * COUNTER_UNIT_TICKS or COUNTER_UNIT_NANO
\r
206 * NOT USED. Set to 0
\r
209 #define GEN_COUNTER_HEAD OsCounterType counter_list[OS_COUNTER_CNT]
\r
210 #define GEN_COUNTER( _id, _name, _type, _unit, \
\r
211 _maxallowedvalue, \
\r
216 _accessing_appl_mask ) \
\r
220 .alarm_base.maxallowedvalue = _maxallowedvalue, \
\r
221 .alarm_base.tickperbase = _ticksperbase, \
\r
222 .alarm_base.mincycle = _mincycle, \
\r
223 .applOwnerId = _appl_owner, \
\r
224 .accessingApplMask = _accessing_appl_mask, \
\r
227 #define GEN_ALARM_AUTOSTART_NAME(_id) &(Os_AlarmAutoStart_ ## _id)
\r
234 * _app_mode Mask of the application modes.
\r
236 #define GEN_ALARM_AUTOSTART(_id, _type, _alarm_time, _cycle_time, _app_mode ) \
\r
237 const OsAlarmAutostartType Os_AlarmAutoStart_ ## _id = \
\r
239 .autostartType = _type, \
\r
240 .alarmTime = _alarm_time, \
\r
241 .cycleTime = _cycle_time, \
\r
242 .appModeRef = _app_mode \
\r
245 #define GEN_ALARM_HEAD OsAlarmType alarm_list[OS_ALARM_CNT]
\r
252 * Name of the alarm, string
\r
255 * The id of the counter to drive the alarm
\r
259 * _X_type - Any of:
\r
260 * ALARM_ACTION_ACTIVATETASK
\r
261 * ALARM_ACTION_SETEVENT
\r
262 * ALARM_ACTION_ALARMCALLBACK
\r
263 * ALARM_ACTION_INCREMENTCOUNTER
\r
265 * _X_task_id - The task ID to activate if _X_type is:
\r
266 * ALARM_ACTION_ACTIVATETASK or
\r
267 * ALARM_ACTION_SETEVENT
\r
269 * _X_event_id - The event ID if type is ALARM_ACTION_SETEVENT
\r
271 * _X_counter_id - The counter ID if type is ALARM_ACTION_INCREMENTCOUNTER
\r
274 #define GEN_ALARM( _id, _name, _counter_id, \
\r
278 _action_event_id, \
\r
279 _action_counter_id, \
\r
281 _accessing_appl_mask ) \
\r
284 .counter = &counter_list[_counter_id], \
\r
285 .counter_id = _counter_id, \
\r
286 .autostartPtr = _autostart_ref, \
\r
288 .type = _action_type, \
\r
289 .task_id = _action_task_id, \
\r
290 .event_id = _action_event_id, \
\r
291 .counter_id = _action_counter_id \
\r
293 .applOwnerId = _appl_owner, \
\r
294 .accessingApplMask = _accessing_appl_mask, \
\r
298 *---------------------- SCHEDULE TABLES -----------------------------------
\r
301 #define GEN_SCHTBL_EXPIRY_POINT_HEAD(_id ) \
\r
302 OsScheduleTableExpiryPointType Os_SchTblExpPointList_##_id[] =
\r
304 #define GEN_SCHTBL_EXPIRY_POINT_W_TASK_EVENT(_id, _offset ) \
\r
306 .offset = _offset, \
\r
307 .taskList = Os_SchTblTaskList_ ## _id ## _ ## _offset, \
\r
308 .taskListCnt = ARRAY_SIZE(Os_SchTblTaskList_ ## _id ## _ ## _offset), \
\r
309 .eventList = Os_SchTblEventList_ ## _id ## _ ## _offset, \
\r
310 .eventListCnt = ARRAY_SIZE(Os_SchTblEventList_ ## _id ## _ ## _offset) \
\r
313 #define GEN_SCHTBL_EXPIRY_POINT_W_TASK(_id, _offset ) \
\r
315 .offset = _offset, \
\r
316 .taskList = Os_SchTblTaskList_ ## _id ## _ ## _offset, \
\r
317 .taskListCnt = ARRAY_SIZE(Os_SchTblTaskList_ ## _id ## _ ## _offset), \
\r
320 #define GEN_SCHTBL_EXPIRY_POINT_W_EVENT(_id, _offset ) \
\r
322 .offset = _offset, \
\r
323 .eventList = Os_SchTblEventList_ ## _id ## _ ## _offset, \
\r
324 .eventListCnt = ARRAY_SIZE(Os_SchTblEventList_ ## _id ## _ ## _offset) \
\r
327 #define GEN_SCHTBL_TASK_LIST_HEAD( _id, _offset ) \
\r
328 const TaskType Os_SchTblTaskList_ ## _id ## _ ## _offset[] =
\r
330 #define GEN_SCHTBL_EVENT_LIST_HEAD( _id, _offset ) \
\r
331 const OsScheduleTableEventSettingType Os_SchTblEventList_ ## _id ## _ ## _offset[] =
\r
333 #define GEN_SCHTBL_AUTOSTART(_id, _type, _offset, _app_mode ) \
\r
334 const struct OsSchTblAutostart Os_SchTblAutoStart_ ## _id = \
\r
337 .offset = _offset, \
\r
338 .appMode = _app_mode, \
\r
341 #define GEN_SCHTBL_AUTOSTART_NAME(_id) &(Os_SchTblAutoStart_ ## _id)
\r
343 #define GEN_SCHTBL_HEAD OsSchTblType sched_list[] =
\r
350 * Name of the alarm, string
\r
353 * Pointer to the counter that drives the table
\r
356 * SINGLE_SHOT or REPEATING
\r
359 * The duration of the schedule table
\r
362 * Pointer to autostart configuration.
\r
363 * If autostart is desired set name to GEN_SCHTBL_AUTOSTART_NAME(<id>). It also
\r
364 * requires that GEN_SCHTBL_AUTOSTART(...) is set.
\r
365 * Set to NULL if not autostart configuration is desired.
\r
367 * The usage of the macro requires that GEN_SCHTBL_EXPIRY_POINT_HEAD(<id>) is also
\r
371 #define GEN_SCHEDULETABLE( _id, _name, _counter_id, _repeating, \
\r
376 .counter = &counter_list[_counter_id], \
\r
377 .repeating = _repeating, \
\r
378 .duration = _duration, \
\r
379 .expirePointList = { \
\r
380 .data = (void *)( Os_SchTblExpPointList_ ## _id ), \
\r
381 .cnt = ARRAY_SIZE(Os_SchTblExpPointList_ ## _id), \
\r
383 .autostartPtr = _autostart_ref, \
\r
387 #define GEN_HOOKS( _startup, _protection, _shutdown, _error, _pretask, _posttask ) \
\r
388 struct OsHooks os_conf_global_hooks = { \
\r
389 .StartupHook = _startup, \
\r
390 .ProtectionHook = _protection, \
\r
391 .ShutdownHook = _shutdown, \
\r
392 .ErrorHook = _error, \
\r
393 .PreTaskHook = _pretask, \
\r
394 .PostTaskHook = _posttask \
\r
397 #define ALIGN_16(x) (((x)>>4)<<4)
\r
399 #define DECLARE_STACK(_name,_size) \
\r
400 uint8_t stack_##_name[_size]
\r
402 #define SECTION_BSS_SUPER __attribute__ ((aligned (16),section(".bss")))
\r
403 #define SECTION_BSS_USER __attribute__ ((aligned (16),section(".bss")))
\r