4 * Copyright (c) 2019 Yoshinori Sato
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2 or later, as published by the Free Software Foundation.
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License along with
16 * this program. If not, see <http://www.gnu.org/licenses/>.
18 #include "qemu/osdep.h"
19 #include "qemu-common.h"
21 #include "exec/gdbstub.h"
23 int rx_cpu_gdb_read_register(CPUState
*cs
, GByteArray
*mem_buf
, int n
)
25 RXCPU
*cpu
= RX_CPU(cs
);
26 CPURXState
*env
= &cpu
->env
;
30 return gdb_get_regl(mem_buf
, env
->regs
[n
]);
32 return gdb_get_regl(mem_buf
, (env
->psw_u
) ? env
->regs
[0] : env
->usp
);
34 return gdb_get_regl(mem_buf
, (!env
->psw_u
) ? env
->regs
[0] : env
->isp
);
36 return gdb_get_regl(mem_buf
, rx_cpu_pack_psw(env
));
38 return gdb_get_regl(mem_buf
, env
->pc
);
40 return gdb_get_regl(mem_buf
, env
->intb
);
42 return gdb_get_regl(mem_buf
, env
->bpsw
);
44 return gdb_get_regl(mem_buf
, env
->bpc
);
46 return gdb_get_regl(mem_buf
, env
->fintv
);
48 return gdb_get_regl(mem_buf
, env
->fpsw
);
55 int rx_cpu_gdb_write_register(CPUState
*cs
, uint8_t *mem_buf
, int n
)
57 RXCPU
*cpu
= RX_CPU(cs
);
58 CPURXState
*env
= &cpu
->env
;
62 env
->regs
[n
] = ldl_p(mem_buf
);
65 env
->usp
= env
->regs
[0];
67 env
->isp
= env
->regs
[0];
72 env
->usp
= ldl_p(mem_buf
);
74 env
->regs
[0] = ldl_p(mem_buf
);
78 env
->isp
= ldl_p(mem_buf
);
80 env
->regs
[0] = ldl_p(mem_buf
);
85 rx_cpu_unpack_psw(env
, psw
, 1);
88 env
->pc
= ldl_p(mem_buf
);
91 env
->intb
= ldl_p(mem_buf
);
94 env
->bpsw
= ldl_p(mem_buf
);
97 env
->bpc
= ldl_p(mem_buf
);
100 env
->fintv
= ldl_p(mem_buf
);
103 env
->fpsw
= ldl_p(mem_buf
);