Xenomai  3.0.8
cobalt.h
1 /*
2  * Copyright (C) 2014 Philippe Gerum <rpm@xenomai.org>.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17  */
18 #ifndef _COBALT_SYS_COBALT_H
19 #define _COBALT_SYS_COBALT_H
20 
21 #include <sys/types.h>
22 #include <signal.h>
23 #include <pthread.h>
24 #include <sched.h>
25 #include <semaphore.h>
26 #include <errno.h>
27 #include <stdio.h>
28 #include <time.h>
29 #include <boilerplate/atomic.h>
30 #include <boilerplate/list.h>
31 #include <cobalt/uapi/kernel/synch.h>
32 #include <cobalt/uapi/kernel/vdso.h>
33 #include <cobalt/uapi/corectl.h>
34 #include <cobalt/uapi/mutex.h>
35 #include <cobalt/uapi/event.h>
36 #include <cobalt/uapi/monitor.h>
37 #include <cobalt/uapi/thread.h>
38 #include <cobalt/uapi/cond.h>
39 #include <cobalt/uapi/sem.h>
40 #include <cobalt/ticks.h>
41 
42 #define cobalt_commit_memory(p) __cobalt_commit_memory(p, sizeof(*p))
43 
44 struct cobalt_tsd_hook {
45  void (*create_tsd)(void);
46  void (*delete_tsd)(void);
47  struct pvholder next;
48 };
49 
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53 
54 int cobalt_extend(unsigned int magic);
55 
56 int cobalt_corectl(int request, void *buf, size_t bufsz);
57 
58 int cobalt_thread_stat(pid_t pid,
59  struct cobalt_threadstat *stat);
60 
61 int cobalt_serial_debug(const char *fmt, ...);
62 
63 void __cobalt_commit_memory(void *p, size_t len);
64 
65 void cobalt_thread_harden(void);
66 
67 void cobalt_thread_relax(void);
68 
69 int cobalt_thread_join(pthread_t thread);
70 
71 pid_t cobalt_thread_pid(pthread_t thread);
72 
73 int cobalt_thread_mode(void);
74 
75 int cobalt_monitor_init(cobalt_monitor_t *mon,
76  clockid_t clk_id, int flags);
77 
78 int cobalt_monitor_destroy(cobalt_monitor_t *mon);
79 
80 int cobalt_monitor_enter(cobalt_monitor_t *mon);
81 
82 int cobalt_monitor_exit(cobalt_monitor_t *mon);
83 
84 int cobalt_monitor_wait(cobalt_monitor_t *mon, int event,
85  const struct timespec *ts);
86 
87 void cobalt_monitor_grant(cobalt_monitor_t *mon,
88  struct xnthread_user_window *u_window);
89 
90 int cobalt_monitor_grant_sync(cobalt_monitor_t *mon,
91  struct xnthread_user_window *u_window);
92 
93 void cobalt_monitor_grant_all(cobalt_monitor_t *mon);
94 
95 int cobalt_monitor_grant_all_sync(cobalt_monitor_t *mon);
96 
97 void cobalt_monitor_drain(cobalt_monitor_t *mon);
98 
99 int cobalt_monitor_drain_sync(cobalt_monitor_t *mon);
100 
101 void cobalt_monitor_drain_all(cobalt_monitor_t *mon);
102 
103 int cobalt_monitor_drain_all_sync(cobalt_monitor_t *mon);
104 
105 int cobalt_event_init(cobalt_event_t *event,
106  unsigned int value,
107  int flags);
108 
109 int cobalt_event_post(cobalt_event_t *event,
110  unsigned int bits);
111 
112 int cobalt_event_wait(cobalt_event_t *event,
113  unsigned int bits,
114  unsigned int *bits_r,
115  int mode,
116  const struct timespec *timeout);
117 
118 unsigned long cobalt_event_clear(cobalt_event_t *event,
119  unsigned int bits);
120 
121 int cobalt_event_inquire(cobalt_event_t *event,
122  struct cobalt_event_info *info,
123  pid_t *waitlist, size_t waitsz);
124 
125 int cobalt_event_destroy(cobalt_event_t *event);
126 
127 int cobalt_sem_inquire(sem_t *sem, struct cobalt_sem_info *info,
128  pid_t *waitlist, size_t waitsz);
129 
130 int cobalt_sched_weighted_prio(int policy,
131  const struct sched_param_ex *param_ex);
132 
133 void cobalt_register_tsd_hook(struct cobalt_tsd_hook *th);
134 
135 void cobalt_assert_nrt(void);
136 
137 /* Use cobalt_assert_nrt() instead of: */
138 __deprecated void assert_nrt(void);
139 __deprecated void assert_nrt_fast(void);
140 
141 extern int __cobalt_control_bind;
142 
143 #ifdef __cplusplus
144 }
145 #endif
146 
147 #endif /* !_COBALT_SYS_COBALT_H */