2 * SPARC gdb server stub
4 * Copyright (c) 2003-2005 Fabrice Bellard
5 * Copyright (c) 2013 SUSE LINUX Products GmbH
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.
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.
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/>.
20 #include "qemu/osdep.h"
21 #include "qemu-common.h"
23 #include "exec/gdbstub.h"
26 #define gdb_get_rega(buf, val) gdb_get_reg32(buf, val)
28 #define gdb_get_rega(buf, val) gdb_get_regl(buf, val)
31 int sparc_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n)
33 SPARCCPU *cpu = SPARC_CPU(cs);
34 CPUSPARCState *env = &cpu->env;
38 return gdb_get_rega(mem_buf, env->gregs[n]);
42 return gdb_get_rega(mem_buf, env->regwptr[n - 8]);
44 #if defined(TARGET_ABI32) || !defined(TARGET_SPARC64)
48 return gdb_get_reg32(mem_buf, env->fpr[(n - 32) / 2].l.lower);
50 return gdb_get_reg32(mem_buf, env->fpr[(n - 32) / 2].l.upper);
53 /* Y, PSR, WIM, TBR, PC, NPC, FPSR, CPSR */
56 return gdb_get_rega(mem_buf, env->y);
58 return gdb_get_rega(mem_buf, cpu_get_psr(env));
60 return gdb_get_rega(mem_buf, env->wim);
62 return gdb_get_rega(mem_buf, env->tbr);
64 return gdb_get_rega(mem_buf, env->pc);
66 return gdb_get_rega(mem_buf, env->npc);
68 return gdb_get_rega(mem_buf, env->fsr);
70 return gdb_get_rega(mem_buf, 0); /* csr */
72 return gdb_get_rega(mem_buf, 0);
78 return gdb_get_reg32(mem_buf, env->fpr[(n - 32) / 2].l.lower);
80 return gdb_get_reg32(mem_buf, env->fpr[(n - 32) / 2].l.upper);
84 /* f32-f62 (double width, even numbers only) */
85 return gdb_get_reg64(mem_buf, env->fpr[(n - 32) / 2].ll);
89 return gdb_get_regl(mem_buf, env->pc);
91 return gdb_get_regl(mem_buf, env->npc);
93 return gdb_get_regl(mem_buf, (cpu_get_ccr(env) << 32) |
94 ((env->asi & 0xff) << 24) |
95 ((env->pstate & 0xfff) << 8) |
98 return gdb_get_regl(mem_buf, env->fsr);
100 return gdb_get_regl(mem_buf, env->fprs);
102 return gdb_get_regl(mem_buf, env->y);
108 int sparc_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
110 SPARCCPU *cpu = SPARC_CPU(cs);
111 CPUSPARCState *env = &cpu->env;
112 #if defined(TARGET_ABI32)
115 tmp = ldl_p(mem_buf);
119 tmp = ldtul_p(mem_buf);
126 /* register window */
127 env->regwptr[n - 8] = tmp;
129 #if defined(TARGET_ABI32) || !defined(TARGET_SPARC64)
134 env->fpr[(n - 32) / 2].l.lower = tmp;
136 env->fpr[(n - 32) / 2].l.upper = tmp;
139 /* Y, PSR, WIM, TBR, PC, NPC, FPSR, CPSR */
145 cpu_put_psr(env, tmp);
170 tmp = ldl_p(mem_buf);
172 env->fpr[(n - 32) / 2].l.lower = tmp;
174 env->fpr[(n - 32) / 2].l.upper = tmp;
178 /* f32-f62 (double width, even numbers only) */
179 env->fpr[(n - 32) / 2].ll = tmp;
189 cpu_put_ccr(env, tmp >> 32);
190 env->asi = (tmp >> 24) & 0xff;
191 env->pstate = (tmp >> 8) & 0xfff;
192 cpu_put_cwp64(env, tmp & 0xff);