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  L4_PROTO_SMCCC = -24L,
77 };
78 
79 enum L4_varg_type
80 {
81  L4_VARG_TYPE_NIL = 0x00,
82  L4_VARG_TYPE_UMWORD = 0x01,
83  L4_VARG_TYPE_MWORD = 0x81,
84  L4_VARG_TYPE_STRING = 0x02,
85  L4_VARG_TYPE_FPAGE = 0x03,
86 
87  L4_VARG_TYPE_SIGN = 0x80,
88 };
89 
90 
96 {
97  // flags for received IPC
102  L4_MSGTAG_ERROR = 0x8000,
103 
104  // flags for sending IPC
134 
139  L4_MSGTAG_FLAGS = 0xf000,
140 };
141 
142 
159 typedef struct l4_msgtag_t
160 {
162 #ifdef __cplusplus
163  long label() const throw() { return raw >> 16; }
166  void label(long v) throw() { raw = (raw & 0x0ffff) | (v << 16); }
168  unsigned words() const throw() { return raw & 0x3f; }
170  unsigned items() const throw() { return (raw >> 6) & 0x3f; }
177  unsigned flags() const throw() { return raw & 0xf000; }
179  bool is_page_fault() const throw() { return label() == L4_PROTO_PAGE_FAULT; }
181  bool is_preemption() const throw() { return label() == L4_PROTO_PREEMPTION; }
183  bool is_sys_exception() const throw() { return label() == L4_PROTO_SYS_EXCEPTION; }
185  bool is_exception() const throw() { return label() == L4_PROTO_EXCEPTION; }
187  bool is_sigma0() const throw() { return label() == L4_PROTO_SIGMA0; }
189  bool is_io_page_fault() const throw() { return label() == L4_PROTO_IO_PAGE_FAULT; }
191  unsigned has_error() const throw() { return raw & L4_MSGTAG_ERROR; }
192 #endif
193 } l4_msgtag_t;
194 
195 
196 
208 L4_INLINE l4_msgtag_t l4_msgtag(long label, unsigned words, unsigned items,
209  unsigned flags) L4_NOTHROW;
210 
219 L4_INLINE long l4_msgtag_label(l4_msgtag_t t) L4_NOTHROW;
220 
229 L4_INLINE unsigned l4_msgtag_words(l4_msgtag_t t) L4_NOTHROW;
230 
239 L4_INLINE unsigned l4_msgtag_items(l4_msgtag_t t) L4_NOTHROW;
240 
251 L4_INLINE unsigned l4_msgtag_flags(l4_msgtag_t t) L4_NOTHROW;
252 
265 L4_INLINE unsigned l4_msgtag_has_error(l4_msgtag_t t) L4_NOTHROW;
266 
275 L4_INLINE unsigned l4_msgtag_is_page_fault(l4_msgtag_t t) L4_NOTHROW;
276 
284 L4_INLINE unsigned l4_msgtag_is_preemption(l4_msgtag_t t) L4_NOTHROW;
285 
295 
304 L4_INLINE unsigned l4_msgtag_is_exception(l4_msgtag_t t) L4_NOTHROW;
305 
314 L4_INLINE unsigned l4_msgtag_is_sigma0(l4_msgtag_t t) L4_NOTHROW;
315 
325 
342 typedef unsigned long l4_cap_idx_t;
343 
353 L4_INLINE unsigned l4_is_invalid_cap(l4_cap_idx_t c) L4_NOTHROW;
354 
364 L4_INLINE unsigned l4_is_valid_cap(l4_cap_idx_t c) L4_NOTHROW;
365 
376 L4_INLINE unsigned l4_capability_equal(l4_cap_idx_t c1, l4_cap_idx_t c2) L4_NOTHROW;
377 
386 L4_INLINE l4_cap_idx_t l4_capability_next(l4_cap_idx_t c) L4_NOTHROW;
387 
388 /* ************************************************************************* */
389 /* Implementation */
390 
391 L4_INLINE unsigned
392 l4_is_invalid_cap(l4_cap_idx_t c) L4_NOTHROW
393 { return c & L4_INVALID_CAP_BIT; }
394 
395 L4_INLINE unsigned
396 l4_is_valid_cap(l4_cap_idx_t c) L4_NOTHROW
397 { return !(c & L4_INVALID_CAP_BIT); }
398 
399 L4_INLINE unsigned
400 l4_capability_equal(l4_cap_idx_t c1, l4_cap_idx_t c2) L4_NOTHROW
401 { return (c1 >> L4_CAP_SHIFT) == (c2 >> L4_CAP_SHIFT); }
402 
403 
407 L4_INLINE
408 l4_msgtag_t l4_msgtag(long label, unsigned words, unsigned items,
409  unsigned flags) L4_NOTHROW
410 {
411  return (l4_msgtag_t){(label << 16) | (l4_mword_t)(words & 0x3f)
412  | (l4_mword_t)((items & 0x3f) << 6)
413  | (l4_mword_t)(flags & 0xf000)};
414 }
415 
416 
417 
418 L4_INLINE
419 long l4_msgtag_label(l4_msgtag_t t) L4_NOTHROW
420 { return t.raw >> 16; }
421 
422 L4_INLINE
423 unsigned l4_msgtag_words(l4_msgtag_t t) L4_NOTHROW
424 { return t.raw & 0x3f; }
425 
426 L4_INLINE
427 unsigned l4_msgtag_items(l4_msgtag_t t) L4_NOTHROW
428 { return (t.raw >> 6) & 0x3f; }
429 
430 L4_INLINE
431 unsigned l4_msgtag_flags(l4_msgtag_t t) L4_NOTHROW
432 { return t.raw & 0xf000; }
433 
434 
435 L4_INLINE
436 unsigned l4_msgtag_has_error(l4_msgtag_t t) L4_NOTHROW
437 { return t.raw & L4_MSGTAG_ERROR; }
438 
439 
440 
441 L4_INLINE unsigned l4_msgtag_is_page_fault(l4_msgtag_t t) L4_NOTHROW
442 { return l4_msgtag_label(t) == L4_PROTO_PAGE_FAULT; }
443 
444 L4_INLINE unsigned l4_msgtag_is_preemption(l4_msgtag_t t) L4_NOTHROW
445 { return l4_msgtag_label(t) == L4_PROTO_PREEMPTION; }
446 
447 L4_INLINE unsigned l4_msgtag_is_sys_exception(l4_msgtag_t t) L4_NOTHROW
448 { return l4_msgtag_label(t) == L4_PROTO_SYS_EXCEPTION; }
449 
450 L4_INLINE unsigned l4_msgtag_is_exception(l4_msgtag_t t) L4_NOTHROW
451 { return l4_msgtag_label(t) == L4_PROTO_EXCEPTION; }
452 
453 L4_INLINE unsigned l4_msgtag_is_sigma0(l4_msgtag_t t) L4_NOTHROW
454 { return l4_msgtag_label(t) == L4_PROTO_SIGMA0; }
455 
456 L4_INLINE unsigned l4_msgtag_is_io_page_fault(l4_msgtag_t t) L4_NOTHROW
457 { return l4_msgtag_label(t) == L4_PROTO_IO_PAGE_FAULT; }
458 
459 L4_INLINE l4_cap_idx_t l4_capability_next(l4_cap_idx_t c) L4_NOTHROW
460 { return c + L4_CAP_OFFSET; }
461 
462 #include <l4/sys/__l4_fpage.h>
463 #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:441
Protocol ID for ARM SMCCC calls.
Definition: types.h:76
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:392
bool is_sigma0() const
Test if protocol indicates sigma0 protocol.
Definition: types.h:187
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:436
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:447
unsigned l4_msgtag_is_preemption(l4_msgtag_t t) L4_NOTHROW
Test for preemption protocol.
Definition: types.h:444
l4_mword_t raw
raw value
Definition: types.h:161
signed long l4_mword_t
Signed machine word.
Definition: l4int.h:49
unsigned words() const
Get the number of untyped words.
Definition: types.h:168
Mask for all flags.
Definition: types.h:139
unsigned l4_is_valid_cap(l4_cap_idx_t c) L4_NOTHROW
Test if a capability selector is a valid selector.
Definition: types.h:396
bool is_exception() const
Test if protocol indicates exception protocol.
Definition: types.h:185
unsigned long l4_cap_idx_t
L4 Capability selector Type.
Definition: types.h:342
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:181
Enable FPU transfer flag for IPC.
Definition: types.h:114
long l4_msgtag_label(l4_msgtag_t t) L4_NOTHROW
Get the protocol of tag.
Definition: types.h:419
unsigned l4_msgtag_is_sigma0(l4_msgtag_t t) L4_NOTHROW
Test for sigma0 protocol.
Definition: types.h:453
Protocol for messages to a thread object.
Definition: types.h:64
long label() const
Get the protocol value.
Definition: types.h:164
Protocol ID for IO-MMUs.
Definition: types.h:74
l4_msgtag_flags
Flags for message tags.
Definition: types.h:95
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:427
Protocol for (creating) kernel DMA space objects.
Definition: types.h:69
Enable schedule in IPC flag.
Definition: types.h:123
unsigned l4_msgtag_is_exception(l4_msgtag_t t) L4_NOTHROW
Test for exception protocol.
Definition: types.h:450
l4_cap_idx_t l4_capability_next(l4_cap_idx_t c) L4_NOTHROW
Get the next capability selector after c.
Definition: types.h:459
unsigned has_error() const
Test if flags indicate an error.
Definition: types.h:191
bool is_sys_exception() const
Test if protocol indicates system-exception protocol.
Definition: types.h:183
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:400
unsigned items() const
Get the number of typed items.
Definition: types.h:170
unsigned l4_msgtag_words(l4_msgtag_t t) L4_NOTHROW
Get the number of untyped words.
Definition: types.h:423
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:166
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:408
Protocol for semaphore objects.
Definition: types.h:72
unsigned flags() const
Get the flags value.
Definition: types.h:177
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:159
unsigned l4_msgtag_is_io_page_fault(l4_msgtag_t t) L4_NOTHROW
Test for IO-page-fault protocol.
Definition: types.h:456
bool is_io_page_fault() const
Test if protocol indicates IO-page-fault protocol.
Definition: types.h:189
Error indicator flag.
Definition: types.h:102
Enable IPC propagation.
Definition: types.h:133
#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:179