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"
21 #include "exec/helper-proto.h"
24 /*****************************************************************************/
27 target_ulong
helper_load_tbl(CPUPPCState
*env
)
29 return (target_ulong
)cpu_ppc_load_tbl(env
);
32 target_ulong
helper_load_tbu(CPUPPCState
*env
)
34 return cpu_ppc_load_tbu(env
);
37 target_ulong
helper_load_atbl(CPUPPCState
*env
)
39 return (target_ulong
)cpu_ppc_load_atbl(env
);
42 target_ulong
helper_load_atbu(CPUPPCState
*env
)
44 return cpu_ppc_load_atbu(env
);
47 #if defined(TARGET_PPC64) && !defined(CONFIG_USER_ONLY)
48 target_ulong
helper_load_purr(CPUPPCState
*env
)
50 return (target_ulong
)cpu_ppc_load_purr(env
);
54 target_ulong
helper_load_601_rtcl(CPUPPCState
*env
)
56 return cpu_ppc601_load_rtcl(env
);
59 target_ulong
helper_load_601_rtcu(CPUPPCState
*env
)
61 return cpu_ppc601_load_rtcu(env
);
64 #if !defined(CONFIG_USER_ONLY)
65 void helper_store_tbl(CPUPPCState
*env
, target_ulong val
)
67 cpu_ppc_store_tbl(env
, val
);
70 void helper_store_tbu(CPUPPCState
*env
, target_ulong val
)
72 cpu_ppc_store_tbu(env
, val
);
75 void helper_store_atbl(CPUPPCState
*env
, target_ulong val
)
77 cpu_ppc_store_atbl(env
, val
);
80 void helper_store_atbu(CPUPPCState
*env
, target_ulong val
)
82 cpu_ppc_store_atbu(env
, val
);
85 void helper_store_601_rtcl(CPUPPCState
*env
, target_ulong val
)
87 cpu_ppc601_store_rtcl(env
, val
);
90 void helper_store_601_rtcu(CPUPPCState
*env
, target_ulong val
)
92 cpu_ppc601_store_rtcu(env
, val
);
95 target_ulong
helper_load_decr(CPUPPCState
*env
)
97 return cpu_ppc_load_decr(env
);
100 void helper_store_decr(CPUPPCState
*env
, target_ulong val
)
102 cpu_ppc_store_decr(env
, val
);
105 target_ulong
helper_load_hdecr(CPUPPCState
*env
)
107 return cpu_ppc_load_hdecr(env
);
110 void helper_store_hdecr(CPUPPCState
*env
, target_ulong val
)
112 cpu_ppc_store_hdecr(env
, val
);
115 target_ulong
helper_load_40x_pit(CPUPPCState
*env
)
117 return load_40x_pit(env
);
120 void helper_store_40x_pit(CPUPPCState
*env
, target_ulong val
)
122 store_40x_pit(env
, val
);
125 void helper_store_booke_tcr(CPUPPCState
*env
, target_ulong val
)
127 store_booke_tcr(env
, val
);
130 void helper_store_booke_tsr(CPUPPCState
*env
, target_ulong val
)
132 store_booke_tsr(env
, val
);
136 /*****************************************************************************/
137 /* Embedded PowerPC specific helpers */
139 /* XXX: to be improved to check access rights when in user-mode */
140 target_ulong
helper_load_dcr(CPUPPCState
*env
, target_ulong dcrn
)
144 if (unlikely(env
->dcr_env
== NULL
)) {
145 qemu_log_mask(LOG_GUEST_ERROR
, "No DCR environment\n");
146 helper_raise_exception_err(env
, POWERPC_EXCP_PROGRAM
,
148 POWERPC_EXCP_INVAL_INVAL
);
149 } else if (unlikely(ppc_dcr_read(env
->dcr_env
,
150 (uint32_t)dcrn
, &val
) != 0)) {
151 qemu_log_mask(LOG_GUEST_ERROR
, "DCR read error %d %03x\n",
152 (uint32_t)dcrn
, (uint32_t)dcrn
);
153 helper_raise_exception_err(env
, POWERPC_EXCP_PROGRAM
,
154 POWERPC_EXCP_INVAL
| POWERPC_EXCP_PRIV_REG
);
159 void helper_store_dcr(CPUPPCState
*env
, target_ulong dcrn
, target_ulong val
)
161 if (unlikely(env
->dcr_env
== NULL
)) {
162 qemu_log_mask(LOG_GUEST_ERROR
, "No DCR environment\n");
163 helper_raise_exception_err(env
, POWERPC_EXCP_PROGRAM
,
165 POWERPC_EXCP_INVAL_INVAL
);
166 } else if (unlikely(ppc_dcr_write(env
->dcr_env
, (uint32_t)dcrn
,
167 (uint32_t)val
) != 0)) {
168 qemu_log_mask(LOG_GUEST_ERROR
, "DCR write error %d %03x\n",
169 (uint32_t)dcrn
, (uint32_t)dcrn
);
170 helper_raise_exception_err(env
, POWERPC_EXCP_PROGRAM
,
171 POWERPC_EXCP_INVAL
| POWERPC_EXCP_PRIV_REG
);