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 48*5d62725bSSuraj Jitindar Singh target_ulong helper_load_vtb(CPUPPCState *env) 49*5d62725bSSuraj Jitindar Singh { 50*5d62725bSSuraj Jitindar Singh return cpu_ppc_load_vtb(env); 51*5d62725bSSuraj Jitindar Singh } 52*5d62725bSSuraj 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 } 586de673d4SBlue Swirl #endif 596de673d4SBlue Swirl 60d0f1562dSBlue Swirl target_ulong helper_load_601_rtcl(CPUPPCState *env) 616de673d4SBlue Swirl { 626de673d4SBlue Swirl return cpu_ppc601_load_rtcl(env); 636de673d4SBlue Swirl } 646de673d4SBlue Swirl 65d0f1562dSBlue Swirl target_ulong helper_load_601_rtcu(CPUPPCState *env) 666de673d4SBlue Swirl { 676de673d4SBlue Swirl return cpu_ppc601_load_rtcu(env); 686de673d4SBlue Swirl } 696de673d4SBlue Swirl 706de673d4SBlue Swirl #if !defined(CONFIG_USER_ONLY) 71d0f1562dSBlue Swirl void helper_store_tbl(CPUPPCState *env, target_ulong val) 726de673d4SBlue Swirl { 736de673d4SBlue Swirl cpu_ppc_store_tbl(env, val); 746de673d4SBlue Swirl } 756de673d4SBlue Swirl 76d0f1562dSBlue Swirl void helper_store_tbu(CPUPPCState *env, target_ulong val) 776de673d4SBlue Swirl { 786de673d4SBlue Swirl cpu_ppc_store_tbu(env, val); 796de673d4SBlue Swirl } 806de673d4SBlue Swirl 81d0f1562dSBlue Swirl void helper_store_atbl(CPUPPCState *env, target_ulong val) 826de673d4SBlue Swirl { 836de673d4SBlue Swirl cpu_ppc_store_atbl(env, val); 846de673d4SBlue Swirl } 856de673d4SBlue Swirl 86d0f1562dSBlue Swirl void helper_store_atbu(CPUPPCState *env, target_ulong val) 876de673d4SBlue Swirl { 886de673d4SBlue Swirl cpu_ppc_store_atbu(env, val); 896de673d4SBlue Swirl } 906de673d4SBlue Swirl 91d0f1562dSBlue Swirl void helper_store_601_rtcl(CPUPPCState *env, target_ulong val) 926de673d4SBlue Swirl { 936de673d4SBlue Swirl cpu_ppc601_store_rtcl(env, val); 946de673d4SBlue Swirl } 956de673d4SBlue Swirl 96d0f1562dSBlue Swirl void helper_store_601_rtcu(CPUPPCState *env, target_ulong val) 976de673d4SBlue Swirl { 986de673d4SBlue Swirl cpu_ppc601_store_rtcu(env, val); 996de673d4SBlue Swirl } 1006de673d4SBlue Swirl 101d0f1562dSBlue Swirl target_ulong helper_load_decr(CPUPPCState *env) 1026de673d4SBlue Swirl { 1036de673d4SBlue Swirl return cpu_ppc_load_decr(env); 1046de673d4SBlue Swirl } 1056de673d4SBlue Swirl 106d0f1562dSBlue Swirl void helper_store_decr(CPUPPCState *env, target_ulong val) 1076de673d4SBlue Swirl { 1086de673d4SBlue Swirl cpu_ppc_store_decr(env, val); 1096de673d4SBlue Swirl } 1106de673d4SBlue Swirl 1114b236b62SBenjamin Herrenschmidt target_ulong helper_load_hdecr(CPUPPCState *env) 1124b236b62SBenjamin Herrenschmidt { 1134b236b62SBenjamin Herrenschmidt return cpu_ppc_load_hdecr(env); 1144b236b62SBenjamin Herrenschmidt } 1154b236b62SBenjamin Herrenschmidt 1164b236b62SBenjamin Herrenschmidt void helper_store_hdecr(CPUPPCState *env, target_ulong val) 1174b236b62SBenjamin Herrenschmidt { 1184b236b62SBenjamin Herrenschmidt cpu_ppc_store_hdecr(env, val); 1194b236b62SBenjamin Herrenschmidt } 1204b236b62SBenjamin Herrenschmidt 121*5d62725bSSuraj Jitindar Singh void helper_store_vtb(CPUPPCState *env, target_ulong val) 122*5d62725bSSuraj Jitindar Singh { 123*5d62725bSSuraj Jitindar Singh cpu_ppc_store_vtb(env, val); 124*5d62725bSSuraj Jitindar Singh } 125*5d62725bSSuraj Jitindar Singh 126d0f1562dSBlue Swirl target_ulong helper_load_40x_pit(CPUPPCState *env) 1276de673d4SBlue Swirl { 1286de673d4SBlue Swirl return load_40x_pit(env); 1296de673d4SBlue Swirl } 1306de673d4SBlue Swirl 131d0f1562dSBlue Swirl void helper_store_40x_pit(CPUPPCState *env, target_ulong val) 1326de673d4SBlue Swirl { 1336de673d4SBlue Swirl store_40x_pit(env, val); 1346de673d4SBlue Swirl } 1356de673d4SBlue Swirl 136d0f1562dSBlue Swirl void helper_store_booke_tcr(CPUPPCState *env, target_ulong val) 1376de673d4SBlue Swirl { 1386de673d4SBlue Swirl store_booke_tcr(env, val); 1396de673d4SBlue Swirl } 1406de673d4SBlue Swirl 141d0f1562dSBlue Swirl void helper_store_booke_tsr(CPUPPCState *env, target_ulong val) 1426de673d4SBlue Swirl { 1436de673d4SBlue Swirl store_booke_tsr(env, val); 1446de673d4SBlue Swirl } 1456de673d4SBlue Swirl #endif 1466de673d4SBlue Swirl 1476de673d4SBlue Swirl /*****************************************************************************/ 1486de673d4SBlue Swirl /* Embedded PowerPC specific helpers */ 1496de673d4SBlue Swirl 1506de673d4SBlue Swirl /* XXX: to be improved to check access rights when in user-mode */ 151d0f1562dSBlue Swirl target_ulong helper_load_dcr(CPUPPCState *env, target_ulong dcrn) 1526de673d4SBlue Swirl { 1536de673d4SBlue Swirl uint32_t val = 0; 1546de673d4SBlue Swirl 1556de673d4SBlue Swirl if (unlikely(env->dcr_env == NULL)) { 15648880da6SPaolo Bonzini qemu_log_mask(LOG_GUEST_ERROR, "No DCR environment\n"); 157a13f0a9bSBenjamin Herrenschmidt raise_exception_err_ra(env, POWERPC_EXCP_PROGRAM, 1586de673d4SBlue Swirl POWERPC_EXCP_INVAL | 159a13f0a9bSBenjamin Herrenschmidt POWERPC_EXCP_INVAL_INVAL, GETPC()); 1606de673d4SBlue Swirl } else if (unlikely(ppc_dcr_read(env->dcr_env, 1616de673d4SBlue Swirl (uint32_t)dcrn, &val) != 0)) { 16248880da6SPaolo Bonzini qemu_log_mask(LOG_GUEST_ERROR, "DCR read error %d %03x\n", 16348880da6SPaolo Bonzini (uint32_t)dcrn, (uint32_t)dcrn); 164a13f0a9bSBenjamin Herrenschmidt raise_exception_err_ra(env, POWERPC_EXCP_PROGRAM, 165a13f0a9bSBenjamin Herrenschmidt POWERPC_EXCP_INVAL | 166a13f0a9bSBenjamin Herrenschmidt POWERPC_EXCP_PRIV_REG, GETPC()); 1676de673d4SBlue Swirl } 1686de673d4SBlue Swirl return val; 1696de673d4SBlue Swirl } 1706de673d4SBlue Swirl 171d0f1562dSBlue Swirl void helper_store_dcr(CPUPPCState *env, target_ulong dcrn, target_ulong val) 1726de673d4SBlue Swirl { 1736de673d4SBlue Swirl if (unlikely(env->dcr_env == NULL)) { 17448880da6SPaolo Bonzini qemu_log_mask(LOG_GUEST_ERROR, "No DCR environment\n"); 175a13f0a9bSBenjamin Herrenschmidt raise_exception_err_ra(env, POWERPC_EXCP_PROGRAM, 1766de673d4SBlue Swirl POWERPC_EXCP_INVAL | 177a13f0a9bSBenjamin Herrenschmidt POWERPC_EXCP_INVAL_INVAL, GETPC()); 1786de673d4SBlue Swirl } else if (unlikely(ppc_dcr_write(env->dcr_env, (uint32_t)dcrn, 1796de673d4SBlue Swirl (uint32_t)val) != 0)) { 18048880da6SPaolo Bonzini qemu_log_mask(LOG_GUEST_ERROR, "DCR write error %d %03x\n", 18148880da6SPaolo Bonzini (uint32_t)dcrn, (uint32_t)dcrn); 182a13f0a9bSBenjamin Herrenschmidt raise_exception_err_ra(env, POWERPC_EXCP_PROGRAM, 183a13f0a9bSBenjamin Herrenschmidt POWERPC_EXCP_INVAL | 184a13f0a9bSBenjamin Herrenschmidt POWERPC_EXCP_PRIV_REG, GETPC()); 1856de673d4SBlue Swirl } 1866de673d4SBlue Swirl } 187