trace: Add trace-file command to open/close/flush trace file
[qemu/agraf.git] / target-s390x / cpu.h
blob8d73fad360e3aef36c5c98206f599dbee31d7d85
1 /*
2 * S/390 virtual CPU header
4 * Copyright (c) 2009 Ulrich Hecht
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.
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.
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/>.
19 #ifndef CPU_S390X_H
20 #define CPU_S390X_H
22 #define TARGET_LONG_BITS 64
24 #define ELF_MACHINE EM_S390
26 #define CPUState struct CPUS390XState
28 #include "cpu-defs.h"
30 #include "softfloat.h"
32 #define NB_MMU_MODES 2
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
44 float64 d;
45 uint64_t i;
46 } FPReg;
48 typedef struct CPUS390XState {
49 uint64_t regs[16]; /* GP registers */
51 uint32_t aregs[16]; /* access registers */
53 uint32_t fpc; /* floating-point control register */
54 FPReg fregs[16]; /* FP registers */
55 float_status fpu_status; /* passed to softfloat lib */
57 struct {
58 uint64_t mask;
59 uint64_t addr;
60 } psw;
62 int cc; /* condition code (0-3) */
64 uint64_t __excp_addr;
66 CPU_COMMON
67 } CPUS390XState;
69 #if defined(CONFIG_USER_ONLY)
70 static inline void cpu_clone_regs(CPUState *env, target_ulong newsp)
72 if (newsp)
73 env->regs[15] = newsp;
74 env->regs[0] = 0;
76 #endif
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)
83 /* XXX: Currently we don't implement virtual memory */
84 return 0;
87 CPUS390XState *cpu_s390x_init(const char *cpu_model);
88 int cpu_s390x_exec(CPUS390XState *s);
89 void cpu_s390x_close(CPUS390XState *s);
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
100 #define TARGET_PAGE_BITS 12
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
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
114 #define cpu_init cpu_s390x_init
115 #define cpu_exec cpu_s390x_exec
116 #define cpu_gen_code cpu_s390x_gen_code
118 #include "cpu-all.h"
120 #define EXCP_OPEX 1 /* operation exception (sigill) */
121 #define EXCP_SVC 2 /* supervisor call (syscall) */
122 #define EXCP_ADDR 5 /* addressing exception */
123 #define EXCP_EXECUTE_SVC 0xff00000 /* supervisor call via execute insn */
125 static inline void cpu_get_tb_cpu_state(CPUState* env, target_ulong *pc,
126 target_ulong *cs_base, int *flags)
128 *pc = env->psw.addr;
129 /* XXX this is correct for user-mode emulation, but needs
130 * the asce register information as well when softmmu
131 * is implemented in the future */
132 *cs_base = 0;
133 *flags = env->psw.mask;
136 /* Program Status Word. */
137 #define S390_PSWM_REGNUM 0
138 #define S390_PSWA_REGNUM 1
139 /* General Purpose Registers. */
140 #define S390_R0_REGNUM 2
141 #define S390_R1_REGNUM 3
142 #define S390_R2_REGNUM 4
143 #define S390_R3_REGNUM 5
144 #define S390_R4_REGNUM 6
145 #define S390_R5_REGNUM 7
146 #define S390_R6_REGNUM 8
147 #define S390_R7_REGNUM 9
148 #define S390_R8_REGNUM 10
149 #define S390_R9_REGNUM 11
150 #define S390_R10_REGNUM 12
151 #define S390_R11_REGNUM 13
152 #define S390_R12_REGNUM 14
153 #define S390_R13_REGNUM 15
154 #define S390_R14_REGNUM 16
155 #define S390_R15_REGNUM 17
156 /* Access Registers. */
157 #define S390_A0_REGNUM 18
158 #define S390_A1_REGNUM 19
159 #define S390_A2_REGNUM 20
160 #define S390_A3_REGNUM 21
161 #define S390_A4_REGNUM 22
162 #define S390_A5_REGNUM 23
163 #define S390_A6_REGNUM 24
164 #define S390_A7_REGNUM 25
165 #define S390_A8_REGNUM 26
166 #define S390_A9_REGNUM 27
167 #define S390_A10_REGNUM 28
168 #define S390_A11_REGNUM 29
169 #define S390_A12_REGNUM 30
170 #define S390_A13_REGNUM 31
171 #define S390_A14_REGNUM 32
172 #define S390_A15_REGNUM 33
173 /* Floating Point Control Word. */
174 #define S390_FPC_REGNUM 34
175 /* Floating Point Registers. */
176 #define S390_F0_REGNUM 35
177 #define S390_F1_REGNUM 36
178 #define S390_F2_REGNUM 37
179 #define S390_F3_REGNUM 38
180 #define S390_F4_REGNUM 39
181 #define S390_F5_REGNUM 40
182 #define S390_F6_REGNUM 41
183 #define S390_F7_REGNUM 42
184 #define S390_F8_REGNUM 43
185 #define S390_F9_REGNUM 44
186 #define S390_F10_REGNUM 45
187 #define S390_F11_REGNUM 46
188 #define S390_F12_REGNUM 47
189 #define S390_F13_REGNUM 48
190 #define S390_F14_REGNUM 49
191 #define S390_F15_REGNUM 50
192 /* Total. */
193 #define S390_NUM_REGS 51
195 /* Pseudo registers -- PC and condition code. */
196 #define S390_PC_REGNUM S390_NUM_REGS
197 #define S390_CC_REGNUM (S390_NUM_REGS+1)
198 #define S390_NUM_PSEUDO_REGS 2
199 #define S390_NUM_TOTAL_REGS (S390_NUM_REGS+2)
203 /* Program Status Word. */
204 #define S390_PSWM_REGNUM 0
205 #define S390_PSWA_REGNUM 1
206 /* General Purpose Registers. */
207 #define S390_R0_REGNUM 2
208 #define S390_R1_REGNUM 3
209 #define S390_R2_REGNUM 4
210 #define S390_R3_REGNUM 5
211 #define S390_R4_REGNUM 6
212 #define S390_R5_REGNUM 7
213 #define S390_R6_REGNUM 8
214 #define S390_R7_REGNUM 9
215 #define S390_R8_REGNUM 10
216 #define S390_R9_REGNUM 11
217 #define S390_R10_REGNUM 12
218 #define S390_R11_REGNUM 13
219 #define S390_R12_REGNUM 14
220 #define S390_R13_REGNUM 15
221 #define S390_R14_REGNUM 16
222 #define S390_R15_REGNUM 17
223 /* Access Registers. */
224 #define S390_A0_REGNUM 18
225 #define S390_A1_REGNUM 19
226 #define S390_A2_REGNUM 20
227 #define S390_A3_REGNUM 21
228 #define S390_A4_REGNUM 22
229 #define S390_A5_REGNUM 23
230 #define S390_A6_REGNUM 24
231 #define S390_A7_REGNUM 25
232 #define S390_A8_REGNUM 26
233 #define S390_A9_REGNUM 27
234 #define S390_A10_REGNUM 28
235 #define S390_A11_REGNUM 29
236 #define S390_A12_REGNUM 30
237 #define S390_A13_REGNUM 31
238 #define S390_A14_REGNUM 32
239 #define S390_A15_REGNUM 33
240 /* Floating Point Control Word. */
241 #define S390_FPC_REGNUM 34
242 /* Floating Point Registers. */
243 #define S390_F0_REGNUM 35
244 #define S390_F1_REGNUM 36
245 #define S390_F2_REGNUM 37
246 #define S390_F3_REGNUM 38
247 #define S390_F4_REGNUM 39
248 #define S390_F5_REGNUM 40
249 #define S390_F6_REGNUM 41
250 #define S390_F7_REGNUM 42
251 #define S390_F8_REGNUM 43
252 #define S390_F9_REGNUM 44
253 #define S390_F10_REGNUM 45
254 #define S390_F11_REGNUM 46
255 #define S390_F12_REGNUM 47
256 #define S390_F13_REGNUM 48
257 #define S390_F14_REGNUM 49
258 #define S390_F15_REGNUM 50
259 /* Total. */
260 #define S390_NUM_REGS 51
262 /* Pseudo registers -- PC and condition code. */
263 #define S390_PC_REGNUM S390_NUM_REGS
264 #define S390_CC_REGNUM (S390_NUM_REGS+1)
265 #define S390_NUM_PSEUDO_REGS 2
266 #define S390_NUM_TOTAL_REGS (S390_NUM_REGS+2)
269 #endif