blob: 8437eb03401cc708397ac2af57b22f5d3ba45dd7 [file] [log] [blame]
Bruno Larsen (billionai)a829cec2021-05-07 08:55:12 -03001/*
2 * PowerPC emulation for qemu: read/write callbacks for SPRs
3 *
4 * Copyright (C) 2021 Instituto de Pesquisas Eldorado
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.1 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 */
Fabiano Rosas99e964e2022-02-18 08:34:15 +010019#ifndef SPR_COMMON_H
20#define SPR_COMMON_H
Bruno Larsen (billionai)a829cec2021-05-07 08:55:12 -030021
Bruno Larsen (billionai)3e770bf2021-05-07 08:55:51 -030022#define SPR_NOACCESS (&spr_noaccess)
23
Fabiano Rosas565873b2022-02-18 08:34:15 +010024#ifdef CONFIG_TCG
25# define USR_ARG(X) X,
26# ifdef CONFIG_USER_ONLY
27# define SYS_ARG(X)
28# else
29# define SYS_ARG(X) X,
30# endif
31#else
32# define USR_ARG(X)
33# define SYS_ARG(X)
34#endif
35#ifdef CONFIG_KVM
36# define KVM_ARG(X) X,
37#else
38# define KVM_ARG(X)
39#endif
40
41typedef void spr_callback(DisasContext *, int, int);
42
43void _spr_register(CPUPPCState *env, int num, const char *name,
44 USR_ARG(spr_callback *uea_read)
45 USR_ARG(spr_callback *uea_write)
46 SYS_ARG(spr_callback *oea_read)
47 SYS_ARG(spr_callback *oea_write)
48 SYS_ARG(spr_callback *hea_read)
49 SYS_ARG(spr_callback *hea_write)
50 KVM_ARG(uint64_t one_reg_id)
51 target_ulong initial_value);
52
53/* spr_register_kvm_hv passes all required arguments. */
54#define spr_register_kvm_hv(env, num, name, uea_read, uea_write, \
55 oea_read, oea_write, hea_read, hea_write, \
56 one_reg_id, initial_value) \
57 _spr_register(env, num, name, \
58 USR_ARG(uea_read) USR_ARG(uea_write) \
59 SYS_ARG(oea_read) SYS_ARG(oea_write) \
60 SYS_ARG(hea_read) SYS_ARG(hea_write) \
61 KVM_ARG(one_reg_id) initial_value)
62
63/* spr_register_kvm duplicates the oea callbacks to the hea callbacks. */
64#define spr_register_kvm(env, num, name, uea_read, uea_write, \
65 oea_read, oea_write, one_reg_id, ival) \
66 spr_register_kvm_hv(env, num, name, uea_read, uea_write, oea_read, \
67 oea_write, oea_read, oea_write, one_reg_id, ival)
68
69/* spr_register_hv and spr_register are similar, except there is no kvm id. */
70#define spr_register_hv(env, num, name, uea_read, uea_write, \
71 oea_read, oea_write, hea_read, hea_write, ival) \
72 spr_register_kvm_hv(env, num, name, uea_read, uea_write, oea_read, \
73 oea_write, hea_read, hea_write, 0, ival)
74
75#define spr_register(env, num, name, uea_read, uea_write, \
76 oea_read, oea_write, ival) \
77 spr_register_kvm(env, num, name, uea_read, uea_write, \
78 oea_read, oea_write, 0, ival)
79
Bruno Larsen (billionai)a829cec2021-05-07 08:55:12 -030080/* prototypes for readers and writers for SPRs */
81void spr_noaccess(DisasContext *ctx, int gprn, int sprn);
82void spr_read_generic(DisasContext *ctx, int gprn, int sprn);
83void spr_write_generic(DisasContext *ctx, int sprn, int gprn);
Daniel Henrique Barbozac2eff582021-12-17 17:57:18 +010084void spr_write_MMCR0(DisasContext *ctx, int sprn, int gprn);
Daniel Henrique Barbozaa6f91242021-12-17 17:57:18 +010085void spr_write_MMCR1(DisasContext *ctx, int sprn, int gprn);
Daniel Henrique Barboza308b9fa2021-12-17 17:57:18 +010086void spr_write_PMC(DisasContext *ctx, int sprn, int gprn);
Daniel Henrique Barboza7aeac352021-12-17 17:57:18 +010087void spr_write_CTRL(DisasContext *ctx, int sprn, int gprn);
Bruno Larsen (billionai)a829cec2021-05-07 08:55:12 -030088void spr_read_xer(DisasContext *ctx, int gprn, int sprn);
89void spr_write_xer(DisasContext *ctx, int sprn, int gprn);
90void spr_read_lr(DisasContext *ctx, int gprn, int sprn);
91void spr_write_lr(DisasContext *ctx, int sprn, int gprn);
92void spr_read_ctr(DisasContext *ctx, int gprn, int sprn);
93void spr_write_ctr(DisasContext *ctx, int sprn, int gprn);
94void spr_read_ureg(DisasContext *ctx, int gprn, int sprn);
Gustavo Romero565cb102021-10-17 22:01:20 -030095void spr_read_MMCR0_ureg(DisasContext *ctx, int gprn, int sprn);
Daniel Henrique Barboza7b3ecf12021-10-17 22:01:21 -030096void spr_read_MMCR2_ureg(DisasContext *ctx, int gprn, int sprn);
Daniel Henrique Barboza308b9fa2021-12-17 17:57:18 +010097void spr_read_PMC(DisasContext *ctx, int gprn, int sprn);
Daniel Henrique Barbozacedf7062021-10-17 22:01:22 -030098void spr_read_PMC14_ureg(DisasContext *ctx, int gprn, int sprn);
99void spr_read_PMC56_ureg(DisasContext *ctx, int gprn, int sprn);
Bruno Larsen (billionai)a829cec2021-05-07 08:55:12 -0300100void spr_read_tbl(DisasContext *ctx, int gprn, int sprn);
101void spr_read_tbu(DisasContext *ctx, int gprn, int sprn);
102void spr_read_atbl(DisasContext *ctx, int gprn, int sprn);
103void spr_read_atbu(DisasContext *ctx, int gprn, int sprn);
Bruno Larsen (billionai)a829cec2021-05-07 08:55:12 -0300104void spr_read_spefscr(DisasContext *ctx, int gprn, int sprn);
105void spr_write_spefscr(DisasContext *ctx, int sprn, int gprn);
Gustavo Romero565cb102021-10-17 22:01:20 -0300106void spr_write_MMCR0_ureg(DisasContext *ctx, int sprn, int gprn);
Daniel Henrique Barboza7b3ecf12021-10-17 22:01:21 -0300107void spr_write_MMCR2_ureg(DisasContext *ctx, int sprn, int gprn);
Daniel Henrique Barbozacedf7062021-10-17 22:01:22 -0300108void spr_write_PMC14_ureg(DisasContext *ctx, int sprn, int gprn);
109void spr_write_PMC56_ureg(DisasContext *ctx, int sprn, int gprn);
Bruno Larsen (billionai)a829cec2021-05-07 08:55:12 -0300110
111#ifndef CONFIG_USER_ONLY
112void spr_write_generic32(DisasContext *ctx, int sprn, int gprn);
113void spr_write_clear(DisasContext *ctx, int sprn, int gprn);
114void spr_access_nop(DisasContext *ctx, int sprn, int gprn);
115void spr_read_decr(DisasContext *ctx, int gprn, int sprn);
116void spr_write_decr(DisasContext *ctx, int sprn, int gprn);
117void spr_write_tbl(DisasContext *ctx, int sprn, int gprn);
118void spr_write_tbu(DisasContext *ctx, int sprn, int gprn);
119void spr_write_atbl(DisasContext *ctx, int sprn, int gprn);
120void spr_write_atbu(DisasContext *ctx, int sprn, int gprn);
121void spr_read_ibat(DisasContext *ctx, int gprn, int sprn);
122void spr_read_ibat_h(DisasContext *ctx, int gprn, int sprn);
123void spr_write_ibatu(DisasContext *ctx, int sprn, int gprn);
124void spr_write_ibatu_h(DisasContext *ctx, int sprn, int gprn);
125void spr_write_ibatl(DisasContext *ctx, int sprn, int gprn);
126void spr_write_ibatl_h(DisasContext *ctx, int sprn, int gprn);
127void spr_read_dbat(DisasContext *ctx, int gprn, int sprn);
128void spr_read_dbat_h(DisasContext *ctx, int gprn, int sprn);
129void spr_write_dbatu(DisasContext *ctx, int sprn, int gprn);
130void spr_write_dbatu_h(DisasContext *ctx, int sprn, int gprn);
131void spr_write_dbatl(DisasContext *ctx, int sprn, int gprn);
132void spr_write_dbatl_h(DisasContext *ctx, int sprn, int gprn);
133void spr_write_sdr1(DisasContext *ctx, int sprn, int gprn);
Bruno Larsen (billionai)a829cec2021-05-07 08:55:12 -0300134void spr_read_40x_pit(DisasContext *ctx, int gprn, int sprn);
135void spr_write_40x_pit(DisasContext *ctx, int sprn, int gprn);
136void spr_write_40x_dbcr0(DisasContext *ctx, int sprn, int gprn);
137void spr_write_40x_sler(DisasContext *ctx, int sprn, int gprn);
Cédric Le Goatercbd8f172022-01-04 07:55:34 +0100138void spr_write_40x_tcr(DisasContext *ctx, int sprn, int gprn);
139void spr_write_40x_tsr(DisasContext *ctx, int sprn, int gprn);
Cédric Le Goaterdd69d142022-01-04 07:55:34 +0100140void spr_write_40x_pid(DisasContext *ctx, int sprn, int gprn);
Bruno Larsen (billionai)a829cec2021-05-07 08:55:12 -0300141void spr_write_booke_tcr(DisasContext *ctx, int sprn, int gprn);
142void spr_write_booke_tsr(DisasContext *ctx, int sprn, int gprn);
143void spr_read_403_pbr(DisasContext *ctx, int gprn, int sprn);
144void spr_write_403_pbr(DisasContext *ctx, int sprn, int gprn);
145void spr_write_pir(DisasContext *ctx, int sprn, int gprn);
146void spr_write_excp_prefix(DisasContext *ctx, int sprn, int gprn);
147void spr_write_excp_vector(DisasContext *ctx, int sprn, int gprn);
148void spr_read_thrm(DisasContext *ctx, int gprn, int sprn);
149void spr_write_e500_l1csr0(DisasContext *ctx, int sprn, int gprn);
150void spr_write_e500_l1csr1(DisasContext *ctx, int sprn, int gprn);
151void spr_write_e500_l2csr0(DisasContext *ctx, int sprn, int gprn);
152void spr_write_booke206_mmucsr0(DisasContext *ctx, int sprn, int gprn);
153void spr_write_booke_pid(DisasContext *ctx, int sprn, int gprn);
154void spr_write_eplc(DisasContext *ctx, int sprn, int gprn);
155void spr_write_epsc(DisasContext *ctx, int sprn, int gprn);
156void spr_write_mas73(DisasContext *ctx, int sprn, int gprn);
157void spr_read_mas73(DisasContext *ctx, int gprn, int sprn);
158#ifdef TARGET_PPC64
159void spr_read_cfar(DisasContext *ctx, int gprn, int sprn);
160void spr_write_cfar(DisasContext *ctx, int sprn, int gprn);
161void spr_write_ureg(DisasContext *ctx, int sprn, int gprn);
162void spr_read_purr(DisasContext *ctx, int gprn, int sprn);
163void spr_write_purr(DisasContext *ctx, int sprn, int gprn);
164void spr_read_hdecr(DisasContext *ctx, int gprn, int sprn);
165void spr_write_hdecr(DisasContext *ctx, int sprn, int gprn);
166void spr_read_vtb(DisasContext *ctx, int gprn, int sprn);
167void spr_write_vtb(DisasContext *ctx, int sprn, int gprn);
168void spr_write_tbu40(DisasContext *ctx, int sprn, int gprn);
169void spr_write_pidr(DisasContext *ctx, int sprn, int gprn);
170void spr_write_lpidr(DisasContext *ctx, int sprn, int gprn);
171void spr_read_hior(DisasContext *ctx, int gprn, int sprn);
172void spr_write_hior(DisasContext *ctx, int sprn, int gprn);
173void spr_write_ptcr(DisasContext *ctx, int sprn, int gprn);
174void spr_write_pcr(DisasContext *ctx, int sprn, int gprn);
175void spr_read_dpdes(DisasContext *ctx, int gprn, int sprn);
176void spr_write_dpdes(DisasContext *ctx, int sprn, int gprn);
177void spr_write_amr(DisasContext *ctx, int sprn, int gprn);
178void spr_write_uamor(DisasContext *ctx, int sprn, int gprn);
179void spr_write_iamr(DisasContext *ctx, int sprn, int gprn);
180#endif
181#endif
182
183#ifdef TARGET_PPC64
184void spr_read_prev_upper32(DisasContext *ctx, int gprn, int sprn);
185void spr_write_prev_upper32(DisasContext *ctx, int sprn, int gprn);
186void spr_read_tar(DisasContext *ctx, int gprn, int sprn);
187void spr_write_tar(DisasContext *ctx, int sprn, int gprn);
188void spr_read_tm(DisasContext *ctx, int gprn, int sprn);
189void spr_write_tm(DisasContext *ctx, int sprn, int gprn);
190void spr_read_tm_upper32(DisasContext *ctx, int gprn, int sprn);
191void spr_write_tm_upper32(DisasContext *ctx, int sprn, int gprn);
192void spr_read_ebb(DisasContext *ctx, int gprn, int sprn);
193void spr_write_ebb(DisasContext *ctx, int sprn, int gprn);
194void spr_read_ebb_upper32(DisasContext *ctx, int gprn, int sprn);
195void spr_write_ebb_upper32(DisasContext *ctx, int sprn, int gprn);
196void spr_write_hmer(DisasContext *ctx, int sprn, int gprn);
197void spr_write_lpcr(DisasContext *ctx, int sprn, int gprn);
Nicholas Miehlbradt395b5d52022-12-20 04:23:29 +0000198void spr_read_dexcr_ureg(DisasContext *ctx, int gprn, int sprn);
Bruno Larsen (billionai)a829cec2021-05-07 08:55:12 -0300199#endif
200
Fabiano Rosas917ea432022-02-18 08:34:15 +0100201void register_low_BATs(CPUPPCState *env);
202void register_high_BATs(CPUPPCState *env);
203void register_sdr1_sprs(CPUPPCState *env);
204void register_thrm_sprs(CPUPPCState *env);
205void register_usprgh_sprs(CPUPPCState *env);
206void register_non_embedded_sprs(CPUPPCState *env);
207void register_6xx_7xx_soft_tlb(CPUPPCState *env, int nb_tlbs, int nb_ways);
Fabiano Rosas65e04462022-02-18 08:34:15 +0100208void register_generic_sprs(PowerPCCPU *cpu);
Fabiano Rosas917ea432022-02-18 08:34:15 +0100209
Bruno Larsen (billionai)a829cec2021-05-07 08:55:12 -0300210#endif