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