blockjob: Lie better in child_job_drained_poll()
[qemu.git] / target / moxie / cpu.h
blobd40f1e6c4510e927698de2ea5f4d2a2de4572c03
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 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 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"
25 #define TARGET_LONG_BITS 32
27 #define CPUArchState struct CPUMoxieState
29 #define MOXIE_EX_DIV0 0
30 #define MOXIE_EX_BAD 1
31 #define MOXIE_EX_IRQ 2
32 #define MOXIE_EX_SWI 3
33 #define MOXIE_EX_MMU_MISS 4
34 #define MOXIE_EX_BREAK 16
36 #include "exec/cpu-defs.h"
38 #define TARGET_PAGE_BITS 12 /* 4k */
40 #define TARGET_PHYS_ADDR_SPACE_BITS 32
41 #define TARGET_VIRT_ADDR_SPACE_BITS 32
43 #define NB_MMU_MODES 1
45 typedef struct CPUMoxieState {
47 uint32_t flags; /* general execution flags */
48 uint32_t gregs[16]; /* general registers */
49 uint32_t sregs[256]; /* special registers */
50 uint32_t pc; /* program counter */
51 /* Instead of saving the cc value, we save the cmp arguments
52 and compute cc on demand. */
53 uint32_t cc_a; /* reg a for condition code calculation */
54 uint32_t cc_b; /* reg b for condition code calculation */
56 void *irq[8];
58 /* Fields up to this point are cleared by a CPU reset */
59 struct {} end_reset_fields;
61 CPU_COMMON
63 } CPUMoxieState;
65 #include "qom/cpu.h"
67 #define TYPE_MOXIE_CPU "moxie-cpu"
69 #define MOXIE_CPU_CLASS(klass) \
70 OBJECT_CLASS_CHECK(MoxieCPUClass, (klass), TYPE_MOXIE_CPU)
71 #define MOXIE_CPU(obj) \
72 OBJECT_CHECK(MoxieCPU, (obj), TYPE_MOXIE_CPU)
73 #define MOXIE_CPU_GET_CLASS(obj) \
74 OBJECT_GET_CLASS(MoxieCPUClass, (obj), TYPE_MOXIE_CPU)
76 /**
77 * MoxieCPUClass:
78 * @parent_reset: The parent class' reset handler.
80 * A Moxie CPU model.
82 typedef struct MoxieCPUClass {
83 /*< private >*/
84 CPUClass parent_class;
85 /*< public >*/
87 DeviceRealize parent_realize;
88 void (*parent_reset)(CPUState *cpu);
89 } MoxieCPUClass;
91 /**
92 * MoxieCPU:
93 * @env: #CPUMoxieState
95 * A Moxie CPU.
97 typedef struct MoxieCPU {
98 /*< private >*/
99 CPUState parent_obj;
100 /*< public >*/
102 CPUMoxieState env;
103 } MoxieCPU;
105 static inline MoxieCPU *moxie_env_get_cpu(CPUMoxieState *env)
107 return container_of(env, MoxieCPU, env);
110 #define ENV_GET_CPU(e) CPU(moxie_env_get_cpu(e))
112 #define ENV_OFFSET offsetof(MoxieCPU, env)
114 void moxie_cpu_do_interrupt(CPUState *cs);
115 void moxie_cpu_dump_state(CPUState *cpu, FILE *f,
116 fprintf_function cpu_fprintf, int flags);
117 hwaddr moxie_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
118 void moxie_translate_init(void);
119 int cpu_moxie_signal_handler(int host_signum, void *pinfo,
120 void *puc);
122 #define MOXIE_CPU_TYPE_SUFFIX "-" TYPE_MOXIE_CPU
123 #define MOXIE_CPU_TYPE_NAME(model) model MOXIE_CPU_TYPE_SUFFIX
124 #define CPU_RESOLVING_TYPE TYPE_MOXIE_CPU
126 #define cpu_signal_handler cpu_moxie_signal_handler
128 static inline int cpu_mmu_index(CPUMoxieState *env, bool ifetch)
130 return 0;
133 #include "exec/cpu-all.h"
135 static inline void cpu_get_tb_cpu_state(CPUMoxieState *env, target_ulong *pc,
136 target_ulong *cs_base, uint32_t *flags)
138 *pc = env->pc;
139 *cs_base = 0;
140 *flags = 0;
143 int moxie_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int size,
144 int rw, int mmu_idx);
146 #endif /* MOXIE_CPU_H */