]> rtime.felk.cvut.cz Git - frescor/fosa.git/blob - include/fosa_opaque_types.h
21af0c0298f83661aeae298cf723437d3ea6e658
[frescor/fosa.git] / include / fosa_opaque_types.h
1 //----------------------------------------------------------------------
2 //  Copyright (C) 2006 - 2007 by the FRESCOR consortium:
3 //
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
10 //    ENEA                                   SWEDEN
11 //    Thales Communication S.A.              FRANCE
12 //    Visual Tools S.A.                      SPAIN
13 //    Rapita Systems Ltd                     UK
14 //    Evidence                               ITALY
15 //
16 //    See http://www.frescor.org
17 //
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
21 //        made of this code.
22 //
23 //
24 //  based on previous work (FSF) done in the FIRST project
25 //
26 //   Copyright (C) 2005  Mälardalen University, SWEDEN
27 //                       Scuola Superiore S.Anna, ITALY
28 //                       Universidad de Cantabria, SPAIN
29 //                       University of York, UK
30 //
31 // This file is part of FOSA (Frsh Operating System Abstraction)
32 //
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.
43 //
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 // -----------------------------------------------------------------------
52 //fosa_opaque_types.h
53 //==============================================
54 //  ********  ******    ********  **********
55 //  **///// /**    **  **//////  /**     /**
56 //  **      /**    ** /**        /**     /**
57 //  ******* /**    ** /********* /**********
58 //  **////  /**    ** ////////** /**//////**
59 //  **      /**    **        /** /**     /**
60 //  **      /**    **  ********  /**     /**
61 //  //       /******/  ////////   //      //
62 //
63 // FOSA(Frescor Operating System Adaptation layer)
64 //================================================
65
66 // Implementation dependent definitions
67
68 #ifndef _FOSA_OPAQUE_TYPES_H_
69 #define _FOSA_OPAQUE_TYPES_H_
70
71 #include <stdbool.h>
72
73 ///////////////////////  MARTE_OS /////////////////////////////
74
75 #ifdef MARTE_OS
76
77 #include <pthread.h>
78 #include <signal.h>
79 #include <time.h>
80 #include <sched.h>
81 #include <errno.h>
82
83 /* Time */
84 /********/
85 // typedef struct timespec fosa_rel_time_t;
86 // typedef struct timespec fosa_abs_time_t;
87
88 /* Thread and signals */
89 /**********************/
90 typedef pthread_t FOSA_THREAD_ID_T_OPAQUE;
91 typedef pthread_attr_t FOSA_THREAD_ATTR_T_OPAQUE;
92
93 typedef int FOSA_SIGNAL_T_OPAQUE;
94 /* Signal info is defined as a union in thread_and_signals */
95
96 #define FOSA_SIGNAL_MIN       SIGRTMIN
97 #define FOSA_SIGNAL_MAX       SIGRTMIN+0
98
99 #define FOSA_NULL_SIGNAL 0
100
101 /* Clocks and timers */
102 /**********************/
103 typedef clockid_t FOSA_CLOCK_ID_T_OPAQUE;
104 typedef timer_t FOSA_TIMER_ID_T_OPAQUE;
105
106 #define FOSA_SYSTEM_CLOCK_OPAQUE  CLOCK_MONOTONIC
107
108 /* Mutex and conditional variables */
109 /***********************************/
110 typedef pthread_mutex_t FOSA_MUTEX_T_OPAQUE;
111 typedef pthread_cond_t FOSA_COND_T_OPAQUE;
112
113
114 /* Application defined Scheduling */
115 /**********************************/
116 typedef struct {
117     posix_appsched_actions_t actions;
118     struct timespec *timeout_ptr;
119     struct timespec timeout;
120     bool rejected;
121     bool suspended;
122     bool activated;
123 } fosa_ads_actions_internal_t;
124
125 #define FOSA_ADS_ACTIONS_T_OPAQUE fosa_ads_actions_internal_t
126
127 /* Local jump */
128 /**************/
129 #include "marte_non_local_jmp.h"
130
131 #define FOSA_LONG_JUMP_CONTEXT_T_OPAQUE  struct { \
132   marte_nonlocaljmp_context_t marte_context;      \
133   fosa_thread_id_t tid;                            \
134 }
135
136
137 /* FOSA errors */
138 /***************/
139 /** Not enough memory available **/
140 #define FOSA_ENOMEM   ENOMEM
141
142 /** Invalid parameter **/
143 #define FOSA_EINVAL   EINVAL
144
145 /** Still pending information **/
146 #define FOSA_EAGAIN   EAGAIN
147
148 /** FOSA ADS errors **/
149 #ifdef MARTE_OS
150 #define EREJECT   201 /* (for linux_lib_arch) Appsched has rejected object */
151 #endif
152
153 #define FOSA_EREJECT   EREJECT
154 #define FOSA_EMASKED   -2
155 #define FOSA_EPOLICY   -3
156
157 #define FOSA_ETIMEDOUT ETIMEDOUT
158
159 #endif
160
161 ///////////////////////  End of MARTE_OS  /////////////////////////////
162
163
164 /////////////////////// RT_LINUX ///////////////////////////
165
166 #ifdef RT_LINUX
167
168 /* Very similar to MARTE_OS but I leave separate for clarity */
169
170 #include <pthread.h>
171 #include <signal.h>
172 #include <time.h>
173 #include <sched.h>
174 #include <errno.h>
175 #include <rtl_timer.h>
176
177 /* Time */
178 /********/
179 // typedef struct timespec fosa_rel_time_t;
180 // typedef struct timespec fosa_abs_time_t;
181
182
183 /* Threads and signals */
184 /***********************/
185 #define    FOSA_THREAD_ID_T_OPAQUE pthread_t
186
187 typedef pthread_attr_t FOSA_THREAD_ATTR_T_OPAQUE;
188 typedef int FOSA_SIGNAL_T_OPAQUE;
189 /* Signal info is defined as a union in fosa_types.h */
190
191 // The minimum and maximum signal numbers that may be used by the FRSH
192 // implementation
193 #define FOSA_SIGNAL_MIN       SIGRTMIN
194 #define FOSA_SIGNAL_MAX       SIGRTMIN+0
195 #define FOSA_NULL_SIGNAL 0
196
197 /* Clocks and timers */
198 /*********************/
199 #define    FOSA_CLOCK_ID_T_OPAQUE    clockid_t
200 #define    FOSA_TIMER_ID_T_OPAQUE    timer_t
201 #define    FOSA_SYSTEM_CLOCK_OPAQUE  CLOCK_MONOTONIC
202
203 /* Mutex and cond vars */
204 /***********************/
205 typedef pthread_mutex_t FOSA_MUTEX_T_OPAQUE;
206 #define    FOSA_COND_T_OPAQUE        pthread_cond_t
207
208
209 /* FOSA Errors */
210 /***************/
211 /** Not enough memory available **/
212 #define FOSA_ENOMEM   ENOMEM
213 /** Invalid parameter **/
214 #define FOSA_EINVAL   EINVAL
215 /** Still pending information **/
216 #define FOSA_EAGAIN   EAGAIN
217
218 /** FOSA ADS errors **/
219 #define FOSA_EREJECT   EREJECT
220 #define FOSA_EMASKED   -2
221 #define FOSA_EPOLICY   -3
222
223 #define FOSA_ETIMEDOUT ETIMEDOUT
224
225 #endif
226
227 ///////////////////////  End of RT_LINUX  /////////////////////////////
228
229
230 ////////////////////////// OSE    //////////////////////////////////////
231
232 #ifdef OSE
233
234 /* Time */
235 /********/
236 // typedef struct timespec fosa_rel_time_t;
237 // typedef struct timespec fosa_abs_time_t;
238
239
240 /* Put OSE dependent includes and defines here */
241
242 #endif /* OSE */
243
244
245
246 /////////////////////// AQuoSA ///////////////////////////
247
248 #ifdef AQuoSA
249
250 #define __USE_UNIX98
251
252 #include <pthread.h>
253 #include <signal.h>
254 #include <errno.h>
255 #include <time.h>
256
257 /* Time */
258 /********/
259 // typedef struct timespec fosa_rel_time_t;
260 // typedef struct timespec fosa_abs_time_t;
261
262
263 /* Threads and signals */
264 /***********************/
265 typedef struct {
266         pthread_t pthread_id;
267         pid_t linux_pid;
268         pid_t linux_tid;
269 } FOSA_THREAD_ID_T_OPAQUE;
270
271
272 typedef pthread_attr_t FOSA_THREAD_ATTR_T_OPAQUE;
273 typedef int FOSA_SIGNAL_T_OPAQUE;
274
275
276 // The minimum and maximum signal numbers that may be used by the FRSH
277 // implementation
278 #define FOSA_SIGNAL_MIN       SIGRTMIN
279 #define FOSA_SIGNAL_MAX       SIGRTMIN+0
280
281 #define FOSA_NULL_SIGNAL 0
282
283
284 /* Clocks and signals */
285 /**********************/
286 #define    FOSA_CLOCK_ID_T_OPAQUE    clockid_t
287 #define    FOSA_SYSTEM_CLOCK_OPAQUE  CLOCK_MONOTONIC
288 #define    FOSA_TIMER_ID_T_OPAQUE    timer_t
289
290
291
292 /* Mutex and cond vars */
293 /***********************/
294 typedef pthread_mutex_t FOSA_MUTEX_T_OPAQUE;
295 #define    FOSA_COND_T_OPAQUE        pthread_cond_t
296
297
298 /* Application Defined Scheduling */
299 /**********************************/
300 /* hack to get AQuoSA sources compile without having none
301  * of the application level scheduler header files and symbols */
302 #define posix_appsched_actions_t int
303 #define FOSA_LONG_JUMP_CONTEXT_T_OPAQUE int
304
305 #define FOSA_ADS_ACTIONS_T_OPAQUE posix_appsched_actions_t
306
307
308 /* FOSA Errors */
309
310 /** Not enough memory available **/
311 #define FOSA_ENOMEM   ENOMEM
312
313 /** Invalid parameter **/
314 #define FOSA_EINVAL   EINVAL
315
316 /** Still pending information **/
317 #define FOSA_EAGAIN   EAGAIN
318
319 #define FOSA_EREJECT   EREJECT
320 #define FOSA_EMASKED   -2
321 #define FOSA_EPOLICY   -3
322
323 #define FOSA_ETIMEDOUT ETIMEDOUT
324
325
326 #endif 
327 ////////////////// END of AQuoSA //////////////////////
328
329
330
331 /////////////////////////////////// PARTIKLE ///////////////////////////////////////////
332 #if defined(PARTIKLE)
333
334 #include <pthread.h>
335 #include <signal.h>
336 #include <time.h>
337 #include <sched.h>
338 #include <stdlib.h>
339
340 typedef struct {
341     posix_appsched_actions_t actions;
342     struct timespec * timeout_ptr;
343     struct timespec timeout;
344     bool rejected;
345     bool suspended;
346     bool activated;
347 } fosa_ads_actions_internal_t;
348
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 fosa_ads_actions_internal_t FOSA_ADS_ACTIONS_T_OPAQUE;
353 typedef clockid_t                   FOSA_CLOCK_ID_T_OPAQUE;
354 typedef timer_t                     FOSA_TIMER_ID_T_OPAQUE;
355 typedef pthread_cond_t              FOSA_COND_T_OPAQUE;
356 typedef pthread_mutex_t             FOSA_MUTEX_T_OPAQUE;
357 typedef void *                      FOSA_LONG_JUMP_CONTEXT_T_OPAQUE;
358
359
360 enum _fosa_clocks_e {
361   FOSA_SYSTEM_CLOCK_OPAQUE = CLOCK_MONOTONIC
362 };
363
364 enum _fosa_signal_limits_e {
365   FOSA_SIGNAL_MIN = SIGRTMIN,
366   FOSA_SIGNAL_MAX = SIGRTMAX,
367 };
368
369 enum _fosa_errors_e {
370   FOSA_EINVAL = EINVAL,
371   FOSA_EAGAIN = EAGAIN,
372   FOSA_EREJECT = EREJECT,
373   FOSA_EMASKED = EMASKED,
374   FOSA_EPOLICY = EPOLICY, 
375   FOSA_ETIMEDOUT = ETIMEDOUT,
376   FOSA_ENOMEM = ENOMEM,
377 };
378
379 #endif
380 /////////////////////////////////// PARTIKLE  END //////////////////////////////////////
381
382
383
384 ////////////////////////// VIRTUAL TIME    //////////////////////////////////////
385 #ifdef VIRTUAL_TIME
386
387 /* Time */
388 /********/
389 // typedef struct timespec fosa_rel_time_t;
390 // typedef struct timespec fosa_abs_time_t;
391
392 #include <fosa_vt.h>
393
394 #define FOSA_THREAD_ID_T_OPAQUE   vt_posix_process_t
395 #define FOSA_THREAD_ATTR_T_OPAQUE fosa_thread_attr_t
396 #define FOSA_SIGNAL_T_OPAQUE      int
397
398 #define FOSA_MUTEX_T_OPAQUE fosa_mutex_t
399
400 // The minimum and maximum signal numbers that may be used by the FRSH
401 // implementation
402 #define FOSA_SIGNAL_MIN       8
403 #define FOSA_SIGNAL_MAX       31
404
405 // the min. and max. priority a fosa thread can have
406 #define FOSA_PRIORITY_MAX VT_PRIORITY_MIN - 1
407 #define FOSA_PRIORITY_MIN VT_PRIORITY_MAX
408
409 #define FOSA_NULL_SIGNAL        0
410
411 /* FOSA Errors and return values*/
412
413 /** Invalid parameter **/
414 #define FOSA_EINVAL   -1
415
416 /** Not enough memory available **/
417 #define FOSA_ENOMEM   -2
418
419 /** Still pending information **/
420 #define FOSA_EAGAIN   -3
421
422 /** Mutex not available **/
423 #define FOSA_EBUSY         -4
424
425 /** Cond var timedout **/
426 #define FOSA_ETIMEDOUT  -5
427
428 /** FOSA ADS errors **/
429 #define FOSA_EREJECT   -6
430 #define FOSA_EMASKED   -7
431
432
433 /** Sched policy not correct */
434 #define FOSA_EPOLICY    -8
435
436 /** the value given by thread_id is not valid for ADS */
437 #define FOSA_ESRCH              -9
438
439 /** retval if no action performed **/
440 #define FOSA_NO_ACTION  0
441
442 #endif /* VIRTUAL_TIME */
443 //////////////////////////End of VIRTUAL TIME ///////////////////////////////////
444
445
446 ////////////////////////// DUMMY_OS    //////////////////////////////////////
447
448 #if defined(DUMMY_OS)
449
450 /* With this define we make sure that we are truly POSIX and OSE */
451 /* independent at the FRSH code.                                 */
452 /*****************************************************************/
453
454 /* Time */
455 /********/
456 // typedef struct timespec fosa_rel_time_t;
457 // typedef struct timespec fosa_abs_time_t;
458
459 /* Thread and signals */
460 /**********************/
461 typedef int FOSA_THREAD_ID_T_OPAQUE;
462 typedef int FOSA_THREAD_ATTR_T_OPAQUE;
463
464 typedef int FOSA_SIGNAL_T_OPAQUE;
465 typedef int FOSA_SIGNAL_INFO_T_OPAQUE;
466
467 /* Signal info is defined as a union in thread_and_signals */
468
469 #define FOSA_SIGNAL_MIN     42
470 #define FOSA_SIGNAL_MAX     44
471
472 #define FOSA_NULL_SIGNAL 0
473
474 /* Clocks and timers */
475 /**********************/
476 typedef int FOSA_CLOCK_ID_T_OPAQUE;
477 typedef int FOSA_TIMER_ID_T_OPAQUE;
478
479 #define FOSA_SYSTEM_CLOCK_OPAQUE  25
480
481 /* Mutex and conditional variables */
482 /***********************************/
483 typedef int FOSA_MUTEX_T_OPAQUE;
484 typedef int FOSA_COND_T_OPAQUE;
485
486 /* Application defined Scheduling */
487 /**********************************/
488 #define FOSA_ADS_ACTIONS_T_OPAQUE  int
489
490
491 #endif /* DUMMY */
492 //////////////////////////End of DUMMY_OS ////////////////////////////////////
493
494
495
496
497 #endif // _FOSA_OPAQUE_TYPES_H_