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"
14 #include "exec/exec-all.h"
15 #include "exec/gdbstub.h"
16 #include "exec/helper-proto.h"
17 #include "qemu/host-utils.h"
18 #ifndef CONFIG_USER_ONLY
19 #include "ui/console.h"
25 #define DPRINTF(fmt, ...) printf("%s: " fmt , __func__, ## __VA_ARGS__)
27 #define DPRINTF(fmt, ...) do {} while (0)
30 #ifndef CONFIG_USER_ONLY
31 void helper_cp0_set(CPUUniCore32State
*env
, uint32_t val
, uint32_t creg
,
34 UniCore32CPU
*cpu
= uc32_env_get_cpu(env
);
37 * movc pp.nn, rn, #imm9
41 * 2: page table base reg.
42 * 3: data fault status reg.
43 * 4: insn fault status reg.
46 * imm9: split UCOP_IMM10 with bit5 is 0
53 env
->cp0
.c1_sys
= val
;
59 env
->cp0
.c2_base
= val
;
65 env
->cp0
.c3_faultstatus
= val
;
71 env
->cp0
.c4_faultaddr
= val
;
76 DPRINTF("Invalidate Entire I&D cache\n");
79 DPRINTF("Invalidate Entire Icache\n");
82 DPRINTF("Invalidate Entire Dcache\n");
85 DPRINTF("Clean Entire Dcache\n");
88 DPRINTF("Flush Entire Dcache\n");
91 DPRINTF("Invalidate Dcache line\n");
94 DPRINTF("Clean Dcache line\n");
97 DPRINTF("Flush Dcache line\n");
102 if ((cop
<= 6) && (cop
>= 2)) {
103 /* invalid all tlb */
113 DPRINTF("Wrong register (%d) or wrong operation (%d) in cp0_set!\n",
117 uint32_t helper_cp0_get(CPUUniCore32State
*env
, uint32_t creg
, uint32_t cop
)
120 * movc rd, pp.nn, #imm9
123 * 0: cpuid and cachetype
124 * 1: sys control reg.
125 * 2: page table base reg.
126 * 3: data fault status reg.
127 * 4: insn fault status reg.
128 * imm9: split UCOP_IMM10 with bit5 is 0
134 return env
->cp0
.c0_cpuid
;
136 return env
->cp0
.c0_cachetype
;
141 return env
->cp0
.c1_sys
;
146 return env
->cp0
.c2_base
;
151 return env
->cp0
.c3_faultstatus
;
156 return env
->cp0
.c4_faultaddr
;
160 DPRINTF("Wrong register (%d) or wrong operation (%d) in cp0_set!\n",
167 /* KEY_EVENT is defined in wincon.h and in curses.h. Avoid redefinition. */
174 * 1. curses windows will be blank when switching back
175 * 2. backspace is not handled yet
177 static void putc_on_screen(unsigned char ch
)
179 static WINDOW
*localwin
;
183 /* Assume 80 * 30 screen to minimize the implementation */
184 localwin
= newwin(30, 80, 0, 0);
185 scrollok(localwin
, TRUE
);
190 wprintw(localwin
, "%c", ch
);
194 wprintw(localwin
, "%c", ch
);
197 /* If '\r' is put before '\n', the curses window will destroy the
198 * last print line. And meanwhile, '\n' implifies '\r' inside. */
200 default: /* Not handled, so just print it hex code */
201 wprintw(localwin
, "-- 0x%x --", ch
);
208 #define putc_on_screen(c) do { } while (0)
211 void helper_cp1_putc(target_ulong x
)
213 putc_on_screen((unsigned char)x
); /* Output to screen */
214 DPRINTF("%c", x
); /* Output to stdout */
218 bool uc32_cpu_exec_interrupt(CPUState
*cs
, int interrupt_request
)
220 if (interrupt_request
& CPU_INTERRUPT_HARD
) {
221 UniCore32CPU
*cpu
= UNICORE32_CPU(cs
);
222 CPUUniCore32State
*env
= &cpu
->env
;
224 if (!(env
->uncached_asr
& ASR_I
)) {
225 cs
->exception_index
= UC32_EXCP_INTR
;
226 uc32_cpu_do_interrupt(cs
);