Statistics
| Branch: | Revision:

root / target-xtensa / cpu.c @ 5087a72c

History | View | Annotate | Download (2.8 kB)

1 a4633e16 Andreas Färber
/*
2 a4633e16 Andreas Färber
 * QEMU Xtensa CPU
3 a4633e16 Andreas Färber
 *
4 5087a72c Andreas Färber
 * Copyright (c) 2011, Max Filippov, Open Source and Linux Lab.
5 a4633e16 Andreas Färber
 * Copyright (c) 2012 SUSE LINUX Products GmbH
6 a4633e16 Andreas Färber
 * All rights reserved.
7 a4633e16 Andreas Färber
 *
8 a4633e16 Andreas Färber
 * Redistribution and use in source and binary forms, with or without
9 a4633e16 Andreas Färber
 * modification, are permitted provided that the following conditions are met:
10 a4633e16 Andreas Färber
 *     * Redistributions of source code must retain the above copyright
11 a4633e16 Andreas Färber
 *       notice, this list of conditions and the following disclaimer.
12 a4633e16 Andreas Färber
 *     * Redistributions in binary form must reproduce the above copyright
13 a4633e16 Andreas Färber
 *       notice, this list of conditions and the following disclaimer in the
14 a4633e16 Andreas Färber
 *       documentation and/or other materials provided with the distribution.
15 a4633e16 Andreas Färber
 *     * Neither the name of the Open Source and Linux Lab nor the
16 a4633e16 Andreas Färber
 *       names of its contributors may be used to endorse or promote products
17 a4633e16 Andreas Färber
 *       derived from this software without specific prior written permission.
18 a4633e16 Andreas Färber
 *
19 a4633e16 Andreas Färber
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 a4633e16 Andreas Färber
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 a4633e16 Andreas Färber
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 a4633e16 Andreas Färber
 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
23 a4633e16 Andreas Färber
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 a4633e16 Andreas Färber
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 a4633e16 Andreas Färber
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 a4633e16 Andreas Färber
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 a4633e16 Andreas Färber
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 a4633e16 Andreas Färber
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 a4633e16 Andreas Färber
 */
30 a4633e16 Andreas Färber
31 a4633e16 Andreas Färber
#include "cpu-qom.h"
32 a4633e16 Andreas Färber
#include "qemu-common.h"
33 a4633e16 Andreas Färber
34 a4633e16 Andreas Färber
35 a4633e16 Andreas Färber
/* CPUClass::reset() */
36 a4633e16 Andreas Färber
static void xtensa_cpu_reset(CPUState *s)
37 a4633e16 Andreas Färber
{
38 a4633e16 Andreas Färber
    XtensaCPU *cpu = XTENSA_CPU(s);
39 a4633e16 Andreas Färber
    XtensaCPUClass *xcc = XTENSA_CPU_GET_CLASS(cpu);
40 a4633e16 Andreas Färber
    CPUXtensaState *env = &cpu->env;
41 a4633e16 Andreas Färber
42 a4633e16 Andreas Färber
    xcc->parent_reset(s);
43 a4633e16 Andreas Färber
44 5087a72c Andreas Färber
    env->exception_taken = 0;
45 5087a72c Andreas Färber
    env->pc = env->config->exception_vector[EXC_RESET];
46 5087a72c Andreas Färber
    env->sregs[LITBASE] &= ~1;
47 5087a72c Andreas Färber
    env->sregs[PS] = xtensa_option_enabled(env->config,
48 5087a72c Andreas Färber
            XTENSA_OPTION_INTERRUPT) ? 0x1f : 0x10;
49 5087a72c Andreas Färber
    env->sregs[VECBASE] = env->config->vecbase;
50 5087a72c Andreas Färber
    env->sregs[IBREAKENABLE] = 0;
51 5087a72c Andreas Färber
52 5087a72c Andreas Färber
    env->pending_irq_level = 0;
53 5087a72c Andreas Färber
    reset_mmu(env);
54 a4633e16 Andreas Färber
}
55 a4633e16 Andreas Färber
56 a4633e16 Andreas Färber
static void xtensa_cpu_class_init(ObjectClass *oc, void *data)
57 a4633e16 Andreas Färber
{
58 a4633e16 Andreas Färber
    CPUClass *cc = CPU_CLASS(oc);
59 a4633e16 Andreas Färber
    XtensaCPUClass *xcc = XTENSA_CPU_CLASS(cc);
60 a4633e16 Andreas Färber
61 a4633e16 Andreas Färber
    xcc->parent_reset = cc->reset;
62 a4633e16 Andreas Färber
    cc->reset = xtensa_cpu_reset;
63 a4633e16 Andreas Färber
}
64 a4633e16 Andreas Färber
65 a4633e16 Andreas Färber
static const TypeInfo xtensa_cpu_type_info = {
66 a4633e16 Andreas Färber
    .name = TYPE_XTENSA_CPU,
67 a4633e16 Andreas Färber
    .parent = TYPE_CPU,
68 a4633e16 Andreas Färber
    .instance_size = sizeof(XtensaCPU),
69 a4633e16 Andreas Färber
    .abstract = false,
70 a4633e16 Andreas Färber
    .class_size = sizeof(XtensaCPUClass),
71 a4633e16 Andreas Färber
    .class_init = xtensa_cpu_class_init,
72 a4633e16 Andreas Färber
};
73 a4633e16 Andreas Färber
74 a4633e16 Andreas Färber
static void xtensa_cpu_register_types(void)
75 a4633e16 Andreas Färber
{
76 a4633e16 Andreas Färber
    type_register_static(&xtensa_cpu_type_info);
77 a4633e16 Andreas Färber
}
78 a4633e16 Andreas Färber
79 a4633e16 Andreas Färber
type_init(xtensa_cpu_register_types)