L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
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 * This file is part of TUD:OS and distributed under the terms of the
12 * GNU General Public License 2.
13 * Please see the COPYING-GPL-2 file for details.
14 *
15 * As a special exception, you may use this file as part of a free software
16 * library without restriction. Specifically, if other files instantiate
17 * templates or use macros or inline functions from this file, or you compile
18 * this file and link it with other files to produce an executable, this
19 * file does not by itself cause the resulting executable to be covered by
20 * the GNU General Public License. This exception does not however
21 * invalidate any other reasons why the executable file might be covered by
22 * the GNU General Public License.
23 */
24
25#pragma once
26
27#include <l4/sys/capability>
28#include <l4/sys/thread.h>
29
30namespace L4 {
31
59class Thread :
60 public Kobject_t<Thread, Kobject, L4_PROTO_THREAD,
61 Type_info::Demand_t<1> >
62{
63public:
91 l4_umword_t flags,
92 l4_utcb_t *utcb = l4_utcb()) noexcept
93 { return l4_thread_ex_regs_u(cap(), ip, sp, flags, utcb); }
94
124 l4_umword_t *flags,
125 l4_utcb_t *utcb = l4_utcb()) noexcept
126 { return l4_thread_ex_regs_ret_u(cap(), ip, sp, flags, utcb); }
127
128
141 class Attr
142 {
143 private:
144 friend class L4::Thread;
145 l4_utcb_t *_u;
146
147 public:
155 explicit Attr(l4_utcb_t *utcb = l4_utcb()) noexcept : _u(utcb)
156 { l4_thread_control_start_u(utcb); }
157
165 void pager(Cap<void> const &pager) noexcept
166 { l4_thread_control_pager_u(pager.cap(), _u); }
167
174 Cap<void> pager() noexcept
175 { return Cap<void>(l4_utcb_mr_u(_u)->mr[1]); }
176
184 void exc_handler(Cap<void> const &exc_handler) noexcept
185 { l4_thread_control_exc_handler_u(exc_handler.cap(), _u); }
186
194 { return Cap<void>(l4_utcb_mr_u(_u)->mr[2]); }
195
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
231 void ux_host_syscall(int on) noexcept
232 { l4_thread_control_ux_host_syscall_u(_u, on); }
233
234 };
235
249 l4_msgtag_t control(Attr const &attr) noexcept
250 { return l4_thread_control_commit_u(cap(), attr._u); }
251
260 { return l4_thread_switch_u(cap(), utcb); }
261
271 l4_utcb_t *utcb = l4_utcb()) noexcept
272 { return l4_thread_stats_time_u(cap(), us, utcb); }
273
290 { return l4_thread_vcpu_resume_start_u(utcb); }
291
331 l4_utcb_t *utcb = l4_utcb()) noexcept
332 { return l4_thread_vcpu_resume_commit_u(cap(), tag, utcb); }
333
355 noexcept
356 { return l4_thread_vcpu_control_u(cap(), vcpu_state, utcb); }
357
388 l4_utcb_t *utcb = l4_utcb()) noexcept
389 { return l4_thread_vcpu_control_ext_u(cap(), ext_vcpu_state, utcb); }
390
415 { return l4_thread_register_del_irq_u(cap(), irq.cap(), u); }
416
436 {
437 private:
438 friend class Thread;
439 l4_utcb_t *utcb;
440 unsigned cnt;
441
442 public:
443 explicit Modify_senders(l4_utcb_t *u = l4_utcb()) noexcept
444 : utcb(u), cnt(1)
445 {
446 l4_utcb_mr_u(utcb)->mr[0] = L4_THREAD_MODIFY_SENDER_OP;
447 }
448
468 int add(l4_umword_t match_mask, l4_umword_t match,
469 l4_umword_t del_bits, l4_umword_t add_bits) noexcept
470 {
471 l4_msg_regs_t *m = l4_utcb_mr_u(utcb);
472 if (cnt >= L4_UTCB_GENERIC_DATA_SIZE - 4)
473 return -L4_ENOMEM;
474 m->mr[cnt++] = match_mask;
475 m->mr[cnt++] = match;
476 m->mr[cnt++] = del_bits;
477 m->mr[cnt++] = add_bits;
478 return 0;
479 }
480 };
481
502 {
503 return l4_ipc_call(cap(), todo.utcb, l4_msgtag(L4_PROTO_THREAD, todo.cnt, 0, 0), L4_IPC_NEVER);
504 }
505};
506}
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:219
Helper class to create an L4Re interface class that is derived from a single base class.
Definition __typeinfo.h:761
l4_cap_idx_t cap() const noexcept
Return capability selector.
Definition kobject:79
Thread attributes used for control().
Definition thread:142
void pager(Cap< void > const &pager) noexcept
Set the pager capability selector.
Definition thread:165
void exc_handler(Cap< void > const &exc_handler) noexcept
Set the exception-handler capability selector.
Definition thread:184
Attr(l4_utcb_t *utcb=l4_utcb()) noexcept
Create a thread-attribute object with the given UTCB.
Definition thread:155
void ux_host_syscall(int on) noexcept
Allow host system calls on Fiasco-UX.
Definition thread:231
Cap< void > exc_handler() noexcept
Get the capability selector used for exception messages.
Definition thread:193
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:174
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:436
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:468
C++ L4 kernel thread interface, see Thread for the C interface.
Definition thread:62
l4_msgtag_t control(Attr const &attr) noexcept
Commit the given thread-attributes object.
Definition thread:249
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:414
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:330
l4_msgtag_t switch_to(l4_utcb_t *utcb=l4_utcb()) noexcept
Switch execution to this thread.
Definition thread:259
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:270
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:354
l4_msgtag_t modify_senders(Modify_senders const &todo) noexcept
Apply sender modification rules.
Definition thread:501
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:90
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:387
l4_msgtag_t vcpu_resume_start(l4_utcb_t *utcb=l4_utcb()) noexcept
Resume from vCPU asynchronous IPC handler, start.
Definition thread:289
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:123
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:51
unsigned long l4_addr_t
Address type.
Definition l4int.h:45
l4_uint64_t l4_kernel_clock_t
Kernel clock type.
Definition l4int.h:64
@ L4_ENOMEM
No memory.
Definition err.h:50
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:576
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:428
@ L4_PROTO_THREAD
Protocol for messages to a thread object.
Definition types.h:64
@ L4_THREAD_MODIFY_SENDER_OP
Modify all senders IDs that match the given pattern.
Definition thread.h:701
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:1035
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:785
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:1020
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:774
#define L4_IPC_NEVER
never timeout
Definition __timeout.h:84
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Definition utcb.h:67
l4_utcb_t * l4_utcb(void) L4_NOTHROW L4_PURE
Get the UTCB address.
Definition utcb.h:340
L4 low-level kernel interface.
Definition io_regblock.h:19
Message tag data structure.
Definition types.h:164
Encapsulation of the message-register block in the UTCB.
Definition utcb.h:79
l4_umword_t mr[L4_UTCB_GENERIC_DATA_SIZE]
Message registers.
Definition utcb.h:80