]> git.proxmox.com Git - mirror_qemu.git/blob - target-tricore/helper.c
target-tricore: Add target stubs and qom-cpu
[mirror_qemu.git] / target-tricore / helper.c
1 /*
2 * Copyright (c) 2012-2014 Bastian Koppelmann C-Lab/University Paderborn
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include <stdarg.h>
19 #include <stdlib.h>
20 #include <stdio.h>
21 #include <string.h>
22 #include <inttypes.h>
23 #include <signal.h>
24
25 #include "cpu.h"
26
27 int cpu_tricore_handle_mmu_fault(CPUState *cs, target_ulong address,
28 int rw, int mmu_idx)
29 {
30 return 0;
31 }
32
33 void tricore_cpu_do_interrupt(CPUState *cs)
34 {
35 }
36
37 TriCoreCPU *cpu_tricore_init(const char *cpu_model)
38 {
39 return TRICORE_CPU(cpu_generic_init(TYPE_TRICORE_CPU, cpu_model));
40 }
41
42 static void tricore_cpu_list_entry(gpointer data, gpointer user_data)
43 {
44 ObjectClass *oc = data;
45 CPUListState *s = user_data;
46 const char *typename;
47 char *name;
48
49 typename = object_class_get_name(oc);
50 name = g_strndup(typename, strlen(typename) - strlen("-" TYPE_TRICORE_CPU));
51 (*s->cpu_fprintf)(s->file, " %s\n",
52 name);
53 g_free(name);
54 }
55
56 void tricore_cpu_list(FILE *f, fprintf_function cpu_fprintf)
57 {
58 CPUListState s = {
59 .file = f,
60 .cpu_fprintf = cpu_fprintf,
61 };
62 GSList *list;
63
64 list = object_class_get_list(TYPE_TRICORE_CPU, false);
65 (*cpu_fprintf)(f, "Available CPUs:\n");
66 g_slist_foreach(list, tricore_cpu_list_entry, &s);
67 g_slist_free(list);
68 }
69
70 uint32_t psw_read(CPUTriCoreState *env)
71 {
72 /* clear all USB bits */
73 env->PSW &= 0xffffff;
74 /* now set them from the cache */
75 env->PSW |= ((env->PSW_USB_C != 0) << 31);
76 env->PSW |= ((env->PSW_USB_V & (1 << 31)) >> 1);
77 env->PSW |= ((env->PSW_USB_SV & (1 << 31)) >> 2);
78 env->PSW |= ((env->PSW_USB_AV & (1 << 31)) >> 3);
79 env->PSW |= ((env->PSW_USB_SAV & (1 << 31)) >> 4);
80
81 return env->PSW;
82 }
83
84 void psw_write(CPUTriCoreState *env, uint32_t val)
85 {
86 env->PSW_USB_C = (val & MASK_USB_C);
87 env->PSW_USB_V = (val & MASK_USB_V << 1);
88 env->PSW_USB_SV = (val & MASK_USB_SV << 2);
89 env->PSW_USB_AV = ((val & MASK_USB_AV) << 3);
90 env->PSW_USB_SAV = ((val & MASK_USB_SAV) << 4);
91 env->PSW = val;
92 }