2 * SuperH 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"
24 /* Hint: Use "set architecture sh4" in GDB to see fpu registers */
25 /* FIXME: We should use XML for this. */
27 int superh_cpu_gdb_read_register(CPUState
*cs
, GByteArray
*mem_buf
, int n
)
29 CPUSH4State
*env
= cpu_env(cs
);
33 if ((env
->sr
& (1u << SR_MD
)) && (env
->sr
& (1u << SR_RB
))) {
34 return gdb_get_regl(mem_buf
, env
->gregs
[n
+ 16]);
36 return gdb_get_regl(mem_buf
, env
->gregs
[n
]);
39 return gdb_get_regl(mem_buf
, env
->gregs
[n
]);
41 return gdb_get_regl(mem_buf
, env
->pc
);
43 return gdb_get_regl(mem_buf
, env
->pr
);
45 return gdb_get_regl(mem_buf
, env
->gbr
);
47 return gdb_get_regl(mem_buf
, env
->vbr
);
49 return gdb_get_regl(mem_buf
, env
->mach
);
51 return gdb_get_regl(mem_buf
, env
->macl
);
53 return gdb_get_regl(mem_buf
, cpu_read_sr(env
));
55 return gdb_get_regl(mem_buf
, env
->fpul
);
57 return gdb_get_regl(mem_buf
, env
->fpscr
);
59 if (env
->fpscr
& FPSCR_FR
) {
60 return gdb_get_reg32(mem_buf
, env
->fregs
[n
- 9]);
62 return gdb_get_reg32(mem_buf
, env
->fregs
[n
- 25]);
64 return gdb_get_regl(mem_buf
, env
->ssr
);
66 return gdb_get_regl(mem_buf
, env
->spc
);
68 return gdb_get_regl(mem_buf
, env
->gregs
[n
- 43]);
70 return gdb_get_regl(mem_buf
, env
->gregs
[n
- (51 - 16)]);
76 int superh_cpu_gdb_write_register(CPUState
*cs
, uint8_t *mem_buf
, int n
)
78 CPUSH4State
*env
= cpu_env(cs
);
82 if ((env
->sr
& (1u << SR_MD
)) && (env
->sr
& (1u << SR_RB
))) {
83 env
->gregs
[n
+ 16] = ldl_p(mem_buf
);
85 env
->gregs
[n
] = ldl_p(mem_buf
);
89 env
->gregs
[n
] = ldl_p(mem_buf
);
92 env
->pc
= ldl_p(mem_buf
);
95 env
->pr
= ldl_p(mem_buf
);
98 env
->gbr
= ldl_p(mem_buf
);
101 env
->vbr
= ldl_p(mem_buf
);
104 env
->mach
= ldl_p(mem_buf
);
107 env
->macl
= ldl_p(mem_buf
);
110 cpu_write_sr(env
, ldl_p(mem_buf
));
113 env
->fpul
= ldl_p(mem_buf
);
116 env
->fpscr
= ldl_p(mem_buf
);
119 if (env
->fpscr
& FPSCR_FR
) {
120 env
->fregs
[n
- 9] = ldl_p(mem_buf
);
122 env
->fregs
[n
- 25] = ldl_p(mem_buf
);
126 env
->ssr
= ldl_p(mem_buf
);
129 env
->spc
= ldl_p(mem_buf
);
132 env
->gregs
[n
- 43] = ldl_p(mem_buf
);
135 env
->gregs
[n
- (51 - 16)] = ldl_p(mem_buf
);