1 |
|
/* thread.h - Public interface to L4 threads. |
2 |
|
Copyright (C) 2003 Free Software Foundation, Inc. |
3 |
|
Written by Marcus Brinkmann <marcus@gnu.org>. |
4 |
|
|
5 |
|
This file is part of the GNU L4 library. |
6 |
|
|
7 |
|
The GNU L4 library is free software; you can redistribute it and/or |
8 |
|
modify it under the terms of the GNU Lesser General Public License |
9 |
|
as published by the Free Software Foundation; either version 2.1 of |
10 |
|
the License, or (at your option) any later version. |
11 |
|
|
12 |
|
The GNU L4 library is distributed in the hope that it will be |
13 |
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty |
14 |
|
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
|
GNU Lesser General Public License for more details. |
16 |
|
|
17 |
|
You should have received a copy of the GNU Lesser General Public |
18 |
|
License along with the GNU L4 library; if not, write to the Free |
19 |
|
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
20 |
|
02111-1307, USA. */ |
21 |
|
|
22 |
#ifndef _L4_THREAD_H |
#ifndef _L4_THREAD_H |
23 |
#define _L4_THREAD_H 1 |
#define _L4_THREAD_H 1 |
24 |
|
|
35 |
((l4_thread_id_t) { .local.local = -1, .local._all_zero = 0 }) |
((l4_thread_id_t) { .local.local = -1, .local._all_zero = 0 }) |
36 |
|
|
37 |
|
|
38 |
#ifndef _L4_EXTERN_INLINE |
static inline l4_thread_id_t |
39 |
#define _L4_EXTERN_INLINE extern __inline |
__attribute__((__always_inline__)) |
|
#endif |
|
|
|
|
|
|
|
|
_L4_EXTERN_INLINE l4_thread_id_t |
|
40 |
l4_global_id (l4_word_t thread_no, l4_word_t version) |
l4_global_id (l4_word_t thread_no, l4_word_t version) |
41 |
{ |
{ |
42 |
l4_thread_id_t thread; |
l4_thread_id_t thread; |
48 |
} |
} |
49 |
|
|
50 |
|
|
51 |
_L4_EXTERN_INLINE l4_word_t |
static inline l4_word_t |
52 |
|
__attribute__((__always_inline__)) |
53 |
l4_version (l4_thread_id_t thread) |
l4_version (l4_thread_id_t thread) |
54 |
{ |
{ |
55 |
return thread.version; |
return thread.version; |
56 |
} |
} |
57 |
|
|
58 |
|
|
59 |
_L4_EXTERN_INLINE l4_word_t |
static inline l4_word_t |
60 |
|
__attribute__((__always_inline__)) |
61 |
l4_thread_no (l4_thread_id_t thread) |
l4_thread_no (l4_thread_id_t thread) |
62 |
{ |
{ |
63 |
return thread.thread_no; |
return thread.thread_no; |
64 |
} |
} |
65 |
|
|
66 |
|
|
67 |
_L4_EXTERN_INLINE l4_word_t |
static inline l4_word_t |
68 |
|
__attribute__((__always_inline__)) |
69 |
l4_is_thread_equal (l4_thread_id_t thread1, l4_thread_id_t thread2) |
l4_is_thread_equal (l4_thread_id_t thread1, l4_thread_id_t thread2) |
70 |
{ |
{ |
71 |
return thread1.raw == thread2.raw; |
return thread1.raw == thread2.raw; |
72 |
} |
} |
73 |
|
|
74 |
|
|
75 |
_L4_EXTERN_INLINE l4_word_t |
static inline l4_word_t |
76 |
|
__attribute__((__always_inline__)) |
77 |
l4_is_thread_not_equal (l4_thread_id_t thread1, l4_thread_id_t thread2) |
l4_is_thread_not_equal (l4_thread_id_t thread1, l4_thread_id_t thread2) |
78 |
{ |
{ |
79 |
return thread1.raw != thread2.raw; |
return thread1.raw != thread2.raw; |
80 |
} |
} |
81 |
|
|
82 |
|
|
83 |
_L4_EXTERN_INLINE l4_word_t |
static inline l4_word_t |
84 |
|
__attribute__((__always_inline__)) |
85 |
l4_is_nil_thread (l4_thread_id_t thread) |
l4_is_nil_thread (l4_thread_id_t thread) |
86 |
{ |
{ |
87 |
return thread.raw == 0; |
return thread.raw == 0; |
88 |
} |
} |
89 |
|
|
90 |
|
|
91 |
_L4_EXTERN_INLINE l4_word_t |
static inline l4_word_t |
92 |
|
__attribute__((__always_inline__)) |
93 |
l4_is_local_id (l4_thread_id_t thread) |
l4_is_local_id (l4_thread_id_t thread) |
94 |
{ |
{ |
95 |
return thread._all_zero == 0; |
return thread._all_zero == 0; |
96 |
} |
} |
97 |
|
|
98 |
|
|
99 |
_L4_EXTERN_INLINE l4_word_t |
static inline l4_word_t |
100 |
|
__attribute__((__always_inline__)) |
101 |
l4_is_global_id (l4_thread_id_t thread) |
l4_is_global_id (l4_thread_id_t thread) |
102 |
{ |
{ |
103 |
return thread._all_zero != 0; |
return thread._all_zero != 0; |
104 |
} |
} |
105 |
|
|
106 |
|
|
107 |
_L4_EXTERN_INLINE l4_thread_id_t |
static inline l4_thread_id_t |
108 |
|
__attribute__((__always_inline__)) |
109 |
l4_myself (void) |
l4_myself (void) |
110 |
{ |
{ |
111 |
return l4_my_global_id (); |
return l4_my_global_id (); |
112 |
} |
} |
113 |
|
|
114 |
|
|
115 |
_L4_EXTERN_INLINE l4_thread_id_t |
static inline l4_thread_id_t |
116 |
|
__attribute__((__always_inline__)) |
117 |
l4_global_id_of (l4_thread_id_t thread) |
l4_global_id_of (l4_thread_id_t thread) |
118 |
{ |
{ |
119 |
if (l4_is_global_id (thread)) |
if (l4_is_global_id (thread)) |
132 |
} |
} |
133 |
|
|
134 |
|
|
135 |
_L4_EXTERN_INLINE l4_word_t |
static inline l4_word_t |
136 |
|
__attribute__((__always_inline__)) |
137 |
l4_same_threads (l4_thread_id_t thread1, l4_thread_id_t thread2) |
l4_same_threads (l4_thread_id_t thread1, l4_thread_id_t thread2) |
138 |
{ |
{ |
139 |
l4_thread_id_t global1 = l4_global_id_of (thread1); |
l4_thread_id_t global1 = l4_global_id_of (thread1); |
143 |
} |
} |
144 |
|
|
145 |
|
|
146 |
_L4_EXTERN_INLINE l4_thread_id_t |
static inline l4_thread_id_t |
147 |
|
__attribute__((__always_inline__)) |
148 |
l4_local_id_of (l4_thread_id_t thread) |
l4_local_id_of (l4_thread_id_t thread) |
149 |
{ |
{ |
150 |
if (l4_is_local_id (thread)) |
if (l4_is_local_id (thread)) |
163 |
} |
} |
164 |
|
|
165 |
|
|
166 |
_L4_EXTERN_INLINE l4_word_t |
static inline l4_word_t |
167 |
|
__attribute__((__always_inline__)) |
168 |
l4_user_defined_handle_of (l4_thread_id_t thread) |
l4_user_defined_handle_of (l4_thread_id_t thread) |
169 |
{ |
{ |
170 |
l4_thread_id_t dest = thread; |
l4_thread_id_t dest = thread; |
179 |
} |
} |
180 |
|
|
181 |
|
|
182 |
_L4_EXTERN_INLINE void |
static inline void |
183 |
|
__attribute__((__always_inline__)) |
184 |
l4_set_user_defined_handle_of (l4_thread_id_t thread, l4_word_t handle) |
l4_set_user_defined_handle_of (l4_thread_id_t thread, l4_word_t handle) |
185 |
{ |
{ |
186 |
l4_thread_id_t dest = thread; |
l4_thread_id_t dest = thread; |
194 |
} |
} |
195 |
|
|
196 |
|
|
197 |
_L4_EXTERN_INLINE l4_thread_id_t |
static inline l4_thread_id_t |
198 |
|
__attribute__((__always_inline__)) |
199 |
l4_pager_of (l4_thread_id_t thread) |
l4_pager_of (l4_thread_id_t thread) |
200 |
{ |
{ |
201 |
l4_thread_id_t dest = thread; |
l4_thread_id_t dest = thread; |
209 |
} |
} |
210 |
|
|
211 |
|
|
212 |
_L4_EXTERN_INLINE void |
static inline void |
213 |
|
__attribute__((__always_inline__)) |
214 |
l4_set_pager_of (l4_thread_id_t thread, l4_thread_id_t pager_thread) |
l4_set_pager_of (l4_thread_id_t thread, l4_thread_id_t pager_thread) |
215 |
{ |
{ |
216 |
l4_thread_id_t dest = thread; |
l4_thread_id_t dest = thread; |
223 |
} |
} |
224 |
|
|
225 |
|
|
226 |
_L4_EXTERN_INLINE void |
static inline void |
227 |
|
__attribute__((__always_inline__)) |
228 |
l4_start (l4_thread_id_t thread) |
l4_start (l4_thread_id_t thread) |
229 |
{ |
{ |
230 |
l4_thread_id_t dest = thread; |
l4_thread_id_t dest = thread; |
237 |
} |
} |
238 |
|
|
239 |
|
|
240 |
_L4_EXTERN_INLINE void |
static inline void |
241 |
|
__attribute__((__always_inline__)) |
242 |
l4_start_sp_ip (l4_thread_id_t thread, l4_word_t sp_data, l4_word_t ip_data) |
l4_start_sp_ip (l4_thread_id_t thread, l4_word_t sp_data, l4_word_t ip_data) |
243 |
{ |
{ |
244 |
l4_thread_id_t dest = thread; |
l4_thread_id_t dest = thread; |
253 |
} |
} |
254 |
|
|
255 |
|
|
256 |
_L4_EXTERN_INLINE void |
static inline void |
257 |
|
__attribute__((__always_inline__)) |
258 |
l4_start_sp_ip_flags (l4_thread_id_t thread, l4_word_t sp_data, |
l4_start_sp_ip_flags (l4_thread_id_t thread, l4_word_t sp_data, |
259 |
l4_word_t ip_data, l4_word_t flags_data) |
l4_word_t ip_data, l4_word_t flags_data) |
260 |
{ |
{ |
272 |
|
|
273 |
|
|
274 |
#define __L4_STOP(name, extra_control) \ |
#define __L4_STOP(name, extra_control) \ |
275 |
_L4_EXTERN_INLINE l4_word_t \ |
static inline l4_word_t \ |
276 |
|
__attribute__((__always_inline__)) \ |
277 |
name (l4_thread_id_t thread) \ |
name (l4_thread_id_t thread) \ |
278 |
{ \ |
{ \ |
279 |
l4_thread_id_t dest = thread; \ |
l4_thread_id_t dest = thread; \ |
288 |
} \ |
} \ |
289 |
\ |
\ |
290 |
\ |
\ |
291 |
_L4_EXTERN_INLINE l4_word_t \ |
static inline l4_word_t \ |
292 |
|
__attribute__((__always_inline__)) \ |
293 |
name ## _sp_ip_flags (l4_thread_id_t thread, l4_word_t *sp, \ |
name ## _sp_ip_flags (l4_thread_id_t thread, l4_word_t *sp, \ |
294 |
l4_word_t *ip, l4_word_t *flags) \ |
l4_word_t *ip, l4_word_t *flags) \ |
295 |
{ \ |
{ \ |
313 |
|
|
314 |
/* Convenience interface for l4_thread_control. */ |
/* Convenience interface for l4_thread_control. */ |
315 |
|
|
316 |
_L4_EXTERN_INLINE l4_word_t |
static inline l4_word_t |
317 |
|
__attribute__((__always_inline__)) |
318 |
l4_associate_interrupt (l4_thread_id_t irq, l4_thread_id_t handler) |
l4_associate_interrupt (l4_thread_id_t irq, l4_thread_id_t handler) |
319 |
{ |
{ |
320 |
return l4_thread_control (irq, irq, l4_nilthread, handler, (void *) -1); |
return l4_thread_control (irq, irq, l4_nilthread, handler, (void *) -1); |
321 |
} |
} |
322 |
|
|
323 |
|
|
324 |
_L4_EXTERN_INLINE l4_word_t |
static inline l4_word_t |
325 |
|
__attribute__((__always_inline__)) |
326 |
l4_deassociate_interrupt (l4_thread_id_t irq) |
l4_deassociate_interrupt (l4_thread_id_t irq) |
327 |
{ |
{ |
328 |
return l4_thread_control (irq, irq, l4_nilthread, irq, (void *) -1); |
return l4_thread_control (irq, irq, l4_nilthread, irq, (void *) -1); |