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 #ifndef SCHED_TABLE_I_H_
\r
17 #define SCHED_TABLE_I_H_
\r
19 /* Should hold the internal API used by the schedule tables */
\r
21 #define SCHEDULE_ACTION_ACTIVATETASK 0
\r
22 #define SCHEDULE_ACTION_SETEVENT 1
\r
24 #include "alist_i.h"
\r
25 #include "counter_i.h"
\r
29 #define SINGLE_SHOT 0
\r
32 #if ( OS_SC2 == STD_ON ) || ( OS_SC4 == STD_ON )
\r
33 enum OsScheduleTableSyncStrategy {
\r
34 /* Support for sync, this is same as no OS */
\r
36 /* synchronize with "external" counter */
\r
43 enum OsScheduleTableAutostartType {
\r
44 // Start with StartScheduleTableAbs()
\r
45 SCHTBL_AUTOSTART_ABSOLUTE,
\r
46 // Start with StartScheduleTableRel()
\r
47 SCHTBL_AUTOSTART_RELATIVE,
\r
48 // Start with StartScheduleTableSyncon()
\r
49 SCHTBL_AUTOSTART_SYNCHRONE
\r
53 /* STD container: OsScheduleTableEventSetting
\r
54 * OsScheduleTableSetEventRef: 1
\r
55 * OsScheduleTableSetEventTaskRef: 1
\r
57 typedef struct OsScheduleTableEventSetting {
\r
58 EventMaskType event;
\r
60 } OsScheduleTableEventSettingType;
\r
62 /* OsScheduleTableTaskActivation */
\r
64 /* STD container: OsScheduleTableExpiryPoint
\r
65 * OsScheduleTblExpPointOffset: 1 Int
\r
66 * OsScheduleTableEventSetting: 0..*
\r
67 * OsScheduleTableTaskActivation: 0..*
\r
68 * OsScheduleTblAdjustableExpPoint: 0..1
\r
73 typedef struct OsScheduleTableExpiryPoint {
\r
74 /* The expiry point offset, OsScheduleTblExpPointOffset */
\r
77 // delta to next action
\r
81 /* List of events to activate */
\r
82 const TaskType *taskList;
\r
83 uint8_t taskListCnt;
\r
85 /* List of events to activate */
\r
86 const OsScheduleTableEventSettingType *eventList;
\r
87 uint8_t eventListCnt;
\r
88 } OsScheduleTableExpiryPointType;
\r
91 #if ( OS_SC2 == STD_ON ) || ( OS_SC4 == STD_ON )
\r
92 typedef struct OsScheduleTableSync {
\r
95 enum OsScheduleTableSyncStrategy syncStrategy;
\r
96 // from spec. (only if syncStrategy==EXPLICIT )
\r
97 int explicitPrecision;
\r
100 // This counter is advanced by the driver counter but is synchronized
\r
101 // by SyncScheduleTable()
\r
102 GlobalTimeTickType syncCounter;
\r
104 // This is the deviation from the sync counter to the drive counter.
\r
105 // (set by SyncScheduleTable())
\r
106 // Calculated as 'driver count' - 'global time count from SyncScheduleTable()'
\r
109 } OsScheduleTableSyncType;
\r
113 typedef struct OsSchTblAdjExpPoint {
\r
114 uint8_t maxAdvance;
\r
116 } OsSchTblAdjExpPointType;
\r
119 /* STD container: OsScheduleTableAutostart
\r
120 * OsScheduleTableAbsValue 1 Int
\r
121 * OsScheduleTableAutostartType 1 Enum
\r
122 * OsScheduleTableRelOffset 1 Int
\r
123 * OsScheduleTableAppModeRef 1..* Ref to OsAppMode
\r
125 struct OsSchTblAutostart {
\r
126 enum OsScheduleTableAutostartType type;
\r
127 /* offset applies to both rel and abs */
\r
129 uint32_t appMode; // TODO
\r
133 /* STD container: OsScheduleTable
\r
134 * OsScheduleTableDuration: 1 Int
\r
135 * OsScheduleTableRepeating: 1 Bool
\r
136 * OsSchTblAccessingApplication 0..* Ref
\r
137 * OsScheduleTableCounterRef: 1 Ref
\r
138 * OsScheduleTableAutostart[C] 0..1
\r
139 * OsScheduleTableExpiryPoint[C] 1..*
\r
140 * OsScheduleTableSync 0..1
\r
143 typedef struct OsSchTbl {
\r
144 /* OsScheduleTableDuration */
\r
148 /* If true, the schedule is periodic, OS009
\r
149 * OsScheduleTableRepeating , 0 - SINGLE_SHOT */
\r
153 #if defined(SC3) || defined(SC4)
\r
154 uint32 accessingApplMask;
\r
157 // pointer to this tables counter
\r
158 // OsScheduleTableCounterRef
\r
160 struct OsCounter *counter;
\r
162 /* OsScheduleTableAutostart[C] */
\r
163 const struct OsSchTblAutostart *autostartPtr;
\r
165 /* NULL if NONE, and non-NULL if EXPLICIT and IMPLICIT */
\r
166 struct OsScheduleTableSync *sync;
\r
168 #if (OS_USE_APPLICATIONS == STD_ON)
\r
172 #if ( OS_SC2 == STD_ON ) || ( OS_SC4 == STD_ON )
\r
173 struct OsSchTblAdjExpPoint adjExpPoint;
\r
179 /* The current index into the expire list
\r
180 * The value is updated at each expire point. */
\r
181 int expire_curr_index;
\r
183 /* When this table expires the next time
\r
184 * This value should be compared to the counter that drives
\r
185 * the counter to check if it has expired.
\r
186 * The value is updated at each expire point. */
\r
187 TickType expire_val;
\r
189 ScheduleTableStatusType state;
\r
191 /* Pointer to next schedule table, if any
\r
192 * (don't use normal lists here since we have no list head) */
\r
193 struct OsSchTbl *next;
\r
195 /* Head of static expire point list
\r
196 * OsScheduleTableExpiryPoint[C] */
\r
197 SA_LIST_HEAD(alist,OsScheduleTableExpiryPoint) expirePointList;
\r
199 /* Entry in the list of schedule tables connected to a specific
\r
201 SLIST_ENTRY(OsSchTbl) sched_list;
\r
206 #define os_stbl_get_action(x) SA_LIST_GET(&(x)->expirePointList,(x)->expire_curr_index)
\r
207 #define os_stbl_get_action_type(x) os_stbl_get_action(x)->type
\r
208 #define os_stbl_get_action_offset(x) os_stbl_get_action(x)->offset
\r
209 #define os_stbl_get_action_pid(x) os_stbl_get_action(x)->pid
\r
210 #define os_stbl_get_action_event(x) os_stbl_get_action(x)->event
\r
213 void Os_SchTblInit( void );
\r
214 void Os_SchTblAutostart( void );
\r
215 void Os_SchTblCalcExpire( OsSchTblType *stbl );
\r
216 void Os_SchTblCheck(OsCounterType *c_p);
\r
217 void Os_SchTblAutostart( void );
\r
220 static inline TickType Os_SchTblGetInitialOffset( OsSchTblType *sPtr ) {
\r
221 return SA_LIST_GET(&sPtr->expirePointList,0)->offset;
\r
224 static inline TickType Os_SchTblGetFinalOffset( OsSchTblType *sPtr ) {
\r
225 return (sPtr->duration -
\r
226 SA_LIST_GET(&sPtr->expirePointList, SA_LIST_CNT(&sPtr->expirePointList)-1)->offset);
\r
229 void Os_SchTblCheck(OsCounterType *c_p);
\r
232 #endif /*SCHED_TABLE_I_H_*/
\r