Loading...
Searching...
No Matches
vcpu
Go to the documentation of this file.
// vi:se ft=cpp:
/*
* (c) 2010 Adam Lackorzynski <adam@os.inf.tu-dresden.de>
* economic rights: Technische Universität Dresden (Germany)
*
* License: see LICENSE.spdx (in this directory or the directories above)
*/
#pragma once
#include <l4/re/env>
#include <l4/vcpu/vcpu.h>
namespace L4vcpu {
class State
{
public:
State() {}
explicit State(unsigned v) : _s(v) {}
void add(unsigned bits) throw() { _s |= bits; }
void clear(unsigned bits) throw() { _s &= ~bits; }
void set(unsigned v) throw() { _s = v; }
private:
__typeof__(((l4_vcpu_state_t *)0)->state) _s;
};
class Vcpu : private l4_vcpu_state_t
{
public:
void irq_disable() throw()
{ l4vcpu_irq_disable(this); }
unsigned irq_disable_save() throw()
{ return l4vcpu_irq_disable_save(this); }
l4_vcpu_state_t *s() { return this; }
l4_vcpu_state_t const *s() const { return this; }
State *state() throw()
{
static_assert(sizeof(State) == sizeof(l4_vcpu_state_t::state),
"size mismatch");
return reinterpret_cast< State *>(&(l4_vcpu_state_t::state));
}
State state() const throw()
{ return static_cast< State >(l4_vcpu_state_t::state); }
State *saved_state() throw()
{
static_assert(sizeof(State) == sizeof(l4_vcpu_state_t::saved_state),
"size mismatch");
return reinterpret_cast< State *>(&(l4_vcpu_state_t::saved_state));
}
State saved_state() const throw()
{ return static_cast< State >(l4_vcpu_state_t::saved_state); }
l4_uint16_t sticky_flags() const throw()
{ return l4_vcpu_state_t::sticky_flags; }
void irq_enable(l4_utcb_t *utcb, l4vcpu_event_hndl_t do_event_work_cb,
l4vcpu_setup_ipc_t setup_ipc) throw()
{ l4vcpu_irq_enable(this, utcb, do_event_work_cb, setup_ipc); }
void irq_restore(unsigned s, l4_utcb_t *utcb,
l4vcpu_event_hndl_t do_event_work_cb,
l4vcpu_setup_ipc_t setup_ipc) throw()
{ l4vcpu_irq_restore(this, s, utcb, do_event_work_cb, setup_ipc); }
void wait_for_event(l4_utcb_t *utcb, l4vcpu_event_hndl_t do_event_work_cb,
l4vcpu_setup_ipc_t setup_ipc) throw()
{ l4vcpu_wait_for_event(this, utcb, do_event_work_cb, setup_ipc); }
void task(L4::Cap<L4::Task> const task = L4::Cap<L4::Task>::Invalid) throw()
{ user_task = task.cap(); }
int is_page_fault_entry() const
{ return l4vcpu_is_page_fault_entry(this); }
int is_irq_entry() const
{ return l4vcpu_is_irq_entry(this); }
l4_vcpu_regs_t *r() throw()
{ return &(l4_vcpu_state_t::r); }
l4_vcpu_regs_t const *r() const throw()
{ return &(l4_vcpu_state_t::r); }
l4_vcpu_ipc_regs_t *i() throw()
{ return &(l4_vcpu_state_t::i); }
l4_vcpu_ipc_regs_t const *i() const throw()
{ return &(l4_vcpu_state_t::i); }
void entry_sp(l4_umword_t sp)
{ l4_vcpu_state_t::entry_sp = sp; }
void entry_ip(l4_umword_t ip)
{ l4_vcpu_state_t::entry_ip = ip; }
L4_CV static int
ext_alloc(Vcpu **vcpu,
l4_addr_t *ext_state,
L4::Cap<L4::Task> task = L4Re::Env::env()->task(),
L4::Cap<L4Re::Rm> rm = L4Re::Env::env()->rm()) throw();
static inline Vcpu *cast(void *x) throw()
{ return reinterpret_cast< Vcpu *>(x); }
static inline Vcpu *cast(l4_addr_t x) throw()
{ return reinterpret_cast< Vcpu *>(x); }
void print_state(const char *prefix = "") const throw()
{ l4vcpu_print_state(this, prefix); }
};
}
L4Re::Env::env
static Env const * env() noexcept
Returns the initial environment for the current task.
Definition env:96
L4::Cap_base::Invalid
@ Invalid
Invalid capability selector.
Definition capability.h:42
L4::Cap
C++ interface for capabilities.
Definition capability.h:224
L4vcpu::State
C++ implementation of state word in the vCPU area.
Definition vcpu:25
L4vcpu::State::set
void set(unsigned v)
Set flags.
Definition vcpu:55
L4vcpu::State::add
void add(unsigned bits)
Add flags.
Definition vcpu:41
L4vcpu::State::State
State(unsigned v)
Initialize state.
Definition vcpu:34
L4vcpu::State::clear
void clear(unsigned bits)
Clear flags.
Definition vcpu:48
L4vcpu::Vcpu
C++ implementation of the vCPU save state area.
Definition vcpu:66
L4vcpu::Vcpu::irq_disable_save
unsigned irq_disable_save()
Disable the vCPU for event delivery and return previous state.
Definition vcpu:78
L4vcpu::Vcpu::i
l4_vcpu_ipc_regs_t const * i() const
Return pointer to IPC state.
Definition vcpu:216
L4vcpu::Vcpu::state
State * state()
Get state word.
Definition vcpu:88
L4vcpu::Vcpu::cast
static Vcpu * cast(void *x)
Cast a void pointer to a class pointer.
Definition vcpu:259
L4vcpu::Vcpu::is_irq_entry
int is_irq_entry() const
Return whether the entry reason was an IRQ/IPC message.
Definition vcpu:188
L4vcpu::Vcpu::ext_alloc
static int ext_alloc(Vcpu **vcpu, l4_addr_t *ext_state, L4::Cap< L4::Task > task=L4Re::Env::env() ->task(), L4::Cap< L4Re::Rm > rm=L4Re::Env::env() ->rm())
Allocate state area for an extended vCPU.
L4vcpu::Vcpu::irq_disable
void irq_disable()
Disable the vCPU for event delivery.
Definition vcpu:71
L4vcpu::Vcpu::state
State state() const
Get state word.
Definition vcpu:99
L4vcpu::Vcpu::i
l4_vcpu_ipc_regs_t * i()
Return pointer to IPC state.
Definition vcpu:209
L4vcpu::Vcpu::cast
static Vcpu * cast(l4_addr_t x)
Cast an address to a class pointer.
Definition vcpu:269
L4vcpu::Vcpu::r
l4_vcpu_regs_t const * r() const
Return pointer to register state.
Definition vcpu:202
L4vcpu::Vcpu::r
l4_vcpu_regs_t * r()
Return pointer to register state.
Definition vcpu:195
L4vcpu::Vcpu::entry_ip
void entry_ip(l4_umword_t ip)
Set vCPU entry instruction pointer.
Definition vcpu:232
L4vcpu::Vcpu::irq_enable
void irq_enable(l4_utcb_t *utcb, l4vcpu_event_hndl_t do_event_work_cb, l4vcpu_setup_ipc_t setup_ipc)
Enable the vCPU for event delivery.
Definition vcpu:135
L4vcpu::Vcpu::wait_for_event
void wait_for_event(l4_utcb_t *utcb, l4vcpu_event_hndl_t do_event_work_cb, l4vcpu_setup_ipc_t setup_ipc)
Wait for event.
Definition vcpu:166
L4vcpu::Vcpu::entry_sp
void entry_sp(l4_umword_t sp)
Set vCPU entry stack pointer.
Definition vcpu:225
L4vcpu::Vcpu::print_state
void print_state(const char *prefix="") const
Print the state of the vCPU.
Definition vcpu:275
L4vcpu::Vcpu::task
void task(L4::Cap< L4::Task > const task=L4::Cap< L4::Task >::Invalid)
Set the task of the vCPU.
Definition vcpu:174
L4vcpu::Vcpu::sticky_flags
l4_uint16_t sticky_flags() const
Get sticky flags.
Definition vcpu:122
L4vcpu::Vcpu::irq_restore
void irq_restore(unsigned s, l4_utcb_t *utcb, l4vcpu_event_hndl_t do_event_work_cb, l4vcpu_setup_ipc_t setup_ipc)
Restore a previously saved IRQ/event state.
Definition vcpu:150
L4vcpu::Vcpu::saved_state
State * saved_state()
Get saved_state word.
Definition vcpu:106
L4vcpu::Vcpu::is_page_fault_entry
int is_page_fault_entry() const
Return whether the entry reason was a page fault.
Definition vcpu:181
L4vcpu::Vcpu::saved_state
State saved_state() const
Get saved_state word.
Definition vcpu:116
env
Environment interface.
l4vcpu_is_irq_entry
int l4vcpu_is_irq_entry(l4_vcpu_state_t const *vcpu) L4_NOTHROW
Return whether the entry reason was an IRQ/IPC message.
l4vcpu_irq_enable
void l4vcpu_irq_enable(l4_vcpu_state_t *vcpu, l4_utcb_t *utcb, l4vcpu_event_hndl_t do_event_work_cb, l4vcpu_setup_ipc_t setup_ipc) L4_NOTHROW
Enable a vCPU for event delivery.
Definition vcpu.h:232
l4vcpu_irq_restore
void l4vcpu_irq_restore(l4_vcpu_state_t *vcpu, unsigned s, l4_utcb_t *utcb, l4vcpu_event_hndl_t do_event_work_cb, l4vcpu_setup_ipc_t setup_ipc) L4_NOTHROW
Restore a previously saved IRQ/event state.
Definition vcpu.h:257
l4vcpu_irq_disable_save
unsigned l4vcpu_irq_disable_save(l4_vcpu_state_t *vcpu) L4_NOTHROW
Disable a vCPU for event delivery and return previous state.
Definition vcpu.h:209
l4vcpu_is_page_fault_entry
int l4vcpu_is_page_fault_entry(l4_vcpu_state_t const *vcpu) L4_NOTHROW
Return whether the entry reason was a page fault.
l4vcpu_irq_disable
void l4vcpu_irq_disable(l4_vcpu_state_t *vcpu) L4_NOTHROW
Disable a vCPU for event delivery.
Definition vcpu.h:201
l4vcpu_print_state
void l4vcpu_print_state(const l4_vcpu_state_t *vcpu, const char *prefix) L4_NOTHROW
Print the state of a vCPU.
l4vcpu_wait_for_event
void l4vcpu_wait_for_event(l4_vcpu_state_t *vcpu, l4_utcb_t *utcb, l4vcpu_event_hndl_t do_event_work_cb, l4vcpu_setup_ipc_t setup_ipc) L4_NOTHROW
Wait for event.
Definition vcpu.h:270
l4_umword_t
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:40
l4_addr_t
unsigned long l4_addr_t
Address type.
Definition l4int.h:34
l4_uint16_t
unsigned short int l4_uint16_t
Unsigned 16bit value.
Definition l4int.h:27
l4_utcb_t
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Definition utcb.h:56
L4_CV
#define L4_CV
Define calling convention.
Definition linkage.h:33
l4_vcpu_ipc_regs_t
vCPU message registers.
Definition __vcpu-arch.h:84
l4_vcpu_regs_t
vCPU registers.
Definition __vcpu-arch.h:56
l4_vcpu_state_t
State of a vCPU.
Definition vcpu.h:76
l4_vcpu_state_t::entry_sp
l4_umword_t entry_sp
Stack pointer for entry (when coming from user task).
Definition vcpu.h:91
l4_vcpu_state_t::sticky_flags
l4_uint16_t sticky_flags
Pending flags. See L4_vcpu_sticky_flags.
Definition vcpu.h:86
l4_vcpu_state_t::state
l4_uint16_t state
Current vCPU state. See L4_vcpu_state_flags.
Definition vcpu.h:84
l4_vcpu_state_t::r
l4_vcpu_regs_t r
Register state.
Definition vcpu.h:81
l4_vcpu_state_t::entry_ip
l4_umword_t entry_ip
IP for entry.
Definition vcpu.h:92
l4_vcpu_state_t::user_task
l4_cap_idx_t user_task
User task to use.
Definition vcpu.h:89
l4_vcpu_state_t::i
l4_vcpu_ipc_regs_t i
IPC state.
Definition vcpu.h:82
l4_vcpu_state_t::saved_state
l4_uint16_t saved_state
Saved vCPU state. See L4_vcpu_state_flags.
Definition vcpu.h:85
vcpu.h
vCPU support library (C interface).