Statistics
| Branch: | Revision:

root / target-s390x / cpu.h @ 64b85a8f

History | View | Annotate | Download (7.1 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
int s390_virtio_hypercall(CPUState *env);
109
void kvm_s390_virtio_irq(CPUState *env, int config_change, uint64_t token);
110
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

    
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 */
124

    
125
static inline void cpu_get_tb_cpu_state(CPUState* env, target_ulong *pc,
126
                                        target_ulong *cs_base, int *flags)
127
{
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;
134
}
135

    
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
194

    
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)
200

    
201

    
202

    
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
261

    
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)
267

    
268

    
269
#endif