]> Git Repo - qemu.git/blob - target-unicore32/cpu.c
de63f58dda055fab4763094599908d5040dfbb81
[qemu.git] / target-unicore32 / cpu.c
1 /*
2  * QEMU UniCore32 CPU
3  *
4  * Copyright (c) 2010-2011 GUAN Xue-tao
5  * Copyright (c) 2012 SUSE LINUX Products GmbH
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation.
10  *
11  * Contributions from 2012-04-01 on are considered under GPL version 2,
12  * or (at your option) any later version.
13  */
14
15 #include "cpu-qom.h"
16 #include "qemu-common.h"
17
18 static inline void set_feature(CPUUniCore32State *env, int feature)
19 {
20     env->features |= feature;
21 }
22
23 /* CPU models */
24
25 typedef struct UniCore32CPUInfo {
26     const char *name;
27     void (*instance_init)(Object *obj);
28 } UniCore32CPUInfo;
29
30 static void unicore_ii_cpu_initfn(Object *obj)
31 {
32     UniCore32CPU *cpu = UNICORE32_CPU(obj);
33     CPUUniCore32State *env = &cpu->env;
34
35     env->cp0.c0_cpuid = 0x40010863;
36
37     set_feature(env, UC32_HWCAP_CMOV);
38     set_feature(env, UC32_HWCAP_UCF64);
39     env->ucf64.xregs[UC32_UCF64_FPSCR] = 0;
40     env->cp0.c0_cachetype = 0x1dd20d2;
41     env->cp0.c1_sys = 0x00090078;
42 }
43
44 static void uc32_any_cpu_initfn(Object *obj)
45 {
46     UniCore32CPU *cpu = UNICORE32_CPU(obj);
47     CPUUniCore32State *env = &cpu->env;
48
49     env->cp0.c0_cpuid = 0xffffffff;
50
51     set_feature(env, UC32_HWCAP_CMOV);
52     set_feature(env, UC32_HWCAP_UCF64);
53 }
54
55 static const UniCore32CPUInfo uc32_cpus[] = {
56     { .name = "UniCore-II", .instance_init = unicore_ii_cpu_initfn },
57     { .name = "any",        .instance_init = uc32_any_cpu_initfn },
58 };
59
60 static void uc32_cpu_initfn(Object *obj)
61 {
62     UniCore32CPU *cpu = UNICORE32_CPU(obj);
63     CPUUniCore32State *env = &cpu->env;
64
65     cpu_exec_init(env);
66     env->cpu_model_str = object_get_typename(obj);
67
68     env->uncached_asr = ASR_MODE_USER;
69     env->regs[31] = 0;
70
71     tlb_flush(env, 1);
72 }
73
74 static void uc32_register_cpu_type(const UniCore32CPUInfo *info)
75 {
76     TypeInfo type_info = {
77         .name = info->name,
78         .parent = TYPE_UNICORE32_CPU,
79         .instance_init = info->instance_init,
80     };
81
82     type_register_static(&type_info);
83 }
84
85 static const TypeInfo uc32_cpu_type_info = {
86     .name = TYPE_UNICORE32_CPU,
87     .parent = TYPE_CPU,
88     .instance_size = sizeof(UniCore32CPU),
89     .instance_init = uc32_cpu_initfn,
90     .abstract = true,
91     .class_size = sizeof(UniCore32CPUClass),
92 };
93
94 static void uc32_cpu_register_types(void)
95 {
96     int i;
97
98     type_register_static(&uc32_cpu_type_info);
99     for (i = 0; i < ARRAY_SIZE(uc32_cpus); i++) {
100         uc32_register_cpu_type(&uc32_cpus[i]);
101     }
102 }
103
104 type_init(uc32_cpu_register_types)
This page took 0.019637 seconds and 2 git commands to generate.