]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4sys/include/ARCH-arm/vm.h
update
[l4.git] / l4 / pkg / l4sys / include / ARCH-arm / vm.h
1 /**
2  * \file
3  * \brief ARM virtualization interface.
4  */
5 /*
6  * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
7  *               Torsten Frenzel <frenzel@os.inf.tu-dresden.de>
8  *     economic rights: Technische Universität Dresden (Germany)
9  *
10  * This file is part of TUD:OS and distributed under the terms of the
11  * GNU General Public License 2.
12  * Please see the COPYING-GPL-2 file for details.
13  *
14  * As a special exception, you may use this file as part of a free software
15  * library without restriction.  Specifically, if other files instantiate
16  * templates or use macros or inline functions from this file, or you compile
17  * this file and link it with other files to produce an executable, this
18  * file does not by itself cause the resulting executable to be covered by
19  * the GNU General Public License.  This exception does not however
20  * invalidate any other reasons why the executable file might be covered by
21  * the GNU General Public License.
22  */
23 #pragma once
24
25 #include <l4/sys/ipc.h>
26 #include <l4/sys/task.h>
27
28 /**
29  * \defgroup l4_vm_tz_api VM API for TZ
30  * \brief Virtual Machine API for ARM TrustZone
31  * \ingroup l4_vm_api
32  */
33
34 /**
35  * \brief state structure for TrustZone VMs
36  * \ingroup l4_vm_tz_api
37  */
38 struct l4_vm_state
39 {
40   l4_umword_t r[13]; // r0 - r12
41
42   l4_umword_t sp_usr;
43   l4_umword_t lr_usr;
44
45   l4_umword_t sp_irq;
46   l4_umword_t lr_irq;
47   l4_umword_t spsr_irq;
48
49   l4_umword_t r_fiq[5]; // r8 - r12
50   l4_umword_t sp_fiq;
51   l4_umword_t lr_fiq;
52   l4_umword_t spsr_fiq;
53
54   l4_umword_t sp_abt;
55   l4_umword_t lr_abt;
56   l4_umword_t spsr_abt;
57
58   l4_umword_t sp_und;
59   l4_umword_t lr_und;
60   l4_umword_t spsr_und;
61
62   l4_umword_t sp_svc;
63   l4_umword_t lr_svc;
64   l4_umword_t spsr_svc;
65
66   l4_umword_t pc;
67   l4_umword_t cpsr;
68
69   l4_umword_t pending_events;
70
71   l4_umword_t cp15_ttbr0;
72   l4_umword_t cp15_ttbr1;
73   l4_umword_t cp15_ttbc;
74   l4_umword_t cp15_vector_base;
75   l4_umword_t cp15_dfsr;
76   l4_umword_t cp15_dfar;
77   l4_umword_t cp15_ifsr;
78   l4_umword_t cp15_ifar;
79   l4_umword_t cp15_control;
80   l4_umword_t cp15_prim_region_remap;
81   l4_umword_t cp15_norm_region_remap;
82   l4_umword_t cp15_cid;    // banked
83   l4_umword_t cp15_tls[3]; // banked
84   l4_umword_t cp10_fpexc;
85
86   l4_umword_t pfs;
87   l4_umword_t pfa;
88   l4_umword_t exit_reason;
89 };
90
91
92 /**
93  * \brief Run a VM
94  * \ingroup l4_vm_tz_api
95  *
96  * \param vm         Capability selector for VM
97  */
98 L4_INLINE l4_msgtag_t
99 l4_vm_run(l4_cap_idx_t vm) L4_NOTHROW;
100
101 /**
102  * \internal
103  * \ingroup l4_vm_tz_api
104  */
105 L4_INLINE l4_msgtag_t
106 l4_vm_run_u(l4_cap_idx_t vm, l4_utcb_t *u) L4_NOTHROW;
107
108 /**
109  * \internal
110  * \brief Operations on task objects.
111  * \ingroup l4_vm_tz_api
112  */
113 enum
114 {
115   L4_VM_RUN_OP    = 0    /* Run a VM */
116 };
117
118
119 /****** Implementations ****************/
120
121 L4_INLINE l4_msgtag_t
122 l4_vm_run_u(l4_cap_idx_t vm, l4_fpage_t const vm_state_fpage,
123             l4_umword_t *label, l4_utcb_t *u) L4_NOTHROW
124 {
125   l4_msg_regs_t *r = l4_utcb_mr_u(u);
126   r->mr[0] = L4_VM_RUN_OP;
127   r->mr[1] = vm_state_fpage.raw;
128   //r->mr[2] = *label;
129
130   return l4_ipc(vm, u, L4_SYSF_CALL, *label, l4_msgtag(L4_PROTO_TASK, 3, 0, 0), label, L4_IPC_NEVER);
131 }
132
133 L4_INLINE l4_msgtag_t
134 l4_vm_run(l4_cap_idx_t vm, l4_fpage_t const vm_state_fpage,
135           l4_umword_t *label) L4_NOTHROW
136 {
137   return l4_vm_run_u(vm, vm_state_fpage, label, l4_utcb());
138 }