2 * Copyright (C) 2010-2012 Guan Xuetao
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 * Contributions from 2012-04-01 on are considered under GPL version 2,
9 * or (at your option) any later version.
12 #include "qemu/osdep.h"
15 #include "exec/exec-all.h"
16 #include "exec/helper-proto.h"
17 #include "hw/semihosting/console.h"
22 #define DPRINTF(fmt, ...) printf("%s: " fmt , __func__, ## __VA_ARGS__)
24 #define DPRINTF(fmt, ...) do {} while (0)
27 #ifndef CONFIG_USER_ONLY
28 void helper_cp0_set(CPUUniCore32State
*env
, uint32_t val
, uint32_t creg
,
32 * movc pp.nn, rn, #imm9
36 * 2: page table base reg.
37 * 3: data fault status reg.
38 * 4: insn fault status reg.
41 * imm9: split UCOP_IMM10 with bit5 is 0
48 env
->cp0
.c1_sys
= val
;
54 env
->cp0
.c2_base
= val
;
60 env
->cp0
.c3_faultstatus
= val
;
66 env
->cp0
.c4_faultaddr
= val
;
71 DPRINTF("Invalidate Entire I&D cache\n");
74 DPRINTF("Invalidate Entire Icache\n");
77 DPRINTF("Invalidate Entire Dcache\n");
80 DPRINTF("Clean Entire Dcache\n");
83 DPRINTF("Flush Entire Dcache\n");
86 DPRINTF("Invalidate Dcache line\n");
89 DPRINTF("Clean Dcache line\n");
92 DPRINTF("Flush Dcache line\n");
97 if ((cop
<= 6) && (cop
>= 2)) {
99 tlb_flush(env_cpu(env
));
108 qemu_log_mask(LOG_GUEST_ERROR
,
109 "Wrong register (%d) or wrong operation (%d) in cp0_set!\n",
113 uint32_t helper_cp0_get(CPUUniCore32State
*env
, uint32_t creg
, uint32_t cop
)
116 * movc rd, pp.nn, #imm9
119 * 0: cpuid and cachetype
120 * 1: sys control reg.
121 * 2: page table base reg.
122 * 3: data fault status reg.
123 * 4: insn fault status reg.
124 * imm9: split UCOP_IMM10 with bit5 is 0
130 return env
->cp0
.c0_cpuid
;
132 return env
->cp0
.c0_cachetype
;
137 return env
->cp0
.c1_sys
;
142 return env
->cp0
.c2_base
;
147 return env
->cp0
.c3_faultstatus
;
152 return env
->cp0
.c4_faultaddr
;
156 qemu_log_mask(LOG_GUEST_ERROR
,
157 "Wrong register (%d) or wrong operation (%d) in cp0_set!\n",
162 void helper_cp1_putc(target_ulong regval
)
164 const char c
= regval
;
166 qemu_semihosting_log_out(&c
, sizeof(c
));
168 #endif /* !CONFIG_USER_ONLY */
170 bool uc32_cpu_exec_interrupt(CPUState
*cs
, int interrupt_request
)
172 if (interrupt_request
& CPU_INTERRUPT_HARD
) {
173 UniCore32CPU
*cpu
= UNICORE32_CPU(cs
);
174 CPUUniCore32State
*env
= &cpu
->env
;
176 if (!(env
->uncached_asr
& ASR_I
)) {
177 cs
->exception_index
= UC32_EXCP_INTR
;
178 uc32_cpu_do_interrupt(cs
);