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 ------------------------------*/
18 * ------------------------------------------------
\r
20 * - 3 extended ( do NOT terminate )
\r
21 * - 3 basic ( terminate )
\r
25 * - 1 soft( incremented with IncrementCounter(X) )
\r
29 * - 1 hardware alarm
\r
31 * - Running on the soft counter above
\r
32 * - Triggers the basic task through ActivateTask() in alarm
\r
36 * - 1 ISR type, system counter
\r
39 * - Running on the system timer
\r
45 * ----------------------------------
\r
46 * A system MUST have a system counter to function. This is almost
\r
47 * always a hardware timer. So where is this timer configured?
\r
49 * decrementer exception
\r
50 * --> generate a prioritised interrupt through INTC soft interrupt
\r
52 * Using the decrementer without generating the soft interrupt is not
\r
53 * recommended since it's not prioritised( it's and exception that blocks
\r
54 * interrupts from INTC )
\r
56 * The timers are initialized in EcuM() using Gpt_Init(X). A StartupHook() must
\r
57 * be used to start the timer. Example
\r
59 * Gpt_StartTimer( GPT_CHANNEL_DEC, 10000UL);
\r
60 * Gpt_EnableNotification(GPT_CHANNEL_DEC);
\r
63 * The counter configuration, e.g. timeout is not yet configured
\r
64 * through the counter in the configuration.
\r
67 * ----------------------------------
\r
68 * dec_exception ( From Mcu_Exception.S )
\r
69 * This exception installed HARD in the exception_tbl( Mcu_Exceptions )
\r
73 * - Do NOT use internal resource unless you are very sure that you to it right..
\r
78 #define OS_CFG_API_VERSION 2
82 #include "os_config_macros.h"
\r
83 #include "Platform_Types.h"
\r
84 #include "Os.h" // includes Os_Cfg.h
\r
85 #include "os_test.h"
\r
87 #include "kernel_offset.h"
\r
91 OsTickType OsTickFreq = 1000;
\r
93 extern void dec_exception( void );
\r
95 #if ( OS_SC1 == STD_ON ) || ( OS_SC4 == STD_ON )
99 GEN_TRUSTEDFUNCTIONS_LIST
\r
103 //-------------------------------------------------------------------
\r
105 #if ( OS_SC1 == STD_ON ) || ( OS_SC4 == STD_ON )
\r
106 GEN_APPLICATION_HEAD {
\r
107 GEN_APPLICATON(0,"application_1",true,NULL,NULL,NULL , 0,0,0,0,0,0 )
\r
111 //-------------------------------------------------------------------
\r
113 #define ALIGN_16(x) (((x)>>4)<<4)
\r
116 uint8 stack_OsIdle[STACK_SIZE_OsIdle] SECTION_BSS_SUPER;
\r
117 uint8 stack_etask_master[STACK_SIZE_etask_master] SECTION_BSS_SUPER;
\r
118 uint8 stack_etask_sup_l[STACK_SIZE_etask_sup_l] SECTION_BSS_SUPER;
\r
119 uint8 stack_etask_sup_m[STACK_SIZE_etask_sup_m] SECTION_BSS_SUPER;
\r
120 uint8 stack_etask_sup_h[STACK_SIZE_etask_sup_h] SECTION_BSS_SUPER;
\r
121 uint8 stack_btask_sup_l[STACK_SIZE_btask_sup_l] SECTION_BSS_SUPER;
\r
122 uint8 stack_btask_sup_m[STACK_SIZE_btask_sup_m] SECTION_BSS_SUPER;
\r
123 uint8 stack_btask_sup_h[STACK_SIZE_btask_sup_h] SECTION_BSS_SUPER;
\r
125 #define INTC_VECTOR_EXCEPTION_DEC (320+10)
\r
126 #define INTC_VECTOR_SSCIR0 0
\r
127 #define INTC_VECTOR_SSCIR7 7
\r
129 //-------------------------------------------------------------------
\r
131 GEN_RESOURCE_HEAD {
\r
132 GEN_RESOURCE(RES_SCHEDULER,RESOURCE_TYPE_STANDARD,0,0,0), // Standard resource..
\r
133 // Internal resources
\r
134 GEN_RESOURCE(1,RESOURCE_TYPE_INTERNAL,8, APPLICATION_ID_application_1,(1<<TASK_ID_etask_sup_l)),
\r
135 // external resource
\r
136 GEN_RESOURCE(2,RESOURCE_TYPE_STANDARD,3,0,0),
138 GEN_RESOURCE(3,RESOURCE_TYPE_STANDARD,4,0,0),
140 GEN_RESOURCE(4,RESOURCE_TYPE_STANDARD,5,0,0),
144 //-------------------------------------------------------------------
\r
148 GEN_ETASK(OsIdle,0,true/*auto*/, NULL/*tm*/, APPLICATION_ID_application_1/*app*/,NULL/*rsrc*/, FULL, 0 ),
\r
151 GEN_ETASK(etask_master,1,true/*auto*/, NULL/*tm*/, APPLICATION_ID_application_1/*app*/,NULL/*rsrc*/, NON, 0),
\r
153 GEN_ETASK(etask_sup_l,2,false/*auto*/, NULL/*tm*/, APPLICATION_ID_application_1/*app*/,NULL/*rsrc*/, FULL, 0 ),
\r
154 GEN_ETASK(etask_sup_m,3,false/*auto*/, NULL/*tm*/, APPLICATION_ID_application_1/*app*/,NULL/*rsrc*/, FULL, 0 ),
\r
155 GEN_ETASK(etask_sup_h,4,false/*auto*/, NULL/*tm*/, APPLICATION_ID_application_1/*app*/,NULL/*rsrc*/, FULL, 0 ),
\r
158 GEN_BTASK(btask_sup_l,2,false/*auto*/, NULL/*tm*/, APPLICATION_ID_application_1/*app*/,NULL/*rsrc*/, FULL, 0, 1 ),
\r
159 GEN_BTASK(btask_sup_m,3,false/*auto*/, NULL/*tm*/, APPLICATION_ID_application_1/*app*/,NULL/*rsrc*/, FULL, 0, 1 ),
\r
160 GEN_BTASK(btask_sup_h,4,false/*auto*/, NULL/*tm*/, APPLICATION_ID_application_1/*app*/,NULL/*rsrc*/, FULL, 0, 1 ),
\r
162 GEN_ISR_2( TASK_ID_os_tick, "dec", OsTick, /*prio*/ 11, /*type*/ PROC_ISR2, INTC_VECTOR_EXCEPTION_DEC , NULL, APPLICATION_ID_application_1),
\r
164 // Use the intc_vector tables for now
\r
165 GEN_ISR_2( TASK_ID_isr_dec, "dec", my_dec, /*prio*/ 11, /*type*/ PROC_ISR2, INTC_VECTOR_EXCEPTION_DEC , NULL, APPLICATION_ID_application_1),
\r
166 GEN_ISR_1( TASK_ID_isr_soft7, "exception_sc", my_intc_soft7, /*prio*/ 12, INTC_VECTOR_SSCIR7 ),
\r
173 //-------------------------------------------------------------------
\r
174 typedef void (*exc_func_t)(uint32_t *);
\r
176 // Print all to stdout
\r
177 uint32 os_dbg_mask = 0;
\r
180 uint32 os_dbg_mask = \
\r
182 D_ISR_MASTER_PRINT |\
\r
188 // D_ALARM | D_TASK;
\r
190 // --- INTERRUPTS ---
192 uint8_t os_interrupt_stack[OS_INTERRUPT_STACK_SIZE] __attribute__ ((aligned (0x10)));
194 GEN_IRQ_VECTOR_TABLE_HEAD {};
195 GEN_IRQ_ISR_TYPE_TABLE_HEAD {};
196 GEN_IRQ_PRIORITY_TABLE_HEAD {};
198 //-------------------------------------------------------------------
\r
200 // Generate as <type> <msg_name>_data
\r
206 OsMessageType message_list[] = {
\r
208 .property = RECEIVE_UNQUEUED_INTERNAL,
\r
209 .data = &MsgRx_1_data,
\r
210 .data_size = sizeof(MsgRx_1_data),
\r
214 .property = SEND_STATIC_INTERNAL,
\r
215 .data = &MsgTx_1_data,
\r
216 .data_size = sizeof(MsgTx_1_data),
\r
223 #define MESSAGE_CLASS(_name,_ctype ,_property,_queued ,_notification) \
\r
224 struct message ## _name ## _s { \
\r
228 MESSAGE_CLASS(rx1,int,,,);
\r
234 message_type_t type; // RECEIVE_UNQUEUED_INTERNAL, RECEIVE_QUEUE_INTERNAL
\r
235 MessageType send_id;
\r
236 OsMessageNotificationType *notification;
\r
241 #define DeclareMessage(x) (x)
\r
247 //-------------------------------------------------------------------
\r
251 // SEND_STATIC_INTERNAL is the only message that needs an object
\r
255 // RECEIVE_UNQUEUED_INTERNAL, RECEIVE_QUEUE_INTERNAL have notification and
\r
260 //-------------------------------------------------------------------
\r
262 //#define COUNTER_SOFT_1 1
\r
263 //#define EVENT_1 1
\r
267 GEN_COUNTER(COUNTER_ID_os_tick, "COUNTER_ID_OsTick",COUNTER_TYPE_HARD,
\r
268 COUNTER_UNIT_NANO, 0xffff,1,1,0 ),
\r
269 GEN_COUNTER(COUNTER_ID_soft_1, "counter_soft_1",COUNTER_TYPE_SOFT,
\r
270 COUNTER_UNIT_NANO, 10,1,1,0),
\r
271 GEN_COUNTER(COUNTER_ID_soft_2, "counter_soft_2",COUNTER_TYPE_SOFT,
\r
272 COUNTER_UNIT_NANO, 100,1,1,0),
\r
275 CounterType Os_Arc_OsTickCounter = COUNTER_ID_OsTick;
277 //-------------------------------------------------------------------
\r
282 .counter = &counter_list[COUNTER_ID_OsTick],
\r
283 .counter_id = COUNTER_ID_OsTick,
\r
286 .type = ALARM_ACTION_ACTIVATETASK,
\r
287 .task_id = TASK_ID_btask_sup_h,
\r
292 /* Set EVENT_1 in etask_sup_m, driven by soft counter */
\r
293 .counter = &counter_list[COUNTER_ID_OsTick],
\r
294 .counter_id = COUNTER_ID_OsTick,
\r
296 .type = ALARM_ACTION_SETEVENT,
\r
297 .task_id = TASK_ID_etask_sup_m,
\r
298 .event_id = EVENT_1,
\r
301 /* Set EVENT_1 in etask_sup_m, driven by counter_soft_1 */
\r
302 .counter = &counter_list[COUNTER_ID_soft_1],
\r
303 .counter_id = COUNTER_ID_soft_1,
\r
305 .type = ALARM_ACTION_SETEVENT,
\r
306 .task_id = TASK_ID_etask_sup_m,
\r
307 .event_id = EVENT_1,
\r
310 .counter = &counter_list[COUNTER_ID_soft_1],
\r
311 .counter_id = COUNTER_ID_soft_1,
\r
313 .type = ALARM_ACTION_INCREMENTCOUNTER,
\r
314 .counter_id = COUNTER_ID_soft_2,
\r
320 //-------------------------------------------------------------------
\r
323 #if defined(SCHEDULETABLE_USE)
\r
326 OsScheduleTableActionType sched_expire_list_0[] = {
\r
328 .type = SCHEDULE_ACTION_ACTIVATETASK,
\r
330 .task_id = TASK_ID_etask_sup_m,
\r
332 .type = SCHEDULE_ACTION_SETEVENT,
\r
334 .task_id = TASK_ID_etask_sup_m,
\r
335 .event_id = EVENT_2,
\r
340 OsScheduleTableActionType sched_expire_list_1[] = {
\r
342 .type = SCHEDULE_ACTION_ACTIVATETASK,
\r
344 .task_id = TASK_ID_etask_sup_m,
\r
349 GEN_SCHEDULETABLE_HEAD {
\r
353 COUNTER_ID_soft_2, // counter
\r
354 REPEATING, // periodic
355 SCHEDULETABLE_DURATION_1, // duration
\r
357 ARRAY_SIZE(sched_expire_list_0), // action count
\r
358 sched_expire_list_0, // expire ref
\r
359 0,0,0,0, // autostart
\r
367 COUNTER_ID_soft_2, // counter
\r
368 REPEATING, // periodic
\r
369 SCHEDULETABLE_DURATION_2, // duration
\r
371 ARRAY_SIZE(sched_expire_list_1), // action count
\r
372 sched_expire_list_1, // expire ref
\r
373 0,0,0,0, // autostart
\r
384 struct OsHooks os_conf_global_hooks = {
\r
385 .StartupHook = StartupHook,
386 #if ( OS_SC2 == STD_ON ) || ( OS_SC1 == STD_ON ) || ( OS_SC4 == STD_ON )
\r
387 .ProtectionHook = ProtectionHook,
389 .ShutdownHook = ShutdownHook,
\r
390 .ErrorHook = ErrorHook,
\r
391 .PreTaskHook = PreTaskHook,
\r
392 .PostTaskHook = PostTaskHook,
\r
396 #include "os_config_funcs.h"
\r