]>
Commit | Line | Data |
---|---|---|
525bd324 AG |
1 | /* |
2 | * Moxie emulation | |
3 | * | |
4 | * Copyright (c) 2008, 2010, 2013 Anthony Green | |
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 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 General Public License | |
17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | */ | |
19 | #ifndef _CPU_MOXIE_H | |
20 | #define _CPU_MOXIE_H | |
21 | ||
22 | #include "config.h" | |
23 | #include "qemu-common.h" | |
24 | ||
25 | #define TARGET_LONG_BITS 32 | |
26 | ||
27 | #define CPUArchState struct CPUMoxieState | |
28 | ||
525bd324 AG |
29 | #define ELF_MACHINE 0xFEED /* EM_MOXIE */ |
30 | ||
31 | #define MOXIE_EX_DIV0 0 | |
32 | #define MOXIE_EX_BAD 1 | |
33 | #define MOXIE_EX_IRQ 2 | |
34 | #define MOXIE_EX_SWI 3 | |
35 | #define MOXIE_EX_MMU_MISS 4 | |
36 | #define MOXIE_EX_BREAK 16 | |
37 | ||
38 | #include "exec/cpu-defs.h" | |
39 | #include "fpu/softfloat.h" | |
40 | ||
41 | #define TARGET_PAGE_BITS 12 /* 4k */ | |
42 | ||
43 | #define TARGET_PHYS_ADDR_SPACE_BITS 32 | |
44 | #define TARGET_VIRT_ADDR_SPACE_BITS 32 | |
45 | ||
46 | #define NB_MMU_MODES 1 | |
47 | ||
48 | typedef struct CPUMoxieState { | |
49 | ||
50 | uint32_t flags; /* general execution flags */ | |
51 | uint32_t gregs[16]; /* general registers */ | |
52 | uint32_t sregs[256]; /* special registers */ | |
53 | uint32_t pc; /* program counter */ | |
54 | /* Instead of saving the cc value, we save the cmp arguments | |
55 | and compute cc on demand. */ | |
56 | uint32_t cc_a; /* reg a for condition code calculation */ | |
57 | uint32_t cc_b; /* reg b for condition code calculation */ | |
58 | ||
59 | void *irq[8]; | |
60 | ||
61 | CPU_COMMON | |
62 | ||
63 | } CPUMoxieState; | |
64 | ||
65 | #include "qom/cpu.h" | |
66 | ||
67 | #define TYPE_MOXIE_CPU "moxie-cpu" | |
68 | ||
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) | |
75 | ||
76 | /** | |
77 | * MoxieCPUClass: | |
78 | * @parent_reset: The parent class' reset handler. | |
79 | * | |
80 | * A Moxie CPU model. | |
81 | */ | |
82 | typedef struct MoxieCPUClass { | |
83 | /*< private >*/ | |
84 | CPUClass parent_class; | |
85 | /*< public >*/ | |
86 | ||
87 | DeviceRealize parent_realize; | |
88 | void (*parent_reset)(CPUState *cpu); | |
89 | } MoxieCPUClass; | |
90 | ||
91 | /** | |
92 | * MoxieCPU: | |
93 | * @env: #CPUMoxieState | |
94 | * | |
95 | * A Moxie CPU. | |
96 | */ | |
97 | typedef struct MoxieCPU { | |
98 | /*< private >*/ | |
99 | CPUState parent_obj; | |
100 | /*< public >*/ | |
101 | ||
102 | CPUMoxieState env; | |
103 | } MoxieCPU; | |
104 | ||
105 | static inline MoxieCPU *moxie_env_get_cpu(CPUMoxieState *env) | |
106 | { | |
6e42be7c | 107 | return container_of(env, MoxieCPU, env); |
525bd324 AG |
108 | } |
109 | ||
110 | #define ENV_GET_CPU(e) CPU(moxie_env_get_cpu(e)) | |
111 | ||
112 | #define ENV_OFFSET offsetof(MoxieCPU, env) | |
113 | ||
114 | MoxieCPU *cpu_moxie_init(const char *cpu_model); | |
115 | int cpu_moxie_exec(CPUMoxieState *s); | |
53574064 | 116 | void moxie_cpu_do_interrupt(CPUState *cs); |
878096ee AF |
117 | void moxie_cpu_dump_state(CPUState *cpu, FILE *f, |
118 | fprintf_function cpu_fprintf, int flags); | |
00b941e5 | 119 | hwaddr moxie_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); |
525bd324 AG |
120 | void moxie_translate_init(void); |
121 | int cpu_moxie_signal_handler(int host_signum, void *pinfo, | |
122 | void *puc); | |
123 | ||
124 | static inline CPUMoxieState *cpu_init(const char *cpu_model) | |
125 | { | |
126 | MoxieCPU *cpu = cpu_moxie_init(cpu_model); | |
127 | if (cpu == NULL) { | |
128 | return NULL; | |
129 | } | |
130 | return &cpu->env; | |
131 | } | |
132 | ||
133 | #define cpu_exec cpu_moxie_exec | |
134 | #define cpu_gen_code cpu_moxie_gen_code | |
135 | #define cpu_signal_handler cpu_moxie_signal_handler | |
136 | ||
137 | static inline int cpu_mmu_index(CPUMoxieState *env) | |
138 | { | |
139 | return 0; | |
140 | } | |
141 | ||
142 | #include "exec/cpu-all.h" | |
143 | #include "exec/exec-all.h" | |
144 | ||
525bd324 AG |
145 | static inline void cpu_get_tb_cpu_state(CPUMoxieState *env, target_ulong *pc, |
146 | target_ulong *cs_base, int *flags) | |
147 | { | |
148 | *pc = env->pc; | |
149 | *cs_base = 0; | |
150 | *flags = 0; | |
151 | } | |
152 | ||
7510454e | 153 | int moxie_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, |
525bd324 AG |
154 | int rw, int mmu_idx); |
155 | ||
156 | #endif /* _CPU_MOXIE_H */ |