Revision | c073aa4e2b8108fe54852fb9eef1bb72c2128db4 (tree) |
---|---|
Time | 2020-01-23 21:44:24 |
Author | Yoshinori Sato <ysato@user...> |
Commiter | Yoshinori Sato |
target/rx: CPU definition
Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
Message-Id: <20190616142836.10614-4-ysato@users.sourceforge.jp>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20190607091116.49044-4-ysato@users.sourceforge.jp>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
[PMD: Use newer QOM style, split cpu-qom.h, restrict access to
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Acked-by: Igor Mammedov <imammedo@redhat.com>
@@ -1,5 +1,4 @@ | ||
1 | 1 | obj-y += translate.o op_helper.o helper.o cpu.o gdbstub.o disas.o |
2 | -obj-$(CONFIG_SOFTMMU) += monitor.o | |
3 | 2 | |
4 | 3 | DECODETREE = $(SRC_PATH)/scripts/decodetree.py |
5 | 4 |
@@ -0,0 +1,31 @@ | ||
1 | +/* | |
2 | + * RX cpu parameters | |
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_PARAM_H | |
20 | +#define RX_CPU_PARAM_H | |
21 | + | |
22 | +#define TARGET_LONG_BITS 32 | |
23 | +#define TARGET_PAGE_BITS 12 | |
24 | + | |
25 | +#define TARGET_PHYS_ADDR_SPACE_BITS 32 | |
26 | +#define TARGET_VIRT_ADDR_SPACE_BITS 32 | |
27 | + | |
28 | +#define NB_MMU_MODES 1 | |
29 | +#define MMU_MODE0_SUFFIX _all | |
30 | + | |
31 | +#endif |
@@ -0,0 +1,42 @@ | ||
1 | +#ifndef QEMU_RX_CPU_QOM_H | |
2 | +#define QEMU_RX_CPU_QOM_H | |
3 | + | |
4 | +#include "hw/core/cpu.h" | |
5 | +/* | |
6 | + * RX CPU | |
7 | + * | |
8 | + * Copyright (c) 2019 Yoshinori Sato | |
9 | + * SPDX-License-Identifier: LGPL-2.0+ | |
10 | + */ | |
11 | + | |
12 | +#define TYPE_RX_CPU "rx-cpu" | |
13 | + | |
14 | +#define TYPE_RX62N_CPU RX_CPU_TYPE_NAME("rx62n") | |
15 | + | |
16 | +#define RXCPU_CLASS(klass) \ | |
17 | + OBJECT_CLASS_CHECK(RXCPUClass, (klass), TYPE_RX_CPU) | |
18 | +#define RXCPU(obj) \ | |
19 | + OBJECT_CHECK(RXCPU, (obj), TYPE_RX_CPU) | |
20 | +#define RXCPU_GET_CLASS(obj) \ | |
21 | + OBJECT_GET_CLASS(RXCPUClass, (obj), TYPE_RX_CPU) | |
22 | + | |
23 | +/* | |
24 | + * RXCPUClass: | |
25 | + * @parent_realize: The parent class' realize handler. | |
26 | + * @parent_reset: The parent class' reset handler. | |
27 | + * | |
28 | + * A RX CPU model. | |
29 | + */ | |
30 | +typedef struct RXCPUClass { | |
31 | + /*< private >*/ | |
32 | + CPUClass parent_class; | |
33 | + /*< public >*/ | |
34 | + | |
35 | + DeviceRealize parent_realize; | |
36 | + void (*parent_reset)(CPUState *cpu); | |
37 | + | |
38 | +} RXCPUClass; | |
39 | + | |
40 | +#define CPUArchState struct CPURXState | |
41 | + | |
42 | +#endif |
@@ -0,0 +1,217 @@ | ||
1 | +/* | |
2 | + * QEMU RX CPU | |
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 | +#include "qemu/osdep.h" | |
20 | +#include "qemu/qemu-print.h" | |
21 | +#include "qapi/error.h" | |
22 | +#include "cpu.h" | |
23 | +#include "qemu-common.h" | |
24 | +#include "migration/vmstate.h" | |
25 | +#include "exec/exec-all.h" | |
26 | +#include "hw/loader.h" | |
27 | +#include "fpu/softfloat.h" | |
28 | + | |
29 | +static void rx_cpu_set_pc(CPUState *cs, vaddr value) | |
30 | +{ | |
31 | + RXCPU *cpu = RXCPU(cs); | |
32 | + | |
33 | + cpu->env.pc = value; | |
34 | +} | |
35 | + | |
36 | +static void rx_cpu_synchronize_from_tb(CPUState *cs, TranslationBlock *tb) | |
37 | +{ | |
38 | + RXCPU *cpu = RXCPU(cs); | |
39 | + | |
40 | + cpu->env.pc = tb->pc; | |
41 | +} | |
42 | + | |
43 | +static bool rx_cpu_has_work(CPUState *cs) | |
44 | +{ | |
45 | + return cs->interrupt_request & | |
46 | + (CPU_INTERRUPT_HARD | CPU_INTERRUPT_FIR); | |
47 | +} | |
48 | + | |
49 | +static void rx_cpu_reset(CPUState *s) | |
50 | +{ | |
51 | + RXCPU *cpu = RXCPU(s); | |
52 | + RXCPUClass *rcc = RXCPU_GET_CLASS(cpu); | |
53 | + CPURXState *env = &cpu->env; | |
54 | + uint32_t *resetvec; | |
55 | + | |
56 | + rcc->parent_reset(s); | |
57 | + | |
58 | + memset(env, 0, offsetof(CPURXState, end_reset_fields)); | |
59 | + | |
60 | + resetvec = rom_ptr(0xfffffffc, 4); | |
61 | + if (resetvec) { | |
62 | + /* In the case of kernel, it is ignored because it is not set. */ | |
63 | + env->pc = ldl_p(resetvec); | |
64 | + } | |
65 | + rx_cpu_unpack_psw(env, 0, 1); | |
66 | + env->regs[0] = env->isp = env->usp = 0; | |
67 | + env->fpsw = 0; | |
68 | + set_flush_to_zero(1, &env->fp_status); | |
69 | + set_flush_inputs_to_zero(1, &env->fp_status); | |
70 | +} | |
71 | + | |
72 | +static void rx_cpu_list_entry(gpointer data, gpointer user_data) | |
73 | +{ | |
74 | + const char *typename = object_class_get_name(OBJECT_CLASS(data)); | |
75 | + | |
76 | + qemu_printf("%s\n", typename); | |
77 | +} | |
78 | + | |
79 | +void rx_cpu_list(void) | |
80 | +{ | |
81 | + GSList *list; | |
82 | + list = object_class_get_list_sorted(TYPE_RX_CPU, false); | |
83 | + g_slist_foreach(list, rx_cpu_list_entry, NULL); | |
84 | + g_slist_free(list); | |
85 | +} | |
86 | + | |
87 | +static ObjectClass *rx_cpu_class_by_name(const char *cpu_model) | |
88 | +{ | |
89 | + ObjectClass *oc; | |
90 | + | |
91 | + oc = object_class_by_name(cpu_model); | |
92 | + if (object_class_dynamic_cast(oc, TYPE_RX_CPU) == NULL || | |
93 | + object_class_is_abstract(oc)) { | |
94 | + oc = NULL; | |
95 | + } | |
96 | + | |
97 | + return oc; | |
98 | +} | |
99 | + | |
100 | +static void rx_cpu_realize(DeviceState *dev, Error **errp) | |
101 | +{ | |
102 | + CPUState *cs = CPU(dev); | |
103 | + RXCPUClass *rcc = RXCPU_GET_CLASS(dev); | |
104 | + Error *local_err = NULL; | |
105 | + | |
106 | + cpu_exec_realizefn(cs, &local_err); | |
107 | + if (local_err != NULL) { | |
108 | + error_propagate(errp, local_err); | |
109 | + return; | |
110 | + } | |
111 | + | |
112 | + cpu_reset(cs); | |
113 | + qemu_init_vcpu(cs); | |
114 | + | |
115 | + rcc->parent_realize(dev, errp); | |
116 | +} | |
117 | + | |
118 | +static void rx_cpu_set_irq(void *opaque, int no, int request) | |
119 | +{ | |
120 | + RXCPU *cpu = opaque; | |
121 | + CPUState *cs = CPU(cpu); | |
122 | + int irq = request & 0xff; | |
123 | + | |
124 | + static const int mask[] = { | |
125 | + [RX_CPU_IRQ] = CPU_INTERRUPT_HARD, | |
126 | + [RX_CPU_FIR] = CPU_INTERRUPT_FIR, | |
127 | + }; | |
128 | + if (irq) { | |
129 | + cpu->env.req_irq = irq; | |
130 | + cpu->env.req_ipl = (request >> 8) & 0x0f; | |
131 | + cpu_interrupt(cs, mask[no]); | |
132 | + } else { | |
133 | + cpu_reset_interrupt(cs, mask[no]); | |
134 | + } | |
135 | +} | |
136 | + | |
137 | +static void rx_cpu_disas_set_info(CPUState *cpu, disassemble_info *info) | |
138 | +{ | |
139 | + info->mach = bfd_mach_rx; | |
140 | + info->print_insn = print_insn_rx; | |
141 | +} | |
142 | + | |
143 | +static bool rx_cpu_tlb_fill(CPUState *cs, vaddr addr, int size, | |
144 | + MMUAccessType access_type, int mmu_idx, | |
145 | + bool probe, uintptr_t retaddr) | |
146 | +{ | |
147 | + uint32_t address, physical, prot; | |
148 | + | |
149 | + /* Linear mapping */ | |
150 | + address = physical = addr & TARGET_PAGE_MASK; | |
151 | + prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; | |
152 | + tlb_set_page(cs, address, physical, prot, mmu_idx, TARGET_PAGE_SIZE); | |
153 | + return true; | |
154 | +} | |
155 | + | |
156 | +static void rx_cpu_init(Object *obj) | |
157 | +{ | |
158 | + CPUState *cs = CPU(obj); | |
159 | + RXCPU *cpu = RXCPU(obj); | |
160 | + CPURXState *env = &cpu->env; | |
161 | + | |
162 | + cpu_set_cpustate_pointers(cpu); | |
163 | + cs->env_ptr = env; | |
164 | + qdev_init_gpio_in(DEVICE(cpu), rx_cpu_set_irq, 2); | |
165 | +} | |
166 | + | |
167 | +static void rx_cpu_class_init(ObjectClass *klass, void *data) | |
168 | +{ | |
169 | + DeviceClass *dc = DEVICE_CLASS(klass); | |
170 | + CPUClass *cc = CPU_CLASS(klass); | |
171 | + RXCPUClass *rcc = RXCPU_CLASS(klass); | |
172 | + | |
173 | + device_class_set_parent_realize(dc, rx_cpu_realize, | |
174 | + &rcc->parent_realize); | |
175 | + | |
176 | + rcc->parent_reset = cc->reset; | |
177 | + cc->reset = rx_cpu_reset; | |
178 | + | |
179 | + cc->class_by_name = rx_cpu_class_by_name; | |
180 | + cc->has_work = rx_cpu_has_work; | |
181 | + cc->do_interrupt = rx_cpu_do_interrupt; | |
182 | + cc->cpu_exec_interrupt = rx_cpu_exec_interrupt; | |
183 | + cc->dump_state = rx_cpu_dump_state; | |
184 | + cc->set_pc = rx_cpu_set_pc; | |
185 | + cc->synchronize_from_tb = rx_cpu_synchronize_from_tb; | |
186 | + cc->gdb_read_register = rx_cpu_gdb_read_register; | |
187 | + cc->gdb_write_register = rx_cpu_gdb_write_register; | |
188 | + cc->get_phys_page_debug = rx_cpu_get_phys_page_debug; | |
189 | + cc->disas_set_info = rx_cpu_disas_set_info; | |
190 | + cc->tcg_initialize = rx_translate_init; | |
191 | + cc->tlb_fill = rx_cpu_tlb_fill; | |
192 | + | |
193 | + cc->gdb_num_core_regs = 26; | |
194 | +} | |
195 | + | |
196 | +static const TypeInfo rx_cpu_info = { | |
197 | + .name = TYPE_RX_CPU, | |
198 | + .parent = TYPE_CPU, | |
199 | + .instance_size = sizeof(RXCPU), | |
200 | + .instance_init = rx_cpu_init, | |
201 | + .abstract = true, | |
202 | + .class_size = sizeof(RXCPUClass), | |
203 | + .class_init = rx_cpu_class_init, | |
204 | +}; | |
205 | + | |
206 | +static const TypeInfo rx62n_rx_cpu_info = { | |
207 | + .name = TYPE_RX62N_CPU, | |
208 | + .parent = TYPE_RX_CPU, | |
209 | +}; | |
210 | + | |
211 | +static void rx_cpu_register_types(void) | |
212 | +{ | |
213 | + type_register_static(&rx_cpu_info); | |
214 | + type_register_static(&rx62n_rx_cpu_info); | |
215 | +} | |
216 | + | |
217 | +type_init(rx_cpu_register_types) |
@@ -0,0 +1,181 @@ | ||
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" | |
23 | +#include "qemu-common.h" | |
24 | +#include "hw/registerfields.h" | |
25 | +#include "cpu-qom.h" | |
26 | + | |
27 | +#include "exec/cpu-defs.h" | |
28 | + | |
29 | +/* PSW define */ | |
30 | +REG32(PSW, 0) | |
31 | +FIELD(PSW, C, 0, 1) | |
32 | +FIELD(PSW, Z, 1, 1) | |
33 | +FIELD(PSW, S, 2, 1) | |
34 | +FIELD(PSW, O, 3, 1) | |
35 | +FIELD(PSW, I, 16, 1) | |
36 | +FIELD(PSW, U, 17, 1) | |
37 | +FIELD(PSW, PM, 20, 1) | |
38 | +FIELD(PSW, IPL, 24, 4) | |
39 | + | |
40 | +/* FPSW define */ | |
41 | +REG32(FPSW, 0) | |
42 | +FIELD(FPSW, RM, 0, 2) | |
43 | +FIELD(FPSW, CV, 2, 1) | |
44 | +FIELD(FPSW, CO, 3, 1) | |
45 | +FIELD(FPSW, CZ, 4, 1) | |
46 | +FIELD(FPSW, CU, 5, 1) | |
47 | +FIELD(FPSW, CX, 6, 1) | |
48 | +FIELD(FPSW, CE, 7, 1) | |
49 | +FIELD(FPSW, CAUSE, 2, 6) | |
50 | +FIELD(FPSW, DN, 8, 1) | |
51 | +FIELD(FPSW, EV, 10, 1) | |
52 | +FIELD(FPSW, EO, 11, 1) | |
53 | +FIELD(FPSW, EZ, 12, 1) | |
54 | +FIELD(FPSW, EU, 13, 1) | |
55 | +FIELD(FPSW, EX, 14, 1) | |
56 | +FIELD(FPSW, ENABLE, 10, 5) | |
57 | +FIELD(FPSW, FV, 26, 1) | |
58 | +FIELD(FPSW, FO, 27, 1) | |
59 | +FIELD(FPSW, FZ, 28, 1) | |
60 | +FIELD(FPSW, FU, 29, 1) | |
61 | +FIELD(FPSW, FX, 30, 1) | |
62 | +FIELD(FPSW, FLAGS, 26, 4) | |
63 | +FIELD(FPSW, FS, 31, 1) | |
64 | + | |
65 | +enum { | |
66 | + NUM_REGS = 16, | |
67 | +}; | |
68 | + | |
69 | +typedef struct CPURXState { | |
70 | + /* CPU registers */ | |
71 | + uint32_t regs[NUM_REGS]; /* general registers */ | |
72 | + uint32_t psw_o; /* O bit of status register */ | |
73 | + uint32_t psw_s; /* S bit of status register */ | |
74 | + uint32_t psw_z; /* Z bit of status register */ | |
75 | + uint32_t psw_c; /* C bit of status register */ | |
76 | + uint32_t psw_u; | |
77 | + uint32_t psw_i; | |
78 | + uint32_t psw_pm; | |
79 | + uint32_t psw_ipl; | |
80 | + uint32_t bpsw; /* backup status */ | |
81 | + uint32_t bpc; /* backup pc */ | |
82 | + uint32_t isp; /* global base register */ | |
83 | + uint32_t usp; /* vector base register */ | |
84 | + uint32_t pc; /* program counter */ | |
85 | + uint32_t intb; /* interrupt vector */ | |
86 | + uint32_t fintv; | |
87 | + uint32_t fpsw; | |
88 | + uint64_t acc; | |
89 | + | |
90 | + /* Fields up to this point are cleared by a CPU reset */ | |
91 | + struct {} end_reset_fields; | |
92 | + | |
93 | + /* Internal use */ | |
94 | + uint32_t in_sleep; | |
95 | + uint32_t req_irq; /* Requested interrupt no (hard) */ | |
96 | + uint32_t req_ipl; /* Requested interrupt level */ | |
97 | + uint32_t ack_irq; /* execute irq */ | |
98 | + uint32_t ack_ipl; /* execute ipl */ | |
99 | + float_status fp_status; | |
100 | + qemu_irq ack; /* Interrupt acknowledge */ | |
101 | +} CPURXState; | |
102 | + | |
103 | +/* | |
104 | + * RXCPU: | |
105 | + * @env: #CPURXState | |
106 | + * | |
107 | + * A RX CPU | |
108 | + */ | |
109 | +struct RXCPU { | |
110 | + /*< private >*/ | |
111 | + CPUState parent_obj; | |
112 | + /*< public >*/ | |
113 | + | |
114 | + CPUNegativeOffsetState neg; | |
115 | + CPURXState env; | |
116 | +}; | |
117 | + | |
118 | +typedef struct RXCPU RXCPU; | |
119 | +typedef RXCPU ArchCPU; | |
120 | + | |
121 | +#define ENV_OFFSET offsetof(RXCPU, env) | |
122 | + | |
123 | +#define RX_CPU_TYPE_SUFFIX "-" TYPE_RX_CPU | |
124 | +#define RX_CPU_TYPE_NAME(model) model RX_CPU_TYPE_SUFFIX | |
125 | +#define CPU_RESOLVING_TYPE TYPE_RX_CPU | |
126 | + | |
127 | +extern const char rx_crname[][6]; | |
128 | + | |
129 | +void rx_cpu_do_interrupt(CPUState *cpu); | |
130 | +bool rx_cpu_exec_interrupt(CPUState *cpu, int int_req); | |
131 | +void rx_cpu_dump_state(CPUState *cpu, FILE *f, int flags); | |
132 | +int rx_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); | |
133 | +int rx_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); | |
134 | +hwaddr rx_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); | |
135 | + | |
136 | +void rx_translate_init(void); | |
137 | +int cpu_rx_signal_handler(int host_signum, void *pinfo, | |
138 | + void *puc); | |
139 | + | |
140 | +void rx_cpu_list(void); | |
141 | +void rx_cpu_unpack_psw(CPURXState *env, uint32_t psw, int rte); | |
142 | + | |
143 | +#define cpu_signal_handler cpu_rx_signal_handler | |
144 | +#define cpu_list rx_cpu_list | |
145 | + | |
146 | +#include "exec/cpu-all.h" | |
147 | + | |
148 | +#define CPU_INTERRUPT_SOFT CPU_INTERRUPT_TGT_INT_0 | |
149 | +#define CPU_INTERRUPT_FIR CPU_INTERRUPT_TGT_INT_1 | |
150 | + | |
151 | +#define RX_CPU_IRQ 0 | |
152 | +#define RX_CPU_FIR 1 | |
153 | + | |
154 | +static inline void cpu_get_tb_cpu_state(CPURXState *env, target_ulong *pc, | |
155 | + target_ulong *cs_base, uint32_t *flags) | |
156 | +{ | |
157 | + *pc = env->pc; | |
158 | + *cs_base = 0; | |
159 | + *flags = FIELD_DP32(0, PSW, PM, env->psw_pm); | |
160 | +} | |
161 | + | |
162 | +static inline int cpu_mmu_index(CPURXState *env, bool ifetch) | |
163 | +{ | |
164 | + return 0; | |
165 | +} | |
166 | + | |
167 | +static inline uint32_t rx_cpu_pack_psw(CPURXState *env) | |
168 | +{ | |
169 | + uint32_t psw = 0; | |
170 | + psw = FIELD_DP32(psw, PSW, IPL, env->psw_ipl); | |
171 | + psw = FIELD_DP32(psw, PSW, PM, env->psw_pm); | |
172 | + psw = FIELD_DP32(psw, PSW, U, env->psw_u); | |
173 | + psw = FIELD_DP32(psw, PSW, I, env->psw_i); | |
174 | + psw = FIELD_DP32(psw, PSW, O, env->psw_o >> 31); | |
175 | + psw = FIELD_DP32(psw, PSW, S, env->psw_s >> 31); | |
176 | + psw = FIELD_DP32(psw, PSW, Z, env->psw_z == 0); | |
177 | + psw = FIELD_DP32(psw, PSW, C, env->psw_c); | |
178 | + return psw; | |
179 | +} | |
180 | + | |
181 | +#endif /* RX_CPU_H */ |
@@ -0,0 +1,112 @@ | ||
1 | +/* | |
2 | + * RX gdb server stub | |
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 | +#include "qemu/osdep.h" | |
19 | +#include "qemu-common.h" | |
20 | +#include "cpu.h" | |
21 | +#include "exec/gdbstub.h" | |
22 | + | |
23 | +int rx_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) | |
24 | +{ | |
25 | + RXCPU *cpu = RXCPU(cs); | |
26 | + CPURXState *env = &cpu->env; | |
27 | + | |
28 | + switch (n) { | |
29 | + case 0 ... 15: | |
30 | + return gdb_get_regl(mem_buf, env->regs[n]); | |
31 | + case 16: | |
32 | + return gdb_get_regl(mem_buf, (env->psw_u) ? env->regs[0] : env->usp); | |
33 | + case 17: | |
34 | + return gdb_get_regl(mem_buf, (!env->psw_u) ? env->regs[0] : env->isp); | |
35 | + case 18: | |
36 | + return gdb_get_regl(mem_buf, rx_cpu_pack_psw(env)); | |
37 | + case 19: | |
38 | + return gdb_get_regl(mem_buf, env->pc); | |
39 | + case 20: | |
40 | + return gdb_get_regl(mem_buf, env->intb); | |
41 | + case 21: | |
42 | + return gdb_get_regl(mem_buf, env->bpsw); | |
43 | + case 22: | |
44 | + return gdb_get_regl(mem_buf, env->bpc); | |
45 | + case 23: | |
46 | + return gdb_get_regl(mem_buf, env->fintv); | |
47 | + case 24: | |
48 | + return gdb_get_regl(mem_buf, env->fpsw); | |
49 | + case 25: | |
50 | + return 0; | |
51 | + } | |
52 | + return 0; | |
53 | +} | |
54 | + | |
55 | +int rx_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) | |
56 | +{ | |
57 | + RXCPU *cpu = RXCPU(cs); | |
58 | + CPURXState *env = &cpu->env; | |
59 | + uint32_t psw; | |
60 | + switch (n) { | |
61 | + case 0 ... 15: | |
62 | + env->regs[n] = ldl_p(mem_buf); | |
63 | + if (n == 0) { | |
64 | + if (env->psw_u) { | |
65 | + env->usp = env->regs[0]; | |
66 | + } else { | |
67 | + env->isp = env->regs[0]; | |
68 | + } | |
69 | + } | |
70 | + break; | |
71 | + case 16: | |
72 | + env->usp = ldl_p(mem_buf); | |
73 | + if (env->psw_u) { | |
74 | + env->regs[0] = ldl_p(mem_buf); | |
75 | + } | |
76 | + break; | |
77 | + case 17: | |
78 | + env->isp = ldl_p(mem_buf); | |
79 | + if (!env->psw_u) { | |
80 | + env->regs[0] = ldl_p(mem_buf); | |
81 | + } | |
82 | + break; | |
83 | + case 18: | |
84 | + psw = ldl_p(mem_buf); | |
85 | + rx_cpu_unpack_psw(env, psw, 1); | |
86 | + break; | |
87 | + case 19: | |
88 | + env->pc = ldl_p(mem_buf); | |
89 | + break; | |
90 | + case 20: | |
91 | + env->intb = ldl_p(mem_buf); | |
92 | + break; | |
93 | + case 21: | |
94 | + env->bpsw = ldl_p(mem_buf); | |
95 | + break; | |
96 | + case 22: | |
97 | + env->bpc = ldl_p(mem_buf); | |
98 | + break; | |
99 | + case 23: | |
100 | + env->fintv = ldl_p(mem_buf); | |
101 | + break; | |
102 | + case 24: | |
103 | + env->fpsw = ldl_p(mem_buf); | |
104 | + break; | |
105 | + case 25: | |
106 | + return 8; | |
107 | + default: | |
108 | + return 0; | |
109 | + } | |
110 | + | |
111 | + return 4; | |
112 | +} |