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