16de673d4SBlue Swirl /* 26de673d4SBlue Swirl * PowerPC emulation helpers for QEMU. 36de673d4SBlue Swirl * 46de673d4SBlue Swirl * Copyright (c) 2003-2007 Jocelyn Mayer 56de673d4SBlue Swirl * 66de673d4SBlue Swirl * This library is free software; you can redistribute it and/or 76de673d4SBlue Swirl * modify it under the terms of the GNU Lesser General Public 86de673d4SBlue Swirl * License as published by the Free Software Foundation; either 96de673d4SBlue Swirl * version 2 of the License, or (at your option) any later version. 106de673d4SBlue Swirl * 116de673d4SBlue Swirl * This library is distributed in the hope that it will be useful, 126de673d4SBlue Swirl * but WITHOUT ANY WARRANTY; without even the implied warranty of 136de673d4SBlue Swirl * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 146de673d4SBlue Swirl * Lesser General Public License for more details. 156de673d4SBlue Swirl * 166de673d4SBlue Swirl * You should have received a copy of the GNU Lesser General Public 176de673d4SBlue Swirl * License along with this library; if not, see <http://www.gnu.org/licenses/>. 186de673d4SBlue Swirl */ 190d75590dSPeter Maydell #include "qemu/osdep.h" 206de673d4SBlue Swirl #include "cpu.h" 212ef6175aSRichard Henderson #include "exec/helper-proto.h" 22a13f0a9bSBenjamin Herrenschmidt #include "exec/exec-all.h" 2363c91552SPaolo Bonzini #include "qemu/log.h" 246de673d4SBlue Swirl 256de673d4SBlue Swirl /*****************************************************************************/ 266de673d4SBlue Swirl /* SPR accesses */ 276de673d4SBlue Swirl 28d0f1562dSBlue Swirl target_ulong helper_load_tbl(CPUPPCState *env) 296de673d4SBlue Swirl { 306de673d4SBlue Swirl return (target_ulong)cpu_ppc_load_tbl(env); 316de673d4SBlue Swirl } 326de673d4SBlue Swirl 33d0f1562dSBlue Swirl target_ulong helper_load_tbu(CPUPPCState *env) 346de673d4SBlue Swirl { 356de673d4SBlue Swirl return cpu_ppc_load_tbu(env); 366de673d4SBlue Swirl } 376de673d4SBlue Swirl 38d0f1562dSBlue Swirl target_ulong helper_load_atbl(CPUPPCState *env) 396de673d4SBlue Swirl { 406de673d4SBlue Swirl return (target_ulong)cpu_ppc_load_atbl(env); 416de673d4SBlue Swirl } 426de673d4SBlue Swirl 43d0f1562dSBlue Swirl target_ulong helper_load_atbu(CPUPPCState *env) 446de673d4SBlue Swirl { 456de673d4SBlue Swirl return cpu_ppc_load_atbu(env); 466de673d4SBlue Swirl } 476de673d4SBlue Swirl 485d62725bSSuraj Jitindar Singh target_ulong helper_load_vtb(CPUPPCState *env) 495d62725bSSuraj Jitindar Singh { 505d62725bSSuraj Jitindar Singh return cpu_ppc_load_vtb(env); 515d62725bSSuraj Jitindar Singh } 525d62725bSSuraj Jitindar Singh 536de673d4SBlue Swirl #if defined(TARGET_PPC64) && !defined(CONFIG_USER_ONLY) 54d0f1562dSBlue Swirl target_ulong helper_load_purr(CPUPPCState *env) 556de673d4SBlue Swirl { 566de673d4SBlue Swirl return (target_ulong)cpu_ppc_load_purr(env); 576de673d4SBlue Swirl } 585cc7e69fSSuraj Jitindar Singh 595cc7e69fSSuraj Jitindar Singh void helper_store_purr(CPUPPCState *env, target_ulong val) 605cc7e69fSSuraj Jitindar Singh { 615cc7e69fSSuraj Jitindar Singh cpu_ppc_store_purr(env, val); 625cc7e69fSSuraj Jitindar Singh } 636de673d4SBlue Swirl #endif 646de673d4SBlue Swirl 65d0f1562dSBlue Swirl target_ulong helper_load_601_rtcl(CPUPPCState *env) 666de673d4SBlue Swirl { 676de673d4SBlue Swirl return cpu_ppc601_load_rtcl(env); 686de673d4SBlue Swirl } 696de673d4SBlue Swirl 70d0f1562dSBlue Swirl target_ulong helper_load_601_rtcu(CPUPPCState *env) 716de673d4SBlue Swirl { 726de673d4SBlue Swirl return cpu_ppc601_load_rtcu(env); 736de673d4SBlue Swirl } 746de673d4SBlue Swirl 756de673d4SBlue Swirl #if !defined(CONFIG_USER_ONLY) 76d0f1562dSBlue Swirl void helper_store_tbl(CPUPPCState *env, target_ulong val) 776de673d4SBlue Swirl { 786de673d4SBlue Swirl cpu_ppc_store_tbl(env, val); 796de673d4SBlue Swirl } 806de673d4SBlue Swirl 81d0f1562dSBlue Swirl void helper_store_tbu(CPUPPCState *env, target_ulong val) 826de673d4SBlue Swirl { 836de673d4SBlue Swirl cpu_ppc_store_tbu(env, val); 846de673d4SBlue Swirl } 856de673d4SBlue Swirl 86d0f1562dSBlue Swirl void helper_store_atbl(CPUPPCState *env, target_ulong val) 876de673d4SBlue Swirl { 886de673d4SBlue Swirl cpu_ppc_store_atbl(env, val); 896de673d4SBlue Swirl } 906de673d4SBlue Swirl 91d0f1562dSBlue Swirl void helper_store_atbu(CPUPPCState *env, target_ulong val) 926de673d4SBlue Swirl { 936de673d4SBlue Swirl cpu_ppc_store_atbu(env, val); 946de673d4SBlue Swirl } 956de673d4SBlue Swirl 96d0f1562dSBlue Swirl void helper_store_601_rtcl(CPUPPCState *env, target_ulong val) 976de673d4SBlue Swirl { 986de673d4SBlue Swirl cpu_ppc601_store_rtcl(env, val); 996de673d4SBlue Swirl } 1006de673d4SBlue Swirl 101d0f1562dSBlue Swirl void helper_store_601_rtcu(CPUPPCState *env, target_ulong val) 1026de673d4SBlue Swirl { 1036de673d4SBlue Swirl cpu_ppc601_store_rtcu(env, val); 1046de673d4SBlue Swirl } 1056de673d4SBlue Swirl 106d0f1562dSBlue Swirl target_ulong helper_load_decr(CPUPPCState *env) 1076de673d4SBlue Swirl { 1086de673d4SBlue Swirl return cpu_ppc_load_decr(env); 1096de673d4SBlue Swirl } 1106de673d4SBlue Swirl 111d0f1562dSBlue Swirl void helper_store_decr(CPUPPCState *env, target_ulong val) 1126de673d4SBlue Swirl { 1136de673d4SBlue Swirl cpu_ppc_store_decr(env, val); 1146de673d4SBlue Swirl } 1156de673d4SBlue Swirl 1164b236b62SBenjamin Herrenschmidt target_ulong helper_load_hdecr(CPUPPCState *env) 1174b236b62SBenjamin Herrenschmidt { 1184b236b62SBenjamin Herrenschmidt return cpu_ppc_load_hdecr(env); 1194b236b62SBenjamin Herrenschmidt } 1204b236b62SBenjamin Herrenschmidt 1214b236b62SBenjamin Herrenschmidt void helper_store_hdecr(CPUPPCState *env, target_ulong val) 1224b236b62SBenjamin Herrenschmidt { 1234b236b62SBenjamin Herrenschmidt cpu_ppc_store_hdecr(env, val); 1244b236b62SBenjamin Herrenschmidt } 1254b236b62SBenjamin Herrenschmidt 1265d62725bSSuraj Jitindar Singh void helper_store_vtb(CPUPPCState *env, target_ulong val) 1275d62725bSSuraj Jitindar Singh { 1285d62725bSSuraj Jitindar Singh cpu_ppc_store_vtb(env, val); 1295d62725bSSuraj Jitindar Singh } 1305d62725bSSuraj Jitindar Singh 131*f0ec31b1SSuraj Jitindar Singh void helper_store_tbu40(CPUPPCState *env, target_ulong val) 132*f0ec31b1SSuraj Jitindar Singh { 133*f0ec31b1SSuraj Jitindar Singh cpu_ppc_store_tbu40(env, val); 134*f0ec31b1SSuraj Jitindar Singh } 135*f0ec31b1SSuraj Jitindar Singh 136d0f1562dSBlue Swirl target_ulong helper_load_40x_pit(CPUPPCState *env) 1376de673d4SBlue Swirl { 1386de673d4SBlue Swirl return load_40x_pit(env); 1396de673d4SBlue Swirl } 1406de673d4SBlue Swirl 141d0f1562dSBlue Swirl void helper_store_40x_pit(CPUPPCState *env, target_ulong val) 1426de673d4SBlue Swirl { 1436de673d4SBlue Swirl store_40x_pit(env, val); 1446de673d4SBlue Swirl } 1456de673d4SBlue Swirl 146d0f1562dSBlue Swirl void helper_store_booke_tcr(CPUPPCState *env, target_ulong val) 1476de673d4SBlue Swirl { 1486de673d4SBlue Swirl store_booke_tcr(env, val); 1496de673d4SBlue Swirl } 1506de673d4SBlue Swirl 151d0f1562dSBlue Swirl void helper_store_booke_tsr(CPUPPCState *env, target_ulong val) 1526de673d4SBlue Swirl { 1536de673d4SBlue Swirl store_booke_tsr(env, val); 1546de673d4SBlue Swirl } 1556de673d4SBlue Swirl #endif 1566de673d4SBlue Swirl 1576de673d4SBlue Swirl /*****************************************************************************/ 1586de673d4SBlue Swirl /* Embedded PowerPC specific helpers */ 1596de673d4SBlue Swirl 1606de673d4SBlue Swirl /* XXX: to be improved to check access rights when in user-mode */ 161d0f1562dSBlue Swirl target_ulong helper_load_dcr(CPUPPCState *env, target_ulong dcrn) 1626de673d4SBlue Swirl { 1636de673d4SBlue Swirl uint32_t val = 0; 1646de673d4SBlue Swirl 1656de673d4SBlue Swirl if (unlikely(env->dcr_env == NULL)) { 16648880da6SPaolo Bonzini qemu_log_mask(LOG_GUEST_ERROR, "No DCR environment\n"); 167a13f0a9bSBenjamin Herrenschmidt raise_exception_err_ra(env, POWERPC_EXCP_PROGRAM, 1686de673d4SBlue Swirl POWERPC_EXCP_INVAL | 169a13f0a9bSBenjamin Herrenschmidt POWERPC_EXCP_INVAL_INVAL, GETPC()); 1706de673d4SBlue Swirl } else if (unlikely(ppc_dcr_read(env->dcr_env, 1716de673d4SBlue Swirl (uint32_t)dcrn, &val) != 0)) { 17248880da6SPaolo Bonzini qemu_log_mask(LOG_GUEST_ERROR, "DCR read error %d %03x\n", 17348880da6SPaolo Bonzini (uint32_t)dcrn, (uint32_t)dcrn); 174a13f0a9bSBenjamin Herrenschmidt raise_exception_err_ra(env, POWERPC_EXCP_PROGRAM, 175a13f0a9bSBenjamin Herrenschmidt POWERPC_EXCP_INVAL | 176a13f0a9bSBenjamin Herrenschmidt POWERPC_EXCP_PRIV_REG, GETPC()); 1776de673d4SBlue Swirl } 1786de673d4SBlue Swirl return val; 1796de673d4SBlue Swirl } 1806de673d4SBlue Swirl 181d0f1562dSBlue Swirl void helper_store_dcr(CPUPPCState *env, target_ulong dcrn, target_ulong val) 1826de673d4SBlue Swirl { 1836de673d4SBlue Swirl if (unlikely(env->dcr_env == NULL)) { 18448880da6SPaolo Bonzini qemu_log_mask(LOG_GUEST_ERROR, "No DCR environment\n"); 185a13f0a9bSBenjamin Herrenschmidt raise_exception_err_ra(env, POWERPC_EXCP_PROGRAM, 1866de673d4SBlue Swirl POWERPC_EXCP_INVAL | 187a13f0a9bSBenjamin Herrenschmidt POWERPC_EXCP_INVAL_INVAL, GETPC()); 1886de673d4SBlue Swirl } else if (unlikely(ppc_dcr_write(env->dcr_env, (uint32_t)dcrn, 1896de673d4SBlue Swirl (uint32_t)val) != 0)) { 19048880da6SPaolo Bonzini qemu_log_mask(LOG_GUEST_ERROR, "DCR write error %d %03x\n", 19148880da6SPaolo Bonzini (uint32_t)dcrn, (uint32_t)dcrn); 192a13f0a9bSBenjamin Herrenschmidt raise_exception_err_ra(env, POWERPC_EXCP_PROGRAM, 193a13f0a9bSBenjamin Herrenschmidt POWERPC_EXCP_INVAL | 194a13f0a9bSBenjamin Herrenschmidt POWERPC_EXCP_PRIV_REG, GETPC()); 1956de673d4SBlue Swirl } 1966de673d4SBlue Swirl } 197