root / target-s390x / cpu.h @ 10eb0cc0
History | View | Annotate | Download (7.2 kB)
1 |
/*
|
---|---|
2 |
* S/390 virtual CPU header
|
3 |
*
|
4 |
* Copyright (c) 2009 Ulrich Hecht
|
5 |
*
|
6 |
* This library is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU Lesser General Public
|
8 |
* License as published by the Free Software Foundation; either
|
9 |
* version 2 of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This library is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
* Lesser General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU Lesser General Public
|
17 |
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
18 |
*/
|
19 |
#ifndef CPU_S390X_H
|
20 |
#define CPU_S390X_H
|
21 |
|
22 |
#define TARGET_LONG_BITS 64 |
23 |
|
24 |
#define ELF_MACHINE EM_S390
|
25 |
|
26 |
#define CPUState struct CPUS390XState |
27 |
|
28 |
#include "cpu-defs.h" |
29 |
|
30 |
#include "softfloat.h" |
31 |
|
32 |
#define NB_MMU_MODES 2 |
33 |
|
34 |
typedef union FPReg { |
35 |
struct {
|
36 |
#ifdef WORDS_BIGENDIAN
|
37 |
float32 e; |
38 |
int32_t __pad; |
39 |
#else
|
40 |
int32_t __pad; |
41 |
float32 e; |
42 |
#endif
|
43 |
}; |
44 |
float64 d; |
45 |
uint64_t i; |
46 |
} FPReg; |
47 |
|
48 |
typedef struct CPUS390XState { |
49 |
uint64_t regs[16]; /* GP registers */ |
50 |
|
51 |
uint32_t aregs[16]; /* access registers */ |
52 |
|
53 |
uint32_t fpc; /* floating-point control register */
|
54 |
FPReg fregs[16]; /* FP registers */ |
55 |
float_status fpu_status; /* passed to softfloat lib */
|
56 |
|
57 |
struct {
|
58 |
uint64_t mask; |
59 |
uint64_t addr; |
60 |
} psw; |
61 |
|
62 |
int cc; /* condition code (0-3) */ |
63 |
|
64 |
uint64_t __excp_addr; |
65 |
|
66 |
CPU_COMMON |
67 |
} CPUS390XState; |
68 |
|
69 |
#if defined(CONFIG_USER_ONLY)
|
70 |
static inline void cpu_clone_regs(CPUState *env, target_ulong newsp) |
71 |
{ |
72 |
if (newsp)
|
73 |
env->regs[15] = newsp;
|
74 |
env->regs[0] = 0; |
75 |
} |
76 |
#endif
|
77 |
|
78 |
#define MMU_MODE0_SUFFIX _kernel
|
79 |
#define MMU_MODE1_SUFFIX _user
|
80 |
#define MMU_USER_IDX 1 |
81 |
static inline int cpu_mmu_index (CPUState *env) |
82 |
{ |
83 |
/* XXX: Currently we don't implement virtual memory */
|
84 |
return 0; |
85 |
} |
86 |
|
87 |
CPUS390XState *cpu_s390x_init(const char *cpu_model); |
88 |
int cpu_s390x_exec(CPUS390XState *s);
|
89 |
void cpu_s390x_close(CPUS390XState *s);
|
90 |
|
91 |
/* you can call this signal handler from your SIGBUS and SIGSEGV
|
92 |
signal handlers to inform the virtual CPU of exceptions. non zero
|
93 |
is returned if the signal was handled by the virtual CPU. */
|
94 |
int cpu_s390x_signal_handler(int host_signum, void *pinfo, |
95 |
void *puc);
|
96 |
int cpu_s390x_handle_mmu_fault (CPUS390XState *env, target_ulong address, int rw, |
97 |
int mmu_idx, int is_softmuu); |
98 |
#define cpu_handle_mmu_fault cpu_s390x_handle_mmu_fault
|
99 |
|
100 |
#define TARGET_PAGE_BITS 12 |
101 |
|
102 |
/* ??? This is certainly wrong for 64-bit s390x, but given that only KVM
|
103 |
emulation actually works, this is good enough for a placeholder. */
|
104 |
#define TARGET_PHYS_ADDR_SPACE_BITS 32 |
105 |
#define TARGET_VIRT_ADDR_SPACE_BITS 32 |
106 |
|
107 |
#ifndef CONFIG_USER_ONLY
|
108 |
extern int s390_virtio_hypercall(CPUState *env); |
109 |
extern void kvm_s390_virtio_irq(CPUState *env, int config_change, uint64_t token); |
110 |
extern CPUState *s390_cpu_addr2state(uint16_t cpu_addr);
|
111 |
#endif
|
112 |
|
113 |
|
114 |
#define cpu_init cpu_s390x_init
|
115 |
#define cpu_exec cpu_s390x_exec
|
116 |
#define cpu_gen_code cpu_s390x_gen_code
|
117 |
|
118 |
#include "cpu-all.h" |
119 |
#include "exec-all.h" |
120 |
|
121 |
#define EXCP_OPEX 1 /* operation exception (sigill) */ |
122 |
#define EXCP_SVC 2 /* supervisor call (syscall) */ |
123 |
#define EXCP_ADDR 5 /* addressing exception */ |
124 |
#define EXCP_EXECUTE_SVC 0xff00000 /* supervisor call via execute insn */ |
125 |
|
126 |
static inline void cpu_get_tb_cpu_state(CPUState* env, target_ulong *pc, |
127 |
target_ulong *cs_base, int *flags)
|
128 |
{ |
129 |
*pc = env->psw.addr; |
130 |
/* XXX this is correct for user-mode emulation, but needs
|
131 |
* the asce register information as well when softmmu
|
132 |
* is implemented in the future */
|
133 |
*cs_base = 0;
|
134 |
*flags = env->psw.mask; |
135 |
} |
136 |
|
137 |
/* Program Status Word. */
|
138 |
#define S390_PSWM_REGNUM 0 |
139 |
#define S390_PSWA_REGNUM 1 |
140 |
/* General Purpose Registers. */
|
141 |
#define S390_R0_REGNUM 2 |
142 |
#define S390_R1_REGNUM 3 |
143 |
#define S390_R2_REGNUM 4 |
144 |
#define S390_R3_REGNUM 5 |
145 |
#define S390_R4_REGNUM 6 |
146 |
#define S390_R5_REGNUM 7 |
147 |
#define S390_R6_REGNUM 8 |
148 |
#define S390_R7_REGNUM 9 |
149 |
#define S390_R8_REGNUM 10 |
150 |
#define S390_R9_REGNUM 11 |
151 |
#define S390_R10_REGNUM 12 |
152 |
#define S390_R11_REGNUM 13 |
153 |
#define S390_R12_REGNUM 14 |
154 |
#define S390_R13_REGNUM 15 |
155 |
#define S390_R14_REGNUM 16 |
156 |
#define S390_R15_REGNUM 17 |
157 |
/* Access Registers. */
|
158 |
#define S390_A0_REGNUM 18 |
159 |
#define S390_A1_REGNUM 19 |
160 |
#define S390_A2_REGNUM 20 |
161 |
#define S390_A3_REGNUM 21 |
162 |
#define S390_A4_REGNUM 22 |
163 |
#define S390_A5_REGNUM 23 |
164 |
#define S390_A6_REGNUM 24 |
165 |
#define S390_A7_REGNUM 25 |
166 |
#define S390_A8_REGNUM 26 |
167 |
#define S390_A9_REGNUM 27 |
168 |
#define S390_A10_REGNUM 28 |
169 |
#define S390_A11_REGNUM 29 |
170 |
#define S390_A12_REGNUM 30 |
171 |
#define S390_A13_REGNUM 31 |
172 |
#define S390_A14_REGNUM 32 |
173 |
#define S390_A15_REGNUM 33 |
174 |
/* Floating Point Control Word. */
|
175 |
#define S390_FPC_REGNUM 34 |
176 |
/* Floating Point Registers. */
|
177 |
#define S390_F0_REGNUM 35 |
178 |
#define S390_F1_REGNUM 36 |
179 |
#define S390_F2_REGNUM 37 |
180 |
#define S390_F3_REGNUM 38 |
181 |
#define S390_F4_REGNUM 39 |
182 |
#define S390_F5_REGNUM 40 |
183 |
#define S390_F6_REGNUM 41 |
184 |
#define S390_F7_REGNUM 42 |
185 |
#define S390_F8_REGNUM 43 |
186 |
#define S390_F9_REGNUM 44 |
187 |
#define S390_F10_REGNUM 45 |
188 |
#define S390_F11_REGNUM 46 |
189 |
#define S390_F12_REGNUM 47 |
190 |
#define S390_F13_REGNUM 48 |
191 |
#define S390_F14_REGNUM 49 |
192 |
#define S390_F15_REGNUM 50 |
193 |
/* Total. */
|
194 |
#define S390_NUM_REGS 51 |
195 |
|
196 |
/* Pseudo registers -- PC and condition code. */
|
197 |
#define S390_PC_REGNUM S390_NUM_REGS
|
198 |
#define S390_CC_REGNUM (S390_NUM_REGS+1) |
199 |
#define S390_NUM_PSEUDO_REGS 2 |
200 |
#define S390_NUM_TOTAL_REGS (S390_NUM_REGS+2) |
201 |
|
202 |
|
203 |
|
204 |
/* Program Status Word. */
|
205 |
#define S390_PSWM_REGNUM 0 |
206 |
#define S390_PSWA_REGNUM 1 |
207 |
/* General Purpose Registers. */
|
208 |
#define S390_R0_REGNUM 2 |
209 |
#define S390_R1_REGNUM 3 |
210 |
#define S390_R2_REGNUM 4 |
211 |
#define S390_R3_REGNUM 5 |
212 |
#define S390_R4_REGNUM 6 |
213 |
#define S390_R5_REGNUM 7 |
214 |
#define S390_R6_REGNUM 8 |
215 |
#define S390_R7_REGNUM 9 |
216 |
#define S390_R8_REGNUM 10 |
217 |
#define S390_R9_REGNUM 11 |
218 |
#define S390_R10_REGNUM 12 |
219 |
#define S390_R11_REGNUM 13 |
220 |
#define S390_R12_REGNUM 14 |
221 |
#define S390_R13_REGNUM 15 |
222 |
#define S390_R14_REGNUM 16 |
223 |
#define S390_R15_REGNUM 17 |
224 |
/* Access Registers. */
|
225 |
#define S390_A0_REGNUM 18 |
226 |
#define S390_A1_REGNUM 19 |
227 |
#define S390_A2_REGNUM 20 |
228 |
#define S390_A3_REGNUM 21 |
229 |
#define S390_A4_REGNUM 22 |
230 |
#define S390_A5_REGNUM 23 |
231 |
#define S390_A6_REGNUM 24 |
232 |
#define S390_A7_REGNUM 25 |
233 |
#define S390_A8_REGNUM 26 |
234 |
#define S390_A9_REGNUM 27 |
235 |
#define S390_A10_REGNUM 28 |
236 |
#define S390_A11_REGNUM 29 |
237 |
#define S390_A12_REGNUM 30 |
238 |
#define S390_A13_REGNUM 31 |
239 |
#define S390_A14_REGNUM 32 |
240 |
#define S390_A15_REGNUM 33 |
241 |
/* Floating Point Control Word. */
|
242 |
#define S390_FPC_REGNUM 34 |
243 |
/* Floating Point Registers. */
|
244 |
#define S390_F0_REGNUM 35 |
245 |
#define S390_F1_REGNUM 36 |
246 |
#define S390_F2_REGNUM 37 |
247 |
#define S390_F3_REGNUM 38 |
248 |
#define S390_F4_REGNUM 39 |
249 |
#define S390_F5_REGNUM 40 |
250 |
#define S390_F6_REGNUM 41 |
251 |
#define S390_F7_REGNUM 42 |
252 |
#define S390_F8_REGNUM 43 |
253 |
#define S390_F9_REGNUM 44 |
254 |
#define S390_F10_REGNUM 45 |
255 |
#define S390_F11_REGNUM 46 |
256 |
#define S390_F12_REGNUM 47 |
257 |
#define S390_F13_REGNUM 48 |
258 |
#define S390_F14_REGNUM 49 |
259 |
#define S390_F15_REGNUM 50 |
260 |
/* Total. */
|
261 |
#define S390_NUM_REGS 51 |
262 |
|
263 |
/* Pseudo registers -- PC and condition code. */
|
264 |
#define S390_PC_REGNUM S390_NUM_REGS
|
265 |
#define S390_CC_REGNUM (S390_NUM_REGS+1) |
266 |
#define S390_NUM_PSEUDO_REGS 2 |
267 |
#define S390_NUM_TOTAL_REGS (S390_NUM_REGS+2) |
268 |
|
269 |
|
270 |
#endif
|