1 //----------------------------------------------------------------------
2 // Copyright (C) 2006 - 2007 by the FRESCOR consortium:
4 // Universidad de Cantabria, SPAIN
5 // University of York, UK
6 // Scuola Superiore Sant'Anna, ITALY
7 // Kaiserslautern University, GERMANY
8 // Univ. Politecnica Valencia, SPAIN
9 // Czech Technical University in Prague, CZECH REPUBLIC
11 // Thales Communication S.A. FRANCE
12 // Visual Tools S.A. SPAIN
13 // Rapita Systems Ltd UK
16 // See http://www.frescor.org
18 // The FRESCOR project (FP6/2005/IST/5-034026) is funded
19 // in part by the European Union Sixth Framework Programme
20 // The European Union is not liable of any use that may be
24 // based on previous work (FSF) done in the FIRST project
26 // Copyright (C) 2005 Mälardalen University, SWEDEN
27 // Scuola Superiore S.Anna, ITALY
28 // Universidad de Cantabria, SPAIN
29 // University of York, UK
31 // This file is part of FOSA (Frsh Operating System Abstraction)
33 // FOSA is free software; you can redistribute it and/or modify it
34 // under terms of the GNU General Public License as published by the
35 // Free Software Foundation; either version 2, or (at your option) any
36 // later version. FOSA is distributed in the hope that it will be
37 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
38 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
39 // General Public License for more details. You should have received a
40 // copy of the GNU General Public License along with FOSA; see file
41 // COPYING. If not, write to the Free Software Foundation, 675 Mass Ave,
42 // Cambridge, MA 02139, USA.
44 // As a special exception, including FOSA header files in a file,
45 // instantiating FOSA generics or templates, or linking other files
46 // with FOSA objects to produce an executable application, does not
47 // by itself cause the resulting executable application to be covered
48 // by the GNU General Public License. This exception does not
49 // however invalidate any other reasons why the executable file might be
50 // covered by the GNU Public License.
51 // -----------------------------------------------------------------------
53 //==============================================
54 // ******** ****** ******** **********
55 // **///// /** ** **////// /** /**
56 // ** /** ** /** /** /**
57 // ******* /** ** /********* /**********
58 // **//// /** ** ////////** /**//////**
59 // ** /** ** /** /** /**
60 // ** /** ** ******** /** /**
61 // // /******/ //////// // //
63 // FOSA(Frescor Operating System Adaptation layer)
64 //================================================
66 // Implementation dependent definitions
68 #ifndef _FOSA_OPAQUE_TYPES_H_
69 #define _FOSA_OPAQUE_TYPES_H_
73 #include "fosa_cpp_macros.h"
74 #include "fosa_opaque_types_time.h"
76 /////////////////////// MARTE_OS /////////////////////////////
89 /* Thread and signals */
90 /**********************/
91 typedef pthread_t FOSA_THREAD_ID_T_OPAQUE;
92 typedef pthread_attr_t FOSA_THREAD_ATTR_T_OPAQUE;
94 typedef int FOSA_SIGNAL_T_OPAQUE;
95 /* Signal info is defined as a union in thread_and_signals */
97 #define FOSA_SIGNAL_MIN SIGRTMIN
98 #define FOSA_SIGNAL_MAX SIGRTMIN+0
100 #define FOSA_NULL_SIGNAL 0
102 /* Clocks and timers */
103 /**********************/
104 typedef clockid_t FOSA_CLOCK_ID_T_OPAQUE;
105 typedef timer_t FOSA_TIMER_ID_T_OPAQUE;
107 #define FOSA_SYSTEM_CLOCK_OPAQUE CLOCK_MONOTONIC
109 /* Mutex and conditional variables */
110 /***********************************/
111 typedef pthread_mutex_t FOSA_MUTEX_T_OPAQUE;
112 typedef pthread_cond_t FOSA_COND_T_OPAQUE;
115 /* Application defined Scheduling */
116 /**********************************/
117 #define FOSA_ADS_ACTIONS_T_OPAQUE struct \
119 posix_appsched_actions_t actions; \
120 struct timespec *timeout_ptr; \
121 struct timespec timeout; \
130 #include "marte_non_local_jmp.h"
132 #define FOSA_LONG_JUMP_CONTEXT_T_OPAQUE struct { \
133 marte_nonlocaljmp_context_t marte_context; \
134 fosa_thread_id_t tid; \
140 /** Not enough memory available **/
141 #define FOSA_ENOMEM ENOMEM
143 /** Invalid parameter **/
144 #define FOSA_EINVAL EINVAL
146 /** Still pending information **/
147 #define FOSA_EAGAIN EAGAIN
149 /** FOSA ADS errors **/
151 #define EREJECT 201 /* (for linux_lib_arch) Appsched has rejected object */
154 #define FOSA_EREJECT EREJECT
155 #define FOSA_EMASKED -2
156 #define FOSA_EPOLICY -3
158 #define FOSA_ETIMEDOUT ETIMEDOUT
162 /////////////////////// End of MARTE_OS /////////////////////////////
165 /////////////////////// RT_LINUX ///////////////////////////
169 /* Very similar to MARTE_OS but I leave separate for clarity */
176 #include <rtl_timer.h>
179 /* Threads and signals */
180 /***********************/
181 #define FOSA_THREAD_ID_T_OPAQUE pthread_t
183 typedef pthread_attr_t FOSA_THREAD_ATTR_T_OPAQUE;
184 typedef int FOSA_SIGNAL_T_OPAQUE;
185 /* Signal info is defined as a union in fosa_types.h */
187 // The minimum and maximum signal numbers that may be used by the FRSH
189 #define FOSA_SIGNAL_MIN SIGRTMIN
190 #define FOSA_SIGNAL_MAX SIGRTMIN+0
191 #define FOSA_NULL_SIGNAL 0
193 /* Clocks and timers */
194 /*********************/
195 #define FOSA_CLOCK_ID_T_OPAQUE clockid_t
196 #define FOSA_TIMER_ID_T_OPAQUE timer_t
197 #define FOSA_SYSTEM_CLOCK_OPAQUE CLOCK_MONOTONIC
199 /* Mutex and cond vars */
200 /***********************/
201 typedef pthread_mutex_t FOSA_MUTEX_T_OPAQUE;
202 #define FOSA_COND_T_OPAQUE pthread_cond_t
207 /** Not enough memory available **/
208 #define FOSA_ENOMEM ENOMEM
209 /** Invalid parameter **/
210 #define FOSA_EINVAL EINVAL
211 /** Still pending information **/
212 #define FOSA_EAGAIN EAGAIN
214 /** FOSA ADS errors **/
215 #define FOSA_EREJECT EREJECT
216 #define FOSA_EMASKED -2
217 #define FOSA_EPOLICY -3
219 #define FOSA_ETIMEDOUT ETIMEDOUT
223 /////////////////////// End of RT_LINUX /////////////////////////////
226 ////////////////////////// OSE //////////////////////////////////////
232 /* Put OSE dependent includes and defines here */
238 /////////////////////// AQuoSA ///////////////////////////
243 #include <linux/unistd.h>
245 #define _XOPEN_SOURCE 500
255 // typedef struct timespec fosa_rel_time_t;
256 // typedef struct timespec fosa_abs_time_t;
259 /* Threads and signals */
260 /***********************/
262 pthread_t pthread_id;
265 } FOSA_THREAD_ID_T_OPAQUE;
268 typedef pthread_attr_t FOSA_THREAD_ATTR_T_OPAQUE;
269 typedef int FOSA_SIGNAL_T_OPAQUE;
272 // The minimum and maximum signal numbers that may be used by the FRSH
274 #define FOSA_SIGNAL_MIN SIGRTMIN
275 #define FOSA_SIGNAL_MAX SIGRTMIN+0
277 #define FOSA_NULL_SIGNAL 0
280 /* Clocks and signals */
281 /**********************/
282 #define FOSA_CLOCK_ID_T_OPAQUE clockid_t
283 #define FOSA_SYSTEM_CLOCK_OPAQUE CLOCK_MONOTONIC
284 #define FOSA_TIMER_ID_T_OPAQUE timer_t
288 /* Mutex and cond vars */
289 /***********************/
290 typedef pthread_mutex_t FOSA_MUTEX_T_OPAQUE;
291 #define FOSA_COND_T_OPAQUE pthread_cond_t
294 /* Application Defined Scheduling */
295 /**********************************/
296 /* hack to get AQuoSA sources compile without having none
297 * of the application level scheduler header files and symbols */
298 #define posix_appsched_actions_t int
299 #define FOSA_LONG_JUMP_CONTEXT_T_OPAQUE int
301 #define FOSA_ADS_ACTIONS_T_OPAQUE posix_appsched_actions_t
306 /** Not enough memory available **/
307 #define FOSA_ENOMEM ENOMEM
309 /** Invalid parameter **/
310 #define FOSA_EINVAL EINVAL
312 /** Still pending information **/
313 #define FOSA_EAGAIN EAGAIN
315 #define FOSA_EREJECT EREJECT
316 #define FOSA_EMASKED -2
317 #define FOSA_EPOLICY -3
319 #define FOSA_ETIMEDOUT ETIMEDOUT
323 ////////////////// END of AQuoSA //////////////////////
327 /////////////////////////////////// PARTIKLE ///////////////////////////////////////////
328 #if defined(PARTIKLE)
339 posix_appsched_actions_t actions;
340 struct timespec * timeout_ptr;
341 struct timespec timeout;
345 } FOSA_ADS_ACTIONS_T_OPAQUE;
347 typedef unsigned long FOSA_LONG_JUMP_CONTEXT_T_OPAQUE [32];
349 typedef pthread_t FOSA_THREAD_ID_T_OPAQUE;
350 typedef pthread_attr_t FOSA_THREAD_ATTR_T_OPAQUE;
351 typedef int FOSA_SIGNAL_T_OPAQUE;
352 typedef clockid_t FOSA_CLOCK_ID_T_OPAQUE;
353 typedef timer_t FOSA_TIMER_ID_T_OPAQUE;
354 typedef pthread_cond_t FOSA_COND_T_OPAQUE;
355 typedef pthread_mutex_t FOSA_MUTEX_T_OPAQUE;
359 enum _fosa_clocks_e {
360 FOSA_SYSTEM_CLOCK_OPAQUE = CLOCK_MONOTONIC
363 #define LONGJMP_NSIG 3
365 #if LONGJMP_NSIG > (RTSIG_MAX - 1)
366 # error LONGJMP_NSIG too big (LONGJMP_NSIG > RTSIG_MAX - 1)
369 enum _fosa_signal_limits_e {
370 LONGJMP_FIRSTSIG = SIGRTMAX - LONGJMP_NSIG + 1,
371 FOSA_SIGNAL_MAX = LONGJMP_FIRSTSIG - 1,
372 FOSA_SIGNAL_MIN = FOSA_SIGNAL_MAX,
376 enum _fosa_errors_e {
377 FOSA_EINVAL = EINVAL,
378 FOSA_EAGAIN = EAGAIN,
379 FOSA_EREJECT = EREJECT,
380 FOSA_EMASKED = EMASKED,
381 FOSA_EPOLICY = EPOLICY,
382 FOSA_ETIMEDOUT = ETIMEDOUT,
383 FOSA_ENOMEM = ENOMEM,
387 /////////////////////////////////// PARTIKLE END //////////////////////////////////////
391 ////////////////////////// VIRTUAL TIME //////////////////////////////////////
396 // typedef struct timespec fosa_rel_time_t;
397 // typedef struct timespec fosa_abs_time_t;
401 #define FOSA_THREAD_ID_T_OPAQUE vt_posix_process_t
402 #define FOSA_THREAD_ATTR_T_OPAQUE fosa_thread_attr_t
403 #define FOSA_SIGNAL_T_OPAQUE int
405 #define FOSA_MUTEX_T_OPAQUE fosa_mutex_t
407 // The minimum and maximum signal numbers that may be used by the FRSH
409 #define FOSA_SIGNAL_MIN 8
410 #define FOSA_SIGNAL_MAX 31
412 // the min. and max. priority a fosa thread can have
413 #define FOSA_PRIORITY_MAX VT_PRIORITY_MIN - 1
414 #define FOSA_PRIORITY_MIN VT_PRIORITY_MAX
416 #define FOSA_NULL_SIGNAL 0
418 /* FOSA Errors and return values*/
420 /** Invalid parameter **/
421 #define FOSA_EINVAL -1
423 /** Not enough memory available **/
424 #define FOSA_ENOMEM -2
426 /** Still pending information **/
427 #define FOSA_EAGAIN -3
429 /** Mutex not available **/
430 #define FOSA_EBUSY -4
432 /** Cond var timedout **/
433 #define FOSA_ETIMEDOUT -5
435 /** FOSA ADS errors **/
436 #define FOSA_EREJECT -6
437 #define FOSA_EMASKED -7
440 /** Sched policy not correct */
441 #define FOSA_EPOLICY -8
443 /** the value given by thread_id is not valid for ADS */
444 #define FOSA_ESRCH -9
446 /** retval if no action performed **/
447 #define FOSA_NO_ACTION 0
449 #endif /* VIRTUAL_TIME */
450 //////////////////////////End of VIRTUAL TIME ///////////////////////////////////
453 ////////////////////////// DUMMY_OS //////////////////////////////////////
455 #if defined(DUMMY_OS)
457 /* With this define we make sure that we are truly POSIX and OSE */
458 /* independent at the FRSH code. */
459 /*****************************************************************/
463 // typedef struct timespec fosa_rel_time_t;
464 // typedef struct timespec fosa_abs_time_t;
466 /* Thread and signals */
467 /**********************/
468 typedef int FOSA_THREAD_ID_T_OPAQUE;
469 typedef int FOSA_THREAD_ATTR_T_OPAQUE;
471 typedef int FOSA_SIGNAL_T_OPAQUE;
472 typedef int FOSA_SIGNAL_INFO_T_OPAQUE;
474 /* Signal info is defined as a union in thread_and_signals */
476 #define FOSA_SIGNAL_MIN 42
477 #define FOSA_SIGNAL_MAX 44
479 #define FOSA_NULL_SIGNAL 0
481 /* Clocks and timers */
482 /**********************/
483 typedef int FOSA_CLOCK_ID_T_OPAQUE;
484 typedef int FOSA_TIMER_ID_T_OPAQUE;
486 #define FOSA_SYSTEM_CLOCK_OPAQUE 25
488 /* Mutex and conditional variables */
489 /***********************************/
490 typedef int FOSA_MUTEX_T_OPAQUE;
491 typedef int FOSA_COND_T_OPAQUE;
493 /* Application defined Scheduling */
494 /**********************************/
495 #define FOSA_ADS_ACTIONS_T_OPAQUE int
499 //////////////////////////End of DUMMY_OS ////////////////////////////////////
504 #endif // _FOSA_OPAQUE_TYPES_H_