xref: /openbmc/qemu/target/hexagon/gdbstub.c (revision 954a6c4f)
1 /*
2  *  Copyright(c) 2019-2021 Qualcomm Innovation Center, Inc. All Rights Reserved.
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include "qemu/osdep.h"
19 #include "exec/gdbstub.h"
20 #include "cpu.h"
21 #include "internal.h"
22 
23 int hexagon_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
24 {
25     HexagonCPU *cpu = HEXAGON_CPU(cs);
26     CPUHexagonState *env = &cpu->env;
27 
28     if (n < TOTAL_PER_THREAD_REGS) {
29         return gdb_get_regl(mem_buf, env->gpr[n]);
30     }
31 
32     g_assert_not_reached();
33 }
34 
35 int hexagon_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
36 {
37     HexagonCPU *cpu = HEXAGON_CPU(cs);
38     CPUHexagonState *env = &cpu->env;
39 
40     if (n < TOTAL_PER_THREAD_REGS) {
41         env->gpr[n] = ldtul_p(mem_buf);
42         return sizeof(target_ulong);
43     }
44 
45     g_assert_not_reached();
46 }
47