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.1 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"
22 #include "gdbstub/helpers.h"
25 #define gdb_get_rega(buf, val) gdb_get_reg32(buf, val)
27 #define gdb_get_rega(buf, val) gdb_get_regl(buf, val)
30 int sparc_cpu_gdb_read_register(CPUState
*cs
, GByteArray
*mem_buf
, int n
)
32 CPUSPARCState
*env
= cpu_env(cs
);
36 return gdb_get_rega(mem_buf
, env
->gregs
[n
]);
40 return gdb_get_rega(mem_buf
, env
->regwptr
[n
- 8]);
42 #if defined(TARGET_ABI32) || !defined(TARGET_SPARC64)
46 return gdb_get_reg32(mem_buf
, env
->fpr
[(n
- 32) / 2].l
.lower
);
48 return gdb_get_reg32(mem_buf
, env
->fpr
[(n
- 32) / 2].l
.upper
);
51 /* Y, PSR, WIM, TBR, PC, NPC, FPSR, CPSR */
54 return gdb_get_rega(mem_buf
, env
->y
);
56 return gdb_get_rega(mem_buf
, cpu_get_psr(env
));
58 return gdb_get_rega(mem_buf
, env
->wim
);
60 return gdb_get_rega(mem_buf
, env
->tbr
);
62 return gdb_get_rega(mem_buf
, env
->pc
);
64 return gdb_get_rega(mem_buf
, env
->npc
);
66 return gdb_get_rega(mem_buf
, cpu_get_fsr(env
));
68 return gdb_get_rega(mem_buf
, 0); /* csr */
70 return gdb_get_rega(mem_buf
, 0);
76 return gdb_get_reg32(mem_buf
, env
->fpr
[(n
- 32) / 2].l
.lower
);
78 return gdb_get_reg32(mem_buf
, env
->fpr
[(n
- 32) / 2].l
.upper
);
82 /* f32-f62 (double width, even numbers only) */
83 return gdb_get_reg64(mem_buf
, env
->fpr
[(n
- 32) / 2].ll
);
87 return gdb_get_regl(mem_buf
, env
->pc
);
89 return gdb_get_regl(mem_buf
, env
->npc
);
91 return gdb_get_regl(mem_buf
, (cpu_get_ccr(env
) << 32) |
92 ((env
->asi
& 0xff) << 24) |
93 ((env
->pstate
& 0xfff) << 8) |
96 return gdb_get_regl(mem_buf
, cpu_get_fsr(env
));
98 return gdb_get_regl(mem_buf
, env
->fprs
);
100 return gdb_get_regl(mem_buf
, env
->y
);
106 int sparc_cpu_gdb_write_register(CPUState
*cs
, uint8_t *mem_buf
, int n
)
108 SPARCCPU
*cpu
= SPARC_CPU(cs
);
109 CPUSPARCState
*env
= &cpu
->env
;
110 #if defined(TARGET_ABI32)
113 tmp
= ldl_p(mem_buf
);
117 tmp
= ldtul_p(mem_buf
);
124 /* register window */
125 env
->regwptr
[n
- 8] = tmp
;
127 #if defined(TARGET_ABI32) || !defined(TARGET_SPARC64)
132 env
->fpr
[(n
- 32) / 2].l
.lower
= tmp
;
134 env
->fpr
[(n
- 32) / 2].l
.upper
= tmp
;
137 /* Y, PSR, WIM, TBR, PC, NPC, FPSR, CPSR */
143 cpu_put_psr(env
, tmp
);
158 cpu_put_fsr(env
, tmp
);
168 tmp
= ldl_p(mem_buf
);
170 env
->fpr
[(n
- 32) / 2].l
.lower
= tmp
;
172 env
->fpr
[(n
- 32) / 2].l
.upper
= tmp
;
176 /* f32-f62 (double width, even numbers only) */
177 env
->fpr
[(n
- 32) / 2].ll
= tmp
;
187 cpu_put_ccr(env
, tmp
>> 32);
188 env
->asi
= (tmp
>> 24) & 0xff;
189 env
->pstate
= (tmp
>> 8) & 0xfff;
190 cpu_put_cwp64(env
, tmp
& 0xff);
193 cpu_put_fsr(env
, tmp
);