]> git.proxmox.com Git - qemu.git/blame - target-ppc/timebase_helper.c
rng-egd: remove redundant free
[qemu.git] / target-ppc / timebase_helper.c
CommitLineData
6de673d4
BS
1/*
2 * PowerPC emulation helpers for QEMU.
3 *
4 * Copyright (c) 2003-2007 Jocelyn Mayer
5 *
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.
10 *
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.
15 *
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/>.
18 */
19#include "cpu.h"
6de673d4
BS
20#include "helper.h"
21
22/*****************************************************************************/
23/* SPR accesses */
24
d0f1562d 25target_ulong helper_load_tbl(CPUPPCState *env)
6de673d4
BS
26{
27 return (target_ulong)cpu_ppc_load_tbl(env);
28}
29
d0f1562d 30target_ulong helper_load_tbu(CPUPPCState *env)
6de673d4
BS
31{
32 return cpu_ppc_load_tbu(env);
33}
34
d0f1562d 35target_ulong helper_load_atbl(CPUPPCState *env)
6de673d4
BS
36{
37 return (target_ulong)cpu_ppc_load_atbl(env);
38}
39
d0f1562d 40target_ulong helper_load_atbu(CPUPPCState *env)
6de673d4
BS
41{
42 return cpu_ppc_load_atbu(env);
43}
44
45#if defined(TARGET_PPC64) && !defined(CONFIG_USER_ONLY)
d0f1562d 46target_ulong helper_load_purr(CPUPPCState *env)
6de673d4
BS
47{
48 return (target_ulong)cpu_ppc_load_purr(env);
49}
50#endif
51
d0f1562d 52target_ulong helper_load_601_rtcl(CPUPPCState *env)
6de673d4
BS
53{
54 return cpu_ppc601_load_rtcl(env);
55}
56
d0f1562d 57target_ulong helper_load_601_rtcu(CPUPPCState *env)
6de673d4
BS
58{
59 return cpu_ppc601_load_rtcu(env);
60}
61
62#if !defined(CONFIG_USER_ONLY)
d0f1562d 63void helper_store_tbl(CPUPPCState *env, target_ulong val)
6de673d4
BS
64{
65 cpu_ppc_store_tbl(env, val);
66}
67
d0f1562d 68void helper_store_tbu(CPUPPCState *env, target_ulong val)
6de673d4
BS
69{
70 cpu_ppc_store_tbu(env, val);
71}
72
d0f1562d 73void helper_store_atbl(CPUPPCState *env, target_ulong val)
6de673d4
BS
74{
75 cpu_ppc_store_atbl(env, val);
76}
77
d0f1562d 78void helper_store_atbu(CPUPPCState *env, target_ulong val)
6de673d4
BS
79{
80 cpu_ppc_store_atbu(env, val);
81}
82
d0f1562d 83void helper_store_601_rtcl(CPUPPCState *env, target_ulong val)
6de673d4
BS
84{
85 cpu_ppc601_store_rtcl(env, val);
86}
87
d0f1562d 88void helper_store_601_rtcu(CPUPPCState *env, target_ulong val)
6de673d4
BS
89{
90 cpu_ppc601_store_rtcu(env, val);
91}
92
d0f1562d 93target_ulong helper_load_decr(CPUPPCState *env)
6de673d4
BS
94{
95 return cpu_ppc_load_decr(env);
96}
97
d0f1562d 98void helper_store_decr(CPUPPCState *env, target_ulong val)
6de673d4
BS
99{
100 cpu_ppc_store_decr(env, val);
101}
102
d0f1562d 103target_ulong helper_load_40x_pit(CPUPPCState *env)
6de673d4
BS
104{
105 return load_40x_pit(env);
106}
107
d0f1562d 108void helper_store_40x_pit(CPUPPCState *env, target_ulong val)
6de673d4
BS
109{
110 store_40x_pit(env, val);
111}
112
d0f1562d 113void helper_store_booke_tcr(CPUPPCState *env, target_ulong val)
6de673d4
BS
114{
115 store_booke_tcr(env, val);
116}
117
d0f1562d 118void helper_store_booke_tsr(CPUPPCState *env, target_ulong val)
6de673d4
BS
119{
120 store_booke_tsr(env, val);
121}
122#endif
123
124/*****************************************************************************/
125/* Embedded PowerPC specific helpers */
126
127/* XXX: to be improved to check access rights when in user-mode */
d0f1562d 128target_ulong helper_load_dcr(CPUPPCState *env, target_ulong dcrn)
6de673d4
BS
129{
130 uint32_t val = 0;
131
132 if (unlikely(env->dcr_env == NULL)) {
133 qemu_log("No DCR environment\n");
134 helper_raise_exception_err(env, POWERPC_EXCP_PROGRAM,
135 POWERPC_EXCP_INVAL |
136 POWERPC_EXCP_INVAL_INVAL);
137 } else if (unlikely(ppc_dcr_read(env->dcr_env,
138 (uint32_t)dcrn, &val) != 0)) {
139 qemu_log("DCR read error %d %03x\n", (uint32_t)dcrn, (uint32_t)dcrn);
140 helper_raise_exception_err(env, POWERPC_EXCP_PROGRAM,
141 POWERPC_EXCP_INVAL | POWERPC_EXCP_PRIV_REG);
142 }
143 return val;
144}
145
d0f1562d 146void helper_store_dcr(CPUPPCState *env, target_ulong dcrn, target_ulong val)
6de673d4
BS
147{
148 if (unlikely(env->dcr_env == NULL)) {
149 qemu_log("No DCR environment\n");
150 helper_raise_exception_err(env, POWERPC_EXCP_PROGRAM,
151 POWERPC_EXCP_INVAL |
152 POWERPC_EXCP_INVAL_INVAL);
153 } else if (unlikely(ppc_dcr_write(env->dcr_env, (uint32_t)dcrn,
154 (uint32_t)val) != 0)) {
155 qemu_log("DCR write error %d %03x\n", (uint32_t)dcrn, (uint32_t)dcrn);
156 helper_raise_exception_err(env, POWERPC_EXCP_PROGRAM,
157 POWERPC_EXCP_INVAL | POWERPC_EXCP_PRIV_REG);
158 }
159}