1 /* -------------------------------- Arctic Core ------------------------------
2 * Arctic Core - the open source AUTOSAR platform http://arccore.com
4 * Copyright (C) 2009 ArcCore AB <contact@arccore.com>
6 * This source code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published by the
8 * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * -------------------------------- Arctic Core ------------------------------*/
17 * - Don't pollute the namespace with the generator tools. The tools should
18 * ONLY know the GEN_xxx macros.
19 * - If something is a container with multiplicity 1 and above, make it a pointer.
23 #ifndef _OS_CONFIG_MACROS_H
\r
24 #define _OS_CONFIG_MACROS_H
\r
26 #include "Std_Types.h"
32 #define ARRAY_SIZE(_x) (sizeof(_x)/sizeof((_x)[0]))
36 // +1 here.. easy to have a reference..
\r
37 #define GEN_TRUSTEDFUNCTIONS_LIST trusted_func_t os_cfg_trusted_list[SERVICE_CNT];
\r
39 #define GEN_APPLICATION_HEAD const OsRomApplicationType rom_app_list[] =
\r
41 #define GEN_APPLICATON( _id,_name,_trusted,_startuphook,_shutdownhook, \
\r
42 _errorhook,_isr_mask,_scheduletable_mask, _alarm_mask, \
\r
43 _counter_mask,_resource_mask,_message_mask ) \
\r
45 .application_id = _id, \
\r
47 .trusted = _trusted, \
\r
48 .StartupHook = _startuphook, \
\r
49 .ShutdownHook = _shutdownhook, \
\r
50 .ErrorHook = _errorhook, \
\r
51 .isr_mask = _isr_mask, \
\r
52 .scheduletable_mask = _scheduletable_mask, \
\r
53 .alarm_mask = _alarm_mask, \
\r
54 .counter_mask = _counter_mask, \
\r
55 .resource_mask = _resource_mask, \
\r
56 .message_mask = _message_mask, \
\r
60 #define GEN_TASK_HEAD const OsRomPcbType rom_pcb_list[] =
\r
66 * _priority The task priority
67 * _autostart true/false
68 * _resource_int_p Pointer to internal resource.
69 * NULL - if no internal resource or scheduling==NON
71 * _scheduling FULL or NON
72 * _resource_mask Mask of the resources used. Applies to STANDARD and LINKED (NOT INTERNAL)
73 * For example if this task would use resource with id 2 and 4 the mask would
74 * become (1<<2)|(1<<4) = 0x14 (limits resources to 32).
75 * Currently used for calculating the ceiling priority.
77 #define GEN_ETASK( _id, _priority, _scheduling, _autostart, _resource_int_p, _resource_mask ) \
79 .pid = TASK_ID_##_id, \
83 .proc_type = PROC_EXTENDED, \
84 .stack.size = sizeof stack_##_id, \
85 .stack.top = stack_##_id, \
86 .autostart = _autostart, \
87 .resource_int_p = _resource_int_p, \
88 .scheduling = _scheduling, \
89 .resourceAccess = _resource_mask, \
90 .activationLimit = 1, \
93 #define GEN_BTASK( _id, _priority, _scheduling, _autostart, _resource_int_p, _resource_mask, _activation_limit ) \
95 .pid = TASK_ID_##_id, \
99 .proc_type = PROC_BASIC, \
100 .stack.size = sizeof stack_##_id, \
101 .stack.top = stack_##_id, \
102 .autostart = _autostart, \
103 .resource_int_p = _resource_int_p, \
104 .scheduling = _scheduling, \
105 .resourceAccess = _resource_mask, \
106 .activationLimit = _activation_limit, \
109 #define GEN_ISR_2( _id, _name, _entry, _priority, _vector ) \
\r
114 .prio = _priority, \
\r
115 .proc_type = PROC_ISR2, \
\r
116 .vector = _vector, \
\r
120 #define GEN_ISR_1( _id, _name, _entry, _priority , _vector ) \
\r
125 .prio = _priority, \
\r
126 .proc_type = PROC_ISR1, \
\r
127 .vector = _vector, \
\r
130 //#define GEN_PCB_LIST() uint8_t pcb_list[PCB_T_SIZE*ARRAY_SIZE(rom_pcb_list)];
131 #define GEN_PCB_LIST() OsPcbType pcb_list[ARRAY_SIZE(rom_pcb_list)];
133 #define GEN_RESOURCE_HEAD OsResourceType resource_list[] =
138 * _type RESOURCE_TYPE_STANDARD, RESOURCE_TYPE_LINKED or RESOURCE_TYPE_INTERNAL
139 * _ceiling_priority The calculated ceiling priority
141 #define GEN_RESOURCE( _id, _type, _ceiling_priority ) \
\r
145 .ceiling_priority = _ceiling_priority, \
\r
153 * Name of the alarm, string
156 * COUNTER_TYPE_HARD or COUNTER_TYPE_SOFT
159 * COUNTER_UNIT_TICKS or COUNTER_UNIT_NANO
174 #define GEN_COUNTER_HEAD OsCounterType counter_list[] =
\r
175 #define GEN_COUNTER( _id, _name, _type, _unit, \
\r
176 _maxallowedvalue, \
\r
183 .alarm_base.maxallowedvalue = _maxallowedvalue, \
\r
184 .alarm_base.tickperbase = _ticksperbase, \
\r
185 .alarm_base.mincycle = _mincycle, \
189 .driver.OsGptChannelRef = _gpt_ch
193 #define GEN_ALARM_AUTOSTART_NAME(_id) &(Os_AlarmAutoStart_ ## _id)
200 * _app_mode Mask of the application modes.
202 #define GEN_ALARM_AUTOSTART(_id, _type, _alarm_time, _cycle_time, _app_mode ) \
203 const OsAlarmAutostartType Os_AlarmAutoStart_ ## _id = \
205 .autostartType = _type, \
206 .alarmTime = _alarm_time, \
207 .cycleTime = _cycle_time, \
208 .appModeRef = _app_mode \
211 #define GEN_ALARM_HEAD OsAlarmType alarm_list[] =
\r
218 * Name of the alarm, string
221 * The id of the counter to drive the alarm
226 * ALARM_ACTION_ACTIVATETASK
227 * ALARM_ACTION_SETEVENT
228 * ALARM_ACTION_ALARMCALLBACK
229 * ALARM_ACTION_INCREMENTCOUNTER
231 * _X_task_id - The task ID to activate if _X_type is:
232 * ALARM_ACTION_ACTIVATETASK or
233 * ALARM_ACTION_SETEVENT
235 * _X_event_id - The event ID if type is ALARM_ACTION_SETEVENT
237 * _X_counter_id - The counter ID if type is ALARM_ACTION_INCREMENTCOUNTER
240 #define GEN_ALARM( _id, _name, _counter_id, \
244 _action_event_id, \
\r
245 _action_counter_id ) \
\r
248 .counter = &counter_list[_counter_id], \
\r
249 .counter_id = _counter_id, \
\r
250 .autostartPtr = _autostart_ref, \
\r
252 .type = _action_type, \
\r
253 .task_id = _action_task_id, \
\r
254 .event_id = _action_event_id, \
\r
255 .counter_id = _action_counter_id \
\r
260 *---------------------- SCHEDULE TABLES -----------------------------------
263 #define GEN_SCHTBL_EXPIRY_POINT_HEAD(_id ) \
264 OsScheduleTableExpiryPointType Os_SchTblExpPointList_##_id[] =
266 #define GEN_SCHTBL_EXPIRY_POINT_W_TASK_EVENT(_id, _offset ) \
269 .taskList = Os_SchTblTaskList_ ## _id ## _ ## _offset, \
270 .taskListCnt = ARRAY_SIZE(Os_SchTblTaskList_ ## _id ## _ ## _offset), \
271 .eventList = Os_SchTblEventList_ ## _id ## _ ## _offset, \
272 .eventListCnt = ARRAY_SIZE(Os_SchTblEventList_ ## _id ## _ ## _offset) \
275 #define GEN_SCHTBL_EXPIRY_POINT_W_TASK(_id, _offset ) \
278 .taskList = Os_SchTblTaskList_ ## _id ## _ ## _offset, \
279 .taskListCnt = ARRAY_SIZE(Os_SchTblTaskList_ ## _id ## _ ## _offset), \
282 #define GEN_SCHTBL_EXPIRY_POINT_W_EVENT(_id, _offset ) \
285 .eventList = Os_SchTblEventList_ ## _id ## _ ## _offset, \
286 .eventListCnt = ARRAY_SIZE(Os_SchTblEventList_ ## _id ## _ ## _offset) \
289 #define GEN_SCHTBL_TASK_LIST_HEAD( _id, _offset ) \
290 const TaskType Os_SchTblTaskList_ ## _id ## _ ## _offset[] =
292 #define GEN_SCHTBL_EVENT_LIST_HEAD( _id, _offset ) \
293 const OsScheduleTableEventSettingType Os_SchTblEventList_ ## _id ## _ ## _offset[] =
295 #define GEN_SCHTBL_AUTOSTART(_id, _type, _offset, _app_mode ) \
296 const struct OsSchTblAutostart Os_SchTblAutoStart_ ## _id = \
300 .appMode = _app_mode, \
303 #define GEN_SCHTBL_AUTOSTART_NAME(_id) &(Os_SchTblAutoStart_ ## _id)
305 #define GEN_SCHTBL_HEAD OsSchTblType sched_list[] =
312 * Name of the alarm, string
315 * Pointer to the counter that drives the table
318 * SINGLE_SHOT or REPEATING
321 * The duration of the schedule table
324 * Pointer to autostart configuration.
325 * If autostart is desired set name to GEN_SCHTBL_AUTOSTART_NAME(<id>). It also
326 * requires that GEN_SCHTBL_AUTOSTART(...) is set.
327 * Set to NULL if not autostart configuration is desired.
329 * The usage of the macro requires that GEN_SCHTBL_EXPIRY_POINT_HEAD(<id>) is also
333 #define GEN_SCHEDULETABLE( _id, _name, _counter_id, _repeating, \
338 .counter = &counter_list[_counter_id], \
339 .repeating = _repeating, \
340 .duration = _duration, \
341 .expirePointList = { \
342 .data = (void *)( Os_SchTblExpPointList_ ## _id ), \
343 .cnt = ARRAY_SIZE(Os_SchTblExpPointList_ ## _id), \
345 .autostartPtr = _autostart_ref, \
349 #if ( OS_SC3 == STD_ON) || ( OS_SC4 == STD_ON)
350 #error OLD or NOT implemented
351 #define GEN_HOOKS( _startup, _protection, _shutdown, _error, _pretask, _posttask ) \
\r
352 struct OsHooks os_conf_global_hooks = { \
\r
353 .StartupHook = _startup, \
354 .ProtectionHook = _protection, \
355 .ShutdownHook = _shutdown, \
\r
356 .ErrorHook = _error, \
\r
357 .PreTaskHook = _pretask, \
\r
358 .PostTaskHook = _posttask, \
\r
361 #define GEN_HOOKS( _startup, _protection, _shutdown, _error, _pretask, _posttask ) \
362 struct OsHooks os_conf_global_hooks = { \
363 .StartupHook = _startup, \
364 .ShutdownHook = _shutdown, \
365 .ErrorHook = _error, \
366 .PreTaskHook = _pretask, \
367 .PostTaskHook = _posttask, \
373 #define GEN_IRQ_VECTOR_TABLE_HEAD \
374 void * Irq_VectorTable[NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS] =
376 #define GEN_IRQ_ISR_TYPE_TABLE_HEAD \
377 uint8_t Irq_IsrTypeTable[NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS] =
379 #define GEN_IRQ_PRIORITY_TABLE_HEAD \
380 uint8_t Irq_PriorityTable[NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS] =
382 #define ALIGN_16(x) (((x)>>4)<<4)
\r
384 #define DECLARE_STACK(_name,_size) \
\r
385 uint8_t stack_##_name[_size]
\r
387 #define SECTION_BSS_SUPER __attribute__ ((aligned (16),section(".bss")))
\r
388 #define SECTION_BSS_USER __attribute__ ((aligned (16),section(".bss")))
\r
391 #undef SCHEDULETABLE_CNT
\r