virtio-blk: fix "disabled data plane" mode
[qemu/cris-port.git] / target-ppc / timebase_helper.c
blob3b340d70d1934a7c866193cef9f00de0747cdbab
1 /*
2 * PowerPC emulation helpers for QEMU.
4 * Copyright (c) 2003-2007 Jocelyn Mayer
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
19 #include "qemu/osdep.h"
20 #include "cpu.h"
21 #include "exec/helper-proto.h"
23 /*****************************************************************************/
24 /* SPR accesses */
26 target_ulong helper_load_tbl(CPUPPCState *env)
28 return (target_ulong)cpu_ppc_load_tbl(env);
31 target_ulong helper_load_tbu(CPUPPCState *env)
33 return cpu_ppc_load_tbu(env);
36 target_ulong helper_load_atbl(CPUPPCState *env)
38 return (target_ulong)cpu_ppc_load_atbl(env);
41 target_ulong helper_load_atbu(CPUPPCState *env)
43 return cpu_ppc_load_atbu(env);
46 #if defined(TARGET_PPC64) && !defined(CONFIG_USER_ONLY)
47 target_ulong helper_load_purr(CPUPPCState *env)
49 return (target_ulong)cpu_ppc_load_purr(env);
51 #endif
53 target_ulong helper_load_601_rtcl(CPUPPCState *env)
55 return cpu_ppc601_load_rtcl(env);
58 target_ulong helper_load_601_rtcu(CPUPPCState *env)
60 return cpu_ppc601_load_rtcu(env);
63 #if !defined(CONFIG_USER_ONLY)
64 void helper_store_tbl(CPUPPCState *env, target_ulong val)
66 cpu_ppc_store_tbl(env, val);
69 void helper_store_tbu(CPUPPCState *env, target_ulong val)
71 cpu_ppc_store_tbu(env, val);
74 void helper_store_atbl(CPUPPCState *env, target_ulong val)
76 cpu_ppc_store_atbl(env, val);
79 void helper_store_atbu(CPUPPCState *env, target_ulong val)
81 cpu_ppc_store_atbu(env, val);
84 void helper_store_601_rtcl(CPUPPCState *env, target_ulong val)
86 cpu_ppc601_store_rtcl(env, val);
89 void helper_store_601_rtcu(CPUPPCState *env, target_ulong val)
91 cpu_ppc601_store_rtcu(env, val);
94 target_ulong helper_load_decr(CPUPPCState *env)
96 return cpu_ppc_load_decr(env);
99 void helper_store_decr(CPUPPCState *env, target_ulong val)
101 cpu_ppc_store_decr(env, val);
104 target_ulong helper_load_40x_pit(CPUPPCState *env)
106 return load_40x_pit(env);
109 void helper_store_40x_pit(CPUPPCState *env, target_ulong val)
111 store_40x_pit(env, val);
114 void helper_store_booke_tcr(CPUPPCState *env, target_ulong val)
116 store_booke_tcr(env, val);
119 void helper_store_booke_tsr(CPUPPCState *env, target_ulong val)
121 store_booke_tsr(env, val);
123 #endif
125 /*****************************************************************************/
126 /* Embedded PowerPC specific helpers */
128 /* XXX: to be improved to check access rights when in user-mode */
129 target_ulong helper_load_dcr(CPUPPCState *env, target_ulong dcrn)
131 uint32_t val = 0;
133 if (unlikely(env->dcr_env == NULL)) {
134 qemu_log_mask(LOG_GUEST_ERROR, "No DCR environment\n");
135 helper_raise_exception_err(env, POWERPC_EXCP_PROGRAM,
136 POWERPC_EXCP_INVAL |
137 POWERPC_EXCP_INVAL_INVAL);
138 } else if (unlikely(ppc_dcr_read(env->dcr_env,
139 (uint32_t)dcrn, &val) != 0)) {
140 qemu_log_mask(LOG_GUEST_ERROR, "DCR read error %d %03x\n",
141 (uint32_t)dcrn, (uint32_t)dcrn);
142 helper_raise_exception_err(env, POWERPC_EXCP_PROGRAM,
143 POWERPC_EXCP_INVAL | POWERPC_EXCP_PRIV_REG);
145 return val;
148 void helper_store_dcr(CPUPPCState *env, target_ulong dcrn, target_ulong val)
150 if (unlikely(env->dcr_env == NULL)) {
151 qemu_log_mask(LOG_GUEST_ERROR, "No DCR environment\n");
152 helper_raise_exception_err(env, POWERPC_EXCP_PROGRAM,
153 POWERPC_EXCP_INVAL |
154 POWERPC_EXCP_INVAL_INVAL);
155 } else if (unlikely(ppc_dcr_write(env->dcr_env, (uint32_t)dcrn,
156 (uint32_t)val) != 0)) {
157 qemu_log_mask(LOG_GUEST_ERROR, "DCR write error %d %03x\n",
158 (uint32_t)dcrn, (uint32_t)dcrn);
159 helper_raise_exception_err(env, POWERPC_EXCP_PROGRAM,
160 POWERPC_EXCP_INVAL | POWERPC_EXCP_PRIV_REG);