2 * RX emulation definition
4 * Copyright (c) 2019 Yoshinori Sato
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2 or later, as published by the Free Software Foundation.
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License along with
16 * this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "qemu/bitops.h"
23 #include "hw/registerfields.h"
26 #include "exec/cpu-defs.h"
37 FIELD(PSW
, IPL
, 24, 4)
48 FIELD(FPSW
, CAUSE
, 2, 6)
50 FIELD(FPSW
, EV
, 10, 1)
51 FIELD(FPSW
, EO
, 11, 1)
52 FIELD(FPSW
, EZ
, 12, 1)
53 FIELD(FPSW
, EU
, 13, 1)
54 FIELD(FPSW
, EX
, 14, 1)
55 FIELD(FPSW
, ENABLE
, 10, 5)
56 FIELD(FPSW
, FV
, 26, 1)
57 FIELD(FPSW
, FO
, 27, 1)
58 FIELD(FPSW
, FZ
, 28, 1)
59 FIELD(FPSW
, FU
, 29, 1)
60 FIELD(FPSW
, FX
, 30, 1)
61 FIELD(FPSW
, FLAGS
, 26, 4)
62 FIELD(FPSW
, FS
, 31, 1)
68 typedef struct CPURXState
{
70 uint32_t regs
[NUM_REGS
]; /* general registers */
71 uint32_t psw_o
; /* O bit of status register */
72 uint32_t psw_s
; /* S bit of status register */
73 uint32_t psw_z
; /* Z bit of status register */
74 uint32_t psw_c
; /* C bit of status register */
79 uint32_t bpsw
; /* backup status */
80 uint32_t bpc
; /* backup pc */
81 uint32_t isp
; /* global base register */
82 uint32_t usp
; /* vector base register */
83 uint32_t pc
; /* program counter */
84 uint32_t intb
; /* interrupt vector */
89 /* Fields up to this point are cleared by a CPU reset */
90 struct {} end_reset_fields
;
94 uint32_t req_irq
; /* Requested interrupt no (hard) */
95 uint32_t req_ipl
; /* Requested interrupt level */
96 uint32_t ack_irq
; /* execute irq */
97 uint32_t ack_ipl
; /* execute ipl */
98 float_status fp_status
;
99 qemu_irq ack
; /* Interrupt acknowledge */
113 CPUNegativeOffsetState neg
;
117 typedef RXCPU ArchCPU
;
119 #define ENV_OFFSET offsetof(RXCPU, env)
121 #define RX_CPU_TYPE_SUFFIX "-" TYPE_RX_CPU
122 #define RX_CPU_TYPE_NAME(model) model RX_CPU_TYPE_SUFFIX
123 #define CPU_RESOLVING_TYPE TYPE_RX_CPU
125 const char *rx_crname(uint8_t cr
);
126 #ifndef CONFIG_USER_ONLY
127 void rx_cpu_do_interrupt(CPUState
*cpu
);
128 bool rx_cpu_exec_interrupt(CPUState
*cpu
, int int_req
);
129 #endif /* !CONFIG_USER_ONLY */
130 void rx_cpu_dump_state(CPUState
*cpu
, FILE *f
, int flags
);
131 int rx_cpu_gdb_read_register(CPUState
*cpu
, GByteArray
*buf
, int reg
);
132 int rx_cpu_gdb_write_register(CPUState
*cpu
, uint8_t *buf
, int reg
);
133 hwaddr
rx_cpu_get_phys_page_debug(CPUState
*cpu
, vaddr addr
);
135 void rx_translate_init(void);
136 void rx_cpu_list(void);
137 void rx_cpu_unpack_psw(CPURXState
*env
, uint32_t psw
, int rte
);
139 #define cpu_list rx_cpu_list
141 #include "exec/cpu-all.h"
143 #define CPU_INTERRUPT_SOFT CPU_INTERRUPT_TGT_INT_0
144 #define CPU_INTERRUPT_FIR CPU_INTERRUPT_TGT_INT_1
149 static inline void cpu_get_tb_cpu_state(CPURXState
*env
, target_ulong
*pc
,
150 target_ulong
*cs_base
, uint32_t *flags
)
154 *flags
= FIELD_DP32(0, PSW
, PM
, env
->psw_pm
);
157 static inline int cpu_mmu_index(CPURXState
*env
, bool ifetch
)
162 static inline uint32_t rx_cpu_pack_psw(CPURXState
*env
)
165 psw
= FIELD_DP32(psw
, PSW
, IPL
, env
->psw_ipl
);
166 psw
= FIELD_DP32(psw
, PSW
, PM
, env
->psw_pm
);
167 psw
= FIELD_DP32(psw
, PSW
, U
, env
->psw_u
);
168 psw
= FIELD_DP32(psw
, PSW
, I
, env
->psw_i
);
169 psw
= FIELD_DP32(psw
, PSW
, O
, env
->psw_o
>> 31);
170 psw
= FIELD_DP32(psw
, PSW
, S
, env
->psw_s
>> 31);
171 psw
= FIELD_DP32(psw
, PSW
, Z
, env
->psw_z
== 0);
172 psw
= FIELD_DP32(psw
, PSW
, C
, env
->psw_c
);
176 #endif /* RX_CPU_H */