]> git.proxmox.com Git - mirror_qemu.git/blame - target/rx/cpu.h
target: Use ArchCPU as interface to target CPU
[mirror_qemu.git] / target / rx / cpu.h
CommitLineData
27a4a30e
YS
1/*
2 * RX emulation definition
3 *
4 * Copyright (c) 2019 Yoshinori Sato
5 *
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.
9 *
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
13 * more details.
14 *
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/>.
17 */
18
19#ifndef RX_CPU_H
20#define RX_CPU_H
21
22#include "qemu/bitops.h"
27a4a30e
YS
23#include "hw/registerfields.h"
24#include "cpu-qom.h"
25
26#include "exec/cpu-defs.h"
27
28/* PSW define */
29REG32(PSW, 0)
30FIELD(PSW, C, 0, 1)
31FIELD(PSW, Z, 1, 1)
32FIELD(PSW, S, 2, 1)
33FIELD(PSW, O, 3, 1)
34FIELD(PSW, I, 16, 1)
35FIELD(PSW, U, 17, 1)
36FIELD(PSW, PM, 20, 1)
37FIELD(PSW, IPL, 24, 4)
38
39/* FPSW define */
40REG32(FPSW, 0)
41FIELD(FPSW, RM, 0, 2)
42FIELD(FPSW, CV, 2, 1)
43FIELD(FPSW, CO, 3, 1)
44FIELD(FPSW, CZ, 4, 1)
45FIELD(FPSW, CU, 5, 1)
46FIELD(FPSW, CX, 6, 1)
47FIELD(FPSW, CE, 7, 1)
48FIELD(FPSW, CAUSE, 2, 6)
49FIELD(FPSW, DN, 8, 1)
50FIELD(FPSW, EV, 10, 1)
51FIELD(FPSW, EO, 11, 1)
52FIELD(FPSW, EZ, 12, 1)
53FIELD(FPSW, EU, 13, 1)
54FIELD(FPSW, EX, 14, 1)
55FIELD(FPSW, ENABLE, 10, 5)
56FIELD(FPSW, FV, 26, 1)
57FIELD(FPSW, FO, 27, 1)
58FIELD(FPSW, FZ, 28, 1)
59FIELD(FPSW, FU, 29, 1)
60FIELD(FPSW, FX, 30, 1)
61FIELD(FPSW, FLAGS, 26, 4)
62FIELD(FPSW, FS, 31, 1)
63
64enum {
65 NUM_REGS = 16,
66};
67
1ea4a06a 68typedef struct CPUArchState {
27a4a30e
YS
69 /* CPU registers */
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 */
75 uint32_t psw_u;
76 uint32_t psw_i;
77 uint32_t psw_pm;
78 uint32_t psw_ipl;
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 */
85 uint32_t fintv;
86 uint32_t fpsw;
87 uint64_t acc;
88
89 /* Fields up to this point are cleared by a CPU reset */
90 struct {} end_reset_fields;
91
92 /* Internal use */
93 uint32_t in_sleep;
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 */
100} CPURXState;
101
102/*
103 * RXCPU:
104 * @env: #CPURXState
105 *
106 * A RX CPU
107 */
b36e239e 108struct ArchCPU {
27a4a30e
YS
109 /*< private >*/
110 CPUState parent_obj;
111 /*< public >*/
112
113 CPUNegativeOffsetState neg;
114 CPURXState env;
115};
116
27a4a30e
YS
117#define RX_CPU_TYPE_SUFFIX "-" TYPE_RX_CPU
118#define RX_CPU_TYPE_NAME(model) model RX_CPU_TYPE_SUFFIX
119#define CPU_RESOLVING_TYPE TYPE_RX_CPU
120
121const char *rx_crname(uint8_t cr);
65c575b6 122#ifndef CONFIG_USER_ONLY
27a4a30e
YS
123void rx_cpu_do_interrupt(CPUState *cpu);
124bool rx_cpu_exec_interrupt(CPUState *cpu, int int_req);
65c575b6 125#endif /* !CONFIG_USER_ONLY */
27a4a30e
YS
126void rx_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
127int rx_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
128int rx_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
129hwaddr rx_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
130
131void rx_translate_init(void);
27a4a30e
YS
132void rx_cpu_list(void);
133void rx_cpu_unpack_psw(CPURXState *env, uint32_t psw, int rte);
134
27a4a30e
YS
135#define cpu_list rx_cpu_list
136
137#include "exec/cpu-all.h"
138
139#define CPU_INTERRUPT_SOFT CPU_INTERRUPT_TGT_INT_0
140#define CPU_INTERRUPT_FIR CPU_INTERRUPT_TGT_INT_1
141
142#define RX_CPU_IRQ 0
143#define RX_CPU_FIR 1
144
145static inline void cpu_get_tb_cpu_state(CPURXState *env, target_ulong *pc,
146 target_ulong *cs_base, uint32_t *flags)
147{
148 *pc = env->pc;
149 *cs_base = 0;
150 *flags = FIELD_DP32(0, PSW, PM, env->psw_pm);
151}
152
153static inline int cpu_mmu_index(CPURXState *env, bool ifetch)
154{
155 return 0;
156}
157
158static inline uint32_t rx_cpu_pack_psw(CPURXState *env)
159{
160 uint32_t psw = 0;
161 psw = FIELD_DP32(psw, PSW, IPL, env->psw_ipl);
162 psw = FIELD_DP32(psw, PSW, PM, env->psw_pm);
163 psw = FIELD_DP32(psw, PSW, U, env->psw_u);
164 psw = FIELD_DP32(psw, PSW, I, env->psw_i);
165 psw = FIELD_DP32(psw, PSW, O, env->psw_o >> 31);
166 psw = FIELD_DP32(psw, PSW, S, env->psw_s >> 31);
167 psw = FIELD_DP32(psw, PSW, Z, env->psw_z == 0);
168 psw = FIELD_DP32(psw, PSW, C, env->psw_c);
169 return psw;
170}
171
172#endif /* RX_CPU_H */