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
19 #include "Platform_Types.h"
\r
26 * | |--- Platform_Types.h (std?)
\r
27 * | |--- Compiler.h (std?)
\r
40 * kernel.h (shared types between config and OS source... pointless?)
\r
42 * |------------------|
\r
43 * Os_Cfg.c internal.h
\r
47 * -------------------------------------
\r
48 * Os.h - OS API and types
\r
49 * os_config_func.h - Inline API for Os_Cfg.c
\r
50 * ext_config.h - API for os_config_func.h, used by kernel
\r
51 * internal.h - Internal API for kernel, do NOT expose outside kernel
\r
53 * os_types.h - Internal types for the kernel
\r
60 * debug settings for os_debug_mask
\r
64 // print to STDOUT. If not set it prints to ramlog
\r
67 #define D_MASTER_PRINT 0
\r
68 #define D_ISR_MASTER_PRINT 0
\r
69 #define D_ISR_RAMLOG 0
\r
71 #define D_TASK (1<<0)
\r
72 #define D_ALARM (1<<1)
\r
73 #define D_RESOURCE (1<<2)
\r
74 #define D_SCHTBL (1<<3)
\r
75 #define D_EVENT (1<<4)
\r
76 #define D_MESSAGE (1<<5)
\r
80 * Configuration tree:
\r
81 * USE_OS_DEBUG - Turn on/off all Os_DbgPrintf()
\r
82 * SELECT_OS_CONSOLE - Select console
\r
83 * USE_RAMLOG - Compile ramlog code...
\r
86 * Default is to print to RAMLOG.
\r
90 * 1. We don't have a RAMLOG (low on RAM) so we want to print to serial console:
\r
91 * #define CFG_OS_DEBUG = STD_ON
\r
92 * #define USE_SERIAL_PORT
\r
93 * #define SELECT_OS_CONSOLE=TTY_SERIAL0
\r
94 * 2. We have a RAMLOG but we have a debugger connected and want the OS debug
\r
95 * to go there instead:
\r
96 * #define CFG_OS_DEBUG = STD_ON
\r
97 * #define USE_RAMLOG
\r
98 * #define USE_TTY_T32
\r
99 * #define SELECT_OS_CONSOLE=TTY_T32
\r
100 * 3. We have only the ramlog:
\r
101 * #define CFG_OS_DEBUG = STD_ON
\r
102 * #define USE_RAMLOG
\r
103 * #define SELECT_OS_CONSOLE=TTY_RAMLOG
\r
104 * 4. We use no debug.
\r
109 #if (CFG_OS_DEBUG == STD_ON)
\r
110 # if (SELECT_OS_CONSOLE==RAMLOG)
\r
111 # ifndef USE_RAMLOG
\r
112 # error USE_RAMLOG must be defined.
\r
115 # define OS_DEBUG(_mask,...) \
\r
117 if( os_dbg_mask & (_mask) ) { \
\r
118 ramlog_printf("[%08u] : ",(unsigned)GetOsTick()); \
\r
119 ramlog_printf(__VA_ARGS__ ); \
\r
122 # elif (SELECT_OS_CONSOLE==TTY_NONE)
\r
123 # define OS_DEBUG(_mask,...)
\r
125 # define OS_DEBUG(_mask,...) \
\r
127 if( os_dbg_mask & (_mask) ) { \
\r
128 printf("[%08u] : %s %d ",(unsigned)GetOsTick(), __FUNCTION__, __LINE__ ); \
\r
129 printf(__VA_ARGS__ ); \
\r
134 # define OS_DEBUG(_mask,...)
\r
137 extern uint32 os_dbg_mask;
\r
140 * Macros for error handling
\r
141 * Registers service id of the erroneous function and the applicable parameters
\r
142 * to os_error. Functions that have less than three parameters do not touch
\r
143 * os_error.param3. Same rule follows for other parameter counts.
\r
146 /* Error handling for functions that take no arguments */
\r
147 #define OS_STD_END(_service_id) \
\r
150 os_error.serviceId=_service_id;\
\r
155 /* Error handling for functions that take one argument */
\r
156 #define OS_STD_END_1(_service_id, _p1) \
\r
159 os_error.serviceId=_service_id;\
\r
160 os_error.param1 = (uint32_t) _p1; \
\r
165 /* Error handling for functions that take two arguments */
\r
166 #define OS_STD_END_2(_service_id, _p1,_p2) \
\r
169 os_error.serviceId=_service_id;\
\r
170 os_error.param1 = (uint32_t) _p1; \
\r
171 os_error.param2 = (uint32_t) _p2; \
\r
176 /* Error handling for functions that take three arguments */
\r
177 #define OS_STD_END_3(_service_id,_p1,_p2,_p3) \
\r
180 os_error.serviceId=_service_id;\
\r
181 os_error.param1 = (uint32_t) _p1; \
\r
182 os_error.param2 = (uint32_t) _p2; \
\r
183 os_error.param3 = (uint32_t) _p3; \
\r
189 #define OS_SAVE_PARAM_3(_service_id,_p1,_p2,_p3) \
\r
190 os_error.serviceId=_service_id;\
\r
191 os_error.param1 = (uint32_t) _p1; \
\r
192 os_error.param2 = (uint32_t) _p2; \
\r
193 os_error.param3 = (uint32_t) _p3; \
\r
197 /* Called for sequence of error hook calls in case a service
\r
198 * does not return with E_OK. Note that in this case the general error hook and the OS-
\r
199 * Application specific error hook are called.
\r
202 #define ERRORHOOK(x) \
\r
203 if( Os_Sys.hooks->ErrorHook != NULL ) { \
\r
204 Os_Sys.hooks->ErrorHook(x); \
\r
206 OS_APP_CALL_ERRORHOOKS(x);
\r
210 #if (OS_USE_APPLICATIONS == STD_ON)
\r
211 #define PROTECTIONHOOK(_x) \
\r
213 if( Os_Sys.hooks->ProtectionHook != NULL ) { \
\r
214 Os_Sys.hooks->ProtectionHook(_x); \
\r
221 #define PRETASKHOOK() \
\r
222 assert( Os_Sys.currTaskPtr->state & ST_RUNNING ); \
\r
223 assert( Os_Sys.currTaskPtr->flags == SYS_FLAG_HOOK_STATE_EXPECTING_PRE ); \
\r
224 Os_Sys.currTaskPtr->flags = SYS_FLAG_HOOK_STATE_EXPECTING_POST; \
\r
225 if( Os_Sys.hooks->PreTaskHook != NULL ) { \
\r
226 Os_Sys.hooks->PreTaskHook(); \
\r
229 #define POSTTASKHOOK() \
\r
230 assert( Os_Sys.currTaskPtr->state & ST_RUNNING ); \
\r
231 assert( Os_Sys.currTaskPtr->flags == SYS_FLAG_HOOK_STATE_EXPECTING_POST ); \
\r
232 Os_Sys.currTaskPtr->flags = SYS_FLAG_HOOK_STATE_EXPECTING_PRE; \
\r
233 if( Os_Sys.hooks->PostTaskHook != NULL ) { \
\r
234 Os_Sys.hooks->PostTaskHook(); \
\r
237 #endif /*INTERNAL_H_*/
\r