2 * Xtensa 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/>.
21 #include "qemu-common.h"
22 #include "exec/gdbstub.h"
24 int xtensa_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n)
26 XtensaCPU *cpu = XTENSA_CPU(cs);
27 CPUXtensaState *env = &cpu->env;
28 const XtensaGdbReg *reg = env->config->gdb_regmap.reg + n;
31 if (n < 0 || n >= env->config->gdb_regmap.num_regs) {
37 return gdb_get_reg32(mem_buf, env->pc);
40 xtensa_sync_phys_from_window(env);
41 return gdb_get_reg32(mem_buf, env->phys_regs[(reg->targno & 0xff)
42 % env->config->nareg]);
45 return gdb_get_reg32(mem_buf, env->sregs[reg->targno & 0xff]);
48 return gdb_get_reg32(mem_buf, env->uregs[reg->targno & 0xff]);
51 i = reg->targno & 0x0f;
54 return gdb_get_reg32(mem_buf,
55 float32_val(env->fregs[i].f32[FP_F32_LOW]));
57 return gdb_get_reg64(mem_buf, float64_val(env->fregs[i].f64));
63 return gdb_get_reg32(mem_buf, env->regs[reg->targno & 0x0f]);
66 qemu_log("%s from reg %d of unsupported type %d\n",
67 __func__, n, reg->type);
72 int xtensa_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
74 XtensaCPU *cpu = XTENSA_CPU(cs);
75 CPUXtensaState *env = &cpu->env;
77 const XtensaGdbReg *reg = env->config->gdb_regmap.reg + n;
79 if (n < 0 || n >= env->config->gdb_regmap.num_regs) {
91 env->phys_regs[(reg->targno & 0xff) % env->config->nareg] = tmp;
92 xtensa_sync_window_from_phys(env);
96 env->sregs[reg->targno & 0xff] = tmp;
100 env->uregs[reg->targno & 0xff] = tmp;
106 env->fregs[reg->targno & 0x0f].f32[FP_F32_LOW] = make_float32(tmp);
109 env->fregs[reg->targno & 0x0f].f64 = make_float64(tmp);
116 env->regs[reg->targno & 0x0f] = tmp;
120 qemu_log("%s to reg %d of unsupported type %d\n",
121 __func__, n, reg->type);