]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4sys/include/vcpu.h
update
[l4.git] / l4 / pkg / l4sys / include / vcpu.h
1 /*
2  * (c) 2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
3  *          Alexander Warg <warg@os.inf.tu-dresden.de>
4  *     economic rights: Technische Universität Dresden (Germany)
5  *
6  * This file is part of TUD:OS and distributed under the terms of the
7  * GNU General Public License 2.
8  * Please see the COPYING-GPL-2 file for details.
9  *
10  * As a special exception, you may use this file as part of a free software
11  * library without restriction.  Specifically, if other files instantiate
12  * templates or use macros or inline functions from this file, or you compile
13  * this file and link it with other files to produce an executable, this
14  * file does not by itself cause the resulting executable to be covered by
15  * the GNU General Public License.  This exception does not however
16  * invalidate any other reasons why the executable file might be covered by
17  * the GNU General Public License.
18  */
19 #pragma once
20
21 #include <l4/sys/types.h>
22 #include <l4/sys/__vcpu-arch.h>
23
24 /**
25  * \defgroup l4_vcpu_api vCPU API
26  * \ingroup  l4_thread_api
27  * \brief vCPU API
28  */
29
30 /**
31  * \brief State of a vCPU
32  * \ingroup l4_vcpu_api
33  */
34 typedef struct l4_vcpu_state_t
35 {
36   l4_vcpu_regs_t       r;             ///< Register state
37   l4_vcpu_ipc_regs_t   i;             ///< IPC state
38
39   l4_uint16_t          state;         ///< Current vCPU state
40   l4_uint16_t          saved_state;   ///< Saved vCPU state
41   l4_uint16_t          sticky_flags;  ///< Pending flags
42   l4_uint16_t          _reserved;     ///< \internal
43
44   l4_cap_idx_t         user_task;     ///< User task to use
45
46   l4_umword_t          entry_sp;      ///< Stack pointer for entry (when coming from user task)
47   l4_umword_t          entry_ip;      ///< IP for entry
48   l4_umword_t          reserved_sp;   ///< \internal
49   l4_vcpu_arch_state_t arch_state;
50 } l4_vcpu_state_t;
51
52 /**
53  * \brief State flags of a vCPU
54  * \ingroup l4_vcpu_api
55  */
56 enum L4_vcpu_state_flags
57 {
58   L4_VCPU_F_IRQ         = 0x01, ///< IRQs (events) enabled
59   L4_VCPU_F_PAGE_FAULTS = 0x02, ///< Page faults enabled
60   L4_VCPU_F_EXCEPTIONS  = 0x04, ///< Exception enabled
61   L4_VCPU_F_DEBUG_EXC   = 0x08, ///< Debug exception enabled
62   L4_VCPU_F_USER_MODE   = 0x20, ///< User task will be used
63   L4_VCPU_F_FPU_ENABLED = 0x80, ///< FPU enabled
64 };
65
66 /**
67  * \brief Sticky flags of a vCPU
68  * \ingroup l4_vcpu_api
69  */
70 enum L4_vcpu_sticky_flags
71 {
72   L4_VCPU_SF_IRQ_PENDING = 0x01, ///< An event (e.g. IRQ) is pending
73 };
74
75 /**
76  * \brief Offsets for vCPU state layouts
77  * \ingroup l4_vcpu_api
78  */
79 enum L4_vcpu_state_offset
80 {
81   L4_VCPU_OFFSET_EXT_STATE = 0x400, ///< Offset where extended state begins
82   L4_VCPU_OFFSET_EXT_INFOS = 0x200, ///< Offset where extended infos begin
83 };