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 L4_NOTHROW { return raw >> 16; }
166  void label(long v) L4_NOTHROW { raw = (raw & 0x0ffff) | ((l4_umword_t)v << 16); }
168  unsigned words() const L4_NOTHROW { return raw & 0x3f; }
170  unsigned items() const L4_NOTHROW { return (raw >> 6) & 0x3f; }
177  unsigned flags() const L4_NOTHROW { return raw & 0xf000; }
179  bool is_page_fault() const L4_NOTHROW { return label() == L4_PROTO_PAGE_FAULT; }
181  bool is_preemption() const L4_NOTHROW { return label() == L4_PROTO_PREEMPTION; }
185  bool is_exception() const L4_NOTHROW { return label() == L4_PROTO_EXCEPTION; }
187  bool is_sigma0() const L4_NOTHROW { return label() == L4_PROTO_SIGMA0; }
191  unsigned has_error() const L4_NOTHROW { return raw & L4_MSGTAG_ERROR; }
192 #endif
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 
387 
388 /* ************************************************************************* */
389 /* Implementation */
390 
391 L4_INLINE unsigned
393 { return c & L4_INVALID_CAP_BIT; }
394 
395 L4_INLINE unsigned
397 { return !(c & L4_INVALID_CAP_BIT); }
398 
399 L4_INLINE unsigned
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){ (l4_mword_t)((l4_umword_t)label << 16)
412  | (l4_mword_t)(words & 0x3f)
413  | (l4_mword_t)((items & 0x3f) << 6)
414  | (l4_mword_t)(flags & 0xf000)};
415 }
416 
417 
418 
419 L4_INLINE
421 { return t.raw >> 16; }
422 
423 L4_INLINE
425 { return t.raw & 0x3f; }
426 
427 L4_INLINE
429 { return (t.raw >> 6) & 0x3f; }
430 
431 L4_INLINE
433 { return t.raw & 0xf000; }
434 
435 
436 L4_INLINE
438 { return t.raw & L4_MSGTAG_ERROR; }
439 
440 
441 
443 { return l4_msgtag_label(t) == L4_PROTO_PAGE_FAULT; }
444 
446 { return l4_msgtag_label(t) == L4_PROTO_PREEMPTION; }
447 
449 { return l4_msgtag_label(t) == L4_PROTO_SYS_EXCEPTION; }
450 
452 { return l4_msgtag_label(t) == L4_PROTO_EXCEPTION; }
453 
455 { return l4_msgtag_label(t) == L4_PROTO_SIGMA0; }
456 
458 { return l4_msgtag_label(t) == L4_PROTO_IO_PAGE_FAULT; }
459 
461 { return c + L4_CAP_OFFSET; }
462 
463 #include <l4/sys/__l4_fpage.h>
464 #include <l4/sys/__timeout.h>
L4_PROTO_IRQ_SENDER
@ L4_PROTO_IRQ_SENDER
Protocol for IRQ senders (IRQ -> IPC)
Definition: types.h:70
l4_capability_next
l4_cap_idx_t l4_capability_next(l4_cap_idx_t c) L4_NOTHROW
Get the next capability selector after c.
Definition: types.h:460
l4_msgtag_t::label
void label(long v) L4_NOTHROW
Set the protocol value.
Definition: types.h:166
L4_NOTHROW
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
Definition: compiler.h:186
l4_cap_idx_t
unsigned long l4_cap_idx_t
L4 Capability selector Type.
Definition: types.h:342
L4_PROTO_PAGE_FAULT
@ L4_PROTO_PAGE_FAULT
Page fault message.
Definition: types.h:56
L4_PROTO_IRQ_MUX
@ L4_PROTO_IRQ_MUX
Protocol for IRQ mux (IRQ -> n x IRQ)
Definition: types.h:71
L4_PROTO_SEMAPHORE
@ L4_PROTO_SEMAPHORE
Protocol for semaphore objects.
Definition: types.h:72
L4_PROTO_NONE
@ L4_PROTO_NONE
Default protocol tag to reply to kernel.
Definition: types.h:51
l4_msgtag_label
long l4_msgtag_label(l4_msgtag_t t) L4_NOTHROW
Get the protocol of tag.
Definition: types.h:420
l4_msgtag_t::flags
unsigned flags() const L4_NOTHROW
Get the flags value.
Definition: types.h:177
L4_PROTO_PF_EXCEPTION
@ L4_PROTO_PF_EXCEPTION
Make an exception out of a page fault.
Definition: types.h:53
l4_msgtag_flags
l4_msgtag_flags
Flags for message tags.
Definition: types.h:96
l4_msgtag
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
L4_PROTO_PREEMPTION
@ L4_PROTO_PREEMPTION
Preemption message.
Definition: types.h:57
l4_msgtag_is_exception
unsigned l4_msgtag_is_exception(l4_msgtag_t t) L4_NOTHROW
Test for exception protocol.
Definition: types.h:451
L4_PROTO_EXCEPTION
@ L4_PROTO_EXCEPTION
Exception.
Definition: types.h:59
L4_PROTO_META
@ L4_PROTO_META
Meta information protocol.
Definition: types.h:73
l4_msgtag_t::raw
l4_mword_t raw
raw value
Definition: types.h:161
l4_is_invalid_cap
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
l4_msgtag_t::label
long label() const L4_NOTHROW
Get the protocol value.
Definition: types.h:164
L4_PROTO_IRQ
@ L4_PROTO_IRQ
IRQ message.
Definition: types.h:55
l4_msgtag_t::is_exception
bool is_exception() const L4_NOTHROW
Test if protocol indicates exception protocol.
Definition: types.h:185
L4_PROTO_SCHEDULER
@ L4_PROTO_SCHEDULER
Protocol for messages to a scheduler object.
Definition: types.h:66
L4_CAP_SHIFT
@ L4_CAP_SHIFT
Capability index shift.
Definition: consts.h:131
l4_msgtag_is_io_page_fault
unsigned l4_msgtag_is_io_page_fault(l4_msgtag_t t) L4_NOTHROW
Test for IO-page-fault protocol.
Definition: types.h:457
l4_msgtag_t::words
unsigned words() const L4_NOTHROW
Get the number of untyped words.
Definition: types.h:168
L4_MSGTAG_PROPAGATE
@ L4_MSGTAG_PROPAGATE
Enable IPC propagation.
Definition: types.h:133
L4_PROTO_SYS_EXCEPTION
@ L4_PROTO_SYS_EXCEPTION
System exception.
Definition: types.h:58
l4_msgtag_t::is_page_fault
bool is_page_fault() const L4_NOTHROW
Test if protocol indicates page-fault protocol.
Definition: types.h:179
l4_msgtag_is_sigma0
unsigned l4_msgtag_is_sigma0(l4_msgtag_t t) L4_NOTHROW
Test for sigma0 protocol.
Definition: types.h:454
L4_MSGTAG_ERROR
@ L4_MSGTAG_ERROR
Error indicator flag.
Definition: types.h:102
l4_msgtag_t::items
unsigned items() const L4_NOTHROW
Get the number of typed items.
Definition: types.h:170
L4_PROTO_SMCCC
@ L4_PROTO_SMCCC
Protocol ID for ARM SMCCC calls.
Definition: types.h:76
L4_PROTO_IO_PAGE_FAULT
@ L4_PROTO_IO_PAGE_FAULT
I/O page fault message.
Definition: types.h:61
l4_capability_equal
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
l4_msgtag_is_page_fault
unsigned l4_msgtag_is_page_fault(l4_msgtag_t t) L4_NOTHROW
Test for page-fault protocol.
Definition: types.h:442
L4_PROTO_SIGMA0
@ L4_PROTO_SIGMA0
Sigma0 protocol.
Definition: types.h:60
L4_PROTO_DEBUGGER
@ L4_PROTO_DEBUGGER
Protocol ID for the debugger.
Definition: types.h:75
l4_msgtag_t::is_preemption
bool is_preemption() const L4_NOTHROW
Test if protocol indicates preemption protocol.
Definition: types.h:181
L4_PROTO_LOG
@ L4_PROTO_LOG
Protocol for messages to a log object.
Definition: types.h:65
compiler.h
L4 compiler related defines.
L4_PROTO_FACTORY
@ L4_PROTO_FACTORY
Protocol for messages to a factory object.
Definition: types.h:67
L4_PROTO_ALLOW_SYSCALL
@ L4_PROTO_ALLOW_SYSCALL
Allow an alien the system call.
Definition: types.h:52
l4_msgtag_t::has_error
unsigned has_error() const L4_NOTHROW
Test if flags indicate an error.
Definition: types.h:191
l4_msgtag_items
unsigned l4_msgtag_items(l4_msgtag_t t) L4_NOTHROW
Get the number of typed items.
Definition: types.h:428
l4_msgtag_t::is_sigma0
bool is_sigma0() const L4_NOTHROW
Test if protocol indicates sigma0 protocol.
Definition: types.h:187
l4_msgtag_is_preemption
unsigned l4_msgtag_is_preemption(l4_msgtag_t t) L4_NOTHROW
Test for preemption protocol.
Definition: types.h:445
L4_PROTO_KOBJECT
@ L4_PROTO_KOBJECT
Protocol for messages to a generic kobject.
Definition: types.h:62
l4_msgtag_t
struct l4_msgtag_t l4_msgtag_t
Message tag data structure.
L4_MSGTAG_TRANSFER_FPU
@ L4_MSGTAG_TRANSFER_FPU
Enable FPU transfer flag for IPC.
Definition: types.h:114
L4_MSGTAG_FLAGS
@ L4_MSGTAG_FLAGS
Mask for all flags.
Definition: types.h:139
l4_is_valid_cap
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
l4_msgtag_words
unsigned l4_msgtag_words(l4_msgtag_t t) L4_NOTHROW
Get the number of untyped words.
Definition: types.h:424
L4_PROTO_IOMMU
@ L4_PROTO_IOMMU
Protocol ID for IO-MMUs.
Definition: types.h:74
L4_PROTO_VM
@ L4_PROTO_VM
Protocol for messages to a virtual machine object.
Definition: types.h:68
l4_mword_t
signed long l4_mword_t
Signed machine word.
Definition: l4int.h:49
l4_umword_t
unsigned long l4_umword_t
Unsigned machine word.
Definition: l4int.h:52
L4_PROTO_THREAD
@ L4_PROTO_THREAD
Protocol for messages to a thread object.
Definition: types.h:64
l4_msgtag_has_error
unsigned l4_msgtag_has_error(l4_msgtag_t t) L4_NOTHROW
Test for error indicator flag.
Definition: types.h:437
l4_msgtag_t
Message tag data structure.
Definition: types.h:160
l4_msgtag_protocol
l4_msgtag_protocol
Message tag for IPC operations.
Definition: types.h:50
l4_msgtag_t::is_sys_exception
bool is_sys_exception() const L4_NOTHROW
Test if protocol indicates system-exception protocol.
Definition: types.h:183
l4_msgtag_is_sys_exception
unsigned l4_msgtag_is_sys_exception(l4_msgtag_t t) L4_NOTHROW
Test for system-exception protocol.
Definition: types.h:448
L4_MSGTAG_SCHEDULE
@ L4_MSGTAG_SCHEDULE
Enable schedule in IPC flag.
Definition: types.h:123
L4_PROTO_TASK
@ L4_PROTO_TASK
Protocol for messages to a task object.
Definition: types.h:63
L4_PROTO_DMA_SPACE
@ L4_PROTO_DMA_SPACE
Protocol for (creating) kernel DMA space objects.
Definition: types.h:69
l4_msgtag_t::is_io_page_fault
bool is_io_page_fault() const L4_NOTHROW
Test if protocol indicates IO-page-fault protocol.
Definition: types.h:189