1 // -----------------------------------------------------------------------
2 // Copyright (C) 2006 - 2008 FRESCOR consortium partners:
4 // Universidad de Cantabria, SPAIN
5 // University of York, UK
6 // Scuola Superiore Sant'Anna, ITALY
7 // Kaiserslautern University, GERMANY
8 // Univ. Politécnica 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 for a link to partners' websites
18 // 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 // FSF API web pages: http://marte.unican.es/fsf/docs
32 // http://shark.sssup.it/contrib/first/docs/
34 // This file is part of FOSA (Frsh Operating System Adaption)
36 // FOSA is free software; you can redistribute it and/or modify it
37 // under terms of the GNU General Public License as published by the
38 // Free Software Foundation; either version 2, or (at your option) any
39 // later version. FOSA is distributed in the hope that it will be
40 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
41 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
42 // General Public License for more details. You should have received a
43 // copy of the GNU General Public License along with FOSA; see file
44 // COPYING. If not, write to the Free Software Foundation, 675 Mass Ave,
45 // Cambridge, MA 02139, USA.
47 // As a special exception, including FOSA header files in a file,
48 // instantiating FOSA generics or templates, or linking other files
49 // with FOSA objects to produce an executable application, does not
50 // by itself cause the resulting executable application to be covered
51 // by the GNU General Public License. This exception does not
52 // however invalidate any other reasons why the executable file might be
53 // covered by the GNU Public License.
54 // -----------------------------------------------------------------------
56 //==============================================
57 // ******** ****** ******** **********
58 // **///// /** ** **////// /** /**
59 // ** /** ** /** /** /**
60 // ******* /** ** /********* /**********
61 // **//// /** ** ////////** /**//////**
62 // ** /** ** /** /** /**
63 // ** /** ** ******** /** /**
64 // // /******/ //////// // //
66 // FOSA(Frescor Operating System Adaptation layer)
67 //================================================
69 // Implementation dependent definitions
71 #ifndef _FOSA_OPAQUE_TYPES_H_
72 #define _FOSA_OPAQUE_TYPES_H_
76 #include "fosa_cpp_macros.h"
77 #include "fosa_opaque_types_time.h"
79 /////////////////////// MARTE_OS /////////////////////////////
92 /* Thread and signals */
93 /**********************/
94 typedef pthread_t FOSA_THREAD_ID_T_OPAQUE;
95 typedef pthread_attr_t FOSA_THREAD_ATTR_T_OPAQUE;
97 typedef int FOSA_SIGNAL_T_OPAQUE;
98 /* Signal info is defined as a union in thread_and_signals */
100 #define FOSA_SIGNAL_MIN SIGRTMIN
101 #define FOSA_SIGNAL_MAX SIGRTMIN+0
103 #define FOSA_NULL_SIGNAL 0
105 /* Clocks and timers */
106 /**********************/
107 typedef clockid_t FOSA_CLOCK_ID_T_OPAQUE;
108 typedef timer_t FOSA_TIMER_ID_T_OPAQUE;
110 #define FOSA_SYSTEM_CLOCK_OPAQUE CLOCK_MONOTONIC
112 /* Mutex and conditional variables */
113 /***********************************/
114 typedef pthread_mutex_t FOSA_MUTEX_T_OPAQUE;
115 typedef pthread_cond_t FOSA_COND_T_OPAQUE;
118 /* Application defined Scheduling */
119 /**********************************/
120 #define FOSA_ADS_ACTIONS_T_OPAQUE struct \
122 posix_appsched_actions_t actions; \
123 struct timespec *timeout_ptr; \
124 struct timespec timeout; \
133 #include "misc/marte_non_local_jmp.h"
135 #define FOSA_LONG_JUMP_CONTEXT_T_OPAQUE struct { \
136 marte_nonlocaljmp_context_t marte_context; \
137 fosa_thread_id_t tid; \
143 typedef marte_thread_set_t FOSA_THREAD_SET_ID_T_OPAQUE;
145 #define FOSA_NULL_THREAD_SET_ID_OPAQUE 0 /* In MaRTE-OS thread_set_t are
150 /** Not enough memory available **/
151 #define FOSA_ENOMEM ENOMEM
153 /** Invalid parameter **/
154 #define FOSA_EINVAL EINVAL
156 /** Still pending information **/
157 #define FOSA_EAGAIN EAGAIN
159 /** FOSA ADS errors **/
161 #define EREJECT 201 /* (for linux_lib_arch) Appsched has rejected object */
164 #define FOSA_EREJECT EREJECT
165 #define FOSA_EMASKED -2
166 #define FOSA_EPOLICY -3
168 #define FOSA_ETIMEDOUT ETIMEDOUT
170 /* Not found in search (non existing thread, thread_set...) */
171 #define FOSA_ESRCH ESRCH
172 #define FOSA_ENOTSUP ENOTSUP
176 /////////////////////// End of MARTE_OS /////////////////////////////
179 /////////////////////// RT_LINUX ///////////////////////////
183 /* Very similar to MARTE_OS but I leave separate for clarity */
190 #include <rtl_timer.h>
193 /* Threads and signals */
194 /***********************/
195 #define FOSA_THREAD_ID_T_OPAQUE pthread_t
197 typedef pthread_attr_t FOSA_THREAD_ATTR_T_OPAQUE;
198 typedef int FOSA_SIGNAL_T_OPAQUE;
199 /* Signal info is defined as a union in fosa_types.h */
201 // The minimum and maximum signal numbers that may be used by the FRSH
203 #define FOSA_SIGNAL_MIN SIGRTMIN
204 #define FOSA_SIGNAL_MAX SIGRTMIN+0
205 #define FOSA_NULL_SIGNAL 0
207 /* Clocks and timers */
208 /*********************/
209 #define FOSA_CLOCK_ID_T_OPAQUE clockid_t
210 #define FOSA_TIMER_ID_T_OPAQUE timer_t
211 #define FOSA_SYSTEM_CLOCK_OPAQUE CLOCK_MONOTONIC
213 /* Mutex and cond vars */
214 /***********************/
215 typedef pthread_mutex_t FOSA_MUTEX_T_OPAQUE;
216 #define FOSA_COND_T_OPAQUE pthread_cond_t
220 typedef int FOSA_THREAD_SET_ID_T_OPAQUE
224 /** Not enough memory available **/
225 #define FOSA_ENOMEM ENOMEM
226 /** Invalid parameter **/
227 #define FOSA_EINVAL EINVAL
228 /** Still pending information **/
229 #define FOSA_EAGAIN EAGAIN
231 /** FOSA ADS errors **/
232 #define FOSA_EREJECT EREJECT
233 #define FOSA_EMASKED -2
234 #define FOSA_EPOLICY -3
236 #define FOSA_ETIMEDOUT ETIMEDOUT
240 /////////////////////// End of RT_LINUX /////////////////////////////
243 ////////////////////////// OSE //////////////////////////////////////
249 /* Put OSE dependent includes and defines here */
255 /////////////////////// AQuoSA ///////////////////////////
260 #include <linux/unistd.h>
262 #ifndef _XOPEN_SOURCE
263 #define _XOPEN_SOURCE 500
279 typedef sigjmp_buf FOSA_LONG_JUMP_CONTEXT_T_OPAQUE;
282 /* Threads and signals */
283 /***********************/
285 pthread_t pthread_id;
288 } FOSA_THREAD_ID_T_OPAQUE;
291 typedef pthread_attr_t FOSA_THREAD_ATTR_T_OPAQUE;
292 typedef int FOSA_SIGNAL_T_OPAQUE;
295 // The minimum and maximum signal numbers that may be used by the FRSH
297 #define FOSA_SIGNAL_MIN SIGRTMIN
298 #define FOSA_SIGNAL_MAX SIGRTMIN+0
300 #define FOSA_NULL_SIGNAL 0
305 typedef int FOSA_THREAD_SET_ID_T_OPAQUE;
307 /* Clocks and signals */
308 /**********************/
309 #define FOSA_CLOCK_ID_T_OPAQUE clockid_t
310 #define FOSA_SYSTEM_CLOCK_OPAQUE CLOCK_MONOTONIC
311 #define FOSA_TIMER_ID_T_OPAQUE timer_t
315 /* Mutex and cond vars */
316 /***********************/
317 typedef pthread_mutex_t FOSA_MUTEX_T_OPAQUE;
318 #define FOSA_COND_T_OPAQUE pthread_cond_t
321 /* Application Defined Scheduling */
322 /**********************************/
323 /* hack to get AQuoSA sources compile without having none
324 * of the application level scheduler header files and symbols */
325 #define posix_appsched_actions_t int
327 #define FOSA_ADS_ACTIONS_T_OPAQUE posix_appsched_actions_t
332 /** Not enough memory available **/
333 #define FOSA_ENOMEM ENOMEM
335 /** Invalid parameter **/
336 #define FOSA_EINVAL EINVAL
338 /** Still pending information **/
339 #define FOSA_EAGAIN EAGAIN
341 #define FOSA_EREJECT EREJECT
342 #define FOSA_EMASKED -2
343 #define FOSA_EPOLICY -3
345 #define FOSA_ETIMEDOUT ETIMEDOUT
349 ////////////////// END of AQuoSA //////////////////////
353 ///////////////////////////////// PARTIKLE /////////////////////////////////////
354 #if defined(PARTIKLE)
365 posix_appsched_actions_t actions;
366 struct timespec * timeout_ptr;
367 struct timespec timeout;
371 } FOSA_ADS_ACTIONS_T_OPAQUE;
374 typedef pthread_t FOSA_THREAD_ID_T_OPAQUE;
375 typedef pthread_attr_t FOSA_THREAD_ATTR_T_OPAQUE;
376 typedef int FOSA_SIGNAL_T_OPAQUE;
377 typedef clockid_t FOSA_CLOCK_ID_T_OPAQUE;
378 typedef timer_t FOSA_TIMER_ID_T_OPAQUE;
379 typedef pthread_cond_t FOSA_COND_T_OPAQUE;
380 typedef pthread_mutex_t FOSA_MUTEX_T_OPAQUE;
381 typedef unsigned long FOSA_LONG_JUMP_CONTEXT_T_OPAQUE [32];
382 typedef group_clock_t FOSA_THREAD_SET_ID_T_OPAQUE;
384 #define FOSA_NULL_THREAD_SET_ID_OPAQUE 0x0;
386 enum _fosa_clocks_e {
387 FOSA_SYSTEM_CLOCK_OPAQUE = CLOCK_MONOTONIC
390 #define LONGJMP_NSIG 3
392 #if LONGJMP_NSIG > (RTSIG_MAX - 1)
393 # error LONGJMP_NSIG too big (LONGJMP_NSIG > RTSIG_MAX - 1)
396 enum _fosa_signal_limits_e {
397 LONGJMP_FIRSTSIG = SIGRTMAX - LONGJMP_NSIG + 1,
398 FOSA_SIGNAL_MAX = LONGJMP_FIRSTSIG - 1,
399 FOSA_SIGNAL_MIN = SIGRTMIN,
400 FOSA_NULL_SIGNAL = -1,
404 enum _fosa_errors_e {
405 FOSA_EINVAL = EINVAL,
406 FOSA_EAGAIN = EAGAIN,
407 FOSA_EREJECT = EREJECT,
408 FOSA_EMASKED = EMASKED,
409 FOSA_EPOLICY = EPOLICY,
410 FOSA_ETIMEDOUT = ETIMEDOUT,
411 FOSA_ENOMEM = ENOMEM,
416 /////////////////////////////// PARTIKLE END //////////////////////////////////
420 ////////////////////////// VIRTUAL TIME //////////////////////////////////////
425 // typedef struct timespec fosa_rel_time_t;
426 // typedef struct timespec fosa_abs_time_t;
430 #define FOSA_THREAD_ID_T_OPAQUE vt_posix_process_t
431 #define FOSA_THREAD_ATTR_T_OPAQUE fosa_thread_attr_t
432 #define FOSA_SIGNAL_T_OPAQUE int
434 #define FOSA_MUTEX_T_OPAQUE fosa_mutex_t
436 // The minimum and maximum signal numbers that may be used by the FRSH
438 #define FOSA_SIGNAL_MIN 8
439 #define FOSA_SIGNAL_MAX 31
441 // the min. and max. priority a fosa thread can have
442 #define FOSA_PRIORITY_MAX VT_PRIORITY_MIN - 1
443 #define FOSA_PRIORITY_MIN VT_PRIORITY_MAX
445 #define FOSA_NULL_SIGNAL 0
447 /* FOSA Errors and return values*/
449 /** Invalid parameter **/
450 #define FOSA_EINVAL -1
452 /** Not enough memory available **/
453 #define FOSA_ENOMEM -2
455 /** Still pending information **/
456 #define FOSA_EAGAIN -3
458 /** Mutex not available **/
459 #define FOSA_EBUSY -4
461 /** Cond var timedout **/
462 #define FOSA_ETIMEDOUT -5
464 /** FOSA ADS errors **/
465 #define FOSA_EREJECT -6
466 #define FOSA_EMASKED -7
469 /** Sched policy not correct */
470 #define FOSA_EPOLICY -8
472 /** the value given by thread_id is not valid for ADS */
473 #define FOSA_ESRCH -9
475 /** retval if no action performed **/
476 #define FOSA_NO_ACTION 0
478 #endif /* VIRTUAL_TIME */
479 //////////////////////////End of VIRTUAL TIME ///////////////////////////////////
482 ////////////////////////// DUMMY_OS //////////////////////////////////////
484 #if defined(DUMMY_OS)
486 /* With this define we make sure that we are truly POSIX and OSE */
487 /* independent at the FRSH code. */
488 /*****************************************************************/
492 // typedef struct timespec fosa_rel_time_t;
493 // typedef struct timespec fosa_abs_time_t;
495 /* Thread and signals */
496 /**********************/
497 typedef int FOSA_THREAD_ID_T_OPAQUE;
498 typedef int FOSA_THREAD_ATTR_T_OPAQUE;
500 typedef int FOSA_SIGNAL_T_OPAQUE;
501 typedef int FOSA_SIGNAL_INFO_T_OPAQUE;
503 /* Signal info is defined as a union in thread_and_signals */
505 #define FOSA_SIGNAL_MIN 42
506 #define FOSA_SIGNAL_MAX 44
508 #define FOSA_NULL_SIGNAL 0
510 /* Clocks and timers */
511 /**********************/
512 typedef int FOSA_CLOCK_ID_T_OPAQUE;
513 typedef int FOSA_TIMER_ID_T_OPAQUE;
515 #define FOSA_SYSTEM_CLOCK_OPAQUE 25
517 /* Mutex and conditional variables */
518 /***********************************/
519 typedef int FOSA_MUTEX_T_OPAQUE;
520 typedef int FOSA_COND_T_OPAQUE;
522 /* Application defined Scheduling */
523 /**********************************/
524 #define FOSA_ADS_ACTIONS_T_OPAQUE int
528 //////////////////////////End of DUMMY_OS ////////////////////////////////////
533 #endif // _FOSA_OPAQUE_TYPES_H_