2004-01-05 01:58:38 +03:00
|
|
|
/*
|
2012-05-30 08:23:21 +04:00
|
|
|
* PowerPC emulation helpers for QEMU.
|
2007-09-17 01:08:06 +04:00
|
|
|
*
|
2007-03-07 11:32:30 +03:00
|
|
|
* Copyright (c) 2003-2007 Jocelyn Mayer
|
2004-01-05 01:58:38 +03:00
|
|
|
*
|
|
|
|
* 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/>.
|
2004-01-05 01:58:38 +03:00
|
|
|
*/
|
2009-01-05 01:09:19 +03:00
|
|
|
#include <string.h>
|
2011-07-13 16:44:15 +04:00
|
|
|
#include "cpu.h"
|
|
|
|
#include "dyngen-exec.h"
|
2007-10-28 15:54:53 +03:00
|
|
|
#include "host-utils.h"
|
2008-11-17 17:43:54 +03:00
|
|
|
#include "helper.h"
|
2004-01-05 01:58:38 +03:00
|
|
|
|
2007-10-26 01:35:50 +04:00
|
|
|
#include "helper_regs.h"
|
2007-03-21 01:11:31 +03:00
|
|
|
|
2011-07-13 16:44:15 +04:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
|
|
|
#include "softmmu_exec.h"
|
|
|
|
#endif /* !defined(CONFIG_USER_ONLY) */
|
|
|
|
|
2005-07-05 02:17:05 +04:00
|
|
|
//#define DEBUG_OP
|
2009-01-16 00:48:06 +03:00
|
|
|
|
2008-12-07 16:40:29 +03:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* SPR accesses */
|
2012-05-30 08:23:21 +04:00
|
|
|
void helper_load_dump_spr(uint32_t sprn)
|
2007-04-16 11:10:48 +04:00
|
|
|
{
|
2009-08-16 15:13:18 +04:00
|
|
|
qemu_log("Read SPR %d %03x => " TARGET_FMT_lx "\n", sprn, sprn,
|
|
|
|
env->spr[sprn]);
|
2007-04-16 11:10:48 +04:00
|
|
|
}
|
|
|
|
|
2012-05-30 08:23:21 +04:00
|
|
|
void helper_store_dump_spr(uint32_t sprn)
|
2007-04-16 11:10:48 +04:00
|
|
|
{
|
2009-08-16 15:13:18 +04:00
|
|
|
qemu_log("Write SPR %d %03x <= " TARGET_FMT_lx "\n", sprn, sprn,
|
|
|
|
env->spr[sprn]);
|
2008-12-07 16:40:29 +03:00
|
|
|
}
|
|
|
|
|
2012-05-30 08:23:21 +04:00
|
|
|
target_ulong helper_load_tbl(void)
|
2008-12-07 16:40:29 +03:00
|
|
|
{
|
2009-12-21 14:24:17 +03:00
|
|
|
return (target_ulong)cpu_ppc_load_tbl(env);
|
2008-12-07 16:40:29 +03:00
|
|
|
}
|
|
|
|
|
2012-05-30 08:23:21 +04:00
|
|
|
target_ulong helper_load_tbu(void)
|
2008-12-07 16:40:29 +03:00
|
|
|
{
|
|
|
|
return cpu_ppc_load_tbu(env);
|
|
|
|
}
|
|
|
|
|
2012-05-30 08:23:21 +04:00
|
|
|
target_ulong helper_load_atbl(void)
|
2008-12-07 16:40:29 +03:00
|
|
|
{
|
2009-12-21 15:52:08 +03:00
|
|
|
return (target_ulong)cpu_ppc_load_atbl(env);
|
2008-12-07 16:40:29 +03:00
|
|
|
}
|
|
|
|
|
2012-05-30 08:23:21 +04:00
|
|
|
target_ulong helper_load_atbu(void)
|
2008-12-07 16:40:29 +03:00
|
|
|
{
|
|
|
|
return cpu_ppc_load_atbu(env);
|
|
|
|
}
|
|
|
|
|
2011-04-01 08:15:12 +04:00
|
|
|
#if defined(TARGET_PPC64) && !defined(CONFIG_USER_ONLY)
|
2012-05-30 08:23:21 +04:00
|
|
|
target_ulong helper_load_purr(void)
|
2011-04-01 08:15:12 +04:00
|
|
|
{
|
|
|
|
return (target_ulong)cpu_ppc_load_purr(env);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-05-30 08:23:21 +04:00
|
|
|
target_ulong helper_load_601_rtcl(void)
|
2008-12-07 16:40:29 +03:00
|
|
|
{
|
|
|
|
return cpu_ppc601_load_rtcl(env);
|
|
|
|
}
|
|
|
|
|
2012-05-30 08:23:21 +04:00
|
|
|
target_ulong helper_load_601_rtcu(void)
|
2008-12-07 16:40:29 +03:00
|
|
|
{
|
|
|
|
return cpu_ppc601_load_rtcu(env);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2012-05-30 08:23:21 +04:00
|
|
|
#if defined(TARGET_PPC64)
|
|
|
|
void helper_store_asr(target_ulong val)
|
2008-12-07 16:40:29 +03:00
|
|
|
{
|
|
|
|
ppc_store_asr(env, val);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-05-30 08:23:21 +04:00
|
|
|
void helper_store_sdr1(target_ulong val)
|
2008-12-07 16:40:29 +03:00
|
|
|
{
|
|
|
|
ppc_store_sdr1(env, val);
|
|
|
|
}
|
|
|
|
|
2012-05-30 08:23:21 +04:00
|
|
|
void helper_store_tbl(target_ulong val)
|
2008-12-07 16:40:29 +03:00
|
|
|
{
|
|
|
|
cpu_ppc_store_tbl(env, val);
|
|
|
|
}
|
|
|
|
|
2012-05-30 08:23:21 +04:00
|
|
|
void helper_store_tbu(target_ulong val)
|
2008-12-07 16:40:29 +03:00
|
|
|
{
|
|
|
|
cpu_ppc_store_tbu(env, val);
|
|
|
|
}
|
|
|
|
|
2012-05-30 08:23:21 +04:00
|
|
|
void helper_store_atbl(target_ulong val)
|
2008-12-07 16:40:29 +03:00
|
|
|
{
|
|
|
|
cpu_ppc_store_atbl(env, val);
|
|
|
|
}
|
|
|
|
|
2012-05-30 08:23:21 +04:00
|
|
|
void helper_store_atbu(target_ulong val)
|
2008-12-07 16:40:29 +03:00
|
|
|
{
|
|
|
|
cpu_ppc_store_atbu(env, val);
|
|
|
|
}
|
|
|
|
|
2012-05-30 08:23:21 +04:00
|
|
|
void helper_store_601_rtcl(target_ulong val)
|
2008-12-07 16:40:29 +03:00
|
|
|
{
|
|
|
|
cpu_ppc601_store_rtcl(env, val);
|
|
|
|
}
|
|
|
|
|
2012-05-30 08:23:21 +04:00
|
|
|
void helper_store_601_rtcu(target_ulong val)
|
2008-12-07 16:40:29 +03:00
|
|
|
{
|
|
|
|
cpu_ppc601_store_rtcu(env, val);
|
|
|
|
}
|
|
|
|
|
2012-05-30 08:23:21 +04:00
|
|
|
target_ulong helper_load_decr(void)
|
2008-12-07 16:40:29 +03:00
|
|
|
{
|
|
|
|
return cpu_ppc_load_decr(env);
|
|
|
|
}
|
|
|
|
|
2012-05-30 08:23:21 +04:00
|
|
|
void helper_store_decr(target_ulong val)
|
2008-12-07 16:40:29 +03:00
|
|
|
{
|
|
|
|
cpu_ppc_store_decr(env, val);
|
|
|
|
}
|
|
|
|
|
2012-05-30 08:23:21 +04:00
|
|
|
void helper_store_hid0_601(target_ulong val)
|
2008-12-07 16:40:29 +03:00
|
|
|
{
|
|
|
|
target_ulong hid0;
|
|
|
|
|
|
|
|
hid0 = env->spr[SPR_HID0];
|
|
|
|
if ((val ^ hid0) & 0x00000008) {
|
|
|
|
/* Change current endianness */
|
|
|
|
env->hflags &= ~(1 << MSR_LE);
|
|
|
|
env->hflags_nmsr &= ~(1 << MSR_LE);
|
|
|
|
env->hflags_nmsr |= (1 << MSR_LE) & (((val >> 3) & 1) << MSR_LE);
|
|
|
|
env->hflags |= env->hflags_nmsr;
|
2009-08-16 15:13:18 +04:00
|
|
|
qemu_log("%s: set endianness to %c => " TARGET_FMT_lx "\n", __func__,
|
|
|
|
val & 0x8 ? 'l' : 'b', env->hflags);
|
2007-04-16 11:10:48 +04:00
|
|
|
}
|
2008-12-07 16:40:29 +03:00
|
|
|
env->spr[SPR_HID0] = (uint32_t)val;
|
2007-04-16 11:10:48 +04:00
|
|
|
}
|
|
|
|
|
2012-05-30 08:23:21 +04:00
|
|
|
void helper_store_403_pbr(uint32_t num, target_ulong value)
|
2008-12-07 16:40:29 +03:00
|
|
|
{
|
|
|
|
if (likely(env->pb[num] != value)) {
|
|
|
|
env->pb[num] = value;
|
|
|
|
/* Should be optimized */
|
|
|
|
tlb_flush(env, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-30 08:23:21 +04:00
|
|
|
target_ulong helper_load_40x_pit(void)
|
2008-12-07 16:40:29 +03:00
|
|
|
{
|
|
|
|
return load_40x_pit(env);
|
|
|
|
}
|
|
|
|
|
2012-05-30 08:23:21 +04:00
|
|
|
void helper_store_40x_pit(target_ulong val)
|
2008-12-07 16:40:29 +03:00
|
|
|
{
|
|
|
|
store_40x_pit(env, val);
|
|
|
|
}
|
|
|
|
|
2012-05-30 08:23:21 +04:00
|
|
|
void helper_store_40x_dbcr0(target_ulong val)
|
2008-12-07 16:40:29 +03:00
|
|
|
{
|
|
|
|
store_40x_dbcr0(env, val);
|
|
|
|
}
|
|
|
|
|
2012-05-30 08:23:21 +04:00
|
|
|
void helper_store_40x_sler(target_ulong val)
|
2008-12-07 16:40:29 +03:00
|
|
|
{
|
|
|
|
store_40x_sler(env, val);
|
|
|
|
}
|
|
|
|
|
2012-05-30 08:23:21 +04:00
|
|
|
void helper_store_booke_tcr(target_ulong val)
|
2008-12-07 16:40:29 +03:00
|
|
|
{
|
|
|
|
store_booke_tcr(env, val);
|
|
|
|
}
|
|
|
|
|
2012-05-30 08:23:21 +04:00
|
|
|
void helper_store_booke_tsr(target_ulong val)
|
2008-12-07 16:40:29 +03:00
|
|
|
{
|
|
|
|
store_booke_tsr(env, val);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-11-30 19:23:56 +03:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* Memory load and stores */
|
|
|
|
|
2009-08-16 13:06:54 +04:00
|
|
|
static inline target_ulong addr_add(target_ulong addr, target_long arg)
|
2008-11-30 19:23:56 +03:00
|
|
|
{
|
|
|
|
#if defined(TARGET_PPC64)
|
2012-05-30 08:23:21 +04:00
|
|
|
if (!msr_sf) {
|
|
|
|
return (uint32_t)(addr + arg);
|
|
|
|
} else
|
2008-11-30 19:23:56 +03:00
|
|
|
#endif
|
2012-05-30 08:23:21 +04:00
|
|
|
{
|
|
|
|
return addr + arg;
|
|
|
|
}
|
2008-11-30 19:23:56 +03:00
|
|
|
}
|
|
|
|
|
2012-05-30 08:23:21 +04:00
|
|
|
void helper_lmw(target_ulong addr, uint32_t reg)
|
2008-11-30 19:23:56 +03:00
|
|
|
{
|
2008-12-08 21:11:21 +03:00
|
|
|
for (; reg < 32; reg++) {
|
2012-05-30 08:23:21 +04:00
|
|
|
if (msr_le) {
|
2008-12-08 21:11:21 +03:00
|
|
|
env->gpr[reg] = bswap32(ldl(addr));
|
2012-05-30 08:23:21 +04:00
|
|
|
} else {
|
2008-12-08 21:11:21 +03:00
|
|
|
env->gpr[reg] = ldl(addr);
|
2012-05-30 08:23:21 +04:00
|
|
|
}
|
|
|
|
addr = addr_add(addr, 4);
|
2008-11-30 19:23:56 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-30 08:23:21 +04:00
|
|
|
void helper_stmw(target_ulong addr, uint32_t reg)
|
2008-11-30 19:23:56 +03:00
|
|
|
{
|
2008-12-08 21:11:21 +03:00
|
|
|
for (; reg < 32; reg++) {
|
2012-05-30 08:23:21 +04:00
|
|
|
if (msr_le) {
|
2008-12-08 21:11:21 +03:00
|
|
|
stl(addr, bswap32((uint32_t)env->gpr[reg]));
|
2012-05-30 08:23:21 +04:00
|
|
|
} else {
|
2008-12-08 21:11:21 +03:00
|
|
|
stl(addr, (uint32_t)env->gpr[reg]);
|
2012-05-30 08:23:21 +04:00
|
|
|
}
|
|
|
|
addr = addr_add(addr, 4);
|
2008-11-30 19:23:56 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-30 19:24:21 +03:00
|
|
|
void helper_lsw(target_ulong addr, uint32_t nb, uint32_t reg)
|
|
|
|
{
|
|
|
|
int sh;
|
2012-05-30 08:23:21 +04:00
|
|
|
|
2008-12-08 21:11:21 +03:00
|
|
|
for (; nb > 3; nb -= 4) {
|
|
|
|
env->gpr[reg] = ldl(addr);
|
2008-11-30 19:24:21 +03:00
|
|
|
reg = (reg + 1) % 32;
|
2012-05-30 08:23:21 +04:00
|
|
|
addr = addr_add(addr, 4);
|
2008-11-30 19:24:21 +03:00
|
|
|
}
|
|
|
|
if (unlikely(nb > 0)) {
|
|
|
|
env->gpr[reg] = 0;
|
2008-12-08 21:11:21 +03:00
|
|
|
for (sh = 24; nb > 0; nb--, sh -= 8) {
|
|
|
|
env->gpr[reg] |= ldub(addr) << sh;
|
2012-05-30 08:23:21 +04:00
|
|
|
addr = addr_add(addr, 1);
|
2008-11-30 19:24:21 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* PPC32 specification says we must generate an exception if
|
|
|
|
* rA is in the range of registers to be loaded.
|
|
|
|
* In an other hand, IBM says this is valid, but rA won't be loaded.
|
|
|
|
* For now, I'll follow the spec...
|
|
|
|
*/
|
|
|
|
void helper_lswx(target_ulong addr, uint32_t reg, uint32_t ra, uint32_t rb)
|
|
|
|
{
|
|
|
|
if (likely(xer_bc != 0)) {
|
|
|
|
if (unlikely((ra != 0 && reg < ra && (reg + xer_bc) > ra) ||
|
|
|
|
(reg < rb && (reg + xer_bc) > rb))) {
|
2012-05-30 08:23:23 +04:00
|
|
|
helper_raise_exception_err(env, POWERPC_EXCP_PROGRAM,
|
2008-12-12 01:42:14 +03:00
|
|
|
POWERPC_EXCP_INVAL |
|
|
|
|
POWERPC_EXCP_INVAL_LSWX);
|
2008-11-30 19:24:21 +03:00
|
|
|
} else {
|
|
|
|
helper_lsw(addr, xer_bc, reg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void helper_stsw(target_ulong addr, uint32_t nb, uint32_t reg)
|
|
|
|
{
|
|
|
|
int sh;
|
2012-05-30 08:23:21 +04:00
|
|
|
|
2008-12-08 21:11:21 +03:00
|
|
|
for (; nb > 3; nb -= 4) {
|
|
|
|
stl(addr, env->gpr[reg]);
|
2008-11-30 19:24:21 +03:00
|
|
|
reg = (reg + 1) % 32;
|
2012-05-30 08:23:21 +04:00
|
|
|
addr = addr_add(addr, 4);
|
2008-11-30 19:24:21 +03:00
|
|
|
}
|
|
|
|
if (unlikely(nb > 0)) {
|
2008-12-29 12:46:58 +03:00
|
|
|
for (sh = 24; nb > 0; nb--, sh -= 8) {
|
2008-12-08 21:11:21 +03:00
|
|
|
stb(addr, (env->gpr[reg] >> sh) & 0xFF);
|
2008-12-29 12:46:58 +03:00
|
|
|
addr = addr_add(addr, 1);
|
|
|
|
}
|
2008-11-30 19:24:21 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-30 19:24:05 +03:00
|
|
|
static void do_dcbz(target_ulong addr, int dcache_line_size)
|
|
|
|
{
|
|
|
|
int i;
|
2012-05-30 08:23:21 +04:00
|
|
|
|
|
|
|
addr &= ~(dcache_line_size - 1);
|
|
|
|
for (i = 0; i < dcache_line_size; i += 4) {
|
|
|
|
stl(addr + i, 0);
|
2008-11-30 19:24:05 +03:00
|
|
|
}
|
2012-05-30 08:23:21 +04:00
|
|
|
if (env->reserve_addr == addr) {
|
2009-08-03 19:43:25 +04:00
|
|
|
env->reserve_addr = (target_ulong)-1ULL;
|
2012-05-30 08:23:21 +04:00
|
|
|
}
|
2008-11-30 19:24:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void helper_dcbz(target_ulong addr)
|
|
|
|
{
|
|
|
|
do_dcbz(addr, env->dcache_line_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
void helper_dcbz_970(target_ulong addr)
|
|
|
|
{
|
2012-05-30 08:23:21 +04:00
|
|
|
if (((env->spr[SPR_970_HID5] >> 7) & 0x3) == 1) {
|
2008-11-30 19:24:05 +03:00
|
|
|
do_dcbz(addr, 32);
|
2012-05-30 08:23:21 +04:00
|
|
|
} else {
|
2008-11-30 19:24:05 +03:00
|
|
|
do_dcbz(addr, env->dcache_line_size);
|
2012-05-30 08:23:21 +04:00
|
|
|
}
|
2008-11-30 19:24:05 +03:00
|
|
|
}
|
|
|
|
|
2008-11-30 19:24:13 +03:00
|
|
|
void helper_icbi(target_ulong addr)
|
|
|
|
{
|
2008-12-08 21:11:21 +03:00
|
|
|
addr &= ~(env->dcache_line_size - 1);
|
2008-11-30 19:24:13 +03:00
|
|
|
/* Invalidate one cache line :
|
|
|
|
* PowerPC specification says this is to be treated like a load
|
|
|
|
* (not a fetch) by the MMU. To be sure it will be so,
|
|
|
|
* do the load "by hand".
|
|
|
|
*/
|
2010-10-13 22:38:08 +04:00
|
|
|
ldl(addr);
|
2008-11-30 19:24:13 +03:00
|
|
|
}
|
|
|
|
|
2012-05-30 08:23:21 +04:00
|
|
|
/* XXX: to be tested */
|
|
|
|
target_ulong helper_lscbx(target_ulong addr, uint32_t reg, uint32_t ra,
|
|
|
|
uint32_t rb)
|
2008-11-30 19:24:30 +03:00
|
|
|
{
|
|
|
|
int i, c, d;
|
2012-05-30 08:23:21 +04:00
|
|
|
|
2008-11-30 19:24:30 +03:00
|
|
|
d = 24;
|
|
|
|
for (i = 0; i < xer_bc; i++) {
|
2008-12-08 21:11:21 +03:00
|
|
|
c = ldub(addr);
|
2012-05-30 08:23:21 +04:00
|
|
|
addr = addr_add(addr, 1);
|
2008-11-30 19:24:30 +03:00
|
|
|
/* ra (if not 0) and rb are never modified */
|
|
|
|
if (likely(reg != rb && (ra == 0 || reg != ra))) {
|
|
|
|
env->gpr[reg] = (env->gpr[reg] & ~(0xFF << d)) | (c << d);
|
|
|
|
}
|
2012-05-30 08:23:21 +04:00
|
|
|
if (unlikely(c == xer_cmp)) {
|
2008-11-30 19:24:30 +03:00
|
|
|
break;
|
2012-05-30 08:23:21 +04:00
|
|
|
}
|
2008-11-30 19:24:30 +03:00
|
|
|
if (likely(d != 0)) {
|
|
|
|
d -= 8;
|
|
|
|
} else {
|
|
|
|
d = 24;
|
|
|
|
reg++;
|
|
|
|
reg = reg & 0x1F;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2005-07-05 02:17:05 +04:00
|
|
|
/*****************************************************************************/
|
2007-03-07 11:32:30 +03:00
|
|
|
/* PowerPC 601 specific instructions (POWER bridge) */
|
2004-01-05 01:58:38 +03:00
|
|
|
|
2012-05-30 08:23:21 +04:00
|
|
|
target_ulong helper_clcs(uint32_t arg)
|
2004-01-05 01:58:38 +03:00
|
|
|
{
|
2008-12-06 15:19:14 +03:00
|
|
|
switch (arg) {
|
2007-03-07 11:32:30 +03:00
|
|
|
case 0x0CUL:
|
|
|
|
/* Instruction cache line size */
|
2008-12-06 15:19:14 +03:00
|
|
|
return env->icache_line_size;
|
2007-03-07 11:32:30 +03:00
|
|
|
break;
|
|
|
|
case 0x0DUL:
|
|
|
|
/* Data cache line size */
|
2008-12-06 15:19:14 +03:00
|
|
|
return env->dcache_line_size;
|
2007-03-07 11:32:30 +03:00
|
|
|
break;
|
|
|
|
case 0x0EUL:
|
|
|
|
/* Minimum cache line size */
|
2008-12-06 15:19:14 +03:00
|
|
|
return (env->icache_line_size < env->dcache_line_size) ?
|
2012-05-30 08:23:21 +04:00
|
|
|
env->icache_line_size : env->dcache_line_size;
|
2007-03-07 11:32:30 +03:00
|
|
|
break;
|
|
|
|
case 0x0FUL:
|
|
|
|
/* Maximum cache line size */
|
2008-12-06 15:19:14 +03:00
|
|
|
return (env->icache_line_size > env->dcache_line_size) ?
|
2012-05-30 08:23:21 +04:00
|
|
|
env->icache_line_size : env->dcache_line_size;
|
2007-03-07 11:32:30 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* Undefined */
|
2008-12-06 15:19:14 +03:00
|
|
|
return 0;
|
2007-03-07 11:32:30 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/* Embedded PowerPC specific helpers */
|
|
|
|
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 03:54:22 +04:00
|
|
|
/* XXX: to be improved to check access rights when in user-mode */
|
2012-05-30 08:23:21 +04:00
|
|
|
target_ulong helper_load_dcr(target_ulong dcrn)
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 03:54:22 +04:00
|
|
|
{
|
2009-12-21 16:02:39 +03:00
|
|
|
uint32_t val = 0;
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 03:54:22 +04:00
|
|
|
|
|
|
|
if (unlikely(env->dcr_env == NULL)) {
|
2009-01-16 01:34:14 +03:00
|
|
|
qemu_log("No DCR environment\n");
|
2012-05-30 08:23:23 +04:00
|
|
|
helper_raise_exception_err(env, POWERPC_EXCP_PROGRAM,
|
2012-05-30 08:23:21 +04:00
|
|
|
POWERPC_EXCP_INVAL |
|
|
|
|
POWERPC_EXCP_INVAL_INVAL);
|
|
|
|
} else if (unlikely(ppc_dcr_read(env->dcr_env,
|
|
|
|
(uint32_t)dcrn, &val) != 0)) {
|
2010-02-06 18:59:11 +03:00
|
|
|
qemu_log("DCR read error %d %03x\n", (uint32_t)dcrn, (uint32_t)dcrn);
|
2012-05-30 08:23:23 +04:00
|
|
|
helper_raise_exception_err(env, POWERPC_EXCP_PROGRAM,
|
2008-12-12 01:42:14 +03:00
|
|
|
POWERPC_EXCP_INVAL | POWERPC_EXCP_PRIV_REG);
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 03:54:22 +04:00
|
|
|
}
|
2008-12-06 19:37:18 +03:00
|
|
|
return val;
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 03:54:22 +04:00
|
|
|
}
|
|
|
|
|
2012-05-30 08:23:21 +04:00
|
|
|
void helper_store_dcr(target_ulong dcrn, target_ulong val)
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 03:54:22 +04:00
|
|
|
{
|
|
|
|
if (unlikely(env->dcr_env == NULL)) {
|
2009-01-16 01:34:14 +03:00
|
|
|
qemu_log("No DCR environment\n");
|
2012-05-30 08:23:23 +04:00
|
|
|
helper_raise_exception_err(env, POWERPC_EXCP_PROGRAM,
|
2012-05-30 08:23:21 +04:00
|
|
|
POWERPC_EXCP_INVAL |
|
|
|
|
POWERPC_EXCP_INVAL_INVAL);
|
|
|
|
} else if (unlikely(ppc_dcr_write(env->dcr_env, (uint32_t)dcrn,
|
|
|
|
(uint32_t)val) != 0)) {
|
2010-02-06 18:59:11 +03:00
|
|
|
qemu_log("DCR write error %d %03x\n", (uint32_t)dcrn, (uint32_t)dcrn);
|
2012-05-30 08:23:23 +04:00
|
|
|
helper_raise_exception_err(env, POWERPC_EXCP_PROGRAM,
|
2008-12-12 01:42:14 +03:00
|
|
|
POWERPC_EXCP_INVAL | POWERPC_EXCP_PRIV_REG);
|
Great rework and cleanups to ease PowerPC implementations definitions.
* cleanup cpu.h, removing definitions used only in translate.c/translate_init.c
* add new flags to define instructions sets more precisely
* various changes in MMU models definitions
* add definitions for PowerPC 440/460 support (insns and SPRs).
* add definitions for PowerPC 401/403 and 620 input pins model
* Fix definitions for most PowerPC 401, 403, 405, 440, 601, 602, 603 and 7x0
* Preliminary support for PowerPC 74xx (aka G4) without altivec.
* Code provision for other PowerPC support (7x5, 970, ...).
* New SPR and PVR defined, from PowerPC 2.04 specification and other sources
* Misc code bugs, error messages and styles fixes.
* Update status files for PowerPC cores support.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3244 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27 03:54:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-03 16:31:19 +03:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* Altivec extension helpers */
|
2009-07-27 18:13:06 +04:00
|
|
|
#if defined(HOST_WORDS_BIGENDIAN)
|
2009-01-03 16:31:19 +03:00
|
|
|
#define HI_IDX 0
|
|
|
|
#define LO_IDX 1
|
|
|
|
#else
|
|
|
|
#define HI_IDX 1
|
|
|
|
#define LO_IDX 0
|
|
|
|
#endif
|
|
|
|
|
2009-01-05 01:13:10 +03:00
|
|
|
#define LVE(name, access, swap, element) \
|
2012-05-30 08:23:21 +04:00
|
|
|
void helper_##name(ppc_avr_t *r, target_ulong addr) \
|
2009-01-05 01:13:10 +03:00
|
|
|
{ \
|
|
|
|
size_t n_elems = ARRAY_SIZE(r->element); \
|
2012-05-30 08:23:21 +04:00
|
|
|
int adjust = HI_IDX*(n_elems - 1); \
|
2009-01-05 01:13:10 +03:00
|
|
|
int sh = sizeof(r->element[0]) >> 1; \
|
|
|
|
int index = (addr & 0xf) >> sh; \
|
2012-05-30 08:23:21 +04:00
|
|
|
\
|
|
|
|
if (msr_le) { \
|
|
|
|
r->element[LO_IDX ? index : (adjust - index)] = \
|
|
|
|
swap(access(addr)); \
|
|
|
|
} else { \
|
|
|
|
r->element[LO_IDX ? index : (adjust - index)] = \
|
|
|
|
access(addr); \
|
|
|
|
} \
|
2009-01-05 01:13:10 +03:00
|
|
|
}
|
|
|
|
#define I(x) (x)
|
|
|
|
LVE(lvebx, ldub, I, u8)
|
|
|
|
LVE(lvehx, lduw, bswap16, u16)
|
|
|
|
LVE(lvewx, ldl, bswap32, u32)
|
|
|
|
#undef I
|
|
|
|
#undef LVE
|
|
|
|
|
2012-05-30 08:23:21 +04:00
|
|
|
#define STVE(name, access, swap, element) \
|
|
|
|
void helper_##name(ppc_avr_t *r, target_ulong addr) \
|
|
|
|
{ \
|
|
|
|
size_t n_elems = ARRAY_SIZE(r->element); \
|
|
|
|
int adjust = HI_IDX * (n_elems - 1); \
|
|
|
|
int sh = sizeof(r->element[0]) >> 1; \
|
|
|
|
int index = (addr & 0xf) >> sh; \
|
|
|
|
\
|
|
|
|
if (msr_le) { \
|
2009-01-05 01:13:10 +03:00
|
|
|
access(addr, swap(r->element[LO_IDX ? index : (adjust - index)])); \
|
|
|
|
} else { \
|
|
|
|
access(addr, r->element[LO_IDX ? index : (adjust - index)]); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
#define I(x) (x)
|
|
|
|
STVE(stvebx, stb, I, u8)
|
|
|
|
STVE(stvehx, stw, bswap16, u16)
|
|
|
|
STVE(stvewx, stl, bswap32, u32)
|
|
|
|
#undef I
|
|
|
|
#undef LVE
|
|
|
|
|
2009-01-03 16:31:19 +03:00
|
|
|
#undef HI_IDX
|
|
|
|
#undef LO_IDX
|
|
|
|
|
2005-07-05 02:17:05 +04:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* Softmmu support */
|
2012-05-30 08:23:21 +04:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2005-07-05 02:17:05 +04:00
|
|
|
|
|
|
|
#define MMUSUFFIX _mmu
|
|
|
|
|
|
|
|
#define SHIFT 0
|
|
|
|
#include "softmmu_template.h"
|
|
|
|
|
|
|
|
#define SHIFT 1
|
|
|
|
#include "softmmu_template.h"
|
|
|
|
|
|
|
|
#define SHIFT 2
|
|
|
|
#include "softmmu_template.h"
|
|
|
|
|
|
|
|
#define SHIFT 3
|
|
|
|
#include "softmmu_template.h"
|
|
|
|
|
|
|
|
/* 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 */
|
2012-03-14 04:38:22 +04:00
|
|
|
void tlb_fill(CPUPPCState *env1, target_ulong addr, int is_write, int mmu_idx,
|
2012-04-09 18:20:20 +04:00
|
|
|
uintptr_t retaddr)
|
2005-07-05 02:17:05 +04:00
|
|
|
{
|
|
|
|
TranslationBlock *tb;
|
2012-03-14 04:38:22 +04:00
|
|
|
CPUPPCState *saved_env;
|
2005-07-05 02:17:05 +04:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
saved_env = env;
|
2011-07-05 00:57:05 +04:00
|
|
|
env = env1;
|
2011-08-01 20:12:17 +04:00
|
|
|
ret = cpu_ppc_handle_mmu_fault(env, addr, is_write, mmu_idx);
|
2007-03-07 11:32:30 +03:00
|
|
|
if (unlikely(ret != 0)) {
|
2005-07-05 02:17:05 +04:00
|
|
|
if (likely(retaddr)) {
|
|
|
|
/* now we have a real cpu fault */
|
2012-04-09 18:20:20 +04:00
|
|
|
tb = tb_find_pc(retaddr);
|
2005-07-05 02:17:05 +04:00
|
|
|
if (likely(tb)) {
|
|
|
|
/* the PC is inside the translated code. It means that we have
|
|
|
|
a virtual CPU fault */
|
2012-04-09 18:20:20 +04:00
|
|
|
cpu_restore_state(tb, env, retaddr);
|
2007-03-07 11:32:30 +03:00
|
|
|
}
|
2005-07-05 02:17:05 +04:00
|
|
|
}
|
2012-05-30 08:23:23 +04:00
|
|
|
helper_raise_exception_err(env, env->exception_index, env->error_code);
|
2005-07-05 02:17:05 +04:00
|
|
|
}
|
|
|
|
env = saved_env;
|
2004-01-05 01:58:38 +03:00
|
|
|
}
|
2007-03-07 11:32:30 +03:00
|
|
|
#endif /* !CONFIG_USER_ONLY */
|