Add Renesas RX archtecture
RFC PATCH 10/11 Add rx-softmmu.
In reply to Yoshinori Sato--- arch_init.c | 2 ++ configure | 8 ++++++++ default-configs/rx-softmmu.mak | 7 +++++++ include/sysemu/arch_init.h | 1 + target/rx/Makefile.objs | 2 ++ 5 files changed, 20 insertions(+) create mode 100644 default-configs/rx-softmmu.mak create mode 100644 target/rx/Makefile.objs
arch_init.c +2 -0
@@ -74,6 +74,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 )
configure +8 -0
@@ -7232,6 +7232,11 @@ case "$target_name" in mttcg=yes target_compiler=$cross_cc_riscv64 ;; + rx) + TARGET_ARCH=rx + bflt="yes" + target_compiler=$cross_cc_rx + ;; sh4|sh4eb) TARGET_ARCH=sh4 bflt="yes"
@@ -7452,6 +7457,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 +7 -0
@@ -0,0 +1,7 @@ +# Default configuration for rx-softmmu + +CONFIG_SERIAL=y +CONFIG_PTIMER=y +CONFIG_RX=y +CONFIG_RENESAS_SCI=y +CONFIG_RX_DIS=y
include/sysemu/arch_init.h +1 -0
@@ -25,6 +25,7 @@ enum {QEMU_ARCH_NIOS2 = (1 <<17 ),QEMU_ARCH_HPPA = (1 <<18 ),QEMU_ARCH_RISCV = (1 <<19 ), + QEMU_ARCH_RX = (1 << 20), };extern const uint32_t arch_type;
target/rx/Makefile.objs new file +2 -0
@@ -0,0 +1,2 @@ +obj-y += translate.o op_helper.o helper.o cpu.o gdbstub.o +obj-$(CONFIG_SOFTMMU) += monitor.o
Signature · 1 line
2.11.0
RFC PATCH 3/11 TCG helper functions
In reply to Yoshinori Sato--- target/rx/helper.c | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 target/rx/helper.c
target/rx/helper.c new file +143 -0
@@ -0,0 +1,143 @@ +/* +* RX emulation +* +* Copyright (c) 2019 Yoshinori Sato +* +* 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/>. +*/ + +#include "qemu/osdep.h" + +#include "cpu.h" +#include "exec/log.h" +#include "exec/cpu_ldst.h" +#include "sysemu/sysemu.h" + +void rx_cpu_do_interrupt (CPUState *cs) +{ +RXCPU *cpu =RXCPU (cs); +CPURXState *env = &cpu->env; +int do_irq = cs->interrupt_request & + (CPU_INTERRUPT_HARD |CPU_INTERRUPT_SOFT |CPU_INTERRUPT_FIR ); +int irq_vector =-1 ; + + env->in_sleep =0 ; + +if (do_irq &CPU_INTERRUPT_HARD ) { + irq_vector = env->irq; + cs->interrupt_request &= ~CPU_INTERRUPT_HARD ; + } +if (irq_vector ==-1 && do_irq &CPU_INTERRUPT_SOFT ) { + irq_vector = env->sirq; + cs->interrupt_request &= ~CPU_INTERRUPT_SOFT ; + } + +if (qemu_loglevel_mask (CPU_LOG_INT )) { +if (cs->exception_index <0x100 ) { +const char *expname; +switch (cs->exception_index) { +case 20 : + expname ="previlage_violation" ; +break ; +case 21 : + expname ="access_exception" ; +break ; +case 23 : + expname ="illegal_instruction" ; +break ; +case 25 : + expname ="fpu_exception" ; +break ; +case 30 : + expname ="NMI_interrupt" ; +break ; + } +qemu_log ("exception 0x%02x [%s] raised\n" , + cs->exception_index, expname); + }else { +if (do_irq &CPU_INTERRUPT_FIR ) +qemu_log ("fast interrupt raised\n" ); +else +qemu_log ("interrupt 0x%02x raised\n" , + irq_vector); + } +log_cpu_state (cs,0 ); + } +if (env->psw_u) { + env->usp = env->regs[0 ]; + }else { + env->isp = env->regs[0 ]; + } +rx_cpu_pack_psw (env); +if ((do_irq &CPU_INTERRUPT_FIR ) ==0 ) { + env->isp -=4 ; +cpu_stl_all (env, env->isp, env->psw); + env->isp -=4 ; +cpu_stl_all (env, env->isp, env->pc); + }else { + env->bpc = env->pc; + env->bpsw = env->psw; + } + env->psw_pm = env->psw_i = env->psw_u =0 ; + env->regs[0 ] = env->isp; +if (do_irq) { +if (do_irq &CPU_INTERRUPT_FIR ) { + env->pc = env->fintv; + env->psw_ipl =15 ; + cs->interrupt_request &= ~CPU_INTERRUPT_FIR ; +qemu_set_irq (env->ack,0 ); +return ; + }else if (do_irq &CPU_INTERRUPT_HARD ) { + env->psw_ipl = env->intlevel; +qemu_set_irq (env->ack,0 ); + } + env->pc =cpu_ldl_all (env, env->intb + irq_vector *4 ); +return ; + }else { +uint32_t vec = cs->exception_index; + env->pc =cpu_ldl_all (env,0xffffffc0 + vec *4 ); +return ; + } +} + +bool rx_cpu_exec_interrupt (CPUState *cs,int interrupt_request) +{ +RXCPU *cpu =RXCPU (cs); +CPURXState *env = &cpu->env; +int accept =0 ; +/* software interrupt */ +if (interrupt_request &CPU_INTERRUPT_SOFT ) { + accept =1 ; + } +/* hardware interrupt (Normal) */ +if ((interrupt_request &CPU_INTERRUPT_HARD ) && + env->psw_i && (env->psw_ipl < env->intlevel)) { + accept =1 ; + } +/* hardware interrupt (FIR) */ +if ((interrupt_request &CPU_INTERRUPT_FIR ) && + env->psw_i && (env->psw_ipl <15 )) { + accept =1 ; + } +if (accept) { +rx_cpu_do_interrupt (cs); +return true; + } +return false; +} + +hwaddr rx_cpu_get_phys_page_debug (CPUState *cs,vaddr addr) +{ +return addr; +}
Signature · 1 line
2.11.0
RFC PATCH 5/11 RX disassembler
In reply to Yoshinori SatoIt only supported RXv1 instructions.
--- disas/Makefile.objs | 1 + disas/rx.c | 1277 +++++++++++++++++++++++++++++++++++++++++++++++++++ include/disas/bfd.h | 5 + 3 files changed, 1283 insertions(+) create mode 100644 disas/rx.c
disas/Makefile.objs +1 -0
@@ -24,6 +24,7 @@ common-obj-$(CONFIG_SH4_DIS) += sh4.o common-obj-$(CONFIG_SPARC_DIS) += sparc.o common-obj-$(CONFIG_LM32_DIS) += lm32.o common-obj-$(CONFIG_XTENSA_DIS) += xtensa.o +common-obj-$(CONFIG_RX_DIS) += rx.o # TODO: As long as the TCG interpreter and its generated code depend # on the QEMU target, we cannot compile the disassembler here.
disas/rx.c new file +1277 -0
1,277 lines not on this page · raw message
include/disas/bfd.h +5 -0
@@ -228,6 +228,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
@@ -432,6 +436,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. */
Signature · 1 line
2.11.0
cover Add Renesas RX archtecture
Hello.
This patch series is added Renesas RX target emulation.
My git repository is bellow.git://git.pf.osdn.net/gitroot/y/ys/ysato/qemu.git
Since my understanding is not enough,
I want many comments to make this a good one.
Thanks.
Yoshinori Sato (11):
TCG translation
RX CPU definition
TCG helper functions
Target miscellaneous functions.
RX disassembler
RX62N interrupt contoller.
RX62N internal timer unit.
RX62N internal serical communication interface. RX Target hardware definition.
Add rx-softmmu.
MAINTAINERS: Add RX entry.
MAINTAINERS | 20 + arch_init.c | 2 + configure | 8 + default-configs/rx-softmmu.mak | 7 + disas/Makefile.objs | 1 + disas/rx.c | 1277 +++++++++++++++++ hw/char/Makefile.objs | 2 +- hw/char/renesas_sci.c | 279 ++++ hw/intc/Makefile.objs | 1 + hw/intc/rx_icu.c | 313 +++++ hw/rx/Makefile.objs | 1 + hw/rx/rx62n.c | 233 ++++ hw/rx/rxqemu.c | 106 ++ hw/timer/Makefile.objs | 2 + hw/timer/renesas_cmt.c | 226 +++ hw/timer/renesas_tmr.c | 401 ++++++ include/disas/bfd.h | 5 + include/hw/char/renesas_sci.h | 42 + include/hw/intc/rx_icu.h | 49 + include/hw/rx/rx.h | 7 + include/hw/rx/rx62n.h | 45 + include/hw/timer/renesas_cmt.h | 33 + include/hw/timer/renesas_tmr.h | 42 + include/sysemu/arch_init.h | 1 + target/rx/Makefile.objs | 2 + target/rx/cpu-qom.h | 54 + target/rx/cpu.c | 226 +++ target/rx/cpu.h | 212 +++ target/rx/gdbstub.c | 114 ++ target/rx/helper.c | 143 ++ target/rx/helper.h | 22 + target/rx/monitor.c | 38 + target/rx/op_helper.c | 548 ++++++++ target/rx/translate.c | 3003 ++++++++++++++++++++++++++++++++++++++++ 34 files changed, 7464 insertions(+), 1 deletion(-) create mode 100644 default-configs/rx-softmmu.mak create mode 100644 disas/rx.c create mode 100644 hw/char/renesas_sci.c create mode 100644 hw/intc/rx_icu.c create mode 100644 hw/rx/Makefile.objs create mode 100644 hw/rx/rx62n.c create mode 100644 hw/rx/rxqemu.c create mode 100644 hw/timer/renesas_cmt.c create mode 100644 hw/timer/renesas_tmr.c create mode 100644 include/hw/char/renesas_sci.h create mode 100644 include/hw/intc/rx_icu.h create mode 100644 include/hw/rx/rx.h create mode 100644 include/hw/rx/rx62n.h create mode 100644 include/hw/timer/renesas_cmt.h create mode 100644 include/hw/timer/renesas_tmr.h create mode 100644 target/rx/Makefile.objs create mode 100644 target/rx/cpu-qom.h create mode 100644 target/rx/cpu.c create mode 100644 target/rx/cpu.h create mode 100644 target/rx/gdbstub.c create mode 100644 target/rx/helper.c create mode 100644 target/rx/helper.h create mode 100644 target/rx/monitor.c create mode 100644 target/rx/op_helper.c create mode 100644 target/rx/translate.c
Signature · 1 line
2.11.0
RFC PATCH 4/11 Target miscellaneous functions.
--- target/rx/gdbstub.c | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++ target/rx/monitor.c | 38 ++++++++++++++++++ 2 files changed, 152 insertions(+) create mode 100644 target/rx/gdbstub.c create mode 100644 target/rx/monitor.c
target/rx/gdbstub.c new file +114 -0
@@ -0,0 +1,114 @@ +/* +* RX gdb server stub +* +* Copyright (c) 2019 Yoshinori Sato +* +* 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/>. +*/ +#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 : +rx_cpu_pack_psw (env); +return gdb_get_regl (mem_buf, env->psw); +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; + +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 : + env->psw =ldl_p (mem_buf); +rx_cpu_unpack_psw (env,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/monitor.c new file +38 -0
@@ -0,0 +1,38 @@ +/* +* QEMU monitor +* +* Copyright (c) 2003-2004 Fabrice Bellard +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ +#include "qemu/osdep.h" +#include "cpu.h" +#include "monitor/monitor.h" +#include "monitor/hmp-target.h" +#include "hmp.h" + +void hmp_info_tlb (Monitor *mon,const QDict *qdict) +{ +CPUArchState *env =mon_get_cpu_env (); + +if (!env) { +monitor_printf (mon,"No CPU available\n" ); +return ; + } +}
Signature · 1 line
2.11.0
RFC PATCH 7/11 RX62N internal timer unit.
In reply to Yoshinori Satorenesas_tmr: 8bit timer modules.renesas_cmt: 16bit compare match timer modules.
This part use many renesas's CPU.
Hardware manual.
https://www.renesas.com/us/en/doc/products/mpumcu/doc/rx_family/r01uh0033ej0140_rx62n.pdf?key=086621e01bd70347c18ea7f794aa9cc3
--- hw/timer/Makefile.objs | 2 + hw/timer/renesas_cmt.c | 226 +++++++++++++++++++++++ hw/timer/renesas_tmr.c | 401 +++++++++++++++++++++++++++++++++++++++++ include/hw/timer/renesas_cmt.h | 33 ++++ include/hw/timer/renesas_tmr.h | 42 +++++ 5 files changed, 704 insertions(+) create mode 100644 hw/timer/renesas_cmt.c create mode 100644 hw/timer/renesas_tmr.c create mode 100644 include/hw/timer/renesas_cmt.h create mode 100644 include/hw/timer/renesas_tmr.h
hw/timer/Makefile.objs +2 -0
@@ -40,6 +40,8 @@ obj-$(CONFIG_MC146818RTC) += mc146818rtc.o obj-$(CONFIG_ALLWINNER_A10_PIT) += allwinner-a10-pit.o +obj-$(CONFIG_RX) += renesas_tmr.o renesas_cmt.o + common-obj-$(CONFIG_STM32F2XX_TIMER) += stm32f2xx_timer.o common-obj-$(CONFIG_ASPEED_SOC) += aspeed_timer.o
hw/timer/renesas_cmt.c new file +226 -0
226 lines not on this page · raw message
hw/timer/renesas_tmr.c new file +401 -0
401 lines not on this page · raw message
include/hw/timer/renesas_cmt.h new file +33 -0
@@ -0,0 +1,33 @@ +/* +* Renesas Compare-match timer Object +* +* Copyright (c) 2018 Yoshinori Sato +* +* This code is licensed under the GPL version 2 or later. +* +*/ + +#ifndef HW_RENESAS_CMT_H +#define HW_RENESAS_CMT_H + +#include "hw/sysbus.h" + +#define TYPE_RENESAS_CMT "renesas-cmt" +#define RCMT (obj) OBJECT_CHECK(RCMTState, (obj), TYPE_RENESAS_CMT) + +typedef struct RCMTState { +SysBusDevice parent_obj; + +uint64_t input_freq; +MemoryRegion memory; + +uint16_t cmstr; +uint16_t cmcr[2 ]; +uint16_t cmcnt[2 ]; +uint16_t cmcor[2 ]; +int64_t tick[2 ]; +qemu_irq cmi[2 ]; +QEMUTimer *timer[2 ]; +}RCMTState ; + +#endif
include/hw/timer/renesas_tmr.h new file +42 -0
42 lines not on this page · raw message
Signature · 1 line
2.11.0
RFC PATCH 11/11 MAINTAINERS: Add RX entry.
In reply to Yoshinori Sato--- MAINTAINERS | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
MAINTAINERS +20 -0
@@ -272,6 +272,14 @@ F: include/hw/riscv/ F: linux-user/host/riscv32/ F: linux-user/host/riscv64/ +RX +M: Yoshinori Sato <[email protected]> +S: Maintained +F: target/rx/ +F: hw/rx/ +F: include/hw/rx/ +F: disas/rx.c + S390 M: Richard Henderson <[email protected]> M: David Hildenbrand <[email protected]>
@@ -1071,6 +1079,18 @@ F: pc-bios/canyonlands.dt[sb] F: pc-bios/u-boot-sam460ex-20100605.bin F: roms/u-boot-sam460ex +RX Machines +----------- +RX-QEMU +M: Yoshinori Sato <[email protected]> +S: Maintained +F: hw/rx/rxqemu.c +F: hw/intc/rx_icu.c +F: hw/timer/renesas_*.c +F: hw/char/renesas_sci.c +F: include/hw/timer/renesas_*.h +F: include/hw/char/renesas_sci.h + SH4 Machines ------------ R2D
Signature · 1 line
2.11.0
RFC PATCH 8/11 RX62N internal serical communication interface.
In reply to Yoshinori SatoThis module supported only non FIFO type.
Hardware manual.
https://www.renesas.com/us/en/doc/products/mpumcu/doc/rx_family/r01uh0033ej0140_rx62n.pdf?key=086621e01bd70347c18ea7f794aa9cc3
--- hw/char/Makefile.objs | 2 +- hw/char/renesas_sci.c | 279 ++++++++++++++++++++++++++++++++++++++++++ include/hw/char/renesas_sci.h | 42 +++++++ 3 files changed, 322 insertions(+), 1 deletion(-) create mode 100644 hw/char/renesas_sci.c create mode 100644 include/hw/char/renesas_sci.h
hw/char/Makefile.objs +1 -1
@@ -15,7 +15,7 @@ common-obj-$(CONFIG_CADENCE) += cadence_uart.o obj-$(CONFIG_EXYNOS4) += exynos4210_uart.o obj-$(CONFIG_COLDFIRE) += mcf_uart.o obj-$(CONFIG_OMAP) += omap_uart.o -obj-$(CONFIG_SH4) += sh_serial.o +obj-$(CONFIG_RENESAS_SCI) += renesas_sci.o obj-$(CONFIG_PSERIES) += spapr_vty.o obj-$(CONFIG_DIGIC) += digic-uart.o obj-$(CONFIG_STM32F2XX_USART) += stm32f2xx_usart.o
hw/char/renesas_sci.c new file +279 -0
279 lines not on this page · raw message
include/hw/char/renesas_sci.h new file +42 -0
42 lines not on this page · raw message
Signature · 1 line
2.11.0
RFC PATCH 9/11 RX Target hardware definition.
In reply to Yoshinori Satorx62n - RX62N cpu.
rxqemu - QEMU virtual target.
--- hw/rx/Makefile.objs | 1 + hw/rx/rx62n.c | 233 ++++++++++++++++++++++++++++++++++++++++++++++++++ hw/rx/rxqemu.c | 106 +++++++++++++++++++++++ include/hw/rx/rx.h | 7 ++ include/hw/rx/rx62n.h | 45 ++++++++++ 5 files changed, 392 insertions(+) create mode 100644 hw/rx/Makefile.objs create mode 100644 hw/rx/rx62n.c create mode 100644 hw/rx/rxqemu.c create mode 100644 include/hw/rx/rx.h create mode 100644 include/hw/rx/rx62n.h
hw/rx/Makefile.objs new file +1 -0
@@ -0,0 +1 @@ +obj-y += rx62n.o rxqemu.o
hw/rx/rx62n.c new file +233 -0
233 lines not on this page · raw message
hw/rx/rxqemu.c new file +106 -0
106 lines not on this page · raw message
include/hw/rx/rx.h new file +7 -0
@@ -0,0 +1,7 @@ +#ifndef QEMU_RX_H +#define QEMU_RX_H +/* Definitions for RX board emulation. */ + +#include "target/rx/cpu-qom.h" + +#endif
include/hw/rx/rx62n.h new file +45 -0
45 lines not on this page · raw message
Signature · 1 line
2.11.0
RFC PATCH 2/11 RX CPU definition
In reply to Yoshinori Sato--- target/rx/cpu-qom.h | 54 +++++++++++++ target/rx/cpu.c | 226 ++++++++++++++++++++++++++++++++++++++++++++++++++++ target/rx/cpu.h | 212 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 492 insertions(+) create mode 100644 target/rx/cpu-qom.h create mode 100644 target/rx/cpu.c create mode 100644 target/rx/cpu.h
target/rx/cpu-qom.h new file +54 -0
@@ -0,0 +1,54 @@ +/* +* QEMU RX CPU +* +* Copyright (c) 2019 Yoshinori Sato +* +* 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.1 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/lgpl-2.1.html> +*/ + +#ifndef QEMU_RX_CPU_QOM_H +#define QEMU_RX_CPU_QOM_H + +#include "qom/cpu.h" + +#define TYPE_RXCPU "rxcpu" + +#define RXCPU_CLASS (klass) \ + OBJECT_CLASS_CHECK(RXCPUClass, (klass), TYPE_RXCPU) +#define RXCPU (obj) \ + OBJECT_CHECK(RXCPU, (obj), TYPE_RXCPU) +#define RXCPU_GET_CLASS (obj) \ + OBJECT_GET_CLASS(RXCPUClass, (obj), TYPE_RXCPU) + +/* +* 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 ; + +typedef struct RXCPU RXCPU ; + +#endif
target/rx/cpu.c new file +226 -0
226 lines not on this page · raw message
target/rx/cpu.h new file +212 -0
212 lines not on this page · raw message
Signature · 1 line
2.11.0
RFC PATCH 6/11 RX62N interrupt contoller.
In reply to Yoshinori SatoThis implementation supported only ICUa.
Hardware manual.
https://www.renesas.com/us/en/doc/products/mpumcu/doc/rx_family/r01uh0033ej0140_rx62n.pdf?key=086621e01bd70347c18ea7f794aa9cc3
--- hw/intc/Makefile.objs | 1 + hw/intc/rx_icu.c | 313 +++++++++++++++++++++++++++++++++++++++++++++++ include/hw/intc/rx_icu.h | 49 ++++++++ 3 files changed, 363 insertions(+) create mode 100644 hw/intc/rx_icu.c create mode 100644 include/hw/intc/rx_icu.h
hw/intc/Makefile.objs +1 -0
@@ -48,3 +48,4 @@ obj-$(CONFIG_ARM_GIC) += arm_gicv3_cpuif.o obj-$(CONFIG_MIPS_CPS) += mips_gic.o obj-$(CONFIG_NIOS2) += nios2_iic.o obj-$(CONFIG_OMPIC) += ompic.o +obj-$(CONFIG_RX) += rx_icu.o
hw/intc/rx_icu.c new file +313 -0
313 lines not on this page · raw message
include/hw/intc/rx_icu.h new file +49 -0
49 lines not on this page · raw message
Signature · 1 line
2.11.0
RFC PATCH 1/11 TCG translation
In reply to Yoshinori SatoThis part only supported RXv1 instructions.
Instruction manual.
https://www.renesas.com/us/en/doc/products/mpumcu/doc/rx_family/r01us0032ej0120_rxsm.pdf
--- target/rx/helper.h | 22 + target/rx/op_helper.c | 548 +++++++++ target/rx/translate.c | 3003 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 3573 insertions(+) create mode 100644 target/rx/helper.h create mode 100644 target/rx/op_helper.c create mode 100644 target/rx/translate.c
target/rx/helper.h new file +22 -0
@@ -0,0 +1,22 @@ +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_4(floatop, TCG_CALL_NO_WG, f32, env, i32, f32, f32) +DEF_HELPER_2(to_fpsw, void, env, i32) +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(racw, void, env, i32) +DEF_HELPER_1(update_psw, void, env) +DEF_HELPER_1(psw_c, i32, env) +DEF_HELPER_1(psw_s, i32, env) +DEF_HELPER_1(psw_o, i32, env) +DEF_HELPER_3(mvtc, void, env, i32, i32) +DEF_HELPER_2(mvfc, i32, env, i32) +DEF_HELPER_2(cond, i32, env, i32) +DEF_HELPER_1 (unpack_psw, void, env) +
target/rx/op_helper.c new file +548 -0
548 lines not on this page · raw message
target/rx/translate.c new file +3003 -0
2,430 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.11.0
Part of the diff is not shown here. View the raw message.
Re: [Qemu-devel] [PATCH RFC 01/11] TCG translation
Quoted 6 lines · Yoshinori Sato
This part only supported RXv1 instructions.
Instruction manual.
https://www.renesas.com/us/en/doc/products/mpumcu/doc/rx_family/r01us0032ej0120_rxsm.pdfSigned-off-by Yoshinori Sato <[email protected]>---
[...]
Quoted 6 lines
target/rx/op_helper.c new file +0
-0
target/rx/op_helper.c line 9
Quoted 9 lines
target/rx/op_helper.c new file +9
-0@@ -0,0 +1,548 @@ +/* +* RX helper functions +* +* Copyright (c) 2018 Yoshinori Sato +* +* 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.
Hi,
just a short meta comment for all the new files in your patch series:
It's either
GNU *Library* General Public License, version 2
or
GNU Lesser General Public License, version *2.1*
I'd suggest to go with "Lesser" and "2.1".
Apart from that, it might be a good idea to CC: some people who are familiar with TCG if you want to make sure to get some review (see the MAINTAINERS file for example).
Thanks,
Thomas
PS: Seems like we've got this "Lesser" vs. "Library" wrong in a couple of other source files in QEMU ... I'll try to come up with a patch to fix this in the files that we've already got in the repo.
Re: [Qemu-devel] [PATCH RFC 01/11] TCG translation
Quoted 34 lines · Thomas Huth
Quoted 6 lines · Yoshinori Sato
This part only supported RXv1 instructions.
Instruction manual.
https://www.renesas.com/us/en/doc/products/mpumcu/doc/rx_family/r01us0032ej0120_rxsm.pdfSigned-off-by Yoshinori Sato <[email protected]>---
[...]
Quoted 6 lines
target/rx/op_helper.c new file +0
-0target/rx/op_helper.c line 9
Quoted 9 lines
target/rx/op_helper.c new file +9
-0@@ -0,0 +1,548 @@ +/* +* RX helper functions +* +* Copyright (c) 2018 Yoshinori Sato +* +* 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. Hi,
just a short meta comment for all the new files in your patch series:
It's eitherGNU *Library* General Public License, version 2
or
Quoted 7 lines
GNU Lesser General Public License, version *2.1*
I'd suggest to go with "Lesser" and "2.1".
Apart from that, it might be a good idea to CC: some people who are familiar with TCG if you want to make sure to get some review (see the
MAINTAINERSfile for example).
Thanks comment.
OK.
I will update the license text and resend it.
Quoted 8 lines
Thanks,
ThomasPS: Seems like we've got this "Lesser" vs. "Library" wrong in a couple of other source files in QEMU ... I'll try to come up with a patch to fix this in the files that we've already got in the repo.
Signature · 1 line
Yosinori Sato
Re: [Qemu-devel] [PATCH RFC 01/11] TCG translation
In reply to Yoshinori Satotarget/rx/translate.c line 44
Quoted 8 lines · Yoshinori Sato
target/rx/translate.c new file +8
-0+/* PSW condition operation */ +typedef struct { +TCGv op_mode; +TCGv op_a1[13 ]; +TCGv op_a2[13 ]; +TCGv op_r[13 ]; +}CCOP ; +CCOP ccop;
Why does this have different array sizes than cpu.h?
Indeed, why does this have array sizes at all? I am confused by your method of flags generation. This would be improved with comments, at least. I suspect that this is overly complicated and should be simplified to a single set of variables, like target/i386 or target/s390x.
But I wonder if it might be least complicated, at least to start, if you just explicitly compute each flag, like target/arm.
Note that computation need not be expensive. Indeed, the Z and S flags can generally be "computed" with a single move, if we define the representations as env->psw_z == 0 and env->psw_s < 0.
Quoted 11 lines
target/rx/helper.h new file +11
-0+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_4(floatop, TCG_CALL_NO_WG, f32, env, i32, f32, f32) +DEF_HELPER_2(to_fpsw, void, env, i32) +DEF_HELPER_FLAGS_2(ftoi, TCG_CALL_NO_WG, i32, env, f32) +DEF_HELPER_FLAGS_2 (round,TCG_CALL_NO_WG , i32, env, f32)
target/rx/helper.h line 21
Quoted 10 lines
target/rx/helper.h new file +10
-0+DEF_HELPER_FLAGS_2(itof, TCG_CALL_NO_WG, f32, env, i32) +DEF_HELPER_2(racw, void, env, i32) +DEF_HELPER_1(update_psw, void, env) +DEF_HELPER_1(psw_c, i32, env) +DEF_HELPER_1(psw_s, i32, env) +DEF_HELPER_1(psw_o, i32, env) +DEF_HELPER_3(mvtc, void, env, i32, i32) +DEF_HELPER_2(mvfc, i32, env, i32) +DEF_HELPER_2(cond, i32, env, i32) +DEF_HELPER_1 (unpack_psw, void, env)
Should fill in the flags for all of the non-noreturn helpers.
target/rx/op_helper.c line 71
Quoted 5 lines
target/rx/op_helper.c new file +5
-0+static uint32_t psw_z (CPURXState *env) +{ +int m = (env->op_mode >>4 ) &0x000f ; +if (m ==RX_PSW_OP_NONE ) +return env->psw_z;
./scripts/checkpatch.pl should have given a diagnostic for the lack of braces here.
Quoted 8 lines
target/rx/op_helper.c new file +8
-0+void helper_update_psw (CPURXState *env) +{ +struct { +uint32_t *p; +uint32_t (*fn)(CPURXState *); + }const update_proc[] = { + {&env->psw_c, psw_c}, + {&env->psw_z, psw_z},
target/rx/op_helper.c line 242
Quoted 10 lines
target/rx/op_helper.c new file +10
-0+ {&env->psw_s, psw_s}, + {&env->psw_o, psw_o}, + }; +int i; + +for (i =0 ; i <4 ; i++) { + *(update_proc[i].p) = update_proc[i].fn (env); + } +g_assert ((env->op_mode &0xffff ) ==0 ); +}
All of the helpers already update the variables. This should simplify to
void helper_update_psw(CPURXState *env)
{
psw_c(env);
psw_z(env);
psw_s(env);
psw_o(env);
assert(env->op_mode == 0);
}
target/rx/op_helper.c line 455
Quoted 9 lines
target/rx/op_helper.c new file +9
-0+void rx_cpu_pack_psw (CPURXState *env) +{ +helper_update_psw (env); + env->psw = ( + (env->psw_ipl <<24 ) | (env->psw_pm <<20 ) | + (env->psw_u <<17 ) | (env->psw_i <<16 ) | + (env->psw_o <<3 ) | (env->psw_s <<2 ) | + (env->psw_z <<1 ) | (env->psw_c <<0 )); +}
I recommend this only return a value, and not modify state. This is particularly important for debugging, where you would like to examine state without modifying anything.
Quoted 6 lines
target/rx/op_helper.c new file +6
-0+typedef float32 (*floatfunc )(float32 f1,float32 f2,float_status *st); +float32 helper_floatop (CPURXState *env,uint32_t op, +float32 t0,float32 t1) +{ +static const floatfunc fop[] = { + float32_sub,
target/rx/op_helper.c line 376
Quoted 10 lines
target/rx/op_helper.c new file +10
-0+NULL , + float32_add, + float32_mul, + float32_div, + }; +int st, xcpt; +if (op !=1 ) { + t0 = fop[op](t0, t1, &env->fp_status); +update_fpsw (env,GETPC ()); + }else {
I recommend that you split this into 5 different functions, one for each arithmetic operator and one for the comparison.
target/rx/op_helper.c line 397
Quoted 11 lines
target/rx/op_helper.c new file +11
-0+switch (st) { +case float_relation_unordered: +return (float32 )0 ; +case float_relation_equal: +return (float32 )1 ; +case float_relation_less: +return (float32 )2 ; + } + } +return t0; +}
The comparison function should return uint32_t instead of values that are obviously not normal float32 values.
target/rx/op_helper.c line 525
Quoted 5 lines
target/rx/op_helper.c new file +5
-0+void helper_racw (CPURXState *env,uint32_t shift) +{ +int64_t acc; + acc = env->acc_m; + acc = (acc <<32 ) | env->acc_l;
I think that acc should be stored as (u)int64_t within env.
target/rx/op_helper.c line 530
Quoted 5 lines
target/rx/op_helper.c new file +5
-0+ acc <<= shift; + acc +=0x0000000080000000LL ; +if (acc >0x00007FFF00000000LL ) { + acc =0x00007FFF00000000LL ; + }else if (acc <0xFFFF800000000000LL ) {
If you want a signed type, use a signed value: -0x800000000000LL.
target/rx/translate.c line 69
Quoted 3 lines
target/rx/translate.c new file +3
-0+ psw =rx_get_psw_low (env); + psw |= (env->psw_ipl <<24 ) | (env->psw_pm <<20 ) | + (env->psw_u <<17 ) | (env->psw_i <<16 );
I think you should use your regular "get everything" helper.
target/rx/translate.c line 204
Quoted 9 lines
target/rx/translate.c new file +9
-0+static void rx_gen_ldst (int size,int dir,TCGv reg,TCGv mem) +{ +static void (*const rw[])(TCGv ret,TCGv addr,int idx) = { + tcg_gen_qemu_st8, tcg_gen_qemu_ld8s, + tcg_gen_qemu_st16, tcg_gen_qemu_ld16s, + tcg_gen_qemu_st32, tcg_gen_qemu_ld32s, + }; + rw[size *2 + dir](reg, mem,0 ); +}
Use tcg_gen_qemu_ld_i32 and tcg_gen_qemu_st_i32 instead:
if (dir) {
tcg_gen_qemu_ld_i32(reg, mem, 0, size | MO_SIGN | MO_TE);
} else {
tcg_gen_qemu_st_i32(reg, mem, 0, size | MO_TE);
}Quoted 9 lines
target/rx/translate.c new file +9
-0+DEFINE_INSN (mov1_2) +{ +TCGv mem; +int r1, r2, dsp, dir, sz; + + insn >>=16 ; + sz = (insn >>12 ) &3 ; + dsp = ((insn >>6 ) &0x1e ) | ((insn >>3 ) &1 ); + dsp <<= sz;
target/rx/translate.c line 225
Quoted 10 lines
target/rx/translate.c new file +10
-0+ r2 = insn &7 ; + r1 = (insn >>4 ) &7 ; + dir = (insn >>11 ) &1 ; + + mem =tcg_temp_local_new (); +tcg_gen_addi_i32 (mem, cpu_regs[r1], dsp); +rx_gen_ldst (sz, dir, cpu_regs[r2], mem); +tcg_temp_free (mem); + dc->pc +=2 ; +}
Do not use tcg_temp_local_new() unless you need it to hold a value across a branch or label. Use tcg_temp_new() instead.
Likewise with tcg_const_local.
target/rx/translate.c line 2878
Quoted 11 lines
target/rx/translate.c new file +11
-0+static void rx_tr_translate_insn (DisasContextBase *dcbase,CPUState *cs) +{ +CPURXState *env = cs->env_ptr; +DisasContext *dc =container_of (dcbase, DisasContext, base); +uint32_t insn =0 ; +int i; + +for (i =0 ; i <4 ; i++) { + insn <<=8 ; + insn |=cpu_ldub_code (env, dc->base.pc_next + i); + }
You're reading 4 bytes when the insn may be only 1-2 bytes long? This could fail if a branch insn is placed near the end of memory.
I wish Renesas has published a consolidated opcode map, because it is very hard to compare your decoding to the manual. I am tempted to try to extend ./scripts/decodetree.py to handle variable width instruction sets to see if we can make this process easier.
r~
Re: [Qemu-devel] [PATCH RFC 01/11] TCG translation
Quoted 12 lines · Richard Henderson
target/rx/translate.c line 44
Quoted 8 lines · Yoshinori Sato
target/rx/translate.c new file +8
-0+/* PSW condition operation */ +typedef struct { +TCGv op_mode; +TCGv op_a1[13 ]; +TCGv op_a2[13 ]; +TCGv op_r[13 ]; +}CCOP ; +CCOP ccop;Why does this have different array sizes than
cpu.h?
It array not use first one.
Bt it confused. I will fix same size.
Quoted 11 lines
Indeed, why does this have array sizes at all? I am confused by your method of flags generation. This would be improved with comments, at least. I suspect that this is overly complicated and should be simplified to a single set of variables, like target/i386 or target/s390x.
But I wonder if it might be least complicated, at least to start, if you just explicitly compute each flag, like target/arm.
Note that computation need not be expensive. Indeed, the Z and S flags can generally be "computed" with a single move, if we define the representations as
env->psw_z== 0 andenv->psw_s< 0.
Since there are instructions that only change specific flags, so need to manage the status of each flag individually. I will consider a simpler method.
Quoted 15 lines
Quoted 15 lines
target/rx/helper.h new file +15
-0+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_4(floatop, TCG_CALL_NO_WG, f32, env, i32, f32, f32) +DEF_HELPER_2(to_fpsw, void, env, i32) +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(racw, void, env, i32) +DEF_HELPER_1(update_psw, void, env) +DEF_HELPER_1 (psw_c, i32, env)
Quoted 8 lines
target/rx/helper.h line 21
Quoted 6 lines
target/rx/helper.h new file +6
-0+DEF_HELPER_1(psw_s, i32, env) +DEF_HELPER_1(psw_o, i32, env) +DEF_HELPER_3(mvtc, void, env, i32, i32) +DEF_HELPER_2(mvfc, i32, env, i32) +DEF_HELPER_2(cond, i32, env, i32) +DEF_HELPER_1 (unpack_psw, void, env)Should fill in the flags for all of the non-noreturn helpers.
OK
Quoted 7 lines
target/rx/op_helper.c line 71
Quoted 5 lines
target/rx/op_helper.c new file +5
-0+static uint32_t psw_z (CPURXState *env) +{ +int m = (env->op_mode >>4 ) &0x000f ; +if (m ==RX_PSW_OP_NONE ) +return env->psw_z;
./scripts/checkpatch.plshould have given a diagnostic for the lack of braces here.
OK.
It seems I overlooked it.
Quoted 30 lines
Quoted 8 lines
target/rx/op_helper.c new file +8
-0+void helper_update_psw (CPURXState *env) +{ +struct { +uint32_t *p; +uint32_t (*fn)(CPURXState *); + }const update_proc[] = { + {&env->psw_c, psw_c}, + {&env->psw_z, psw_z},target/rx/op_helper.c line 242
Quoted 10 lines
target/rx/op_helper.c new file +10
-0+ {&env->psw_s, psw_s}, + {&env->psw_o, psw_o}, + }; +int i; + +for (i =0 ; i <4 ; i++) { + *(update_proc[i].p) = update_proc[i].fn (env); + } +g_assert ((env->op_mode &0xffff ) ==0 ); +}All of the helpers already update the variables. This should simplify to
void
helper_update_psw(CPURXState *env)
{
psw_c(env);
psw_z(env);
psw_s(env);
psw_o(env);
assert(env->op_mode == 0);
}
Quoted 13 lines
target/rx/op_helper.c line 455
Quoted 9 lines
target/rx/op_helper.c new file +9
-0+void rx_cpu_pack_psw (CPURXState *env) +{ +helper_update_psw (env); + env->psw = ( + (env->psw_ipl <<24 ) | (env->psw_pm <<20 ) | + (env->psw_u <<17 ) | (env->psw_i <<16 ) | + (env->psw_o <<3 ) | (env->psw_s <<2 ) | + (env->psw_z <<1 ) | (env->psw_c <<0 )); +}I recommend this only return a value, and not modify state. This is particularly important for debugging, where you would like to examine state without modifying anything.
OK.
Quoted 11 lines
Quoted 11 lines
target/rx/op_helper.c new file +11
-0+typedef float32 (*floatfunc )(float32 f1,float32 f2,float_status *st); +float32 helper_floatop (CPURXState *env,uint32_t op, +float32 t0,float32 t1) +{ +static const floatfunc fop[] = { + float32_sub, +NULL , + float32_add, + float32_mul, + float32_div, + };
Quoted 8 lines
target/rx/op_helper.c line 376
Quoted 5 lines
target/rx/op_helper.c new file +5
-0+int st, xcpt; +if (op !=1 ) { + t0 = fop[op](t0, t1, &env->fp_status); +update_fpsw (env,GETPC ()); + }else {I recommend that you split this into 5 different functions, one for each arithmetic operator and one for the comparison.
OK.
Quoted 12 lines
target/rx/op_helper.c line 397
Quoted 11 lines
target/rx/op_helper.c new file +11
-0+switch (st) { +case float_relation_unordered: +return (float32 )0 ; +case float_relation_equal: +return (float32 )1 ; +case float_relation_less: +return (float32 )2 ; + } + } +return t0; +}
Quoted 2 lines
The comparison function should return
uint32_tinstead of values that are obviously not normal float32 values.
OK.
Quoted 7 lines
target/rx/op_helper.c line 525
Quoted 5 lines
target/rx/op_helper.c new file +5
-0+void helper_racw (CPURXState *env,uint32_t shift) +{ +int64_t acc; + acc = env->acc_m; + acc = (acc <<32 ) | env->acc_l;I think that acc should be stored as (u)int64_t within env.
OK.
The new instruction set will be 72 bits here,
so I will consider a bit more.
Quoted 6 lines
target/rx/op_helper.c line 530
Quoted 5 lines
target/rx/op_helper.c new file +5
-0+ acc <<= shift; + acc +=0x0000000080000000LL ; +if (acc >0x00007FFF00000000LL ) { + acc =0x00007FFF00000000LL ; + }else if (acc <0xFFFF800000000000LL ) {
Quoted 7 lines
If you want a signed type, use a signed value: -0x800000000000LL.
target/rx/translate.c line 69
Quoted 3 lines
target/rx/translate.c new file +3
-0+ psw =rx_get_psw_low (env); + psw |= (env->psw_ipl <<24 ) | (env->psw_pm <<20 ) | + (env->psw_u <<17 ) | (env->psw_i <<16 );I think you should use your regular "get everything" helper.
OK.
Quoted 11 lines
target/rx/translate.c line 204
Quoted 9 lines
target/rx/translate.c new file +9
-0+static void rx_gen_ldst (int size,int dir,TCGv reg,TCGv mem) +{ +static void (*const rw[])(TCGv ret,TCGv addr,int idx) = { + tcg_gen_qemu_st8, tcg_gen_qemu_ld8s, + tcg_gen_qemu_st16, tcg_gen_qemu_ld16s, + tcg_gen_qemu_st32, tcg_gen_qemu_ld32s, + }; + rw[size *2 + dir](reg, mem,0 ); +}Use
tcg_gen_qemu_ld_i32andtcg_gen_qemu_st_i32instead:
OK.
Quoted 29 lines
if (dir) { tcg_gen_qemu_ld_i32(reg, mem, 0, size | MO_SIGN | MO_TE); } else { tcg_gen_qemu_st_i32(reg, mem, 0, size | MO_TE); }Quoted 9 lines
target/rx/translate.c new file +9
-0+DEFINE_INSN (mov1_2) +{ +TCGv mem; +int r1, r2, dsp, dir, sz; + + insn >>=16 ; + sz = (insn >>12 ) &3 ; + dsp = ((insn >>6 ) &0x1e ) | ((insn >>3 ) &1 ); + dsp <<= sz;target/rx/translate.c line 225
Quoted 10 lines
target/rx/translate.c new file +10
-0+ r2 = insn &7 ; + r1 = (insn >>4 ) &7 ; + dir = (insn >>11 ) &1 ; + + mem =tcg_temp_local_new (); +tcg_gen_addi_i32 (mem, cpu_regs[r1], dsp); +rx_gen_ldst (sz, dir, cpu_regs[r2], mem); +tcg_temp_free (mem); + dc->pc +=2 ; +}Do not use
tcg_temp_local_new()unless you need it to hold a value across a branch or label. Usetcg_temp_new()instead.
Quoted 1 line
Likewise with
tcg_const_local.
OK.
Quoted 6 lines
Quoted 6 lines
target/rx/translate.c new file +6
-0+static void rx_tr_translate_insn (DisasContextBase *dcbase,CPUState *cs) +{ +CPURXState *env = cs->env_ptr; +DisasContext *dc =container_of (dcbase, DisasContext, base); +uint32_t insn =0 ; +int i;
Quoted 8 lines
target/rx/translate.c line 2878
Quoted 5 lines
target/rx/translate.c new file +5
-0+ +for (i =0 ; i <4 ; i++) { + insn <<=8 ; + insn |=cpu_ldub_code (env, dc->base.pc_next + i); + }You're reading 4 bytes when the insn may be only 1-2 bytes long? This could fail if a branch insn is placed near the end of memory.
OK.
Since most instructions are less than 4 bytes, they are acquired at once. I did not assume the case of the memory boundary,
but since there is a problem, I fix it.
Quoted 4 lines
I wish Renesas has published a consolidated opcode map, because it is very hard to compare your decoding to the manual. I am tempted to try to extend
./scripts/decodetree.pyto handle variable width instruction sets to see if we can make this process easier.
Yes. This CPU opode very complex.
I also try decodetree.py.
Quoted 2 lines
r~
Your comment was very helpful.
Thank you.
Signature · 1 line
Yosinori Sato
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: [Qemu-devel] [PATCH RFC 00/11] Add Renesas RX archtecture
Type: series
Message-id: [email protected]
=== TEST SCRIPT BEGIN ===
#!/bin/bash
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'a739c452f4 MAINTAINERS: Add RX entry.3778b84308 Add rx-softmmu.9b35f3e02a RX Target hardware definition. d098f8610b RX62N internal serical communication interface. d1fda562b0 RX62N internal timer unit.58ae337613 RX62N interrupt contoller.9cb21f3ffd RX disassemblerce17708f0b Target miscellaneous functions. 276096a543 TCG helper functions02c37e53dc RX CPU definition228562c3da TCG translation
=== OUTPUT BEGIN ===
1/11 Checking commit 228562c3dabd (TCG translation)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #15:
new file mode 100644
ERROR: space prohibited between function name and open parenthesis '(' #408: FILE: target/rx/op_helper.c:361:
+typedef float32 (*floatfunc)(float32 f1, float32 f2, float_status *st);
ERROR: spaces required around that '*' (ctx:WxV)
#408: FILE: target/rx/op_helper.c:361:
+typedef float32 (*floatfunc)(float32 f1, float32 f2, float_status *st);
^total: 2 errors, 1 warnings, 3573 lines checked
Patch 1/11 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
2/11 Checking commit 02c37e53dcae (RX CPU definition)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #11:
new file mode 100644
total: 0 errors, 1 warnings, 492 lines checked
Patch 2/11 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
3/11 Checking commit 276096a543bc (TCG helper functions)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #11:
new file mode 100644
total: 0 errors, 1 warnings, 143 lines checked
Patch 3/11 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
4/11 Checking commit ce17708f0bed (Target miscellaneous functions.)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #11:
new file mode 100644
total: 0 errors, 1 warnings, 152 lines checked
Patch 4/11 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
5/11 Checking commit 9cb21f3ffddb (RX disassembler)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #25:
new file mode 100644
ERROR: Macros with complex values should be enclosed in parenthesis #1067: FILE: disas/rx.c:1038:
+#define prt(...) dis->fprintf_func(dis->stream, __VA_ARGS__)
ERROR: space prohibited between function name and open parenthesis '(' #1326: FILE: include/disas/bfd.h:439:
+int print_insn_rx (bfd_vma, disassemble_info*);
total: 2 errors, 1 warnings, 1301 lines checked
Patch 5/11 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
6/11 Checking commit 58ae3376133f (RX62N interrupt contoller.)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #24:
new file mode 100644
total: 0 errors, 1 warnings, 366 lines checked
Patch 6/11 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
7/11 Checking commit d1fda562b065 (RX62N internal timer unit.)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #30:
new file mode 100644
ERROR: return is not a function, parentheses are not required #375: FILE: hw/timer/renesas_tmr.c:109:
+ return (tmr->tcnt[0] << 8) | (tmr->tcnt[1] & 0xff);
total: 1 errors, 1 warnings, 710 lines checked
Patch 7/11 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
8/11 Checking commit d098f8610bf1 (RX62N internal serical communication interface.)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #28:
new file mode 100644
total: 0 errors, 1 warnings, 329 lines checked
Patch 8/11 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
9/11 Checking commit 9b35f3e02a44 (RX Target hardware definition.)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #14:
new file mode 100644
total: 0 errors, 1 warnings, 392 lines checked
Patch 9/11 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
10/11 Checking commit 3778b8430851 (Add rx-softmmu.)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #50:
new file mode 100644
total: 0 errors, 1 warnings, 44 lines checked
Patch 10/11 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
11/11 Checking commit a739c452f473 (MAINTAINERS: Add RX entry.) === 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 [http://patchew.org/].
Please send your feedback to [email protected]