Orocos Real-Time Toolkit  2.9.0
fosi_interface.h
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Peter Soetens Mon Jun 26 13:25:56 CEST 2006 fosi_interface.h
3 
4  fosi_interface.h - description
5  -------------------
6  begin : Mon June 26 2006
7  copyright : (C) 2006 Peter Soetens
8  email : peter.soetens@fmtc.be
9 
10  ***************************************************************************
11  * This library is free software; you can redistribute it and/or *
12  * modify it under the terms of the GNU General Public *
13  * License as published by the Free Software Foundation; *
14  * version 2 of the License. *
15  * *
16  * As a special exception, you may use this file as part of a free *
17  * software library without restriction. Specifically, if other files *
18  * instantiate templates or use macros or inline functions from this *
19  * file, or you compile this file and link it with other files to *
20  * produce an executable, this file does not by itself cause the *
21  * resulting executable to be covered by the GNU General Public *
22  * License. This exception does not however invalidate any other *
23  * reasons why the executable file might be covered by the GNU General *
24  * Public License. *
25  * *
26  * This library is distributed in the hope that it will be useful, *
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
29  * Lesser General Public License for more details. *
30  * *
31  * You should have received a copy of the GNU General Public *
32  * License along with this library; if not, write to the Free Software *
33  * Foundation, Inc., 59 Temple Place, *
34  * Suite 330, Boston, MA 02111-1307 USA *
35  * *
36  ***************************************************************************/
37 
38 
47 #ifndef ORO_FOSI_INTERFACE_H
48 #define ORO_FOSI_INTERFACE_H
49 
50 #error "This file is a template for developers, do not include directly."
51 
52 #ifdef __cplusplus
53 extern "C"
54 {
55 #endif
56 
57  struct MyTask;
58  typedef struct MyTask RTOS_TASK;
59 
60  // include 'atomic' functions,
61  // depends on processor target, not OS.
62 #include "oro_arch.h"
63 
64 #define ORO_SCHED_RT 0
65 #define ORO_SCHED_OTHER 1
70  typedef long long NANO_TIME;
71 
74  typedef long long TICK_TIME;
75 
80 
85  TICK_TIME rtos_get_time_ticks (void );
86 
90  TICK_TIME nano2ticks( NANO_TIME nano );
94  NANO_TIME ticks2nano( TICK_TIME count );
95 
96  // Semaphore functions
97  typedef struct sem_struct rt_sem_t;
101  int rtos_sem_init(rt_sem_t* m, int value );
102  int rtos_sem_destroy(rt_sem_t* m );
103  int rtos_sem_signal(rt_sem_t* m );
104  int rtos_sem_wait(rt_sem_t* m );
105  int rtos_sem_trywait(rt_sem_t* m );
106  int rtos_sem_value(rt_sem_t* m );
107 
108  // Mutex and recursive mutex functions
109  typedef struct mutex_struct rt_mutex_t;
110  typedef struct recursive_mutex_struct rt_rec_mutex_t;
111 
112  int rtos_mutex_init(rt_mutex_t* m);
116  int rtos_mutex_lock( rt_mutex_t* m);
118  int rtos_mutex_trylock_for( rt_mutex_t* m, NANO_TIME relative_time);
119  int rtos_mutex_lock_until( rt_mutex_t* m, NANO_TIME abs_time);
120  int rtos_mutex_unlock( rt_mutex_t* m);
123  int rtos_mutex_rec_trylock_for( rt_rec_mutex_t* m, NANO_TIME relative_time);
126 
127  // Condition variables must support waiting, timed waiting and broadcasting.
128  typedef struct cond_struct rt_cond_t;
129  int rtos_cond_init(rt_cond_t *cond);
130  int rtos_cond_destroy(rt_cond_t *cond);
131  int rtos_cond_wait(rt_cond_t *cond, rt_mutex_t *mutex);
132  int rtos_cond_timedwait(rt_cond_t *cond, rt_mutex_t *mutex, NANO_TIME abs_time);
133  int rtos_cond_broadcast(rt_cond_t *cond);
134 
138  int rtos_printf( const char *fmt, ... );
139 
141  void rtos_enable_rt_warning();
144 
145 #ifdef __cplusplus
146 }
147 #endif
148 
149 #endif // ORO_FOSI_INTERFACE_H
NANO_TIME ticks2nano(TICK_TIME count)
Time conversions from system ticks to nano seconds.
Definition: fosi.h:107
long long NANO_TIME
Definition: fosi.h:55
int rtos_mutex_rec_lock(rt_rec_mutex_t *m)
long long TICK_TIME
OS representation of system ticks.
int rtos_cond_destroy(rt_cond_t *cond)
int rtos_mutex_unlock(rt_mutex_t *m)
int rtos_mutex_rec_init(rt_rec_mutex_t *m)
int rtos_sem_trywait(rt_sem_t *m)
int rtos_mutex_rec_trylock(rt_rec_mutex_t *m)
int rtos_sem_signal(rt_sem_t *m)
int rtos_mutex_rec_trylock_for(rt_rec_mutex_t *m, NANO_TIME relative_time)
int rtos_cond_timedwait(rt_cond_t *cond, rt_mutex_t *mutex, NANO_TIME abs_time)
int rtos_cond_wait(rt_cond_t *cond, rt_mutex_t *mutex)
NANO_TIME rtos_get_time_ns(void)
Get "system" time in nanoseconds.
Definition: fosi.h:113
int rtos_mutex_rec_unlock(rt_rec_mutex_t *m)
void rtos_disable_rt_warning()
Disallows the RTOS to print a warning when we violate real-time constraints.
int rtos_mutex_lock(rt_mutex_t *m)
int rtos_sem_destroy(rt_sem_t *m)
int rtos_mutex_lock_until(rt_mutex_t *m, NANO_TIME abs_time)
int rtos_mutex_rec_lock_until(rt_rec_mutex_t *m, NANO_TIME abs_time)
int rtos_mutex_init(rt_mutex_t *m)
int rtos_mutex_destroy(rt_mutex_t *m)
int rtos_mutex_trylock(rt_mutex_t *m)
int rtos_sem_init(rt_sem_t *m, int value)
All these should return zero in case of succes.
int rtos_sem_value(rt_sem_t *m)
int rtos_printf(const char *fmt,...)
'real-time' print function.
Definition: fosi.h:372
TICK_TIME nano2ticks(NANO_TIME nano)
Time conversions from nano seconds to system ticks.
Definition: fosi.h:100
int rtos_mutex_trylock_for(rt_mutex_t *m, NANO_TIME relative_time)
Definition: fosi.h:62
void rtos_enable_rt_warning()
Allows the RTOS to print a warning when we violate real-time constraints.
int rtos_cond_init(rt_cond_t *cond)
TICK_TIME rtos_get_time_ticks(void)
Get "system" time in ticks FIXME see https://proj.fmtc.be/orocos-bugzilla/show_bug.cgi?id=60
Definition: fosi.h:118
int rtos_sem_wait(rt_sem_t *m)
int rtos_cond_broadcast(rt_cond_t *cond)
cyg_sem_t rt_sem_t
Definition: fosi.h:131
int rtos_mutex_rec_destroy(rt_rec_mutex_t *m)
cyg_mutex_t rt_mutex_t
Definition: fosi.h:185