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"
22 #include "exec/gdbstub.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 SPARCCPU
*cpu
= SPARC_CPU(cs
);
33 CPUSPARCState
*env
= &cpu
->env
;
37 return gdb_get_rega(mem_buf
, env
->gregs
[n
]);
41 return gdb_get_rega(mem_buf
, env
->regwptr
[n
- 8]);
43 #if defined(TARGET_ABI32) || !defined(TARGET_SPARC64)
47 return gdb_get_reg32(mem_buf
, env
->fpr
[(n
- 32) / 2].l
.lower
);
49 return gdb_get_reg32(mem_buf
, env
->fpr
[(n
- 32) / 2].l
.upper
);
52 /* Y, PSR, WIM, TBR, PC, NPC, FPSR, CPSR */
55 return gdb_get_rega(mem_buf
, env
->y
);
57 return gdb_get_rega(mem_buf
, cpu_get_psr(env
));
59 return gdb_get_rega(mem_buf
, env
->wim
);
61 return gdb_get_rega(mem_buf
, env
->tbr
);
63 return gdb_get_rega(mem_buf
, env
->pc
);
65 return gdb_get_rega(mem_buf
, env
->npc
);
67 return gdb_get_rega(mem_buf
, env
->fsr
);
69 return gdb_get_rega(mem_buf
, 0); /* csr */
71 return gdb_get_rega(mem_buf
, 0);
77 return gdb_get_reg32(mem_buf
, env
->fpr
[(n
- 32) / 2].l
.lower
);
79 return gdb_get_reg32(mem_buf
, env
->fpr
[(n
- 32) / 2].l
.upper
);
83 /* f32-f62 (double width, even numbers only) */
84 return gdb_get_reg64(mem_buf
, env
->fpr
[(n
- 32) / 2].ll
);
88 return gdb_get_regl(mem_buf
, env
->pc
);
90 return gdb_get_regl(mem_buf
, env
->npc
);
92 return gdb_get_regl(mem_buf
, (cpu_get_ccr(env
) << 32) |
93 ((env
->asi
& 0xff) << 24) |
94 ((env
->pstate
& 0xfff) << 8) |
97 return gdb_get_regl(mem_buf
, env
->fsr
);
99 return gdb_get_regl(mem_buf
, env
->fprs
);
101 return gdb_get_regl(mem_buf
, env
->y
);
107 int sparc_cpu_gdb_write_register(CPUState
*cs
, uint8_t *mem_buf
, int n
)
109 SPARCCPU
*cpu
= SPARC_CPU(cs
);
110 CPUSPARCState
*env
= &cpu
->env
;
111 #if defined(TARGET_ABI32)
114 tmp
= ldl_p(mem_buf
);
118 tmp
= ldtul_p(mem_buf
);
125 /* register window */
126 env
->regwptr
[n
- 8] = tmp
;
128 #if defined(TARGET_ABI32) || !defined(TARGET_SPARC64)
133 env
->fpr
[(n
- 32) / 2].l
.lower
= tmp
;
135 env
->fpr
[(n
- 32) / 2].l
.upper
= tmp
;
138 /* Y, PSR, WIM, TBR, PC, NPC, FPSR, CPSR */
144 cpu_put_psr(env
, tmp
);
169 tmp
= ldl_p(mem_buf
);
171 env
->fpr
[(n
- 32) / 2].l
.lower
= tmp
;
173 env
->fpr
[(n
- 32) / 2].l
.upper
= tmp
;
177 /* f32-f62 (double width, even numbers only) */
178 env
->fpr
[(n
- 32) / 2].ll
= tmp
;
188 cpu_put_ccr(env
, tmp
>> 32);
189 env
->asi
= (tmp
>> 24) & 0xff;
190 env
->pstate
= (tmp
>> 8) & 0xfff;
191 cpu_put_cwp64(env
, tmp
& 0xff);