]>
git.proxmox.com Git - mirror_qemu.git/blob - target-m68k/helper.c
4 * Copyright (c) 2006-2007 CodeSourcery
5 * Written by Paul Brook
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
40 static m68k_def_t m68k_cpu_defs
[] = {
41 {"m5206", M68K_CPUID_M5206
},
42 {"cfv4e", M68K_CPUID_CFV4E
},
43 {"any", M68K_CPUID_ANY
},
47 static void m68k_set_feature(CPUM68KState
*env
, int feature
)
49 env
->features
|= (1u << feature
);
52 int cpu_m68k_set_model(CPUM68KState
*env
, const char * name
)
56 for (def
= m68k_cpu_defs
; def
->name
; def
++) {
57 if (strcmp(def
->name
, name
) == 0)
64 case M68K_CPUID_M5206
:
65 m68k_set_feature(env
, M68K_FEATURE_CF_ISA_A
);
67 case M68K_CPUID_CFV4E
:
68 m68k_set_feature(env
, M68K_FEATURE_CF_ISA_A
);
69 m68k_set_feature(env
, M68K_FEATURE_CF_ISA_B
);
70 m68k_set_feature(env
, M68K_FEATURE_CF_ISA_C
);
71 m68k_set_feature(env
, M68K_FEATURE_CF_FPU
);
72 m68k_set_feature(env
, M68K_FEATURE_CF_MAC
);
73 m68k_set_feature(env
, M68K_FEATURE_CF_EMAC
);
76 m68k_set_feature(env
, M68K_FEATURE_CF_ISA_A
);
77 m68k_set_feature(env
, M68K_FEATURE_CF_ISA_B
);
78 m68k_set_feature(env
, M68K_FEATURE_CF_ISA_C
);
79 m68k_set_feature(env
, M68K_FEATURE_CF_FPU
);
80 m68k_set_feature(env
, M68K_FEATURE_CF_MAC
);
81 m68k_set_feature(env
, M68K_FEATURE_CF_EMAC
);
82 m68k_set_feature(env
, M68K_FEATURE_EXT_FULL
);
86 register_m68k_insns(env
);
91 void cpu_m68k_flush_flags(CPUM68KState
*env
, int cc_op
)
98 #define HIGHBIT 0x80000000u
100 #define SET_NZ(x) do { \
103 else if ((int32_t)(x) < 0) \
107 #define SET_FLAGS_SUB(type, utype) do { \
108 SET_NZ((type)dest); \
110 if ((utype) tmp < (utype) src) \
112 if ((1u << (sizeof(type) * 8 - 1)) & (tmp ^ dest) & (tmp ^ src)) \
131 if (HIGHBIT
& (src
^ dest
) & ~(tmp
^ src
))
135 SET_FLAGS_SUB(int32_t, uint32_t);
138 SET_FLAGS_SUB(int8_t, uint8_t);
141 SET_FLAGS_SUB(int16_t, uint16_t);
147 tmp
= dest
- src
- 1;
148 if (HIGHBIT
& (src
^ dest
) & ~(tmp
^ src
))
153 tmp
= dest
+ src
+ 1;
156 if (HIGHBIT
& (tmp
^ dest
) & (tmp
^ src
))
166 if (src
&& src
<= 32 && (dest
& (1 << (32 - src
))))
176 if (src
&& src
<= 32 && ((dest
>> (src
- 1)) & 1))
183 tmp
= (int32_t)dest
>> src
;
186 if (src
&& src
<= 32 && (((int32_t)dest
>> (src
- 1)) & 1))
190 cpu_abort(env
, "Bad CC_OP %d", cc_op
);
192 env
->cc_op
= CC_OP_FLAGS
;
193 env
->cc_dest
= flags
;
196 float64
helper_sub_cmpf64(CPUM68KState
*env
, float64 src0
, float64 src1
)
198 /* ??? This may incorrectly raise exceptions. */
199 /* ??? Should flush denormals to zero. */
201 res
= float64_sub(src0
, src1
, &env
->fp_status
);
202 if (float64_is_nan(res
)) {
203 /* +/-inf compares equal against itself, but sub returns nan. */
204 if (!float64_is_nan(src0
)
205 && !float64_is_nan(src1
)) {
207 if (float64_lt_quiet(src0
, res
, &env
->fp_status
))
208 res
= float64_chs(res
);
214 void helper_movec(CPUM68KState
*env
, int reg
, uint32_t val
)
217 case 0x02: /* CACR */
220 case 0x801: /* VBR */
223 /* TODO: Implement control registers. */
225 cpu_abort(env
, "Unimplemented control register write 0x%x = 0x%x\n",
232 /* TODO: This will need fixing once the MMU is implemented. */
233 target_phys_addr_t
cpu_get_phys_page_debug(CPUState
*env
, target_ulong addr
)
238 #if defined(CONFIG_USER_ONLY)
240 int cpu_m68k_handle_mmu_fault (CPUState
*env
, target_ulong address
, int rw
,
241 int is_user
, int is_softmmu
)
243 env
->exception_index
= EXCP_ACCESS
;
244 env
->mmu
.ar
= address
;
250 int cpu_m68k_handle_mmu_fault (CPUState
*env
, target_ulong address
, int rw
,
251 int is_user
, int is_softmmu
)
255 address
&= TARGET_PAGE_MASK
;
256 prot
= PAGE_READ
| PAGE_WRITE
;
257 return tlb_set_page(env
, address
, address
, prot
, is_user
, is_softmmu
);
260 /* Notify CPU of a pending interrupt. Prioritization and vectoring should
261 be handled by the interrupt controller. Real hardware only requests
262 the vector when the interrupt is acknowledged by the CPU. For
263 simplicitly we calculate it when the interrupt is signalled. */
264 void m68k_set_irq_level(CPUM68KState
*env
, int level
, uint8_t vector
)
266 env
->pending_level
= level
;
267 env
->pending_vector
= vector
;
269 cpu_interrupt(env
, CPU_INTERRUPT_HARD
);
271 cpu_reset_interrupt(env
, CPU_INTERRUPT_HARD
);