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.
15 #include "host-utils.h"
20 #define DPRINTF(fmt, ...) printf("%s: " fmt , __func__, ## __VA_ARGS__)
22 #define DPRINTF(fmt, ...) do {} while (0)
25 CPUUniCore32State
*uc32_cpu_init(const char *cpu_model
)
28 CPUUniCore32State
*env
;
29 static int inited
= 1;
31 if (object_class_by_name(cpu_model
) == NULL
) {
34 cpu
= UNICORE32_CPU(object_new(cpu_model
));
39 uc32_translate_init();
46 uint32_t HELPER(clo
)(uint32_t x
)
51 uint32_t HELPER(clz
)(uint32_t x
)
56 #ifndef CONFIG_USER_ONLY
57 void helper_cp0_set(CPUUniCore32State
*env
, uint32_t val
, uint32_t creg
,
61 * movc pp.nn, rn, #imm9
65 * 2: page table base reg.
66 * 3: data fault status reg.
67 * 4: insn fault status reg.
70 * imm9: split UCOP_IMM10 with bit5 is 0
77 env
->cp0
.c1_sys
= val
;
83 env
->cp0
.c2_base
= val
;
89 env
->cp0
.c3_faultstatus
= val
;
95 env
->cp0
.c4_faultaddr
= val
;
100 DPRINTF("Invalidate Entire I&D cache\n");
103 DPRINTF("Invalidate Entire Icache\n");
106 DPRINTF("Invalidate Entire Dcache\n");
109 DPRINTF("Clean Entire Dcache\n");
112 DPRINTF("Flush Entire Dcache\n");
115 DPRINTF("Invalidate Dcache line\n");
118 DPRINTF("Clean Dcache line\n");
121 DPRINTF("Flush Dcache line\n");
126 if ((cop
<= 6) && (cop
>= 2)) {
127 /* invalid all tlb */
137 DPRINTF("Wrong register (%d) or wrong operation (%d) in cp0_set!\n",
141 uint32_t helper_cp0_get(CPUUniCore32State
*env
, uint32_t creg
, uint32_t cop
)
144 * movc rd, pp.nn, #imm9
147 * 0: cpuid and cachetype
148 * 1: sys control reg.
149 * 2: page table base reg.
150 * 3: data fault status reg.
151 * 4: insn fault status reg.
152 * imm9: split UCOP_IMM10 with bit5 is 0
158 return env
->cp0
.c0_cpuid
;
160 return env
->cp0
.c0_cachetype
;
165 return env
->cp0
.c1_sys
;
170 return env
->cp0
.c2_base
;
175 return env
->cp0
.c3_faultstatus
;
180 return env
->cp0
.c4_faultaddr
;
184 DPRINTF("Wrong register (%d) or wrong operation (%d) in cp0_set!\n",
189 void helper_cp1_putc(target_ulong x
)
191 /* TODO: curses display should be added here for screen output. */
196 #ifdef CONFIG_USER_ONLY
197 void switch_mode(CPUUniCore32State
*env
, int mode
)
199 if (mode
!= ASR_MODE_USER
) {
200 cpu_abort(env
, "Tried to switch out of user mode\n");
204 void do_interrupt(CPUUniCore32State
*env
)
206 cpu_abort(env
, "NO interrupt in user mode\n");
209 int uc32_cpu_handle_mmu_fault(CPUUniCore32State
*env
, target_ulong address
,
210 int access_type
, int mmu_idx
)
212 cpu_abort(env
, "NO mmu fault in user mode\n");