1 // -----------------------------------------------------------------------
2 // Copyright (C) 2006 - 2007 by the FRESCOR consortium:
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
11 // Thales Communication S.A. FRANCE
12 // Visual Tools S.A. SPAIN
13 // Rapita Systems Ltd UK
16 // See http://www.frescor.org
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
23 // All rights reserved.
25 // Redistribution and use in source and binary forms, with or
26 // without modification, are permitted provided that the
27 // following conditions are met:
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.
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 // // /******/ //////// // //
67 // FOSA(Frescor Operating System Adaptation layer)
68 //================================================
71 * Intended to be used only by internal .c files to include all
72 * internal declarations visible only within the src library directory.
74 * It is not used by any .h file to avoid include deadlocks.
78 #ifndef FOSA_OSE_IMPLEMENTATION_SPECIFIC_H
79 #define FOSA_OSE_IMPLEMENTATION_SPECIFIC_H
81 #include "fosa_ose_signals.sig" //The only place where this file is incl.
82 #include "fosa_ose_types.h"
90 /*************************
92 *************************/
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.
101 extern unsigned int process_name_number;
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().
110 extern bool fosa_ose_keys_initialized;
111 extern bool fosa_ose_keys_taken[];
113 /*************************
114 * General Help Functions
115 *************************/
120 * Function to convert systime, or actually system_tick and microseconds
121 * to timespec, or seconds and nanoseconds.
123 void fosa_ose_systime_to_timespec(unsigned long ticks,
124 unsigned long microsec, struct timespec* time);
126 /*************************
127 * Process Specific Functions
128 *************************/
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.
137 bool fosa_ose_is_process(PROCESS Pid);
139 extern fosa_ose_process_info_t* fosa_ose_processes;
144 * This function returns a pointer to the node with the given pid in the
145 * fosa_ose_processes list.
147 fosa_ose_process_info_t* fosa_ose_process_get_node(frsh_thread_id_t pid);
152 * This function is called to remove a node in the list fosa_ose_processes
153 * prefferable from the kill handler, or the scheduler.
155 * return 0 if success.
157 int fosa_ose_process_list_node_remove(frsh_thread_id_t pid);
159 /*************************
160 * Application defined scheduling functions
161 *************************/
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.
169 void fosa_ose_ads_actions_init(fosa_ads_actions_t *sched_actions);
174 * Function to remove the first action in an fosa_ads_actions_t queue.
176 void fosa_ose_adsactions_remove_first(fosa_ads_actions_t *sched_actions);
178 void fosa_ose_execute_action_activate(PROCESS pid);
180 void fosa_ose_execute_action_suspend(PROCESS pid);
182 void fosa_ose_execute_action_reject(PROCESS pid);
184 void fosa_ose_execute_action_accept(PROCESS pid);
186 void fosa_ose_execute_action_thread_notification(
187 fosa_ose_action_t* action);
189 void fosa_ose_execute_action_timeout(
190 fosa_ose_action_t* action);
196 * This function initialize the scheduler operations.
198 void fosa_ose_scheduler_ops_init(fosa_ads_scheduler_ops_t *scheduler_ops);
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.
207 void fosa_ose_send_event_to_scheduler( PROCESS event_pid,
208 SIGSELECT event_sig);
211 /*************************
212 * Test Help Functions
213 *************************/
215 //For test purpose only........remove.....................................
216 //Bad design if this has to be here!!!....................................
217 extern void * test_function(char * text);
222 * Callback to test the callback functionality of fosa. Returns 0 if
223 * succesful. Otherwise it returns an error.
225 int frsh_ose_callback_test();
230 * fosa_ose_adsactions_add_test()
232 * Test action that can be added to an actions list.
234 * This function adds a test action to the that will cause the
235 * test action to be invoked.
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
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
247 int fosa_ose_adsactions_add_test(fosa_ads_actions_t *sched_actions,
251 * fosa_ose_convert_prio_to_ose()
253 * Maps fosa priority to ose priority. FOSA internal function.
255 //OSPRIORITY fosa_ose_convert_prio_to_ose(int fosa_prio);
258 * fosa_ose_convert_prio_to_fosa()
260 * Maps ose priority to fosa priority. FOSA internal function.
262 //int fosa_ose_convert_prio_to_fosa(OSPRIORITY ose_prio);
265 #endif /* FOSA_OSE_IMPLEMENTATION_SPECIFIC_H */