L4Re Operating System Framework
Interface and Usage Documentation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
thread
Go to the documentation of this file.
1// vi:set ft=cpp: -*- Mode: C++ -*-
6/*
7 * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
8 * Alexander Warg <warg@os.inf.tu-dresden.de>
9 * economic rights: Technische Universität Dresden (Germany)
10 *
11 * License: see LICENSE.spdx (in this directory or the directories above)
12 */
13
14#pragma once
15
16#include <l4/sys/capability>
17#include <l4/sys/thread.h>
18
19namespace L4 {
20
51class Thread :
52 public Kobject_t<Thread, Kobject, L4_PROTO_THREAD,
53 Type_info::Demand_t<1> >
54{
55public:
84 l4_umword_t flags,
85 l4_utcb_t *utcb = l4_utcb()) noexcept
86 { return l4_thread_ex_regs_u(cap(), ip, sp, flags, utcb); }
87
119 l4_umword_t *flags,
120 l4_utcb_t *utcb = l4_utcb()) noexcept
121 { return l4_thread_ex_regs_ret_u(cap(), ip, sp, flags, utcb); }
122
123
136 class Attr
137 {
138 private:
139 friend class L4::Thread;
140 l4_utcb_t *_u;
141
142 public:
150 explicit Attr(l4_utcb_t *utcb = l4_utcb()) noexcept : _u(utcb)
151 { l4_thread_control_start_u(utcb); }
152
160 void pager(Cap<void> const &pager) noexcept
161 { l4_thread_control_pager_u(pager.cap(), _u); }
162
169 Cap<void> pager() noexcept
170 { return Cap<void>(l4_utcb_mr_u(_u)->mr[1]); }
171
179 void exc_handler(Cap<void> const &exc_handler) noexcept
180 { l4_thread_control_exc_handler_u(exc_handler.cap(), _u); }
181
189 { return Cap<void>(l4_utcb_mr_u(_u)->mr[2]); }
190
217 void bind(l4_utcb_t *thread_utcb, Cap<Task> const &task) noexcept
218 { l4_thread_control_bind_u(thread_utcb, task.cap(), _u); }
219
223 void alien(int on) noexcept
224 { l4_thread_control_alien_u(_u, on); }
225 };
226
242 l4_msgtag_t control(Attr const &attr) noexcept
243 { return l4_thread_control_commit_u(cap(), attr._u); }
244
253 { return l4_thread_switch_u(cap(), utcb); }
254
264 l4_utcb_t *utcb = l4_utcb()) noexcept
265 { return l4_thread_stats_time_u(cap(), us, utcb); }
266
283 { return l4_thread_vcpu_resume_start_u(utcb); }
284
334 l4_utcb_t *utcb = l4_utcb()) noexcept
335 { return l4_thread_vcpu_resume_commit_u(cap(), tag, utcb); }
336
358 noexcept
359 { return l4_thread_vcpu_control_u(cap(), vcpu_state, utcb); }
360
398 l4_utcb_t *utcb = l4_utcb()) noexcept
399 { return l4_thread_vcpu_control_ext_u(cap(), ext_vcpu_state, utcb); }
400
427 { return l4_thread_register_del_irq_u(cap(), irq.cap(), u); }
428
448 {
449 private:
450 friend class Thread;
451 l4_utcb_t *utcb;
452 unsigned cnt;
453
454 public:
455 explicit Modify_senders(l4_utcb_t *u = l4_utcb()) noexcept
456 : utcb(u), cnt(1)
457 {
458 l4_utcb_mr_u(utcb)->mr[0] = L4_THREAD_MODIFY_SENDER_OP;
459 }
460
480 int add(l4_umword_t match_mask, l4_umword_t match,
481 l4_umword_t del_bits, l4_umword_t add_bits) noexcept
482 {
483 l4_msg_regs_t *m = l4_utcb_mr_u(utcb);
484 if (cnt >= L4_UTCB_GENERIC_DATA_SIZE - 4)
485 return -L4_ENOMEM;
486 m->mr[cnt++] = match_mask;
487 m->mr[cnt++] = match;
488 m->mr[cnt++] = del_bits;
489 m->mr[cnt++] = add_bits;
490 return 0;
491 }
492 };
493
525 {
526 return l4_ipc_call(cap(), todo.utcb, l4_msgtag(L4_PROTO_THREAD, todo.cnt, 0, 0), L4_IPC_NEVER);
527 }
528
553 { return l4_thread_register_doorbell_irq_u(cap(), irq.cap(), u); }
554};
555}
L4::Cap related definitions.
l4_cap_idx_t cap() const noexcept
Return capability selector.
Definition capability.h:49
C++ interface for capabilities.
Definition capability.h:224
Helper class to create an L4Re interface class that is derived from a single base class.
Definition __typeinfo.h:750
l4_cap_idx_t cap() const noexcept
Return capability selector.
Definition kobject:69
Thread attributes used for control().
Definition thread:137
void pager(Cap< void > const &pager) noexcept
Set the pager capability selector.
Definition thread:160
void exc_handler(Cap< void > const &exc_handler) noexcept
Set the exception-handler capability selector.
Definition thread:179
Attr(l4_utcb_t *utcb=l4_utcb()) noexcept
Create a thread-attribute object with the given UTCB.
Definition thread:150
Cap< void > exc_handler() noexcept
Get the capability selector used for exception messages.
Definition thread:188
void bind(l4_utcb_t *thread_utcb, Cap< Task > const &task) noexcept
Bind the thread to a task.
Definition thread:217
Cap< void > pager() noexcept
Get the capability selector used for page-fault messages.
Definition thread:169
void alien(int on) noexcept
Enable alien mode.
Definition thread:223
Class wrapping a list of rules which modify the sender label of IPC messages inbound to this thread.
Definition thread:448
int add(l4_umword_t match_mask, l4_umword_t match, l4_umword_t del_bits, l4_umword_t add_bits) noexcept
Add a rule.
Definition thread:480
C++ L4 kernel thread interface, see Thread for the C interface.
Definition thread:54
l4_msgtag_t register_doorbell_irq(Cap< Irq > irq, l4_utcb_t *u=l4_utcb()) noexcept
Register an IRQ that will trigger when a forwarded virtual interrupt is pending.
Definition thread:552
l4_msgtag_t control(Attr const &attr) noexcept
Commit the given thread-attributes object.
Definition thread:242
l4_msgtag_t register_del_irq(Cap< Irq > irq, l4_utcb_t *u=l4_utcb()) noexcept
Register an IRQ that will trigger upon deletion events.
Definition thread:426
l4_msgtag_t vcpu_resume_commit(l4_msgtag_t tag, l4_utcb_t *utcb=l4_utcb()) noexcept
Resume from vCPU asynchronous IPC handler, commit.
Definition thread:333
l4_msgtag_t switch_to(l4_utcb_t *utcb=l4_utcb()) noexcept
Switch execution to this thread.
Definition thread:252
l4_msgtag_t stats_time(l4_kernel_clock_t *us, l4_utcb_t *utcb=l4_utcb()) noexcept
Get consumed time of thread in us.
Definition thread:263
l4_msgtag_t vcpu_control(l4_addr_t vcpu_state, l4_utcb_t *utcb=l4_utcb()) noexcept
Enable the vCPU feature for the thread.
Definition thread:357
l4_msgtag_t modify_senders(Modify_senders const &todo) noexcept
Apply sender modification rules.
Definition thread:524
l4_msgtag_t ex_regs(l4_addr_t ip, l4_addr_t sp, l4_umword_t flags, l4_utcb_t *utcb=l4_utcb()) noexcept
Exchange basic thread registers.
Definition thread:83
l4_msgtag_t vcpu_control_ext(l4_addr_t ext_vcpu_state, l4_utcb_t *utcb=l4_utcb()) noexcept
Enable the extended vCPU feature for the thread.
Definition thread:397
l4_msgtag_t vcpu_resume_start(l4_utcb_t *utcb=l4_utcb()) noexcept
Resume from vCPU asynchronous IPC handler, start.
Definition thread:282
l4_msgtag_t ex_regs(l4_addr_t *ip, l4_addr_t *sp, l4_umword_t *flags, l4_utcb_t *utcb=l4_utcb()) noexcept
Exchange basic thread registers and return previous values.
Definition thread:118
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:40
unsigned long l4_addr_t
Address type.
Definition l4int.h:34
l4_uint64_t l4_kernel_clock_t
Kernel clock type.
Definition l4int.h:53
@ L4_ENOMEM
No memory.
Definition err.h:39
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:565
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:404
@ L4_PROTO_THREAD
Protocol for messages to a thread object.
Definition types.h:53
@ L4_THREAD_MODIFY_SENDER_OP
Modify all senders IDs that match the given pattern.
Definition thread.h:740
l4_msgtag_t l4_thread_vcpu_control_ext_u(l4_cap_idx_t thread, l4_addr_t ext_vcpu_state, l4_utcb_t *utcb) L4_NOTHROW
Enable the extended vCPU feature for the thread.
Definition thread.h:1059
l4_msgtag_t l4_thread_ex_regs_ret_u(l4_cap_idx_t thread, l4_addr_t *ip, l4_addr_t *sp, l4_umword_t *flags, l4_utcb_t *utcb) L4_NOTHROW
Exchange basic thread registers and return previous values.
Definition thread.h:823
l4_msgtag_t l4_thread_vcpu_control_u(l4_cap_idx_t thread, l4_addr_t vcpu_state, l4_utcb_t *utcb) L4_NOTHROW
Enable the vCPU feature for the thread.
Definition thread.h:1044
l4_msgtag_t l4_thread_ex_regs_u(l4_cap_idx_t thread, l4_addr_t ip, l4_addr_t sp, l4_umword_t flags, l4_utcb_t *utcb) L4_NOTHROW
Exchange basic thread registers.
Definition thread.h:812
#define L4_IPC_NEVER
never timeout
Definition __timeout.h:76
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Definition utcb.h:56
l4_utcb_t * l4_utcb(void) L4_NOTHROW L4_PURE
Get the UTCB address.
Definition utcb.h:346
L4 low-level kernel interface.
Message tag data structure.
Definition types.h:153
Encapsulation of the message-register block in the UTCB.
Definition utcb.h:68
l4_umword_t mr[L4_UTCB_GENERIC_DATA_SIZE]
Message registers.
Definition utcb.h:69