L4Re - L4 Runtime Environment
semaphore.h
1 
18 #pragma once
19 
20 #include <l4/sys/irq.h>
21 
22 enum L4_semaphore_op
23 {
24  L4_SEMAPHORE_OP_DOWN = 0,
25  // semaphore up is IRQ_OP_TRIGGER with IRQ/Triggerable protocol
26 };
27 
28 L4_INLINE l4_msgtag_t
29 l4_semaphore_up(l4_cap_idx_t sem) L4_NOTHROW
30 {
31  return l4_irq_trigger(sem);
32 }
33 
34 L4_INLINE l4_msgtag_t
35 l4_semaphore_up_u(l4_cap_idx_t sem, l4_utcb_t *utcb) L4_NOTHROW
36 {
37  return l4_irq_trigger_u(sem, utcb);
38 }
39 
40 L4_INLINE l4_msgtag_t
41 l4_semaphore_down(l4_cap_idx_t sem, l4_timeout_t to) L4_NOTHROW;
42 
46 L4_INLINE l4_msgtag_t
47 l4_semaphore_down_u(l4_cap_idx_t sem, l4_timeout_t to,
48  l4_utcb_t *utcb) L4_NOTHROW;
49 
50 
51 L4_INLINE l4_msgtag_t
52 l4_semaphore_down_u(l4_cap_idx_t sem, l4_timeout_t to,
53  l4_utcb_t *utcb) L4_NOTHROW
54 {
55  l4_msg_regs_t *m = l4_utcb_mr_u(utcb);
56  m->mr[0] = L4_SEMAPHORE_OP_DOWN;
57  return l4_ipc_call(sem, utcb, l4_msgtag(L4_PROTO_SEMAPHORE, 1, 0, 0), to);
58 }
59 
60 
61 L4_INLINE l4_msgtag_t
62 l4_semaphore_down(l4_cap_idx_t sem, l4_timeout_t to) L4_NOTHROW
63 {
64  return l4_semaphore_down_u(sem, to, l4_utcb());
65 }
66 
C Irq interface.
Encapsulation of the message-register block in the UTCB.
Definition: utcb.h:78
l4_msgtag_t l4_irq_trigger_u(l4_cap_idx_t irq, l4_utcb_t *utcb) L4_NOTHROW
Trigger.
Definition: irq.h:300
l4_umword_t mr[L4_UTCB_GENERIC_DATA_SIZE]
Message registers.
Definition: utcb.h:80
l4_msgtag_t l4_ipc_call(l4_cap_idx_t object, l4_utcb_t *utcb, l4_msgtag_t tag, l4_timeout_t timeout) L4_NOTHROW
Object call (usual invocation).
Definition: ipc.h:445
unsigned long l4_cap_idx_t
L4 Capability selector Type.
Definition: types.h:342
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Definition: utcb.h:67
Timeout pair.
Definition: __timeout.h:57
l4_msgtag_t l4_irq_trigger(l4_cap_idx_t irq) L4_NOTHROW
Trigger an IRQ.
Definition: irq.h:353
l4_utcb_t * l4_utcb(void) L4_NOTHROW L4_PURE
Get the UTCB address.
Definition: utcb.h:340
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
Message tag data structure.
Definition: types.h:159
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
Definition: compiler.h:185