]> git.proxmox.com Git - mirror_qemu.git/blame - target/ppc/timebase_helper.c
tests/vm: custom openbsd partitioning to increase /home space
[mirror_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
6bd039cd 9 * version 2.1 of the License, or (at your option) any later version.
6de673d4
BS
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 */
0d75590d 19#include "qemu/osdep.h"
6de673d4 20#include "cpu.h"
2ef6175a 21#include "exec/helper-proto.h"
a13f0a9b 22#include "exec/exec-all.h"
63c91552 23#include "qemu/log.h"
235352ee 24#include "qemu/main-loop.h"
6de673d4
BS
25
26/*****************************************************************************/
27/* SPR accesses */
28
d0f1562d 29target_ulong helper_load_tbl(CPUPPCState *env)
6de673d4
BS
30{
31 return (target_ulong)cpu_ppc_load_tbl(env);
32}
33
d0f1562d 34target_ulong helper_load_tbu(CPUPPCState *env)
6de673d4
BS
35{
36 return cpu_ppc_load_tbu(env);
37}
38
d0f1562d 39target_ulong helper_load_atbl(CPUPPCState *env)
6de673d4
BS
40{
41 return (target_ulong)cpu_ppc_load_atbl(env);
42}
43
d0f1562d 44target_ulong helper_load_atbu(CPUPPCState *env)
6de673d4
BS
45{
46 return cpu_ppc_load_atbu(env);
47}
48
5d62725b
SJS
49target_ulong helper_load_vtb(CPUPPCState *env)
50{
51 return cpu_ppc_load_vtb(env);
52}
53
6de673d4 54#if defined(TARGET_PPC64) && !defined(CONFIG_USER_ONLY)
d0f1562d 55target_ulong helper_load_purr(CPUPPCState *env)
6de673d4
BS
56{
57 return (target_ulong)cpu_ppc_load_purr(env);
58}
5cc7e69f
SJS
59
60void helper_store_purr(CPUPPCState *env, target_ulong val)
61{
62 cpu_ppc_store_purr(env, val);
63}
6de673d4
BS
64#endif
65
6de673d4 66#if !defined(CONFIG_USER_ONLY)
d0f1562d 67void helper_store_tbl(CPUPPCState *env, target_ulong val)
6de673d4
BS
68{
69 cpu_ppc_store_tbl(env, val);
70}
71
d0f1562d 72void helper_store_tbu(CPUPPCState *env, target_ulong val)
6de673d4
BS
73{
74 cpu_ppc_store_tbu(env, val);
75}
76
d0f1562d 77void helper_store_atbl(CPUPPCState *env, target_ulong val)
6de673d4
BS
78{
79 cpu_ppc_store_atbl(env, val);
80}
81
d0f1562d 82void helper_store_atbu(CPUPPCState *env, target_ulong val)
6de673d4
BS
83{
84 cpu_ppc_store_atbu(env, val);
85}
86
d0f1562d 87target_ulong helper_load_decr(CPUPPCState *env)
6de673d4
BS
88{
89 return cpu_ppc_load_decr(env);
90}
91
d0f1562d 92void helper_store_decr(CPUPPCState *env, target_ulong val)
6de673d4
BS
93{
94 cpu_ppc_store_decr(env, val);
95}
96
4b236b62
BH
97target_ulong helper_load_hdecr(CPUPPCState *env)
98{
99 return cpu_ppc_load_hdecr(env);
100}
101
102void helper_store_hdecr(CPUPPCState *env, target_ulong val)
103{
104 cpu_ppc_store_hdecr(env, val);
105}
106
5d62725b
SJS
107void helper_store_vtb(CPUPPCState *env, target_ulong val)
108{
109 cpu_ppc_store_vtb(env, val);
110}
111
f0ec31b1
SJS
112void helper_store_tbu40(CPUPPCState *env, target_ulong val)
113{
114 cpu_ppc_store_tbu40(env, val);
115}
116
d0f1562d 117target_ulong helper_load_40x_pit(CPUPPCState *env)
6de673d4
BS
118{
119 return load_40x_pit(env);
120}
121
d0f1562d 122void helper_store_40x_pit(CPUPPCState *env, target_ulong val)
6de673d4
BS
123{
124 store_40x_pit(env, val);
125}
126
cbd8f17d
CLG
127void helper_store_40x_tcr(CPUPPCState *env, target_ulong val)
128{
129 store_40x_tcr(env, val);
130}
131
132void helper_store_40x_tsr(CPUPPCState *env, target_ulong val)
133{
134 store_40x_tsr(env, val);
135}
136
d0f1562d 137void helper_store_booke_tcr(CPUPPCState *env, target_ulong val)
6de673d4
BS
138{
139 store_booke_tcr(env, val);
140}
141
d0f1562d 142void helper_store_booke_tsr(CPUPPCState *env, target_ulong val)
6de673d4
BS
143{
144 store_booke_tsr(env, val);
145}
6de673d4
BS
146
147/*****************************************************************************/
148/* Embedded PowerPC specific helpers */
149
150/* XXX: to be improved to check access rights when in user-mode */
d0f1562d 151target_ulong helper_load_dcr(CPUPPCState *env, target_ulong dcrn)
6de673d4
BS
152{
153 uint32_t val = 0;
154
155 if (unlikely(env->dcr_env == NULL)) {
48880da6 156 qemu_log_mask(LOG_GUEST_ERROR, "No DCR environment\n");
a13f0a9b
BH
157 raise_exception_err_ra(env, POWERPC_EXCP_PROGRAM,
158 POWERPC_EXCP_INVAL |
159 POWERPC_EXCP_INVAL_INVAL, GETPC());
235352ee
PM
160 } else {
161 int ret;
162
163 qemu_mutex_lock_iothread();
164 ret = ppc_dcr_read(env->dcr_env, (uint32_t)dcrn, &val);
165 qemu_mutex_unlock_iothread();
166 if (unlikely(ret != 0)) {
167 qemu_log_mask(LOG_GUEST_ERROR, "DCR read error %d %03x\n",
168 (uint32_t)dcrn, (uint32_t)dcrn);
169 raise_exception_err_ra(env, POWERPC_EXCP_PROGRAM,
170 POWERPC_EXCP_INVAL |
e8985179 171 POWERPC_EXCP_INVAL_INVAL, GETPC());
235352ee 172 }
6de673d4
BS
173 }
174 return val;
175}
176
d0f1562d 177void helper_store_dcr(CPUPPCState *env, target_ulong dcrn, target_ulong val)
6de673d4
BS
178{
179 if (unlikely(env->dcr_env == NULL)) {
48880da6 180 qemu_log_mask(LOG_GUEST_ERROR, "No DCR environment\n");
a13f0a9b
BH
181 raise_exception_err_ra(env, POWERPC_EXCP_PROGRAM,
182 POWERPC_EXCP_INVAL |
183 POWERPC_EXCP_INVAL_INVAL, GETPC());
235352ee
PM
184 } else {
185 int ret;
186 qemu_mutex_lock_iothread();
187 ret = ppc_dcr_write(env->dcr_env, (uint32_t)dcrn, (uint32_t)val);
188 qemu_mutex_unlock_iothread();
189 if (unlikely(ret != 0)) {
190 qemu_log_mask(LOG_GUEST_ERROR, "DCR write error %d %03x\n",
191 (uint32_t)dcrn, (uint32_t)dcrn);
192 raise_exception_err_ra(env, POWERPC_EXCP_PROGRAM,
193 POWERPC_EXCP_INVAL |
e8985179 194 POWERPC_EXCP_INVAL_INVAL, GETPC());
235352ee 195 }
6de673d4
BS
196 }
197}
e8985179 198#endif