xref: /openbmc/qemu/target/m68k/cpu.c (revision f15f7273ea55472d5904c53566c82369d81214c1)
1fcf5ef2aSThomas Huth /*
2fcf5ef2aSThomas Huth  * QEMU Motorola 68k CPU
3fcf5ef2aSThomas Huth  *
4fcf5ef2aSThomas Huth  * Copyright (c) 2012 SUSE LINUX Products GmbH
5fcf5ef2aSThomas Huth  *
6fcf5ef2aSThomas Huth  * This library is free software; you can redistribute it and/or
7fcf5ef2aSThomas Huth  * modify it under the terms of the GNU Lesser General Public
8fcf5ef2aSThomas Huth  * License as published by the Free Software Foundation; either
9fcf5ef2aSThomas Huth  * version 2.1 of the License, or (at your option) any later version.
10fcf5ef2aSThomas Huth  *
11fcf5ef2aSThomas Huth  * This library is distributed in the hope that it will be useful,
12fcf5ef2aSThomas Huth  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13fcf5ef2aSThomas Huth  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14fcf5ef2aSThomas Huth  * Lesser General Public License for more details.
15fcf5ef2aSThomas Huth  *
16fcf5ef2aSThomas Huth  * You should have received a copy of the GNU Lesser General Public
17fcf5ef2aSThomas Huth  * License along with this library; if not, see
18fcf5ef2aSThomas Huth  * <http://www.gnu.org/licenses/lgpl-2.1.html>
19fcf5ef2aSThomas Huth  */
20fcf5ef2aSThomas Huth 
21fcf5ef2aSThomas Huth #include "qemu/osdep.h"
22fcf5ef2aSThomas Huth #include "qapi/error.h"
23fcf5ef2aSThomas Huth #include "cpu.h"
24fcf5ef2aSThomas Huth #include "migration/vmstate.h"
2524f91e81SAlex Bennée #include "fpu/softfloat.h"
26fcf5ef2aSThomas Huth 
m68k_cpu_set_pc(CPUState * cs,vaddr value)27fcf5ef2aSThomas Huth static void m68k_cpu_set_pc(CPUState *cs, vaddr value)
28fcf5ef2aSThomas Huth {
29fcf5ef2aSThomas Huth     M68kCPU *cpu = M68K_CPU(cs);
30fcf5ef2aSThomas Huth 
31fcf5ef2aSThomas Huth     cpu->env.pc = value;
32fcf5ef2aSThomas Huth }
33fcf5ef2aSThomas Huth 
m68k_cpu_get_pc(CPUState * cs)34e4fdf9dfSRichard Henderson static vaddr m68k_cpu_get_pc(CPUState *cs)
35e4fdf9dfSRichard Henderson {
36e4fdf9dfSRichard Henderson     M68kCPU *cpu = M68K_CPU(cs);
37e4fdf9dfSRichard Henderson 
38e4fdf9dfSRichard Henderson     return cpu->env.pc;
39e4fdf9dfSRichard Henderson }
40e4fdf9dfSRichard Henderson 
m68k_restore_state_to_opc(CPUState * cs,const TranslationBlock * tb,const uint64_t * data)41584fd342SRichard Henderson static void m68k_restore_state_to_opc(CPUState *cs,
42584fd342SRichard Henderson                                       const TranslationBlock *tb,
43584fd342SRichard Henderson                                       const uint64_t *data)
44584fd342SRichard Henderson {
45584fd342SRichard Henderson     M68kCPU *cpu = M68K_CPU(cs);
46584fd342SRichard Henderson     int cc_op = data[1];
47584fd342SRichard Henderson 
48584fd342SRichard Henderson     cpu->env.pc = data[0];
49584fd342SRichard Henderson     if (cc_op != CC_OP_DYNAMIC) {
50584fd342SRichard Henderson         cpu->env.cc_op = cc_op;
51584fd342SRichard Henderson     }
52584fd342SRichard Henderson }
53584fd342SRichard Henderson 
m68k_cpu_has_work(CPUState * cs)54fcf5ef2aSThomas Huth static bool m68k_cpu_has_work(CPUState *cs)
55fcf5ef2aSThomas Huth {
56fcf5ef2aSThomas Huth     return cs->interrupt_request & CPU_INTERRUPT_HARD;
57fcf5ef2aSThomas Huth }
58fcf5ef2aSThomas Huth 
m68k_cpu_mmu_index(CPUState * cs,bool ifetch)59a5a2d7f6SRichard Henderson static int m68k_cpu_mmu_index(CPUState *cs, bool ifetch)
60a5a2d7f6SRichard Henderson {
61a5a2d7f6SRichard Henderson     return cpu_env(cs)->sr & SR_S ? MMU_KERNEL_IDX : MMU_USER_IDX;
62a5a2d7f6SRichard Henderson }
63a5a2d7f6SRichard Henderson 
m68k_set_feature(CPUM68KState * env,int feature)64fcf5ef2aSThomas Huth static void m68k_set_feature(CPUM68KState *env, int feature)
65fcf5ef2aSThomas Huth {
662dc7bf63SMark Cave-Ayland     env->features |= BIT_ULL(feature);
67fcf5ef2aSThomas Huth }
68fcf5ef2aSThomas Huth 
m68k_unset_feature(CPUM68KState * env,int feature)694ecce5fbSLucien Murray-Pitts static void m68k_unset_feature(CPUM68KState *env, int feature)
704ecce5fbSLucien Murray-Pitts {
712dc7bf63SMark Cave-Ayland     env->features &= ~BIT_ULL(feature);
724ecce5fbSLucien Murray-Pitts }
734ecce5fbSLucien Murray-Pitts 
m68k_cpu_reset_hold(Object * obj,ResetType type)74ad80e367SPeter Maydell static void m68k_cpu_reset_hold(Object *obj, ResetType type)
75fcf5ef2aSThomas Huth {
76348802b5SPhilippe Mathieu-Daudé     CPUState *cs = CPU(obj);
77348802b5SPhilippe Mathieu-Daudé     M68kCPUClass *mcc = M68K_CPU_GET_CLASS(obj);
78e22a4560SPhilippe Mathieu-Daudé     CPUM68KState *env = cpu_env(cs);
79f83311e4SLaurent Vivier     floatx80 nan = floatx80_default_nan(NULL);
80f4a6ce51SLaurent Vivier     int i;
81fcf5ef2aSThomas Huth 
82bf90b345SPeter Maydell     if (mcc->parent_phases.hold) {
83ad80e367SPeter Maydell         mcc->parent_phases.hold(obj, type);
84bf90b345SPeter Maydell     }
85fcf5ef2aSThomas Huth 
861f5c00cfSAlex Bennée     memset(env, 0, offsetof(CPUM68KState, end_reset_fields));
876a140586SPhilippe Mathieu-Daudé #ifdef CONFIG_USER_ONLY
886e22b28eSLaurent Vivier     cpu_m68k_set_sr(env, 0);
896a140586SPhilippe Mathieu-Daudé #else
906a140586SPhilippe Mathieu-Daudé     cpu_m68k_set_sr(env, SR_S | SR_I);
91fcf5ef2aSThomas Huth #endif
92f4a6ce51SLaurent Vivier     for (i = 0; i < 8; i++) {
93f83311e4SLaurent Vivier         env->fregs[i].d = nan;
94f4a6ce51SLaurent Vivier     }
95ba624944SLaurent Vivier     cpu_m68k_set_fpcr(env, 0);
96*0527cfd9SPeter Maydell     /*
97*0527cfd9SPeter Maydell      * M68000 FAMILY PROGRAMMER'S REFERENCE MANUAL
98*0527cfd9SPeter Maydell      * 3.4 FLOATING-POINT INSTRUCTION DETAILS
99*0527cfd9SPeter Maydell      * If either operand, but not both operands, of an operation is a
100*0527cfd9SPeter Maydell      * nonsignaling NaN, then that NaN is returned as the result. If both
101*0527cfd9SPeter Maydell      * operands are nonsignaling NaNs, then the destination operand
102*0527cfd9SPeter Maydell      * nonsignaling NaN is returned as the result.
103*0527cfd9SPeter Maydell      * If either operand to an operation is a signaling NaN (SNaN), then the
104*0527cfd9SPeter Maydell      * SNaN bit is set in the FPSR EXC byte. If the SNaN exception enable bit
105*0527cfd9SPeter Maydell      * is set in the FPCR ENABLE byte, then the exception is taken and the
106*0527cfd9SPeter Maydell      * destination is not modified. If the SNaN exception enable bit is not
107*0527cfd9SPeter Maydell      * set, setting the SNaN bit in the operand to a one converts the SNaN to
108*0527cfd9SPeter Maydell      * a nonsignaling NaN. The operation then continues as described in the
109*0527cfd9SPeter Maydell      * preceding paragraph for nonsignaling NaNs.
110*0527cfd9SPeter Maydell      */
111*0527cfd9SPeter Maydell     set_float_2nan_prop_rule(float_2nan_prop_ab, &env->fp_status);
112f4a6ce51SLaurent Vivier     env->fpsr = 0;
113f4a6ce51SLaurent Vivier 
114fcf5ef2aSThomas Huth     /* TODO: We should set PC from the interrupt vector.  */
115fcf5ef2aSThomas Huth     env->pc = 0;
116fcf5ef2aSThomas Huth }
117fcf5ef2aSThomas Huth 
m68k_cpu_disas_set_info(CPUState * s,disassemble_info * info)118fcf5ef2aSThomas Huth static void m68k_cpu_disas_set_info(CPUState *s, disassemble_info *info)
119fcf5ef2aSThomas Huth {
120fcf5ef2aSThomas Huth     info->print_insn = print_insn_m68k;
12112629fcfSRichard Henderson     info->mach = 0;
122fcf5ef2aSThomas Huth }
123fcf5ef2aSThomas Huth 
124fcf5ef2aSThomas Huth /* CPU models */
125fcf5ef2aSThomas Huth 
m68k_cpu_class_by_name(const char * cpu_model)126fcf5ef2aSThomas Huth static ObjectClass *m68k_cpu_class_by_name(const char *cpu_model)
127fcf5ef2aSThomas Huth {
128fcf5ef2aSThomas Huth     ObjectClass *oc;
129fcf5ef2aSThomas Huth     char *typename;
130fcf5ef2aSThomas Huth 
131f61797bdSIgor Mammedov     typename = g_strdup_printf(M68K_CPU_TYPE_NAME("%s"), cpu_model);
132fcf5ef2aSThomas Huth     oc = object_class_by_name(typename);
133fcf5ef2aSThomas Huth     g_free(typename);
134d5be19f5SPhilippe Mathieu-Daudé 
135fcf5ef2aSThomas Huth     return oc;
136fcf5ef2aSThomas Huth }
137fcf5ef2aSThomas Huth 
m5206_cpu_initfn(Object * obj)138fcf5ef2aSThomas Huth static void m5206_cpu_initfn(Object *obj)
139fcf5ef2aSThomas Huth {
140e22a4560SPhilippe Mathieu-Daudé     CPUM68KState *env = cpu_env(CPU(obj));
141fcf5ef2aSThomas Huth 
142fcf5ef2aSThomas Huth     m68k_set_feature(env, M68K_FEATURE_CF_ISA_A);
143b342e56bSMark Cave-Ayland     m68k_set_feature(env, M68K_FEATURE_MOVEFROMSR_PRIV);
144fcf5ef2aSThomas Huth }
145fcf5ef2aSThomas Huth 
146ee2fc6c6SLucien Murray-Pitts /* Base feature set, including isns. for m68k family */
m68000_cpu_initfn(Object * obj)147fcf5ef2aSThomas Huth static void m68000_cpu_initfn(Object *obj)
148fcf5ef2aSThomas Huth {
149e22a4560SPhilippe Mathieu-Daudé     CPUM68KState *env = cpu_env(CPU(obj));
150fcf5ef2aSThomas Huth 
151aece90d8SMark Cave-Ayland     m68k_set_feature(env, M68K_FEATURE_M68K);
152fcf5ef2aSThomas Huth     m68k_set_feature(env, M68K_FEATURE_USP);
153fcf5ef2aSThomas Huth     m68k_set_feature(env, M68K_FEATURE_WORD_INDEX);
1541226e212SPavel Dovgalyuk     m68k_set_feature(env, M68K_FEATURE_MOVEP);
155fcf5ef2aSThomas Huth }
156fcf5ef2aSThomas Huth 
1574ecce5fbSLucien Murray-Pitts /*
158f3c6376cSDaniel Palmer  * Adds BKPT, MOVE-from-SR *now priv instr, and MOVEC, MOVES, RTD,
159f3c6376cSDaniel Palmer  *      format+vector in exception frame.
1604ecce5fbSLucien Murray-Pitts  */
m68010_cpu_initfn(Object * obj)1614ecce5fbSLucien Murray-Pitts static void m68010_cpu_initfn(Object *obj)
162fcf5ef2aSThomas Huth {
163e22a4560SPhilippe Mathieu-Daudé     CPUM68KState *env = cpu_env(CPU(obj));
1644ecce5fbSLucien Murray-Pitts 
1654ecce5fbSLucien Murray-Pitts     m68000_cpu_initfn(obj);
1664ecce5fbSLucien Murray-Pitts     m68k_set_feature(env, M68K_FEATURE_M68010);
16718059c9eSLaurent Vivier     m68k_set_feature(env, M68K_FEATURE_RTD);
1684ecce5fbSLucien Murray-Pitts     m68k_set_feature(env, M68K_FEATURE_BKPT);
1698df0e6aeSLucien Murray-Pitts     m68k_set_feature(env, M68K_FEATURE_MOVEC);
170b342e56bSMark Cave-Ayland     m68k_set_feature(env, M68K_FEATURE_MOVEFROMSR_PRIV);
171f3c6376cSDaniel Palmer     m68k_set_feature(env, M68K_FEATURE_EXCEPTION_FORMAT_VEC);
172fcf5ef2aSThomas Huth }
17318b6102eSLaurent Vivier 
174ee2fc6c6SLucien Murray-Pitts /*
175ee2fc6c6SLucien Murray-Pitts  * Adds BFCHG, BFCLR, BFEXTS, BFEXTU, BFFFO, BFINS, BFSET, BFTST, CAS, CAS2,
176ee2fc6c6SLucien Murray-Pitts  *      CHK2, CMP2, DIVSL, DIVUL, EXTB, PACK, TRAPcc, UNPK.
177ee2fc6c6SLucien Murray-Pitts  *
178ee2fc6c6SLucien Murray-Pitts  * 68020/30 only:
179ee2fc6c6SLucien Murray-Pitts  *      CALLM, cpBcc, cpDBcc, cpGEN, cpRESTORE, cpSAVE, cpScc, cpTRAPcc
180ee2fc6c6SLucien Murray-Pitts  */
m68020_cpu_initfn(Object * obj)18118b6102eSLaurent Vivier static void m68020_cpu_initfn(Object *obj)
18218b6102eSLaurent Vivier {
183e22a4560SPhilippe Mathieu-Daudé     CPUM68KState *env = cpu_env(CPU(obj));
18418b6102eSLaurent Vivier 
1854ecce5fbSLucien Murray-Pitts     m68010_cpu_initfn(obj);
1864ecce5fbSLucien Murray-Pitts     m68k_unset_feature(env, M68K_FEATURE_M68010);
18718b6102eSLaurent Vivier     m68k_set_feature(env, M68K_FEATURE_M68020);
1884ecce5fbSLucien Murray-Pitts     m68k_set_feature(env, M68K_FEATURE_QUAD_MULDIV);
1894ecce5fbSLucien Murray-Pitts     m68k_set_feature(env, M68K_FEATURE_BRAL);
1904ecce5fbSLucien Murray-Pitts     m68k_set_feature(env, M68K_FEATURE_BCCL);
1914ecce5fbSLucien Murray-Pitts     m68k_set_feature(env, M68K_FEATURE_BITFIELD);
1924ecce5fbSLucien Murray-Pitts     m68k_set_feature(env, M68K_FEATURE_EXT_FULL);
1934ecce5fbSLucien Murray-Pitts     m68k_set_feature(env, M68K_FEATURE_SCALED_INDEX);
1944ecce5fbSLucien Murray-Pitts     m68k_set_feature(env, M68K_FEATURE_LONG_MULDIV);
1954ecce5fbSLucien Murray-Pitts     m68k_set_feature(env, M68K_FEATURE_FPU);
1964ecce5fbSLucien Murray-Pitts     m68k_set_feature(env, M68K_FEATURE_CAS);
1974ecce5fbSLucien Murray-Pitts     m68k_set_feature(env, M68K_FEATURE_CHK2);
1987525a9b9SLucien Murray-Pitts     m68k_set_feature(env, M68K_FEATURE_MSP);
199a9431a03SMark Cave-Ayland     m68k_set_feature(env, M68K_FEATURE_UNALIGNED_DATA);
200aeeb90afSRichard Henderson     m68k_set_feature(env, M68K_FEATURE_TRAPCC);
20118b6102eSLaurent Vivier }
20218b6102eSLaurent Vivier 
203ee2fc6c6SLucien Murray-Pitts /*
204ee2fc6c6SLucien Murray-Pitts  * Adds: PFLUSH (*5)
205ee2fc6c6SLucien Murray-Pitts  * 68030 Only: PFLUSHA (*5), PLOAD (*5), PMOVE
206ee2fc6c6SLucien Murray-Pitts  * 68030/40 Only: PTEST
207ee2fc6c6SLucien Murray-Pitts  *
208ee2fc6c6SLucien Murray-Pitts  * NOTES:
209ee2fc6c6SLucien Murray-Pitts  *  5. Not valid on MC68EC030
210ee2fc6c6SLucien Murray-Pitts  */
m68030_cpu_initfn(Object * obj)21118b6102eSLaurent Vivier static void m68030_cpu_initfn(Object *obj)
21218b6102eSLaurent Vivier {
213e22a4560SPhilippe Mathieu-Daudé     CPUM68KState *env = cpu_env(CPU(obj));
21418b6102eSLaurent Vivier 
2154ecce5fbSLucien Murray-Pitts     m68020_cpu_initfn(obj);
2164ecce5fbSLucien Murray-Pitts     m68k_unset_feature(env, M68K_FEATURE_M68020);
21718b6102eSLaurent Vivier     m68k_set_feature(env, M68K_FEATURE_M68030);
21818b6102eSLaurent Vivier }
2199d4f0429SLaurent Vivier 
220ee2fc6c6SLucien Murray-Pitts /*
221ee2fc6c6SLucien Murray-Pitts  * Adds: CINV, CPUSH
222ee2fc6c6SLucien Murray-Pitts  * Adds all with Note *2: FABS, FSABS, FDABS, FADD, FSADD, FDADD, FBcc, FCMP,
223ee2fc6c6SLucien Murray-Pitts  *                        FDBcc, FDIV, FSDIV, FDDIV, FMOVE, FSMOVE, FDMOVE,
224ee2fc6c6SLucien Murray-Pitts  *                        FMOVEM, FMUL, FSMUL, FDMUL, FNEG, FSNEG, FDNEG, FNOP,
225ee2fc6c6SLucien Murray-Pitts  *                        FRESTORE, FSAVE, FScc, FSQRT, FSSQRT, FDSQRT, FSUB,
226ee2fc6c6SLucien Murray-Pitts  *                        FSSUB, FDSUB, FTRAPcc, FTST
227ee2fc6c6SLucien Murray-Pitts  *
228ee2fc6c6SLucien Murray-Pitts  * Adds with Notes *2, and *3: FACOS, FASIN, FATAN, FATANH, FCOS, FCOSH, FETOX,
229ee2fc6c6SLucien Murray-Pitts  *                             FETOXM, FGETEXP, FGETMAN, FINT, FINTRZ, FLOG10,
230ee2fc6c6SLucien Murray-Pitts  *                             FLOG2, FLOGN, FLOGNP1, FMOD, FMOVECR, FREM,
231ee2fc6c6SLucien Murray-Pitts  *                             FSCALE, FSGLDIV, FSGLMUL, FSIN, FSINCOS, FSINH,
232ee2fc6c6SLucien Murray-Pitts  *                             FTAN, FTANH, FTENTOX, FTWOTOX
233ee2fc6c6SLucien Murray-Pitts  * NOTES:
234ee2fc6c6SLucien Murray-Pitts  * 2. Not applicable to the MC68EC040, MC68LC040, MC68EC060, and MC68LC060.
235ee2fc6c6SLucien Murray-Pitts  * 3. These are software-supported instructions on the MC68040 and MC68060.
236ee2fc6c6SLucien Murray-Pitts  */
m68040_cpu_initfn(Object * obj)2379d4f0429SLaurent Vivier static void m68040_cpu_initfn(Object *obj)
2389d4f0429SLaurent Vivier {
239e22a4560SPhilippe Mathieu-Daudé     CPUM68KState *env = cpu_env(CPU(obj));
2409d4f0429SLaurent Vivier 
2414ecce5fbSLucien Murray-Pitts     m68030_cpu_initfn(obj);
2424ecce5fbSLucien Murray-Pitts     m68k_unset_feature(env, M68K_FEATURE_M68030);
2439d4f0429SLaurent Vivier     m68k_set_feature(env, M68K_FEATURE_M68040);
2449d4f0429SLaurent Vivier }
245fcf5ef2aSThomas Huth 
246ee2fc6c6SLucien Murray-Pitts /*
247ee2fc6c6SLucien Murray-Pitts  * Adds: PLPA
248ee2fc6c6SLucien Murray-Pitts  * Adds all with Note *2: CAS, CAS2, MULS, MULU, CHK2, CMP2, DIVS, DIVU
249ee2fc6c6SLucien Murray-Pitts  * All Fxxxx instructions are as per m68040 with exception to; FMOVEM NOTE3
250ee2fc6c6SLucien Murray-Pitts  *
251ee2fc6c6SLucien Murray-Pitts  * Does NOT implement MOVEP
252ee2fc6c6SLucien Murray-Pitts  *
253ee2fc6c6SLucien Murray-Pitts  * NOTES:
254ee2fc6c6SLucien Murray-Pitts  * 2. Not applicable to the MC68EC040, MC68LC040, MC68EC060, and MC68LC060.
255ee2fc6c6SLucien Murray-Pitts  * 3. These are software-supported instructions on the MC68040 and MC68060.
256ee2fc6c6SLucien Murray-Pitts  */
m68060_cpu_initfn(Object * obj)257fcf5ef2aSThomas Huth static void m68060_cpu_initfn(Object *obj)
258fcf5ef2aSThomas Huth {
259e22a4560SPhilippe Mathieu-Daudé     CPUM68KState *env = cpu_env(CPU(obj));
260fcf5ef2aSThomas Huth 
2614ecce5fbSLucien Murray-Pitts     m68040_cpu_initfn(obj);
2624ecce5fbSLucien Murray-Pitts     m68k_unset_feature(env, M68K_FEATURE_M68040);
26318b6102eSLaurent Vivier     m68k_set_feature(env, M68K_FEATURE_M68060);
2644ecce5fbSLucien Murray-Pitts     m68k_unset_feature(env, M68K_FEATURE_MOVEP);
2654ecce5fbSLucien Murray-Pitts 
2664ecce5fbSLucien Murray-Pitts     /* Implemented as a software feature */
2674ecce5fbSLucien Murray-Pitts     m68k_unset_feature(env, M68K_FEATURE_QUAD_MULDIV);
268fcf5ef2aSThomas Huth }
269fcf5ef2aSThomas Huth 
m5208_cpu_initfn(Object * obj)270fcf5ef2aSThomas Huth static void m5208_cpu_initfn(Object *obj)
271fcf5ef2aSThomas Huth {
272e22a4560SPhilippe Mathieu-Daudé     CPUM68KState *env = cpu_env(CPU(obj));
273fcf5ef2aSThomas Huth 
274fcf5ef2aSThomas Huth     m68k_set_feature(env, M68K_FEATURE_CF_ISA_A);
275fcf5ef2aSThomas Huth     m68k_set_feature(env, M68K_FEATURE_CF_ISA_APLUSC);
276fcf5ef2aSThomas Huth     m68k_set_feature(env, M68K_FEATURE_BRAL);
277fcf5ef2aSThomas Huth     m68k_set_feature(env, M68K_FEATURE_CF_EMAC);
278fcf5ef2aSThomas Huth     m68k_set_feature(env, M68K_FEATURE_USP);
279b342e56bSMark Cave-Ayland     m68k_set_feature(env, M68K_FEATURE_MOVEFROMSR_PRIV);
280fcf5ef2aSThomas Huth }
281fcf5ef2aSThomas Huth 
cfv4e_cpu_initfn(Object * obj)282fcf5ef2aSThomas Huth static void cfv4e_cpu_initfn(Object *obj)
283fcf5ef2aSThomas Huth {
284e22a4560SPhilippe Mathieu-Daudé     CPUM68KState *env = cpu_env(CPU(obj));
285fcf5ef2aSThomas Huth 
286fcf5ef2aSThomas Huth     m68k_set_feature(env, M68K_FEATURE_CF_ISA_A);
287fcf5ef2aSThomas Huth     m68k_set_feature(env, M68K_FEATURE_CF_ISA_B);
288fcf5ef2aSThomas Huth     m68k_set_feature(env, M68K_FEATURE_BRAL);
289fcf5ef2aSThomas Huth     m68k_set_feature(env, M68K_FEATURE_CF_FPU);
290fcf5ef2aSThomas Huth     m68k_set_feature(env, M68K_FEATURE_CF_EMAC);
291fcf5ef2aSThomas Huth     m68k_set_feature(env, M68K_FEATURE_USP);
292b342e56bSMark Cave-Ayland     m68k_set_feature(env, M68K_FEATURE_MOVEFROMSR_PRIV);
293fcf5ef2aSThomas Huth }
294fcf5ef2aSThomas Huth 
any_cpu_initfn(Object * obj)295fcf5ef2aSThomas Huth static void any_cpu_initfn(Object *obj)
296fcf5ef2aSThomas Huth {
297e22a4560SPhilippe Mathieu-Daudé     CPUM68KState *env = cpu_env(CPU(obj));
298fcf5ef2aSThomas Huth 
299fcf5ef2aSThomas Huth     m68k_set_feature(env, M68K_FEATURE_CF_ISA_A);
300fcf5ef2aSThomas Huth     m68k_set_feature(env, M68K_FEATURE_CF_ISA_B);
301fcf5ef2aSThomas Huth     m68k_set_feature(env, M68K_FEATURE_CF_ISA_APLUSC);
302fcf5ef2aSThomas Huth     m68k_set_feature(env, M68K_FEATURE_BRAL);
303fcf5ef2aSThomas Huth     m68k_set_feature(env, M68K_FEATURE_CF_FPU);
304808d77bcSLucien Murray-Pitts     /*
305808d77bcSLucien Murray-Pitts      * MAC and EMAC are mututally exclusive, so pick EMAC.
306808d77bcSLucien Murray-Pitts      * It's mostly backwards compatible.
307808d77bcSLucien Murray-Pitts      */
308fcf5ef2aSThomas Huth     m68k_set_feature(env, M68K_FEATURE_CF_EMAC);
309fcf5ef2aSThomas Huth     m68k_set_feature(env, M68K_FEATURE_CF_EMAC_B);
310fcf5ef2aSThomas Huth     m68k_set_feature(env, M68K_FEATURE_USP);
311fcf5ef2aSThomas Huth     m68k_set_feature(env, M68K_FEATURE_EXT_FULL);
312fcf5ef2aSThomas Huth     m68k_set_feature(env, M68K_FEATURE_WORD_INDEX);
313b342e56bSMark Cave-Ayland     m68k_set_feature(env, M68K_FEATURE_MOVEFROMSR_PRIV);
314fcf5ef2aSThomas Huth }
315fcf5ef2aSThomas Huth 
m68k_cpu_realizefn(DeviceState * dev,Error ** errp)316fcf5ef2aSThomas Huth static void m68k_cpu_realizefn(DeviceState *dev, Error **errp)
317fcf5ef2aSThomas Huth {
318fcf5ef2aSThomas Huth     CPUState *cs = CPU(dev);
319fcf5ef2aSThomas Huth     M68kCPU *cpu = M68K_CPU(dev);
320fcf5ef2aSThomas Huth     M68kCPUClass *mcc = M68K_CPU_GET_CLASS(dev);
321fcf5ef2aSThomas Huth     Error *local_err = NULL;
322fcf5ef2aSThomas Huth 
323f47cf4e3SIgor Mammedov     register_m68k_insns(&cpu->env);
324f47cf4e3SIgor Mammedov 
325fcf5ef2aSThomas Huth     cpu_exec_realizefn(cs, &local_err);
326fcf5ef2aSThomas Huth     if (local_err != NULL) {
327fcf5ef2aSThomas Huth         error_propagate(errp, local_err);
328fcf5ef2aSThomas Huth         return;
329fcf5ef2aSThomas Huth     }
330fcf5ef2aSThomas Huth 
331fcf5ef2aSThomas Huth     m68k_cpu_init_gdb(cpu);
332fcf5ef2aSThomas Huth 
333fcf5ef2aSThomas Huth     cpu_reset(cs);
334fcf5ef2aSThomas Huth     qemu_init_vcpu(cs);
335fcf5ef2aSThomas Huth 
336fcf5ef2aSThomas Huth     mcc->parent_realize(dev, errp);
337fcf5ef2aSThomas Huth }
338fcf5ef2aSThomas Huth 
3396a140586SPhilippe Mathieu-Daudé #if !defined(CONFIG_USER_ONLY)
fpu_needed(void * opaque)340d21f73c6SLaurent Vivier static bool fpu_needed(void *opaque)
341d21f73c6SLaurent Vivier {
342d21f73c6SLaurent Vivier     M68kCPU *s = opaque;
343d21f73c6SLaurent Vivier 
344d21f73c6SLaurent Vivier     return m68k_feature(&s->env, M68K_FEATURE_CF_FPU) ||
345d21f73c6SLaurent Vivier            m68k_feature(&s->env, M68K_FEATURE_FPU);
346d21f73c6SLaurent Vivier }
347d21f73c6SLaurent Vivier 
348d21f73c6SLaurent Vivier typedef struct m68k_FPReg_tmp {
349d21f73c6SLaurent Vivier     FPReg *parent;
350d21f73c6SLaurent Vivier     uint64_t tmp_mant;
351d21f73c6SLaurent Vivier     uint16_t tmp_exp;
352d21f73c6SLaurent Vivier } m68k_FPReg_tmp;
353d21f73c6SLaurent Vivier 
cpu_get_fp80(uint64_t * pmant,uint16_t * pexp,floatx80 f)354d21f73c6SLaurent Vivier static void cpu_get_fp80(uint64_t *pmant, uint16_t *pexp, floatx80 f)
355d21f73c6SLaurent Vivier {
356d21f73c6SLaurent Vivier     CPU_LDoubleU temp;
357d21f73c6SLaurent Vivier 
358d21f73c6SLaurent Vivier     temp.d = f;
359d21f73c6SLaurent Vivier     *pmant = temp.l.lower;
360d21f73c6SLaurent Vivier     *pexp = temp.l.upper;
361d21f73c6SLaurent Vivier }
362d21f73c6SLaurent Vivier 
cpu_set_fp80(uint64_t mant,uint16_t upper)363d21f73c6SLaurent Vivier static floatx80 cpu_set_fp80(uint64_t mant, uint16_t upper)
364d21f73c6SLaurent Vivier {
365d21f73c6SLaurent Vivier     CPU_LDoubleU temp;
366d21f73c6SLaurent Vivier 
367d21f73c6SLaurent Vivier     temp.l.upper = upper;
368d21f73c6SLaurent Vivier     temp.l.lower = mant;
369d21f73c6SLaurent Vivier     return temp.d;
370d21f73c6SLaurent Vivier }
371d21f73c6SLaurent Vivier 
freg_pre_save(void * opaque)372d21f73c6SLaurent Vivier static int freg_pre_save(void *opaque)
373d21f73c6SLaurent Vivier {
374d21f73c6SLaurent Vivier     m68k_FPReg_tmp *tmp = opaque;
375d21f73c6SLaurent Vivier 
376d21f73c6SLaurent Vivier     cpu_get_fp80(&tmp->tmp_mant, &tmp->tmp_exp, tmp->parent->d);
377d21f73c6SLaurent Vivier 
378d21f73c6SLaurent Vivier     return 0;
379d21f73c6SLaurent Vivier }
380d21f73c6SLaurent Vivier 
freg_post_load(void * opaque,int version)381d21f73c6SLaurent Vivier static int freg_post_load(void *opaque, int version)
382d21f73c6SLaurent Vivier {
383d21f73c6SLaurent Vivier     m68k_FPReg_tmp *tmp = opaque;
384d21f73c6SLaurent Vivier 
385d21f73c6SLaurent Vivier     tmp->parent->d = cpu_set_fp80(tmp->tmp_mant, tmp->tmp_exp);
386d21f73c6SLaurent Vivier 
387d21f73c6SLaurent Vivier     return 0;
388d21f73c6SLaurent Vivier }
389d21f73c6SLaurent Vivier 
390d21f73c6SLaurent Vivier static const VMStateDescription vmstate_freg_tmp = {
391d21f73c6SLaurent Vivier     .name = "freg_tmp",
392d21f73c6SLaurent Vivier     .post_load = freg_post_load,
393d21f73c6SLaurent Vivier     .pre_save  = freg_pre_save,
394f3fb948fSRichard Henderson     .fields = (const VMStateField[]) {
395d21f73c6SLaurent Vivier         VMSTATE_UINT64(tmp_mant, m68k_FPReg_tmp),
396d21f73c6SLaurent Vivier         VMSTATE_UINT16(tmp_exp, m68k_FPReg_tmp),
397d21f73c6SLaurent Vivier         VMSTATE_END_OF_LIST()
398d21f73c6SLaurent Vivier     }
399d21f73c6SLaurent Vivier };
400d21f73c6SLaurent Vivier 
401d21f73c6SLaurent Vivier static const VMStateDescription vmstate_freg = {
402d21f73c6SLaurent Vivier     .name = "freg",
403f3fb948fSRichard Henderson     .fields = (const VMStateField[]) {
404d21f73c6SLaurent Vivier         VMSTATE_WITH_TMP(FPReg, m68k_FPReg_tmp, vmstate_freg_tmp),
405d21f73c6SLaurent Vivier         VMSTATE_END_OF_LIST()
406d21f73c6SLaurent Vivier     }
407d21f73c6SLaurent Vivier };
408d21f73c6SLaurent Vivier 
fpu_pre_save(void * opaque)40958883579SKeith Packard static int fpu_pre_save(void *opaque)
41058883579SKeith Packard {
41158883579SKeith Packard     M68kCPU *s = opaque;
41258883579SKeith Packard 
41358883579SKeith Packard     s->env.fpsr = cpu_m68k_get_fpsr(&s->env);
41458883579SKeith Packard     return 0;
41558883579SKeith Packard }
41658883579SKeith Packard 
fpu_post_load(void * opaque,int version)417d21f73c6SLaurent Vivier static int fpu_post_load(void *opaque, int version)
418d21f73c6SLaurent Vivier {
419d21f73c6SLaurent Vivier     M68kCPU *s = opaque;
420d21f73c6SLaurent Vivier 
42158883579SKeith Packard     cpu_m68k_set_fpsr(&s->env, s->env.fpsr);
422d21f73c6SLaurent Vivier     return 0;
423d21f73c6SLaurent Vivier }
424d21f73c6SLaurent Vivier 
425d21f73c6SLaurent Vivier const VMStateDescription vmmstate_fpu = {
426d21f73c6SLaurent Vivier     .name = "cpu/fpu",
427d21f73c6SLaurent Vivier     .version_id = 1,
428d21f73c6SLaurent Vivier     .minimum_version_id = 1,
429d21f73c6SLaurent Vivier     .needed = fpu_needed,
43058883579SKeith Packard     .pre_save = fpu_pre_save,
431d21f73c6SLaurent Vivier     .post_load = fpu_post_load,
432f3fb948fSRichard Henderson     .fields = (const VMStateField[]) {
433d21f73c6SLaurent Vivier         VMSTATE_UINT32(env.fpcr, M68kCPU),
434d21f73c6SLaurent Vivier         VMSTATE_UINT32(env.fpsr, M68kCPU),
435d21f73c6SLaurent Vivier         VMSTATE_STRUCT_ARRAY(env.fregs, M68kCPU, 8, 0, vmstate_freg, FPReg),
436d21f73c6SLaurent Vivier         VMSTATE_STRUCT(env.fp_result, M68kCPU, 0, vmstate_freg, FPReg),
437d21f73c6SLaurent Vivier         VMSTATE_END_OF_LIST()
438d21f73c6SLaurent Vivier     }
439d21f73c6SLaurent Vivier };
440d21f73c6SLaurent Vivier 
cf_spregs_needed(void * opaque)441d21f73c6SLaurent Vivier static bool cf_spregs_needed(void *opaque)
442d21f73c6SLaurent Vivier {
443d21f73c6SLaurent Vivier     M68kCPU *s = opaque;
444d21f73c6SLaurent Vivier 
445d21f73c6SLaurent Vivier     return m68k_feature(&s->env, M68K_FEATURE_CF_ISA_A);
446d21f73c6SLaurent Vivier }
447d21f73c6SLaurent Vivier 
448d21f73c6SLaurent Vivier const VMStateDescription vmstate_cf_spregs = {
449d21f73c6SLaurent Vivier     .name = "cpu/cf_spregs",
450d21f73c6SLaurent Vivier     .version_id = 1,
451d21f73c6SLaurent Vivier     .minimum_version_id = 1,
452d21f73c6SLaurent Vivier     .needed = cf_spregs_needed,
453f3fb948fSRichard Henderson     .fields = (const VMStateField[]) {
454d21f73c6SLaurent Vivier         VMSTATE_UINT64_ARRAY(env.macc, M68kCPU, 4),
455d21f73c6SLaurent Vivier         VMSTATE_UINT32(env.macsr, M68kCPU),
456d21f73c6SLaurent Vivier         VMSTATE_UINT32(env.mac_mask, M68kCPU),
457d21f73c6SLaurent Vivier         VMSTATE_UINT32(env.rambar0, M68kCPU),
458d21f73c6SLaurent Vivier         VMSTATE_UINT32(env.mbar, M68kCPU),
459d21f73c6SLaurent Vivier         VMSTATE_END_OF_LIST()
460d21f73c6SLaurent Vivier     }
461d21f73c6SLaurent Vivier };
462d21f73c6SLaurent Vivier 
cpu_68040_mmu_needed(void * opaque)463d21f73c6SLaurent Vivier static bool cpu_68040_mmu_needed(void *opaque)
464d21f73c6SLaurent Vivier {
465d21f73c6SLaurent Vivier     M68kCPU *s = opaque;
466d21f73c6SLaurent Vivier 
467d21f73c6SLaurent Vivier     return m68k_feature(&s->env, M68K_FEATURE_M68040);
468d21f73c6SLaurent Vivier }
469d21f73c6SLaurent Vivier 
470d21f73c6SLaurent Vivier const VMStateDescription vmstate_68040_mmu = {
471d21f73c6SLaurent Vivier     .name = "cpu/68040_mmu",
472d21f73c6SLaurent Vivier     .version_id = 1,
473d21f73c6SLaurent Vivier     .minimum_version_id = 1,
474d21f73c6SLaurent Vivier     .needed = cpu_68040_mmu_needed,
475f3fb948fSRichard Henderson     .fields = (const VMStateField[]) {
476d21f73c6SLaurent Vivier         VMSTATE_UINT32(env.mmu.ar, M68kCPU),
477d21f73c6SLaurent Vivier         VMSTATE_UINT32(env.mmu.ssw, M68kCPU),
478d21f73c6SLaurent Vivier         VMSTATE_UINT16(env.mmu.tcr, M68kCPU),
479d21f73c6SLaurent Vivier         VMSTATE_UINT32(env.mmu.urp, M68kCPU),
480d21f73c6SLaurent Vivier         VMSTATE_UINT32(env.mmu.srp, M68kCPU),
481d21f73c6SLaurent Vivier         VMSTATE_BOOL(env.mmu.fault, M68kCPU),
482d21f73c6SLaurent Vivier         VMSTATE_UINT32_ARRAY(env.mmu.ttr, M68kCPU, 4),
483d21f73c6SLaurent Vivier         VMSTATE_UINT32(env.mmu.mmusr, M68kCPU),
484d21f73c6SLaurent Vivier         VMSTATE_END_OF_LIST()
485d21f73c6SLaurent Vivier     }
486d21f73c6SLaurent Vivier };
487d21f73c6SLaurent Vivier 
cpu_68040_spregs_needed(void * opaque)488d21f73c6SLaurent Vivier static bool cpu_68040_spregs_needed(void *opaque)
489d21f73c6SLaurent Vivier {
490d21f73c6SLaurent Vivier     M68kCPU *s = opaque;
491d21f73c6SLaurent Vivier 
492d21f73c6SLaurent Vivier     return m68k_feature(&s->env, M68K_FEATURE_M68040);
493d21f73c6SLaurent Vivier }
494d21f73c6SLaurent Vivier 
495d21f73c6SLaurent Vivier const VMStateDescription vmstate_68040_spregs = {
496d21f73c6SLaurent Vivier     .name = "cpu/68040_spregs",
497d21f73c6SLaurent Vivier     .version_id = 1,
498d21f73c6SLaurent Vivier     .minimum_version_id = 1,
499d21f73c6SLaurent Vivier     .needed = cpu_68040_spregs_needed,
500f3fb948fSRichard Henderson     .fields = (const VMStateField[]) {
501d21f73c6SLaurent Vivier         VMSTATE_UINT32(env.vbr, M68kCPU),
502d21f73c6SLaurent Vivier         VMSTATE_UINT32(env.cacr, M68kCPU),
503d21f73c6SLaurent Vivier         VMSTATE_UINT32(env.sfc, M68kCPU),
504d21f73c6SLaurent Vivier         VMSTATE_UINT32(env.dfc, M68kCPU),
505d21f73c6SLaurent Vivier         VMSTATE_END_OF_LIST()
506d21f73c6SLaurent Vivier     }
507d21f73c6SLaurent Vivier };
508d21f73c6SLaurent Vivier 
509fcf5ef2aSThomas Huth static const VMStateDescription vmstate_m68k_cpu = {
510fcf5ef2aSThomas Huth     .name = "cpu",
511d21f73c6SLaurent Vivier     .version_id = 1,
512d21f73c6SLaurent Vivier     .minimum_version_id = 1,
513f3fb948fSRichard Henderson     .fields = (const VMStateField[]) {
514d21f73c6SLaurent Vivier         VMSTATE_UINT32_ARRAY(env.dregs, M68kCPU, 8),
515d21f73c6SLaurent Vivier         VMSTATE_UINT32_ARRAY(env.aregs, M68kCPU, 8),
516d21f73c6SLaurent Vivier         VMSTATE_UINT32(env.pc, M68kCPU),
517d21f73c6SLaurent Vivier         VMSTATE_UINT32(env.sr, M68kCPU),
518d21f73c6SLaurent Vivier         VMSTATE_INT32(env.current_sp, M68kCPU),
519d21f73c6SLaurent Vivier         VMSTATE_UINT32_ARRAY(env.sp, M68kCPU, 3),
520d21f73c6SLaurent Vivier         VMSTATE_UINT32(env.cc_op, M68kCPU),
521d21f73c6SLaurent Vivier         VMSTATE_UINT32(env.cc_x, M68kCPU),
522d21f73c6SLaurent Vivier         VMSTATE_UINT32(env.cc_n, M68kCPU),
523d21f73c6SLaurent Vivier         VMSTATE_UINT32(env.cc_v, M68kCPU),
524d21f73c6SLaurent Vivier         VMSTATE_UINT32(env.cc_c, M68kCPU),
525d21f73c6SLaurent Vivier         VMSTATE_UINT32(env.cc_z, M68kCPU),
526d21f73c6SLaurent Vivier         VMSTATE_INT32(env.pending_vector, M68kCPU),
527d21f73c6SLaurent Vivier         VMSTATE_INT32(env.pending_level, M68kCPU),
528d21f73c6SLaurent Vivier         VMSTATE_END_OF_LIST()
529d21f73c6SLaurent Vivier     },
530f3fb948fSRichard Henderson     .subsections = (const VMStateDescription * const []) {
531d21f73c6SLaurent Vivier         &vmmstate_fpu,
532d21f73c6SLaurent Vivier         &vmstate_cf_spregs,
533d21f73c6SLaurent Vivier         &vmstate_68040_mmu,
534d21f73c6SLaurent Vivier         &vmstate_68040_spregs,
535d21f73c6SLaurent Vivier         NULL
536d21f73c6SLaurent Vivier     },
537fcf5ef2aSThomas Huth };
538fcf5ef2aSThomas Huth 
5398b80bd28SPhilippe Mathieu-Daudé #include "hw/core/sysemu-cpu-ops.h"
5408b80bd28SPhilippe Mathieu-Daudé 
5418b80bd28SPhilippe Mathieu-Daudé static const struct SysemuCPUOps m68k_sysemu_ops = {
54208928c6dSPhilippe Mathieu-Daudé     .get_phys_page_debug = m68k_cpu_get_phys_page_debug,
5438b80bd28SPhilippe Mathieu-Daudé };
5446a140586SPhilippe Mathieu-Daudé #endif /* !CONFIG_USER_ONLY */
5458b80bd28SPhilippe Mathieu-Daudé 
54678271684SClaudio Fontana #include "hw/core/tcg-cpu-ops.h"
54778271684SClaudio Fontana 
5481764ad70SRichard Henderson static const TCGCPUOps m68k_tcg_ops = {
54978271684SClaudio Fontana     .initialize = m68k_tcg_init,
550584fd342SRichard Henderson     .restore_state_to_opc = m68k_restore_state_to_opc,
55178271684SClaudio Fontana 
55278271684SClaudio Fontana #ifndef CONFIG_USER_ONLY
553028772c4SRichard Henderson     .tlb_fill = m68k_cpu_tlb_fill,
554d5db810cSPhilippe Mathieu-Daudé     .cpu_exec_interrupt = m68k_cpu_exec_interrupt,
5554f7b1ecbSPeter Maydell     .cpu_exec_halt = m68k_cpu_has_work,
55678271684SClaudio Fontana     .do_interrupt = m68k_cpu_do_interrupt,
55778271684SClaudio Fontana     .do_transaction_failed = m68k_cpu_transaction_failed,
55878271684SClaudio Fontana #endif /* !CONFIG_USER_ONLY */
55978271684SClaudio Fontana };
56078271684SClaudio Fontana 
m68k_cpu_class_init(ObjectClass * c,void * data)561fcf5ef2aSThomas Huth static void m68k_cpu_class_init(ObjectClass *c, void *data)
562fcf5ef2aSThomas Huth {
563fcf5ef2aSThomas Huth     M68kCPUClass *mcc = M68K_CPU_CLASS(c);
564fcf5ef2aSThomas Huth     CPUClass *cc = CPU_CLASS(c);
565fcf5ef2aSThomas Huth     DeviceClass *dc = DEVICE_CLASS(c);
566bf90b345SPeter Maydell     ResettableClass *rc = RESETTABLE_CLASS(c);
567fcf5ef2aSThomas Huth 
568bf853881SPhilippe Mathieu-Daudé     device_class_set_parent_realize(dc, m68k_cpu_realizefn,
569bf853881SPhilippe Mathieu-Daudé                                     &mcc->parent_realize);
570bf90b345SPeter Maydell     resettable_class_set_parent_phases(rc, NULL, m68k_cpu_reset_hold, NULL,
571bf90b345SPeter Maydell                                        &mcc->parent_phases);
572fcf5ef2aSThomas Huth 
573fcf5ef2aSThomas Huth     cc->class_by_name = m68k_cpu_class_by_name;
574fcf5ef2aSThomas Huth     cc->has_work = m68k_cpu_has_work;
575a5a2d7f6SRichard Henderson     cc->mmu_index = m68k_cpu_mmu_index;
576fcf5ef2aSThomas Huth     cc->dump_state = m68k_cpu_dump_state;
577fcf5ef2aSThomas Huth     cc->set_pc = m68k_cpu_set_pc;
578e4fdf9dfSRichard Henderson     cc->get_pc = m68k_cpu_get_pc;
579fcf5ef2aSThomas Huth     cc->gdb_read_register = m68k_cpu_gdb_read_register;
580fcf5ef2aSThomas Huth     cc->gdb_write_register = m68k_cpu_gdb_write_register;
5816a140586SPhilippe Mathieu-Daudé #if !defined(CONFIG_USER_ONLY)
582d21f73c6SLaurent Vivier     dc->vmsd = &vmstate_m68k_cpu;
5838b80bd28SPhilippe Mathieu-Daudé     cc->sysemu_ops = &m68k_sysemu_ops;
584fcf5ef2aSThomas Huth #endif
585fcf5ef2aSThomas Huth     cc->disas_set_info = m68k_cpu_disas_set_info;
586fcf5ef2aSThomas Huth 
58778271684SClaudio Fontana     cc->tcg_ops = &m68k_tcg_ops;
588fcf5ef2aSThomas Huth }
589fcf5ef2aSThomas Huth 
m68k_cpu_class_init_cf_core(ObjectClass * c,void * data)590a976ed3fSKONRAD Frederic static void m68k_cpu_class_init_cf_core(ObjectClass *c, void *data)
591a976ed3fSKONRAD Frederic {
592a976ed3fSKONRAD Frederic     CPUClass *cc = CPU_CLASS(c);
593a976ed3fSKONRAD Frederic 
594a976ed3fSKONRAD Frederic     cc->gdb_core_xml_file = "cf-core.xml";
595a976ed3fSKONRAD Frederic }
596a976ed3fSKONRAD Frederic 
597a976ed3fSKONRAD Frederic #define DEFINE_M68K_CPU_TYPE_CF(model)               \
598f61797bdSIgor Mammedov     {                                                \
599a976ed3fSKONRAD Frederic         .name = M68K_CPU_TYPE_NAME(#model),          \
600a976ed3fSKONRAD Frederic         .instance_init = model##_cpu_initfn,         \
601f61797bdSIgor Mammedov         .parent = TYPE_M68K_CPU,                     \
602a976ed3fSKONRAD Frederic         .class_init = m68k_cpu_class_init_cf_core    \
603a976ed3fSKONRAD Frederic     }
604a976ed3fSKONRAD Frederic 
m68k_cpu_class_init_m68k_core(ObjectClass * c,void * data)605a976ed3fSKONRAD Frederic static void m68k_cpu_class_init_m68k_core(ObjectClass *c, void *data)
606a976ed3fSKONRAD Frederic {
607a976ed3fSKONRAD Frederic     CPUClass *cc = CPU_CLASS(c);
608a976ed3fSKONRAD Frederic 
609a976ed3fSKONRAD Frederic     cc->gdb_core_xml_file = "m68k-core.xml";
610a976ed3fSKONRAD Frederic }
611a976ed3fSKONRAD Frederic 
612a976ed3fSKONRAD Frederic #define DEFINE_M68K_CPU_TYPE_M68K(model)             \
613a976ed3fSKONRAD Frederic     {                                                \
614a976ed3fSKONRAD Frederic         .name = M68K_CPU_TYPE_NAME(#model),          \
615a976ed3fSKONRAD Frederic         .instance_init = model##_cpu_initfn,         \
616a976ed3fSKONRAD Frederic         .parent = TYPE_M68K_CPU,                     \
617a976ed3fSKONRAD Frederic         .class_init = m68k_cpu_class_init_m68k_core  \
618fcf5ef2aSThomas Huth     }
619fcf5ef2aSThomas Huth 
620f61797bdSIgor Mammedov static const TypeInfo m68k_cpus_type_infos[] = {
621f61797bdSIgor Mammedov     { /* base class should be registered first */
622fcf5ef2aSThomas Huth         .name = TYPE_M68K_CPU,
623fcf5ef2aSThomas Huth         .parent = TYPE_CPU,
624fcf5ef2aSThomas Huth         .instance_size = sizeof(M68kCPU),
625f669c992SRichard Henderson         .instance_align = __alignof(M68kCPU),
626fcf5ef2aSThomas Huth         .abstract = true,
627fcf5ef2aSThomas Huth         .class_size = sizeof(M68kCPUClass),
628fcf5ef2aSThomas Huth         .class_init = m68k_cpu_class_init,
629f61797bdSIgor Mammedov     },
630a976ed3fSKONRAD Frederic     DEFINE_M68K_CPU_TYPE_M68K(m68000),
6314ecce5fbSLucien Murray-Pitts     DEFINE_M68K_CPU_TYPE_M68K(m68010),
632a976ed3fSKONRAD Frederic     DEFINE_M68K_CPU_TYPE_M68K(m68020),
633a976ed3fSKONRAD Frederic     DEFINE_M68K_CPU_TYPE_M68K(m68030),
634a976ed3fSKONRAD Frederic     DEFINE_M68K_CPU_TYPE_M68K(m68040),
635a976ed3fSKONRAD Frederic     DEFINE_M68K_CPU_TYPE_M68K(m68060),
636a976ed3fSKONRAD Frederic     DEFINE_M68K_CPU_TYPE_CF(m5206),
637a976ed3fSKONRAD Frederic     DEFINE_M68K_CPU_TYPE_CF(m5208),
638a976ed3fSKONRAD Frederic     DEFINE_M68K_CPU_TYPE_CF(cfv4e),
639a976ed3fSKONRAD Frederic     DEFINE_M68K_CPU_TYPE_CF(any),
640fcf5ef2aSThomas Huth };
641fcf5ef2aSThomas Huth 
642f61797bdSIgor Mammedov DEFINE_TYPES(m68k_cpus_type_infos)
643