2 * TriCore gdb server stub
4 * Copyright (c) 2019 Bastian Koppelmann, Paderborn University
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
20 #include "qemu/osdep.h"
21 #include "qemu-common.h"
22 #include "exec/gdbstub.h"
27 #define PCXI_REGNUM 34
28 #define TRICORE_PSW_REGNUM 35
29 #define TRICORE_PC_REGNUM 36
34 #define SYSCON_REGNUM 41
35 #define PMUCON0_REGNUM 42
36 #define DMUCON_REGNUM 43
38 static uint32_t tricore_cpu_gdb_read_csfr(CPUTriCoreState
*env
, int n
)
47 case TRICORE_PSW_REGNUM
:
49 case TRICORE_PC_REGNUM
:
62 return 0; /* PMUCON0 */
64 return 0; /* DMUCON0 */
70 static void tricore_cpu_gdb_write_csfr(CPUTriCoreState
*env
, int n
,
83 case TRICORE_PSW_REGNUM
:
86 case TRICORE_PC_REGNUM
:
108 int tricore_cpu_gdb_read_register(CPUState
*cs
, GByteArray
*mem_buf
, int n
)
110 TriCoreCPU
*cpu
= TRICORE_CPU(cs
);
111 CPUTriCoreState
*env
= &cpu
->env
;
113 if (n
< 16) { /* data registers */
114 return gdb_get_reg32(mem_buf
, env
->gpr_d
[n
]);
115 } else if (n
< 32) { /* address registers */
116 return gdb_get_reg32(mem_buf
, env
->gpr_a
[n
- 16]);
118 return gdb_get_reg32(mem_buf
, tricore_cpu_gdb_read_csfr(env
, n
));
123 int tricore_cpu_gdb_write_register(CPUState
*cs
, uint8_t *mem_buf
, int n
)
125 TriCoreCPU
*cpu
= TRICORE_CPU(cs
);
126 CPUTriCoreState
*env
= &cpu
->env
;
129 tmp
= ldl_p(mem_buf
);
131 if (n
< 16) { /* data registers */
133 } else if (n
< 32) { /* address registers */
134 env
->gpr_d
[n
- 16] = tmp
;
136 tricore_cpu_gdb_write_csfr(env
, n
, tmp
);