target: Add Renesas RX architecture
cover target: Add Renesas RX architecture
This is a merger of Yoshinori's v32 of the Renesas RX architecture emulation.
Richard temporarily handed it over for the 5.0 release.
This part adds the architectural part. The hardware part will follow.
Call this release, or merge, candidate 1.
repo: https://gitlab.com/philmd/qemu.git
branch: rx_target_merger
Richard Henderson (6):
target/rx: Disassemble rx_index_addr into a string target/rx: Replace operand with prt_ldmi in disassembler target/rx: Use prt_ldmi for XCHG_mr disassembly target/rx: Emit all disassembly in one prt() target/rx: Collect all bytes during disassembly target/rx: Dump bytes for each insn during disassembly
Yoshinori Sato (7):
hw/registerfields.h: Add 8bit and 16bit register macros
MAINTAINERS: Cover Renesas RX architecture target/rx: TCG translation
target/rx: TCG helpers
target/rx: CPU definitions
target/rx: RX disassembler
Add rx-softmmu
configure | 11 +- default-configs/rx-softmmu.mak | 2 + qapi/machine.json | 4 +- include/disas/dis-asm.h | 5 + include/exec/poison.h | 1 + include/hw/registerfields.h | 32 +- include/sysemu/arch_init.h | 1 + target/rx/cpu-param.h | 31 + target/rx/cpu-qom.h | 43 + target/rx/cpu.h | 180 +++ target/rx/helper.h | 31 + target/rx/insns.decode | 621 ++++++++ arch_init.c | 2 + target/rx/cpu.c | 226 +++ target/rx/disas.c | 1446 ++++++++++++++++++ target/rx/gdbstub.c | 112 ++ target/rx/helper.c | 149 ++ target/rx/op_helper.c | 470 ++++++ target/rx/translate.c | 2439 +++++++++++++++++++++++++++++++ tests/qtest/machine-none-test.c | 1 + MAINTAINERS | 5 + gdb-xml/rx-core.xml | 70 + target/rx/Makefile.objs | 11 + 23 files changed, 5890 insertions(+), 3 deletions(-) create mode 100644 default-configs/rx-softmmu.mak create mode 100644 target/rx/cpu-param.h create mode 100644 target/rx/cpu-qom.h create mode 100644 target/rx/cpu.h create mode 100644 target/rx/helper.h create mode 100644 target/rx/insns.decode create mode 100644 target/rx/cpu.c create mode 100644 target/rx/disas.c create mode 100644 target/rx/gdbstub.c create mode 100644 target/rx/helper.c create mode 100644 target/rx/op_helper.c create mode 100644 target/rx/translate.c create mode 100644 gdb-xml/rx-core.xml create mode 100644 target/rx/Makefile.objs
Signature · 1 line
2.21.1
PATCH 1/13 hw/registerfields.h: Add 8bit and 16bit register macros
From: Yoshinori Sato <[email protected]>
Some RX peripheral using 8bit and 16bit registers. Added 8bit and 16bit APIs.
Message-Id: <[email protected]>
--- include/hw/registerfields.h | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-)
include/hw/registerfields.h +31 -1
@@ -22,6 +22,14 @@ enum { A_ ## reg = (addr) }; \ enum { R_ ## reg = (addr) / 4 }; +#define REG8 (reg, addr) \ + enum { A_ ## reg = (addr) }; \ + enum { R_ ## reg = (addr) }; + +#define REG16 (reg, addr) \ + enum { A_ ## reg = (addr) }; \ + enum { R_ ## reg = (addr) / 2 }; +/* Define SHIFT, LENGTH and MASK constants for a field within a register */ /* This macro will define R_FOO_BAR_MASK, R_FOO_BAR_SHIFT and R_FOO_BAR_LENGTH
@@ -34,6 +42,12 @@ MAKE_64BIT_MASK(shift, length)};/* Extract a field from a register */ +#define FIELD_EX8 (storage, reg, field) \ + extract8((storage), R_ ## reg ## _ ## field ## _SHIFT, \ + R_ ## reg ## _ ## field ## _LENGTH) +#define FIELD_EX16 (storage, reg, field) \ + extract16((storage), R_ ## reg ## _ ## field ## _SHIFT, \ + R_ ## reg ## _ ## field ## _LENGTH)#define FIELD_EX32 (storage, reg, field) \ extract32((storage), R_ ## reg ## _ ## field ## _SHIFT, \ R_ ## reg ## _ ## field ## _LENGTH)
@@ -49,6 +63,22 @@* Assigning values larger then the target field will result in * compilation warnings. */ +#define FIELD_DP8 (storage, reg, field, val) ({ \ + struct { \ + unsigned int v:R_ ## reg ## _ ## field ## _LENGTH; \ + } v = { .v = val }; \ + uint8_t d; \ + d = deposit32((storage), R_ ## reg ## _ ## field ## _SHIFT, \ + R_ ## reg ## _ ## field ## _LENGTH, v.v); \ + d; }) +#define FIELD_DP16 (storage, reg, field, val) ({ \ + struct { \ + unsigned int v:R_ ## reg ## _ ## field ## _LENGTH; \ + } v = { .v = val }; \ + uint16_t d; \ + d = deposit32((storage), R_ ## reg ## _ ## field ## _SHIFT, \ + R_ ## reg ## _ ## field ## _LENGTH, v.v); \ + d; })#define FIELD_DP32 (storage, reg, field, val) ({ \ struct { \ unsigned int v:R_ ## reg ## _ ## field ## _LENGTH; \
@@ -57,7 +87,7 @@ d = deposit32((storage), R_ ## reg ## _ ## field ## _SHIFT, \ R_ ## reg ## _ ## field ## _LENGTH, v.v); \ d; }) -#define FIELD_DP64 (storage, reg, field, val) ({ \ +#define FIELD_DP64 (storage, reg, field, val) ({ \ struct { \ unsigned int v:R_ ## reg ## _ ## field ## _LENGTH; \ } v = { .v = val }; \
Signature · 1 line
2.21.1
PATCH 2/13 MAINTAINERS: Cover Renesas RX architecture
In reply to Philippe Mathieu-DaudéFrom: Yoshinori Sato <[email protected]>
Message-Id: <[email protected]>
--- MAINTAINERS | 5 +++++ 1 file changed, 5 insertions(+)
MAINTAINERS +5 -0
@@ -276,6 +276,11 @@ F: include/hw/riscv/ F: linux-user/host/riscv32/ F: linux-user/host/riscv64/ +RENESAS RX CPUs +M: Yoshinori Sato <[email protected]> +S: Maintained +F: target/rx/ + S390 TCG CPUs M: Richard Henderson <[email protected]> M: David Hildenbrand <[email protected]>
Signature · 1 line
2.21.1
PATCH 3/13 target/rx: TCG translation
In reply to Philippe Mathieu-DaudéFrom: Yoshinori Sato <[email protected]>
This part only supported RXv1 instructions.
Instruction manual:
https://www.renesas.com/us/en/doc/products/mpumcu/doc/rx_family/r01us0032ej0120_rxsm.pdf
Message-Id: <[email protected]>
--- target/rx/insns.decode | 621 ++++++++++ target/rx/translate.c | 2432 +++++++++++++++++++++++++++++++++++++++ target/rx/Makefile.objs | 12 + 3 files changed, 3065 insertions(+) create mode 100644 target/rx/insns.decode create mode 100644 target/rx/translate.c create mode 100644 target/rx/Makefile.objs
target/rx/insns.decode new file +621 -0
@@ -0,0 +1,621 @@ +# +# Renesas RX instruction decode definitions. +# +# Copyright (c) 2019 Richard Henderson <[email protected]> +# Copyright (c) 2019 Yoshinori Sato <[email protected]> +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, see <http://www.gnu.org/licenses/>. +# + +&bcnd cd dsp sz +&jdsp dsp sz +&jreg rs +&rr rd rs +&ri rd imm +&rrr rd rs rs2 +&rri rd imm rs2 +&rm rd rs ld mi +&mi rs ld mi imm +&mr rs ld mi rs2 +&mcnd ld sz rd cd +######## +%b1_bdsp 24:3 !function=bdsp_s + +@b1_bcnd_s .... cd:1 ... &bcnd dsp=%b1_bdsp sz=1 +@b1_bra_s .... .... &jdsp dsp=%b1_bdsp sz=1 + +%b2_r_0 16:4 +%b2_li_2 18:2 !function=li +%b2_li_8 24:2 !function=li +%b2_dsp5_3 23:4 19:1 + +@b2_rds .... .... .... rd:4 &rr rs=%b2_r_0 +@b2_rds_li .... .... .... rd:4 &rri rs2=%b2_r_0 imm=%b2_li_8 +@b2_rds_uimm4 .... .... imm:4 rd:4 &rri rs2=%b2_r_0 +@b2_rs2_uimm4 .... .... imm:4 rs2:4 &rri rd=0 +@b2_rds_imm5 .... ... imm:5 rd:4 &rri rs2=%b2_r_0 +@b2_rd_rs_li .... .... rs2:4 rd:4 &rri imm=%b2_li_8 +@b2_rd_ld_ub .... .. ld:2 rs:4 rd:4 &rm mi=4 +@b2_ld_imm3 .... .. ld:2 rs:4 . imm:3 &mi mi=4 +@b2_bcnd_b .... cd:4 dsp:s8 &bcnd sz=2 +@b2_bra_b .... .... dsp:s8 &jdsp sz=2 + +######## + +%b3_r_0 8:4 +%b3_li_10 18:2 !function=li +%b3_dsp5_8 23:1 16:4 +%b3_bdsp 8:s8 16:8 + +@b3_rd_rs .... .... .... .... rs:4 rd:4 &rr +@b3_rs_rd .... .... .... .... rd:4 rs:4 &rr +@b3_rd_li .... .... .... .... .... rd:4 \ + &rri rs2=%b3_r_0 imm=%b3_li_10 +@b3_rd_ld .... .... mi:2 .... ld:2 rs:4 rd:4 &rm +@b3_rd_ld_ub .... .... .... .. ld:2 rs:4 rd:4 &rm mi=4 +@b3_rd_ld_ul .... .... .... .. ld:2 rs:4 rd:4 &rm mi=2 +@b3_rd_rs_rs2 .... .... .... rd:4 rs:4 rs2:4 &rrr +@b3_rds_imm5 .... .... ....... imm:5 rd:4 &rri rs2=%b3_r_0 +@b3_rd_rs_imm5 .... .... ... imm:5 rs2:4 rd:4 &rri +@b3_bcnd_w .... ... cd:1 .... .... .... .... &bcnd dsp=%b3_bdsp sz=3 +@b3_bra_w .... .... .... .... .... .... &jdsp dsp=%b3_bdsp sz=3 +@b3_ld_rd_rs .... .... .... .. ld:2 rs:4 rd:4 &rm mi=0 +@b3_sz_ld_rd_cd .... .... .... sz:2 ld:2 rd:4 cd:4 &mcnd + +######## + +%b4_li_18 18:2 !function=li +%b4_dsp_16 0:s8 8:8 +%b4_bdsp 0:s8 8:8 16:8 + +@b4_rd_ldmi .... .... mi:2 .... ld:2 .... .... rs:4 rd:4 &rm +@b4_bra_a .... .... .... .... .... .... .... .... \ + &jdsp dsp=%b4_bdsp sz=4 +######## +# ABS rd +ABS_rr 0111 1110 0010 .... @b2_rds +# ABS rs, rd +ABS_rr 1111 1100 0000 1111 .... .... @b3_rd_rs + +# ADC #imm, rd +ADC_ir 1111 1101 0111 ..00 0010 .... @b3_rd_li +# ADC rs, rd +ADC_rr 1111 1100 0000 1011 .... .... @b3_rd_rs +# ADC dsp[rs].l, rd +# Note only mi==2 allowed. +ADC_mr 0000 0110 ..10 00.. 0000 0010 .... .... @b4_rd_ldmi + +# ADD #uimm4, rd +ADD_irr 0110 0010 .... .... @b2_rds_uimm4 +# ADD #imm, rs, rd +ADD_irr 0111 00.. .... .... @b2_rd_rs_li +# ADD dsp[rs].ub, rd +# ADD rs, rd +ADD_mr 0100 10.. .... .... @b2_rd_ld_ub +# ADD dsp[rs], rd +ADD_mr 0000 0110 ..00 10.. .... .... @b3_rd_ld +# ADD rs, rs2, rd +ADD_rrr 1111 1111 0010 .... .... .... @b3_rd_rs_rs2 + +# AND #uimm4, rd +AND_ir 0110 0100 .... .... @b2_rds_uimm4 +# AND #imm, rd +AND_ir 0111 01.. 0010 .... @b2_rds_li +# AND dsp[rs].ub, rd +# AND rs, rd +AND_mr 0101 00.. .... .... @b2_rd_ld_ub +# AND dsp[rs], rd +AND_mr 0000 0110 ..01 00.. .... .... @b3_rd_ld +# AND rs, rs2, rd +AND_rrr 1111 1111 0100 .... .... .... @b3_rd_rs_rs2 + +# BCLR #imm, dsp[rd] +BCLR_im 1111 00.. .... 1... @b2_ld_imm3 +# BCLR #imm, rs +BCLR_ir 0111 101. .... .... @b2_rds_imm5 +# BCLR rs, rd +# BCLR rs, dsp[rd] +{ + BCLR_rr 1111 1100 0110 0111 .... .... @b3_rs_rd + BCLR_rm 1111 1100 0110 01.. .... .... @b3_rd_ld_ub +} + +# BCnd.s dsp +BCnd 0001 .... @b1_bcnd_s +# BRA.b dsp +# BCnd.b dsp +{ + BRA 0010 1110 .... .... @b2_bra_b + BCnd 0010 .... .... .... @b2_bcnd_b +} + +# BCnd.w dsp +BCnd 0011 101 . .... .... .... .... @b3_bcnd_w + +# BNOT #imm, dsp[rd] +# BMCnd #imm, dsp[rd] +{ + BNOT_im 1111 1100 111 imm:3 ld:2 rs:4 1111 + BMCnd_im 1111 1100 111 imm:3 ld:2 rd:4 cd:4 +} + +# BNOT #imm, rd +# BMCnd #imm, rd +{ + BNOT_ir 1111 1101 111 imm:5 1111 rd:4 + BMCnd_ir 1111 1101 111 imm:5 cd:4 rd:4 +} + +# BNOT rs, rd +# BNOT rs, dsp[rd] +{ + BNOT_rr 1111 1100 0110 1111 .... .... @b3_rs_rd + BNOT_rm 1111 1100 0110 11.. .... .... @b3_rd_ld_ub +} + +# BRA.s dsp +BRA 0000 1 ... @b1_bra_s +# BRA.w dsp +BRA 0011 1000 .... .... .... .... @b3_bra_w +# BRA.a dsp +BRA 0000 0100 .... .... .... .... .... .... @b4_bra_a +# BRA.l rs +BRA_l 0111 1111 0100 rd:4 + +BRK 0000 0000 + +# BSET #imm, dsp[rd] +BSET_im 1111 00.. .... 0... @b2_ld_imm3 +# BSET #imm, rd +BSET_ir 0111 100. .... .... @b2_rds_imm5 +# BSET rs, rd +# BSET rs, dsp[rd] +{ + BSET_rr 1111 1100 0110 0011 .... .... @b3_rs_rd + BSET_rm 1111 1100 0110 00.. .... .... @b3_rd_ld_ub +} + +# BSR.w dsp +BSR 0011 1001 .... .... .... .... @b3_bra_w +# BSR.a dsp +BSR 0000 0101 .... .... .... .... .... .... @b4_bra_a +# BSR.l rs +BSR_l 0111 1111 0101 rd:4 + +# BSET #imm, dsp[rd] +BTST_im 1111 01.. .... 0... @b2_ld_imm3 +# BSET #imm, rd +BTST_ir 0111 110. .... .... @b2_rds_imm5 +# BSET rs, rd +# BSET rs, dsp[rd] +{ + BTST_rr 1111 1100 0110 1011 .... .... @b3_rs_rd + BTST_rm 1111 1100 0110 10.. .... .... @b3_rd_ld_ub +} + +# CLRSPW psw +CLRPSW 0111 1111 1011 cb:4 + +# CMP #uimm4, rs2 +CMP_ir 0110 0001 .... .... @b2_rs2_uimm4 +# CMP #uimm8, rs2 +CMP_ir 0111 0101 0101 rs2:4 imm:8 &rri rd=0 +# CMP #imm, rs2 +CMP_ir 0111 01.. 0000 rs2:4 &rri imm=%b2_li_8 rd=0 +# CMP dsp[rs].ub, rs2 +# CMP rs, rs2 +CMP_mr 0100 01.. .... .... @b2_rd_ld_ub +# CMP dsp[rs], rs2 +CMP_mr 0000 0110 ..00 01.. .... .... @b3_rd_ld + +# DIV #imm, rd +DIV_ir 1111 1101 0111 ..00 1000 .... @b3_rd_li +# DIV dsp[rs].ub, rd +# DIV rs, rd +DIV_mr 1111 1100 0010 00.. .... .... @b3_rd_ld_ub +# DIV dsp[rs], rd +DIV_mr 0000 0110 ..10 00.. 0000 1000 .... .... @b4_rd_ldmi + +# DIVU #imm, rd +DIVU_ir 1111 1101 0111 ..00 1001 .... @b3_rd_li +# DIVU dsp[rs].ub, rd +# DIVU rs, rd +DIVU_mr 1111 1100 0010 01.. .... .... @b3_rd_ld_ub +# DIVU dsp[rs], rd +DIVU_mr 0000 0110 ..10 00.. 0000 1001 .... .... @b4_rd_ldmi + +# EMUL #imm, rd +EMUL_ir 1111 1101 0111 ..00 0110 .... @b3_rd_li +# EMUL dsp[rs].ub, rd +# EMUL rs, rd +EMUL_mr 1111 1100 0001 10.. .... .... @b3_rd_ld_ub +# EMUL dsp[rs], rd +EMUL_mr 0000 0110 ..10 00.. 0000 0110 .... .... @b4_rd_ldmi + +# EMULU #imm, rd +EMULU_ir 1111 1101 0111 ..00 0111 .... @b3_rd_li +# EMULU dsp[rs].ub, rd +# EMULU rs, rd +EMULU_mr 1111 1100 0001 11.. .... .... @b3_rd_ld_ub +# EMULU dsp[rs], rd +EMULU_mr 0000 0110 ..10 00.. 0000 0111 .... .... @b4_rd_ldmi + +# FADD #imm, rd +FADD_ir 1111 1101 0111 0010 0010 rd:4 +# FADD rs, rd +# FADD dsp[rs], rd +FADD_mr 1111 1100 1000 10.. .... .... @b3_rd_ld_ul + +# FCMP #imm, rd +FCMP_ir 1111 1101 0111 0010 0001 rd:4 +# FCMP rs, rd +# FCMP dsp[rs], rd +FCMP_mr 1111 1100 1000 01.. .... .... @b3_rd_ld_ul + +# FDIV #imm, rd +FDIV_ir 1111 1101 0111 0010 0100 rd:4 +# FDIV rs, rd +# FDIV dsp[rs], rd +FDIV_mr 1111 1100 1001 00.. .... .... @b3_rd_ld_ul + +# FMUL #imm, rd +FMUL_ir 1111 1101 0111 0010 0011 rd:4 +# FMUL rs, rd +# FMUL dsp[rs], rd +FMUL_mr 1111 1100 1000 11.. .... .... @b3_rd_ld_ul + +# FSUB #imm, rd +FSUB_ir 1111 1101 0111 0010 0000 rd:4 +# FSUB rs, rd +# FSUB dsp[rs], rd +FSUB_mr 1111 1100 1000 00.. .... .... @b3_rd_ld_ul + +# FTOI rs, rd +# FTOI dsp[rs], rd +FTOI 1111 1100 1001 01.. .... .... @b3_rd_ld_ul + +# INT #uimm8 +INT 0111 0101 0110 0000 imm:8 + +# ITOF dsp[rs].ub, rd +# ITOF rs, rd +ITOF 1111 1100 0100 01.. .... .... @b3_rd_ld_ub +# ITOF dsp[rs], rd +ITOF 0000 0110 ..10 00.. 0001 0001 .... .... @b4_rd_ldmi + +# JMP rs +JMP 0111 1111 0000 rs:4 &jreg +# JSR rs +JSR 0111 1111 0001 rs:4 &jreg + +# MACHI rs, rs2 +MACHI 1111 1101 0000 0100 rs:4 rs2:4 +# MACLO rs, rs2 +MACLO 1111 1101 0000 0101 rs:4 rs2:4 + +# MAX #imm, rd +MAX_ir 1111 1101 0111 ..00 0100 .... @b3_rd_li +# MAX dsp[rs].ub, rd +# MAX rs, rd +MAX_mr 1111 1100 0001 00.. .... .... @b3_rd_ld_ub +# MAX dsp[rs], rd +MAX_mr 0000 0110 ..10 00.. 0000 0100 .... .... @b4_rd_ldmi + +# MIN #imm, rd +MIN_ir 1111 1101 0111 ..00 0101 .... @b3_rd_li +# MIN dsp[rs].ub, rd +# MIN rs, rd +MIN_mr 1111 1100 0001 01.. .... .... @b3_rd_ld_ub +# MIN dsp[rs], rd +MIN_mr 0000 0110 ..10 00.. 0000 0101 .... .... @b4_rd_ldmi + +# MOV.b rs, dsp5[rd] +MOV_rm 1000 0 .... rd:3 . rs:3 dsp=%b2_dsp5_3 sz=0 +# MOV.w rs, dsp5[rd] +MOV_rm 1001 0 .... rd:3 . rs:3 dsp=%b2_dsp5_3 sz=1 +# MOV.l rs, dsp5[rd] +MOV_rm 1010 0 .... rd:3 . rs:3 dsp=%b2_dsp5_3 sz=2 +# MOV.b dsp5[rs], rd +MOV_mr 1000 1 .... rs:3 . rd:3 dsp=%b2_dsp5_3 sz=0 +# MOV.w dsp5[rs], rd +MOV_mr 1001 1 .... rs:3 . rd:3 dsp=%b2_dsp5_3 sz=1 +# MOV.l dsp5[rs], rd +MOV_mr 1010 1 .... rs:3 . rd:3 dsp=%b2_dsp5_3 sz=2 +# MOV.l #uimm4, rd +MOV_ir 0110 0110 imm:4 rd:4 +# MOV.b #imm8, dsp5[rd] +MOV_im 0011 1100 . rd:3 .... imm:8 sz=0 dsp=%b3_dsp5_8 +# MOV.w #imm8, dsp5[rd] +MOV_im 0011 1101 . rd:3 .... imm:8 sz=1 dsp=%b3_dsp5_8 +# MOV.l #imm8, dsp5[rd] +MOV_im 0011 1110 . rd:3 .... imm:8 sz=2 dsp=%b3_dsp5_8 +# MOV.l #imm8, rd +MOV_ir 0111 0101 0100 rd:4 imm:8 +# MOV.l #mm8, rd +MOV_ir 1111 1011 rd:4 .. 10 imm=%b2_li_2 +# MOV.<bwl> #imm, [rd] +MOV_im 1111 1000 rd:4 .. sz:2 dsp=0 imm=%b2_li_2 +# MOV.<bwl> #imm, dsp8[rd] +MOV_im 1111 1001 rd:4 .. sz:2 dsp:8 imm=%b3_li_10 +# MOV.<bwl> #imm, dsp16[rd] +MOV_im 1111 1010 rd:4 .. sz:2 .... .... .... .... \ + imm=%b4_li_18 dsp=%b4_dsp_16 +# MOV.<bwl> [ri,rb], rd +MOV_ar 1111 1110 01 sz:2 ri:4 rb:4 rd:4 +# MOV.<bwl> rs, [ri,rb] +MOV_ra 1111 1110 00 sz:2 ri:4 rb:4 rs:4 +# Note ldd=3 and lds=3 indicate register src or dst +# MOV.b rs, rd +# MOV.b rs, dsp[rd] +# MOV.b dsp[rs], rd +# MOV.b dsp[rs], dsp[rd] +MOV_mm 1100 ldd:2 lds:2 rs:4 rd:4 sz=0 +# MOV.w rs, rd +# MOV.w rs, dsp[rd] +# MOV.w dsp[rs], rd +# MOV.w dsp[rs], dsp[rd] +MOV_mm 1101 ldd:2 lds:2 rs:4 rd:4 sz=1 +# MOV.l rs, rd +# MOV.l rs, dsp[rd] +# MOV.l dsp[rs], rd +# MOV.l dsp[rs], dsp[rd] +MOV_mm 1110 ldd:2 lds:2 rs:4 rd:4 sz=2 +# MOV.l rs, [rd+] +# MOV.l rs, [-rd] +MOV_rp 1111 1101 0010 0 ad:1 sz:2 rd:4 rs:4 +# MOV.l [rs+], rd +# MOV.l [-rs], rd +MOV_pr 1111 1101 0010 1 ad:1 sz:2 rd:4 rs:4 + +# MOVU.<bw> dsp5[rs], rd +MOVU_mr 1011 sz:1 ... . rs:3 . rd:3 dsp=%b2_dsp5_3 +# MOVU.<bw> [rs], rd +MOVU_mr 0101 1 sz:1 00 rs:4 rd:4 dsp=0 +# MOVU.<bw> dsp8[rs], rd +MOVU_mr 0101 1 sz:1 01 rs:4 rd:4 dsp:8 +# MOVU.<bw> dsp16[rs], rd +MOVU_mr 0101 1 sz:1 10 rs:4 rd:4 .... .... .... .... dsp=%b4_dsp_16 +# MOVU.<bw> rs, rd +MOVU_rr 0101 1 sz:1 11 rs:4 rd:4 +# MOVU.<bw> [ri, rb], rd +MOVU_ar 1111 1110 110 sz:1 ri:4 rb:4 rd:4 +# MOVU.<bw> [rs+], rd +MOVU_pr 1111 1101 0011 1 ad:1 0 sz:1 rd:4 rs:4 + +# MUL #uimm4, rd +MUL_ir 0110 0011 .... .... @b2_rds_uimm4 +# MUL #imm4, rd +MUL_ir 0111 01.. 0001 .... @b2_rds_li +# MUL dsp[rs].ub, rd +# MUL rs, rd +MUL_mr 0100 11.. .... .... @b2_rd_ld_ub +# MUL dsp[rs], rd +MUL_mr 0000 0110 ..00 11.. .... .... @b3_rd_ld +# MOV rs, rs2, rd +MUL_rrr 1111 1111 0011 .... .... .... @b3_rd_rs_rs2 + +# MULHI rs, rs2 +MULHI 1111 1101 0000 0000 rs:4 rs2:4 +# MULLO rs, rs2 +MULLO 1111 1101 0000 0001 rs:4 rs2:4 + +# MVFACHI rd +MVFACHI 1111 1101 0001 1111 0000 rd:4 +# MVFACMI rd +MVFACMI 1111 1101 0001 1111 0010 rd:4 + +# MVFC cr, rd +MVFC 1111 1101 0110 1010 cr:4 rd:4 + +# MVTACHI rs +MVTACHI 1111 1101 0001 0111 0000 rs:4 +# MVTACLO rs +MVTACLO 1111 1101 0001 0111 0001 rs:4 + +# MVTC #imm, cr +MVTC_i 1111 1101 0111 ..11 0000 cr:4 imm=%b3_li_10 +# MVTC rs, cr +MVTC_r 1111 1101 0110 1000 rs:4 cr:4 + +# MVTIPL #imm +MVTIPL 0111 0101 0111 0000 0000 imm:4 + +# NEG rd +NEG_rr 0111 1110 0001 .... @b2_rds +# NEG rs, rd +NEG_rr 1111 1100 0000 0111 .... .... @b3_rd_rs + +NOP 0000 0011 + +# NOT rd +NOT_rr 0111 1110 0000 .... @b2_rds +# NOT rs, rd +NOT_rr 1111 1100 0011 1011 .... .... @b3_rd_rs + +# OR #uimm4, rd +OR_ir 0110 0101 .... .... @b2_rds_uimm4 +# OR #imm, rd +OR_ir 0111 01.. 0011 .... @b2_rds_li +# OR dsp[rs].ub, rd +# OR rs, rd +OR_mr 0101 01.. .... .... @b2_rd_ld_ub +# OR dsp[rs], rd +OR_mr 0000 0110 .. 0101 .. .... .... @b3_rd_ld +# OR rs, rs2, rd +OR_rrr 1111 1111 0101 .... .... .... @b3_rd_rs_rs2 + +# POP cr +POPC 0111 1110 1110 cr:4 +# POP rd-rd2 +POPM 0110 1111 rd:4 rd2:4 + +# POP rd +# PUSH.<bwl> rs +{ + POP 0111 1110 1011 rd:4 + PUSH_r 0111 1110 10 sz:2 rs:4 +} +# PUSH.<bwl> dsp[rs] +PUSH_m 1111 01 ld:2 rs:4 10 sz:2 +# PUSH cr +PUSHC 0111 1110 1100 cr:4 +# PUSHM rs-rs2 +PUSHM 0110 1110 rs:4 rs2:4 + +# RACW #imm +RACW 1111 1101 0001 1000 000 imm:1 0000 + +# REVL rs,rd +REVL 1111 1101 0110 0111 .... .... @b3_rd_rs +# REVW rs,rd +REVW 1111 1101 0110 0101 .... .... @b3_rd_rs + +# SMOVF +# RPMA.<bwl> +{ + SMOVF 0111 1111 1000 1111 + RMPA 0111 1111 1000 11 sz:2 +} + +# ROLC rd +ROLC 0111 1110 0101 .... @b2_rds +# RORC rd +RORC 0111 1110 0100 .... @b2_rds + +# ROTL #imm, rd +ROTL_ir 1111 1101 0110 111. .... .... @b3_rds_imm5 +# ROTL rs, rd +ROTL_rr 1111 1101 0110 0110 .... .... @b3_rd_rs + +# ROTR #imm, rd +ROTR_ir 1111 1101 0110 110. .... .... @b3_rds_imm5 +# ROTR #imm, rd +ROTR_rr 1111 1101 0110 0100 .... .... @b3_rd_rs + +# ROUND rs,rd +# ROUND dsp[rs],rd +ROUND 1111 1100 1001 10 .. .... .... @b3_ld_rd_rs + +RTE 0111 1111 1001 0101 + +RTFI 0111 1111 1001 0100 + +RTS 0000 0010 + +# RTSD #imm +RTSD_i 0110 0111 imm:8 +# RTSD #imm, rd-rd2 +RTSD_irr 0011 1111 rd:4 rd2:4 imm:8 + +# SAT rd +SAT 0111 1110 0011 .... @b2_rds +# SATR +SATR 0111 1111 1001 0011 + +# SBB rs, rd +SBB_rr 1111 1100 0000 0011 .... .... @b3_rd_rs +# SBB dsp[rs].l, rd +# Note only mi==2 allowed. +SBB_mr 0000 0110 ..10 00.. 0000 0000 .... .... @b4_rd_ldmi + +# SCCnd dsp[rd] +# SCCnd rd +SCCnd 1111 1100 1101 .... .... .... @b3_sz_ld_rd_cd + +# SETPSW psw +SETPSW 0111 1111 1010 cb:4 + +# SHAR #imm, rd +SHAR_irr 0110 101. .... .... @b2_rds_imm5 +# SHAR #imm, rs, rd +SHAR_irr 1111 1101 101. .... .... .... @b3_rd_rs_imm5 +# SHAR rs, rd +SHAR_rr 1111 1101 0110 0001 .... .... @b3_rd_rs + +# SHLL #imm, rd +SHLL_irr 0110 110. .... .... @b2_rds_imm5 +# SHLL #imm, rs, rd +SHLL_irr 1111 1101 110. .... .... .... @b3_rd_rs_imm5 +# SHLL rs, rd +SHLL_rr 1111 1101 0110 0010 .... .... @b3_rd_rs + +# SHLR #imm, rd +SHLR_irr 0110 100. .... .... @b2_rds_imm5 +# SHLR #imm, rs, rd +SHLR_irr 1111 1101 100. .... .... .... @b3_rd_rs_imm5 +# SHLR rs, rd +SHLR_rr 1111 1101 0110 0000 .... .... @b3_rd_rs + +# SMOVB +# SSTR.<bwl> +{ + SMOVB 0111 1111 1000 1011 + SSTR 0111 1111 1000 10 sz:2 +} + +# STNZ #imm, rd +STNZ 1111 1101 0111 ..00 1111 .... @b3_rd_li +# STZ #imm, rd +STZ 1111 1101 0111 ..00 1110 .... @b3_rd_li + +# SUB #uimm4, rd +SUB_ir 0110 0000 .... .... @b2_rds_uimm4 +# SUB dsp[rs].ub, rd +# SUB rs, rd +SUB_mr 0100 00.. .... .... @b2_rd_ld_ub +# SUB dsp[rs], rd +SUB_mr 0000 0110 ..00 00.. .... .... @b3_rd_ld +# SUB rs, rs2, rd +SUB_rrr 1111 1111 0000 .... .... .... @b3_rd_rs_rs2 + +# SCMPU +# SUNTIL.<bwl> +{ + SCMPU 0111 1111 1000 0011 + SUNTIL 0111 1111 1000 00 sz:2 +} + +# SMOVU +# SWHILE.<bwl> +{ + SMOVU 0111 1111 1000 0111 + SWHILE 0111 1111 1000 01 sz:2 +} + +# TST #imm, rd +TST_ir 1111 1101 0111 ..00 1100 .... @b3_rd_li +# TST dsp[rs].ub, rd +# TST rs, rd +TST_mr 1111 1100 0011 00.. .... .... @b3_rd_ld_ub +# TST dsp[rs], rd +TST_mr 0000 0110 ..10 00.. 0000 1100 .... .... @b4_rd_ldmi + +WAIT 0111 1111 1001 0110 + +# XCHG rs, rd +# XCHG dsp[rs].ub, rd +{ + XCHG_rr 1111 1100 0100 0011 .... .... @b3_rd_rs + XCHG_mr 1111 1100 0100 00.. .... .... @b3_rd_ld_ub +} +# XCHG dsp[rs], rd +XCHG_mr 0000 0110 ..10 00.. 0001 0000 .... .... @b4_rd_ldmi + +# XOR #imm, rd +XOR_ir 1111 1101 0111 ..00 1101 .... @b3_rd_li +# XOR dsp[rs].ub, rd +# XOR rs, rd +XOR_mr 1111 1100 0011 01.. .... .... @b3_rd_ld_ub +# XOR dsp[rs], rd +XOR_mr 0000 0110 ..10 00.. 0000 1101 .... .... @b4_rd_ldmi
target/rx/translate.c new file +2432 -0
2,379 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.21.1
Part of the diff is not shown here. View the raw message.
PATCH 4/13 target/rx: TCG helpers
In reply to Philippe Mathieu-DaudéFrom: Yoshinori Sato <[email protected]>
[PMD: Removed tlb_fill, extracted from patch of Yoshinori Sato
'Convert to CPUClass::tlb_fill']
Message-Id: <[email protected]>
--- target/rx/helper.h | 31 +++ target/rx/helper.c | 149 +++++++++++++ target/rx/op_helper.c | 470 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 650 insertions(+) create mode 100644 target/rx/helper.h create mode 100644 target/rx/helper.c create mode 100644 target/rx/op_helper.c
target/rx/helper.h new file +31 -0
@@ -0,0 +1,31 @@ +DEF_HELPER_1(raise_illegal_instruction, noreturn, env) +DEF_HELPER_1(raise_access_fault, noreturn, env) +DEF_HELPER_1(raise_privilege_violation, noreturn, env) +DEF_HELPER_1(wait, noreturn, env) +DEF_HELPER_1(debug, noreturn, env) +DEF_HELPER_2(rxint, noreturn, env, i32) +DEF_HELPER_1(rxbrk, noreturn, env) +DEF_HELPER_FLAGS_3(fadd, TCG_CALL_NO_WG, f32, env, f32, f32) +DEF_HELPER_FLAGS_3(fsub, TCG_CALL_NO_WG, f32, env, f32, f32) +DEF_HELPER_FLAGS_3(fmul, TCG_CALL_NO_WG, f32, env, f32, f32) +DEF_HELPER_FLAGS_3(fdiv, TCG_CALL_NO_WG, f32, env, f32, f32) +DEF_HELPER_FLAGS_3(fcmp, TCG_CALL_NO_WG, void, env, f32, f32) +DEF_HELPER_FLAGS_2(ftoi, TCG_CALL_NO_WG, i32, env, f32) +DEF_HELPER_FLAGS_2(round, TCG_CALL_NO_WG, i32, env, f32) +DEF_HELPER_FLAGS_2(itof, TCG_CALL_NO_WG, f32, env, i32) +DEF_HELPER_2(set_fpsw, void, env, i32) +DEF_HELPER_FLAGS_2(racw, TCG_CALL_NO_WG, void, env, i32) +DEF_HELPER_FLAGS_2(set_psw_rte, TCG_CALL_NO_WG, void, env, i32) +DEF_HELPER_FLAGS_2(set_psw, TCG_CALL_NO_WG, void, env, i32) +DEF_HELPER_1(pack_psw, i32, env) +DEF_HELPER_FLAGS_3(div, TCG_CALL_NO_WG, i32, env, i32, i32) +DEF_HELPER_FLAGS_3(divu, TCG_CALL_NO_WG, i32, env, i32, i32) +DEF_HELPER_FLAGS_1(scmpu, TCG_CALL_NO_WG, void, env) +DEF_HELPER_1(smovu, void, env) +DEF_HELPER_1(smovf, void, env) +DEF_HELPER_1(smovb, void, env) +DEF_HELPER_2(sstr, void, env, i32) +DEF_HELPER_FLAGS_2(swhile, TCG_CALL_NO_WG, void, env, i32) +DEF_HELPER_FLAGS_2(suntil, TCG_CALL_NO_WG, void, env, i32) +DEF_HELPER_FLAGS_2(rmpa, TCG_CALL_NO_WG, void, env, i32) +DEF_HELPER_1 (satr, void, env)
target/rx/helper.c new file +149 -0
149 lines not on this page · raw message
target/rx/op_helper.c new file +470 -0
470 lines not on this page · raw message
Signature · 1 line
2.21.1
PATCH 5/13 target/rx: CPU definitions
In reply to Philippe Mathieu-DaudéFrom: Yoshinori Sato <[email protected]>
[PMD: Use newer QOM style, split cpu-qom.h, restrict access to
extable array, use rx_cpu_tlb_fill() extracted from patch of Yoshinori Sato 'Convert to CPUClass::tlb_fill', call cpu_reset after qemu_init_vcpu, make rx_crname a function]
Message-Id: <[email protected]>
--- target/rx/cpu-param.h | 31 ++++++ target/rx/cpu-qom.h | 43 ++++++++ target/rx/cpu.h | 180 ++++++++++++++++++++++++++++++++ target/rx/cpu.c | 226 ++++++++++++++++++++++++++++++++++++++++ target/rx/gdbstub.c | 112 ++++++++++++++++++++ target/rx/translate.c | 17 ++- gdb-xml/rx-core.xml | 70 +++++++++++++ target/rx/Makefile.objs | 1 - 8 files changed, 674 insertions(+), 6 deletions(-) create mode 100644 target/rx/cpu-param.h create mode 100644 target/rx/cpu-qom.h create mode 100644 target/rx/cpu.h create mode 100644 target/rx/cpu.c create mode 100644 target/rx/gdbstub.c create mode 100644 gdb-xml/rx-core.xml
target/rx/cpu-param.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* RX cpu parameters +* +* Copyright (c) 2019 Yoshinori Sato +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2 or later, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef RX_CPU_PARAM_H +#define RX_CPU_PARAM_H + +#define TARGET_LONG_BITS 32 +#define TARGET_PAGE_BITS 12 + +#define TARGET_PHYS_ADDR_SPACE_BITS 32 +#define TARGET_VIRT_ADDR_SPACE_BITS 32 + +#define NB_MMU_MODES 1 +#define MMU_MODE0_SUFFIX _all + +#endif
target/rx/cpu-qom.h new file +43 -0
43 lines not on this page · raw message
target/rx/cpu.h new file +180 -0
180 lines not on this page · raw message
target/rx/cpu.c new file +226 -0
226 lines not on this page · raw message
target/rx/gdbstub.c new file +112 -0
112 lines not on this page · raw message
target/rx/translate.c +12 -5
@@ -41,10 +41,17 @@ typedef struct DisasCompare {TCGCond cond; } DisasCompare; -const char rx_crname[][6 ] = { -"psw" ,"pc" ,"usp" ,"fpsw" ,"" ,"" ,"" ,"" , -"bpsw" ,"bpc" ,"isp" ,"fintv" ,"intb" ,"" ,"" ,"" , -}; +const char *rx_crname (uint8_t cr) +{ +static const char *cr_names[] = { +"psw" ,"pc" ,"usp" ,"fpsw" ,"" ,"" ,"" ,"" , +"bpsw" ,"bpc" ,"isp" ,"fintv" ,"intb" ,"" ,"" ,"" + }; +if (cr >=ARRAY_SIZE (cr_names)) { +return "illegal" ; + } +return cr_names[cr]; +}/* Target-specific values for dc->base.is_jmp. */ #define DISAS_JUMP DISAS_TARGET_0
@@ -365,7 +372,7 @@ static void move_to_cr(DisasContext *ctx, TCGv val, int cr)if (cr >=8 && !is_privileged (ctx,0 )) {/* Some control registers can only be written in privileged mode. */ qemu_log_mask (LOG_GUEST_ERROR , -"disallow control register write %s" , rx_crname[cr]); +"disallow control register write %s" ,rx_crname (cr));return ; } z =tcg_const_i32 (0 );
gdb-xml/rx-core.xml new file +70 -0
70 lines not on this page · raw message
target/rx/Makefile.objs +0 -1
@@ -1,5 +1,4 @@ obj-y += translate.o op_helper.o helper.o cpu.o gdbstub.o disas.o -obj-$(CONFIG_SOFTMMU) += monitor.o DECODETREE = $(SRC_PATH)/scripts/decodetree.py
Signature · 1 line
2.21.1
Re: [PATCH 05/13] target/rx: CPU definitions
Hi Yoshinori,
Quoted 73 lines · Philippe Mathieu-Daudé
From: Yoshinori Sato <[email protected]>
Reviewed-by Richard Henderson <[email protected]>Signed-off-by Yoshinori Sato <[email protected]>Signed-off-by Richard Henderson <[email protected]>[PMD: Use newer QOM style, split
cpu-qom.h, restrict access to
extable array, userx_cpu_tlb_fill()extracted from patch of Yoshinori Sato 'Convert toCPUClass::tlb_fill', callcpu_resetafterqemu_init_vcpu, makerx_crnamea function]Signed-off-by Philippe Mathieu-Daudé <[email protected]>Acked-by Igor Mammedov <[email protected]>Message-Id: <[email protected]>
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/rx/cpu-param.h | 31 ++++++ target/rx/cpu-qom.h | 43 ++++++++ target/rx/cpu.h | 180 ++++++++++++++++++++++++++++++++ target/rx/cpu.c | 226 ++++++++++++++++++++++++++++++++++++++++ target/rx/gdbstub.c | 112 ++++++++++++++++++++ target/rx/translate.c | 17 ++- gdb-xml/rx-core.xml | 70 +++++++++++++ target/rx/Makefile.objs | 1 - 8 files changed, 674 insertions(+), 6 deletions(-)create mode 100644
target/rx/cpu-param.h
create mode 100644target/rx/cpu-qom.h
create mode 100644target/rx/cpu.h
create mode 100644target/rx/cpu.c
create mode 100644target/rx/gdbstub.c
create mode 100644gdb-xml/rx-core.xmltarget/rx/cpu-param.h new file +31
-0@@ -0,0 +1,31 @@ +/* +* RX cpu parameters +* +* Copyright (c) 2019 Yoshinori Sato +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2 or later, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef RX_CPU_PARAM_H +#define RX_CPU_PARAM_H + +#define TARGET_LONG_BITS 32 +#define TARGET_PAGE_BITS 12 + +#define TARGET_PHYS_ADDR_SPACE_BITS 32 +#define TARGET_VIRT_ADDR_SPACE_BITS 32 + +#define NB_MMU_MODES 1 +#define MMU_MODE0_SUFFIX _all + +#endif target/rx/cpu-qom.h new file +0
-0
target/rx/cpu-qom.h line 5
Quoted 5 lines
target/rx/cpu-qom.h new file +5
-0@@ -0,0 +1,43 @@ +/* +* RX CPU +* +* Copyright (c) 2019 Yoshinori Sato +* SPDX-License-Identifier: LGPL-2.0+
For the rest of your work you used GPL-2.0-or-later but here LGPL-2.0+, is this on purpose?
Quoted 696 lines
target/rx/cpu-qom.h new file +38
-0+*/ + +#ifndef RX_CPU_QOM_H +#define RX_CPU_QOM_H + +#include "hw/core/cpu.h" + +#define TYPE_RX_CPU "rx-cpu" + +#define TYPE_RX62N_CPU RX_CPU_TYPE_NAME("rx62n") + +#define RXCPU_CLASS (klass) \ + OBJECT_CLASS_CHECK(RXCPUClass, (klass), TYPE_RX_CPU) +#define RXCPU (obj) \ + OBJECT_CHECK(RXCPU, (obj), TYPE_RX_CPU) +#define RXCPU_GET_CLASS (obj) \ + OBJECT_GET_CLASS(RXCPUClass, (obj), TYPE_RX_CPU) + +/* +* RXCPUClass: +* @parent_realize: The parent class' realize handler. +* @parent_reset: The parent class' reset handler. +* +* A RX CPU model. +*/ +typedef struct RXCPUClass { +/*< private >*/ +CPUClass parent_class; +/*< public >*/ + +DeviceRealize parent_realize; +void (*parent_reset)(CPUState *cpu); + +}RXCPUClass ; + +#define CPUArchState struct CPURXState + +#endif target/rx/cpu.h new file +180
-0@@ -0,0 +1,180 @@ +/* +* RX emulation definition +* +* Copyright (c) 2019 Yoshinori Sato +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2 or later, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef RX_CPU_H +#define RX_CPU_H + +#include "qemu/bitops.h" +#include "qemu-common.h" +#include "hw/registerfields.h" +#include "cpu-qom.h" + +#include "exec/cpu-defs.h" + +/* PSW define */ +REG32(PSW, 0) +FIELD(PSW, C, 0, 1) +FIELD(PSW, Z, 1, 1) +FIELD(PSW, S, 2, 1) +FIELD(PSW, O, 3, 1) +FIELD(PSW, I, 16, 1) +FIELD(PSW, U, 17, 1) +FIELD(PSW, PM, 20, 1) +FIELD (PSW ,IPL ,24 ,4 ) + +/* FPSW define */ +REG32(FPSW, 0) +FIELD(FPSW, RM, 0, 2) +FIELD(FPSW, CV, 2, 1) +FIELD(FPSW, CO, 3, 1) +FIELD(FPSW, CZ, 4, 1) +FIELD(FPSW, CU, 5, 1) +FIELD(FPSW, CX, 6, 1) +FIELD(FPSW, CE, 7, 1) +FIELD(FPSW, CAUSE, 2, 6) +FIELD(FPSW, DN, 8, 1) +FIELD(FPSW, EV, 10, 1) +FIELD(FPSW, EO, 11, 1) +FIELD(FPSW, EZ, 12, 1) +FIELD(FPSW, EU, 13, 1) +FIELD(FPSW, EX, 14, 1) +FIELD(FPSW, ENABLE, 10, 5) +FIELD(FPSW, FV, 26, 1) +FIELD(FPSW, FO, 27, 1) +FIELD(FPSW, FZ, 28, 1) +FIELD(FPSW, FU, 29, 1) +FIELD(FPSW, FX, 30, 1) +FIELD(FPSW, FLAGS, 26, 4) +FIELD(FPSW, FS, 31, 1) + +enum { +NUM_REGS =16 , +}; + +typedef struct CPURXState { +/* CPU registers */ +uint32_t regs[NUM_REGS ];/* general registers */ +uint32_t psw_o;/* O bit of status register */ +uint32_t psw_s;/* S bit of status register */ +uint32_t psw_z;/* Z bit of status register */ +uint32_t psw_c;/* C bit of status register */ +uint32_t psw_u; +uint32_t psw_i; +uint32_t psw_pm; +uint32_t psw_ipl; +uint32_t bpsw;/* backup status */ +uint32_t bpc;/* backup pc */ +uint32_t isp;/* global base register */ +uint32_t usp;/* vector base register */ +uint32_t pc;/* program counter */ +uint32_t intb;/* interrupt vector */ +uint32_t fintv; +uint32_t fpsw; +uint64_t acc; + +/* Fields up to this point are cleared by a CPU reset */ +struct {} end_reset_fields; + +/* Internal use */ +uint32_t in_sleep; +uint32_t req_irq;/* Requested interrupt no (hard) */ +uint32_t req_ipl;/* Requested interrupt level */ +uint32_t ack_irq;/* execute irq */ +uint32_t ack_ipl;/* execute ipl */ +float_status fp_status; +qemu_irq ack;/* Interrupt acknowledge */ +}CPURXState ; + +/* +* RXCPU: +* @env: #CPURXState +* +* A RX CPU +*/ +struct RXCPU { +/*< private >*/ +CPUState parent_obj; +/*< public >*/ + +CPUNegativeOffsetState neg; +CPURXState env; +}; + +typedef struct RXCPU RXCPU ; +typedef RXCPU ArchCPU ; + +#define ENV_OFFSET offsetof(RXCPU, env) + +#define RX_CPU_TYPE_SUFFIX "-" TYPE_RX_CPU +#define RX_CPU_TYPE_NAME (model) model RX_CPU_TYPE_SUFFIX +#define CPU_RESOLVING_TYPE TYPE_RX_CPU + +const char *rx_crname (uint8_t cr); +void rx_cpu_do_interrupt (CPUState *cpu); +bool rx_cpu_exec_interrupt (CPUState *cpu,int int_req); +void rx_cpu_dump_state (CPUState *cpu,FILE *f,int flags); +int rx_cpu_gdb_read_register (CPUState *cpu,uint8_t *buf,int reg); +int rx_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg); +hwaddr rx_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr); + +void rx_translate_init (void ); +int cpu_rx_signal_handler (int host_signum,void *pinfo, +void *puc); + +void rx_cpu_list (void ); +void rx_cpu_unpack_psw (CPURXState *env,uint32_t psw,int rte); + +#define cpu_signal_handler cpu_rx_signal_handler +#define cpu_list rx_cpu_list + +#include "exec/cpu-all.h" + +#define CPU_INTERRUPT_SOFT CPU_INTERRUPT_TGT_INT_0 +#define CPU_INTERRUPT_FIR CPU_INTERRUPT_TGT_INT_1 + +#define RX_CPU_IRQ 0 +#define RX_CPU_FIR 1 + +static inline void cpu_get_tb_cpu_state (CPURXState *env,target_ulong *pc, +target_ulong *cs_base,uint32_t *flags) +{ + *pc = env->pc; + *cs_base =0 ; + *flags =FIELD_DP32 (0 ,PSW ,PM , env->psw_pm); +} + +static inline int cpu_mmu_index (CPURXState *env,bool ifetch) +{ +return 0 ; +} + +static inline uint32_t rx_cpu_pack_psw (CPURXState *env) +{ +uint32_t psw =0 ; + psw =FIELD_DP32 (psw,PSW ,IPL , env->psw_ipl); + psw =FIELD_DP32 (psw,PSW ,PM , env->psw_pm); + psw =FIELD_DP32 (psw,PSW ,U , env->psw_u); + psw =FIELD_DP32 (psw,PSW ,I , env->psw_i); + psw =FIELD_DP32 (psw,PSW ,O , env->psw_o >>31 ); + psw =FIELD_DP32 (psw,PSW ,S , env->psw_s >>31 ); + psw =FIELD_DP32 (psw,PSW ,Z , env->psw_z ==0 ); + psw =FIELD_DP32 (psw,PSW ,C , env->psw_c); +return psw; +} + +#endif /* RX_CPU_H */ target/rx/cpu.c new file +226
-0@@ -0,0 +1,226 @@ +/* +* QEMU RX CPU +* +* Copyright (c) 2019 Yoshinori Sato +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2 or later, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include "qemu/osdep.h" +#include "qemu/qemu-print.h" +#include "qapi/error.h" +#include "cpu.h" +#include "qemu-common.h" +#include "migration/vmstate.h" +#include "exec/exec-all.h" +#include "hw/loader.h" +#include "fpu/softfloat.h" + +static void rx_cpu_set_pc (CPUState *cs,vaddr value) +{ +RXCPU *cpu =RXCPU (cs); + + cpu->env.pc = value; +} + +static void rx_cpu_synchronize_from_tb (CPUState *cs,TranslationBlock *tb) +{ +RXCPU *cpu =RXCPU (cs); + + cpu->env.pc = tb->pc; +} + +static bool rx_cpu_has_work (CPUState *cs) +{ +return cs->interrupt_request & + (CPU_INTERRUPT_HARD |CPU_INTERRUPT_FIR ); +} + +static void rx_cpu_reset (CPUState *s) +{ +RXCPU *cpu =RXCPU (s); +RXCPUClass *rcc =RXCPU_GET_CLASS (cpu); +CPURXState *env = &cpu->env; +uint32_t *resetvec; + + rcc->parent_reset (s); + +memset (env,0 , offsetof(CPURXState , end_reset_fields)); + + resetvec =rom_ptr (0xfffffffc ,4 ); +if (resetvec) { +/* In the case of kernel, it is ignored because it is not set. */ + env->pc =ldl_p (resetvec); + } +rx_cpu_unpack_psw (env,0 ,1 ); + env->regs[0 ] = env->isp = env->usp =0 ; + env->fpsw =0 ; +set_flush_to_zero (1 , &env->fp_status); +set_flush_inputs_to_zero (1 , &env->fp_status); +} + +static void rx_cpu_list_entry (gpointer data,gpointer user_data) +{ +ObjectClass *oc = data; + +qemu_printf (" %s\n" ,object_class_get_name (oc)); +} + +void rx_cpu_list (void ) +{ +GSList *list; + list =object_class_get_list_sorted (TYPE_RX_CPU , false); +qemu_printf ("Available CPUs:\n" ); +g_slist_foreach (list, rx_cpu_list_entry,NULL ); +g_slist_free (list); +} + +static ObjectClass *rx_cpu_class_by_name (const char *cpu_model) +{ +ObjectClass *oc; +char *typename; + + oc =object_class_by_name (cpu_model); +if (oc !=NULL &&object_class_dynamic_cast (oc,TYPE_RX_CPU ) !=NULL && + !object_class_is_abstract (oc)) { +return oc; + } + typename =g_strdup_printf (RX_CPU_TYPE_NAME ("%s" ), cpu_model); + oc =object_class_by_name (typename); +g_free (typename); +if (oc !=NULL &&object_class_is_abstract (oc)) { + oc =NULL ; + } + +return oc; +} + +static void rx_cpu_realize (DeviceState *dev,Error **errp) +{ +CPUState *cs =CPU (dev); +RXCPUClass *rcc =RXCPU_GET_CLASS (dev); +Error *local_err =NULL ; + +cpu_exec_realizefn (cs, &local_err); +if (local_err !=NULL ) { +error_propagate (errp, local_err); +return ; + } + +qemu_init_vcpu (cs); +cpu_reset (cs); + + rcc->parent_realize (dev, errp); +} + +static void rx_cpu_set_irq (void *opaque,int no,int request) +{ +RXCPU *cpu = opaque; +CPUState *cs =CPU (cpu); +int irq = request &0xff ; + +static const int mask[] = { + [RX_CPU_IRQ ] =CPU_INTERRUPT_HARD , + [RX_CPU_FIR ] =CPU_INTERRUPT_FIR , + }; +if (irq) { + cpu->env.req_irq = irq; + cpu->env.req_ipl = (request >>8 ) &0x0f ; +cpu_interrupt (cs, mask[no]); + }else { +cpu_reset_interrupt (cs, mask[no]); + } +} + +static void rx_cpu_disas_set_info (CPUState *cpu,disassemble_info *info) +{ + info->mach = bfd_mach_rx; + info->print_insn = print_insn_rx; +} + +static bool rx_cpu_tlb_fill (CPUState *cs,vaddr addr,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr) +{ +uint32_t address, physical, prot; + +/* Linear mapping */ + address = physical = addr &TARGET_PAGE_MASK ; + prot =PAGE_READ |PAGE_WRITE |PAGE_EXEC ; +tlb_set_page (cs, address, physical, prot, mmu_idx,TARGET_PAGE_SIZE ); +return true; +} + +static void rx_cpu_init (Object *obj) +{ +CPUState *cs =CPU (obj); +RXCPU *cpu =RXCPU (obj); +CPURXState *env = &cpu->env; + +cpu_set_cpustate_pointers (cpu); + cs->env_ptr = env; +qdev_init_gpio_in (DEVICE (cpu), rx_cpu_set_irq,2 ); +} + +static void rx_cpu_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); +CPUClass *cc =CPU_CLASS (klass); +RXCPUClass *rcc =RXCPU_CLASS (klass); + +device_class_set_parent_realize (dc, rx_cpu_realize, + &rcc->parent_realize); + + rcc->parent_reset = cc->reset; + cc->reset = rx_cpu_reset; + + cc->class_by_name = rx_cpu_class_by_name; + cc->has_work = rx_cpu_has_work; + cc->do_interrupt = rx_cpu_do_interrupt; + cc->cpu_exec_interrupt = rx_cpu_exec_interrupt; + cc->dump_state = rx_cpu_dump_state; + cc->set_pc = rx_cpu_set_pc; + cc->synchronize_from_tb = rx_cpu_synchronize_from_tb; + cc->gdb_read_register = rx_cpu_gdb_read_register; + cc->gdb_write_register = rx_cpu_gdb_write_register; + cc->get_phys_page_debug = rx_cpu_get_phys_page_debug; + cc->disas_set_info = rx_cpu_disas_set_info; + cc->tcg_initialize = rx_translate_init; + cc->tlb_fill = rx_cpu_tlb_fill; + + cc->gdb_num_core_regs =26 ; + cc->gdb_core_xml_file ="rx-core.xml" ; +} + +static const TypeInfo rx_cpu_info = { + .name =TYPE_RX_CPU , + .parent =TYPE_CPU , + .instance_size =sizeof (RXCPU ), + .instance_init = rx_cpu_init, + .abstract = true, + .class_size =sizeof (RXCPUClass), + .class_init = rx_cpu_class_init, +}; + +static const TypeInfo rx62n_rx_cpu_info = { + .name =TYPE_RX62N_CPU , + .parent =TYPE_RX_CPU , +}; + +static void rx_cpu_register_types (void ) +{ +type_register_static (&rx_cpu_info); +type_register_static (&rx62n_rx_cpu_info); +} + +type_init (rx_cpu_register_types)target/rx/gdbstub.c new file +112
-0@@ -0,0 +1,112 @@ +/* +* RX gdb server stub +* +* Copyright (c) 2019 Yoshinori Sato +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2 or later, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see <http://www.gnu.org/licenses/>. +*/ +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "cpu.h" +#include "exec/gdbstub.h" + +int rx_cpu_gdb_read_register (CPUState *cs,uint8_t *mem_buf,int n) +{ +RXCPU *cpu =RXCPU (cs); +CPURXState *env = &cpu->env; + +switch (n) { + case 0 ... 15: +return gdb_get_regl (mem_buf, env->regs[n]); +case 16 : +return gdb_get_regl (mem_buf, (env->psw_u) ? env->regs[0 ] : env->usp); +case 17 : +return gdb_get_regl (mem_buf, (!env->psw_u) ? env->regs[0 ] : env->isp); +case 18 : +return gdb_get_regl (mem_buf,rx_cpu_pack_psw (env)); +case 19 : +return gdb_get_regl (mem_buf, env->pc); +case 20 : +return gdb_get_regl (mem_buf, env->intb); +case 21 : +return gdb_get_regl (mem_buf, env->bpsw); +case 22 : +return gdb_get_regl (mem_buf, env->bpc); +case 23 : +return gdb_get_regl (mem_buf, env->fintv); +case 24 : +return gdb_get_regl (mem_buf, env->fpsw); +case 25 : +return 0 ; + } +return 0 ; +} + +int rx_cpu_gdb_write_register (CPUState *cs,uint8_t *mem_buf,int n) +{ +RXCPU *cpu =RXCPU (cs); +CPURXState *env = &cpu->env; +uint32_t psw; +switch (n) { + case 0 ... 15: + env->regs[n] =ldl_p (mem_buf); +if (n ==0 ) { +if (env->psw_u) { + env->usp = env->regs[0 ]; + }else { + env->isp = env->regs[0 ]; + } + } +break ; +case 16 : + env->usp =ldl_p (mem_buf); +if (env->psw_u) { + env->regs[0 ] =ldl_p (mem_buf); + } +break ; +case 17 : + env->isp =ldl_p (mem_buf); +if (!env->psw_u) { + env->regs[0 ] =ldl_p (mem_buf); + } +break ; +case 18 : + psw =ldl_p (mem_buf); +rx_cpu_unpack_psw (env, psw,1 ); +break ; +case 19 : + env->pc =ldl_p (mem_buf); +break ; +case 20 : + env->intb =ldl_p (mem_buf); +break ; +case 21 : + env->bpsw =ldl_p (mem_buf); +break ; +case 22 : + env->bpc =ldl_p (mem_buf); +break ; +case 23 : + env->fintv =ldl_p (mem_buf); +break ; +case 24 : + env->fpsw =ldl_p (mem_buf); +break ; +case 25 : +return 8 ; +default : +return 0 ; + } + +return 4 ; +}target/rx/translate.c +12
-5@@ -41,10 +41,17 @@ typedef struct DisasCompare {TCGCond cond; } DisasCompare; -const char rx_crname[][6 ] = { -"psw" ,"pc" ,"usp" ,"fpsw" ,"" ,"" ,"" ,"" , -"bpsw" ,"bpc" ,"isp" ,"fintv" ,"intb" ,"" ,"" ,"" , -}; +const char *rx_crname (uint8_t cr) +{ +static const char *cr_names[] = { +"psw" ,"pc" ,"usp" ,"fpsw" ,"" ,"" ,"" ,"" , +"bpsw" ,"bpc" ,"isp" ,"fintv" ,"intb" ,"" ,"" ,"" + }; +if (cr >=ARRAY_SIZE (cr_names)) { +return "illegal" ; + } +return cr_names[cr]; +}/* Target-specific values for dc->base.is_jmp. */ #define DISAS_JUMP DISAS_TARGET_0@@ -365,7 +372,7 @@ static void move_to_cr(DisasContext *ctx, TCGv val, int cr)if (cr >=8 && !is_privileged (ctx,0 )) {/* Some control registers can only be written in privileged mode. */ qemu_log_mask (LOG_GUEST_ERROR , -"disallow control register write %s" , rx_crname[cr]); +"disallow control register write %s" ,rx_crname (cr));return ; } z =tcg_const_i32 (0 );gdb-xml/rx-core.xml new file +70
-0@@ -0,0 +1,70 @@ +<?xml version="1.0"?> +<!-- Copyright (C) 2019 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. --> + +<!DOCTYPE feature SYSTEM "gdb-target.dtd"> +<feature name="org.gnu.gdb.rx.core"> + <reg name="r0" bitsize="32" type="data_ptr"/> + <reg name="r1" bitsize="32" type="uint32"/> + <reg name="r2" bitsize="32" type="uint32"/> + <reg name="r3" bitsize="32" type="uint32"/> + <reg name="r4" bitsize="32" type="uint32"/> + <reg name="r5" bitsize="32" type="uint32"/> + <reg name="r6" bitsize="32" type="uint32"/> + <reg name="r7" bitsize="32" type="uint32"/> + <reg name="r8" bitsize="32" type="uint32"/> + <reg name="r9" bitsize="32" type="uint32"/> + <reg name="r10" bitsize="32" type="uint32"/> + <reg name="r11" bitsize="32" type="uint32"/> + <reg name="r12" bitsize="32" type="uint32"/> + <reg name="r13" bitsize="32" type="uint32"/> + <reg name="r14" bitsize="32" type="uint32"/> + <reg name="r15" bitsize="32" type="uint32"/> + + <flags id="psw_flags" size="4"> + <field name="C" start="0" end="0"/> + <field name="Z" start="1" end="1"/> + <field name="S" start="2" end="2"/> + <field name="O" start="3" end="3"/> + <field name="I" start="16" end="16"/> + <field name="U" start="17" end="17"/> + <field name="PM" start="20" end="20"/> + <field name="IPL" start="24" end="27"/> + </flags> + + <flags id="fpsw_flags" size="4"> + <field name="RM" start="0" end="1"/> + <field name="CV" start="2" end="2"/> + <field name="CO" start="3" end="3"/> + <field name="CZ" start="4" end="4"/> + <field name="CU" start="5" end="5"/> + <field name="CX" start="6" end="6"/> + <field name="CE" start="7" end="7"/> + <field name="DN" start="8" end="8"/> + <field name="EV" start="10" end="10"/> + <field name="EO" start="11" end="11"/> + <field name="EZ" start="12" end="12"/> + <field name="EU" start="13" end="13"/> + <field name="EX" start="14" end="14"/> + <field name="FV" start="26" end="26"/> + <field name="FO" start="27" end="27"/> + <field name="FZ" start="28" end="28"/> + <field name="FU" start="29" end="29"/> + <field name="FX" start="30" end="30"/> + <field name="FS" start="31" end="31"/> + </flags> + + <reg name="usp" bitsize="32" type="data_ptr"/> + <reg name="isp" bitsize="32" type="data_ptr"/> + <reg name="psw" bitsize="32" type="psw_flags"/> + <reg name="pc" bitsize="32" type="code_ptr"/> + <reg name="intb" bitsize="32" type="data_ptr"/> + <reg name="bpsw" bitsize="32" type="psw_flags"/> + <reg name="bpc" bitsize="32" type="code_ptr"/> + <reg name="fintv" bitsize="32" type="code_ptr"/> + <reg name="fpsw" bitsize="32" type="fpsw_flags"/> + <reg name="acc" bitsize="64" type="uint64"/> +</feature>target/rx/Makefile.objs +0
-1@@ -1,5 +1,4 @@ obj-y += translate.o op_helper.o helper.o cpu.o gdbstub.o disas.o -obj-$(CONFIG_SOFTMMU) += monitor.o DECODETREE = $(SRC_PATH)/scripts/decodetree.py
Re: [PATCH 05/13] target/rx: CPU definitions
Quoted 77 lines · Philippe Mathieu-Daudé
Hi Yoshinori,
Quoted 73 lines · Philippe Mathieu-Daudé
From: Yoshinori Sato <[email protected]>
Reviewed-by Richard Henderson <[email protected]>Signed-off-by Yoshinori Sato <[email protected]>Signed-off-by Richard Henderson <[email protected]>[PMD: Use newer QOM style, split
cpu-qom.h, restrict access to
extable array, userx_cpu_tlb_fill()extracted from patch of Yoshinori Sato 'Convert toCPUClass::tlb_fill', callcpu_resetafterqemu_init_vcpu, makerx_crnamea function]Signed-off-by Philippe Mathieu-Daudé <[email protected]>Acked-by Igor Mammedov <[email protected]>Message-Id: <[email protected]>
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/rx/cpu-param.h | 31 ++++++ target/rx/cpu-qom.h | 43 ++++++++ target/rx/cpu.h | 180 ++++++++++++++++++++++++++++++++ target/rx/cpu.c | 226 ++++++++++++++++++++++++++++++++++++++++ target/rx/gdbstub.c | 112 ++++++++++++++++++++ target/rx/translate.c | 17 ++- gdb-xml/rx-core.xml | 70 +++++++++++++ target/rx/Makefile.objs | 1 - 8 files changed, 674 insertions(+), 6 deletions(-)create mode 100644
target/rx/cpu-param.h
create mode 100644target/rx/cpu-qom.h
create mode 100644target/rx/cpu.h
create mode 100644target/rx/cpu.c
create mode 100644target/rx/gdbstub.c
create mode 100644gdb-xml/rx-core.xmltarget/rx/cpu-param.h new file +31
-0@@ -0,0 +1,31 @@ +/* +* RX cpu parameters +* +* Copyright (c) 2019 Yoshinori Sato +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2 or later, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef RX_CPU_PARAM_H +#define RX_CPU_PARAM_H + +#define TARGET_LONG_BITS 32 +#define TARGET_PAGE_BITS 12 + +#define TARGET_PHYS_ADDR_SPACE_BITS 32 +#define TARGET_VIRT_ADDR_SPACE_BITS 32 + +#define NB_MMU_MODES 1 +#define MMU_MODE0_SUFFIX _all + +#endif target/rx/cpu-qom.h new file +0
-0@@ -0,0 +1,43 @@
Quoted 8 lines
target/rx/cpu-qom.h line 5
Quoted 5 lines
target/rx/cpu-qom.h new file +5
-0+/* +* RX CPU +* +* Copyright (c) 2019 Yoshinori Sato +* SPDX-License-Identifier: LGPL-2.0+ For the rest of your work you used GPL-2.0-or-later but here LGPL-2.0+, is this on purpose?
It seems I wrote it wrong.
Make GPLv2 according to others.
Quoted 694 lines
Quoted 692 lines
target/rx/cpu-qom.h new file +38
-0+*/ + +#ifndef RX_CPU_QOM_H +#define RX_CPU_QOM_H + +#include "hw/core/cpu.h" + +#define TYPE_RX_CPU "rx-cpu" + +#define TYPE_RX62N_CPU RX_CPU_TYPE_NAME("rx62n") + +#define RXCPU_CLASS (klass) \ + OBJECT_CLASS_CHECK(RXCPUClass, (klass), TYPE_RX_CPU) +#define RXCPU (obj) \ + OBJECT_CHECK(RXCPU, (obj), TYPE_RX_CPU) +#define RXCPU_GET_CLASS (obj) \ + OBJECT_GET_CLASS(RXCPUClass, (obj), TYPE_RX_CPU) + +/* +* RXCPUClass: +* @parent_realize: The parent class' realize handler. +* @parent_reset: The parent class' reset handler. +* +* A RX CPU model. +*/ +typedef struct RXCPUClass { +/*< private >*/ +CPUClass parent_class; +/*< public >*/ + +DeviceRealize parent_realize; +void (*parent_reset)(CPUState *cpu); + +}RXCPUClass ; + +#define CPUArchState struct CPURXState + +#endif target/rx/cpu.h new file +180
-0@@ -0,0 +1,180 @@ +/* +* RX emulation definition +* +* Copyright (c) 2019 Yoshinori Sato +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2 or later, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef RX_CPU_H +#define RX_CPU_H + +#include "qemu/bitops.h" +#include "qemu-common.h" +#include "hw/registerfields.h" +#include "cpu-qom.h" + +#include "exec/cpu-defs.h" + +/* PSW define */ +REG32(PSW, 0) +FIELD(PSW, C, 0, 1) +FIELD(PSW, Z, 1, 1) +FIELD(PSW, S, 2, 1) +FIELD(PSW, O, 3, 1) +FIELD(PSW, I, 16, 1) +FIELD(PSW, U, 17, 1) +FIELD(PSW, PM, 20, 1) +FIELD (PSW ,IPL ,24 ,4 ) + +/* FPSW define */ +REG32(FPSW, 0) +FIELD(FPSW, RM, 0, 2) +FIELD(FPSW, CV, 2, 1) +FIELD(FPSW, CO, 3, 1) +FIELD(FPSW, CZ, 4, 1) +FIELD(FPSW, CU, 5, 1) +FIELD(FPSW, CX, 6, 1) +FIELD(FPSW, CE, 7, 1) +FIELD(FPSW, CAUSE, 2, 6) +FIELD(FPSW, DN, 8, 1) +FIELD(FPSW, EV, 10, 1) +FIELD(FPSW, EO, 11, 1) +FIELD(FPSW, EZ, 12, 1) +FIELD(FPSW, EU, 13, 1) +FIELD(FPSW, EX, 14, 1) +FIELD(FPSW, ENABLE, 10, 5) +FIELD(FPSW, FV, 26, 1) +FIELD(FPSW, FO, 27, 1) +FIELD(FPSW, FZ, 28, 1) +FIELD(FPSW, FU, 29, 1) +FIELD(FPSW, FX, 30, 1) +FIELD(FPSW, FLAGS, 26, 4) +FIELD(FPSW, FS, 31, 1) + +enum { +NUM_REGS =16 , +}; + +typedef struct CPURXState { +/* CPU registers */ +uint32_t regs[NUM_REGS ];/* general registers */ +uint32_t psw_o;/* O bit of status register */ +uint32_t psw_s;/* S bit of status register */ +uint32_t psw_z;/* Z bit of status register */ +uint32_t psw_c;/* C bit of status register */ +uint32_t psw_u; +uint32_t psw_i; +uint32_t psw_pm; +uint32_t psw_ipl; +uint32_t bpsw;/* backup status */ +uint32_t bpc;/* backup pc */ +uint32_t isp;/* global base register */ +uint32_t usp;/* vector base register */ +uint32_t pc;/* program counter */ +uint32_t intb;/* interrupt vector */ +uint32_t fintv; +uint32_t fpsw; +uint64_t acc; + +/* Fields up to this point are cleared by a CPU reset */ +struct {} end_reset_fields; + +/* Internal use */ +uint32_t in_sleep; +uint32_t req_irq;/* Requested interrupt no (hard) */ +uint32_t req_ipl;/* Requested interrupt level */ +uint32_t ack_irq;/* execute irq */ +uint32_t ack_ipl;/* execute ipl */ +float_status fp_status; +qemu_irq ack;/* Interrupt acknowledge */ +}CPURXState ; + +/* +* RXCPU: +* @env: #CPURXState +* +* A RX CPU +*/ +struct RXCPU { +/*< private >*/ +CPUState parent_obj; +/*< public >*/ + +CPUNegativeOffsetState neg; +CPURXState env; +}; + +typedef struct RXCPU RXCPU ; +typedef RXCPU ArchCPU ; + +#define ENV_OFFSET offsetof(RXCPU, env) + +#define RX_CPU_TYPE_SUFFIX "-" TYPE_RX_CPU +#define RX_CPU_TYPE_NAME (model) model RX_CPU_TYPE_SUFFIX +#define CPU_RESOLVING_TYPE TYPE_RX_CPU + +const char *rx_crname (uint8_t cr); +void rx_cpu_do_interrupt (CPUState *cpu); +bool rx_cpu_exec_interrupt (CPUState *cpu,int int_req); +void rx_cpu_dump_state (CPUState *cpu,FILE *f,int flags); +int rx_cpu_gdb_read_register (CPUState *cpu,uint8_t *buf,int reg); +int rx_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg); +hwaddr rx_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr); + +void rx_translate_init (void ); +int cpu_rx_signal_handler (int host_signum,void *pinfo, +void *puc); + +void rx_cpu_list (void ); +void rx_cpu_unpack_psw (CPURXState *env,uint32_t psw,int rte); + +#define cpu_signal_handler cpu_rx_signal_handler +#define cpu_list rx_cpu_list + +#include "exec/cpu-all.h" + +#define CPU_INTERRUPT_SOFT CPU_INTERRUPT_TGT_INT_0 +#define CPU_INTERRUPT_FIR CPU_INTERRUPT_TGT_INT_1 + +#define RX_CPU_IRQ 0 +#define RX_CPU_FIR 1 + +static inline void cpu_get_tb_cpu_state (CPURXState *env,target_ulong *pc, +target_ulong *cs_base,uint32_t *flags) +{ + *pc = env->pc; + *cs_base =0 ; + *flags =FIELD_DP32 (0 ,PSW ,PM , env->psw_pm); +} + +static inline int cpu_mmu_index (CPURXState *env,bool ifetch) +{ +return 0 ; +} + +static inline uint32_t rx_cpu_pack_psw (CPURXState *env) +{ +uint32_t psw =0 ; + psw =FIELD_DP32 (psw,PSW ,IPL , env->psw_ipl); + psw =FIELD_DP32 (psw,PSW ,PM , env->psw_pm); + psw =FIELD_DP32 (psw,PSW ,U , env->psw_u); + psw =FIELD_DP32 (psw,PSW ,I , env->psw_i); + psw =FIELD_DP32 (psw,PSW ,O , env->psw_o >>31 ); + psw =FIELD_DP32 (psw,PSW ,S , env->psw_s >>31 ); + psw =FIELD_DP32 (psw,PSW ,Z , env->psw_z ==0 ); + psw =FIELD_DP32 (psw,PSW ,C , env->psw_c); +return psw; +} + +#endif /* RX_CPU_H */ target/rx/cpu.c new file +226
-0@@ -0,0 +1,226 @@ +/* +* QEMU RX CPU +* +* Copyright (c) 2019 Yoshinori Sato +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2 or later, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include "qemu/osdep.h" +#include "qemu/qemu-print.h" +#include "qapi/error.h" +#include "cpu.h" +#include "qemu-common.h" +#include "migration/vmstate.h" +#include "exec/exec-all.h" +#include "hw/loader.h" +#include "fpu/softfloat.h" + +static void rx_cpu_set_pc (CPUState *cs,vaddr value) +{ +RXCPU *cpu =RXCPU (cs); + + cpu->env.pc = value; +} + +static void rx_cpu_synchronize_from_tb (CPUState *cs,TranslationBlock *tb) +{ +RXCPU *cpu =RXCPU (cs); + + cpu->env.pc = tb->pc; +} + +static bool rx_cpu_has_work (CPUState *cs) +{ +return cs->interrupt_request & + (CPU_INTERRUPT_HARD |CPU_INTERRUPT_FIR ); +} + +static void rx_cpu_reset (CPUState *s) +{ +RXCPU *cpu =RXCPU (s); +RXCPUClass *rcc =RXCPU_GET_CLASS (cpu); +CPURXState *env = &cpu->env; +uint32_t *resetvec; + + rcc->parent_reset (s); + +memset (env,0 , offsetof(CPURXState , end_reset_fields)); + + resetvec =rom_ptr (0xfffffffc ,4 ); +if (resetvec) { +/* In the case of kernel, it is ignored because it is not set. */ + env->pc =ldl_p (resetvec); + } +rx_cpu_unpack_psw (env,0 ,1 ); + env->regs[0 ] = env->isp = env->usp =0 ; + env->fpsw =0 ; +set_flush_to_zero (1 , &env->fp_status); +set_flush_inputs_to_zero (1 , &env->fp_status); +} + +static void rx_cpu_list_entry (gpointer data,gpointer user_data) +{ +ObjectClass *oc = data; + +qemu_printf (" %s\n" ,object_class_get_name (oc)); +} + +void rx_cpu_list (void ) +{ +GSList *list; + list =object_class_get_list_sorted (TYPE_RX_CPU , false); +qemu_printf ("Available CPUs:\n" ); +g_slist_foreach (list, rx_cpu_list_entry,NULL ); +g_slist_free (list); +} + +static ObjectClass *rx_cpu_class_by_name (const char *cpu_model) +{ +ObjectClass *oc; +char *typename; + + oc =object_class_by_name (cpu_model); +if (oc !=NULL &&object_class_dynamic_cast (oc,TYPE_RX_CPU ) !=NULL && + !object_class_is_abstract (oc)) { +return oc; + } + typename =g_strdup_printf (RX_CPU_TYPE_NAME ("%s" ), cpu_model); + oc =object_class_by_name (typename); +g_free (typename); +if (oc !=NULL &&object_class_is_abstract (oc)) { + oc =NULL ; + } + +return oc; +} + +static void rx_cpu_realize (DeviceState *dev,Error **errp) +{ +CPUState *cs =CPU (dev); +RXCPUClass *rcc =RXCPU_GET_CLASS (dev); +Error *local_err =NULL ; + +cpu_exec_realizefn (cs, &local_err); +if (local_err !=NULL ) { +error_propagate (errp, local_err); +return ; + } + +qemu_init_vcpu (cs); +cpu_reset (cs); + + rcc->parent_realize (dev, errp); +} + +static void rx_cpu_set_irq (void *opaque,int no,int request) +{ +RXCPU *cpu = opaque; +CPUState *cs =CPU (cpu); +int irq = request &0xff ; + +static const int mask[] = { + [RX_CPU_IRQ ] =CPU_INTERRUPT_HARD , + [RX_CPU_FIR ] =CPU_INTERRUPT_FIR , + }; +if (irq) { + cpu->env.req_irq = irq; + cpu->env.req_ipl = (request >>8 ) &0x0f ; +cpu_interrupt (cs, mask[no]); + }else { +cpu_reset_interrupt (cs, mask[no]); + } +} + +static void rx_cpu_disas_set_info (CPUState *cpu,disassemble_info *info) +{ + info->mach = bfd_mach_rx; + info->print_insn = print_insn_rx; +} + +static bool rx_cpu_tlb_fill (CPUState *cs,vaddr addr,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr) +{ +uint32_t address, physical, prot; + +/* Linear mapping */ + address = physical = addr &TARGET_PAGE_MASK ; + prot =PAGE_READ |PAGE_WRITE |PAGE_EXEC ; +tlb_set_page (cs, address, physical, prot, mmu_idx,TARGET_PAGE_SIZE ); +return true; +} + +static void rx_cpu_init (Object *obj) +{ +CPUState *cs =CPU (obj); +RXCPU *cpu =RXCPU (obj); +CPURXState *env = &cpu->env; + +cpu_set_cpustate_pointers (cpu); + cs->env_ptr = env; +qdev_init_gpio_in (DEVICE (cpu), rx_cpu_set_irq,2 ); +} + +static void rx_cpu_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); +CPUClass *cc =CPU_CLASS (klass); +RXCPUClass *rcc =RXCPU_CLASS (klass); + +device_class_set_parent_realize (dc, rx_cpu_realize, + &rcc->parent_realize); + + rcc->parent_reset = cc->reset; + cc->reset = rx_cpu_reset; + + cc->class_by_name = rx_cpu_class_by_name; + cc->has_work = rx_cpu_has_work; + cc->do_interrupt = rx_cpu_do_interrupt; + cc->cpu_exec_interrupt = rx_cpu_exec_interrupt; + cc->dump_state = rx_cpu_dump_state; + cc->set_pc = rx_cpu_set_pc; + cc->synchronize_from_tb = rx_cpu_synchronize_from_tb; + cc->gdb_read_register = rx_cpu_gdb_read_register; + cc->gdb_write_register = rx_cpu_gdb_write_register; + cc->get_phys_page_debug = rx_cpu_get_phys_page_debug; + cc->disas_set_info = rx_cpu_disas_set_info; + cc->tcg_initialize = rx_translate_init; + cc->tlb_fill = rx_cpu_tlb_fill; + + cc->gdb_num_core_regs =26 ; + cc->gdb_core_xml_file ="rx-core.xml" ; +} + +static const TypeInfo rx_cpu_info = { + .name =TYPE_RX_CPU , + .parent =TYPE_CPU , + .instance_size =sizeof (RXCPU ), + .instance_init = rx_cpu_init, + .abstract = true, + .class_size =sizeof (RXCPUClass), + .class_init = rx_cpu_class_init, +}; + +static const TypeInfo rx62n_rx_cpu_info = { + .name =TYPE_RX62N_CPU , + .parent =TYPE_RX_CPU , +}; + +static void rx_cpu_register_types (void ) +{ +type_register_static (&rx_cpu_info); +type_register_static (&rx62n_rx_cpu_info); +} + +type_init (rx_cpu_register_types)target/rx/gdbstub.c new file +112
-0@@ -0,0 +1,112 @@ +/* +* RX gdb server stub +* +* Copyright (c) 2019 Yoshinori Sato +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2 or later, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see <http://www.gnu.org/licenses/>. +*/ +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "cpu.h" +#include "exec/gdbstub.h" + +int rx_cpu_gdb_read_register (CPUState *cs,uint8_t *mem_buf,int n) +{ +RXCPU *cpu =RXCPU (cs); +CPURXState *env = &cpu->env; + +switch (n) { + case 0 ... 15: +return gdb_get_regl (mem_buf, env->regs[n]); +case 16 : +return gdb_get_regl (mem_buf, (env->psw_u) ? env->regs[0 ] : env->usp); +case 17 : +return gdb_get_regl (mem_buf, (!env->psw_u) ? env->regs[0 ] : env->isp); +case 18 : +return gdb_get_regl (mem_buf,rx_cpu_pack_psw (env)); +case 19 : +return gdb_get_regl (mem_buf, env->pc); +case 20 : +return gdb_get_regl (mem_buf, env->intb); +case 21 : +return gdb_get_regl (mem_buf, env->bpsw); +case 22 : +return gdb_get_regl (mem_buf, env->bpc); +case 23 : +return gdb_get_regl (mem_buf, env->fintv); +case 24 : +return gdb_get_regl (mem_buf, env->fpsw); +case 25 : +return 0 ; + } +return 0 ; +} + +int rx_cpu_gdb_write_register (CPUState *cs,uint8_t *mem_buf,int n) +{ +RXCPU *cpu =RXCPU (cs); +CPURXState *env = &cpu->env; +uint32_t psw; +switch (n) { + case 0 ... 15: + env->regs[n] =ldl_p (mem_buf); +if (n ==0 ) { +if (env->psw_u) { + env->usp = env->regs[0 ]; + }else { + env->isp = env->regs[0 ]; + } + } +break ; +case 16 : + env->usp =ldl_p (mem_buf); +if (env->psw_u) { + env->regs[0 ] =ldl_p (mem_buf); + } +break ; +case 17 : + env->isp =ldl_p (mem_buf); +if (!env->psw_u) { + env->regs[0 ] =ldl_p (mem_buf); + } +break ; +case 18 : + psw =ldl_p (mem_buf); +rx_cpu_unpack_psw (env, psw,1 ); +break ; +case 19 : + env->pc =ldl_p (mem_buf); +break ; +case 20 : + env->intb =ldl_p (mem_buf); +break ; +case 21 : + env->bpsw =ldl_p (mem_buf); +break ; +case 22 : + env->bpc =ldl_p (mem_buf); +break ; +case 23 : + env->fintv =ldl_p (mem_buf); +break ; +case 24 : + env->fpsw =ldl_p (mem_buf); +break ; +case 25 : +return 8 ; +default : +return 0 ; + } + +return 4 ; +}target/rx/translate.c +12
-4@@ -41,10 +41,17 @@ typedef struct DisasCompare {TCGCond cond; } DisasCompare; -const char rx_crname[][6] = { -"psw" ,"pc" ,"usp" ,"fpsw" ,"" ,"" ,"" ,"" , -"bpsw" ,"bpc" ,"isp" ,"fintv" ,"intb" ,"" ,"" ,"" , -}; +const char *rx_crname(uint8_t cr) +{ + static const char *cr_names[] = { +"psw" ,"pc" ,"usp" ,"fpsw" ,"" ,"" ,"" ,"" , +"bpsw" ,"bpc" ,"isp" ,"fintv" ,"intb" ,"" ,"" ,"" + }; +if (cr >=ARRAY_SIZE (cr_names)) { +return "illegal" ; + } +return cr_names[cr]; +}/* Target-specific values for dc->base.is_jmp. */ #define DISAS_JUMP DISAS_TARGET_0@@ -365,7 +372,7 @@ static void move_to_cr(DisasContext *ctx, TCGv val, int cr)if (cr >=8 && !is_privileged (ctx,0 )) {/* Some control registers can only be written in privileged mode. */ qemu_log_mask (LOG_GUEST_ERROR , -"disallow control register write %s" , rx_crname[cr]); +"disallow control register write %s" ,rx_crname (cr));return ; } z =tcg_const_i32 (0 );gdb-xml/rx-core.xml new file +70
-0@@ -0,0 +1,70 @@ +<?xml version="1.0"?> +<!-- Copyright (C) 2019 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. --> + +<!DOCTYPE feature SYSTEM "gdb-target.dtd"> +<feature name="org.gnu.gdb.rx.core"> + <reg name="r0" bitsize="32" type="data_ptr"/> + <reg name="r1" bitsize="32" type="uint32"/> + <reg name="r2" bitsize="32" type="uint32"/> + <reg name="r3" bitsize="32" type="uint32"/> + <reg name="r4" bitsize="32" type="uint32"/> + <reg name="r5" bitsize="32" type="uint32"/> + <reg name="r6" bitsize="32" type="uint32"/> + <reg name="r7" bitsize="32" type="uint32"/> + <reg name="r8" bitsize="32" type="uint32"/> + <reg name="r9" bitsize="32" type="uint32"/> + <reg name="r10" bitsize="32" type="uint32"/> + <reg name="r11" bitsize="32" type="uint32"/> + <reg name="r12" bitsize="32" type="uint32"/> + <reg name="r13" bitsize="32" type="uint32"/> + <reg name="r14" bitsize="32" type="uint32"/> + <reg name="r15" bitsize="32" type="uint32"/> + + <flags id="psw_flags" size="4"> + <field name="C" start="0" end="0"/> + <field name="Z" start="1" end="1"/> + <field name="S" start="2" end="2"/> + <field name="O" start="3" end="3"/> + <field name="I" start="16" end="16"/> + <field name="U" start="17" end="17"/> + <field name="PM" start="20" end="20"/> + <field name="IPL" start="24" end="27"/> + </flags> + + <flags id="fpsw_flags" size="4"> + <field name="RM" start="0" end="1"/> + <field name="CV" start="2" end="2"/> + <field name="CO" start="3" end="3"/> + <field name="CZ" start="4" end="4"/> + <field name="CU" start="5" end="5"/> + <field name="CX" start="6" end="6"/> + <field name="CE" start="7" end="7"/> + <field name="DN" start="8" end="8"/> + <field name="EV" start="10" end="10"/> + <field name="EO" start="11" end="11"/> + <field name="EZ" start="12" end="12"/> + <field name="EU" start="13" end="13"/> + <field name="EX" start="14" end="14"/> + <field name="FV" start="26" end="26"/> + <field name="FO" start="27" end="27"/> + <field name="FZ" start="28" end="28"/> + <field name="FU" start="29" end="29"/> + <field name="FX" start="30" end="30"/> + <field name="FS" start="31" end="31"/> + </flags> + + <reg name="usp" bitsize="32" type="data_ptr"/> + <reg name="isp" bitsize="32" type="data_ptr"/> + <reg name="psw" bitsize="32" type="psw_flags"/> + <reg name="pc" bitsize="32" type="code_ptr"/> + <reg name="intb" bitsize="32" type="data_ptr"/> + <reg name="bpsw" bitsize="32" type="psw_flags"/> + <reg name="bpc" bitsize="32" type="code_ptr"/> + <reg name="fintv" bitsize="32" type="code_ptr"/> + <reg name="fpsw" bitsize="32" type="fpsw_flags"/> + <reg name="acc" bitsize="64" type="uint64"/> +</feature>target/rx/Makefile.objs +0
-1@@ -1,5 +1,4 @@ obj-y += translate.o op_helper.o helper.o cpu.o gdbstub.o disas.o -obj-$(CONFIG_SOFTMMU) += monitor.o DECODETREE = $(SRC_PATH)/scripts/decodetree.py
Signature · 1 line
Yosinori Sato
Re: [PATCH 05/13] target/rx: CPU definitions
In reply to Philippe Mathieu-DaudéQuoted 1 line · Philippe Mathieu-Daudé
+#define
MMU_MODE0_SUFFIX_all
These have been removed.
r~
PATCH 6/13 target/rx: RX disassembler
In reply to Philippe Mathieu-DaudéFrom: Yoshinori Sato <[email protected]>
Message-Id: <[email protected]>
--- include/disas/dis-asm.h | 5 + target/rx/disas.c | 1480 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 1485 insertions(+) create mode 100644 target/rx/disas.c
include/disas/dis-asm.h +5 -0
@@ -226,6 +226,10 @@ enum bfd_architecture#define bfd_mach_nios2r2 2 bfd_arch_lm32, /* Lattice Mico32 */#define bfd_mach_lm32 1 + bfd_arch_rx, /* Renesas RX */ +#define bfd_mach_rx 0x75 +#define bfd_mach_rx_v2 0x76 +#define bfd_mach_rx_v3 0x77 bfd_arch_last };#define bfd_mach_s390_31 31
@@ -436,6 +440,7 @@ int print_insn_little_nios2 (bfd_vma, disassemble_info*);int print_insn_xtensa (bfd_vma ,disassemble_info *);int print_insn_riscv32 (bfd_vma ,disassemble_info *);int print_insn_riscv64 (bfd_vma ,disassemble_info *); +int print_insn_rx (bfd_vma ,disassemble_info *);#if 0 /* Fetch the disassembler for a given BFD, if that support is available. */
target/rx/disas.c new file +1480 -0
1,480 lines not on this page · raw message
Signature · 1 line
2.21.1
PATCH 7/13 target/rx: Disassemble rx_index_addr into a string
In reply to Philippe Mathieu-DaudéFrom: Richard Henderson <[email protected]>
We were eliding all zero indexes. It is only ld==0 that does not have an index in the instruction. This also allows us to avoid breaking the final print into multiple pieces.
Message-Id: <[email protected]>
--- target/rx/disas.c | 154 +++++++++++++++++----------------------------- 1 file changed, 55 insertions(+), 99 deletions(-)
target/rx/disas.c +55 -99
@@ -107,49 +107,42 @@ static const char psw[] = { 'i', 'u', 0, 0, 0, 0, 0, 0, }; -static uint32_t rx_index_addr (int ld,int size,DisasContext *ctx) +static void rx_index_addr (DisasContext *ctx,char out[8 ],int ld,int mi) { -bfd_byte buf[2 ]; +uint32_t addr = ctx->addr; +uint8_t buf[2 ]; +uint16_t dsp; +switch (ld) {case 0 : -return 0 ; +/* No index; return empty string. */ + out[0 ] ='\0' ; +return ;case 1 : - ctx->dis->read_memory_func (ctx->addr, buf,1 , ctx->dis); ctx->addr +=1 ; -return ((uint8_t )buf[0 ]) << size; + ctx->dis->read_memory_func (addr, buf,1 , ctx->dis); + dsp = buf[0 ]; +break ;case 2 : - ctx->dis->read_memory_func (ctx->addr, buf,2 , ctx->dis); ctx->addr +=2 ; -return lduw_le_p (buf) << size; + ctx->dis->read_memory_func (addr, buf,2 , ctx->dis); + dsp =lduw_le_p (buf); +break ; +default : +g_assert_not_reached (); } -g_assert_not_reached (); + +sprintf (out,"%u" , dsp << (mi <3 ? mi :4 - mi)); }static void operand (DisasContext *ctx,int ld,int mi,int rs,int rd) { -int dsp;static const char sizes[][4 ] = {".b" ,".w" ,".l" ,".uw" ,".ub" }; +char dsp[8 ]; +if (ld <3 ) { -switch (mi) { -case 4 : -/* dsp[rs].ub */ - dsp =rx_index_addr (ld,RX_MEMORY_BYTE , ctx); -break ; -case 3 : -/* dsp[rs].uw */ - dsp =rx_index_addr (ld,RX_MEMORY_WORD , ctx); -break ; -default : -/* dsp[rs].b */ -/* dsp[rs].w */ -/* dsp[rs].l */ - dsp =rx_index_addr (ld, mi, ctx); -break ; - } -if (dsp >0 ) { -prt ("%d" , dsp); - } -prt ("[r%d]%s" , rs, sizes[mi]); +rx_index_addr (ctx, dsp, ld, mi); +prt ("%s[r%d]%s" , dsp, rs, sizes[mi]); }else {prt ("r%d" , rs); }
@@ -235,7 +228,7 @@ static bool trans_MOV_ra(DisasContext *ctx, arg_MOV_ra *a)/* mov.[bwl] rs,rd */ static bool trans_MOV_mm (DisasContext *ctx,arg_MOV_mm *a) { -int dsp; +char dspd[8 ], dsps[8 ];prt ("mov.%c\t" , size[a->sz]);if (a->lds ==3 && a->ldd ==3 ) {
@@ -244,29 +237,15 @@ static bool trans_MOV_mm(DisasContext *ctx, arg_MOV_mm *a)return true; }if (a->lds ==3 ) { -prt ("r%d, " , a->rd); - dsp =rx_index_addr (a->ldd, a->sz, ctx); -if (dsp >0 ) { -prt ("%d" , dsp); - } -prt ("[r%d]" , a->rs); +rx_index_addr (ctx, dspd, a->ldd, a->sz); +prt ("r%d, %s[r%d]" , a->rs, dspd, a->rd); }else if (a->ldd ==3 ) { - dsp =rx_index_addr (a->lds, a->sz, ctx); -if (dsp >0 ) { -prt ("%d" , dsp); - } -prt ("[r%d], r%d" , a->rs, a->rd); +rx_index_addr (ctx, dsps, a->lds, a->sz); +prt ("%s[r%d], r%d" , dsps, a->rs, a->rd); }else { - dsp =rx_index_addr (a->lds, a->sz, ctx); -if (dsp >0 ) { -prt ("%d" , dsp); - } -prt ("[r%d], " , a->rs); - dsp =rx_index_addr (a->ldd, a->sz, ctx); -if (dsp >0 ) { -prt ("%d" , dsp); - } -prt ("[r%d]" , a->rd); +rx_index_addr (ctx, dsps, a->lds, a->sz); +rx_index_addr (ctx, dspd, a->ldd, a->sz); +prt ("%s[r%d], %s[r%d]" , dsps, a->rs, dspd, a->rd); }return true; }
@@ -357,12 +336,10 @@ static bool trans_PUSH_r(DisasContext *ctx, arg_PUSH_r *a)/* push dsp[rs] */ static bool trans_PUSH_m (DisasContext *ctx,arg_PUSH_m *a) { -prt ("push\t" ); -int dsp =rx_index_addr (a->ld, a->sz, ctx); -if (dsp >0 ) { -prt ("%d" , dsp); - } -prt ("[r%d]" , a->rs); +char dsp[8 ]; + +rx_index_addr (ctx, dsp, a->ld, a->sz); +prt ("push\t%s[r%d]" , dsp, a->rs);return true; }
@@ -389,17 +366,13 @@ static bool trans_XCHG_rr(DisasContext *ctx, arg_XCHG_rr *a)/* xchg dsp[rs].<mi>,rd */ static bool trans_XCHG_mr (DisasContext *ctx,arg_XCHG_mr *a) { -int dsp;static const char msize[][4 ] = {"b" ,"w" ,"l" ,"ub" ,"uw" , }; +char dsp[8 ]; -prt ("xchg\t" ); - dsp =rx_index_addr (a->ld, a->mi, ctx); -if (dsp >0 ) { -prt ("%d" , dsp); - } -prt ("[r%d].%s, r%d" , a->rs, msize[a->mi], a->rd); +rx_index_addr (ctx, dsp, a->ld, a->mi); +prt ("xchg\t%s[r%d].%s, r%d" , dsp, a->rs, msize[a->mi], a->rd);return true; }
@@ -552,13 +525,10 @@ static bool trans_ADC_rr(DisasContext *ctx, arg_ADC_rr *a)/* adc dsp[rs], rd */ static bool trans_ADC_mr (DisasContext *ctx,arg_ADC_mr *a) { -int dsp; -prt ("adc\t" ); - dsp =rx_index_addr (a->ld,2 , ctx); -if (dsp >0 ) { -prt ("%d" , dsp); - } -prt ("[r%d], r%d" , a->rs, a->rd); +char dsp[8 ]; + +rx_index_addr (ctx, dsp, a->ld,2 ); +prt ("adc\t%s[r%d], r%d" , dsp, a->rs, a->rd);return true; }
@@ -1217,25 +1187,17 @@ static bool trans_ITOF(DisasContext *ctx, arg_ITOF *a)#define BOP_IM (name, reg) \ do { \ - int dsp; \ - prt("b%s\t#%d, ", #name, a->imm); \ - dsp = rx_index_addr(a->ld, RX_MEMORY_BYTE, ctx); \ - if (dsp > 0) { \ - prt("%d", dsp); \ - } \ - prt("[r%d]", reg); \ + char dsp[8]; \ + rx_index_addr(ctx, dsp, a->ld, RX_MEMORY_BYTE); \ + prt("b%s\t#%d, %s[r%d]", #name, a->imm, dsp, reg); \ return true; \ } while (0)#define BOP_RM (name) \ do { \ - int dsp; \ - prt("b%s\tr%d, ", #name, a->rd); \ - dsp = rx_index_addr(a->ld, RX_MEMORY_BYTE, ctx); \ - if (dsp > 0) { \ - prt("%d", dsp); \ - } \ - prt("[r%d]", a->rs); \ + char dsp[8]; \ + rx_index_addr(ctx, dsp, a->ld, RX_MEMORY_BYTE); \ + prt("b%s\tr%d, %s[r%d]", #name, a->rd, dsp, a->rs); \ return true; \ } while (0)
@@ -1346,12 +1308,10 @@ static bool trans_BNOT_ir(DisasContext *ctx, arg_BNOT_ir *a)/* bmcond #imm, dsp[rd] */ static bool trans_BMCnd_im (DisasContext *ctx,arg_BMCnd_im *a) { -int dsp =rx_index_addr (a->ld,RX_MEMORY_BYTE , ctx); -prt ("bm%s\t#%d, " , cond[a->cd], a->imm); -if (dsp >0 ) { -prt ("%d" , dsp); - } -prt ("[%d]" , a->rd); +char dsp[8 ]; + +rx_index_addr (ctx, dsp, a->ld,RX_MEMORY_BYTE ); +prt ("bm%s\t#%d, %s[r%d]" , cond[a->cd], a->imm, dsp, a->rd);return true; }
@@ -1443,16 +1403,12 @@ static bool trans_WAIT(DisasContext *ctx, arg_WAIT *a)/* sccnd.[bwl] dsp:[rd] */ static bool trans_SCCnd (DisasContext *ctx,arg_SCCnd *a) { -int dsp; -prt ("sc%s.%c\t" , cond[a->cd], size[a->sz]);if (a->ld <3 ) { - dsp =rx_index_addr (a->sz, a->ld, ctx); -if (dsp >0 ) { -prt ("%d" , dsp); - } -prt ("[r%d]" , a->rd); +char dsp[8 ]; +rx_index_addr (ctx, dsp, a->sz, a->ld); +prt ("sc%s.%c\t%s[r%d]" , cond[a->cd], size[a->sz], dsp, a->rd); }else { -prt ("r%d" , a->rd); +prt ("sc%s.%c\tr%d" , cond[a->cd], size[a->sz], a->rd); }return true; }
Signature · 1 line
2.21.1
PATCH 8/13 target/rx: Replace operand with prt_ldmi in disassembler
In reply to Philippe Mathieu-DaudéFrom: Richard Henderson <[email protected]>
This has consistency with prt_ri(). It loads all data before beginning output. It uses exactly one call to prt() to emit the full instruction.
Message-Id: <[email protected]>
--- target/rx/disas.c | 77 +++++++++++++++++------------------------------ 1 file changed, 27 insertions(+), 50 deletions(-)
target/rx/disas.c +27 -50
@@ -135,18 +135,18 @@ static void rx_index_addr(DisasContext *ctx, char out[8], int ld, int mi)sprintf (out,"%u" , dsp << (mi <3 ? mi :4 - mi)); } -static void operand (DisasContext *ctx,int ld,int mi,int rs,int rd) +static void prt_ldmi (DisasContext *ctx,const char *insn, +int ld,int mi,int rs,int rd) {static const char sizes[][4 ] = {".b" ,".w" ,".l" ,".uw" ,".ub" };char dsp[8 ];if (ld <3 ) {rx_index_addr (ctx, dsp, ld, mi); -prt ("%s[r%d]%s" , dsp, rs, sizes[mi]); +prt ("%s\t%s[r%d]%s, r%d" , insn, dsp, rs, sizes[mi], rd); }else { -prt ("r%d" , rs); +prt ("%s\tr%d, r%d" , insn, rs, rd); } -prt (", r%d" , rd); }static void prt_ir (DisasContext *ctx,const char *insn,int imm,int rd)
@@ -416,8 +416,7 @@ static bool trans_AND_ir(DisasContext *ctx, arg_AND_ir *a)/* and rs,rd */ static bool trans_AND_mr (DisasContext *ctx,arg_AND_mr *a) { -prt ("and\t" ); -operand (ctx, a->ld, a->mi, a->rs, a->rd); +prt_ldmi (ctx,"and" , a->ld, a->mi, a->rs, a->rd);return true; }
@@ -440,8 +439,7 @@ static bool trans_OR_ir(DisasContext *ctx, arg_OR_ir *a)/* or rs,rd */ static bool trans_OR_mr (DisasContext *ctx,arg_OR_mr *a) { -prt ("or\t" ); -operand (ctx, a->ld, a->mi, a->rs, a->rd); +prt_ldmi (ctx,"or" , a->ld, a->mi, a->rs, a->rd);return true; }
@@ -463,8 +461,7 @@ static bool trans_XOR_ir(DisasContext *ctx, arg_XOR_ir *a)/* xor rs,rd */ static bool trans_XOR_mr (DisasContext *ctx,arg_XOR_mr *a) { -prt ("xor\t" ); -operand (ctx, a->ld, a->mi, a->rs, a->rd); +prt_ldmi (ctx,"xor" , a->ld, a->mi, a->rs, a->rd);return true; }
@@ -479,8 +476,7 @@ static bool trans_TST_ir(DisasContext *ctx, arg_TST_ir *a)/* tst rs, rd */ static bool trans_TST_mr (DisasContext *ctx,arg_TST_mr *a) { -prt ("tst\t" ); -operand (ctx, a->ld, a->mi, a->rs, a->rd); +prt_ldmi (ctx,"tst" , a->ld, a->mi, a->rs, a->rd);return true; }
@@ -548,8 +544,7 @@ static bool trans_ADD_irr(DisasContext *ctx, arg_ADD_irr *a)/* add dsp[rs], rd */ static bool trans_ADD_mr (DisasContext *ctx,arg_ADD_mr *a) { -prt ("add\t" ); -operand (ctx, a->ld, a->mi, a->rs, a->rd); +prt_ldmi (ctx,"add" , a->ld, a->mi, a->rs, a->rd);return true; }
@@ -573,8 +568,7 @@ static bool trans_CMP_ir(DisasContext *ctx, arg_CMP_ir *a)/* cmp dsp[rs], rs2 */ static bool trans_CMP_mr (DisasContext *ctx,arg_CMP_mr *a) { -prt ("cmp\t" ); -operand (ctx, a->ld, a->mi, a->rs, a->rd); +prt_ldmi (ctx,"cmp" , a->ld, a->mi, a->rs, a->rd);return true; }
@@ -589,8 +583,7 @@ static bool trans_SUB_ir(DisasContext *ctx, arg_SUB_ir *a)/* sub dsp[rs], rd */ static bool trans_SUB_mr (DisasContext *ctx,arg_SUB_mr *a) { -prt ("sub\t" ); -operand (ctx, a->ld, a->mi, a->rs, a->rd); +prt_ldmi (ctx,"sub" , a->ld, a->mi, a->rs, a->rd);return true; }
@@ -611,8 +604,7 @@ static bool trans_SBB_rr(DisasContext *ctx, arg_SBB_rr *a)/* sbb dsp[rs], rd */ static bool trans_SBB_mr (DisasContext *ctx,arg_SBB_mr *a) { -prt ("sbb\t" ); -operand (ctx, a->ld,RX_IM_LONG , a->rs, a->rd); +prt_ldmi (ctx,"sbb" , a->ld,RX_IM_LONG , a->rs, a->rd);return true; }
@@ -640,8 +632,7 @@ static bool trans_MAX_ir(DisasContext *ctx, arg_MAX_ir *a)/* max dsp[rs], rd */ static bool trans_MAX_mr (DisasContext *ctx,arg_MAX_mr *a) { -prt ("max\t" ); -operand (ctx, a->ld, a->mi, a->rs, a->rd); +prt_ldmi (ctx,"max" , a->ld, a->mi, a->rs, a->rd);return true; }
@@ -656,8 +647,7 @@ static bool trans_MIN_ir(DisasContext *ctx, arg_MIN_ir *a)/* min dsp[rs], rd */ static bool trans_MIN_mr (DisasContext *ctx,arg_MIN_mr *a) { -prt ("max\t" ); -operand (ctx, a->ld, a->mi, a->rs, a->rd); +prt_ldmi (ctx,"min" , a->ld, a->mi, a->rs, a->rd);return true; }
@@ -673,8 +663,7 @@ static bool trans_MUL_ir(DisasContext *ctx, arg_MUL_ir *a)/* mul dsp[rs], rd */ static bool trans_MUL_mr (DisasContext *ctx,arg_MUL_mr *a) { -prt ("mul\t" ); -operand (ctx, a->ld, a->mi, a->rs, a->rd); +prt_ldmi (ctx,"mul" , a->ld, a->mi, a->rs, a->rd);return true; }
@@ -696,8 +685,7 @@ static bool trans_EMUL_ir(DisasContext *ctx, arg_EMUL_ir *a)/* emul dsp[rs], rd */ static bool trans_EMUL_mr (DisasContext *ctx,arg_EMUL_mr *a) { -prt ("emul\t" ); -operand (ctx, a->ld, a->mi, a->rs, a->rd); +prt_ldmi (ctx,"emul" , a->ld, a->mi, a->rs, a->rd);return true; }
@@ -712,8 +700,7 @@ static bool trans_EMULU_ir(DisasContext *ctx, arg_EMULU_ir *a)/* emulu dsp[rs], rd */ static bool trans_EMULU_mr (DisasContext *ctx,arg_EMULU_mr *a) { -prt ("emulu\t" ); -operand (ctx, a->ld, a->mi, a->rs, a->rd); +prt_ldmi (ctx,"emulu" , a->ld, a->mi, a->rs, a->rd);return true; }
@@ -728,8 +715,7 @@ static bool trans_DIV_ir(DisasContext *ctx, arg_DIV_ir *a)/* div dsp[rs], rd */ static bool trans_DIV_mr (DisasContext *ctx,arg_DIV_mr *a) { -prt ("div\t" ); -operand (ctx, a->ld, a->mi, a->rs, a->rd); +prt_ldmi (ctx,"div" , a->ld, a->mi, a->rs, a->rd);return true; }
@@ -744,8 +730,7 @@ static bool trans_DIVU_ir(DisasContext *ctx, arg_DIVU_ir *a)/* divu dsp[rs], rd */ static bool trans_DIVU_mr (DisasContext *ctx,arg_DIVU_mr *a) { -prt ("divu\t" ); -operand (ctx, a->ld, a->mi, a->rs, a->rd); +prt_ldmi (ctx,"divu" , a->ld, a->mi, a->rs, a->rd);return true; }
@@ -1089,8 +1074,7 @@ static bool trans_FADD_ir(DisasContext *ctx, arg_FADD_ir *a)/* fadd rs, rd */ static bool trans_FADD_mr (DisasContext *ctx,arg_FADD_mr *a) { -prt ("fadd\t" ); -operand (ctx, a->ld,RX_IM_LONG , a->rs, a->rd); +prt_ldmi (ctx,"fadd" , a->ld,RX_IM_LONG , a->rs, a->rd);return true; }
@@ -1105,8 +1089,7 @@ static bool trans_FCMP_ir(DisasContext *ctx, arg_FCMP_ir *a)/* fcmp rs, rd */ static bool trans_FCMP_mr (DisasContext *ctx,arg_FCMP_mr *a) { -prt ("fcmp\t" ); -operand (ctx, a->ld,RX_IM_LONG , a->rs, a->rd); +prt_ldmi (ctx,"fcmp" , a->ld,RX_IM_LONG , a->rs, a->rd);return true; }
@@ -1121,8 +1104,7 @@ static bool trans_FSUB_ir(DisasContext *ctx, arg_FSUB_ir *a)/* fsub rs, rd */ static bool trans_FSUB_mr (DisasContext *ctx,arg_FSUB_mr *a) { -prt ("fsub\t" ); -operand (ctx, a->ld,RX_IM_LONG , a->rs, a->rd); +prt_ldmi (ctx,"fsub" , a->ld,RX_IM_LONG , a->rs, a->rd);return true; }
@@ -1130,8 +1112,7 @@ static bool trans_FSUB_mr(DisasContext *ctx, arg_FSUB_mr *a)/* ftoi rs, rd */ static bool trans_FTOI (DisasContext *ctx,arg_FTOI *a) { -prt ("ftoi\t" ); -operand (ctx, a->ld,RX_IM_LONG , a->rs, a->rd); +prt_ldmi (ctx,"ftoi" , a->ld,RX_IM_LONG , a->rs, a->rd);return true; }
@@ -1146,8 +1127,7 @@ static bool trans_FMUL_ir(DisasContext *ctx, arg_FMUL_ir *a)/* fmul rs, rd */ static bool trans_FMUL_mr (DisasContext *ctx,arg_FMUL_mr *a) { -prt ("fmul\t" ); -operand (ctx, a->ld,RX_IM_LONG , a->rs, a->rd); +prt_ldmi (ctx,"fmul" , a->ld,RX_IM_LONG , a->rs, a->rd);return true; }
@@ -1162,8 +1142,7 @@ static bool trans_FDIV_ir(DisasContext *ctx, arg_FDIV_ir *a)/* fdiv rs, rd */ static bool trans_FDIV_mr (DisasContext *ctx,arg_FDIV_mr *a) { -prt ("fdiv\t" ); -operand (ctx, a->ld,RX_IM_LONG , a->rs, a->rd); +prt_ldmi (ctx,"fdiv" , a->ld,RX_IM_LONG , a->rs, a->rd);return true; }
@@ -1171,8 +1150,7 @@ static bool trans_FDIV_mr(DisasContext *ctx, arg_FDIV_mr *a)/* round rs, rd */ static bool trans_ROUND (DisasContext *ctx,arg_ROUND *a) { -prt ("round\t" ); -operand (ctx, a->ld,RX_IM_LONG , a->rs, a->rd); +prt_ldmi (ctx,"round" , a->ld,RX_IM_LONG , a->rs, a->rd);return true; }
@@ -1180,8 +1158,7 @@ static bool trans_ROUND(DisasContext *ctx, arg_ROUND *a)/* itof dsp[rs], rd */ static bool trans_ITOF (DisasContext *ctx,arg_ITOF *a) { -prt ("itof\t" ); -operand (ctx, a->ld,RX_IM_LONG , a->rs, a->rd); +prt_ldmi (ctx,"itof" , a->ld,RX_IM_LONG , a->rs, a->rd);return true; }
Signature · 1 line
2.21.1
PATCH 9/13 target/rx: Use prt_ldmi for XCHG_mr disassembly
In reply to Philippe Mathieu-DaudéFrom: Richard Henderson <[email protected]>
Note that the ld == 3 case handled by prt_ldmi is decoded as XCHG_rr and cannot appear here.
Message-Id: <[email protected]>
--- target/rx/disas.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
target/rx/disas.c +1 -7
@@ -366,13 +366,7 @@ static bool trans_XCHG_rr(DisasContext *ctx, arg_XCHG_rr *a)/* xchg dsp[rs].<mi>,rd */ static bool trans_XCHG_mr (DisasContext *ctx,arg_XCHG_mr *a) { -static const char msize[][4 ] = { -"b" ,"w" ,"l" ,"ub" ,"uw" , - }; -char dsp[8 ]; - -rx_index_addr (ctx, dsp, a->ld, a->mi); -prt ("xchg\t%s[r%d].%s, r%d" , dsp, a->rs, msize[a->mi], a->rd); +prt_ldmi (ctx,"xchg" , a->ld, a->mi, a->rs, a->rd);return true; }
Signature · 1 line
2.21.1
PATCH 10/13 target/rx: Emit all disassembly in one prt()
In reply to Philippe Mathieu-DaudéFrom: Richard Henderson <[email protected]>
Many of the multi-part prints have been eliminated by previous patches. Eliminate the rest of them.
Message-Id: <[email protected]>
--- target/rx/disas.c | 75 ++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 36 deletions(-)
target/rx/disas.c +39 -36
@@ -228,24 +228,21 @@ static bool trans_MOV_ra(DisasContext *ctx, arg_MOV_ra *a)/* mov.[bwl] rs,rd */ static bool trans_MOV_mm (DisasContext *ctx,arg_MOV_mm *a) { -char dspd[8 ], dsps[8 ]; +char dspd[8 ], dsps[8 ], szc = size[a->sz]; -prt ("mov.%c\t" , size[a->sz]);if (a->lds ==3 && a->ldd ==3 ) {/* mov.[bwl] rs,rd */ -prt ("r%d, r%d" , a->rs, a->rd); -return true; - } -if (a->lds ==3 ) { +prt ("mov.%c\tr%d, r%d" , szc, a->rs, a->rd); + }else if (a->lds ==3 ) {rx_index_addr (ctx, dspd, a->ldd, a->sz); -prt ("r%d, %s[r%d]" , a->rs, dspd, a->rd); +prt ("mov.%c\tr%d, %s[r%d]" , szc, a->rs, dspd, a->rd); }else if (a->ldd ==3 ) {rx_index_addr (ctx, dsps, a->lds, a->sz); -prt ("%s[r%d], r%d" , dsps, a->rs, a->rd); +prt ("mov.%c\t%s[r%d], r%d" , szc, dsps, a->rs, a->rd); }else {rx_index_addr (ctx, dsps, a->lds, a->sz);rx_index_addr (ctx, dspd, a->ldd, a->sz); -prt ("%s[r%d], %s[r%d]" , dsps, a->rs, dspd, a->rd); +prt ("mov.%c\t%s[r%d], %s[r%d]" , szc, dsps, a->rs, dspd, a->rd); }return true; }
@@ -254,8 +251,11 @@ static bool trans_MOV_mm(DisasContext *ctx, arg_MOV_mm *a)/* mov.[bwl] rs,[-rd] */ static bool trans_MOV_rp (DisasContext *ctx,arg_MOV_rp *a) { -prt ("mov.%c\tr%d, " , size[a->sz], a->rs); -prt ((a->ad ==0 ) ?"[r%d+]" :"[-r%d]" , a->rd); +if (a->ad) { +prt ("mov.%c\tr%d, [-r%d]" , size[a->sz], a->rs, a->rd); + }else { +prt ("mov.%c\tr%d, [r%d+]" , size[a->sz], a->rs, a->rd); + }return true; }
@@ -263,9 +263,11 @@ static bool trans_MOV_rp(DisasContext *ctx, arg_MOV_rp *a)/* mov.[bwl] [-rd],rs */ static bool trans_MOV_pr (DisasContext *ctx,arg_MOV_pr *a) { -prt ("mov.%c\t" , size[a->sz]); -prt ((a->ad ==0 ) ?"[r%d+]" :"[-r%d]" , a->rd); -prt (", r%d" , a->rs); +if (a->ad) { +prt ("mov.%c\t[-r%d], r%d" , size[a->sz], a->rd, a->rs); + }else { +prt ("mov.%c\t[r%d+], r%d" , size[a->sz], a->rd, a->rs); + }return true; }
@@ -299,9 +301,11 @@ static bool trans_MOVU_ar(DisasContext *ctx, arg_MOVU_ar *a)/* movu.[bw] [-rs],rd */ static bool trans_MOVU_pr (DisasContext *ctx,arg_MOVU_pr *a) { -prt ("movu.%c\t" , size[a->sz]); -prt ((a->ad ==0 ) ?"[r%d+]" :"[-r%d]" , a->rd); -prt (", r%d" , a->rs); +if (a->ad) { +prt ("movu.%c\t[-r%d], r%d" , size[a->sz], a->rd, a->rs); + }else { +prt ("movu.%c\t[r%d+], r%d" , size[a->sz], a->rd, a->rs); + }return true; }
@@ -478,11 +482,11 @@ static bool trans_TST_mr(DisasContext *ctx, arg_TST_mr *a)/* not rs, rd */ static bool trans_NOT_rr (DisasContext *ctx,arg_NOT_rr *a) { -prt ("not\t" );if (a->rs != a->rd) { -prt ("r%d, " , a->rs); +prt ("not\tr%d, r%d" , a->rs, a->rd); + }else { +prt ("not\tr%d" , a->rs); } -prt ("r%d" , a->rd);return true; }
@@ -490,11 +494,11 @@ static bool trans_NOT_rr(DisasContext *ctx, arg_NOT_rr *a)/* neg rs, rd */ static bool trans_NEG_rr (DisasContext *ctx,arg_NEG_rr *a) { -prt ("neg\t" );if (a->rs != a->rd) { -prt ("r%d, " , a->rs); +prt ("neg\tr%d, r%d" , a->rs, a->rd); + }else { +prt ("neg\tr%d" , a->rs); } -prt ("r%d" , a->rd);return true; }
@@ -606,11 +610,10 @@ static bool trans_SBB_mr(DisasContext *ctx, arg_SBB_mr *a)/* abs rs, rd */ static bool trans_ABS_rr (DisasContext *ctx,arg_ABS_rr *a) { -prt ("abs\t" ); -if (a->rs == a->rd) { -prt ("r%d" , a->rd); +if (a->rs != a->rd) { +prt ("abs\tr%d, r%d" , a->rs, a->rd); }else { -prt ("r%d, r%d" , a->rs, a->rd); +prt ("abs\tr%d" , a->rs); }return true; }
@@ -733,11 +736,11 @@ static bool trans_DIVU_mr(DisasContext *ctx, arg_DIVU_mr *a)/* shll #imm:5, rs, rd */ static bool trans_SHLL_irr (DisasContext *ctx,arg_SHLL_irr *a) { -prt ("shll\t#%d, " , a->imm);if (a->rs2 != a->rd) { -prt ("r%d, " , a->rs2); +prt ("shll\t#%d, r%d, r%d" , a->imm, a->rs2, a->rd); + }else { +prt ("shll\t#%d, r%d" , a->imm, a->rd); } -prt ("r%d" , a->rd);return true; }
@@ -752,11 +755,11 @@ static bool trans_SHLL_rr(DisasContext *ctx, arg_SHLL_rr *a)/* shar #imm:5, rs, rd */ static bool trans_SHAR_irr (DisasContext *ctx,arg_SHAR_irr *a) { -prt ("shar\t#%d," , a->imm);if (a->rs2 != a->rd) { -prt ("r%d, " , a->rs2); +prt ("shar\t#%d, r%d, r%d" , a->imm, a->rs2, a->rd); + }else { +prt ("shar\t#%d, r%d" , a->imm, a->rd); } -prt ("r%d" , a->rd);return true; }
@@ -771,11 +774,11 @@ static bool trans_SHAR_rr(DisasContext *ctx, arg_SHAR_rr *a)/* shlr #imm:5, rs, rd */ static bool trans_SHLR_irr (DisasContext *ctx,arg_SHLR_irr *a) { -prt ("shlr\t#%d, " , a->imm);if (a->rs2 != a->rd) { -prt ("r%d, " , a->rs2); +prt ("shlr\t#%d, r%d, r%d" , a->imm, a->rs2, a->rd); + }else { +prt ("shlr\t#%d, r%d" , a->imm, a->rd); } -prt ("r%d" , a->rd);return true; }
Signature · 1 line
2.21.1
PATCH 11/13 target/rx: Collect all bytes during disassembly
In reply to Philippe Mathieu-DaudéFrom: Richard Henderson <[email protected]>
Collected, to be used in the next patch.
Message-Id: <[email protected]>
--- target/rx/disas.c | 62 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 20 deletions(-)
target/rx/disas.c +42 -20
@@ -25,43 +25,59 @@ typedef struct DisasContext {disassemble_info *dis;uint32_t addr;uint32_t pc; +uint8_t len; +uint8_t bytes[8 ]; } DisasContext;static uint32_t decode_load_bytes (DisasContext *ctx,uint32_t insn, -int i,int n) +int i,int n) { -bfd_byte buf; +uint32_t addr = ctx->addr; + +g_assert (ctx->len == i); +g_assert (n <=ARRAY_SIZE (ctx->bytes)); +while (++i <= n) { - ctx->dis->read_memory_func (ctx->addr++, &buf,1 , ctx->dis); - insn |= buf << (32 - i *8 ); + ctx->dis->read_memory_func (addr++, &ctx->bytes[i -1 ],1 , ctx->dis); + insn |= ctx->bytes[i -1 ] << (32 - i *8 ); } + ctx->addr = addr; + ctx->len = n; +return insn; }static int32_t li (DisasContext *ctx,int sz) { -int32_t addr; -bfd_byte buf[4 ]; - addr = ctx->addr; +uint32_t addr = ctx->addr; +uintptr_t len = ctx->len;switch (sz) {case 1 : +g_assert (len +1 <=ARRAY_SIZE (ctx->bytes)); ctx->addr +=1 ; - ctx->dis->read_memory_func (addr, buf,1 , ctx->dis); -return (int8_t )buf[0 ]; + ctx->len +=1 ; + ctx->dis->read_memory_func (addr, ctx->bytes + len,1 , ctx->dis); +return (int8_t )ctx->bytes[len];case 2 : +g_assert (len +2 <=ARRAY_SIZE (ctx->bytes)); ctx->addr +=2 ; - ctx->dis->read_memory_func (addr, buf,2 , ctx->dis); -return ldsw_le_p (buf); + ctx->len +=2 ; + ctx->dis->read_memory_func (addr, ctx->bytes + len,2 , ctx->dis); +return ldsw_le_p (ctx->bytes + len);case 3 : +g_assert (len +3 <=ARRAY_SIZE (ctx->bytes)); ctx->addr +=3 ; - ctx->dis->read_memory_func (addr, buf,3 , ctx->dis); -return (int8_t )buf[2 ] <<16 |lduw_le_p (buf); + ctx->len +=3 ; + ctx->dis->read_memory_func (addr, ctx->bytes + len,3 , ctx->dis); +return (int8_t )ctx->bytes[len +2 ] <<16 |lduw_le_p (ctx->bytes + len);case 0 : +g_assert (len +4 <=ARRAY_SIZE (ctx->bytes)); ctx->addr +=4 ; - ctx->dis->read_memory_func (addr, buf,4 , ctx->dis); -return ldl_le_p (buf); + ctx->len +=4 ; + ctx->dis->read_memory_func (addr, ctx->bytes + len,4 , ctx->dis); +return ldl_le_p (ctx->bytes + len);default :g_assert_not_reached (); }
@@ -110,7 +126,7 @@ static const char psw[] = {static void rx_index_addr (DisasContext *ctx,char out[8 ],int ld,int mi) {uint32_t addr = ctx->addr; -uint8_t buf[2 ]; +uintptr_t len = ctx->len;uint16_t dsp;switch (ld) {
@@ -119,14 +135,18 @@ static void rx_index_addr(DisasContext *ctx, char out[8], int ld, int mi) out[0 ] ='\0' ;return ;case 1 : +g_assert (len +1 <=ARRAY_SIZE (ctx->bytes)); ctx->addr +=1 ; - ctx->dis->read_memory_func (addr, buf,1 , ctx->dis); - dsp = buf[0 ]; + ctx->len +=1 ; + ctx->dis->read_memory_func (addr, ctx->bytes + len,1 , ctx->dis); + dsp = ctx->bytes[len];break ;case 2 : +g_assert (len +2 <=ARRAY_SIZE (ctx->bytes)); ctx->addr +=2 ; - ctx->dis->read_memory_func (addr, buf,2 , ctx->dis); - dsp =lduw_le_p (buf); + ctx->len +=2 ; + ctx->dis->read_memory_func (addr, ctx->bytes + len,2 , ctx->dis); + dsp =lduw_le_p (ctx->bytes + len);break ;default :g_assert_not_reached ();
@@ -1392,8 +1412,10 @@ int print_insn_rx(bfd_vma addr, disassemble_info *dis)DisasContext ctx;uint32_t insn;int i; + ctx.dis = dis; ctx.pc = ctx.addr = addr; + ctx.len =0 ; insn =decode_load (&ctx);if (!decode (&ctx, insn)) {
Signature · 1 line
2.21.1
PATCH 12/13 target/rx: Dump bytes for each insn during disassembly
In reply to Philippe Mathieu-DaudéFrom: Richard Henderson <[email protected]>
There are so many different forms of each RX instruction that it will be very useful to be able to look at the bytes to see on which path a bug may lie.
Message-Id: <[email protected]>
--- target/rx/disas.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
target/rx/disas.c +15 -1
@@ -102,7 +102,21 @@ static int bdsp_s(DisasContext *ctx, int d)/* Include the auto-generated decoder. */ #include "decode.inc.c" -#define prt (...) (ctx->dis->fprintf_func)((ctx->dis->stream), __VA_ARGS__) +static void dump_bytes (DisasContext *ctx) +{ +int i, len = ctx->len; + +for (i =0 ; i < len; ++i) { + ctx->dis->fprintf_func (ctx->dis->stream,"%02x " , ctx->bytes[i]); + } + ctx->dis->fprintf_func (ctx->dis->stream,"%*c" , (8 - i) *3 ,'\t' ); +} + +#define prt (...) \ + do { \ + dump_bytes(ctx); \ + ctx->dis->fprintf_func(ctx->dis->stream, __VA_ARGS__); \ + } while (0)#define RX_MEMORY_BYTE 0#define RX_MEMORY_WORD 1
Signature · 1 line
2.21.1
PATCH 13/13 Add rx-softmmu
In reply to Philippe Mathieu-DaudéFrom: Yoshinori Sato <[email protected]>
[PMD: Squashed patches from Richard Henderson modifying
qapi/common.json and tests/machine-none-test.c]
Message-Id: <[email protected]>
--- configure | 11 ++++++++++- default-configs/rx-softmmu.mak | 2 ++ qapi/machine.json | 4 +++- include/exec/poison.h | 1 + include/sysemu/arch_init.h | 1 + arch_init.c | 2 ++ tests/qtest/machine-none-test.c | 1 + 7 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 default-configs/rx-softmmu.mak
configure +10 -1
@@ -4184,7 +4184,7 @@ fi fdt_required=no for target in $target_list; do case $target in - aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu|riscv*-softmmu) + aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu|riscv*-softmmu|rx-softmmu) fdt_required=yes ;; esac
@@ -7881,6 +7881,12 @@ case "$target_name" in mttcg=yes gdb_xml_files="riscv-64bit-cpu.xml riscv-32bit-fpu.xml riscv-64bit-fpu.xml riscv-64bit-csr.xml riscv-64bit-virtual.xml" ;; + rx) + TARGET_ARCH=rx + bflt="yes" + target_compiler=$cross_cc_rx + gdb_xml_files="rx-core.xml" + ;; sh4|sh4eb) TARGET_ARCH=sh4 bflt="yes"
@@ -8062,6 +8068,9 @@ for i in $ARCH $TARGET_BASE_ARCH ; do riscv*) disas_config "RISCV" ;; + rx) + disas_config "RX" + ;; s390*) disas_config "S390" ;;
default-configs/rx-softmmu.mak new file +2 -0
@@ -0,0 +1,2 @@ +# Default configuration for rx-softmmu +
qapi/machine.json +3 -1
@@ -16,6 +16,8 @@ # individual target constants are not documented here, for the time # being. # +# @rx: since 5.0 +# # Notes: The resulting QMP strings can be appended to the "qemu-system-" # prefix to produce the corresponding QEMU executable name. This # is true even for "qemu-system-x86_64".
@@ -26,7 +28,7 @@ 'data' : [ 'aarch64', 'alpha', 'arm', 'cris', 'hppa', 'i386', 'lm32', 'm68k', 'microblaze', 'microblazeel', 'mips', 'mips64', 'mips64el', 'mipsel', 'moxie', 'nios2', 'or1k', 'ppc', - 'ppc64', 'riscv32', 'riscv64', 's390x', 'sh4', + 'ppc64', 'riscv32', 'riscv64', 'rx', 's390x', 'sh4', 'sh4eb', 'sparc', 'sparc64', 'tricore', 'unicore32', 'x86_64', 'xtensa', 'xtensaeb' ] }
include/exec/poison.h +1 -0
@@ -26,6 +26,7 @@#pragma GCC poison TARGET_PPC#pragma GCC poison TARGET_PPC64#pragma GCC poison TARGET_ABI32 +#pragma GCC poison TARGET_RX#pragma GCC poison TARGET_S390X#pragma GCC poison TARGET_SH4#pragma GCC poison TARGET_SPARC
include/sysemu/arch_init.h +1 -0
@@ -24,6 +24,7 @@ enum {QEMU_ARCH_NIOS2 = (1 <<17 ),QEMU_ARCH_HPPA = (1 <<18 ),QEMU_ARCH_RISCV = (1 <<19 ), +QEMU_ARCH_RX = (1 <<20 ), QEMU_ARCH_NONE = (1 << 31), };
arch_init.c +2 -0
@@ -77,6 +77,8 @@ int graphic_depth = 32;#define QEMU_ARCH QEMU_ARCH_PPC#elif defined(TARGET_RISCV )#define QEMU_ARCH QEMU_ARCH_RISCV +#elif defined(TARGET_RX ) +#define QEMU_ARCH QEMU_ARCH_RX#elif defined(TARGET_S390X )#define QEMU_ARCH QEMU_ARCH_S390X#elif defined(TARGET_SH4 )
tests/qtest/machine-none-test.c +1 -0
@@ -56,6 +56,7 @@ static struct arch2cpu cpus_map[] = { { "hppa", "hppa" }, { "riscv64", "rv64gcsu-v1.10.0" }, { "riscv32", "rv32gcsu-v1.9.1" }, + { "rx", "rx62n" }, };static const char *get_cpu_model_by_arch (const char *arch)
Signature · 1 line
2.21.1
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Subject: [PATCH 00/13] target: Add Renesas RX architecture
Message-id: [email protected]
Type: series
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 Switched to a new branch 'test'
79d6cda Add rx-softmmu
61d5dc4 target/rx: Dump bytes for each insn during disassembly 61f37ba target/rx: Collect all bytes during disassembly 5e44021 target/rx: Emit all disassembly in one prt() 1d7fe28 target/rx: Use prt_ldmi for XCHG_mr disassembly 181dd6d target/rx: Replace operand with prt_ldmi in disassembler 02b4bd4 target/rx: Disassemble rx_index_addr into a string 45dffb0 target/rx: RX disassembler
f481b57 target/rx: CPU definitions
393bf6b target/rx: TCG helpers
d65fdf3 target/rx: TCG translation
330642d MAINTAINERS: Cover Renesas RX architecture 956e3be hw/registerfields.h: Add 8bit and 16bit register macros
=== OUTPUT BEGIN ===
1/13 Checking commit 956e3be0f31c (hw/registerfields.h: Add 8bit and 16bit register macros) Use of uninitialized value in concatenation (.) or string at ./scripts/checkpatch.pl line 2495.
ERROR: Macros with multiple statements should be enclosed in a do - while loop #28: FILE: include/hw/registerfields.h:25:
+#define REG8(reg, addr) \
+ enum { A_ ## reg = (addr) }; \
+ enum { R_ ## reg = (addr) };
ERROR: Macros with multiple statements should be enclosed in a do - while loop #32: FILE: include/hw/registerfields.h:29:
+#define REG16(reg, addr) \
+ enum { A_ ## reg = (addr) }; \
+ enum { R_ ## reg = (addr) / 2 };
total: 2 errors, 0 warnings, 56 lines checked
Patch 1/13 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
2/13 Checking commit 330642d32f53 (MAINTAINERS: Cover Renesas RX architecture) 3/13 Checking commit d65fdf35865b (target/rx: TCG translation)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #21:
new file mode 100644
total: 0 errors, 1 warnings, 3065 lines checked
Patch 3/13 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
4/13 Checking commit 393bf6b3880e (target/rx: TCG helpers)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #19:
new file mode 100644
total: 0 errors, 1 warnings, 650 lines checked
Patch 4/13 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
5/13 Checking commit f481b5709276 (target/rx: CPU definitions)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #21:
new file mode 100644
total: 0 errors, 1 warnings, 696 lines checked
Patch 5/13 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
6/13 Checking commit 45dffb0da024 (target/rx: RX disassembler)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #39:
new file mode 100644
total: 0 errors, 1 warnings, 1497 lines checked
Patch 6/13 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
7/13 Checking commit 02b4bd4eeca4 (target/rx: Disassemble rx_index_addr into a string) 8/13 Checking commit 181dd6d83f88 (target/rx: Replace operand with prt_ldmi in disassembler) 9/13 Checking commit 1d7fe289cc4d (target/rx: Use prt_ldmi for XCHG_mr disassembly) 10/13 Checking commit 5e44021cea93 (target/rx: Emit all disassembly in one prt()) 11/13 Checking commit 61f37ba4dba9 (target/rx: Collect all bytes during disassembly) 12/13 Checking commit 61d5dc47c3f0 (target/rx: Dump bytes for each insn during disassembly) 13/13 Checking commit 79d6cdaded27 (Add rx-softmmu)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #68:
new file mode 100644
total: 0 errors, 1 warnings, 76 lines checked
Patch 13/13 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]