L4Re - L4 Runtime Environment
types.h
Go to the documentation of this file.
1 /*****************************************************************************/
7 /*
8  * (c) 2008-2013 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
9  * Alexander Warg <warg@os.inf.tu-dresden.de>,
10  * Björn Döbel <doebel@os.inf.tu-dresden.de>,
11  * Torsten Frenzel <frenzel@os.inf.tu-dresden.de>
12  * economic rights: Technische Universität Dresden (Germany)
13  *
14  * This file is part of TUD:OS and distributed under the terms of the
15  * GNU General Public License 2.
16  * Please see the COPYING-GPL-2 file for details.
17  *
18  * As a special exception, you may use this file as part of a free software
19  * library without restriction. Specifically, if other files instantiate
20  * templates or use macros or inline functions from this file, or you compile
21  * this file and link it with other files to produce an executable, this
22  * file does not by itself cause the resulting executable to be covered by
23  * the GNU General Public License. This exception does not however
24  * invalidate any other reasons why the executable file might be covered by
25  * the GNU General Public License.
26  */
27 /*****************************************************************************/
28 #pragma once
29 
30 #include <l4/sys/l4int.h>
31 #include <l4/sys/compiler.h>
32 #include <l4/sys/consts.h>
33 
34 
50 {
54 
55  L4_PROTO_IRQ = -1L,
63  L4_PROTO_TASK = -11L,
64  L4_PROTO_THREAD = -12L,
65  L4_PROTO_LOG = -13L,
68  L4_PROTO_VM = -16L,
73  L4_PROTO_META = -21L,
74  L4_PROTO_IOMMU = -22L,
76 };
77 
78 enum L4_varg_type
79 {
80  L4_VARG_TYPE_NIL = 0x00,
81  L4_VARG_TYPE_UMWORD = 0x01,
82  L4_VARG_TYPE_MWORD = 0x81,
83  L4_VARG_TYPE_STRING = 0x02,
84  L4_VARG_TYPE_FPAGE = 0x03,
85 
86  L4_VARG_TYPE_SIGN = 0x80,
87 };
88 
89 
95 {
96  // flags for received IPC
101  L4_MSGTAG_ERROR = 0x8000,
102 
103  // flags for sending IPC
133 
138  L4_MSGTAG_FLAGS = 0xf000,
139 };
140 
141 
158 typedef struct l4_msgtag_t
159 {
161 #ifdef __cplusplus
162  long label() const throw() { return raw >> 16; }
165  void label(long v) throw() { raw = (raw & 0x0ffff) | (v << 16); }
167  unsigned words() const throw() { return raw & 0x3f; }
169  unsigned items() const throw() { return (raw >> 6) & 0x3f; }
176  unsigned flags() const throw() { return raw & 0xf000; }
178  bool is_page_fault() const throw() { return label() == L4_PROTO_PAGE_FAULT; }
180  bool is_preemption() const throw() { return label() == L4_PROTO_PREEMPTION; }
182  bool is_sys_exception() const throw() { return label() == L4_PROTO_SYS_EXCEPTION; }
184  bool is_exception() const throw() { return label() == L4_PROTO_EXCEPTION; }
186  bool is_sigma0() const throw() { return label() == L4_PROTO_SIGMA0; }
188  bool is_io_page_fault() const throw() { return label() == L4_PROTO_IO_PAGE_FAULT; }
190  unsigned has_error() const throw() { return raw & L4_MSGTAG_ERROR; }
191 #endif
192 } l4_msgtag_t;
193 
194 
195 
207 L4_INLINE l4_msgtag_t l4_msgtag(long label, unsigned words, unsigned items,
208  unsigned flags) L4_NOTHROW;
209 
218 L4_INLINE long l4_msgtag_label(l4_msgtag_t t) L4_NOTHROW;
219 
228 L4_INLINE unsigned l4_msgtag_words(l4_msgtag_t t) L4_NOTHROW;
229 
238 L4_INLINE unsigned l4_msgtag_items(l4_msgtag_t t) L4_NOTHROW;
239 
250 L4_INLINE unsigned l4_msgtag_flags(l4_msgtag_t t) L4_NOTHROW;
251 
264 L4_INLINE unsigned l4_msgtag_has_error(l4_msgtag_t t) L4_NOTHROW;
265 
274 L4_INLINE unsigned l4_msgtag_is_page_fault(l4_msgtag_t t) L4_NOTHROW;
275 
283 L4_INLINE unsigned l4_msgtag_is_preemption(l4_msgtag_t t) L4_NOTHROW;
284 
294 
303 L4_INLINE unsigned l4_msgtag_is_exception(l4_msgtag_t t) L4_NOTHROW;
304 
313 L4_INLINE unsigned l4_msgtag_is_sigma0(l4_msgtag_t t) L4_NOTHROW;
314 
324 
341 typedef unsigned long l4_cap_idx_t;
342 
352 L4_INLINE unsigned l4_is_invalid_cap(l4_cap_idx_t c) L4_NOTHROW;
353 
363 L4_INLINE unsigned l4_is_valid_cap(l4_cap_idx_t c) L4_NOTHROW;
364 
375 L4_INLINE unsigned l4_capability_equal(l4_cap_idx_t c1, l4_cap_idx_t c2) L4_NOTHROW;
376 
385 L4_INLINE l4_cap_idx_t l4_capability_next(l4_cap_idx_t c) L4_NOTHROW;
386 
387 /* ************************************************************************* */
388 /* Implementation */
389 
390 L4_INLINE unsigned
391 l4_is_invalid_cap(l4_cap_idx_t c) L4_NOTHROW
392 { return c & L4_INVALID_CAP_BIT; }
393 
394 L4_INLINE unsigned
395 l4_is_valid_cap(l4_cap_idx_t c) L4_NOTHROW
396 { return !(c & L4_INVALID_CAP_BIT); }
397 
398 L4_INLINE unsigned
399 l4_capability_equal(l4_cap_idx_t c1, l4_cap_idx_t c2) L4_NOTHROW
400 { return (c1 >> L4_CAP_SHIFT) == (c2 >> L4_CAP_SHIFT); }
401 
402 
406 L4_INLINE
407 l4_msgtag_t l4_msgtag(long label, unsigned words, unsigned items,
408  unsigned flags) L4_NOTHROW
409 {
410  return (l4_msgtag_t){(label << 16) | (l4_mword_t)(words & 0x3f)
411  | (l4_mword_t)((items & 0x3f) << 6)
412  | (l4_mword_t)(flags & 0xf000)};
413 }
414 
415 
416 
417 L4_INLINE
418 long l4_msgtag_label(l4_msgtag_t t) L4_NOTHROW
419 { return t.raw >> 16; }
420 
421 L4_INLINE
422 unsigned l4_msgtag_words(l4_msgtag_t t) L4_NOTHROW
423 { return t.raw & 0x3f; }
424 
425 L4_INLINE
426 unsigned l4_msgtag_items(l4_msgtag_t t) L4_NOTHROW
427 { return (t.raw >> 6) & 0x3f; }
428 
429 L4_INLINE
430 unsigned l4_msgtag_flags(l4_msgtag_t t) L4_NOTHROW
431 { return t.raw & 0xf000; }
432 
433 
434 L4_INLINE
435 unsigned l4_msgtag_has_error(l4_msgtag_t t) L4_NOTHROW
436 { return t.raw & L4_MSGTAG_ERROR; }
437 
438 
439 
440 L4_INLINE unsigned l4_msgtag_is_page_fault(l4_msgtag_t t) L4_NOTHROW
441 { return l4_msgtag_label(t) == L4_PROTO_PAGE_FAULT; }
442 
443 L4_INLINE unsigned l4_msgtag_is_preemption(l4_msgtag_t t) L4_NOTHROW
444 { return l4_msgtag_label(t) == L4_PROTO_PREEMPTION; }
445 
446 L4_INLINE unsigned l4_msgtag_is_sys_exception(l4_msgtag_t t) L4_NOTHROW
447 { return l4_msgtag_label(t) == L4_PROTO_SYS_EXCEPTION; }
448 
449 L4_INLINE unsigned l4_msgtag_is_exception(l4_msgtag_t t) L4_NOTHROW
450 { return l4_msgtag_label(t) == L4_PROTO_EXCEPTION; }
451 
452 L4_INLINE unsigned l4_msgtag_is_sigma0(l4_msgtag_t t) L4_NOTHROW
453 { return l4_msgtag_label(t) == L4_PROTO_SIGMA0; }
454 
455 L4_INLINE unsigned l4_msgtag_is_io_page_fault(l4_msgtag_t t) L4_NOTHROW
456 { return l4_msgtag_label(t) == L4_PROTO_IO_PAGE_FAULT; }
457 
458 L4_INLINE l4_cap_idx_t l4_capability_next(l4_cap_idx_t c) L4_NOTHROW
459 { return c + L4_CAP_OFFSET; }
460 
461 #include <l4/sys/__l4_fpage.h>
462 #include <l4/sys/__timeout.h>
Protocol for messages to a log object.
Definition: types.h:65
System exception.
Definition: types.h:58
unsigned l4_msgtag_is_page_fault(l4_msgtag_t t) L4_NOTHROW
Test for page-fault protocol.
Definition: types.h:440
I/O page fault message.
Definition: types.h:61
unsigned l4_is_invalid_cap(l4_cap_idx_t c) L4_NOTHROW
Test if a capability selector is the invalid capability.
Definition: types.h:391
bool is_sigma0() const
Test if protocol indicates sigma0 protocol.
Definition: types.h:186
Protocol ID for the ddebugger.
Definition: types.h:75
Protocol for messages to a a generic kobject.
Definition: types.h:62
unsigned l4_msgtag_has_error(l4_msgtag_t t) L4_NOTHROW
Test for error indicator flag.
Definition: types.h:435
Protocol for messages to a factory object.
Definition: types.h:67
Allow an alien the system call.
Definition: types.h:52
unsigned l4_msgtag_is_sys_exception(l4_msgtag_t t) L4_NOTHROW
Test for system-exception protocol.
Definition: types.h:446
unsigned l4_msgtag_is_preemption(l4_msgtag_t t) L4_NOTHROW
Test for preemption protocol.
Definition: types.h:443
l4_mword_t raw
raw value
Definition: types.h:160
signed long l4_mword_t
Signed machine word.
Definition: l4int.h:49
unsigned words() const
Get the number of untyped words.
Definition: types.h:167
Mask for all flags.
Definition: types.h:138
unsigned l4_is_valid_cap(l4_cap_idx_t c) L4_NOTHROW
Test if a capability selector is a valid selector.
Definition: types.h:395
bool is_exception() const
Test if protocol indicates exception protocol.
Definition: types.h:184
unsigned long l4_cap_idx_t
L4 Capability selector Type.
Definition: types.h:341
Protocol for messages to a virtual machine object.
Definition: types.h:68
bool is_preemption() const
Test if protocol indicates preemption protocol.
Definition: types.h:180
Enable FPU transfer flag for IPC.
Definition: types.h:113
long l4_msgtag_label(l4_msgtag_t t) L4_NOTHROW
Get the protocol of tag.
Definition: types.h:418
unsigned l4_msgtag_is_sigma0(l4_msgtag_t t) L4_NOTHROW
Test for sigma0 protocol.
Definition: types.h:452
Protocol for messages to a thread object.
Definition: types.h:64
long label() const
Get the protocol value.
Definition: types.h:163
Protocol ID for IO-MMUs.
Definition: types.h:74
l4_msgtag_flags
Flags for message tags.
Definition: types.h:94
L4 compiler related defines.
l4_msgtag_protocol
Message tag for IPC operations.
Definition: types.h:49
unsigned l4_msgtag_items(l4_msgtag_t t) L4_NOTHROW
Get the number of typed items.
Definition: types.h:426
Protocol for (creating) kernel DMA space objects.
Definition: types.h:69
Enable schedule in IPC flag.
Definition: types.h:122
unsigned l4_msgtag_is_exception(l4_msgtag_t t) L4_NOTHROW
Test for exception protocol.
Definition: types.h:449
l4_cap_idx_t l4_capability_next(l4_cap_idx_t c) L4_NOTHROW
Get the next capability selector after c.
Definition: types.h:458
unsigned has_error() const
Test if flags indicate an error.
Definition: types.h:190
bool is_sys_exception() const
Test if protocol indicates system-exception protocol.
Definition: types.h:182
Protocol for messages to a task object.
Definition: types.h:63
Capability index shift.
Definition: consts.h:131
Protocol for IRQ senders (IRQ -> IPC)
Definition: types.h:70
unsigned l4_capability_equal(l4_cap_idx_t c1, l4_cap_idx_t c2) L4_NOTHROW
Test if two capability selectors are equal.
Definition: types.h:399
unsigned items() const
Get the number of typed items.
Definition: types.h:169
unsigned l4_msgtag_words(l4_msgtag_t t) L4_NOTHROW
Get the number of untyped words.
Definition: types.h:422
Default protocol tag to reply to kernel.
Definition: types.h:51
Preemption message.
Definition: types.h:57
void label(long v)
Set the protocol value.
Definition: types.h:165
Page fault message.
Definition: types.h:56
Exception.
Definition: types.h:59
Protocol for IRQ mux (IRQ -> n x IRQ)
Definition: types.h:71
l4_msgtag_t l4_msgtag(long label, unsigned words, unsigned items, unsigned flags) L4_NOTHROW
Create a message tag from the specified values.
Definition: types.h:407
Protocol for semaphore objects.
Definition: types.h:72
unsigned flags() const
Get the flags value.
Definition: types.h:176
Make an exception out of a page fault.
Definition: types.h:53
IRQ message.
Definition: types.h:55
Protocol for messages to a scheduler object.
Definition: types.h:66
Meta information protocol.
Definition: types.h:73
struct l4_msgtag_t l4_msgtag_t
Message tag data structure.
Message tag data structure.
Definition: types.h:158
unsigned l4_msgtag_is_io_page_fault(l4_msgtag_t t) L4_NOTHROW
Test for IO-page-fault protocol.
Definition: types.h:455
bool is_io_page_fault() const
Test if protocol indicates IO-page-fault protocol.
Definition: types.h:188
Error indicator flag.
Definition: types.h:101
Enable IPC propagation.
Definition: types.h:132
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
Definition: compiler.h:185
Sigma0 protocol.
Definition: types.h:60
bool is_page_fault() const
Test if protocol indicates page-fault protocol.
Definition: types.h:178