]> rtime.felk.cvut.cz Git - frescor/frsh-include.git/blob - frsh_os_compatibility.h
Adding new distributed systems
[frescor/frsh-include.git] / frsh_os_compatibility.h
1 // -----------------------------------------------------------------------
2 //  Copyright (C) 2006 - 2007 FRESCOR consortium partners:
3 //
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
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 for a link to partners' websites
17 //
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
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 //   FSF API web pages: http://marte.unican.es/fsf/docs
32 //                      http://shark.sssup.it/contrib/first/docs/
33 //
34 //  This file is part of FRSH API
35 //
36 //  FRSH API is free software; you can  redistribute it and/or  modify
37 //  it under the terms of  the GNU General Public License as published by
38 //  the Free Software Foundation;  either  version 2, or (at  your option)
39 //  any later version.
40 //
41 //  FRSH API  is distributed  in  the hope  that  it  will  be useful,  but
42 //  WITHOUT  ANY  WARRANTY;     without  even the   implied   warranty  of
43 //  MERCHANTABILITY  or  FITNESS FOR  A  PARTICULAR PURPOSE. See  the  GNU
44 //  General Public License for more details.
45 //
46 //  You should have  received a  copy of  the  GNU  General Public License
47 //  distributed  with  FRSH API;  see file COPYING.   If not,  write to the
48 //  Free Software  Foundation,  59 Temple Place  -  Suite 330,  Boston, MA
49 //  02111-1307, USA.
50 //
51 //  As a special exception, if you include this header file into source
52 //  files to be compiled, this header file does not by itself cause
53 //  the resulting executable to be covered by the GNU General Public
54 //  License.  This exception does not however invalidate any other
55 //  reasons why the executable file might be covered by the GNU General
56 //  Public License.
57 // -----------------------------------------------------------------------
58 //==============================================
59 //  ******** *******    ********  **      **
60 //  **///// /**////**  **//////  /**     /**
61 //  **      /**   /** /**        /**     /**
62 //  ******* /*******  /********* /**********
63 //  **////  /**///**  ////////** /**//////**
64 //  **      /**  //**        /** /**     /**
65 //  **      /**   //** ********  /**     /**
66 //  //       //     // ////////   //      // 
67 //
68 // FRSH(FRescor ScHeduler), pronounced "fresh"
69 //==============================================
70
71 // Header file that allows a general testing code to be used for calling
72 // the FRSH primitives in both platforms: MaRTE_OS and SHARK
73
74 #ifndef _FRSH_OS_COMPATIBILITY_H_
75 #define _FRSH_OS_COMPATIBILITY_H_
76 /////////////////////////////SHARK SECTION /////////////////////////////
77 #ifndef MARTE_FRSH
78
79 #define  INITIALIZATION_CODE   \
80 {                              \
81   calibrate_cycle();           \
82   init_network();              \
83 }
84
85 #define FRSH_STI kern_sti
86
87 #define FRSH_CLI kern_cli
88
89
90 //#define frsh_printf udp_print
91 #define frsh_printf cprintf
92 #define printf cprintf
93 /*
94 double
95 t2d(struct timespec time)
96 {
97           return time.tv_nsec*0.000000001 + (double)time.tv_sec;
98 }
99 */
100 #define t2d( ts ) ((ts).tv_nsec*0.000000001 + (double)((ts).tv_sec))
101
102 #define ERROR(nn, ss) { if(errno==0) errno=nn ; kern_printf(ss); exit(nn);}
103
104 #define FINALIZATION_CODE { exit(0); }
105
106 #define STANDARD_CONSOLE_INIT { }
107 #define SERIAL_CONSOLE_INIT { }
108 #define EAT eat
109 #endif /* SHARK_FRSH */
110 //////////////////////////END OF SHARK SECTION /////////////////////////
111
112
113 /////////////////////////////MARTE SECTION /////////////////////////////
114 #ifdef MARTE_FRSH
115 #include <misc/serial_console.h>
116 #include <misc/load.h>
117 #include "calibrate.h"
118
119 #include <debug_marte.h>
120 #include <sys/pio.h>
121
122
123 #define  INITIALIZATION_CODE \
124 {                                                                         \
125         /*printf("max_prio = %d\n", sched_get_priority_max(SCHED_FIFO));*/\
126         /*printf("min_prio = %d\n", sched_get_priority_min(SCHED_FIFO));*/\
127         /*SERIAL_CONSOLE_INIT;*/ /*marte1.26i+                              */\
128         init_serial_communication_with_gdb(SERIAL_PORT_1);            \
129         /*printf("max_prio = %d\n", sched_get_priority_max(SCHED_FIFO));*/\
130                                                                           \
131         calibrate_cycle();  /*adjust();*/                                \
132         /*printf("min_prio = %d\n", sched_get_priority_min(SCHED_FIFO));*/\
133         /*set_break_point_here;                                         */\
134 }
135
136 #define ERROR(nn, ss) {if(errno==0) errno=(nn); perror(ss); exit (nn);}
137
138 #define FRSH_STI sti
139
140 #define FRSH_CLI cli
141
142 int
143 frsh_priority_map (unsigned long plevel)
144 {
145         return plevel;
146 }
147
148 #define frsh_printf  printf
149
150 extern int   stop_scheduler; /* Defined at frsh_scheduler.h */
151 //#define FINALIZATION_CODE { stop_scheduler=1; eat(1.0); return 0; }
152 #define FINALIZATION_CODE { stop_scheduler=1; eat_cycles(1000000); return 0; }
153
154 //#define EAT( tt ) eat( (double)(tt)/(double)1000000 )
155 #define EAT eat_cycles
156
157 #endif /* MARTE_FRSH */
158 //////////////////////////END OF MARTE SECTION /////////////////////////
159
160 #endif /* _FRSH_OS_COMPATIBILITY_H_ */