]> git.proxmox.com Git - qemu.git/blame - target-unicore32/cpu.c
fdc: fix FD_SR0_SEEK for non-DMA transfers and multi sectors transfers
[qemu.git] / target-unicore32 / cpu.c
CommitLineData
ae0f5e9e
AF
1/*
2 * QEMU UniCore32 CPU
3 *
d48813dd 4 * Copyright (c) 2010-2012 Guan Xuetao
ae0f5e9e
AF
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
3993c6bd 15#include "cpu.h"
ae0f5e9e
AF
16#include "qemu-common.h"
17
8df9082d
AF
18static inline void set_feature(CPUUniCore32State *env, int feature)
19{
20 env->features |= feature;
21}
22
ae0f5e9e
AF
23/* CPU models */
24
25typedef struct UniCore32CPUInfo {
26 const char *name;
27 void (*instance_init)(Object *obj);
28} UniCore32CPUInfo;
29
30static void unicore_ii_cpu_initfn(Object *obj)
31{
32 UniCore32CPU *cpu = UNICORE32_CPU(obj);
33 CPUUniCore32State *env = &cpu->env;
34
d48813dd
GX
35 env->cp0.c0_cpuid = 0x4d000863;
36 env->cp0.c0_cachetype = 0x0d152152;
37 env->cp0.c1_sys = 0x2000;
38 env->cp0.c2_base = 0x0;
39 env->cp0.c3_faultstatus = 0x0;
40 env->cp0.c4_faultaddr = 0x0;
41 env->ucf64.xregs[UC32_UCF64_FPSCR] = 0;
8df9082d
AF
42
43 set_feature(env, UC32_HWCAP_CMOV);
44 set_feature(env, UC32_HWCAP_UCF64);
ae0f5e9e
AF
45}
46
47static void uc32_any_cpu_initfn(Object *obj)
48{
49 UniCore32CPU *cpu = UNICORE32_CPU(obj);
50 CPUUniCore32State *env = &cpu->env;
51
52 env->cp0.c0_cpuid = 0xffffffff;
d48813dd 53 env->ucf64.xregs[UC32_UCF64_FPSCR] = 0;
8df9082d
AF
54
55 set_feature(env, UC32_HWCAP_CMOV);
56 set_feature(env, UC32_HWCAP_UCF64);
ae0f5e9e
AF
57}
58
59static const UniCore32CPUInfo uc32_cpus[] = {
60 { .name = "UniCore-II", .instance_init = unicore_ii_cpu_initfn },
61 { .name = "any", .instance_init = uc32_any_cpu_initfn },
62};
63
64static void uc32_cpu_initfn(Object *obj)
65{
66 UniCore32CPU *cpu = UNICORE32_CPU(obj);
67 CPUUniCore32State *env = &cpu->env;
68
69 cpu_exec_init(env);
70 env->cpu_model_str = object_get_typename(obj);
71
d48813dd 72#ifdef CONFIG_USER_ONLY
ae0f5e9e
AF
73 env->uncached_asr = ASR_MODE_USER;
74 env->regs[31] = 0;
d48813dd
GX
75#else
76 env->uncached_asr = ASR_MODE_PRIV;
77 env->regs[31] = 0x03000000;
78#endif
ae0f5e9e
AF
79
80 tlb_flush(env, 1);
81}
82
83static void uc32_register_cpu_type(const UniCore32CPUInfo *info)
84{
85 TypeInfo type_info = {
86 .name = info->name,
87 .parent = TYPE_UNICORE32_CPU,
88 .instance_init = info->instance_init,
89 };
90
91 type_register_static(&type_info);
92}
93
94static const TypeInfo uc32_cpu_type_info = {
95 .name = TYPE_UNICORE32_CPU,
96 .parent = TYPE_CPU,
97 .instance_size = sizeof(UniCore32CPU),
98 .instance_init = uc32_cpu_initfn,
99 .abstract = true,
100 .class_size = sizeof(UniCore32CPUClass),
101};
102
103static void uc32_cpu_register_types(void)
104{
105 int i;
106
107 type_register_static(&uc32_cpu_type_info);
108 for (i = 0; i < ARRAY_SIZE(uc32_cpus); i++) {
109 uc32_register_cpu_type(&uc32_cpus[i]);
110 }
111}
112
113type_init(uc32_cpu_register_types)