]>
Commit | Line | Data |
---|---|---|
cfae5c90 AF |
1 | /* |
2 | * s390x gdb server stub | |
3 | * | |
4 | * Copyright (c) 2003-2005 Fabrice Bellard | |
5 | * Copyright (c) 2013 SUSE LINUX Products GmbH | |
6 | * | |
7 | * This library is free software; you can redistribute it and/or | |
8 | * modify it under the terms of the GNU Lesser General Public | |
9 | * License as published by the Free Software Foundation; either | |
10 | * version 2 of the License, or (at your option) any later version. | |
11 | * | |
12 | * This library is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * Lesser General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU Lesser General Public | |
18 | * License along with this library; if not, see <http://www.gnu.org/licenses/>. | |
19 | */ | |
5b50e790 AF |
20 | #include "config.h" |
21 | #include "qemu-common.h" | |
22 | #include "exec/gdbstub.h" | |
23 | #include "qemu/bitops.h" | |
cfae5c90 | 24 | |
5b50e790 | 25 | int s390_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) |
cfae5c90 | 26 | { |
5b50e790 AF |
27 | S390CPU *cpu = S390_CPU(cs); |
28 | CPUS390XState *env = &cpu->env; | |
cfae5c90 AF |
29 | uint64_t val; |
30 | int cc_op; | |
31 | ||
32 | switch (n) { | |
33 | case S390_PSWM_REGNUM: | |
97fa52f0 DH |
34 | if (tcg_enabled()) { |
35 | cc_op = calc_cc(env, env->cc_op, env->cc_src, env->cc_dst, | |
36 | env->cc_vr); | |
37 | val = deposit64(env->psw.mask, 44, 2, cc_op); | |
38 | return gdb_get_regl(mem_buf, val); | |
39 | } | |
40 | return gdb_get_regl(mem_buf, env->psw.mask); | |
cfae5c90 | 41 | case S390_PSWA_REGNUM: |
986a2998 | 42 | return gdb_get_regl(mem_buf, env->psw.addr); |
cfae5c90 | 43 | case S390_R0_REGNUM ... S390_R15_REGNUM: |
986a2998 | 44 | return gdb_get_regl(mem_buf, env->regs[n-S390_R0_REGNUM]); |
cfae5c90 | 45 | case S390_A0_REGNUM ... S390_A15_REGNUM: |
986a2998 | 46 | return gdb_get_reg32(mem_buf, env->aregs[n-S390_A0_REGNUM]); |
cfae5c90 | 47 | case S390_FPC_REGNUM: |
986a2998 | 48 | return gdb_get_reg32(mem_buf, env->fpc); |
cfae5c90 | 49 | case S390_F0_REGNUM ... S390_F15_REGNUM: |
986a2998 | 50 | return gdb_get_reg64(mem_buf, env->fregs[n-S390_F0_REGNUM].ll); |
cfae5c90 AF |
51 | } |
52 | ||
53 | return 0; | |
54 | } | |
55 | ||
5b50e790 | 56 | int s390_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) |
cfae5c90 | 57 | { |
5b50e790 AF |
58 | S390CPU *cpu = S390_CPU(cs); |
59 | CPUS390XState *env = &cpu->env; | |
cfae5c90 AF |
60 | target_ulong tmpl; |
61 | uint32_t tmp32; | |
62 | int r = 8; | |
63 | tmpl = ldtul_p(mem_buf); | |
64 | tmp32 = ldl_p(mem_buf); | |
65 | ||
66 | switch (n) { | |
67 | case S390_PSWM_REGNUM: | |
68 | env->psw.mask = tmpl; | |
97fa52f0 DH |
69 | if (tcg_enabled()) { |
70 | env->cc_op = extract64(tmpl, 44, 2); | |
71 | } | |
cfae5c90 AF |
72 | break; |
73 | case S390_PSWA_REGNUM: | |
74 | env->psw.addr = tmpl; | |
75 | break; | |
76 | case S390_R0_REGNUM ... S390_R15_REGNUM: | |
77 | env->regs[n-S390_R0_REGNUM] = tmpl; | |
78 | break; | |
79 | case S390_A0_REGNUM ... S390_A15_REGNUM: | |
80 | env->aregs[n-S390_A0_REGNUM] = tmp32; | |
81 | r = 4; | |
82 | break; | |
83 | case S390_FPC_REGNUM: | |
84 | env->fpc = tmp32; | |
85 | r = 4; | |
86 | break; | |
87 | case S390_F0_REGNUM ... S390_F15_REGNUM: | |
88 | env->fregs[n-S390_F0_REGNUM].ll = tmpl; | |
89 | break; | |
90 | default: | |
91 | return 0; | |
92 | } | |
93 | return r; | |
94 | } |