xref: /qemu/target/hexagon/gdbstub.c (revision d7a84021)
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 "qemu-common.h"
20 #include "exec/gdbstub.h"
21 #include "cpu.h"
22 #include "internal.h"
23 
24 int hexagon_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
25 {
26     HexagonCPU *cpu = HEXAGON_CPU(cs);
27     CPUHexagonState *env = &cpu->env;
28 
29     if (n < TOTAL_PER_THREAD_REGS) {
30         return gdb_get_regl(mem_buf, env->gpr[n]);
31     }
32 
33     g_assert_not_reached();
34 }
35 
36 int hexagon_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
37 {
38     HexagonCPU *cpu = HEXAGON_CPU(cs);
39     CPUHexagonState *env = &cpu->env;
40 
41     if (n < TOTAL_PER_THREAD_REGS) {
42         env->gpr[n] = ldtul_p(mem_buf);
43         return sizeof(target_ulong);
44     }
45 
46     g_assert_not_reached();
47 }
48