2007-04-05 10:58:33 +04:00
|
|
|
/*
|
2012-03-24 20:51:13 +04:00
|
|
|
* Helpers for loads and stores
|
2007-09-17 01:08:06 +04:00
|
|
|
*
|
2007-04-05 10:58:33 +04:00
|
|
|
* Copyright (c) 2007 Jocelyn Mayer
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2009-07-17 00:47:01 +04:00
|
|
|
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
2007-04-05 10:58:33 +04:00
|
|
|
*/
|
|
|
|
|
2016-01-26 21:17:04 +03:00
|
|
|
#include "qemu/osdep.h"
|
2011-07-13 16:44:15 +04:00
|
|
|
#include "cpu.h"
|
2014-04-08 09:31:41 +04:00
|
|
|
#include "exec/helper-proto.h"
|
2016-03-15 15:18:37 +03:00
|
|
|
#include "exec/exec-all.h"
|
2014-03-28 22:42:10 +04:00
|
|
|
#include "exec/cpu_ldst.h"
|
2007-04-05 10:58:33 +04:00
|
|
|
|
|
|
|
/* Softmmu support */
|
2012-03-24 20:51:13 +04:00
|
|
|
#ifndef CONFIG_USER_ONLY
|
2014-03-28 21:14:58 +04:00
|
|
|
void alpha_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
|
2016-06-14 15:26:17 +03:00
|
|
|
MMUAccessType access_type,
|
|
|
|
int mmu_idx, uintptr_t retaddr)
|
2011-04-19 03:13:12 +04:00
|
|
|
{
|
2014-03-28 21:14:58 +04:00
|
|
|
AlphaCPU *cpu = ALPHA_CPU(cs);
|
|
|
|
CPUAlphaState *env = &cpu->env;
|
2011-04-19 03:13:12 +04:00
|
|
|
uint64_t pc;
|
|
|
|
uint32_t insn;
|
|
|
|
|
2012-12-05 00:16:07 +04:00
|
|
|
if (retaddr) {
|
2013-09-01 18:51:34 +04:00
|
|
|
cpu_restore_state(cs, retaddr);
|
2012-12-05 00:16:07 +04:00
|
|
|
}
|
2011-04-19 03:13:12 +04:00
|
|
|
|
|
|
|
pc = env->pc;
|
2012-03-24 20:51:13 +04:00
|
|
|
insn = cpu_ldl_code(env, pc);
|
2011-04-19 03:13:12 +04:00
|
|
|
|
|
|
|
env->trap_arg0 = addr;
|
|
|
|
env->trap_arg1 = insn >> 26; /* opcode */
|
|
|
|
env->trap_arg2 = (insn >> 21) & 31; /* dest regno */
|
2013-08-26 10:31:06 +04:00
|
|
|
cs->exception_index = EXCP_UNALIGN;
|
2012-03-24 20:51:08 +04:00
|
|
|
env->error_code = 0;
|
2013-08-27 19:52:12 +04:00
|
|
|
cpu_loop_exit(cs);
|
2011-04-19 03:13:12 +04:00
|
|
|
}
|
|
|
|
|
2017-08-08 15:42:52 +03:00
|
|
|
void alpha_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,
|
|
|
|
vaddr addr, unsigned size,
|
|
|
|
MMUAccessType access_type,
|
|
|
|
int mmu_idx, MemTxAttrs attrs,
|
|
|
|
MemTxResult response, uintptr_t retaddr)
|
2011-04-19 03:13:12 +04:00
|
|
|
{
|
2013-05-27 08:49:53 +04:00
|
|
|
AlphaCPU *cpu = ALPHA_CPU(cs);
|
|
|
|
CPUAlphaState *env = &cpu->env;
|
|
|
|
|
2017-08-08 15:42:52 +03:00
|
|
|
if (retaddr) {
|
|
|
|
cpu_restore_state(cs, retaddr);
|
|
|
|
}
|
|
|
|
|
2011-04-19 03:13:12 +04:00
|
|
|
env->trap_arg0 = addr;
|
2017-08-08 15:42:52 +03:00
|
|
|
env->trap_arg1 = access_type == MMU_DATA_STORE ? 1 : 0;
|
2014-06-29 00:06:19 +04:00
|
|
|
cs->exception_index = EXCP_MCHK;
|
|
|
|
env->error_code = 0;
|
|
|
|
cpu_loop_exit(cs);
|
2011-04-19 03:13:12 +04:00
|
|
|
}
|
|
|
|
|
2007-04-05 10:58:33 +04:00
|
|
|
/* try to fill the TLB and return an exception if error. If retaddr is
|
|
|
|
NULL, it means that the function was called in C code (i.e. not
|
|
|
|
from generated code or from helper.c) */
|
|
|
|
/* XXX: fix it to restore all registers */
|
2016-06-14 15:26:17 +03:00
|
|
|
void tlb_fill(CPUState *cs, target_ulong addr, MMUAccessType access_type,
|
2012-04-09 18:20:20 +04:00
|
|
|
int mmu_idx, uintptr_t retaddr)
|
2007-04-05 10:58:33 +04:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2016-06-14 15:26:17 +03:00
|
|
|
ret = alpha_cpu_handle_mmu_fault(cs, addr, access_type, mmu_idx);
|
2011-04-25 23:20:27 +04:00
|
|
|
if (unlikely(ret != 0)) {
|
2012-12-05 00:16:07 +04:00
|
|
|
if (retaddr) {
|
2013-09-01 18:51:34 +04:00
|
|
|
cpu_restore_state(cs, retaddr);
|
2012-12-05 00:16:07 +04:00
|
|
|
}
|
2007-04-05 10:58:33 +04:00
|
|
|
/* Exception index and error code are already set */
|
2013-08-27 19:52:12 +04:00
|
|
|
cpu_loop_exit(cs);
|
2007-04-05 10:58:33 +04:00
|
|
|
}
|
|
|
|
}
|
2012-03-24 20:51:13 +04:00
|
|
|
#endif /* CONFIG_USER_ONLY */
|