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"
20 #include "exec/gdbstub.h"
22 int rx_cpu_gdb_read_register(CPUState
*cs
, GByteArray
*mem_buf
, int n
)
24 RXCPU
*cpu
= RX_CPU(cs
);
25 CPURXState
*env
= &cpu
->env
;
29 return gdb_get_regl(mem_buf
, env
->regs
[n
]);
31 return gdb_get_regl(mem_buf
, (env
->psw_u
) ? env
->regs
[0] : env
->usp
);
33 return gdb_get_regl(mem_buf
, (!env
->psw_u
) ? env
->regs
[0] : env
->isp
);
35 return gdb_get_regl(mem_buf
, rx_cpu_pack_psw(env
));
37 return gdb_get_regl(mem_buf
, env
->pc
);
39 return gdb_get_regl(mem_buf
, env
->intb
);
41 return gdb_get_regl(mem_buf
, env
->bpsw
);
43 return gdb_get_regl(mem_buf
, env
->bpc
);
45 return gdb_get_regl(mem_buf
, env
->fintv
);
47 return gdb_get_regl(mem_buf
, env
->fpsw
);
54 int rx_cpu_gdb_write_register(CPUState
*cs
, uint8_t *mem_buf
, int n
)
56 RXCPU
*cpu
= RX_CPU(cs
);
57 CPURXState
*env
= &cpu
->env
;
61 env
->regs
[n
] = ldl_p(mem_buf
);
64 env
->usp
= env
->regs
[0];
66 env
->isp
= env
->regs
[0];
71 env
->usp
= ldl_p(mem_buf
);
73 env
->regs
[0] = ldl_p(mem_buf
);
77 env
->isp
= ldl_p(mem_buf
);
79 env
->regs
[0] = ldl_p(mem_buf
);
84 rx_cpu_unpack_psw(env
, psw
, 1);
87 env
->pc
= ldl_p(mem_buf
);
90 env
->intb
= ldl_p(mem_buf
);
93 env
->bpsw
= ldl_p(mem_buf
);
96 env
->bpc
= ldl_p(mem_buf
);
99 env
->fintv
= ldl_p(mem_buf
);
102 env
->fpsw
= ldl_p(mem_buf
);