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
20 #include <sys/queue.h>
\r
23 extern uint32_t os_dbg_mask;
\r
27 * Configuration tree:
\r
28 * USE_OS_DEBUG - Turn on/off all Os_DbgPrintf()
\r
29 * SELECT_OS_CONSOLE - Select console
\r
30 * USE_RAMLOG - Compile ramlog code...
\r
33 * Default is to print to RAMLOG.
\r
37 * 1. We don't have a RAMLOG (low on RAM) so we want to print to serial console:
\r
38 * #define CFG_OS_DEBUG = STD_ON
\r
39 * #define USE_SERIAL_PORT
\r
40 * #define SELECT_OS_CONSOLE=TTY_SERIAL0
\r
41 * 2. We have a RAMLOG but we have a debugger connected and want the OS debug
\r
42 * to go there instead:
\r
43 * #define CFG_OS_DEBUG = STD_ON
\r
44 * #define USE_RAMLOG
\r
45 * #define USE_TTY_T32
\r
46 * #define SELECT_OS_CONSOLE=TTY_T32
\r
47 * 3. We have only the ramlog:
\r
48 * #define CFG_OS_DEBUG = STD_ON
\r
49 * #define USE_RAMLOG
\r
50 * #define SELECT_OS_CONSOLE=TTY_RAMLOG
\r
51 * 4. We use no debug.
\r
56 #if (CFG_OS_DEBUG == STD_ON)
\r
57 # if (SELECT_OS_CONSOLE==RAMLOG)
\r
59 # error USE_RAMLOG must be defined.
\r
62 # define OS_DEBUG(_mask,...) \
\r
64 if( os_dbg_mask & (_mask) ) { \
\r
65 ramlog_printf("[%08u] : ",(unsigned)GetOsTick()); \
\r
66 ramlog_printf(__VA_ARGS__ ); \
\r
69 # elif (SELECT_OS_CONSOLE==TTY_NONE)
\r
70 # define OS_DEBUG(_mask,...)
\r
72 # define OS_DEBUG(_mask,...) \
\r
74 if( os_dbg_mask & (_mask) ) { \
\r
75 printf("[%08u] : %s %d ",(unsigned)GetOsTick(), __FUNCTION__, __LINE__ ); \
\r
76 printf(__VA_ARGS__ ); \
\r
81 # define OS_DEBUG(_mask,...)
\r
85 #if ( OS_SC1 == STD_ON ) || ( OS_SC4 == STD_ON )
\r
86 typedef void ( * trusted_func_t)( TrustedFunctionIndexType , TrustedFunctionParameterRefType );
\r
90 /* STD container : OsOs. OSEK properties
\r
93 * OsScalabilityClass: 0..1 SC1,SC2,SC3,SC4
\r
94 * OsStackMonitoring: 1 Stack monitoring of tasks/category 2
\r
95 * OsStatus 1 EXTENDED or STANDARD status
\r
96 * OsUseGetServiceId 1 We can use the OSErrorGetServiceId() function
\r
97 * OsUseParameterAccess 1 We save the parameters in OSError_XX_YY()
\r
98 * OsUseResScheduler 1
\r
101 * From OSEK/VDX oil:
\r
104 * STATUS = STANDARD;
\r
105 * STARTUPHOOK = TRUE;
\r
106 * ERRORHOOK = TRUE;
\r
107 * SHUTDOWNHOOK = TRUE;
\r
108 * PRETASKHOOK = FALSE;
\r
109 * POSTTASKHOOK = FALSE;
\r
110 * USEGETSERVICEID = FALSE;
\r
111 * USEPARAMETERACCESS = FALSE;
\r
112 * USERESSCHEDULER = TRUE;
\r
115 * OS_SC1 | OS_SC2 | OS_SC3 | OS_SC4
\r
116 * OS_STACK_MONITORING
\r
117 * OS_STATUS_EXTENDED / OS_STATUS_STANDARD
\r
118 * OS_USE_GET_SERVICE_ID
\r
119 * OS_USE_PARAMETER_ACCESS
\r
124 * STD container: OsResource
\r
125 * OsResourceProperty: 1 INTERNAL, LINKED, STANDARD
\r
126 * OsResourceAccessingApplication: 0..*
\r
127 * OsResourceLinkedResourceRef: 0..1
\r
131 /* External resource */
\r
132 RESOURCE_TYPE_STANDARD,//!< RESOURCE_TYPE_STANDARD
\r
134 RESOURCE_TYPE_LINKED, //!< RESOURCE_TYPE_LINKED
\r
135 /* Internal resource */
\r
136 RESOURCE_TYPE_INTERNAL //!< RESOURCE_TYPE_INTERNAL
\r
137 } OsResourcePropertyType;
\r
139 /*-----------------------------------------------------------------*/
\r
140 typedef struct OsResource {
\r
142 // The running number, starting at RES_SCHEDULER=0
\r
144 // The calculated ceiling prio
\r
145 uint32 ceiling_priority;
\r
146 // Stored prio of the owner oi the resource
\r
147 uint32 old_task_prio;
\r
149 // What application may access this resource. A resource may only be
\r
150 // accessed by one application
\r
151 #if defined(SC3) || defined(SC4)
\r
152 uint32 accessingApplMask;
\r
154 // What tasks may access this resource. A resource may be be shared
\r
156 // uint32 task_mask;
\r
157 // Owner of the resource...
\r
160 OsResourcePropertyType type;
\r
161 // used only if type is RESOURCE_TYPE_LINKED
\r
162 ResourceType linked_resource;
\r
164 /* List of resources for each task. */
\r
165 TAILQ_ENTRY(OsResource) listEntry;
\r
170 LOCK_TYPE_RESOURCE,
\r
171 LOCK_TYPE_INTERRUPT
\r
174 typedef struct OsLockingtime {
\r
175 OsLocktypeType type;
\r
187 } OsLockingtimeType;
\r
189 typedef struct OsTimingProtection {
\r
190 // ROM, worst case execution budget in ns
\r
191 uint64 execution_budget;
\r
192 // ROM, the frame in ns that timelimit may execute in.
\r
194 // ROM, time in ns that the task/isr may with a timeframe.
\r
196 // ROM, resource/interrupt locktimes
\r
197 OsLockingtimeType *lockingtime;
\r
198 } OsTimingProtectionType;
\r
201 #include "counter_i.h"
\r
202 #include "alarm_i.h"
\r
203 #include "sched_table_i.h"
\r
204 #include "application.h"
\r
210 /*-----------------------------------------------------------------*/
\r
213 /*-----------------------------------------------------------------*/
\r
215 * debug settings for os_debug_mask
\r
219 // print to STDOUT. If not set it prints to ramlog
\r
222 #define D_MASTER_PRINT 0
\r
223 #define D_ISR_MASTER_PRINT 0
\r
224 #define D_ISR_RAMLOG 0
\r
226 #define D_TASK (1<<0)
\r
227 #define D_ALARM (1<<1)
\r
228 #define D_RESOURCE (1<<2)
\r
229 #define D_SCHTBL (1<<3)
\r
230 #define D_EVENT (1<<4)
\r
231 #define D_MESSAGE (1<<5)
\r
234 #endif /* KERNEL_H_ */
\r