]>
git.proxmox.com Git - 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
28 void cpu_m68k_flush_flags(CPUM68KState
*env
, int cc_op
)
35 #define HIGHBIT 0x80000000u
37 #define SET_NZ(x) do { \
40 else if ((int32_t)(x) < 0) \
44 #define SET_FLAGS_SUB(type, utype) do { \
47 if ((utype) tmp < (utype) src) \
49 if ((1u << (sizeof(type) * 8 - 1)) & (tmp ^ dest) & (tmp ^ src)) \
68 if (HIGHBIT
& (src
^ dest
) & ~(tmp
^ src
))
72 SET_FLAGS_SUB(int32_t, uint32_t);
75 SET_FLAGS_SUB(int8_t, uint8_t);
78 SET_FLAGS_SUB(int16_t, uint16_t);
85 if (HIGHBIT
& (src
^ dest
) & ~(tmp
^ src
))
93 if (HIGHBIT
& (tmp
^ dest
) & (tmp
^ src
))
103 if (src
&& src
<= 32 && (dest
& (1 << (32 - src
))))
113 if (src
&& src
<= 32 && ((dest
>> (src
- 1)) & 1))
120 tmp
= (int32_t)dest
>> src
;
123 if (src
&& src
<= 32 && (((int32_t)dest
>> (src
- 1)) & 1))
127 cpu_abort(env
, "Bad CC_OP %d", cc_op
);
129 env
->cc_op
= CC_OP_FLAGS
;
130 env
->cc_dest
= flags
;
133 float64
helper_sub_cmpf64(CPUM68KState
*env
, float64 src0
, float64 src1
)
135 /* ??? This may incorrectly raise exceptions. */
136 /* ??? Should flush denormals to zero. */
138 res
= float64_sub(src0
, src1
, &env
->fp_status
);
139 if (float64_is_nan(res
)) {
140 /* +/-inf compares equal against itself, but sub returns nan. */
141 if (!float64_is_nan(src0
)
142 && !float64_is_nan(src1
)) {
144 if (float64_lt_quiet(src0
, res
, &env
->fp_status
))
145 res
= float64_chs(res
);
151 void helper_movec(CPUM68KState
*env
, int reg
, uint32_t val
)
154 case 0x02: /* CACR */
157 case 0x801: /* VBR */
160 /* TODO: Implement control registers. */
162 cpu_abort(env
, "Unimplemented control register write 0x%x = 0x%x\n",
169 /* TODO: This will need fixing once the MMU is implemented. */
170 target_phys_addr_t
cpu_get_phys_page_debug(CPUState
*env
, target_ulong addr
)
175 #if defined(CONFIG_USER_ONLY)
177 int cpu_m68k_handle_mmu_fault (CPUState
*env
, target_ulong address
, int rw
,
178 int is_user
, int is_softmmu
)
180 env
->exception_index
= EXCP_ACCESS
;
181 env
->mmu
.ar
= address
;
187 int cpu_m68k_handle_mmu_fault (CPUState
*env
, target_ulong address
, int rw
,
188 int is_user
, int is_softmmu
)
192 address
&= TARGET_PAGE_MASK
;
193 prot
= PAGE_READ
| PAGE_WRITE
;
194 return tlb_set_page(env
, address
, address
, prot
, is_user
, is_softmmu
);
197 /* Notify CPU of a pending interrupt. Prioritization and vectoring should
198 be handled by the interrupt controller. Real hardware only requests
199 the vector when the interrupt is acknowledged by the CPU. For
200 simplicitly we calculate it when the interrupt is signalled. */
201 void m68k_set_irq_level(CPUM68KState
*env
, int level
, uint8_t vector
)
203 env
->pending_level
= level
;
204 env
->pending_vector
= vector
;
206 cpu_interrupt(env
, CPU_INTERRUPT_HARD
);
208 cpu_reset_interrupt(env
, CPU_INTERRUPT_HARD
);