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,
35 * movc pp.nn, rn, #imm9
39 * 2: page table base reg.
40 * 3: data fault status reg.
41 * 4: insn fault status reg.
44 * imm9: split UCOP_IMM10 with bit5 is 0
51 env->cp0.c1_sys = val;
57 env->cp0.c2_base = val;
63 env->cp0.c3_faultstatus = val;
69 env->cp0.c4_faultaddr = val;
74 DPRINTF("Invalidate Entire I&D cache\n");
77 DPRINTF("Invalidate Entire Icache\n");
80 DPRINTF("Invalidate Entire Dcache\n");
83 DPRINTF("Clean Entire Dcache\n");
86 DPRINTF("Flush Entire Dcache\n");
89 DPRINTF("Invalidate Dcache line\n");
92 DPRINTF("Clean Dcache line\n");
95 DPRINTF("Flush Dcache line\n");
100 if ((cop <= 6) && (cop >= 2)) {
101 /* invalid all tlb */
102 tlb_flush(env_cpu(env));
111 DPRINTF("Wrong register (%d) or wrong operation (%d) in cp0_set!\n",
115 uint32_t helper_cp0_get(CPUUniCore32State *env, uint32_t creg, uint32_t cop)
118 * movc rd, pp.nn, #imm9
121 * 0: cpuid and cachetype
122 * 1: sys control reg.
123 * 2: page table base reg.
124 * 3: data fault status reg.
125 * 4: insn fault status reg.
126 * imm9: split UCOP_IMM10 with bit5 is 0
132 return env->cp0.c0_cpuid;
134 return env->cp0.c0_cachetype;
139 return env->cp0.c1_sys;
144 return env->cp0.c2_base;
149 return env->cp0.c3_faultstatus;
154 return env->cp0.c4_faultaddr;
158 DPRINTF("Wrong register (%d) or wrong operation (%d) in cp0_set!\n",
165 /* KEY_EVENT is defined in wincon.h and in curses.h. Avoid redefinition. */
172 * 1. curses windows will be blank when switching back
173 * 2. backspace is not handled yet
175 static void putc_on_screen(unsigned char ch)
177 static WINDOW *localwin;
181 /* Assume 80 * 30 screen to minimize the implementation */
182 localwin = newwin(30, 80, 0, 0);
183 scrollok(localwin, TRUE);
188 wprintw(localwin, "%c", ch);
192 wprintw(localwin, "%c", ch);
195 /* If '\r' is put before '\n', the curses window will destroy the
196 * last print line. And meanwhile, '\n' implifies '\r' inside. */
198 default: /* Not handled, so just print it hex code */
199 wprintw(localwin, "-- 0x%x --", ch);
206 #define putc_on_screen(c) do { } while (0)
209 void helper_cp1_putc(target_ulong x)
211 putc_on_screen((unsigned char)x); /* Output to screen */
212 DPRINTF("%c", x); /* Output to stdout */
216 bool uc32_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
218 if (interrupt_request & CPU_INTERRUPT_HARD) {
219 UniCore32CPU *cpu = UNICORE32_CPU(cs);
220 CPUUniCore32State *env = &cpu->env;
222 if (!(env->uncached_asr & ASR_I)) {
223 cs->exception_index = UC32_EXCP_INTR;
224 uc32_cpu_do_interrupt(cs);