]> git.proxmox.com Git - mirror_qemu.git/blame - target-xtensa/gdbstub.c
gdbstub: Replace GET_REG*() macros with gdb_get_reg*() functions
[mirror_qemu.git] / target-xtensa / gdbstub.c
CommitLineData
25d8ac0e
AF
1/*
2 * Xtensa 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 */
20
21static int cpu_gdb_read_register(CPUXtensaState *env, uint8_t *mem_buf, int n)
22{
23 const XtensaGdbReg *reg = env->config->gdb_regmap.reg + n;
24
25 if (n < 0 || n >= env->config->gdb_regmap.num_regs) {
26 return 0;
27 }
28
29 switch (reg->type) {
30 case 9: /*pc*/
986a2998 31 return gdb_get_reg32(mem_buf, env->pc);
25d8ac0e
AF
32
33 case 1: /*ar*/
34 xtensa_sync_phys_from_window(env);
986a2998
AF
35 return gdb_get_reg32(mem_buf, env->phys_regs[(reg->targno & 0xff)
36 % env->config->nareg]);
25d8ac0e
AF
37
38 case 2: /*SR*/
986a2998 39 return gdb_get_reg32(mem_buf, env->sregs[reg->targno & 0xff]);
25d8ac0e
AF
40
41 case 3: /*UR*/
986a2998 42 return gdb_get_reg32(mem_buf, env->uregs[reg->targno & 0xff]);
25d8ac0e
AF
43
44 case 4: /*f*/
986a2998
AF
45 return gdb_get_reg32(mem_buf, float32_val(env->fregs[reg->targno
46 & 0x0f]));
25d8ac0e
AF
47
48 case 8: /*a*/
986a2998 49 return gdb_get_reg32(mem_buf, env->regs[reg->targno & 0x0f]);
25d8ac0e
AF
50
51 default:
52 qemu_log("%s from reg %d of unsupported type %d\n",
53 __func__, n, reg->type);
54 return 0;
55 }
56}
57
58static int cpu_gdb_write_register(CPUXtensaState *env, uint8_t *mem_buf, int n)
59{
60 uint32_t tmp;
61 const XtensaGdbReg *reg = env->config->gdb_regmap.reg + n;
62
63 if (n < 0 || n >= env->config->gdb_regmap.num_regs) {
64 return 0;
65 }
66
67 tmp = ldl_p(mem_buf);
68
69 switch (reg->type) {
70 case 9: /*pc*/
71 env->pc = tmp;
72 break;
73
74 case 1: /*ar*/
75 env->phys_regs[(reg->targno & 0xff) % env->config->nareg] = tmp;
76 xtensa_sync_window_from_phys(env);
77 break;
78
79 case 2: /*SR*/
80 env->sregs[reg->targno & 0xff] = tmp;
81 break;
82
83 case 3: /*UR*/
84 env->uregs[reg->targno & 0xff] = tmp;
85 break;
86
87 case 4: /*f*/
88 env->fregs[reg->targno & 0x0f] = make_float32(tmp);
89 break;
90
91 case 8: /*a*/
92 env->regs[reg->targno & 0x0f] = tmp;
93 break;
94
95 default:
96 qemu_log("%s to reg %d of unsupported type %d\n",
97 __func__, n, reg->type);
98 return 0;
99 }
100
101 return 4;
102}