]> git.proxmox.com Git - qemu.git/blame - target-m68k/cpu.c
target-m68k: Start QOM'ifying CPU init
[qemu.git] / target-m68k / cpu.c
CommitLineData
b9e7a234
AF
1/*
2 * QEMU Motorola 68k CPU
3 *
4 * Copyright (c) 2012 SUSE LINUX Products GmbH
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see
18 * <http://www.gnu.org/licenses/lgpl-2.1.html>
19 */
20
21#include "cpu.h"
22#include "qemu-common.h"
23
24
25/* CPUClass::reset() */
26static void m68k_cpu_reset(CPUState *s)
27{
28 M68kCPU *cpu = M68K_CPU(s);
29 M68kCPUClass *mcc = M68K_CPU_GET_CLASS(cpu);
30 CPUM68KState *env = &cpu->env;
31
11c19868
AF
32 if (qemu_loglevel_mask(CPU_LOG_RESET)) {
33 qemu_log("CPU Reset (CPU %d)\n", env->cpu_index);
34 log_cpu_state(env, 0);
35 }
36
b9e7a234
AF
37 mcc->parent_reset(s);
38
11c19868
AF
39 memset(env, 0, offsetof(CPUM68KState, breakpoints));
40#if !defined(CONFIG_USER_ONLY)
41 env->sr = 0x2700;
42#endif
43 m68k_switch_sp(env);
44 /* ??? FP regs should be initialized to NaN. */
45 env->cc_op = CC_OP_FLAGS;
46 /* TODO: We should set PC from the interrupt vector. */
47 env->pc = 0;
48 tlb_flush(env, 1);
b9e7a234
AF
49}
50
9b706039
AF
51static void m68k_cpu_initfn(Object *obj)
52{
53 M68kCPU *cpu = M68K_CPU(obj);
54 CPUM68KState *env = &cpu->env;
55
56 cpu_exec_init(env);
57}
58
b9e7a234
AF
59static void m68k_cpu_class_init(ObjectClass *c, void *data)
60{
61 M68kCPUClass *mcc = M68K_CPU_CLASS(c);
62 CPUClass *cc = CPU_CLASS(c);
63
64 mcc->parent_reset = cc->reset;
65 cc->reset = m68k_cpu_reset;
66}
67
68static const TypeInfo m68k_cpu_type_info = {
69 .name = TYPE_M68K_CPU,
70 .parent = TYPE_CPU,
71 .instance_size = sizeof(M68kCPU),
9b706039 72 .instance_init = m68k_cpu_initfn,
b9e7a234
AF
73 .abstract = false,
74 .class_size = sizeof(M68kCPUClass),
75 .class_init = m68k_cpu_class_init,
76};
77
78static void m68k_cpu_register_types(void)
79{
80 type_register_static(&m68k_cpu_type_info);
81}
82
83type_init(m68k_cpu_register_types)