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 ------------------------------*/
26 * Created on: 23 aug 2009
\r
33 #include <sys/queue.h>
\r
35 #include "counter_i.h"
\r
36 #include "alarm_i.h"
\r
37 #include "sched_table_i.h"
\r
39 typedef void ( * trusted_func_t)( TrustedFunctionIndexType , TrustedFunctionParameterRefType );
\r
41 /*-----------------------------------------------------------------*/
\r
42 /* Global Hooks( non-application specific ) */
\r
44 typedef struct os_conf_global_hooks_s {
\r
45 ProtectionHookType ProtectionHook;
\r
46 StartupHookType StartupHook;
\r
47 ShutdownHookType ShutdownHook;
\r
48 ErrorHookType ErrorHook;
\r
49 PreTaskHookType PreTaskHook;
\r
50 PostTaskHookType PostTaskHook;
\r
51 } os_conf_global_hooks_t;
\r
55 /* Application hooks */
\r
57 typedef struct os_application_hooks_s {
\r
58 void (*StartupHook)( void );
\r
59 void (*ShutdownHook)( Std_ReturnType Error );
\r
60 void (*ErrorHook)( Std_ReturnType Error );
\r
61 } os_application_hooks_t;
\r
64 /*-----------------------------------------------------------------*/
\r
67 * The only information about the COM that is valid is
\r
68 * in the COM specification ..SWS_COM.pdf.
\r
70 * The most important requirements are COM010 and COM013
\r
76 * No. GetMessageStatus()
\r
77 * No. SendZeroMessage()
\r
78 * No. SendDynamicMessage(), RecieveDynamicMessage()
\r
80 * See http://www.altium.com/files/AltiumDesigner6/LearningGuides/GU0102%20TSK51x%20TSK52x%20RTOS.pdf
\r
82 * Yes. SendMessage()
\r
86 typedef enum message_property_e {
\r
88 SEND_STATIC_INTERNAL,
\r
89 // messages are not consumed during read
\r
90 RECEIVE_UNQUEUED_INTERNAL,
\r
91 // We have an internal queue
\r
92 RECEIVE_QUEUE_INTERNAL,
\r
93 } message_property_t;
\r
97 typedef enum message_notification_action_e {
\r
98 MESSAGE_NOTIFICATION_ACTION_NONE=0,
\r
99 MESSAGE_NOTIFICATION_ACTION_ACTIVATETASK,
\r
100 MESSAGE_NOTIFICATION_ACTION_SETEVENT,
\r
101 } message_notification_action_t;
\r
103 typedef struct message_notification_s {
\r
104 message_notification_action_t type;
\r
106 EventMaskType event_id;
\r
107 } message_notification_t;
\r
110 // TODO: Do a untion of all types here ???
\r
117 typedef struct message_obj_s {
\r
118 message_property_t property; // send/recieve...
\r
119 int q_size; // 0-Not queued
\r
120 message_notification_t notification;
\r
121 // TODO: This is not a good solution but it will have to do for now
\r
127 typedef enum scheduling_e {
\r
132 /*-----------------------------------------------------------------*/
\r
145 typedef uint8_t proc_type_t;
\r
147 #define PROC_PRIO 0x1
\r
148 #define PROC_BASIC 0x1
\r
149 #define PROC_EXTENDED 0x3
\r
151 #define PROC_ISR 0x4
\r
152 #define PROC_ISR1 0x4
\r
153 #define PROC_ISR2 0xc
\r
157 void *curr; // Current stack ptr( at swap time )
\r
158 void *top; // Top of the stack( low address )
\r
159 uint32 size; // The size of the stack
\r
162 typedef struct rom_app_s {
\r
163 uint32 application_id;
\r
168 void (*StartupHook)( void );
\r
169 void (*ShutdownHook)( Std_ReturnType Error );
\r
170 void (*ErrorHook)( Std_ReturnType Error );
\r
173 uint32 scheduletable_mask;
\r
175 uint32 counter_mask;
\r
176 uint32 resource_mask;
\r
177 uint32 message_mask;
\r
181 /*-----------------------------------------------------------------*/
\r
183 typedef struct lockingtime_obj_s {
\r
186 int resource_clock_time;
\r
187 int all_interrupt_clock_time;
\r
188 int os_interrupt_clock_time;
\r
190 } lockingtime_obj_t;
\r
194 // the normal behaviour
\r
195 RESOURCE_TYPE_STANDARD,
\r
197 RESOURCE_TYPE_LINKED,
\r
198 // Used for grouping tasks
\r
199 RESOURCE_TYPE_INTERNAL
\r
203 resource_type_t type;
\r
204 // used only if type is RESOURCE_TYPE_LINKED
\r
205 ResourceType linked_resource;
\r
206 } resource_property_t;
\r
208 /*-----------------------------------------------------------------*/
\r
209 typedef struct resource_obj_s {
\r
211 // The running number, starting at RES_SCHEDULER=0
\r
213 // The calculated ceiling prio
\r
214 uint32 ceiling_priority;
\r
215 // Stored prio of the owner oi the resource
\r
216 uint32 old_task_prio;
\r
218 // What application may access this resource. A resource may only be
\r
219 // accessed by one application
\r
220 uint32 application_owner_id;
\r
221 // What tasks may access this resource. A resource may be be shared
\r
224 // Owner of the resource...
\r
227 resource_type_t type;
\r
228 // used only if type is RESOURCE_TYPE_LINKED
\r
229 ResourceType linked_resource;
\r
231 // resource_property_t resource_property;
\r
236 LOCK_TYPE_RESOURCE,
\r
237 LOCK_TYPE_INTERRUPT,
\r
242 ResourceType resource;
\r
244 } resource_locktime_t;
\r
249 } interrupt_locktime_t;
\r
252 typedef struct lockingtime_s {
\r
253 // lock_type_t type;
\r
266 // resource_locktime_t resource;
\r
267 // interrupt_locktime_t interrupt;
\r
271 typedef struct timing_protection_s {
\r
272 // ROM, worst case execution budget in ns
\r
273 uint64 execution_budget;
\r
274 // ROM, the frame in ns that timelimit may execute in.
\r
276 // ROM, time in ns that the task/isr may with a timeframe.
\r
278 // ROM, resource/interrupt locktimes
\r
279 lockingtime_t *lockingtime;
\r
281 // interrupt_locktime_t interrupt_locktime;
\r
282 // ROM, resource lock times
\r
283 // const resource_locktime_t *resource_locktime_list;
\r
284 // lockingtime_t *lockingtime;
\r
285 } timing_protection_t;
\r
288 /*-----------------------------------------------------------------*/
\r
290 typedef struct rom_pcb_s {
\r
295 proc_type_t proc_type;
\r
299 ApplicationType application_id;
\r
301 scheduling_t scheduling;
\r
302 // uint64 execution_budget;
\r
303 // uint32 count_limit;
\r
304 // uint64 time_limit;
\r
305 // pointer to internal resource
\r
307 resource_obj_t *resource_int_p;
\r
308 timing_protection_t *timing_protection;
\r
309 // lockingtime_obj_t
\r
313 /*-----------------------------------------------------------------*/
\r
315 typedef struct sched_action_s {
\r
316 int type; // 0 - activate task, 1 - event
\r
317 uint64 offset; // for debug only???
\r
318 uint64 delta; // delta to next action
\r
320 EventMaskType event_id; // used only if event..
\r
323 /*-----------------------------------------------------------------*/
\r
328 typedef enum message_type_e {
\r
330 SEND_STATIC_INTERNAL,
\r
331 // messages are not consumed during read
\r
332 RECEIVE_UNQUEUED_INTERNAL,
\r
333 // We have an internal queue
\r
334 RECEIVE_QUEUE_INTERNAL,
\r
339 typedef struct message_obj_s {
\r
341 message_type_t type;
\r
344 uint32 accessingapplications_mask;
\r
345 // TODO: Below types are NOT OK !!!!!!!
\r
347 void* initialvalue;
\r
349 message_property_t messageproperty;
\r
350 void * callbackroutine;
\r
351 uint32 callbackMessage;
\r
353 uint32 notification;
\r
360 /*-----------------------------------------------------------------*/
\r
363 typedef struct memory_s {
\r
365 /* ptr to start of memory region */
\r
367 /* size in bytes */
\r
371 /*-----------------------------------------------------------------*/
\r
373 * debug settings for os_debug_mask
\r
377 #define OS_DBG_MASTER_PRINT (1<<0)
\r
378 #define OS_DBG_ISR_MASTER_PRINT (1<<1)
\r
379 #define OS_DBG_STDOUT (1<<2)
\r
380 #define OS_DBG_ISR_STDOUT (1<<3)
\r
382 // Enable print dbg_XXXX (not dbg_isr_XXX though)
\r
383 #define D_MASTER_PRINT (1<<0)
\r
384 // Enable print for all dbg_isr_XXX
\r
385 #define D_ISR_MASTER_PRINT (1<<1)
\r
386 // print to STDOUT. If not set it prints to ramlog
\r
387 #define D_STDOUT (1<<2)
\r
389 // print to STDOUT, If not set print to ramlog
\r
390 #define D_ISR_STDOUT (1<<3)
\r
391 #define D_ISR_RAMLOG 0
\r
393 #define D_TASK (1<<16)
\r
394 #define D_ALARM (1<<18)
\r
396 #define OS_DBG_TASK (1<<16)
\r
397 #define OS_DBG_ALARM (1<<18)
\r
401 #endif /* KERNEL_H_ */
\r