cpu: Replace ENV_GET_CPU with env_cpu
[qemu/ar7.git] / target / moxie / cpu.h
blob275fb9bfbb6f076966e528cf606e91a18ab72c31
1 /*
2 * Moxie emulation
4 * Copyright (c) 2008, 2010, 2013 Anthony Green
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.
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.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef MOXIE_CPU_H
21 #define MOXIE_CPU_H
23 #include "qemu-common.h"
24 #include "exec/cpu-defs.h"
26 #define MOXIE_EX_DIV0 0
27 #define MOXIE_EX_BAD 1
28 #define MOXIE_EX_IRQ 2
29 #define MOXIE_EX_SWI 3
30 #define MOXIE_EX_MMU_MISS 4
31 #define MOXIE_EX_BREAK 16
33 typedef struct CPUMoxieState {
35 uint32_t flags; /* general execution flags */
36 uint32_t gregs[16]; /* general registers */
37 uint32_t sregs[256]; /* special registers */
38 uint32_t pc; /* program counter */
39 /* Instead of saving the cc value, we save the cmp arguments
40 and compute cc on demand. */
41 uint32_t cc_a; /* reg a for condition code calculation */
42 uint32_t cc_b; /* reg b for condition code calculation */
44 void *irq[8];
46 /* Fields up to this point are cleared by a CPU reset */
47 struct {} end_reset_fields;
49 CPU_COMMON
51 } CPUMoxieState;
53 #include "qom/cpu.h"
55 #define TYPE_MOXIE_CPU "moxie-cpu"
57 #define MOXIE_CPU_CLASS(klass) \
58 OBJECT_CLASS_CHECK(MoxieCPUClass, (klass), TYPE_MOXIE_CPU)
59 #define MOXIE_CPU(obj) \
60 OBJECT_CHECK(MoxieCPU, (obj), TYPE_MOXIE_CPU)
61 #define MOXIE_CPU_GET_CLASS(obj) \
62 OBJECT_GET_CLASS(MoxieCPUClass, (obj), TYPE_MOXIE_CPU)
64 /**
65 * MoxieCPUClass:
66 * @parent_reset: The parent class' reset handler.
68 * A Moxie CPU model.
70 typedef struct MoxieCPUClass {
71 /*< private >*/
72 CPUClass parent_class;
73 /*< public >*/
75 DeviceRealize parent_realize;
76 void (*parent_reset)(CPUState *cpu);
77 } MoxieCPUClass;
79 /**
80 * MoxieCPU:
81 * @env: #CPUMoxieState
83 * A Moxie CPU.
85 typedef struct MoxieCPU {
86 /*< private >*/
87 CPUState parent_obj;
88 /*< public >*/
90 CPUMoxieState env;
91 } MoxieCPU;
93 static inline MoxieCPU *moxie_env_get_cpu(CPUMoxieState *env)
95 return container_of(env, MoxieCPU, env);
98 #define ENV_OFFSET offsetof(MoxieCPU, env)
100 void moxie_cpu_do_interrupt(CPUState *cs);
101 void moxie_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
102 hwaddr moxie_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
103 void moxie_translate_init(void);
104 int cpu_moxie_signal_handler(int host_signum, void *pinfo,
105 void *puc);
107 #define MOXIE_CPU_TYPE_SUFFIX "-" TYPE_MOXIE_CPU
108 #define MOXIE_CPU_TYPE_NAME(model) model MOXIE_CPU_TYPE_SUFFIX
109 #define CPU_RESOLVING_TYPE TYPE_MOXIE_CPU
111 #define cpu_signal_handler cpu_moxie_signal_handler
113 static inline int cpu_mmu_index(CPUMoxieState *env, bool ifetch)
115 return 0;
118 typedef CPUMoxieState CPUArchState;
119 typedef MoxieCPU ArchCPU;
121 #include "exec/cpu-all.h"
123 static inline void cpu_get_tb_cpu_state(CPUMoxieState *env, target_ulong *pc,
124 target_ulong *cs_base, uint32_t *flags)
126 *pc = env->pc;
127 *cs_base = 0;
128 *flags = 0;
131 bool moxie_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
132 MMUAccessType access_type, int mmu_idx,
133 bool probe, uintptr_t retaddr);
135 #endif /* MOXIE_CPU_H */