Revision ae0f5e9e target-unicore32/helper.c

b/target-unicore32/helper.c
19 19
    env->features |= feature;
20 20
}
21 21

  
22
struct uc32_cpu_t {
23
    uint32_t id;
24
    const char *name;
25
};
26

  
27
static const struct uc32_cpu_t uc32_cpu_names[] = {
28
    { UC32_CPUID_UCV2, "UniCore-II"},
29
    { UC32_CPUID_ANY, "any"},
30
    { 0, NULL}
31
};
32

  
33
/* return 0 if not found */
34
static uint32_t uc32_cpu_find_by_name(const char *name)
35
{
36
    int i;
37
    uint32_t id;
38

  
39
    id = 0;
40
    for (i = 0; uc32_cpu_names[i].name; i++) {
41
        if (strcmp(name, uc32_cpu_names[i].name) == 0) {
42
            id = uc32_cpu_names[i].id;
43
            break;
44
        }
45
    }
46
    return id;
47
}
48

  
49 22
CPUUniCore32State *uc32_cpu_init(const char *cpu_model)
50 23
{
24
    UniCore32CPU *cpu;
51 25
    CPUUniCore32State *env;
52 26
    uint32_t id;
53 27
    static int inited = 1;
54 28

  
55
    env = g_malloc0(sizeof(CPUUniCore32State));
56
    cpu_exec_init(env);
29
    if (object_class_by_name(cpu_model) == NULL) {
30
        return NULL;
31
    }
32
    cpu = UNICORE32_CPU(object_new(cpu_model));
33
    env = &cpu->env;
57 34

  
58
    id = uc32_cpu_find_by_name(cpu_model);
35
    id = env->cp0.c0_cpuid;
59 36
    switch (id) {
60 37
    case UC32_CPUID_UCV2:
61 38
        set_feature(env, UC32_HWCAP_CMOV);
......
72 49
        cpu_abort(env, "Bad CPU ID: %x\n", id);
73 50
    }
74 51

  
75
    env->cpu_model_str = cpu_model;
76
    env->cp0.c0_cpuid = id;
77
    env->uncached_asr = ASR_MODE_USER;
78
    env->regs[31] = 0;
79

  
80 52
    if (inited) {
81 53
        inited = 0;
82 54
        uc32_translate_init();
83 55
    }
84 56

  
85
    tlb_flush(env, 1);
86 57
    qemu_init_vcpu(env);
87 58
    return env;
88 59
}

Also available in: Unified diff