]>
Commit | Line | Data |
---|---|---|
10ec5117 AG |
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, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA | |
19 | */ | |
20 | #ifndef CPU_S390X_H | |
21 | #define CPU_S390X_H | |
22 | ||
23 | #define TARGET_LONG_BITS 64 | |
24 | ||
25 | #define ELF_MACHINE EM_S390 | |
26 | ||
27 | #define CPUState struct CPUS390XState | |
28 | ||
29 | #include "cpu-defs.h" | |
30 | ||
31 | #include "softfloat.h" | |
32 | ||
33 | #define NB_MMU_MODES 2 // guess | |
34 | #define MMU_USER_IDX 0 // guess | |
35 | ||
36 | typedef union FPReg { | |
37 | struct { | |
38 | #ifdef WORDS_BIGENDIAN | |
39 | float32 e; | |
40 | int32_t __pad; | |
41 | #else | |
42 | int32_t __pad; | |
43 | float32 e; | |
44 | #endif | |
45 | }; | |
46 | float64 d; | |
47 | uint64_t i; | |
48 | } FPReg; | |
49 | ||
50 | typedef struct CPUS390XState { | |
51 | uint64_t regs[16]; /* GP registers */ | |
52 | ||
53 | uint32_t aregs[16]; /* access registers */ | |
54 | ||
55 | uint32_t fpc; /* floating-point control register */ | |
56 | FPReg fregs[16]; /* FP registers */ | |
57 | float_status fpu_status; /* passed to softfloat lib */ | |
58 | ||
59 | struct { | |
60 | uint64_t mask; | |
61 | uint64_t addr; | |
62 | } psw; | |
63 | ||
64 | int cc; /* condition code (0-3) */ | |
65 | ||
66 | uint64_t __excp_addr; | |
67 | ||
68 | CPU_COMMON | |
69 | } CPUS390XState; | |
70 | ||
71 | #if defined(CONFIG_USER_ONLY) | |
72 | static inline void cpu_clone_regs(CPUState *env, target_ulong newsp) | |
73 | { | |
74 | if (newsp) | |
75 | env->regs[15] = newsp; | |
76 | env->regs[0] = 0; | |
77 | } | |
78 | #endif | |
79 | ||
80 | CPUS390XState *cpu_s390x_init(const char *cpu_model); | |
81 | int cpu_s390x_exec(CPUS390XState *s); | |
82 | void cpu_s390x_close(CPUS390XState *s); | |
83 | ||
84 | /* you can call this signal handler from your SIGBUS and SIGSEGV | |
85 | signal handlers to inform the virtual CPU of exceptions. non zero | |
86 | is returned if the signal was handled by the virtual CPU. */ | |
87 | int cpu_s390x_signal_handler(int host_signum, void *pinfo, | |
88 | void *puc); | |
89 | int cpu_s390x_handle_mmu_fault (CPUS390XState *env, target_ulong address, int rw, | |
90 | int mmu_idx, int is_softmuu); | |
91 | #define cpu_handle_mmu_fault cpu_s390x_handle_mmu_fault | |
92 | ||
93 | #define TARGET_PAGE_BITS 12 | |
94 | ||
95 | #define cpu_init cpu_s390x_init | |
96 | #define cpu_exec cpu_s390x_exec | |
97 | #define cpu_gen_code cpu_s390x_gen_code | |
98 | ||
99 | #include "cpu-all.h" | |
100 | #include "exec-all.h" | |
101 | ||
102 | #define EXCP_OPEX 1 /* operation exception (sigill) */ | |
103 | #define EXCP_SVC 2 /* supervisor call (syscall) */ | |
104 | #define EXCP_ADDR 5 /* addressing exception */ | |
105 | #define EXCP_EXECUTE_SVC 0xff00000 /* supervisor call via execute insn */ | |
106 | ||
107 | static inline void cpu_pc_from_tb(CPUState *env, TranslationBlock* tb) | |
108 | { | |
109 | env->psw.addr = tb->pc; | |
110 | } | |
111 | ||
112 | static inline void cpu_get_tb_cpu_state(CPUState* env, target_ulong *pc, | |
113 | target_ulong *cs_base, int *flags) | |
114 | { | |
115 | *pc = env->psw.addr; | |
116 | /* XXX this is correct for user-mode emulation, but needs | |
117 | * the asce register information as well when softmmu | |
118 | * is implemented in the future */ | |
119 | *cs_base = 0; | |
120 | *flags = env->psw.mask; | |
121 | } | |
122 | #endif |