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 * License: see LICENSE.spdx (in this directory or the directories above)
12 */
13
14#pragma once
15
16#include <l4/sys/capability>
18#include <l4/sys/thread.h>
19
20namespace L4 {
21
52class Thread :
53 public Kobject_t<Thread, Snd_destination, L4_PROTO_THREAD,
54 Type_info::Demand_t<1> >
55{
56public:
85 l4_umword_t flags,
86 l4_utcb_t *utcb = l4_utcb()) noexcept
87 { return l4_thread_ex_regs_u(cap(), ip, sp, flags, utcb); }
88
120 l4_umword_t *flags,
121 l4_utcb_t *utcb = l4_utcb()) noexcept
122 { return l4_thread_ex_regs_ret_u(cap(), ip, sp, flags, utcb); }
123
124
137 class Attr
138 {
139 private:
140 friend class L4::Thread;
141 l4_utcb_t *_u;
142
143 public:
151 explicit Attr(l4_utcb_t *utcb = l4_utcb()) noexcept : _u(utcb)
152 { l4_thread_control_start_u(utcb); }
153
161 void pager(Cap<void> const &pager) noexcept
162 { l4_thread_control_pager_u(pager.cap(), _u); }
163
171 Cap<void> pager() noexcept
172 { return Cap<void>(l4_utcb_mr_u(_u)->mr[1]); }
173
182 void exc_handler(Cap<void> const &exc_handler) noexcept
183 { l4_thread_control_exc_handler_u(exc_handler.cap(), _u); }
184
193 { return Cap<void>(l4_utcb_mr_u(_u)->mr[2]); }
194
221 void bind(l4_utcb_t *thread_utcb, Cap<Task> const &task) noexcept
222 { l4_thread_control_bind_u(thread_utcb, task.cap(), _u); }
223
227 void alien(int on) noexcept
228 { l4_thread_control_alien_u(_u, on); }
229 };
230
246 l4_msgtag_t control(Attr const &attr) noexcept
247 { return l4_thread_control_commit_u(cap(), attr._u); }
248
257 { return l4_thread_switch_u(cap(), utcb); }
258
268 l4_utcb_t *utcb = l4_utcb()) noexcept
269 { return l4_thread_stats_time_u(cap(), us, utcb); }
270
287 { return l4_thread_vcpu_resume_start_u(utcb); }
288
338 l4_utcb_t *utcb = l4_utcb()) noexcept
339 { return l4_thread_vcpu_resume_commit_u(cap(), tag, utcb); }
340
362 noexcept
363 { return l4_thread_vcpu_control_u(cap(), vcpu_state, utcb); }
364
402 l4_utcb_t *utcb = l4_utcb()) noexcept
403 { return l4_thread_vcpu_control_ext_u(cap(), ext_vcpu_state, utcb); }
404
431 { return l4_thread_register_del_irq_u(cap(), irq.cap(), u); }
432
451 class Modify_senders
452 {
453 private:
454 friend class Thread;
455 l4_utcb_t *utcb;
456 unsigned cnt;
457
458 public:
459 explicit Modify_senders(l4_utcb_t *u = l4_utcb()) noexcept
460 : utcb(u), cnt(1)
461 {
462 l4_utcb_mr_u(utcb)->mr[0] = L4_THREAD_MODIFY_SENDER_OP;
463 }
464
484 int add(l4_umword_t match_mask, l4_umword_t match,
485 l4_umword_t del_bits, l4_umword_t add_bits) noexcept
486 {
487 l4_msg_regs_t *m = l4_utcb_mr_u(utcb);
488 if (cnt >= L4_UTCB_GENERIC_DATA_SIZE - 4)
489 return -L4_ENOMEM;
490 m->mr[cnt++] = match_mask;
491 m->mr[cnt++] = match;
492 m->mr[cnt++] = del_bits;
493 m->mr[cnt++] = add_bits;
494 return 0;
495 }
496 };
497
529 {
530 return l4_ipc_call(cap(), todo.utcb, l4_msgtag(L4_PROTO_THREAD, todo.cnt, 0, 0), L4_IPC_NEVER);
531 }
532
557 { return l4_thread_register_doorbell_irq_u(cap(), irq.cap(), u); }
558
559
586 l4_utcb_t *u = l4_utcb()) noexcept
587 { return l4_thread_pf_trampoline_setup_u(cap(), pf_tramp_state, u); }
588
598 { return l4_thread_pf_trampoline_resume_u(cap(), u); }
599
610 { return l4_thread_pf_trampoline_reflect_u(cap(), u); }
611
619 l4_msgtag_t pf_trampoline_disable(int *was_enabled = nullptr,
620 l4_utcb_t *u = l4_utcb()) noexcept
621 { return l4_thread_pf_trampoline_disable_u(cap(), was_enabled, u); }
622
631 { return l4_thread_pf_trampoline_enable_u(cap(), u); }
632};
633
634}
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:249
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:138
void pager(Cap< void > const &pager) noexcept
Set the pager capability index.
Definition thread:161
void exc_handler(Cap< void > const &exc_handler) noexcept
Set the exception-handler capability index.
Definition thread:182
Attr(l4_utcb_t *utcb=l4_utcb()) noexcept
Create a thread-attribute object with the given UTCB.
Definition thread:151
Cap< void > exc_handler() noexcept
Get the capability index used for exception messages.
Definition thread:192
void bind(l4_utcb_t *thread_utcb, Cap< Task > const &task) noexcept
Bind the thread to a task.
Definition thread:221
Cap< void > pager() noexcept
Get the capability index used for page-fault messages.
Definition thread:171
void alien(int on) noexcept
Enable alien mode.
Definition thread:227
Class wrapping a list of rules which modify the sender label of IPC messages inbound to this thread.
Definition thread:452
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:484
C++ L4 kernel thread interface, see Thread for the C interface.
Definition thread:55
l4_msgtag_t pf_trampoline_resume(l4_utcb_t *u=l4_utcb()) noexcept
Resume from page fault trampoline handler.
Definition thread:597
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:556
l4_msgtag_t control(Attr const &attr) noexcept
Commit the given thread-attributes object.
Definition thread:246
l4_msgtag_t pf_trampoline_setup(l4_addr_t pf_tramp_state, l4_utcb_t *u=l4_utcb()) noexcept
Setup page fault trampoline handler.
Definition thread:585
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:430
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:337
l4_msgtag_t switch_to(l4_utcb_t *utcb=l4_utcb()) noexcept
Switch execution to this thread.
Definition thread:256
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:267
l4_msgtag_t pf_trampoline_reflect(l4_utcb_t *u=l4_utcb()) noexcept
Page fault trampoline handler reflects page fault to exception handler.
Definition thread:609
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:361
l4_msgtag_t modify_senders(Modify_senders const &todo) noexcept
Apply sender modification rules.
Definition thread:528
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:84
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:401
l4_msgtag_t vcpu_resume_start(l4_utcb_t *utcb=l4_utcb()) noexcept
Resume from vCPU asynchronous IPC handler, start.
Definition thread:286
l4_msgtag_t pf_trampoline_disable(int *was_enabled=nullptr, l4_utcb_t *u=l4_utcb()) noexcept
Disable the page fault trampoline handling for this thread.
Definition thread:619
l4_msgtag_t pf_trampoline_enable(l4_utcb_t *u=l4_utcb()) noexcept
Re-enable the page fault trampoline handling for this thread.
Definition thread:630
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:119
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:40
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:625
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:444
@ L4_PROTO_THREAD
Protocol for messages to a thread object.
Definition types.h:70
@ L4_THREAD_MODIFY_SENDER_OP
Modify all senders IDs that match the given pattern.
Definition thread.h:854
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:1203
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:967
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:1188
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:956
#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:369
Common thread related definitions.
L4 low-level kernel interface.
The C++ Sender destination interface.
Message tag data structure.
Definition types.h:269
Encapsulation of the message-register block in the UTCB.
Definition utcb.h:133
l4_umword_t mr[L4_UTCB_GENERIC_DATA_SIZE]
Message registers.
Definition utcb.h:134