]> rtime.felk.cvut.cz Git - frescor/fosa.git/blob - src_ose/fosa_ose_implementation_specific.h
Makefile: Add missing header file
[frescor/fosa.git] / src_ose / fosa_ose_implementation_specific.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 //  All rights reserved.
24 //
25 //  Redistribution and use in source and binary forms, with or 
26 //  without modification, are permitted provided that the 
27 //  following conditions are met:
28 //
29 //    * Redistributions of source code must retain the above 
30 //      copyright notice, this list of conditions and the 
31 //      following disclaimer.
32 //    * Redistributions in binary form must reproduce the above 
33 //      copyright notice, this list of conditions and the 
34 //      following disclaimer in the documentation and/or other 
35 //      materials provided with the distribution.
36 //    * Neither the name of FRESCOR nor the names of its 
37 //      contributors may be used to endorse or promote products 
38 //      derived from this software without specific prior 
39 //      written permission.
40 //
41 //  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
42 //  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
43 //  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
44 //  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
45 //  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
46 //  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
47 //  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
48 //  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 
49 //  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 
50 //  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
51 //  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
52 //  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 
53 //  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
54 //  POSSIBILITY OF SUCH DAMAGE.
55 // -----------------------------------------------------------------------
56 //fosa_ose_implementation_specific.h
57 //==============================================
58 //  ********  ******    ********  **********
59 //  **///// /**    **  **//////  /**     /**
60 //  **      /**    ** /**        /**     /**
61 //  ******* /**    ** /********* /**********
62 //  **////  /**    ** ////////** /**//////**
63 //  **      /**    **        /** /**     /**
64 //  **      /**    **  ********  /**     /**
65 //  //       /******/  ////////   //      // 
66 //
67 // FOSA(Frescor Operating System Adaptation layer)
68 //================================================
69
70 /*
71  * Intended to be used only by internal .c files to include all
72  * internal declarations visible only within the src library directory.
73  *
74  * It is not used by any .h file to avoid include deadlocks.
75  */
76
77
78 #ifndef     FOSA_OSE_IMPLEMENTATION_SPECIFIC_H
79 #define     FOSA_OSE_IMPLEMENTATION_SPECIFIC_H
80
81 #include "fosa_ose_signals.sig" //The only place where this file is incl.
82 #include "fosa_ose_types.h"
83
84 #include "ose.h"
85 //#include "fosa.h"
86
87 //Debug purpose only:
88 #include "ramlog.h"
89
90 /*************************
91  * Global Data
92  *************************/ 
93
94 /*
95  * author erth
96  *
97  * This global variable is used to initialize a process when made by
98  * fosa_thread_create. It makes the names of the processes to 
99  * "fosa_ose_1", "fosa_ose_2" and so on.
100  */
101 extern unsigned int process_name_number;
102
103 /*
104  * author erth
105  *
106  * Global bool to keep track of if the keys array are initialized (all set
107  * two false) these are used in the functions fosa_key_create() and 
108  * fosa_key_destroy().
109  */
110 extern bool fosa_ose_keys_initialized;
111 extern bool fosa_ose_keys_taken[];
112
113 /*************************
114  * General Help Functions
115  *************************/ 
116
117 /*
118  * author erth
119  *
120  * Function to convert systime, or actually system_tick and microseconds
121  * to timespec, or seconds and nanoseconds. 
122  */
123 void fosa_ose_systime_to_timespec(unsigned long ticks, 
124                     unsigned long microsec, struct timespec* time);
125
126 /*************************
127  * Process Specific Functions
128  *************************/ 
129
130 /*
131  * author erth
132  *
133  * Internal function that takes a pid as argument and returns true if it
134  * is an active process (OS_BG_PROC, OS_PRI_PROC, OS_TI_PROC, OS_INT_PROC
135  * or OS_PHANTOM process), otherwise false are returned.
136  */
137 bool fosa_ose_is_process(PROCESS Pid);
138
139 extern fosa_ose_process_info_t* fosa_ose_processes;
140
141 /*
142  * author erth
143  *
144  * This function returns a pointer to the node with the given pid in the 
145  * fosa_ose_processes list.
146  */
147 fosa_ose_process_info_t* fosa_ose_process_get_node(frsh_thread_id_t pid);
148
149 /*
150  * author erth
151  *
152  * This function is called to remove a node in the list fosa_ose_processes
153  * prefferable from the kill handler, or the scheduler.
154  * 
155  * return 0 if success.
156  */
157 int fosa_ose_process_list_node_remove(frsh_thread_id_t pid);
158
159 /*************************
160  * Application defined scheduling functions
161  *************************/ 
162
163 /*
164  * author erth
165  *
166  * Function to initialize an action queue. This function should be used
167  * before the fosa_ads_actions_t type can be used by other functions.
168  */
169 void fosa_ose_ads_actions_init(fosa_ads_actions_t *sched_actions);
170
171 /*
172  * author erth
173  *
174  * Function to remove the first action in an fosa_ads_actions_t queue.
175  */
176 void fosa_ose_adsactions_remove_first(fosa_ads_actions_t *sched_actions);
177
178 void fosa_ose_execute_action_activate(PROCESS pid);
179
180 void fosa_ose_execute_action_suspend(PROCESS pid);
181
182 void fosa_ose_execute_action_reject(PROCESS pid);
183
184 void fosa_ose_execute_action_accept(PROCESS pid);
185
186 void fosa_ose_execute_action_thread_notification(
187     fosa_ose_action_t* action);
188
189 void fosa_ose_execute_action_timeout(
190     fosa_ose_action_t* action);
191
192
193 /*
194  * author erth
195  *
196  * This function initialize the scheduler operations.
197  */
198 void fosa_ose_scheduler_ops_init(fosa_ads_scheduler_ops_t *scheduler_ops);
199
200 /*
201  * author erth
202  *
203  * This function are used to send an event to the fosa scheduler.
204  * @param event_pid    the pid that the event is about.
205  * @param event_isg    the event that has occured. 
206  */
207 void fosa_ose_send_event_to_scheduler(  PROCESS event_pid, 
208                                         SIGSELECT event_sig);
209                                        
210
211 /*************************
212  * Test Help Functions
213  *************************/ 
214
215 //For test purpose only........remove.....................................
216 //Bad design if this has to be here!!!....................................
217 extern void * test_function(char * text);
218
219 /*
220  * author erth
221  *
222  * Callback to test the callback functionality of fosa. Returns 0 if 
223  * succesful. Otherwise it returns an error.
224  */
225 int frsh_ose_callback_test();
226
227 /*
228  * author erth
229  *
230  * fosa_ose_adsactions_add_test()
231  *
232  * Test action that can be added to an actions list.
233  *
234  * This function adds a test action to the that will cause the
235  * test action to be invoked.
236  * 
237  *  Returns 0 if successful; otherwise it returns an error code:
238  *     ENOMEM: There is insufficient memory to add this action
239  *     EPOLICY: The thread specified by thread has its appscheduled
240  *              attribute set to false, 
241  *     EINVAL: The value specified by sched_actions is invalid
242  *
243  *  Alternatively, in case of error the implementation is allowed to
244  *  notify it to the system console and then terminate the FRSH
245  *  implementation and dependant applications
246  **/
247 int fosa_ose_adsactions_add_test(fosa_ads_actions_t *sched_actions,
248         action_t string);
249
250 /**
251  * fosa_ose_convert_prio_to_ose()
252  *
253  * Maps fosa priority to ose priority. FOSA internal function.
254  **/
255 //OSPRIORITY fosa_ose_convert_prio_to_ose(int fosa_prio);
256
257 /**
258  * fosa_ose_convert_prio_to_fosa()
259  *
260  * Maps ose priority to fosa priority. FOSA internal function.
261  **/
262 //int fosa_ose_convert_prio_to_fosa(OSPRIORITY ose_prio);
263
264
265 #endif /*  FOSA_OSE_IMPLEMENTATION_SPECIFIC_H */
266