1fcf5ef2aSThomas Huth /*
2fcf5ef2aSThomas Huth * PowerPC emulation cpu definitions for qemu.
3fcf5ef2aSThomas Huth *
4fcf5ef2aSThomas Huth * Copyright (c) 2003-2007 Jocelyn Mayer
5fcf5ef2aSThomas Huth *
6fcf5ef2aSThomas Huth * This library is free software; you can redistribute it and/or
7fcf5ef2aSThomas Huth * modify it under the terms of the GNU Lesser General Public
8fcf5ef2aSThomas Huth * License as published by the Free Software Foundation; either
96bd039cdSChetan Pant * version 2.1 of the License, or (at your option) any later version.
10fcf5ef2aSThomas Huth *
11fcf5ef2aSThomas Huth * This library is distributed in the hope that it will be useful,
12fcf5ef2aSThomas Huth * but WITHOUT ANY WARRANTY; without even the implied warranty of
13fcf5ef2aSThomas Huth * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14fcf5ef2aSThomas Huth * Lesser General Public License for more details.
15fcf5ef2aSThomas Huth *
16fcf5ef2aSThomas Huth * You should have received a copy of the GNU Lesser General Public
17fcf5ef2aSThomas Huth * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18fcf5ef2aSThomas Huth */
19fcf5ef2aSThomas Huth
20fcf5ef2aSThomas Huth #ifndef PPC_CPU_H
21fcf5ef2aSThomas Huth #define PPC_CPU_H
22fcf5ef2aSThomas Huth
2360caf221SAvinesh Kumar #include "qemu/int128.h"
2469242e7eSMarc-André Lureau #include "qemu/cpu-float.h"
2574433bf0SRichard Henderson #include "exec/cpu-defs.h"
2674433bf0SRichard Henderson #include "cpu-qom.h"
27db1015e9SEduardo Habkost #include "qom/object.h"
28d41ccf6eSVíctor Colombo #include "hw/registerfields.h"
29fcf5ef2aSThomas Huth
3037b9414bSPhilippe Mathieu-Daudé #define CPU_RESOLVING_TYPE TYPE_POWERPC_CPU
3137b9414bSPhilippe Mathieu-Daudé
32fcf5ef2aSThomas Huth #define TARGET_PAGE_BITS_64K 16
33fcf5ef2aSThomas Huth #define TARGET_PAGE_BITS_16M 24
34fcf5ef2aSThomas Huth
35fcf5ef2aSThomas Huth #if defined(TARGET_PPC64)
36fcf5ef2aSThomas Huth #define PPC_ELF_MACHINE EM_PPC64
37fcf5ef2aSThomas Huth #else
38fcf5ef2aSThomas Huth #define PPC_ELF_MACHINE EM_PPC
39fcf5ef2aSThomas Huth #endif
40fcf5ef2aSThomas Huth
41bf3dd1e6SVíctor Colombo #define PPC_BIT_NR(bit) (63 - (bit))
42a7d4b1bfSCédric Le Goater #define PPC_BIT(bit) (0x8000000000000000ULL >> (bit))
43899e4886SNicholas Piggin #define PPC_BIT32_NR(bit) (31 - (bit))
44a7d4b1bfSCédric Le Goater #define PPC_BIT32(bit) (0x80000000 >> (bit))
45a7d4b1bfSCédric Le Goater #define PPC_BIT8(bit) (0x80 >> (bit))
462a83f997SCédric Le Goater #define PPC_BITMASK(bs, be) ((PPC_BIT(bs) - PPC_BIT(be)) | PPC_BIT(bs))
472a83f997SCédric Le Goater #define PPC_BITMASK32(bs, be) ((PPC_BIT32(bs) - PPC_BIT32(be)) | \
482a83f997SCédric Le Goater PPC_BIT32(bs))
49a6a444a8SCédric Le Goater #define PPC_BITMASK8(bs, be) ((PPC_BIT8(bs) - PPC_BIT8(be)) | PPC_BIT8(bs))
50a6a444a8SCédric Le Goater
5195444afcSAlexey Kardashevskiy /*
5295444afcSAlexey Kardashevskiy * QEMU version of the GETFIELD/SETFIELD macros from skiboot
5395444afcSAlexey Kardashevskiy *
5495444afcSAlexey Kardashevskiy * It might be better to use the existing extract64() and
5595444afcSAlexey Kardashevskiy * deposit64() but this means that all the register definitions will
5695444afcSAlexey Kardashevskiy * change and become incompatible with the ones found in skiboot.
5795444afcSAlexey Kardashevskiy */
5895444afcSAlexey Kardashevskiy #define MASK_TO_LSH(m) (__builtin_ffsll(m) - 1)
5995444afcSAlexey Kardashevskiy #define GETFIELD(m, v) (((v) & (m)) >> MASK_TO_LSH(m))
6095444afcSAlexey Kardashevskiy #define SETFIELD(m, v, val) \
6195444afcSAlexey Kardashevskiy (((v) & ~(m)) | ((((typeof(v))(val)) << MASK_TO_LSH(m)) & (m)))
6295444afcSAlexey Kardashevskiy
63fcf5ef2aSThomas Huth /*****************************************************************************/
64fcf5ef2aSThomas Huth /* Exception vectors definitions */
65fcf5ef2aSThomas Huth enum {
66fcf5ef2aSThomas Huth POWERPC_EXCP_NONE = -1,
67fcf5ef2aSThomas Huth /* The 64 first entries are used by the PowerPC embedded specification */
68fcf5ef2aSThomas Huth POWERPC_EXCP_CRITICAL = 0, /* Critical input */
69fcf5ef2aSThomas Huth POWERPC_EXCP_MCHECK = 1, /* Machine check exception */
70fcf5ef2aSThomas Huth POWERPC_EXCP_DSI = 2, /* Data storage exception */
71fcf5ef2aSThomas Huth POWERPC_EXCP_ISI = 3, /* Instruction storage exception */
72fcf5ef2aSThomas Huth POWERPC_EXCP_EXTERNAL = 4, /* External input */
73fcf5ef2aSThomas Huth POWERPC_EXCP_ALIGN = 5, /* Alignment exception */
74fcf5ef2aSThomas Huth POWERPC_EXCP_PROGRAM = 6, /* Program exception */
75fcf5ef2aSThomas Huth POWERPC_EXCP_FPU = 7, /* Floating-point unavailable exception */
76fcf5ef2aSThomas Huth POWERPC_EXCP_SYSCALL = 8, /* System call exception */
77fcf5ef2aSThomas Huth POWERPC_EXCP_APU = 9, /* Auxiliary processor unavailable */
78fcf5ef2aSThomas Huth POWERPC_EXCP_DECR = 10, /* Decrementer exception */
79fcf5ef2aSThomas Huth POWERPC_EXCP_FIT = 11, /* Fixed-interval timer interrupt */
80fcf5ef2aSThomas Huth POWERPC_EXCP_WDT = 12, /* Watchdog timer interrupt */
81fcf5ef2aSThomas Huth POWERPC_EXCP_DTLB = 13, /* Data TLB miss */
82fcf5ef2aSThomas Huth POWERPC_EXCP_ITLB = 14, /* Instruction TLB miss */
83fcf5ef2aSThomas Huth POWERPC_EXCP_DEBUG = 15, /* Debug interrupt */
84fcf5ef2aSThomas Huth /* Vectors 16 to 31 are reserved */
85fcf5ef2aSThomas Huth POWERPC_EXCP_SPEU = 32, /* SPE/embedded floating-point unavailable */
86fcf5ef2aSThomas Huth POWERPC_EXCP_EFPDI = 33, /* Embedded floating-point data interrupt */
87fcf5ef2aSThomas Huth POWERPC_EXCP_EFPRI = 34, /* Embedded floating-point round interrupt */
88fcf5ef2aSThomas Huth POWERPC_EXCP_EPERFM = 35, /* Embedded performance monitor interrupt */
89fcf5ef2aSThomas Huth POWERPC_EXCP_DOORI = 36, /* Embedded doorbell interrupt */
90fcf5ef2aSThomas Huth POWERPC_EXCP_DOORCI = 37, /* Embedded doorbell critical interrupt */
91fcf5ef2aSThomas Huth POWERPC_EXCP_GDOORI = 38, /* Embedded guest doorbell interrupt */
92fcf5ef2aSThomas Huth POWERPC_EXCP_GDOORCI = 39, /* Embedded guest doorbell critical interrupt*/
93fcf5ef2aSThomas Huth POWERPC_EXCP_HYPPRIV = 41, /* Embedded hypervisor priv instruction */
94fcf5ef2aSThomas Huth /* Vectors 42 to 63 are reserved */
95fcf5ef2aSThomas Huth /* Exceptions defined in the PowerPC server specification */
96fcf5ef2aSThomas Huth POWERPC_EXCP_RESET = 64, /* System reset exception */
97fcf5ef2aSThomas Huth POWERPC_EXCP_DSEG = 65, /* Data segment exception */
98fcf5ef2aSThomas Huth POWERPC_EXCP_ISEG = 66, /* Instruction segment exception */
99fcf5ef2aSThomas Huth POWERPC_EXCP_HDECR = 67, /* Hypervisor decrementer exception */
100fcf5ef2aSThomas Huth POWERPC_EXCP_TRACE = 68, /* Trace exception */
101fcf5ef2aSThomas Huth POWERPC_EXCP_HDSI = 69, /* Hypervisor data storage exception */
102fcf5ef2aSThomas Huth POWERPC_EXCP_HISI = 70, /* Hypervisor instruction storage exception */
103fcf5ef2aSThomas Huth POWERPC_EXCP_HDSEG = 71, /* Hypervisor data segment exception */
104fcf5ef2aSThomas Huth POWERPC_EXCP_HISEG = 72, /* Hypervisor instruction segment exception */
105fcf5ef2aSThomas Huth POWERPC_EXCP_VPU = 73, /* Vector unavailable exception */
106fcf5ef2aSThomas Huth /* 40x specific exceptions */
107fcf5ef2aSThomas Huth POWERPC_EXCP_PIT = 74, /* Programmable interval timer interrupt */
108005b69fdSCédric Le Goater /* Vectors 75-76 are 601 specific exceptions */
109fcf5ef2aSThomas Huth /* 602 specific exceptions */
110fcf5ef2aSThomas Huth POWERPC_EXCP_EMUL = 77, /* Emulation trap exception */
111fcf5ef2aSThomas Huth /* 602/603 specific exceptions */
112fcf5ef2aSThomas Huth POWERPC_EXCP_IFTLB = 78, /* Instruction fetch TLB miss */
113fcf5ef2aSThomas Huth POWERPC_EXCP_DLTLB = 79, /* Data load TLB miss */
114fcf5ef2aSThomas Huth POWERPC_EXCP_DSTLB = 80, /* Data store TLB miss */
115fcf5ef2aSThomas Huth /* Exceptions available on most PowerPC */
116fcf5ef2aSThomas Huth POWERPC_EXCP_FPA = 81, /* Floating-point assist exception */
117fcf5ef2aSThomas Huth POWERPC_EXCP_DABR = 82, /* Data address breakpoint */
118fcf5ef2aSThomas Huth POWERPC_EXCP_IABR = 83, /* Instruction address breakpoint */
119fcf5ef2aSThomas Huth POWERPC_EXCP_SMI = 84, /* System management interrupt */
120fcf5ef2aSThomas Huth POWERPC_EXCP_PERFM = 85, /* Embedded performance monitor interrupt */
121fcf5ef2aSThomas Huth /* 7xx/74xx specific exceptions */
122fcf5ef2aSThomas Huth POWERPC_EXCP_THERM = 86, /* Thermal interrupt */
123fcf5ef2aSThomas Huth /* 74xx specific exceptions */
124fcf5ef2aSThomas Huth POWERPC_EXCP_VPUA = 87, /* Vector assist exception */
125fcf5ef2aSThomas Huth /* 970FX specific exceptions */
126fcf5ef2aSThomas Huth POWERPC_EXCP_SOFTP = 88, /* Soft patch exception */
127fcf5ef2aSThomas Huth POWERPC_EXCP_MAINT = 89, /* Maintenance exception */
128fcf5ef2aSThomas Huth /* Freescale embedded cores specific exceptions */
129fcf5ef2aSThomas Huth POWERPC_EXCP_MEXTBR = 90, /* Maskable external breakpoint */
130fcf5ef2aSThomas Huth POWERPC_EXCP_NMEXTBR = 91, /* Non maskable external breakpoint */
131fcf5ef2aSThomas Huth POWERPC_EXCP_ITLBE = 92, /* Instruction TLB error */
132fcf5ef2aSThomas Huth POWERPC_EXCP_DTLBE = 93, /* Data TLB error */
133fcf5ef2aSThomas Huth /* VSX Unavailable (Power ISA 2.06 and later) */
134fcf5ef2aSThomas Huth POWERPC_EXCP_VSXU = 94, /* VSX Unavailable */
135fcf5ef2aSThomas Huth POWERPC_EXCP_FU = 95, /* Facility Unavailable */
136fcf5ef2aSThomas Huth /* Additional ISA 2.06 and later server exceptions */
137fcf5ef2aSThomas Huth POWERPC_EXCP_HV_EMU = 96, /* HV emulation assistance */
138fcf5ef2aSThomas Huth POWERPC_EXCP_HV_MAINT = 97, /* HMI */
139fcf5ef2aSThomas Huth POWERPC_EXCP_HV_FU = 98, /* Hypervisor Facility unavailable */
1401414c75dSCédric Le Goater /* Server doorbell variants */
1411414c75dSCédric Le Goater POWERPC_EXCP_SDOOR = 99,
1421414c75dSCédric Le Goater POWERPC_EXCP_SDOOR_HV = 100,
143d8ce5fd6SBenjamin Herrenschmidt /* ISA 3.00 additions */
144d8ce5fd6SBenjamin Herrenschmidt POWERPC_EXCP_HVIRT = 101,
1453c89b8d6SNicholas Piggin POWERPC_EXCP_SYSCALL_VECTORED = 102, /* scv exception */
146cb76bbc4SDaniel Henrique Barboza POWERPC_EXCP_PERFM_EBB = 103, /* Performance Monitor EBB Exception */
147cb76bbc4SDaniel Henrique Barboza POWERPC_EXCP_EXTERNAL_EBB = 104, /* External EBB Exception */
148fcf5ef2aSThomas Huth /* EOL */
149cb76bbc4SDaniel Henrique Barboza POWERPC_EXCP_NB = 105,
150fcf5ef2aSThomas Huth /* QEMU exceptions: special cases we want to stop translation */
151fcf5ef2aSThomas Huth POWERPC_EXCP_SYSCALL_USER = 0x203, /* System call in user mode only */
152fcf5ef2aSThomas Huth };
153fcf5ef2aSThomas Huth
154fcf5ef2aSThomas Huth /* Exceptions error codes */
155fcf5ef2aSThomas Huth enum {
156fcf5ef2aSThomas Huth /* Exception subtypes for POWERPC_EXCP_ALIGN */
157fcf5ef2aSThomas Huth POWERPC_EXCP_ALIGN_FP = 0x01, /* FP alignment exception */
158fcf5ef2aSThomas Huth POWERPC_EXCP_ALIGN_LST = 0x02, /* Unaligned mult/extern load/store */
159fcf5ef2aSThomas Huth POWERPC_EXCP_ALIGN_LE = 0x03, /* Multiple little-endian access */
160fcf5ef2aSThomas Huth POWERPC_EXCP_ALIGN_PROT = 0x04, /* Access cross protection boundary */
161fcf5ef2aSThomas Huth POWERPC_EXCP_ALIGN_BAT = 0x05, /* Access cross a BAT/seg boundary */
162fcf5ef2aSThomas Huth POWERPC_EXCP_ALIGN_CACHE = 0x06, /* Impossible dcbz access */
16399082815SRichard Henderson POWERPC_EXCP_ALIGN_INSN = 0x07, /* Pref. insn x-ing 64-byte boundary */
164fcf5ef2aSThomas Huth /* Exception subtypes for POWERPC_EXCP_PROGRAM */
165fcf5ef2aSThomas Huth /* FP exceptions */
166fcf5ef2aSThomas Huth POWERPC_EXCP_FP = 0x10,
167fcf5ef2aSThomas Huth POWERPC_EXCP_FP_OX = 0x01, /* FP overflow */
168fcf5ef2aSThomas Huth POWERPC_EXCP_FP_UX = 0x02, /* FP underflow */
169fcf5ef2aSThomas Huth POWERPC_EXCP_FP_ZX = 0x03, /* FP divide by zero */
170fcf5ef2aSThomas Huth POWERPC_EXCP_FP_XX = 0x04, /* FP inexact */
171fcf5ef2aSThomas Huth POWERPC_EXCP_FP_VXSNAN = 0x05, /* FP invalid SNaN op */
172fcf5ef2aSThomas Huth POWERPC_EXCP_FP_VXISI = 0x06, /* FP invalid infinite subtraction */
173fcf5ef2aSThomas Huth POWERPC_EXCP_FP_VXIDI = 0x07, /* FP invalid infinite divide */
174fcf5ef2aSThomas Huth POWERPC_EXCP_FP_VXZDZ = 0x08, /* FP invalid zero divide */
175fcf5ef2aSThomas Huth POWERPC_EXCP_FP_VXIMZ = 0x09, /* FP invalid infinite * zero */
176fcf5ef2aSThomas Huth POWERPC_EXCP_FP_VXVC = 0x0A, /* FP invalid compare */
177fcf5ef2aSThomas Huth POWERPC_EXCP_FP_VXSOFT = 0x0B, /* FP invalid operation */
178fcf5ef2aSThomas Huth POWERPC_EXCP_FP_VXSQRT = 0x0C, /* FP invalid square root */
179fcf5ef2aSThomas Huth POWERPC_EXCP_FP_VXCVI = 0x0D, /* FP invalid integer conversion */
180fcf5ef2aSThomas Huth /* Invalid instruction */
181fcf5ef2aSThomas Huth POWERPC_EXCP_INVAL = 0x20,
182fcf5ef2aSThomas Huth POWERPC_EXCP_INVAL_INVAL = 0x01, /* Invalid instruction */
183fcf5ef2aSThomas Huth POWERPC_EXCP_INVAL_LSWX = 0x02, /* Invalid lswx instruction */
184fcf5ef2aSThomas Huth POWERPC_EXCP_INVAL_SPR = 0x03, /* Invalid SPR access */
185fcf5ef2aSThomas Huth POWERPC_EXCP_INVAL_FP = 0x04, /* Unimplemented mandatory fp instr */
186fcf5ef2aSThomas Huth /* Privileged instruction */
187fcf5ef2aSThomas Huth POWERPC_EXCP_PRIV = 0x30,
188fcf5ef2aSThomas Huth POWERPC_EXCP_PRIV_OPC = 0x01, /* Privileged operation exception */
189fcf5ef2aSThomas Huth POWERPC_EXCP_PRIV_REG = 0x02, /* Privileged register exception */
190fcf5ef2aSThomas Huth /* Trap */
191fcf5ef2aSThomas Huth POWERPC_EXCP_TRAP = 0x40,
192fcf5ef2aSThomas Huth };
193fcf5ef2aSThomas Huth
194d66d3d4aSPhilippe Mathieu-Daudé /* Exception model */
195d66d3d4aSPhilippe Mathieu-Daudé typedef enum powerpc_excp_t {
196d66d3d4aSPhilippe Mathieu-Daudé POWERPC_EXCP_UNKNOWN = 0,
197d66d3d4aSPhilippe Mathieu-Daudé /* Standard PowerPC exception model */
198d66d3d4aSPhilippe Mathieu-Daudé POWERPC_EXCP_STD,
199d66d3d4aSPhilippe Mathieu-Daudé /* PowerPC 40x exception model */
200d66d3d4aSPhilippe Mathieu-Daudé POWERPC_EXCP_40x,
201d66d3d4aSPhilippe Mathieu-Daudé /* PowerPC 603/604/G2 exception model */
202d66d3d4aSPhilippe Mathieu-Daudé POWERPC_EXCP_6xx,
203d66d3d4aSPhilippe Mathieu-Daudé /* PowerPC 7xx exception model */
204d66d3d4aSPhilippe Mathieu-Daudé POWERPC_EXCP_7xx,
205d66d3d4aSPhilippe Mathieu-Daudé /* PowerPC 74xx exception model */
206d66d3d4aSPhilippe Mathieu-Daudé POWERPC_EXCP_74xx,
207d66d3d4aSPhilippe Mathieu-Daudé /* BookE exception model */
208d66d3d4aSPhilippe Mathieu-Daudé POWERPC_EXCP_BOOKE,
209d66d3d4aSPhilippe Mathieu-Daudé /* PowerPC 970 exception model */
210d66d3d4aSPhilippe Mathieu-Daudé POWERPC_EXCP_970,
211d66d3d4aSPhilippe Mathieu-Daudé /* POWER7 exception model */
212d66d3d4aSPhilippe Mathieu-Daudé POWERPC_EXCP_POWER7,
213d66d3d4aSPhilippe Mathieu-Daudé /* POWER8 exception model */
214d66d3d4aSPhilippe Mathieu-Daudé POWERPC_EXCP_POWER8,
215d66d3d4aSPhilippe Mathieu-Daudé /* POWER9 exception model */
216d66d3d4aSPhilippe Mathieu-Daudé POWERPC_EXCP_POWER9,
217d66d3d4aSPhilippe Mathieu-Daudé /* POWER10 exception model */
218d66d3d4aSPhilippe Mathieu-Daudé POWERPC_EXCP_POWER10,
219c0d96407SAditya Gupta /* POWER11 exception model */
220c0d96407SAditya Gupta POWERPC_EXCP_POWER11,
221d66d3d4aSPhilippe Mathieu-Daudé } powerpc_excp_t;
222d66d3d4aSPhilippe Mathieu-Daudé
2236fb8b16aSPhilippe Mathieu-Daudé /*****************************************************************************/
2246fb8b16aSPhilippe Mathieu-Daudé /* MMU model */
2256fb8b16aSPhilippe Mathieu-Daudé typedef enum powerpc_mmu_t {
2266fb8b16aSPhilippe Mathieu-Daudé POWERPC_MMU_UNKNOWN = 0x00000000,
2276fb8b16aSPhilippe Mathieu-Daudé /* Standard 32 bits PowerPC MMU */
2286fb8b16aSPhilippe Mathieu-Daudé POWERPC_MMU_32B = 0x00000001,
2296fb8b16aSPhilippe Mathieu-Daudé /* PowerPC 6xx MMU with software TLB */
2306fb8b16aSPhilippe Mathieu-Daudé POWERPC_MMU_SOFT_6xx = 0x00000002,
2316fb8b16aSPhilippe Mathieu-Daudé /*
2326fb8b16aSPhilippe Mathieu-Daudé * PowerPC 74xx MMU with software TLB (this has been
2336fb8b16aSPhilippe Mathieu-Daudé * disabled, see git history for more information.
2346fb8b16aSPhilippe Mathieu-Daudé * keywords: tlbld tlbli TLBMISS PTEHI PTELO)
2356fb8b16aSPhilippe Mathieu-Daudé */
2366fb8b16aSPhilippe Mathieu-Daudé POWERPC_MMU_SOFT_74xx = 0x00000003,
2376fb8b16aSPhilippe Mathieu-Daudé /* PowerPC 4xx MMU with software TLB */
2386fb8b16aSPhilippe Mathieu-Daudé POWERPC_MMU_SOFT_4xx = 0x00000004,
2396fb8b16aSPhilippe Mathieu-Daudé /* PowerPC MMU in real mode only */
2406fb8b16aSPhilippe Mathieu-Daudé POWERPC_MMU_REAL = 0x00000006,
2416fb8b16aSPhilippe Mathieu-Daudé /* Freescale MPC8xx MMU model */
2426fb8b16aSPhilippe Mathieu-Daudé POWERPC_MMU_MPC8xx = 0x00000007,
2436fb8b16aSPhilippe Mathieu-Daudé /* BookE MMU model */
2446fb8b16aSPhilippe Mathieu-Daudé POWERPC_MMU_BOOKE = 0x00000008,
2456fb8b16aSPhilippe Mathieu-Daudé /* BookE 2.06 MMU model */
2466fb8b16aSPhilippe Mathieu-Daudé POWERPC_MMU_BOOKE206 = 0x00000009,
2476fb8b16aSPhilippe Mathieu-Daudé #define POWERPC_MMU_64 0x00010000
2486fb8b16aSPhilippe Mathieu-Daudé /* 64 bits PowerPC MMU */
2496fb8b16aSPhilippe Mathieu-Daudé POWERPC_MMU_64B = POWERPC_MMU_64 | 0x00000001,
2506fb8b16aSPhilippe Mathieu-Daudé /* Architecture 2.03 and later (has LPCR) */
2516fb8b16aSPhilippe Mathieu-Daudé POWERPC_MMU_2_03 = POWERPC_MMU_64 | 0x00000002,
2526fb8b16aSPhilippe Mathieu-Daudé /* Architecture 2.06 variant */
2536fb8b16aSPhilippe Mathieu-Daudé POWERPC_MMU_2_06 = POWERPC_MMU_64 | 0x00000003,
2546fb8b16aSPhilippe Mathieu-Daudé /* Architecture 2.07 variant */
2556fb8b16aSPhilippe Mathieu-Daudé POWERPC_MMU_2_07 = POWERPC_MMU_64 | 0x00000004,
2566fb8b16aSPhilippe Mathieu-Daudé /* Architecture 3.00 variant */
2576fb8b16aSPhilippe Mathieu-Daudé POWERPC_MMU_3_00 = POWERPC_MMU_64 | 0x00000005,
2586fb8b16aSPhilippe Mathieu-Daudé } powerpc_mmu_t;
2596fb8b16aSPhilippe Mathieu-Daudé
mmu_is_64bit(powerpc_mmu_t mmu_model)2606fb8b16aSPhilippe Mathieu-Daudé static inline bool mmu_is_64bit(powerpc_mmu_t mmu_model)
2616fb8b16aSPhilippe Mathieu-Daudé {
2626fb8b16aSPhilippe Mathieu-Daudé return mmu_model & POWERPC_MMU_64;
2636fb8b16aSPhilippe Mathieu-Daudé }
2646fb8b16aSPhilippe Mathieu-Daudé
2652bb53fa2SPhilippe Mathieu-Daudé /*****************************************************************************/
2662bb53fa2SPhilippe Mathieu-Daudé /* Input pins model */
2672bb53fa2SPhilippe Mathieu-Daudé typedef enum powerpc_input_t {
2682bb53fa2SPhilippe Mathieu-Daudé PPC_FLAGS_INPUT_UNKNOWN = 0,
2692bb53fa2SPhilippe Mathieu-Daudé /* PowerPC 6xx bus */
2702bb53fa2SPhilippe Mathieu-Daudé PPC_FLAGS_INPUT_6xx,
2712bb53fa2SPhilippe Mathieu-Daudé /* BookE bus */
2722bb53fa2SPhilippe Mathieu-Daudé PPC_FLAGS_INPUT_BookE,
2732bb53fa2SPhilippe Mathieu-Daudé /* PowerPC 405 bus */
2742bb53fa2SPhilippe Mathieu-Daudé PPC_FLAGS_INPUT_405,
2752bb53fa2SPhilippe Mathieu-Daudé /* PowerPC 970 bus */
2762bb53fa2SPhilippe Mathieu-Daudé PPC_FLAGS_INPUT_970,
2772bb53fa2SPhilippe Mathieu-Daudé /* PowerPC POWER7 bus */
2782bb53fa2SPhilippe Mathieu-Daudé PPC_FLAGS_INPUT_POWER7,
2792bb53fa2SPhilippe Mathieu-Daudé /* PowerPC POWER9 bus */
2802bb53fa2SPhilippe Mathieu-Daudé PPC_FLAGS_INPUT_POWER9,
2812bb53fa2SPhilippe Mathieu-Daudé /* Freescale RCPU bus */
2822bb53fa2SPhilippe Mathieu-Daudé PPC_FLAGS_INPUT_RCPU,
2832bb53fa2SPhilippe Mathieu-Daudé } powerpc_input_t;
2842bb53fa2SPhilippe Mathieu-Daudé
28525458103SBALATON Zoltan #define PPC_INPUT(env) ((env)->bus_model)
286fcf5ef2aSThomas Huth
287fcf5ef2aSThomas Huth /*****************************************************************************/
288fcf5ef2aSThomas Huth typedef struct opc_handler_t opc_handler_t;
289fcf5ef2aSThomas Huth
290fcf5ef2aSThomas Huth /*****************************************************************************/
2917222b94aSDavid Gibson /* Types used to describe some PowerPC registers etc. */
292fcf5ef2aSThomas Huth typedef struct DisasContext DisasContext;
293f3cb3325SPhilippe Mathieu-Daudé typedef struct ppc_dcr_t ppc_dcr_t;
294fcf5ef2aSThomas Huth typedef struct ppc_spr_t ppc_spr_t;
295f3cb3325SPhilippe Mathieu-Daudé typedef struct ppc_tb_t ppc_tb_t;
296fcf5ef2aSThomas Huth typedef union ppc_tlb_t ppc_tlb_t;
2971ad9f0a4SDavid Gibson typedef struct ppc_hash_pte64 ppc_hash_pte64_t;
298f3cb3325SPhilippe Mathieu-Daudé typedef struct PPCHash64Options PPCHash64Options;
299f3cb3325SPhilippe Mathieu-Daudé
300f3cb3325SPhilippe Mathieu-Daudé typedef struct CPUArchState CPUPPCState;
301fcf5ef2aSThomas Huth
302fcf5ef2aSThomas Huth /* SPR access micro-ops generations callbacks */
303fcf5ef2aSThomas Huth struct ppc_spr_t {
30472369f5cSRichard Henderson const char *name;
30572369f5cSRichard Henderson target_ulong default_value;
30672369f5cSRichard Henderson #ifndef CONFIG_USER_ONLY
30772369f5cSRichard Henderson unsigned int gdb_id;
30872369f5cSRichard Henderson #endif
30972369f5cSRichard Henderson #ifdef CONFIG_TCG
310fcf5ef2aSThomas Huth void (*uea_read)(DisasContext *ctx, int gpr_num, int spr_num);
311fcf5ef2aSThomas Huth void (*uea_write)(DisasContext *ctx, int spr_num, int gpr_num);
31272369f5cSRichard Henderson # ifndef CONFIG_USER_ONLY
313fcf5ef2aSThomas Huth void (*oea_read)(DisasContext *ctx, int gpr_num, int spr_num);
314fcf5ef2aSThomas Huth void (*oea_write)(DisasContext *ctx, int spr_num, int gpr_num);
315fcf5ef2aSThomas Huth void (*hea_read)(DisasContext *ctx, int gpr_num, int spr_num);
316fcf5ef2aSThomas Huth void (*hea_write)(DisasContext *ctx, int spr_num, int gpr_num);
317fcf5ef2aSThomas Huth # endif
31872369f5cSRichard Henderson #endif
319fcf5ef2aSThomas Huth #ifdef CONFIG_KVM
320c647e3feSDavid Gibson /*
321c647e3feSDavid Gibson * We (ab)use the fact that all the SPRs will have ids for the
322fcf5ef2aSThomas Huth * ONE_REG interface will have KVM_REG_PPC to use 0 as meaning,
323c647e3feSDavid Gibson * don't sync this
324c647e3feSDavid Gibson */
325fcf5ef2aSThomas Huth uint64_t one_reg_id;
326fcf5ef2aSThomas Huth #endif
327fcf5ef2aSThomas Huth };
328fcf5ef2aSThomas Huth
32905ee3e8aSMark Cave-Ayland /* VSX/Altivec registers (128 bits) */
33005ee3e8aSMark Cave-Ayland typedef union _ppc_vsr_t {
331fcf5ef2aSThomas Huth uint8_t u8[16];
332fcf5ef2aSThomas Huth uint16_t u16[8];
333fcf5ef2aSThomas Huth uint32_t u32[4];
33405ee3e8aSMark Cave-Ayland uint64_t u64[2];
335fcf5ef2aSThomas Huth int8_t s8[16];
336fcf5ef2aSThomas Huth int16_t s16[8];
337fcf5ef2aSThomas Huth int32_t s32[4];
338fcf5ef2aSThomas Huth int64_t s64[2];
3392d9cba74SLucas Mateus Castro (alqotel) float16 f16[8];
34005ee3e8aSMark Cave-Ayland float32 f32[4];
34105ee3e8aSMark Cave-Ayland float64 f64[2];
34205ee3e8aSMark Cave-Ayland float128 f128;
343fcf5ef2aSThomas Huth #ifdef CONFIG_INT128
344fcf5ef2aSThomas Huth __uint128_t u128;
345fcf5ef2aSThomas Huth #endif
34660caf221SAvinesh Kumar Int128 s128;
34705ee3e8aSMark Cave-Ayland } ppc_vsr_t;
34805ee3e8aSMark Cave-Ayland
34905ee3e8aSMark Cave-Ayland typedef ppc_vsr_t ppc_avr_t;
350d9acba31SMark Cave-Ayland typedef ppc_vsr_t ppc_fprp_t;
35134553153SLucas Mateus Castro (alqotel) typedef ppc_vsr_t ppc_acc_t;
352fcf5ef2aSThomas Huth
353fcf5ef2aSThomas Huth #if !defined(CONFIG_USER_ONLY)
354fcf5ef2aSThomas Huth /* Software TLB cache */
355fcf5ef2aSThomas Huth typedef struct ppc6xx_tlb_t ppc6xx_tlb_t;
356fcf5ef2aSThomas Huth struct ppc6xx_tlb_t {
357fcf5ef2aSThomas Huth target_ulong pte0;
358fcf5ef2aSThomas Huth target_ulong pte1;
359fcf5ef2aSThomas Huth target_ulong EPN;
360fcf5ef2aSThomas Huth };
361fcf5ef2aSThomas Huth
362fcf5ef2aSThomas Huth typedef struct ppcemb_tlb_t ppcemb_tlb_t;
363fcf5ef2aSThomas Huth struct ppcemb_tlb_t {
364fcf5ef2aSThomas Huth uint64_t RPN;
365fcf5ef2aSThomas Huth target_ulong EPN;
366fcf5ef2aSThomas Huth target_ulong PID;
367fcf5ef2aSThomas Huth target_ulong size;
368fcf5ef2aSThomas Huth uint32_t prot;
369fcf5ef2aSThomas Huth uint32_t attr; /* Storage attributes */
370fcf5ef2aSThomas Huth };
371fcf5ef2aSThomas Huth
372fcf5ef2aSThomas Huth typedef struct ppcmas_tlb_t {
373fcf5ef2aSThomas Huth uint32_t mas8;
374fcf5ef2aSThomas Huth uint32_t mas1;
375fcf5ef2aSThomas Huth uint64_t mas2;
376fcf5ef2aSThomas Huth uint64_t mas7_3;
377fcf5ef2aSThomas Huth } ppcmas_tlb_t;
378fcf5ef2aSThomas Huth
379fcf5ef2aSThomas Huth union ppc_tlb_t {
380fcf5ef2aSThomas Huth ppc6xx_tlb_t *tlb6;
381fcf5ef2aSThomas Huth ppcemb_tlb_t *tlbe;
382fcf5ef2aSThomas Huth ppcmas_tlb_t *tlbm;
383fcf5ef2aSThomas Huth };
384fcf5ef2aSThomas Huth
385fcf5ef2aSThomas Huth /* possible TLB variants */
386fcf5ef2aSThomas Huth #define TLB_NONE 0
387fcf5ef2aSThomas Huth #define TLB_6XX 1
388fcf5ef2aSThomas Huth #define TLB_EMB 2
389fcf5ef2aSThomas Huth #define TLB_MAS 3
390fcf5ef2aSThomas Huth #endif
391fcf5ef2aSThomas Huth
392b07c59f7SDavid Gibson typedef struct PPCHash64SegmentPageSizes PPCHash64SegmentPageSizes;
393b07c59f7SDavid Gibson
394fcf5ef2aSThomas Huth typedef struct ppc_slb_t ppc_slb_t;
395fcf5ef2aSThomas Huth struct ppc_slb_t {
396fcf5ef2aSThomas Huth uint64_t esid;
397fcf5ef2aSThomas Huth uint64_t vsid;
398b07c59f7SDavid Gibson const PPCHash64SegmentPageSizes *sps;
399fcf5ef2aSThomas Huth };
400fcf5ef2aSThomas Huth
401fcf5ef2aSThomas Huth #define MAX_SLB_ENTRIES 64
402fcf5ef2aSThomas Huth #define SEGMENT_SHIFT_256M 28
403fcf5ef2aSThomas Huth #define SEGMENT_MASK_256M (~((1ULL << SEGMENT_SHIFT_256M) - 1))
404fcf5ef2aSThomas Huth
405fcf5ef2aSThomas Huth #define SEGMENT_SHIFT_1T 40
406fcf5ef2aSThomas Huth #define SEGMENT_MASK_1T (~((1ULL << SEGMENT_SHIFT_1T) - 1))
407fcf5ef2aSThomas Huth
40879825f4dSBenjamin Herrenschmidt typedef struct ppc_v3_pate_t {
40979825f4dSBenjamin Herrenschmidt uint64_t dw0;
41079825f4dSBenjamin Herrenschmidt uint64_t dw1;
41179825f4dSBenjamin Herrenschmidt } ppc_v3_pate_t;
412fcf5ef2aSThomas Huth
4138f2e9d40SDaniel Henrique Barboza /* PMU related structs and defines */
4148f2e9d40SDaniel Henrique Barboza #define PMU_COUNTERS_NUM 6
4158f2e9d40SDaniel Henrique Barboza typedef enum {
4168f2e9d40SDaniel Henrique Barboza PMU_EVENT_INVALID = 0,
4178f2e9d40SDaniel Henrique Barboza PMU_EVENT_INACTIVE,
4188f2e9d40SDaniel Henrique Barboza PMU_EVENT_CYCLES,
4198f2e9d40SDaniel Henrique Barboza PMU_EVENT_INSTRUCTIONS,
4207aeac354SDaniel Henrique Barboza PMU_EVENT_INSN_RUN_LATCH,
4218f2e9d40SDaniel Henrique Barboza } PMUEventType;
4228f2e9d40SDaniel Henrique Barboza
423fcf5ef2aSThomas Huth /*****************************************************************************/
424fcf5ef2aSThomas Huth /* Machine state register bits definition */
425bf3dd1e6SVíctor Colombo #define MSR_SF PPC_BIT_NR(0) /* Sixty-four-bit mode hflags */
426bf3dd1e6SVíctor Colombo #define MSR_TAG PPC_BIT_NR(1) /* Tag-active mode (POWERx ?) */
427bf3dd1e6SVíctor Colombo #define MSR_ISF PPC_BIT_NR(2) /* Sixty-four-bit interrupt mode on 630 */
428bf3dd1e6SVíctor Colombo #define MSR_HV PPC_BIT_NR(3) /* hypervisor state hflags */
429bf3dd1e6SVíctor Colombo #define MSR_TS0 PPC_BIT_NR(29) /* Transactional state, 2 bits (Book3s) */
430bf3dd1e6SVíctor Colombo #define MSR_TS1 PPC_BIT_NR(30)
431bf3dd1e6SVíctor Colombo #define MSR_TM PPC_BIT_NR(31) /* Transactional Memory Available (Book3s) */
432bf3dd1e6SVíctor Colombo #define MSR_CM PPC_BIT_NR(32) /* Computation mode for BookE hflags */
433bf3dd1e6SVíctor Colombo #define MSR_ICM PPC_BIT_NR(33) /* Interrupt computation mode for BookE */
434bf3dd1e6SVíctor Colombo #define MSR_GS PPC_BIT_NR(35) /* guest state for BookE */
435bf3dd1e6SVíctor Colombo #define MSR_UCLE PPC_BIT_NR(37) /* User-mode cache lock enable for BookE */
436bf3dd1e6SVíctor Colombo #define MSR_VR PPC_BIT_NR(38) /* altivec available x hflags */
437bf3dd1e6SVíctor Colombo #define MSR_SPE PPC_BIT_NR(38) /* SPE enable for BookE x hflags */
438bf3dd1e6SVíctor Colombo #define MSR_VSX PPC_BIT_NR(40) /* Vector Scalar Extension (>= 2.06)x hflags */
439bf3dd1e6SVíctor Colombo #define MSR_S PPC_BIT_NR(41) /* Secure state */
440bf3dd1e6SVíctor Colombo #define MSR_KEY PPC_BIT_NR(44) /* key bit on 603e */
441bf3dd1e6SVíctor Colombo #define MSR_POW PPC_BIT_NR(45) /* Power management */
442bf3dd1e6SVíctor Colombo #define MSR_WE PPC_BIT_NR(45) /* Wait State Enable on 405 */
443bf3dd1e6SVíctor Colombo #define MSR_TGPR PPC_BIT_NR(46) /* TGPR usage on 602/603 x */
444bf3dd1e6SVíctor Colombo #define MSR_CE PPC_BIT_NR(46) /* Critical int. enable on embedded PPC x */
445bf3dd1e6SVíctor Colombo #define MSR_ILE PPC_BIT_NR(47) /* Interrupt little-endian mode */
446bf3dd1e6SVíctor Colombo #define MSR_EE PPC_BIT_NR(48) /* External interrupt enable */
447bf3dd1e6SVíctor Colombo #define MSR_PR PPC_BIT_NR(49) /* Problem state hflags */
448bf3dd1e6SVíctor Colombo #define MSR_FP PPC_BIT_NR(50) /* Floating point available hflags */
449bf3dd1e6SVíctor Colombo #define MSR_ME PPC_BIT_NR(51) /* Machine check interrupt enable */
450bf3dd1e6SVíctor Colombo #define MSR_FE0 PPC_BIT_NR(52) /* Floating point exception mode 0 */
451bf3dd1e6SVíctor Colombo #define MSR_SE PPC_BIT_NR(53) /* Single-step trace enable x hflags */
452bf3dd1e6SVíctor Colombo #define MSR_DWE PPC_BIT_NR(53) /* Debug wait enable on 405 x */
453bf3dd1e6SVíctor Colombo #define MSR_UBLE PPC_BIT_NR(53) /* User BTB lock enable on e500 x */
454bf3dd1e6SVíctor Colombo #define MSR_BE PPC_BIT_NR(54) /* Branch trace enable x hflags */
455bf3dd1e6SVíctor Colombo #define MSR_DE PPC_BIT_NR(54) /* Debug int. enable on embedded PPC x */
456bf3dd1e6SVíctor Colombo #define MSR_FE1 PPC_BIT_NR(55) /* Floating point exception mode 1 */
457bf3dd1e6SVíctor Colombo #define MSR_AL PPC_BIT_NR(56) /* AL bit on POWER */
458bf3dd1e6SVíctor Colombo #define MSR_EP PPC_BIT_NR(57) /* Exception prefix on 601 */
459bf3dd1e6SVíctor Colombo #define MSR_IR PPC_BIT_NR(58) /* Instruction relocate */
460bf3dd1e6SVíctor Colombo #define MSR_IS PPC_BIT_NR(58) /* Instruction address space (BookE) */
461bf3dd1e6SVíctor Colombo #define MSR_DR PPC_BIT_NR(59) /* Data relocate */
462bf3dd1e6SVíctor Colombo #define MSR_DS PPC_BIT_NR(59) /* Data address space (BookE) */
463bf3dd1e6SVíctor Colombo #define MSR_PE PPC_BIT_NR(60) /* Protection enable on 403 */
464bf3dd1e6SVíctor Colombo #define MSR_PX PPC_BIT_NR(61) /* Protection exclusive on 403 x */
465bf3dd1e6SVíctor Colombo #define MSR_PMM PPC_BIT_NR(61) /* Performance monitor mark on POWER x */
466bf3dd1e6SVíctor Colombo #define MSR_RI PPC_BIT_NR(62) /* Recoverable interrupt 1 */
467bf3dd1e6SVíctor Colombo #define MSR_LE PPC_BIT_NR(63) /* Little-endian mode 1 hflags */
468fcf5ef2aSThomas Huth
46939af1384SVíctor Colombo FIELD(MSR, SF, MSR_SF, 1)
47039af1384SVíctor Colombo FIELD(MSR, TAG, MSR_TAG, 1)
47139af1384SVíctor Colombo FIELD(MSR, ISF, MSR_ISF, 1)
4729de754d3SVíctor Colombo #if defined(TARGET_PPC64)
4739de754d3SVíctor Colombo FIELD(MSR, HV, MSR_HV, 1)
4749de754d3SVíctor Colombo #define FIELD_EX64_HV(storage) FIELD_EX64(storage, MSR, HV)
4759de754d3SVíctor Colombo #else
4769de754d3SVíctor Colombo #define FIELD_EX64_HV(storage) 0
4779de754d3SVíctor Colombo #endif
47839af1384SVíctor Colombo FIELD(MSR, TS0, MSR_TS0, 1)
47939af1384SVíctor Colombo FIELD(MSR, TS1, MSR_TS1, 1)
480ca241959SVíctor Colombo FIELD(MSR, TS, MSR_TS0, 2)
48139af1384SVíctor Colombo FIELD(MSR, TM, MSR_TM, 1)
482cda23360SVíctor Colombo FIELD(MSR, CM, MSR_CM, 1)
48339af1384SVíctor Colombo FIELD(MSR, ICM, MSR_ICM, 1)
48410b2b373SVíctor Colombo FIELD(MSR, GS, MSR_GS, 1)
48539af1384SVíctor Colombo FIELD(MSR, UCLE, MSR_UCLE, 1)
48639af1384SVíctor Colombo FIELD(MSR, VR, MSR_VR, 1)
48739af1384SVíctor Colombo FIELD(MSR, SPE, MSR_SPE, 1)
48839af1384SVíctor Colombo FIELD(MSR, VSX, MSR_VSX, 1)
48939af1384SVíctor Colombo FIELD(MSR, S, MSR_S, 1)
49039af1384SVíctor Colombo FIELD(MSR, KEY, MSR_KEY, 1)
4918e54ad65SVíctor Colombo FIELD(MSR, POW, MSR_POW, 1)
49239af1384SVíctor Colombo FIELD(MSR, WE, MSR_WE, 1)
49339af1384SVíctor Colombo FIELD(MSR, TGPR, MSR_TGPR, 1)
494acc861c2SVíctor Colombo FIELD(MSR, CE, MSR_CE, 1)
4953868540fSVíctor Colombo FIELD(MSR, ILE, MSR_ILE, 1)
4960939b8f8SVíctor Colombo FIELD(MSR, EE, MSR_EE, 1)
497d41ccf6eSVíctor Colombo FIELD(MSR, PR, MSR_PR, 1)
49839695e15SVíctor Colombo FIELD(MSR, FP, MSR_FP, 1)
499c354d858SVíctor Colombo FIELD(MSR, ME, MSR_ME, 1)
500da806a6cSVíctor Colombo FIELD(MSR, FE0, MSR_FE0, 1)
50139af1384SVíctor Colombo FIELD(MSR, SE, MSR_SE, 1)
50239af1384SVíctor Colombo FIELD(MSR, DWE, MSR_DWE, 1)
50339af1384SVíctor Colombo FIELD(MSR, UBLE, MSR_UBLE, 1)
50439af1384SVíctor Colombo FIELD(MSR, BE, MSR_BE, 1)
50567935ecdSVíctor Colombo FIELD(MSR, DE, MSR_DE, 1)
506da806a6cSVíctor Colombo FIELD(MSR, FE1, MSR_FE1, 1)
50739af1384SVíctor Colombo FIELD(MSR, AL, MSR_AL, 1)
50850242330SVíctor Colombo FIELD(MSR, EP, MSR_EP, 1)
5094d979c9fSVíctor Colombo FIELD(MSR, IR, MSR_IR, 1)
510e4eea6efSVíctor Colombo FIELD(MSR, DR, MSR_DR, 1)
51139af1384SVíctor Colombo FIELD(MSR, IS, MSR_IS, 1)
51226363616SVíctor Colombo FIELD(MSR, DS, MSR_DS, 1)
51339af1384SVíctor Colombo FIELD(MSR, PE, MSR_PE, 1)
51439af1384SVíctor Colombo FIELD(MSR, PX, MSR_PX, 1)
51539af1384SVíctor Colombo FIELD(MSR, PMM, MSR_PMM, 1)
51639af1384SVíctor Colombo FIELD(MSR, RI, MSR_RI, 1)
5171922322cSVíctor Colombo FIELD(MSR, LE, MSR_LE, 1)
518d41ccf6eSVíctor Colombo
519da806a6cSVíctor Colombo /*
520da806a6cSVíctor Colombo * FE0 and FE1 bits are not side-by-side
521da806a6cSVíctor Colombo * so we can't combine them using FIELD()
522da806a6cSVíctor Colombo */
523da806a6cSVíctor Colombo #define FIELD_EX64_FE(msr) \
524da806a6cSVíctor Colombo ((FIELD_EX64(msr, MSR, FE0) << 1) | FIELD_EX64(msr, MSR, FE1))
525da806a6cSVíctor Colombo
526f7460df2SDaniel Henrique Barboza /* PMU bits */
527565cb109SGustavo Romero #define MMCR0_FC PPC_BIT(32) /* Freeze Counters */
528e6a19a64SMichael Tokarev #define MMCR0_PMAO PPC_BIT(56) /* Perf Monitor Alert Occurred */
529565cb109SGustavo Romero #define MMCR0_PMAE PPC_BIT(37) /* Perf Monitor Alert Enable */
530565cb109SGustavo Romero #define MMCR0_EBE PPC_BIT(43) /* Perf Monitor EBB Enable */
531565cb109SGustavo Romero #define MMCR0_FCECE PPC_BIT(38) /* FC on Enabled Cond or Event */
532f7460df2SDaniel Henrique Barboza #define MMCR0_PMCC0 PPC_BIT(44) /* PMC Control bit 0 */
533f7460df2SDaniel Henrique Barboza #define MMCR0_PMCC1 PPC_BIT(45) /* PMC Control bit 1 */
534c2eff582SDaniel Henrique Barboza #define MMCR0_PMCC PPC_BITMASK(44, 45) /* PMC Control */
535c2eff582SDaniel Henrique Barboza #define MMCR0_FC14 PPC_BIT(58) /* PMC Freeze Counters 1-4 bit */
536c2eff582SDaniel Henrique Barboza #define MMCR0_FC56 PPC_BIT(59) /* PMC Freeze Counters 5-6 bit */
5371474ba6dSDaniel Henrique Barboza #define MMCR0_PMC1CE PPC_BIT(48) /* MMCR0 PMC1 Condition Enabled */
5381474ba6dSDaniel Henrique Barboza #define MMCR0_PMCjCE PPC_BIT(49) /* MMCR0 PMCj Condition Enabled */
539a7138e28SGlenn Miles #define MMCR0_FCP PPC_BIT(34) /* Freeze Counters/BHRB if PR=1 */
540a7138e28SGlenn Miles #define MMCR0_FCPC PPC_BIT(51) /* Condition for FCP bit */
5416bfcf1dcSGlenn Miles #define MMCR0_BHRBA_NR PPC_BIT_NR(42) /* BHRB Available */
542565cb109SGustavo Romero /* MMCR0 userspace r/w mask */
543565cb109SGustavo Romero #define MMCR0_UREG_MASK (MMCR0_FC | MMCR0_PMAO | MMCR0_PMAE)
5447b3ecf16SDaniel Henrique Barboza /* MMCR2 userspace r/w mask */
5457b3ecf16SDaniel Henrique Barboza #define MMCR2_FC1P0 PPC_BIT(1) /* MMCR2 FCnP0 for PMC1 */
5467b3ecf16SDaniel Henrique Barboza #define MMCR2_FC2P0 PPC_BIT(10) /* MMCR2 FCnP0 for PMC2 */
5477b3ecf16SDaniel Henrique Barboza #define MMCR2_FC3P0 PPC_BIT(19) /* MMCR2 FCnP0 for PMC3 */
5487b3ecf16SDaniel Henrique Barboza #define MMCR2_FC4P0 PPC_BIT(28) /* MMCR2 FCnP0 for PMC4 */
5497b3ecf16SDaniel Henrique Barboza #define MMCR2_FC5P0 PPC_BIT(37) /* MMCR2 FCnP0 for PMC5 */
5507b3ecf16SDaniel Henrique Barboza #define MMCR2_FC6P0 PPC_BIT(46) /* MMCR2 FCnP0 for PMC6 */
5517b3ecf16SDaniel Henrique Barboza #define MMCR2_UREG_MASK (MMCR2_FC1P0 | MMCR2_FC2P0 | MMCR2_FC3P0 | \
5527b3ecf16SDaniel Henrique Barboza MMCR2_FC4P0 | MMCR2_FC5P0 | MMCR2_FC6P0)
553f7460df2SDaniel Henrique Barboza
554a7138e28SGlenn Miles #define MMCRA_BHRBRD PPC_BIT(26) /* BHRB Recording Disable */
5554de4a470SGlenn Miles #define MMCRA_IFM_MASK PPC_BITMASK(32, 33) /* BHRB Instruction Filtering */
5564de4a470SGlenn Miles #define MMCRA_IFM_SHIFT PPC_BIT_NR(33)
557a7138e28SGlenn Miles
558c2eff582SDaniel Henrique Barboza #define MMCR1_EVT_SIZE 8
559c2eff582SDaniel Henrique Barboza /* extract64() does a right shift before extracting */
560c2eff582SDaniel Henrique Barboza #define MMCR1_PMC1SEL_START 32
561c2eff582SDaniel Henrique Barboza #define MMCR1_PMC1EVT_EXTR (64 - MMCR1_PMC1SEL_START - MMCR1_EVT_SIZE)
562c2eff582SDaniel Henrique Barboza #define MMCR1_PMC2SEL_START 40
563c2eff582SDaniel Henrique Barboza #define MMCR1_PMC2EVT_EXTR (64 - MMCR1_PMC2SEL_START - MMCR1_EVT_SIZE)
564c2eff582SDaniel Henrique Barboza #define MMCR1_PMC3SEL_START 48
565c2eff582SDaniel Henrique Barboza #define MMCR1_PMC3EVT_EXTR (64 - MMCR1_PMC3SEL_START - MMCR1_EVT_SIZE)
566c2eff582SDaniel Henrique Barboza #define MMCR1_PMC4SEL_START 56
567c2eff582SDaniel Henrique Barboza #define MMCR1_PMC4EVT_EXTR (64 - MMCR1_PMC4SEL_START - MMCR1_EVT_SIZE)
568c2eff582SDaniel Henrique Barboza
5697aeac354SDaniel Henrique Barboza /* PMU uses CTRL_RUN to sample PM_RUN_INST_CMPL */
5707aeac354SDaniel Henrique Barboza #define CTRL_RUN PPC_BIT(63)
5717aeac354SDaniel Henrique Barboza
5721f26c751SDaniel Henrique Barboza /* EBB/BESCR bits */
5731f26c751SDaniel Henrique Barboza /* Global Enable */
5741f26c751SDaniel Henrique Barboza #define BESCR_GE PPC_BIT(0)
5751f26c751SDaniel Henrique Barboza /* External Event-based Exception Enable */
5761f26c751SDaniel Henrique Barboza #define BESCR_EE PPC_BIT(30)
5771f26c751SDaniel Henrique Barboza /* Performance Monitor Event-based Exception Enable */
5781f26c751SDaniel Henrique Barboza #define BESCR_PME PPC_BIT(31)
5791f26c751SDaniel Henrique Barboza /* External Event-based Exception Occurred */
5801f26c751SDaniel Henrique Barboza #define BESCR_EEO PPC_BIT(62)
5811f26c751SDaniel Henrique Barboza /* Performance Monitor Event-based Exception Occurred */
5821f26c751SDaniel Henrique Barboza #define BESCR_PMEO PPC_BIT(63)
5831f26c751SDaniel Henrique Barboza #define BESCR_INVALID PPC_BITMASK(32, 33)
5841f26c751SDaniel Henrique Barboza
585fcf5ef2aSThomas Huth /* LPCR bits */
5862a83f997SCédric Le Goater #define LPCR_VPM0 PPC_BIT(0)
5872a83f997SCédric Le Goater #define LPCR_VPM1 PPC_BIT(1)
5882a83f997SCédric Le Goater #define LPCR_ISL PPC_BIT(2)
5892a83f997SCédric Le Goater #define LPCR_KBV PPC_BIT(3)
590fcf5ef2aSThomas Huth #define LPCR_DPFD_SHIFT (63 - 11)
5917659ca1aSSuraj Jitindar Singh #define LPCR_DPFD (0x7ull << LPCR_DPFD_SHIFT)
592fcf5ef2aSThomas Huth #define LPCR_VRMASD_SHIFT (63 - 16)
593fcf5ef2aSThomas Huth #define LPCR_VRMASD (0x1full << LPCR_VRMASD_SHIFT)
59418aa49ecSSuraj Jitindar Singh /* P9: Power-saving mode Exit Cause Enable (Upper Section) Mask */
59518aa49ecSSuraj Jitindar Singh #define LPCR_PECE_U_SHIFT (63 - 19)
59618aa49ecSSuraj Jitindar Singh #define LPCR_PECE_U_MASK (0x7ull << LPCR_PECE_U_SHIFT)
5972a83f997SCédric Le Goater #define LPCR_HVEE PPC_BIT(17) /* Hypervisor Virt Exit Enable */
598526cdce7SNicholas Piggin #define LPCR_RMLS_SHIFT (63 - 37) /* RMLS (removed in ISA v3.0) */
599fcf5ef2aSThomas Huth #define LPCR_RMLS (0xfull << LPCR_RMLS_SHIFT)
600526cdce7SNicholas Piggin #define LPCR_HAIL PPC_BIT(37) /* ISA v3.1 HV AIL=3 equivalent */
6012a83f997SCédric Le Goater #define LPCR_ILE PPC_BIT(38)
602fcf5ef2aSThomas Huth #define LPCR_AIL_SHIFT (63 - 40) /* Alternate interrupt location */
603fcf5ef2aSThomas Huth #define LPCR_AIL (3ull << LPCR_AIL_SHIFT)
6042a83f997SCédric Le Goater #define LPCR_UPRT PPC_BIT(41) /* Use Process Table */
6052a83f997SCédric Le Goater #define LPCR_EVIRT PPC_BIT(42) /* Enhanced Virtualisation */
60600fd075eSBenjamin Herrenschmidt #define LPCR_HR PPC_BIT(43) /* Host Radix */
6072a83f997SCédric Le Goater #define LPCR_ONL PPC_BIT(45)
6082a83f997SCédric Le Goater #define LPCR_LD PPC_BIT(46) /* Large Decrementer */
6092a83f997SCédric Le Goater #define LPCR_P7_PECE0 PPC_BIT(49)
6102a83f997SCédric Le Goater #define LPCR_P7_PECE1 PPC_BIT(50)
6112a83f997SCédric Le Goater #define LPCR_P7_PECE2 PPC_BIT(51)
6122a83f997SCédric Le Goater #define LPCR_P8_PECE0 PPC_BIT(47)
6132a83f997SCédric Le Goater #define LPCR_P8_PECE1 PPC_BIT(48)
6142a83f997SCédric Le Goater #define LPCR_P8_PECE2 PPC_BIT(49)
6152a83f997SCédric Le Goater #define LPCR_P8_PECE3 PPC_BIT(50)
6162a83f997SCédric Le Goater #define LPCR_P8_PECE4 PPC_BIT(51)
61718aa49ecSSuraj Jitindar Singh /* P9: Power-saving mode Exit Cause Enable (Lower Section) Mask */
61818aa49ecSSuraj Jitindar Singh #define LPCR_PECE_L_SHIFT (63 - 51)
61918aa49ecSSuraj Jitindar Singh #define LPCR_PECE_L_MASK (0x1full << LPCR_PECE_L_SHIFT)
6202a83f997SCédric Le Goater #define LPCR_PDEE PPC_BIT(47) /* Privileged Doorbell Exit EN */
6212a83f997SCédric Le Goater #define LPCR_HDEE PPC_BIT(48) /* Hyperv Doorbell Exit Enable */
6222a83f997SCédric Le Goater #define LPCR_EEE PPC_BIT(49) /* External Exit Enable */
6232a83f997SCédric Le Goater #define LPCR_DEE PPC_BIT(50) /* Decrementer Exit Enable */
6242a83f997SCédric Le Goater #define LPCR_OEE PPC_BIT(51) /* Other Exit Enable */
6252a83f997SCédric Le Goater #define LPCR_MER PPC_BIT(52)
6262a83f997SCédric Le Goater #define LPCR_GTSE PPC_BIT(53) /* Guest Translation Shootdown */
6272a83f997SCédric Le Goater #define LPCR_TC PPC_BIT(54)
6282a83f997SCédric Le Goater #define LPCR_HEIC PPC_BIT(59) /* HV Extern Interrupt Control */
6292a83f997SCédric Le Goater #define LPCR_LPES0 PPC_BIT(60)
6302a83f997SCédric Le Goater #define LPCR_LPES1 PPC_BIT(61)
6312a83f997SCédric Le Goater #define LPCR_RMI PPC_BIT(62)
6322a83f997SCédric Le Goater #define LPCR_HVICE PPC_BIT(62) /* HV Virtualisation Int Enable */
6332a83f997SCédric Le Goater #define LPCR_HDICE PPC_BIT(63)
634fcf5ef2aSThomas Huth
63521c0d66aSBenjamin Herrenschmidt /* PSSCR bits */
63621c0d66aSBenjamin Herrenschmidt #define PSSCR_ESL PPC_BIT(42) /* Enable State Loss */
63721c0d66aSBenjamin Herrenschmidt #define PSSCR_EC PPC_BIT(43) /* Exit Criterion */
63821c0d66aSBenjamin Herrenschmidt
639493028d8SCédric Le Goater /* HFSCR bits */
64087de77f6SNicholas Piggin #define HFSCR_MSGP PPC_BIT_NR(53) /* Privileged Message Send Facilities */
64187de77f6SNicholas Piggin #define HFSCR_BHRB PPC_BIT_NR(59) /* BHRB Instructions */
642493028d8SCédric Le Goater #define HFSCR_IC_MSGP 0xA
643493028d8SCédric Le Goater
6440e3bf489SRoman Kapl #define DBCR0_ICMP (1 << 27)
6450e3bf489SRoman Kapl #define DBCR0_BRT (1 << 26)
6460e3bf489SRoman Kapl #define DBSR_ICMP (1 << 27)
6470e3bf489SRoman Kapl #define DBSR_BRT (1 << 26)
6480e3bf489SRoman Kapl
649fcf5ef2aSThomas Huth /* Hypervisor bit is more specific */
650fcf5ef2aSThomas Huth #if defined(TARGET_PPC64)
65123513f81SDavid Gibson #define MSR_HVB (1ULL << MSR_HV)
652fcf5ef2aSThomas Huth #else
653fcf5ef2aSThomas Huth #define MSR_HVB (0ULL)
654fcf5ef2aSThomas Huth #endif
655fcf5ef2aSThomas Huth
656da82c73aSSuraj Jitindar Singh /* DSISR */
657da82c73aSSuraj Jitindar Singh #define DSISR_NOPTE 0x40000000
658da82c73aSSuraj Jitindar Singh /* Not permitted by access authority of encoded access authority */
659da82c73aSSuraj Jitindar Singh #define DSISR_PROTFAULT 0x08000000
660da82c73aSSuraj Jitindar Singh #define DSISR_ISSTORE 0x02000000
661da82c73aSSuraj Jitindar Singh /* Not permitted by virtual page class key protection */
662da82c73aSSuraj Jitindar Singh #define DSISR_AMR 0x00200000
663d5fee0bbSSuraj Jitindar Singh /* Unsupported Radix Tree Configuration */
664d5fee0bbSSuraj Jitindar Singh #define DSISR_R_BADCONFIG 0x00080000
665d04ea940SCédric Le Goater #define DSISR_ATOMIC_RC 0x00040000
666d04ea940SCédric Le Goater /* Unable to translate address of (guest) pde or process/page table entry */
667d04ea940SCédric Le Goater #define DSISR_PRTABLE_FAULT 0x00020000
668da82c73aSSuraj Jitindar Singh
669a6152b52SSuraj Jitindar Singh /* SRR1 error code fields */
670a6152b52SSuraj Jitindar Singh
671da82c73aSSuraj Jitindar Singh #define SRR1_NOPTE DSISR_NOPTE
672da82c73aSSuraj Jitindar Singh /* Not permitted due to no-execute or guard bit set */
67307a68f99SSuraj Jitindar Singh #define SRR1_NOEXEC_GUARD 0x10000000
674da82c73aSSuraj Jitindar Singh #define SRR1_PROTFAULT DSISR_PROTFAULT
675da82c73aSSuraj Jitindar Singh #define SRR1_IAMR DSISR_AMR
676a6152b52SSuraj Jitindar Singh
6770911a60cSLeonardo Bras /* SRR1[42:45] wakeup fields for System Reset Interrupt */
6780911a60cSLeonardo Bras
6790911a60cSLeonardo Bras #define SRR1_WAKEMASK 0x003c0000 /* reason for wakeup */
6800911a60cSLeonardo Bras
6810911a60cSLeonardo Bras #define SRR1_WAKEHMI 0x00280000 /* Hypervisor maintenance */
6820911a60cSLeonardo Bras #define SRR1_WAKEHVI 0x00240000 /* Hypervisor Virt. Interrupt (P9) */
6830911a60cSLeonardo Bras #define SRR1_WAKEEE 0x00200000 /* External interrupt */
6840911a60cSLeonardo Bras #define SRR1_WAKEDEC 0x00180000 /* Decrementer interrupt */
6850911a60cSLeonardo Bras #define SRR1_WAKEDBELL 0x00140000 /* Privileged doorbell */
6860911a60cSLeonardo Bras #define SRR1_WAKERESET 0x00100000 /* System reset */
6870911a60cSLeonardo Bras #define SRR1_WAKEHDBELL 0x000c0000 /* Hypervisor doorbell */
6880911a60cSLeonardo Bras #define SRR1_WAKESCOM 0x00080000 /* SCOM not in power-saving mode */
6890911a60cSLeonardo Bras
6900911a60cSLeonardo Bras /* SRR1[46:47] power-saving exit mode */
6910911a60cSLeonardo Bras
6920911a60cSLeonardo Bras #define SRR1_WAKESTATE 0x00030000 /* Powersave exit mask */
6930911a60cSLeonardo Bras
6940911a60cSLeonardo Bras #define SRR1_WS_HVLOSS 0x00030000 /* HV resources not maintained */
6950911a60cSLeonardo Bras #define SRR1_WS_GPRLOSS 0x00020000 /* GPRs not maintained */
6960911a60cSLeonardo Bras #define SRR1_WS_NOLOSS 0x00010000 /* All resources maintained */
6970911a60cSLeonardo Bras
698fcf5ef2aSThomas Huth /* Facility Status and Control (FSCR) bits */
699fcf5ef2aSThomas Huth #define FSCR_EBB (63 - 56) /* Event-Based Branch Facility */
700fcf5ef2aSThomas Huth #define FSCR_TAR (63 - 55) /* Target Address Register */
7013c89b8d6SNicholas Piggin #define FSCR_SCV (63 - 51) /* System call vectored */
702fcf5ef2aSThomas Huth /* Interrupt cause mask and position in FSCR. HFSCR has the same format */
703fcf5ef2aSThomas Huth #define FSCR_IC_MASK (0xFFULL)
704fcf5ef2aSThomas Huth #define FSCR_IC_POS (63 - 7)
705fcf5ef2aSThomas Huth #define FSCR_IC_DSCR_SPR3 2
706fcf5ef2aSThomas Huth #define FSCR_IC_PMU 3
707fcf5ef2aSThomas Huth #define FSCR_IC_BHRB 4
708fcf5ef2aSThomas Huth #define FSCR_IC_TM 5
709fcf5ef2aSThomas Huth #define FSCR_IC_EBB 7
710fcf5ef2aSThomas Huth #define FSCR_IC_TAR 8
7113c89b8d6SNicholas Piggin #define FSCR_IC_SCV 12
712fcf5ef2aSThomas Huth
713fcf5ef2aSThomas Huth /* Exception state register bits definition */
7142a83f997SCédric Le Goater #define ESR_PIL PPC_BIT(36) /* Illegal Instruction */
7152a83f997SCédric Le Goater #define ESR_PPR PPC_BIT(37) /* Privileged Instruction */
7162a83f997SCédric Le Goater #define ESR_PTR PPC_BIT(38) /* Trap */
7172a83f997SCédric Le Goater #define ESR_FP PPC_BIT(39) /* Floating-Point Operation */
7182a83f997SCédric Le Goater #define ESR_ST PPC_BIT(40) /* Store Operation */
7192a83f997SCédric Le Goater #define ESR_AP PPC_BIT(44) /* Auxiliary Processor Operation */
7202a83f997SCédric Le Goater #define ESR_PUO PPC_BIT(45) /* Unimplemented Operation */
7212a83f997SCédric Le Goater #define ESR_BO PPC_BIT(46) /* Byte Ordering */
7222a83f997SCédric Le Goater #define ESR_PIE PPC_BIT(47) /* Imprecise exception */
7232a83f997SCédric Le Goater #define ESR_DATA PPC_BIT(53) /* Data Access (Embedded page table) */
7242a83f997SCédric Le Goater #define ESR_TLBI PPC_BIT(54) /* TLB Ineligible (Embedded page table) */
7252a83f997SCédric Le Goater #define ESR_PT PPC_BIT(55) /* Page Table (Embedded page table) */
7262a83f997SCédric Le Goater #define ESR_SPV PPC_BIT(56) /* SPE/VMX operation */
7272a83f997SCédric Le Goater #define ESR_EPID PPC_BIT(57) /* External Process ID operation */
7282a83f997SCédric Le Goater #define ESR_VLEMI PPC_BIT(58) /* VLE operation */
7292a83f997SCédric Le Goater #define ESR_MIF PPC_BIT(62) /* Misaligned instruction (VLE) */
730fcf5ef2aSThomas Huth
731fcf5ef2aSThomas Huth /* Transaction EXception And Summary Register bits */
732fcf5ef2aSThomas Huth #define TEXASR_FAILURE_PERSISTENT (63 - 7)
733fcf5ef2aSThomas Huth #define TEXASR_DISALLOWED (63 - 8)
734fcf5ef2aSThomas Huth #define TEXASR_NESTING_OVERFLOW (63 - 9)
735fcf5ef2aSThomas Huth #define TEXASR_FOOTPRINT_OVERFLOW (63 - 10)
736fcf5ef2aSThomas Huth #define TEXASR_SELF_INDUCED_CONFLICT (63 - 11)
737fcf5ef2aSThomas Huth #define TEXASR_NON_TRANSACTIONAL_CONFLICT (63 - 12)
738fcf5ef2aSThomas Huth #define TEXASR_TRANSACTION_CONFLICT (63 - 13)
739fcf5ef2aSThomas Huth #define TEXASR_TRANSLATION_INVALIDATION_CONFLICT (63 - 14)
740fcf5ef2aSThomas Huth #define TEXASR_IMPLEMENTATION_SPECIFIC (63 - 15)
741fcf5ef2aSThomas Huth #define TEXASR_INSTRUCTION_FETCH_CONFLICT (63 - 16)
742fcf5ef2aSThomas Huth #define TEXASR_ABORT (63 - 31)
743fcf5ef2aSThomas Huth #define TEXASR_SUSPENDED (63 - 32)
744fcf5ef2aSThomas Huth #define TEXASR_PRIVILEGE_HV (63 - 34)
745fcf5ef2aSThomas Huth #define TEXASR_PRIVILEGE_PR (63 - 35)
746fcf5ef2aSThomas Huth #define TEXASR_FAILURE_SUMMARY (63 - 36)
747fcf5ef2aSThomas Huth #define TEXASR_TFIAR_EXACT (63 - 37)
748fcf5ef2aSThomas Huth #define TEXASR_ROT (63 - 38)
749fcf5ef2aSThomas Huth #define TEXASR_TRANSACTION_LEVEL (63 - 52) /* 12 bits */
750fcf5ef2aSThomas Huth
751fcf5ef2aSThomas Huth enum {
752fcf5ef2aSThomas Huth POWERPC_FLAG_NONE = 0x00000000,
753fcf5ef2aSThomas Huth /* Flag for MSR bit 25 signification (VRE/SPE) */
754fcf5ef2aSThomas Huth POWERPC_FLAG_SPE = 0x00000001,
755fcf5ef2aSThomas Huth POWERPC_FLAG_VRE = 0x00000002,
756fcf5ef2aSThomas Huth /* Flag for MSR bit 17 signification (TGPR/CE) */
757fcf5ef2aSThomas Huth POWERPC_FLAG_TGPR = 0x00000004,
758fcf5ef2aSThomas Huth POWERPC_FLAG_CE = 0x00000008,
759fcf5ef2aSThomas Huth /* Flag for MSR bit 10 signification (SE/DWE/UBLE) */
760fcf5ef2aSThomas Huth POWERPC_FLAG_SE = 0x00000010,
761fcf5ef2aSThomas Huth POWERPC_FLAG_DWE = 0x00000020,
762fcf5ef2aSThomas Huth POWERPC_FLAG_UBLE = 0x00000040,
763fcf5ef2aSThomas Huth /* Flag for MSR bit 9 signification (BE/DE) */
764fcf5ef2aSThomas Huth POWERPC_FLAG_BE = 0x00000080,
765fcf5ef2aSThomas Huth POWERPC_FLAG_DE = 0x00000100,
766fcf5ef2aSThomas Huth /* Flag for MSR bit 2 signification (PX/PMM) */
767fcf5ef2aSThomas Huth POWERPC_FLAG_PX = 0x00000200,
768fcf5ef2aSThomas Huth POWERPC_FLAG_PMM = 0x00000400,
769fcf5ef2aSThomas Huth /* Flag for special features */
770005b69fdSCédric Le Goater /* Decrementer clock */
771fcf5ef2aSThomas Huth POWERPC_FLAG_BUS_CLK = 0x00020000,
772fcf5ef2aSThomas Huth /* Has CFAR */
773fcf5ef2aSThomas Huth POWERPC_FLAG_CFAR = 0x00040000,
774fcf5ef2aSThomas Huth /* Has VSX */
775fcf5ef2aSThomas Huth POWERPC_FLAG_VSX = 0x00080000,
776fcf5ef2aSThomas Huth /* Has Transaction Memory (ISA 2.07) */
777fcf5ef2aSThomas Huth POWERPC_FLAG_TM = 0x00100000,
7783c89b8d6SNicholas Piggin /* Has SCV (ISA 3.00) */
7793c89b8d6SNicholas Piggin POWERPC_FLAG_SCV = 0x00200000,
780b769d4c8SNicholas Piggin /* Has >1 thread per core */
781b769d4c8SNicholas Piggin POWERPC_FLAG_SMT = 0x00400000,
7823401ea3cSNicholas Piggin /* Using "LPAR per core" mode (as opposed to per-thread) */
7833401ea3cSNicholas Piggin POWERPC_FLAG_SMT_1LPAR = 0x00800000,
7844de4a470SGlenn Miles /* Has BHRB */
7854de4a470SGlenn Miles POWERPC_FLAG_BHRB = 0x01000000,
786fcf5ef2aSThomas Huth };
787fcf5ef2aSThomas Huth
7882df4fe7aSRichard Henderson /*
7892df4fe7aSRichard Henderson * Bits for env->hflags.
7902df4fe7aSRichard Henderson *
7912df4fe7aSRichard Henderson * Most of these bits overlap with corresponding bits in MSR,
7922df4fe7aSRichard Henderson * but some come from other sources. Those that do come from
7932df4fe7aSRichard Henderson * the MSR are validated in hreg_compute_hflags.
7942df4fe7aSRichard Henderson */
7952df4fe7aSRichard Henderson enum {
796005b69fdSCédric Le Goater HFLAGS_LE = 0, /* MSR_LE */
7972df4fe7aSRichard Henderson HFLAGS_HV = 1, /* computed from MSR_HV and other state */
7982df4fe7aSRichard Henderson HFLAGS_64 = 2, /* computed from MSR_CE and MSR_SF */
799f03de3b4SRichard Henderson HFLAGS_GTSE = 3, /* computed from SPR_LPCR[GTSE] */
8002df4fe7aSRichard Henderson HFLAGS_DR = 4, /* MSR_DR */
8011db3632aSMatheus Ferst HFLAGS_HR = 5, /* computed from SPR_LPCR[HR] */
8022df4fe7aSRichard Henderson HFLAGS_SPE = 6, /* from MSR_SPE if cpu has SPE; avoid overlap w/ MSR_VR */
8032df4fe7aSRichard Henderson HFLAGS_TM = 8, /* computed from MSR_TM */
8042df4fe7aSRichard Henderson HFLAGS_BE = 9, /* MSR_BE -- from elsewhere on embedded ppc */
8052df4fe7aSRichard Henderson HFLAGS_SE = 10, /* MSR_SE -- from elsewhere on embedded ppc */
8062df4fe7aSRichard Henderson HFLAGS_FP = 13, /* MSR_FP */
8072df4fe7aSRichard Henderson HFLAGS_PR = 14, /* MSR_PR */
808f7460df2SDaniel Henrique Barboza HFLAGS_PMCC0 = 15, /* MMCR0 PMCC bit 0 */
809f7460df2SDaniel Henrique Barboza HFLAGS_PMCC1 = 16, /* MMCR0 PMCC bit 1 */
8108b3d1c49SLeandro Lupori HFLAGS_PMCJCE = 17, /* MMCR0 PMCjCE bit */
8118b3d1c49SLeandro Lupori HFLAGS_PMC_OTHER = 18, /* PMC other than PMC5-6 is enabled */
8128b3d1c49SLeandro Lupori HFLAGS_INSN_CNT = 19, /* PMU instruction count enabled */
813a7138e28SGlenn Miles HFLAGS_BHRB_ENABLE = 20, /* Summary flag for enabling BHRB */
8140e6bac3eSRichard Henderson HFLAGS_VSX = 23, /* MSR_VSX if cpu has VSX */
8152df4fe7aSRichard Henderson HFLAGS_VR = 25, /* MSR_VR if cpu has VRE */
816d764184dSRichard Henderson
817d764184dSRichard Henderson HFLAGS_IMMU_IDX = 26, /* 26..28 -- the composite immu_idx */
818d764184dSRichard Henderson HFLAGS_DMMU_IDX = 29, /* 29..31 -- the composite dmmu_idx */
8192df4fe7aSRichard Henderson };
8202df4fe7aSRichard Henderson
821fcf5ef2aSThomas Huth /*****************************************************************************/
822fcf5ef2aSThomas Huth /* Floating point status and control register */
82359f11543SVíctor Colombo #define FPSCR_DRN2 PPC_BIT_NR(29) /* Decimal Floating-Point rounding ctrl. */
82459f11543SVíctor Colombo #define FPSCR_DRN1 PPC_BIT_NR(30) /* Decimal Floating-Point rounding ctrl. */
82559f11543SVíctor Colombo #define FPSCR_DRN0 PPC_BIT_NR(31) /* Decimal Floating-Point rounding ctrl. */
82659f11543SVíctor Colombo #define FPSCR_FX PPC_BIT_NR(32) /* Floating-point exception summary */
82759f11543SVíctor Colombo #define FPSCR_FEX PPC_BIT_NR(33) /* Floating-point enabled exception summ.*/
82859f11543SVíctor Colombo #define FPSCR_VX PPC_BIT_NR(34) /* Floating-point invalid op. excp. summ.*/
82959f11543SVíctor Colombo #define FPSCR_OX PPC_BIT_NR(35) /* Floating-point overflow exception */
83059f11543SVíctor Colombo #define FPSCR_UX PPC_BIT_NR(36) /* Floating-point underflow exception */
83159f11543SVíctor Colombo #define FPSCR_ZX PPC_BIT_NR(37) /* Floating-point zero divide exception */
83259f11543SVíctor Colombo #define FPSCR_XX PPC_BIT_NR(38) /* Floating-point inexact exception */
83359f11543SVíctor Colombo #define FPSCR_VXSNAN PPC_BIT_NR(39) /* Floating-point invalid op. excp (sNan)*/
83459f11543SVíctor Colombo #define FPSCR_VXISI PPC_BIT_NR(40) /* Floating-point invalid op. excp (inf) */
83559f11543SVíctor Colombo #define FPSCR_VXIDI PPC_BIT_NR(41) /* Floating-point invalid op. excp (inf) */
83659f11543SVíctor Colombo #define FPSCR_VXZDZ PPC_BIT_NR(42) /* Floating-point invalid op. excp (zero)*/
83759f11543SVíctor Colombo #define FPSCR_VXIMZ PPC_BIT_NR(43) /* Floating-point invalid op. excp (inf) */
83859f11543SVíctor Colombo #define FPSCR_VXVC PPC_BIT_NR(44) /* Floating-point invalid op. excp (comp)*/
83959f11543SVíctor Colombo #define FPSCR_FR PPC_BIT_NR(45) /* Floating-point fraction rounded */
84059f11543SVíctor Colombo #define FPSCR_FI PPC_BIT_NR(46) /* Floating-point fraction inexact */
84159f11543SVíctor Colombo #define FPSCR_C PPC_BIT_NR(47) /* Floating-point result class descriptor*/
84259f11543SVíctor Colombo #define FPSCR_FL PPC_BIT_NR(48) /* Floating-point less than or negative */
84359f11543SVíctor Colombo #define FPSCR_FG PPC_BIT_NR(49) /* Floating-point greater than or neg. */
84459f11543SVíctor Colombo #define FPSCR_FE PPC_BIT_NR(50) /* Floating-point equal or zero */
84559f11543SVíctor Colombo #define FPSCR_FU PPC_BIT_NR(51) /* Floating-point unordered or NaN */
84659f11543SVíctor Colombo #define FPSCR_FPCC PPC_BIT_NR(51) /* Floating-point condition code */
84759f11543SVíctor Colombo #define FPSCR_FPRF PPC_BIT_NR(51) /* Floating-point result flags */
84859f11543SVíctor Colombo #define FPSCR_VXSOFT PPC_BIT_NR(53) /* Floating-point invalid op. excp (soft)*/
84959f11543SVíctor Colombo #define FPSCR_VXSQRT PPC_BIT_NR(54) /* Floating-point invalid op. excp (sqrt)*/
85059f11543SVíctor Colombo #define FPSCR_VXCVI PPC_BIT_NR(55) /* Floating-point invalid op. excp (int) */
85159f11543SVíctor Colombo #define FPSCR_VE PPC_BIT_NR(56) /* Floating-point invalid op. excp enable*/
85259f11543SVíctor Colombo #define FPSCR_OE PPC_BIT_NR(57) /* Floating-point overflow excp. enable */
85359f11543SVíctor Colombo #define FPSCR_UE PPC_BIT_NR(58) /* Floating-point underflow excp. enable */
85459f11543SVíctor Colombo #define FPSCR_ZE PPC_BIT_NR(59) /* Floating-point zero divide excp enable*/
85559f11543SVíctor Colombo #define FPSCR_XE PPC_BIT_NR(60) /* Floating-point inexact excp. enable */
85659f11543SVíctor Colombo #define FPSCR_NI PPC_BIT_NR(61) /* Floating-point non-IEEE mode */
85759f11543SVíctor Colombo #define FPSCR_RN1 PPC_BIT_NR(62)
85859f11543SVíctor Colombo #define FPSCR_RN0 PPC_BIT_NR(63) /* Floating-point rounding control */
859fcf5ef2aSThomas Huth /* Invalid operation exception summary */
860fe43ba97SBruno Larsen (billionai) #define FPSCR_IX ((1 << FPSCR_VXSNAN) | (1 << FPSCR_VXISI) | \
861fcf5ef2aSThomas Huth (1 << FPSCR_VXIDI) | (1 << FPSCR_VXZDZ) | \
862fcf5ef2aSThomas Huth (1 << FPSCR_VXIMZ) | (1 << FPSCR_VXVC) | \
863fcf5ef2aSThomas Huth (1 << FPSCR_VXSOFT) | (1 << FPSCR_VXSQRT) | \
864fe43ba97SBruno Larsen (billionai) (1 << FPSCR_VXCVI))
865fcf5ef2aSThomas Huth
8663278677fSVíctor Colombo FIELD(FPSCR, FI, FPSCR_FI, 1)
8673278677fSVíctor Colombo
868a2735cf4SPaul A. Clarke #define FP_DRN2 (1ull << FPSCR_DRN2)
869a2735cf4SPaul A. Clarke #define FP_DRN1 (1ull << FPSCR_DRN1)
870a2735cf4SPaul A. Clarke #define FP_DRN0 (1ull << FPSCR_DRN0)
871a2735cf4SPaul A. Clarke #define FP_DRN (FP_DRN2 | FP_DRN1 | FP_DRN0)
872fcf5ef2aSThomas Huth #define FP_FX (1ull << FPSCR_FX)
873fcf5ef2aSThomas Huth #define FP_FEX (1ull << FPSCR_FEX)
874fcf5ef2aSThomas Huth #define FP_VX (1ull << FPSCR_VX)
875fcf5ef2aSThomas Huth #define FP_OX (1ull << FPSCR_OX)
876fcf5ef2aSThomas Huth #define FP_UX (1ull << FPSCR_UX)
877fcf5ef2aSThomas Huth #define FP_ZX (1ull << FPSCR_ZX)
878fcf5ef2aSThomas Huth #define FP_XX (1ull << FPSCR_XX)
879fcf5ef2aSThomas Huth #define FP_VXSNAN (1ull << FPSCR_VXSNAN)
880fcf5ef2aSThomas Huth #define FP_VXISI (1ull << FPSCR_VXISI)
881fcf5ef2aSThomas Huth #define FP_VXIDI (1ull << FPSCR_VXIDI)
882fcf5ef2aSThomas Huth #define FP_VXZDZ (1ull << FPSCR_VXZDZ)
883fcf5ef2aSThomas Huth #define FP_VXIMZ (1ull << FPSCR_VXIMZ)
884fcf5ef2aSThomas Huth #define FP_VXVC (1ull << FPSCR_VXVC)
88531eb7dddSPaul A. Clarke #define FP_FR (1ull << FPSCR_FR)
886fcf5ef2aSThomas Huth #define FP_FI (1ull << FPSCR_FI)
887fcf5ef2aSThomas Huth #define FP_C (1ull << FPSCR_C)
888fcf5ef2aSThomas Huth #define FP_FL (1ull << FPSCR_FL)
889fcf5ef2aSThomas Huth #define FP_FG (1ull << FPSCR_FG)
890fcf5ef2aSThomas Huth #define FP_FE (1ull << FPSCR_FE)
891fcf5ef2aSThomas Huth #define FP_FU (1ull << FPSCR_FU)
892fcf5ef2aSThomas Huth #define FP_FPCC (FP_FL | FP_FG | FP_FE | FP_FU)
89331eb7dddSPaul A. Clarke #define FP_FPRF (FP_C | FP_FPCC)
894fcf5ef2aSThomas Huth #define FP_VXSOFT (1ull << FPSCR_VXSOFT)
895fcf5ef2aSThomas Huth #define FP_VXSQRT (1ull << FPSCR_VXSQRT)
896fcf5ef2aSThomas Huth #define FP_VXCVI (1ull << FPSCR_VXCVI)
897fcf5ef2aSThomas Huth #define FP_VE (1ull << FPSCR_VE)
898fcf5ef2aSThomas Huth #define FP_OE (1ull << FPSCR_OE)
899fcf5ef2aSThomas Huth #define FP_UE (1ull << FPSCR_UE)
900fcf5ef2aSThomas Huth #define FP_ZE (1ull << FPSCR_ZE)
901fcf5ef2aSThomas Huth #define FP_XE (1ull << FPSCR_XE)
902fcf5ef2aSThomas Huth #define FP_NI (1ull << FPSCR_NI)
903fcf5ef2aSThomas Huth #define FP_RN1 (1ull << FPSCR_RN1)
90431eb7dddSPaul A. Clarke #define FP_RN0 (1ull << FPSCR_RN0)
90531eb7dddSPaul A. Clarke #define FP_RN (FP_RN1 | FP_RN0)
90631eb7dddSPaul A. Clarke
90731eb7dddSPaul A. Clarke #define FP_ENABLES (FP_VE | FP_OE | FP_UE | FP_ZE | FP_XE)
90831eb7dddSPaul A. Clarke #define FP_STATUS (FP_FR | FP_FI | FP_FPRF)
909fcf5ef2aSThomas Huth
910fcf5ef2aSThomas Huth /* the exception bits which can be cleared by mcrfs - includes FX */
911fcf5ef2aSThomas Huth #define FP_EX_CLEAR_BITS (FP_FX | FP_OX | FP_UX | FP_ZX | \
912fcf5ef2aSThomas Huth FP_XX | FP_VXSNAN | FP_VXISI | FP_VXIDI | \
913fcf5ef2aSThomas Huth FP_VXZDZ | FP_VXIMZ | FP_VXVC | FP_VXSOFT | \
914fcf5ef2aSThomas Huth FP_VXSQRT | FP_VXCVI)
915fcf5ef2aSThomas Huth
91625ee608dSLucas Mateus Castro (alqotel) /* FPSCR bits that can be set by mtfsf, mtfsfi and mtfsb1 */
91725ee608dSLucas Mateus Castro (alqotel) #define FPSCR_MTFS_MASK (~(MAKE_64BIT_MASK(36, 28) | PPC_BIT(28) | \
91825ee608dSLucas Mateus Castro (alqotel) FP_FEX | FP_VX | PPC_BIT(52)))
91925ee608dSLucas Mateus Castro (alqotel)
920fcf5ef2aSThomas Huth /*****************************************************************************/
921fcf5ef2aSThomas Huth /* Vector status and control register */
922fcf5ef2aSThomas Huth #define VSCR_NJ 16 /* Vector non-java */
923fcf5ef2aSThomas Huth #define VSCR_SAT 0 /* Vector saturation */
924fcf5ef2aSThomas Huth
925fcf5ef2aSThomas Huth /*****************************************************************************/
926fcf5ef2aSThomas Huth /* BookE e500 MMU registers */
927fcf5ef2aSThomas Huth
928fcf5ef2aSThomas Huth #define MAS0_NV_SHIFT 0
929fcf5ef2aSThomas Huth #define MAS0_NV_MASK (0xfff << MAS0_NV_SHIFT)
930fcf5ef2aSThomas Huth
931fcf5ef2aSThomas Huth #define MAS0_WQ_SHIFT 12
932fcf5ef2aSThomas Huth #define MAS0_WQ_MASK (3 << MAS0_WQ_SHIFT)
933fcf5ef2aSThomas Huth /* Write TLB entry regardless of reservation */
934fcf5ef2aSThomas Huth #define MAS0_WQ_ALWAYS (0 << MAS0_WQ_SHIFT)
935fcf5ef2aSThomas Huth /* Write TLB entry only already in use */
936fcf5ef2aSThomas Huth #define MAS0_WQ_COND (1 << MAS0_WQ_SHIFT)
937fcf5ef2aSThomas Huth /* Clear TLB entry */
938fcf5ef2aSThomas Huth #define MAS0_WQ_CLR_RSRV (2 << MAS0_WQ_SHIFT)
939fcf5ef2aSThomas Huth
940fcf5ef2aSThomas Huth #define MAS0_HES_SHIFT 14
941fcf5ef2aSThomas Huth #define MAS0_HES (1 << MAS0_HES_SHIFT)
942fcf5ef2aSThomas Huth
943fcf5ef2aSThomas Huth #define MAS0_ESEL_SHIFT 16
944fcf5ef2aSThomas Huth #define MAS0_ESEL_MASK (0xfff << MAS0_ESEL_SHIFT)
945fcf5ef2aSThomas Huth
946fcf5ef2aSThomas Huth #define MAS0_TLBSEL_SHIFT 28
947fcf5ef2aSThomas Huth #define MAS0_TLBSEL_MASK (3 << MAS0_TLBSEL_SHIFT)
948fcf5ef2aSThomas Huth #define MAS0_TLBSEL_TLB0 (0 << MAS0_TLBSEL_SHIFT)
949fcf5ef2aSThomas Huth #define MAS0_TLBSEL_TLB1 (1 << MAS0_TLBSEL_SHIFT)
950fcf5ef2aSThomas Huth #define MAS0_TLBSEL_TLB2 (2 << MAS0_TLBSEL_SHIFT)
951fcf5ef2aSThomas Huth #define MAS0_TLBSEL_TLB3 (3 << MAS0_TLBSEL_SHIFT)
952fcf5ef2aSThomas Huth
953fcf5ef2aSThomas Huth #define MAS0_ATSEL_SHIFT 31
954fcf5ef2aSThomas Huth #define MAS0_ATSEL (1 << MAS0_ATSEL_SHIFT)
955fcf5ef2aSThomas Huth #define MAS0_ATSEL_TLB 0
956fcf5ef2aSThomas Huth #define MAS0_ATSEL_LRAT MAS0_ATSEL
957fcf5ef2aSThomas Huth
958fcf5ef2aSThomas Huth #define MAS1_TSIZE_SHIFT 7
959fcf5ef2aSThomas Huth #define MAS1_TSIZE_MASK (0x1f << MAS1_TSIZE_SHIFT)
960fcf5ef2aSThomas Huth
961fcf5ef2aSThomas Huth #define MAS1_TS_SHIFT 12
962fcf5ef2aSThomas Huth #define MAS1_TS (1 << MAS1_TS_SHIFT)
963fcf5ef2aSThomas Huth
964fcf5ef2aSThomas Huth #define MAS1_IND_SHIFT 13
965fcf5ef2aSThomas Huth #define MAS1_IND (1 << MAS1_IND_SHIFT)
966fcf5ef2aSThomas Huth
967fcf5ef2aSThomas Huth #define MAS1_TID_SHIFT 16
968fcf5ef2aSThomas Huth #define MAS1_TID_MASK (0x3fff << MAS1_TID_SHIFT)
969fcf5ef2aSThomas Huth
970fcf5ef2aSThomas Huth #define MAS1_IPROT_SHIFT 30
971fcf5ef2aSThomas Huth #define MAS1_IPROT (1 << MAS1_IPROT_SHIFT)
972fcf5ef2aSThomas Huth
973fcf5ef2aSThomas Huth #define MAS1_VALID_SHIFT 31
974fcf5ef2aSThomas Huth #define MAS1_VALID 0x80000000
975fcf5ef2aSThomas Huth
976fcf5ef2aSThomas Huth #define MAS2_EPN_SHIFT 12
977fcf5ef2aSThomas Huth #define MAS2_EPN_MASK (~0ULL << MAS2_EPN_SHIFT)
978fcf5ef2aSThomas Huth
979fcf5ef2aSThomas Huth #define MAS2_ACM_SHIFT 6
980fcf5ef2aSThomas Huth #define MAS2_ACM (1 << MAS2_ACM_SHIFT)
981fcf5ef2aSThomas Huth
982fcf5ef2aSThomas Huth #define MAS2_VLE_SHIFT 5
983fcf5ef2aSThomas Huth #define MAS2_VLE (1 << MAS2_VLE_SHIFT)
984fcf5ef2aSThomas Huth
985fcf5ef2aSThomas Huth #define MAS2_W_SHIFT 4
986fcf5ef2aSThomas Huth #define MAS2_W (1 << MAS2_W_SHIFT)
987fcf5ef2aSThomas Huth
988fcf5ef2aSThomas Huth #define MAS2_I_SHIFT 3
989fcf5ef2aSThomas Huth #define MAS2_I (1 << MAS2_I_SHIFT)
990fcf5ef2aSThomas Huth
991fcf5ef2aSThomas Huth #define MAS2_M_SHIFT 2
992fcf5ef2aSThomas Huth #define MAS2_M (1 << MAS2_M_SHIFT)
993fcf5ef2aSThomas Huth
994fcf5ef2aSThomas Huth #define MAS2_G_SHIFT 1
995fcf5ef2aSThomas Huth #define MAS2_G (1 << MAS2_G_SHIFT)
996fcf5ef2aSThomas Huth
997fcf5ef2aSThomas Huth #define MAS2_E_SHIFT 0
998fcf5ef2aSThomas Huth #define MAS2_E (1 << MAS2_E_SHIFT)
999fcf5ef2aSThomas Huth
1000fcf5ef2aSThomas Huth #define MAS3_RPN_SHIFT 12
1001fcf5ef2aSThomas Huth #define MAS3_RPN_MASK (0xfffff << MAS3_RPN_SHIFT)
1002fcf5ef2aSThomas Huth
1003fcf5ef2aSThomas Huth #define MAS3_U0 0x00000200
1004fcf5ef2aSThomas Huth #define MAS3_U1 0x00000100
1005fcf5ef2aSThomas Huth #define MAS3_U2 0x00000080
1006fcf5ef2aSThomas Huth #define MAS3_U3 0x00000040
1007fcf5ef2aSThomas Huth #define MAS3_UX 0x00000020
1008fcf5ef2aSThomas Huth #define MAS3_SX 0x00000010
1009fcf5ef2aSThomas Huth #define MAS3_UW 0x00000008
1010fcf5ef2aSThomas Huth #define MAS3_SW 0x00000004
1011fcf5ef2aSThomas Huth #define MAS3_UR 0x00000002
1012fcf5ef2aSThomas Huth #define MAS3_SR 0x00000001
1013fcf5ef2aSThomas Huth #define MAS3_SPSIZE_SHIFT 1
1014fcf5ef2aSThomas Huth #define MAS3_SPSIZE_MASK (0x3e << MAS3_SPSIZE_SHIFT)
1015fcf5ef2aSThomas Huth
1016fcf5ef2aSThomas Huth #define MAS4_TLBSELD_SHIFT MAS0_TLBSEL_SHIFT
1017fcf5ef2aSThomas Huth #define MAS4_TLBSELD_MASK MAS0_TLBSEL_MASK
1018fcf5ef2aSThomas Huth #define MAS4_TIDSELD_MASK 0x00030000
1019fcf5ef2aSThomas Huth #define MAS4_TIDSELD_PID0 0x00000000
1020fcf5ef2aSThomas Huth #define MAS4_TIDSELD_PID1 0x00010000
1021fcf5ef2aSThomas Huth #define MAS4_TIDSELD_PID2 0x00020000
1022fcf5ef2aSThomas Huth #define MAS4_TIDSELD_PIDZ 0x00030000
1023fcf5ef2aSThomas Huth #define MAS4_INDD 0x00008000 /* Default IND */
1024fcf5ef2aSThomas Huth #define MAS4_TSIZED_SHIFT MAS1_TSIZE_SHIFT
1025fcf5ef2aSThomas Huth #define MAS4_TSIZED_MASK MAS1_TSIZE_MASK
1026fcf5ef2aSThomas Huth #define MAS4_ACMD 0x00000040
1027fcf5ef2aSThomas Huth #define MAS4_VLED 0x00000020
1028fcf5ef2aSThomas Huth #define MAS4_WD 0x00000010
1029fcf5ef2aSThomas Huth #define MAS4_ID 0x00000008
1030fcf5ef2aSThomas Huth #define MAS4_MD 0x00000004
1031fcf5ef2aSThomas Huth #define MAS4_GD 0x00000002
1032fcf5ef2aSThomas Huth #define MAS4_ED 0x00000001
1033fcf5ef2aSThomas Huth #define MAS4_WIMGED_MASK 0x0000001f /* Default WIMGE */
1034fcf5ef2aSThomas Huth #define MAS4_WIMGED_SHIFT 0
1035fcf5ef2aSThomas Huth
1036fcf5ef2aSThomas Huth #define MAS5_SGS 0x80000000
1037fcf5ef2aSThomas Huth #define MAS5_SLPID_MASK 0x00000fff
1038fcf5ef2aSThomas Huth
1039fcf5ef2aSThomas Huth #define MAS6_SPID0 0x3fff0000
1040fcf5ef2aSThomas Huth #define MAS6_SPID1 0x00007ffe
1041fcf5ef2aSThomas Huth #define MAS6_ISIZE(x) MAS1_TSIZE(x)
1042fcf5ef2aSThomas Huth #define MAS6_SAS 0x00000001
1043fcf5ef2aSThomas Huth #define MAS6_SPID MAS6_SPID0
1044fcf5ef2aSThomas Huth #define MAS6_SIND 0x00000002 /* Indirect page */
1045fcf5ef2aSThomas Huth #define MAS6_SIND_SHIFT 1
1046fcf5ef2aSThomas Huth #define MAS6_SPID_MASK 0x3fff0000
1047fcf5ef2aSThomas Huth #define MAS6_SPID_SHIFT 16
1048fcf5ef2aSThomas Huth #define MAS6_ISIZE_MASK 0x00000f80
1049fcf5ef2aSThomas Huth #define MAS6_ISIZE_SHIFT 7
1050fcf5ef2aSThomas Huth
1051fcf5ef2aSThomas Huth #define MAS7_RPN 0xffffffff
1052fcf5ef2aSThomas Huth
1053fcf5ef2aSThomas Huth #define MAS8_TGS 0x80000000
1054fcf5ef2aSThomas Huth #define MAS8_VF 0x40000000
1055fcf5ef2aSThomas Huth #define MAS8_TLBPID 0x00000fff
1056fcf5ef2aSThomas Huth
1057fcf5ef2aSThomas Huth /* Bit definitions for MMUCFG */
1058fcf5ef2aSThomas Huth #define MMUCFG_MAVN 0x00000003 /* MMU Architecture Version Number */
1059fcf5ef2aSThomas Huth #define MMUCFG_MAVN_V1 0x00000000 /* v1.0 */
1060fcf5ef2aSThomas Huth #define MMUCFG_MAVN_V2 0x00000001 /* v2.0 */
1061fcf5ef2aSThomas Huth #define MMUCFG_NTLBS 0x0000000c /* Number of TLBs */
1062fcf5ef2aSThomas Huth #define MMUCFG_PIDSIZE 0x000007c0 /* PID Reg Size */
1063fcf5ef2aSThomas Huth #define MMUCFG_TWC 0x00008000 /* TLB Write Conditional (v2.0) */
1064fcf5ef2aSThomas Huth #define MMUCFG_LRAT 0x00010000 /* LRAT Supported (v2.0) */
1065fcf5ef2aSThomas Huth #define MMUCFG_RASIZE 0x00fe0000 /* Real Addr Size */
1066fcf5ef2aSThomas Huth #define MMUCFG_LPIDSIZE 0x0f000000 /* LPID Reg Size */
1067fcf5ef2aSThomas Huth
1068fcf5ef2aSThomas Huth /* Bit definitions for MMUCSR0 */
1069fcf5ef2aSThomas Huth #define MMUCSR0_TLB1FI 0x00000002 /* TLB1 Flash invalidate */
1070fcf5ef2aSThomas Huth #define MMUCSR0_TLB0FI 0x00000004 /* TLB0 Flash invalidate */
1071fcf5ef2aSThomas Huth #define MMUCSR0_TLB2FI 0x00000040 /* TLB2 Flash invalidate */
1072fcf5ef2aSThomas Huth #define MMUCSR0_TLB3FI 0x00000020 /* TLB3 Flash invalidate */
1073fcf5ef2aSThomas Huth #define MMUCSR0_TLBFI (MMUCSR0_TLB0FI | MMUCSR0_TLB1FI | \
1074fcf5ef2aSThomas Huth MMUCSR0_TLB2FI | MMUCSR0_TLB3FI)
1075fcf5ef2aSThomas Huth #define MMUCSR0_TLB0PS 0x00000780 /* TLB0 Page Size */
1076fcf5ef2aSThomas Huth #define MMUCSR0_TLB1PS 0x00007800 /* TLB1 Page Size */
1077fcf5ef2aSThomas Huth #define MMUCSR0_TLB2PS 0x00078000 /* TLB2 Page Size */
1078fcf5ef2aSThomas Huth #define MMUCSR0_TLB3PS 0x00780000 /* TLB3 Page Size */
1079fcf5ef2aSThomas Huth
1080fcf5ef2aSThomas Huth /* TLBnCFG encoding */
1081fcf5ef2aSThomas Huth #define TLBnCFG_N_ENTRY 0x00000fff /* number of entries */
1082fcf5ef2aSThomas Huth #define TLBnCFG_HES 0x00002000 /* HW select supported */
1083fcf5ef2aSThomas Huth #define TLBnCFG_AVAIL 0x00004000 /* variable page size */
1084fcf5ef2aSThomas Huth #define TLBnCFG_IPROT 0x00008000 /* IPROT supported */
1085fcf5ef2aSThomas Huth #define TLBnCFG_GTWE 0x00010000 /* Guest can write */
1086fcf5ef2aSThomas Huth #define TLBnCFG_IND 0x00020000 /* IND entries supported */
1087fcf5ef2aSThomas Huth #define TLBnCFG_PT 0x00040000 /* Can load from page table */
1088fcf5ef2aSThomas Huth #define TLBnCFG_MINSIZE 0x00f00000 /* Minimum Page Size (v1.0) */
1089fcf5ef2aSThomas Huth #define TLBnCFG_MINSIZE_SHIFT 20
1090fcf5ef2aSThomas Huth #define TLBnCFG_MAXSIZE 0x000f0000 /* Maximum Page Size (v1.0) */
1091fcf5ef2aSThomas Huth #define TLBnCFG_MAXSIZE_SHIFT 16
1092fcf5ef2aSThomas Huth #define TLBnCFG_ASSOC 0xff000000 /* Associativity */
1093fcf5ef2aSThomas Huth #define TLBnCFG_ASSOC_SHIFT 24
1094fcf5ef2aSThomas Huth
1095fcf5ef2aSThomas Huth /* TLBnPS encoding */
1096fcf5ef2aSThomas Huth #define TLBnPS_4K 0x00000004
1097fcf5ef2aSThomas Huth #define TLBnPS_8K 0x00000008
1098fcf5ef2aSThomas Huth #define TLBnPS_16K 0x00000010
1099fcf5ef2aSThomas Huth #define TLBnPS_32K 0x00000020
1100fcf5ef2aSThomas Huth #define TLBnPS_64K 0x00000040
1101fcf5ef2aSThomas Huth #define TLBnPS_128K 0x00000080
1102fcf5ef2aSThomas Huth #define TLBnPS_256K 0x00000100
1103fcf5ef2aSThomas Huth #define TLBnPS_512K 0x00000200
1104fcf5ef2aSThomas Huth #define TLBnPS_1M 0x00000400
1105fcf5ef2aSThomas Huth #define TLBnPS_2M 0x00000800
1106fcf5ef2aSThomas Huth #define TLBnPS_4M 0x00001000
1107fcf5ef2aSThomas Huth #define TLBnPS_8M 0x00002000
1108fcf5ef2aSThomas Huth #define TLBnPS_16M 0x00004000
1109fcf5ef2aSThomas Huth #define TLBnPS_32M 0x00008000
1110fcf5ef2aSThomas Huth #define TLBnPS_64M 0x00010000
1111fcf5ef2aSThomas Huth #define TLBnPS_128M 0x00020000
1112fcf5ef2aSThomas Huth #define TLBnPS_256M 0x00040000
1113fcf5ef2aSThomas Huth #define TLBnPS_512M 0x00080000
1114fcf5ef2aSThomas Huth #define TLBnPS_1G 0x00100000
1115fcf5ef2aSThomas Huth #define TLBnPS_2G 0x00200000
1116fcf5ef2aSThomas Huth #define TLBnPS_4G 0x00400000
1117fcf5ef2aSThomas Huth #define TLBnPS_8G 0x00800000
1118fcf5ef2aSThomas Huth #define TLBnPS_16G 0x01000000
1119fcf5ef2aSThomas Huth #define TLBnPS_32G 0x02000000
1120fcf5ef2aSThomas Huth #define TLBnPS_64G 0x04000000
1121fcf5ef2aSThomas Huth #define TLBnPS_128G 0x08000000
1122fcf5ef2aSThomas Huth #define TLBnPS_256G 0x10000000
1123fcf5ef2aSThomas Huth
1124fcf5ef2aSThomas Huth /* tlbilx action encoding */
1125fcf5ef2aSThomas Huth #define TLBILX_T_ALL 0
1126fcf5ef2aSThomas Huth #define TLBILX_T_TID 1
1127fcf5ef2aSThomas Huth #define TLBILX_T_FULLMATCH 3
1128fcf5ef2aSThomas Huth #define TLBILX_T_CLASS0 4
1129fcf5ef2aSThomas Huth #define TLBILX_T_CLASS1 5
1130fcf5ef2aSThomas Huth #define TLBILX_T_CLASS2 6
1131fcf5ef2aSThomas Huth #define TLBILX_T_CLASS3 7
1132fcf5ef2aSThomas Huth
1133fcf5ef2aSThomas Huth /* BookE 2.06 helper defines */
1134fcf5ef2aSThomas Huth
1135fcf5ef2aSThomas Huth #define BOOKE206_FLUSH_TLB0 (1 << 0)
1136fcf5ef2aSThomas Huth #define BOOKE206_FLUSH_TLB1 (1 << 1)
1137fcf5ef2aSThomas Huth #define BOOKE206_FLUSH_TLB2 (1 << 2)
1138fcf5ef2aSThomas Huth #define BOOKE206_FLUSH_TLB3 (1 << 3)
1139fcf5ef2aSThomas Huth
1140fcf5ef2aSThomas Huth /* number of possible TLBs */
1141fcf5ef2aSThomas Huth #define BOOKE206_MAX_TLBN 4
1142fcf5ef2aSThomas Huth
114350728199SRoman Kapl #define EPID_EPID_SHIFT 0x0
114450728199SRoman Kapl #define EPID_EPID 0xFF
114550728199SRoman Kapl #define EPID_ELPID_SHIFT 0x10
114650728199SRoman Kapl #define EPID_ELPID 0x3F0000
114750728199SRoman Kapl #define EPID_EGS 0x20000000
114850728199SRoman Kapl #define EPID_EGS_SHIFT 29
114950728199SRoman Kapl #define EPID_EAS 0x40000000
115050728199SRoman Kapl #define EPID_EAS_SHIFT 30
115150728199SRoman Kapl #define EPID_EPR 0x80000000
115250728199SRoman Kapl #define EPID_EPR_SHIFT 31
115350728199SRoman Kapl /* We don't support EGS and ELPID */
115450728199SRoman Kapl #define EPID_MASK (EPID_EPID | EPID_EAS | EPID_EPR)
115550728199SRoman Kapl
1156fcf5ef2aSThomas Huth /*****************************************************************************/
11577af1e7b0SCédric Le Goater /* Server and Embedded Processor Control */
1158fcf5ef2aSThomas Huth
1159fcf5ef2aSThomas Huth #define DBELL_TYPE_SHIFT 27
1160fcf5ef2aSThomas Huth #define DBELL_TYPE_MASK (0x1f << DBELL_TYPE_SHIFT)
1161fcf5ef2aSThomas Huth #define DBELL_TYPE_DBELL (0x00 << DBELL_TYPE_SHIFT)
1162fcf5ef2aSThomas Huth #define DBELL_TYPE_DBELL_CRIT (0x01 << DBELL_TYPE_SHIFT)
1163fcf5ef2aSThomas Huth #define DBELL_TYPE_G_DBELL (0x02 << DBELL_TYPE_SHIFT)
1164fcf5ef2aSThomas Huth #define DBELL_TYPE_G_DBELL_CRIT (0x03 << DBELL_TYPE_SHIFT)
1165fcf5ef2aSThomas Huth #define DBELL_TYPE_G_DBELL_MC (0x04 << DBELL_TYPE_SHIFT)
1166fcf5ef2aSThomas Huth
11677af1e7b0SCédric Le Goater #define DBELL_TYPE_DBELL_SERVER (0x05 << DBELL_TYPE_SHIFT)
11687af1e7b0SCédric Le Goater
11690dfe59feSNicholas Piggin #define DBELL_BRDCAST_MASK PPC_BITMASK(37, 38)
11700dfe59feSNicholas Piggin #define DBELL_BRDCAST_SHIFT 25
11710dfe59feSNicholas Piggin #define DBELL_BRDCAST_SUBPROC (0x1 << DBELL_BRDCAST_SHIFT)
11720dfe59feSNicholas Piggin #define DBELL_BRDCAST_CORE (0x2 << DBELL_BRDCAST_SHIFT)
11730dfe59feSNicholas Piggin
1174fcf5ef2aSThomas Huth #define DBELL_LPIDTAG_SHIFT 14
1175fcf5ef2aSThomas Huth #define DBELL_LPIDTAG_MASK (0xfff << DBELL_LPIDTAG_SHIFT)
1176fcf5ef2aSThomas Huth #define DBELL_PIRTAG_MASK 0x3fff
1177fcf5ef2aSThomas Huth
11787af1e7b0SCédric Le Goater #define DBELL_PROCIDTAG_MASK PPC_BITMASK(44, 63)
11797af1e7b0SCédric Le Goater
1180fcf5ef2aSThomas Huth #define PPC_PAGE_SIZES_MAX_SZ 8
1181fcf5ef2aSThomas Huth
1182c64abd1fSSam Bobroff struct ppc_radix_page_info {
1183c64abd1fSSam Bobroff uint32_t count;
1184c64abd1fSSam Bobroff uint32_t entries[PPC_PAGE_SIZES_MAX_SZ];
1185c64abd1fSSam Bobroff };
1186fcf5ef2aSThomas Huth
1187fcf5ef2aSThomas Huth /*****************************************************************************/
1188395b5d5bSNicholas Miehlbradt /* Dynamic Execution Control Register */
1189395b5d5bSNicholas Miehlbradt
1190395b5d5bSNicholas Miehlbradt #define DEXCR_ASPECT(name, num) \
1191395b5d5bSNicholas Miehlbradt FIELD(DEXCR, PNH_##name, PPC_BIT_NR(num), 1) \
1192395b5d5bSNicholas Miehlbradt FIELD(DEXCR, PRO_##name, PPC_BIT_NR(num + 32), 1) \
1193395b5d5bSNicholas Miehlbradt FIELD(HDEXCR, HNU_##name, PPC_BIT_NR(num), 1) \
1194395b5d5bSNicholas Miehlbradt FIELD(HDEXCR, ENF_##name, PPC_BIT_NR(num + 32), 1) \
1195395b5d5bSNicholas Miehlbradt
1196395b5d5bSNicholas Miehlbradt DEXCR_ASPECT(SBHE, 0)
1197395b5d5bSNicholas Miehlbradt DEXCR_ASPECT(IBRTPD, 1)
1198395b5d5bSNicholas Miehlbradt DEXCR_ASPECT(SRAPD, 4)
1199395b5d5bSNicholas Miehlbradt DEXCR_ASPECT(NPHIE, 5)
1200395b5d5bSNicholas Miehlbradt DEXCR_ASPECT(PHIE, 6)
1201395b5d5bSNicholas Miehlbradt
1202395b5d5bSNicholas Miehlbradt /*****************************************************************************/
1203fcf5ef2aSThomas Huth /* The whole PowerPC CPU context */
120450728199SRoman Kapl
1205c647e3feSDavid Gibson /*
1206c647e3feSDavid Gibson * PowerPC needs eight modes for different hypervisor/supervisor/guest
1207c647e3feSDavid Gibson * + real/paged mode combinations. The other two modes are for
1208c647e3feSDavid Gibson * external PID load/store.
120950728199SRoman Kapl */
121050728199SRoman Kapl #define PPC_TLB_EPID_LOAD 8
121150728199SRoman Kapl #define PPC_TLB_EPID_STORE 9
1212fcf5ef2aSThomas Huth
1213fcf5ef2aSThomas Huth #define PPC_CPU_OPCODES_LEN 0x40
1214fcf5ef2aSThomas Huth #define PPC_CPU_INDIRECT_OPCODES_LEN 0x20
1215fcf5ef2aSThomas Huth
12164de4a470SGlenn Miles #define BHRB_MAX_NUM_ENTRIES_LOG2 (5)
12174de4a470SGlenn Miles #define BHRB_MAX_NUM_ENTRIES (1 << BHRB_MAX_NUM_ENTRIES_LOG2)
12184de4a470SGlenn Miles
12191ea4a06aSPhilippe Mathieu-Daudé struct CPUArchState {
1220ad5db2e7SBALATON Zoltan /* Most commonly used resources during translated code execution first */
1221ad5db2e7SBALATON Zoltan target_ulong gpr[32]; /* general purpose registers */
1222ad5db2e7SBALATON Zoltan target_ulong gprh[32]; /* storage for GPR MSB, used by the SPE extension */
1223fcf5ef2aSThomas Huth target_ulong lr;
1224fcf5ef2aSThomas Huth target_ulong ctr;
1225ad5db2e7SBALATON Zoltan uint32_t crf[8]; /* condition register */
1226fcf5ef2aSThomas Huth #if defined(TARGET_PPC64)
1227fcf5ef2aSThomas Huth target_ulong cfar;
1228fcf5ef2aSThomas Huth #endif
1229ad5db2e7SBALATON Zoltan target_ulong xer; /* XER (with SO, OV, CA split out) */
1230fcf5ef2aSThomas Huth target_ulong so;
1231fcf5ef2aSThomas Huth target_ulong ov;
1232fcf5ef2aSThomas Huth target_ulong ca;
1233dd09c361SNikunj A Dadhania target_ulong ov32;
1234dd09c361SNikunj A Dadhania target_ulong ca32;
1235ad5db2e7SBALATON Zoltan
1236ad5db2e7SBALATON Zoltan target_ulong reserve_addr; /* Reservation address */
1237392d328aSNicholas Piggin target_ulong reserve_length; /* Reservation larx op size (bytes) */
1238ad5db2e7SBALATON Zoltan target_ulong reserve_val; /* Reservation value */
1239cdab53ddSNicholas Piggin #if defined(TARGET_PPC64)
1240fcf5ef2aSThomas Huth target_ulong reserve_val2;
1241cdab53ddSNicholas Piggin #endif
1242fcf5ef2aSThomas Huth
1243ad5db2e7SBALATON Zoltan /* These are used in supervisor mode only */
1244ad5db2e7SBALATON Zoltan target_ulong msr; /* machine state register */
1245ad5db2e7SBALATON Zoltan target_ulong tgpr[4]; /* temporary general purpose registers, */
1246ad5db2e7SBALATON Zoltan /* used to speed-up TLB assist handlers */
1247fcf5ef2aSThomas Huth
1248ad5db2e7SBALATON Zoltan target_ulong nip; /* next instruction pointer */
124994bf2658SRichard Henderson
1250c647e3feSDavid Gibson /* when a memory exception occurs, the access type is stored here */
1251c647e3feSDavid Gibson int access_type;
1252fcf5ef2aSThomas Huth
1253feb37fdcSNicholas Piggin /* For SMT processors */
125459c921f2SNicholas Piggin bool has_smt_siblings;
1255feb37fdcSNicholas Piggin int core_index;
1256*2fc0a78aSGlenn Miles int chip_index;
1257feb37fdcSNicholas Piggin
1258fcf5ef2aSThomas Huth #if !defined(CONFIG_USER_ONLY)
1259ad5db2e7SBALATON Zoltan /* MMU context, only relevant for full system emulation */
1260fcf5ef2aSThomas Huth #if defined(TARGET_PPC64)
1261ad5db2e7SBALATON Zoltan ppc_slb_t slb[MAX_SLB_ENTRIES]; /* PowerPC 64 SLB area */
126214192307SNicholas Piggin struct CPUBreakpoint *ciabr_breakpoint;
1263d5ee641cSNicholas Piggin struct CPUWatchpoint *dawr0_watchpoint;
1264fcf5ef2aSThomas Huth #endif
1265ad5db2e7SBALATON Zoltan target_ulong sr[32]; /* segment registers */
1266ad5db2e7SBALATON Zoltan uint32_t nb_BATs; /* number of BATs */
1267fcf5ef2aSThomas Huth target_ulong DBAT[2][8];
1268fcf5ef2aSThomas Huth target_ulong IBAT[2][8];
1269fcf5ef2aSThomas Huth /* PowerPC TLB registers (for 4xx, e500 and 60x software driven TLBs) */
1270fcf5ef2aSThomas Huth int32_t nb_tlb; /* Total number of TLB */
1271fcf5ef2aSThomas Huth int tlb_per_way; /* Speed-up helper: used to avoid divisions at run time */
1272fcf5ef2aSThomas Huth int nb_ways; /* Number of ways in the TLB set */
1273fcf5ef2aSThomas Huth int last_way; /* Last used way used to allocate TLB in a LRU way */
1274fcf5ef2aSThomas Huth int nb_pids; /* Number of available PID registers */
1275fcf5ef2aSThomas Huth int tlb_type; /* Type of TLB we're dealing with */
1276fcf5ef2aSThomas Huth ppc_tlb_t tlb; /* TLB is optional. Allocate them only if needed */
127705739977SPhilippe Mathieu-Daudé #ifdef CONFIG_KVM
1278fcf5ef2aSThomas Huth bool tlb_dirty; /* Set to non-zero when modifying TLB */
1279fcf5ef2aSThomas Huth bool kvm_sw_tlb; /* non-zero if KVM SW TLB API is active */
128005739977SPhilippe Mathieu-Daudé #endif /* CONFIG_KVM */
1281fcf5ef2aSThomas Huth uint32_t tlb_need_flush; /* Delayed flush needed */
1282fcf5ef2aSThomas Huth #define TLB_NEED_LOCAL_FLUSH 0x1
1283fcf5ef2aSThomas Huth #define TLB_NEED_GLOBAL_FLUSH 0x2
1284fcf5ef2aSThomas Huth #endif
1285fcf5ef2aSThomas Huth
1286fcf5ef2aSThomas Huth /* Other registers */
1287ad5db2e7SBALATON Zoltan target_ulong spr[1024]; /* special purpose registers */
1288fcf5ef2aSThomas Huth ppc_spr_t spr_cb[1024];
12896e8b9903SRichard Henderson /* Composite status for PMC[1-6] enabled and counting insns or cycles. */
12906e8b9903SRichard Henderson uint8_t pmc_ins_cnt;
12916e8b9903SRichard Henderson uint8_t pmc_cyc_cnt;
1292ad5db2e7SBALATON Zoltan /* Vector status and control register, minus VSCR_SAT */
1293fcf5ef2aSThomas Huth uint32_t vscr;
1294ef96e3aeSMark Cave-Ayland /* VSX registers (including FP and AVR) */
1295ef96e3aeSMark Cave-Ayland ppc_vsr_t vsr[64] QEMU_ALIGNED(16);
1296ad5db2e7SBALATON Zoltan /* Non-zero if and only if VSCR_SAT should be set */
12979b5b74daSRichard Henderson ppc_vsr_t vscr_sat QEMU_ALIGNED(16);
1298fcf5ef2aSThomas Huth /* SPE registers */
1299fcf5ef2aSThomas Huth uint64_t spe_acc;
1300fcf5ef2aSThomas Huth uint32_t spe_fscr;
1301ad5db2e7SBALATON Zoltan /* SPE and Altivec share status as they'll never be used simultaneously */
1302fcf5ef2aSThomas Huth float_status vec_status;
1303ad5db2e7SBALATON Zoltan float_status fp_status; /* Floating point execution context */
1304ad5db2e7SBALATON Zoltan target_ulong fpscr; /* Floating point status and control register */
1305fcf5ef2aSThomas Huth
1306fcf5ef2aSThomas Huth /* Internal devices resources */
1307ad5db2e7SBALATON Zoltan ppc_tb_t *tb_env; /* Time base and decrementer */
1308ad5db2e7SBALATON Zoltan ppc_dcr_t *dcr_env; /* Device control registers */
1309fcf5ef2aSThomas Huth
1310fcf5ef2aSThomas Huth int dcache_line_size;
1311fcf5ef2aSThomas Huth int icache_line_size;
1312fcf5ef2aSThomas Huth
13134de4a470SGlenn Miles #ifdef TARGET_PPC64
13144de4a470SGlenn Miles /* Branch History Rolling Buffer (BHRB) resources */
13154de4a470SGlenn Miles target_ulong bhrb_num_entries;
13164de4a470SGlenn Miles intptr_t bhrb_base;
13174de4a470SGlenn Miles target_ulong bhrb_filter;
13184de4a470SGlenn Miles target_ulong bhrb_offset;
13194de4a470SGlenn Miles target_ulong bhrb_offset_mask;
13204de4a470SGlenn Miles uint64_t bhrb[BHRB_MAX_NUM_ENTRIES];
13214de4a470SGlenn Miles #endif
13224de4a470SGlenn Miles
1323ad5db2e7SBALATON Zoltan /* These resources are used during exception processing */
1324fcf5ef2aSThomas Huth /* CPU model definition */
1325fcf5ef2aSThomas Huth target_ulong msr_mask;
1326fcf5ef2aSThomas Huth powerpc_mmu_t mmu_model;
1327fcf5ef2aSThomas Huth powerpc_excp_t excp_model;
1328fcf5ef2aSThomas Huth powerpc_input_t bus_model;
1329fcf5ef2aSThomas Huth int bfd_mach;
1330fcf5ef2aSThomas Huth uint32_t flags;
1331fcf5ef2aSThomas Huth uint64_t insns_flags;
1332fcf5ef2aSThomas Huth uint64_t insns_flags2;
1333fcf5ef2aSThomas Huth
1334fcf5ef2aSThomas Huth int error_code;
1335fcf5ef2aSThomas Huth uint32_t pending_interrupts;
1336fcf5ef2aSThomas Huth #if !defined(CONFIG_USER_ONLY)
13378a15cceeSBALATON Zoltan uint64_t excp_stats[POWERPC_EXCP_NB];
1338c647e3feSDavid Gibson /*
1339ad5db2e7SBALATON Zoltan * This is the IRQ controller, which is implementation dependent and only
1340ad5db2e7SBALATON Zoltan * relevant when emulating a complete machine. Note that this isn't used
1341ad5db2e7SBALATON Zoltan * by recent Book3s compatible CPUs (POWER7 and newer).
1342fcf5ef2aSThomas Huth */
1343fcf5ef2aSThomas Huth uint32_t irq_input_state;
1344ad5db2e7SBALATON Zoltan
1345ad5db2e7SBALATON Zoltan target_ulong excp_vectors[POWERPC_EXCP_NB]; /* Exception vectors */
1346fcf5ef2aSThomas Huth target_ulong excp_prefix;
1347fcf5ef2aSThomas Huth target_ulong ivor_mask;
1348fcf5ef2aSThomas Huth target_ulong ivpr_mask;
1349fcf5ef2aSThomas Huth target_ulong hreset_vector;
1350fcf5ef2aSThomas Huth hwaddr mpic_iack;
1351ad5db2e7SBALATON Zoltan bool mpic_proxy; /* true if the external proxy facility mode is enabled */
1352ad5db2e7SBALATON Zoltan bool has_hv_mode; /* set when the processor has an HV mode, thus HV priv */
1353ad5db2e7SBALATON Zoltan /* instructions and SPRs are diallowed if MSR:HV is 0 */
1354c647e3feSDavid Gibson /*
1355ad5db2e7SBALATON Zoltan * On P7/P8/P9, set when in PM state so we need to handle resume in a
1356ad5db2e7SBALATON Zoltan * special way (such as routing some resume causes to 0x100, i.e. sreset).
1357fcf5ef2aSThomas Huth */
13581e7fd61dSBenjamin Herrenschmidt bool resume_as_sreset;
135996746f7aSNicholas Piggin bool quiesced;
1360fcf5ef2aSThomas Huth #endif
1361fcf5ef2aSThomas Huth
136226c55599SRichard Henderson /* These resources are used only in TCG */
136326c55599SRichard Henderson uint32_t hflags;
1364f7a7b652SRichard Henderson target_ulong hflags_compat_nmsr; /* for migration compatibility */
1365fcf5ef2aSThomas Huth
1366fcf5ef2aSThomas Huth /* Power management */
1367fcf5ef2aSThomas Huth int (*check_pow)(CPUPPCState *env);
1368fcf5ef2aSThomas Huth
136945693f94SNicholas Piggin /* attn instruction enable */
137045693f94SNicholas Piggin int (*check_attn)(CPUPPCState *env);
137145693f94SNicholas Piggin
1372fcf5ef2aSThomas Huth #if !defined(CONFIG_USER_ONLY)
1373ad5db2e7SBALATON Zoltan void *load_info; /* holds boot loading state */
1374fcf5ef2aSThomas Huth #endif
1375fcf5ef2aSThomas Huth
1376fcf5ef2aSThomas Huth /* booke timers */
1377fcf5ef2aSThomas Huth
1378c647e3feSDavid Gibson /*
1379ad5db2e7SBALATON Zoltan * Specifies bit locations of the Time Base used to signal a fixed timer
1380ad5db2e7SBALATON Zoltan * exception on a transition from 0 to 1 (watchdog or fixed-interval timer)
1381fcf5ef2aSThomas Huth *
1382ad5db2e7SBALATON Zoltan * 0 selects the least significant bit, 63 selects the most significant bit
1383fcf5ef2aSThomas Huth */
1384fcf5ef2aSThomas Huth uint8_t fit_period[4];
1385fcf5ef2aSThomas Huth uint8_t wdt_period[4];
1386fcf5ef2aSThomas Huth
1387fcf5ef2aSThomas Huth /* Transactional memory state */
1388fcf5ef2aSThomas Huth target_ulong tm_gpr[32];
1389fcf5ef2aSThomas Huth ppc_avr_t tm_vsr[64];
1390fcf5ef2aSThomas Huth uint64_t tm_cr;
1391fcf5ef2aSThomas Huth uint64_t tm_lr;
1392fcf5ef2aSThomas Huth uint64_t tm_ctr;
1393fcf5ef2aSThomas Huth uint64_t tm_fpscr;
1394fcf5ef2aSThomas Huth uint64_t tm_amr;
1395fcf5ef2aSThomas Huth uint64_t tm_ppr;
1396fcf5ef2aSThomas Huth uint64_t tm_vrsave;
1397fcf5ef2aSThomas Huth uint32_t tm_vscr;
1398fcf5ef2aSThomas Huth uint64_t tm_dscr;
1399fcf5ef2aSThomas Huth uint64_t tm_tar;
14008f2e9d40SDaniel Henrique Barboza
14018f2e9d40SDaniel Henrique Barboza /*
14028f2e9d40SDaniel Henrique Barboza * Timers used to fire performance monitor alerts
14038f2e9d40SDaniel Henrique Barboza * when counting cycles.
14048f2e9d40SDaniel Henrique Barboza */
14058f2e9d40SDaniel Henrique Barboza QEMUTimer *pmu_cyc_overflow_timers[PMU_COUNTERS_NUM];
1406c2eff582SDaniel Henrique Barboza
1407c2eff582SDaniel Henrique Barboza /*
1408c2eff582SDaniel Henrique Barboza * PMU base time value used by the PMU to calculate
1409c2eff582SDaniel Henrique Barboza * running cycles.
1410c2eff582SDaniel Henrique Barboza */
1411c2eff582SDaniel Henrique Barboza uint64_t pmu_base_time;
1412fcf5ef2aSThomas Huth };
1413fcf5ef2aSThomas Huth
1414b769d4c8SNicholas Piggin #define THREAD_SIBLING_FOREACH(cs, cs_sibling) \
1415b769d4c8SNicholas Piggin CPU_FOREACH(cs_sibling) \
1416*2fc0a78aSGlenn Miles if ((POWERPC_CPU(cs)->env.chip_index == \
1417*2fc0a78aSGlenn Miles POWERPC_CPU(cs_sibling)->env.chip_index) && \
1418*2fc0a78aSGlenn Miles (POWERPC_CPU(cs)->env.core_index == \
1419*2fc0a78aSGlenn Miles POWERPC_CPU(cs_sibling)->env.core_index))
1420b769d4c8SNicholas Piggin
1421fcf5ef2aSThomas Huth #define SET_FIT_PERIOD(a_, b_, c_, d_) \
1422fcf5ef2aSThomas Huth do { \
1423fcf5ef2aSThomas Huth env->fit_period[0] = (a_); \
1424fcf5ef2aSThomas Huth env->fit_period[1] = (b_); \
1425fcf5ef2aSThomas Huth env->fit_period[2] = (c_); \
1426fcf5ef2aSThomas Huth env->fit_period[3] = (d_); \
1427fcf5ef2aSThomas Huth } while (0)
1428fcf5ef2aSThomas Huth
1429fcf5ef2aSThomas Huth #define SET_WDT_PERIOD(a_, b_, c_, d_) \
1430fcf5ef2aSThomas Huth do { \
1431fcf5ef2aSThomas Huth env->wdt_period[0] = (a_); \
1432fcf5ef2aSThomas Huth env->wdt_period[1] = (b_); \
1433fcf5ef2aSThomas Huth env->wdt_period[2] = (c_); \
1434fcf5ef2aSThomas Huth env->wdt_period[3] = (d_); \
1435fcf5ef2aSThomas Huth } while (0)
1436fcf5ef2aSThomas Huth
14371d1be34dSDavid Gibson typedef struct PPCVirtualHypervisor PPCVirtualHypervisor;
14381d1be34dSDavid Gibson typedef struct PPCVirtualHypervisorClass PPCVirtualHypervisorClass;
14390d8d6a24SThomas Huth
1440fcf5ef2aSThomas Huth /**
1441fcf5ef2aSThomas Huth * PowerPCCPU:
1442fcf5ef2aSThomas Huth * @env: #CPUPPCState
144381210c20SSam Bobroff * @vcpu_id: vCPU identifier given to KVM
1444d6e166c0SDavid Gibson * @compat_pvr: Current logical PVR, zero if in "raw" mode
1445fcf5ef2aSThomas Huth *
1446fcf5ef2aSThomas Huth * A PowerPC CPU.
1447fcf5ef2aSThomas Huth */
1448b36e239eSPhilippe Mathieu-Daudé struct ArchCPU {
1449fcf5ef2aSThomas Huth CPUState parent_obj;
1450fcf5ef2aSThomas Huth
1451fcf5ef2aSThomas Huth CPUPPCState env;
14525b146dc7SRichard Henderson
145381210c20SSam Bobroff int vcpu_id;
1454d6e166c0SDavid Gibson uint32_t compat_pvr;
14551d1be34dSDavid Gibson PPCVirtualHypervisor *vhyp;
1456c700b5e1SNicholas Piggin PPCVirtualHypervisorClass *vhyp_class;
14577388efafSDavid Gibson void *machine_data;
145815f8b142SIgor Mammedov int32_t node_id; /* NUMA node this CPU belongs to */
1459b07c59f7SDavid Gibson PPCHash64Options *hash64_opts;
1460fcf5ef2aSThomas Huth
146128876bf2SAlex Bennée /* Those resources are used only during code translation */
146228876bf2SAlex Bennée /* opcode handlers */
146328876bf2SAlex Bennée opc_handler_t *opcodes[PPC_CPU_OPCODES_LEN];
1464fcf5ef2aSThomas Huth };
1465fcf5ef2aSThomas Huth
1466f3cb3325SPhilippe Mathieu-Daudé /**
1467f3cb3325SPhilippe Mathieu-Daudé * PowerPCCPUClass:
1468f3cb3325SPhilippe Mathieu-Daudé * @parent_realize: The parent class' realize handler.
1469f3cb3325SPhilippe Mathieu-Daudé * @parent_phases: The parent class' reset phase handlers.
1470f3cb3325SPhilippe Mathieu-Daudé *
1471f3cb3325SPhilippe Mathieu-Daudé * A PowerPC CPU model.
1472f3cb3325SPhilippe Mathieu-Daudé */
1473f3cb3325SPhilippe Mathieu-Daudé struct PowerPCCPUClass {
1474f3cb3325SPhilippe Mathieu-Daudé CPUClass parent_class;
1475f3cb3325SPhilippe Mathieu-Daudé
1476f3cb3325SPhilippe Mathieu-Daudé DeviceRealize parent_realize;
1477f3cb3325SPhilippe Mathieu-Daudé DeviceUnrealize parent_unrealize;
1478f3cb3325SPhilippe Mathieu-Daudé ResettablePhases parent_phases;
1479f3cb3325SPhilippe Mathieu-Daudé void (*parent_parse_features)(const char *type, char *str, Error **errp);
1480f3cb3325SPhilippe Mathieu-Daudé
1481f3cb3325SPhilippe Mathieu-Daudé uint32_t pvr;
1482c0b2f0ddSAditya Gupta uint32_t spapr_logical_pvr;
1483f3cb3325SPhilippe Mathieu-Daudé /*
1484f3cb3325SPhilippe Mathieu-Daudé * If @best is false, match if pcc is in the family of pvr
1485f3cb3325SPhilippe Mathieu-Daudé * Else match only if pcc is the best match for pvr in this family.
1486f3cb3325SPhilippe Mathieu-Daudé */
1487f3cb3325SPhilippe Mathieu-Daudé bool (*pvr_match)(struct PowerPCCPUClass *pcc, uint32_t pvr, bool best);
1488f3cb3325SPhilippe Mathieu-Daudé uint64_t pcr_mask; /* Available bits in PCR register */
1489f3cb3325SPhilippe Mathieu-Daudé uint64_t pcr_supported; /* Bits for supported PowerISA versions */
1490f3cb3325SPhilippe Mathieu-Daudé uint32_t svr;
1491f3cb3325SPhilippe Mathieu-Daudé uint64_t insns_flags;
1492f3cb3325SPhilippe Mathieu-Daudé uint64_t insns_flags2;
1493f3cb3325SPhilippe Mathieu-Daudé uint64_t msr_mask;
1494f3cb3325SPhilippe Mathieu-Daudé uint64_t lpcr_mask; /* Available bits in the LPCR */
1495f3cb3325SPhilippe Mathieu-Daudé uint64_t lpcr_pm; /* Power-saving mode Exit Cause Enable bits */
1496f3cb3325SPhilippe Mathieu-Daudé powerpc_mmu_t mmu_model;
1497f3cb3325SPhilippe Mathieu-Daudé powerpc_excp_t excp_model;
1498f3cb3325SPhilippe Mathieu-Daudé powerpc_input_t bus_model;
1499f3cb3325SPhilippe Mathieu-Daudé uint32_t flags;
1500f3cb3325SPhilippe Mathieu-Daudé int bfd_mach;
1501f3cb3325SPhilippe Mathieu-Daudé uint32_t l1_dcache_size, l1_icache_size;
1502f3cb3325SPhilippe Mathieu-Daudé #ifndef CONFIG_USER_ONLY
15031b53948fSAkihiko Odaki GDBFeature gdb_spr;
1504f3cb3325SPhilippe Mathieu-Daudé #endif
1505f3cb3325SPhilippe Mathieu-Daudé const PPCHash64Options *hash64_opts;
1506f3cb3325SPhilippe Mathieu-Daudé struct ppc_radix_page_info *radix_page_info;
1507f3cb3325SPhilippe Mathieu-Daudé uint32_t lrg_decr_bits;
1508f3cb3325SPhilippe Mathieu-Daudé int n_host_threads;
1509f3cb3325SPhilippe Mathieu-Daudé void (*init_proc)(CPUPPCState *env);
1510f3cb3325SPhilippe Mathieu-Daudé int (*check_pow)(CPUPPCState *env);
151145693f94SNicholas Piggin int (*check_attn)(CPUPPCState *env);
1512f3cb3325SPhilippe Mathieu-Daudé };
1513fcf5ef2aSThomas Huth
ppc_cpu_core_single_threaded(CPUState * cs)151450d8cfb9SNicholas Piggin static inline bool ppc_cpu_core_single_threaded(CPUState *cs)
151550d8cfb9SNicholas Piggin {
151659c921f2SNicholas Piggin return !POWERPC_CPU(cs)->env.has_smt_siblings;
151750d8cfb9SNicholas Piggin }
151850d8cfb9SNicholas Piggin
ppc_cpu_lpar_single_threaded(CPUState * cs)151950d8cfb9SNicholas Piggin static inline bool ppc_cpu_lpar_single_threaded(CPUState *cs)
152050d8cfb9SNicholas Piggin {
152150d8cfb9SNicholas Piggin return !(POWERPC_CPU(cs)->env.flags & POWERPC_FLAG_SMT_1LPAR) ||
152250d8cfb9SNicholas Piggin ppc_cpu_core_single_threaded(cs);
152350d8cfb9SNicholas Piggin }
152450d8cfb9SNicholas Piggin
1525866c8cf9SPhilippe Mathieu-Daudé ObjectClass *ppc_cpu_class_by_name(const char *name);
1526fcf5ef2aSThomas Huth PowerPCCPUClass *ppc_cpu_class_by_pvr(uint32_t pvr);
1527fcf5ef2aSThomas Huth PowerPCCPUClass *ppc_cpu_class_by_pvr_mask(uint32_t pvr);
1528e9edd931SThomas Huth PowerPCCPUClass *ppc_cpu_get_family_class(PowerPCCPUClass *pcc);
1529fcf5ef2aSThomas Huth
1530e89aac1aSPhilippe Mathieu-Daudé #ifndef CONFIG_USER_ONLY
15311d1be34dSDavid Gibson struct PPCVirtualHypervisorClass {
15321d1be34dSDavid Gibson InterfaceClass parent;
15337cebc5dbSNicholas Piggin bool (*cpu_in_nested)(PowerPCCPU *cpu);
15347cebc5dbSNicholas Piggin void (*deliver_hv_excp)(PowerPCCPU *cpu, int excp);
15351d1be34dSDavid Gibson void (*hypercall)(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu);
1536e57ca75cSDavid Gibson hwaddr (*hpt_mask)(PPCVirtualHypervisor *vhyp);
1537e57ca75cSDavid Gibson const ppc_hash_pte64_t *(*map_hptes)(PPCVirtualHypervisor *vhyp,
1538e57ca75cSDavid Gibson hwaddr ptex, int n);
1539e57ca75cSDavid Gibson void (*unmap_hptes)(PPCVirtualHypervisor *vhyp,
1540e57ca75cSDavid Gibson const ppc_hash_pte64_t *hptes,
1541e57ca75cSDavid Gibson hwaddr ptex, int n);
1542a2dd4e83SBenjamin Herrenschmidt void (*hpte_set_c)(PPCVirtualHypervisor *vhyp, hwaddr ptex, uint64_t pte1);
1543a2dd4e83SBenjamin Herrenschmidt void (*hpte_set_r)(PPCVirtualHypervisor *vhyp, hwaddr ptex, uint64_t pte1);
1544f32d4ab4SNicholas Piggin bool (*get_pate)(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu,
1545f32d4ab4SNicholas Piggin target_ulong lpid, ppc_v3_pate_t *entry);
15461ec26c75SGreg Kurz target_ulong (*encode_hpt_for_kvm_pr)(PPCVirtualHypervisor *vhyp);
154703ef074cSNicholas Piggin void (*cpu_exec_enter)(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu);
154803ef074cSNicholas Piggin void (*cpu_exec_exit)(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu);
15491d1be34dSDavid Gibson };
15501d1be34dSDavid Gibson
15511d1be34dSDavid Gibson #define TYPE_PPC_VIRTUAL_HYPERVISOR "ppc-virtual-hypervisor"
DECLARE_OBJ_CHECKERS(PPCVirtualHypervisor,PPCVirtualHypervisorClass,PPC_VIRTUAL_HYPERVISOR,TYPE_PPC_VIRTUAL_HYPERVISOR)15528110fa1dSEduardo Habkost DECLARE_OBJ_CHECKERS(PPCVirtualHypervisor, PPCVirtualHypervisorClass,
15538110fa1dSEduardo Habkost PPC_VIRTUAL_HYPERVISOR, TYPE_PPC_VIRTUAL_HYPERVISOR)
15547cebc5dbSNicholas Piggin
15557cebc5dbSNicholas Piggin static inline bool vhyp_cpu_in_nested(PowerPCCPU *cpu)
15567cebc5dbSNicholas Piggin {
1557c700b5e1SNicholas Piggin return cpu->vhyp_class->cpu_in_nested(cpu);
15587cebc5dbSNicholas Piggin }
1559e89aac1aSPhilippe Mathieu-Daudé #endif /* CONFIG_USER_ONLY */
15601d1be34dSDavid Gibson
156190c84c56SMarkus Armbruster void ppc_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
1562a010bdbeSAlex Bennée int ppc_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
1563a010bdbeSAlex Bennée int ppc_cpu_gdb_read_register_apple(CPUState *cpu, GByteArray *buf, int reg);
1564fcf5ef2aSThomas Huth int ppc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
1565fcf5ef2aSThomas Huth int ppc_cpu_gdb_write_register_apple(CPUState *cpu, uint8_t *buf, int reg);
1566707c7c2eSFabiano Rosas #ifndef CONFIG_USER_ONLY
15676d2d454aSPhilippe Mathieu-Daudé hwaddr ppc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
1568707c7c2eSFabiano Rosas #endif
1569fcf5ef2aSThomas Huth int ppc64_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs,
15701af0006aSJanosch Frank int cpuid, DumpState *s);
1571356bb70eSMike Nawrocki int ppc32_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs,
15721af0006aSJanosch Frank int cpuid, DumpState *s);
1573fcf5ef2aSThomas Huth #ifndef CONFIG_USER_ONLY
15742fdedcbcSMatheus Ferst void ppc_maybe_interrupt(CPUPPCState *env);
1575f725245cSPhilippe Mathieu-Daudé void ppc_cpu_do_interrupt(CPUState *cpu);
1576f725245cSPhilippe Mathieu-Daudé bool ppc_cpu_exec_interrupt(CPUState *cpu, int int_req);
1577b5b7f391SNicholas Piggin void ppc_cpu_do_system_reset(CPUState *cs);
1578ad77c6caSNicholas Piggin void ppc_cpu_do_fwnmi_machine_check(CPUState *cs, target_ulong vector);
15798a9358ccSMarkus Armbruster extern const VMStateDescription vmstate_ppc_cpu;
1580fcf5ef2aSThomas Huth #endif
1581fcf5ef2aSThomas Huth
1582fcf5ef2aSThomas Huth /*****************************************************************************/
1583fcf5ef2aSThomas Huth void ppc_translate_init(void);
1584fcf5ef2aSThomas Huth
1585fcf5ef2aSThomas Huth #if !defined(CONFIG_USER_ONLY)
1586fcf5ef2aSThomas Huth void ppc_store_sdr1(CPUPPCState *env, target_ulong value);
15876a8e8188SMatheus Ferst void ppc_store_lpcr(PowerPCCPU *cpu, target_ulong val);
158814192307SNicholas Piggin void ppc_update_ciabr(CPUPPCState *env);
158914192307SNicholas Piggin void ppc_store_ciabr(CPUPPCState *env, target_ulong value);
1590d5ee641cSNicholas Piggin void ppc_update_daw0(CPUPPCState *env);
1591d5ee641cSNicholas Piggin void ppc_store_dawr0(CPUPPCState *env, target_ulong value);
1592d5ee641cSNicholas Piggin void ppc_store_dawrx0(CPUPPCState *env, uint32_t value);
1593fcf5ef2aSThomas Huth #endif /* !defined(CONFIG_USER_ONLY) */
1594fcf5ef2aSThomas Huth void ppc_store_msr(CPUPPCState *env, target_ulong value);
1595fcf5ef2aSThomas Huth
15960442428aSMarkus Armbruster void ppc_cpu_list(void);
1597fcf5ef2aSThomas Huth
1598fcf5ef2aSThomas Huth /* Time-base and decrementer management */
1599fcf5ef2aSThomas Huth uint64_t cpu_ppc_load_tbl(CPUPPCState *env);
1600fcf5ef2aSThomas Huth uint32_t cpu_ppc_load_tbu(CPUPPCState *env);
1601fcf5ef2aSThomas Huth void cpu_ppc_store_tbu(CPUPPCState *env, uint32_t value);
1602fcf5ef2aSThomas Huth void cpu_ppc_store_tbl(CPUPPCState *env, uint32_t value);
1603fcf5ef2aSThomas Huth uint64_t cpu_ppc_load_atbl(CPUPPCState *env);
1604fcf5ef2aSThomas Huth uint32_t cpu_ppc_load_atbu(CPUPPCState *env);
1605fcf5ef2aSThomas Huth void cpu_ppc_store_atbl(CPUPPCState *env, uint32_t value);
1606fcf5ef2aSThomas Huth void cpu_ppc_store_atbu(CPUPPCState *env, uint32_t value);
160749771107SHarsh Prateek Bora void cpu_ppc_increase_tb_by_offset(CPUPPCState *env, int64_t offset);
160849771107SHarsh Prateek Bora void cpu_ppc_decrease_tb_by_offset(CPUPPCState *env, int64_t offset);
16095d62725bSSuraj Jitindar Singh uint64_t cpu_ppc_load_vtb(CPUPPCState *env);
16105d62725bSSuraj Jitindar Singh void cpu_ppc_store_vtb(CPUPPCState *env, uint64_t value);
1611fcf5ef2aSThomas Huth bool ppc_decr_clear_on_delivery(CPUPPCState *env);
1612a8dafa52SSuraj Jitindar Singh target_ulong cpu_ppc_load_decr(CPUPPCState *env);
1613a8dafa52SSuraj Jitindar Singh void cpu_ppc_store_decr(CPUPPCState *env, target_ulong value);
1614a8dafa52SSuraj Jitindar Singh target_ulong cpu_ppc_load_hdecr(CPUPPCState *env);
1615a8dafa52SSuraj Jitindar Singh void cpu_ppc_store_hdecr(CPUPPCState *env, target_ulong value);
1616f0ec31b1SSuraj Jitindar Singh void cpu_ppc_store_tbu40(CPUPPCState *env, uint64_t value);
1617fcf5ef2aSThomas Huth uint64_t cpu_ppc_load_purr(CPUPPCState *env);
16185cc7e69fSSuraj Jitindar Singh void cpu_ppc_store_purr(CPUPPCState *env, uint64_t value);
1619fcf5ef2aSThomas Huth #if !defined(CONFIG_USER_ONLY)
1620fcf5ef2aSThomas Huth target_ulong load_40x_pit(CPUPPCState *env);
1621fcf5ef2aSThomas Huth void store_40x_pit(CPUPPCState *env, target_ulong val);
1622fcf5ef2aSThomas Huth void store_40x_dbcr0(CPUPPCState *env, uint32_t val);
1623fcf5ef2aSThomas Huth void store_40x_sler(CPUPPCState *env, uint32_t val);
1624cbd8f17dSCédric Le Goater void store_40x_tcr(CPUPPCState *env, target_ulong val);
1625cbd8f17dSCédric Le Goater void store_40x_tsr(CPUPPCState *env, target_ulong val);
1626fcf5ef2aSThomas Huth void store_booke_tcr(CPUPPCState *env, target_ulong val);
1627fcf5ef2aSThomas Huth void store_booke_tsr(CPUPPCState *env, target_ulong val);
1628fcf5ef2aSThomas Huth void ppc_tlb_invalidate_all(CPUPPCState *env);
1629fcf5ef2aSThomas Huth void ppc_tlb_invalidate_one(CPUPPCState *env, target_ulong addr);
1630da20aed1SDavid Gibson void cpu_ppc_set_vhyp(PowerPCCPU *cpu, PPCVirtualHypervisor *vhyp);
16313401ea3cSNicholas Piggin void cpu_ppc_set_1lpar(PowerPCCPU *cpu);
1632fcf5ef2aSThomas Huth #endif
1633fcf5ef2aSThomas Huth
1634fe43ba97SBruno Larsen (billionai) void ppc_store_fpscr(CPUPPCState *env, target_ulong val);
1635493028d8SCédric Le Goater void helper_hfscr_facility_check(CPUPPCState *env, uint32_t bit,
1636493028d8SCédric Le Goater const char *caller, uint32_t cause);
1637fcf5ef2aSThomas Huth
ppc_dump_gpr(CPUPPCState * env,int gprn)1638fcf5ef2aSThomas Huth static inline uint64_t ppc_dump_gpr(CPUPPCState *env, int gprn)
1639fcf5ef2aSThomas Huth {
1640fcf5ef2aSThomas Huth uint64_t gprv;
1641fcf5ef2aSThomas Huth
1642fcf5ef2aSThomas Huth gprv = env->gpr[gprn];
1643fcf5ef2aSThomas Huth if (env->flags & POWERPC_FLAG_SPE) {
1644c647e3feSDavid Gibson /*
1645c647e3feSDavid Gibson * If the CPU implements the SPE extension, we have to get the
1646fcf5ef2aSThomas Huth * high bits of the GPR from the gprh storage area
1647fcf5ef2aSThomas Huth */
1648fcf5ef2aSThomas Huth gprv &= 0xFFFFFFFFULL;
1649fcf5ef2aSThomas Huth gprv |= (uint64_t)env->gprh[gprn] << 32;
1650fcf5ef2aSThomas Huth }
1651fcf5ef2aSThomas Huth
1652fcf5ef2aSThomas Huth return gprv;
1653fcf5ef2aSThomas Huth }
1654fcf5ef2aSThomas Huth
1655fcf5ef2aSThomas Huth /* Device control registers */
1656fcf5ef2aSThomas Huth int ppc_dcr_read(ppc_dcr_t *dcr_env, int dcrn, uint32_t *valp);
1657fcf5ef2aSThomas Huth int ppc_dcr_write(ppc_dcr_t *dcr_env, int dcrn, uint32_t val);
1658fcf5ef2aSThomas Huth
1659fcf5ef2aSThomas Huth #define cpu_list ppc_cpu_list
1660fcf5ef2aSThomas Huth
1661fcf5ef2aSThomas Huth /* MMU modes definitions */
1662fcf5ef2aSThomas Huth #define MMU_USER_IDX 0
ppc_env_mmu_index(CPUPPCState * env,bool ifetch)1663fb00f730SRichard Henderson static inline int ppc_env_mmu_index(CPUPPCState *env, bool ifetch)
1664fcf5ef2aSThomas Huth {
1665d764184dSRichard Henderson #ifdef CONFIG_USER_ONLY
1666d764184dSRichard Henderson return MMU_USER_IDX;
1667d764184dSRichard Henderson #else
1668d764184dSRichard Henderson return (env->hflags >> (ifetch ? HFLAGS_IMMU_IDX : HFLAGS_DMMU_IDX)) & 7;
1669d764184dSRichard Henderson #endif
1670fcf5ef2aSThomas Huth }
1671fcf5ef2aSThomas Huth
16729d6f1065SDavid Gibson /* Compatibility modes */
16739d6f1065SDavid Gibson #if defined(TARGET_PPC64)
16749d2179d6SDavid Gibson bool ppc_check_compat(PowerPCCPU *cpu, uint32_t compat_pvr,
16759d2179d6SDavid Gibson uint32_t min_compat_pvr, uint32_t max_compat_pvr);
1676ad99d04cSDavid Gibson bool ppc_type_check_compat(const char *cputype, uint32_t compat_pvr,
1677ad99d04cSDavid Gibson uint32_t min_compat_pvr, uint32_t max_compat_pvr);
1678ad99d04cSDavid Gibson
16792c82e8dfSGreg Kurz int ppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pvr, Error **errp);
1680ad99d04cSDavid Gibson
1681f6f242c7SDavid Gibson #if !defined(CONFIG_USER_ONLY)
16822c82e8dfSGreg Kurz int ppc_set_compat_all(uint32_t compat_pvr, Error **errp);
16839c7b7f01SNicholas Piggin int ppc_init_compat_all(uint32_t compat_pvr, Error **errp);
1684f6f242c7SDavid Gibson #endif
1685abbc1247SDavid Gibson int ppc_compat_max_vthreads(PowerPCCPU *cpu);
16867843c0d6SDavid Gibson void ppc_compat_add_property(Object *obj, const char *name,
168740c2281cSMarkus Armbruster uint32_t *compat_pvr, const char *basedesc);
16889d6f1065SDavid Gibson #endif /* defined(TARGET_PPC64) */
16899d6f1065SDavid Gibson
1690fcf5ef2aSThomas Huth #include "exec/cpu-all.h"
1691fcf5ef2aSThomas Huth
1692fcf5ef2aSThomas Huth /*****************************************************************************/
1693fcf5ef2aSThomas Huth /* CRF definitions */
1694efa73196SNikunj A Dadhania #define CRF_LT_BIT 3
1695efa73196SNikunj A Dadhania #define CRF_GT_BIT 2
1696efa73196SNikunj A Dadhania #define CRF_EQ_BIT 1
1697efa73196SNikunj A Dadhania #define CRF_SO_BIT 0
1698efa73196SNikunj A Dadhania #define CRF_LT (1 << CRF_LT_BIT)
1699efa73196SNikunj A Dadhania #define CRF_GT (1 << CRF_GT_BIT)
1700efa73196SNikunj A Dadhania #define CRF_EQ (1 << CRF_EQ_BIT)
1701efa73196SNikunj A Dadhania #define CRF_SO (1 << CRF_SO_BIT)
1702efa73196SNikunj A Dadhania /* For SPE extensions */
1703efa73196SNikunj A Dadhania #define CRF_CH (1 << CRF_LT_BIT)
1704efa73196SNikunj A Dadhania #define CRF_CL (1 << CRF_GT_BIT)
1705efa73196SNikunj A Dadhania #define CRF_CH_OR_CL (1 << CRF_EQ_BIT)
1706efa73196SNikunj A Dadhania #define CRF_CH_AND_CL (1 << CRF_SO_BIT)
1707fcf5ef2aSThomas Huth
1708fcf5ef2aSThomas Huth /* XER definitions */
1709fcf5ef2aSThomas Huth #define XER_SO 31
1710fcf5ef2aSThomas Huth #define XER_OV 30
1711fcf5ef2aSThomas Huth #define XER_CA 29
1712dd09c361SNikunj A Dadhania #define XER_OV32 19
1713dd09c361SNikunj A Dadhania #define XER_CA32 18
1714fcf5ef2aSThomas Huth #define XER_CMP 8
1715fcf5ef2aSThomas Huth #define XER_BC 0
1716fcf5ef2aSThomas Huth #define xer_so (env->so)
1717fcf5ef2aSThomas Huth #define xer_cmp ((env->xer >> XER_CMP) & 0xFF)
1718fcf5ef2aSThomas Huth #define xer_bc ((env->xer >> XER_BC) & 0x7F)
1719fcf5ef2aSThomas Huth
1720fcf5ef2aSThomas Huth /* SPR definitions */
1721fcf5ef2aSThomas Huth #define SPR_MQ (0x000)
1722fcf5ef2aSThomas Huth #define SPR_XER (0x001)
1723fcf5ef2aSThomas Huth #define SPR_LR (0x008)
1724fcf5ef2aSThomas Huth #define SPR_CTR (0x009)
1725f244115cSThomas Huth #define SPR_UAMR (0x00D)
1726fcf5ef2aSThomas Huth #define SPR_DSCR (0x011)
1727fcf5ef2aSThomas Huth #define SPR_DSISR (0x012)
1728005b69fdSCédric Le Goater #define SPR_DAR (0x013)
1729fcf5ef2aSThomas Huth #define SPR_DECR (0x016)
1730fcf5ef2aSThomas Huth #define SPR_SDR1 (0x019)
1731fcf5ef2aSThomas Huth #define SPR_SRR0 (0x01A)
1732fcf5ef2aSThomas Huth #define SPR_SRR1 (0x01B)
1733fcf5ef2aSThomas Huth #define SPR_CFAR (0x01C)
1734fcf5ef2aSThomas Huth #define SPR_AMR (0x01D)
1735fcf5ef2aSThomas Huth #define SPR_ACOP (0x01F)
1736fcf5ef2aSThomas Huth #define SPR_BOOKE_PID (0x030)
1737fcf5ef2aSThomas Huth #define SPR_BOOKS_PID (0x030)
1738fcf5ef2aSThomas Huth #define SPR_BOOKE_DECAR (0x036)
1739fcf5ef2aSThomas Huth #define SPR_BOOKE_CSRR0 (0x03A)
1740fcf5ef2aSThomas Huth #define SPR_BOOKE_CSRR1 (0x03B)
1741fcf5ef2aSThomas Huth #define SPR_BOOKE_DEAR (0x03D)
1742fcf5ef2aSThomas Huth #define SPR_IAMR (0x03D)
1743fcf5ef2aSThomas Huth #define SPR_BOOKE_ESR (0x03E)
1744fcf5ef2aSThomas Huth #define SPR_BOOKE_IVPR (0x03F)
1745fcf5ef2aSThomas Huth #define SPR_MPC_EIE (0x050)
1746fcf5ef2aSThomas Huth #define SPR_MPC_EID (0x051)
1747fcf5ef2aSThomas Huth #define SPR_MPC_NRI (0x052)
1748fcf5ef2aSThomas Huth #define SPR_TFHAR (0x080)
1749fcf5ef2aSThomas Huth #define SPR_TFIAR (0x081)
1750fcf5ef2aSThomas Huth #define SPR_TEXASR (0x082)
1751fcf5ef2aSThomas Huth #define SPR_TEXASRU (0x083)
1752fcf5ef2aSThomas Huth #define SPR_UCTRL (0x088)
1753650f3287SDavid Gibson #define SPR_TIDR (0x090)
1754fcf5ef2aSThomas Huth #define SPR_MPC_CMPA (0x090)
1755fcf5ef2aSThomas Huth #define SPR_MPC_CMPB (0x091)
1756fcf5ef2aSThomas Huth #define SPR_MPC_CMPC (0x092)
1757fcf5ef2aSThomas Huth #define SPR_MPC_CMPD (0x093)
1758fcf5ef2aSThomas Huth #define SPR_MPC_ECR (0x094)
1759fcf5ef2aSThomas Huth #define SPR_MPC_DER (0x095)
1760fcf5ef2aSThomas Huth #define SPR_MPC_COUNTA (0x096)
1761fcf5ef2aSThomas Huth #define SPR_MPC_COUNTB (0x097)
1762fcf5ef2aSThomas Huth #define SPR_CTRL (0x098)
1763fcf5ef2aSThomas Huth #define SPR_MPC_CMPE (0x098)
1764fcf5ef2aSThomas Huth #define SPR_MPC_CMPF (0x099)
1765fcf5ef2aSThomas Huth #define SPR_FSCR (0x099)
1766fcf5ef2aSThomas Huth #define SPR_MPC_CMPG (0x09A)
1767fcf5ef2aSThomas Huth #define SPR_MPC_CMPH (0x09B)
1768fcf5ef2aSThomas Huth #define SPR_MPC_LCTRL1 (0x09C)
1769fcf5ef2aSThomas Huth #define SPR_MPC_LCTRL2 (0x09D)
1770fcf5ef2aSThomas Huth #define SPR_UAMOR (0x09D)
1771fcf5ef2aSThomas Huth #define SPR_MPC_ICTRL (0x09E)
1772fcf5ef2aSThomas Huth #define SPR_MPC_BAR (0x09F)
1773fcf5ef2aSThomas Huth #define SPR_PSPB (0x09F)
1774cfc61ba6SAlexey Kardashevskiy #define SPR_DPDES (0x0B0)
1775a7913d5eSRavi Bangoria #define SPR_DAWR0 (0x0B4)
1776bb23bcceSHarsh Prateek Bora #define SPR_DAWR1 (0x0B5)
1777fcf5ef2aSThomas Huth #define SPR_RPR (0x0BA)
1778fcf5ef2aSThomas Huth #define SPR_CIABR (0x0BB)
1779a7913d5eSRavi Bangoria #define SPR_DAWRX0 (0x0BC)
1780bb23bcceSHarsh Prateek Bora #define SPR_DAWRX1 (0x0BD)
1781fcf5ef2aSThomas Huth #define SPR_HFSCR (0x0BE)
1782fcf5ef2aSThomas Huth #define SPR_VRSAVE (0x100)
1783fcf5ef2aSThomas Huth #define SPR_USPRG0 (0x100)
1784fcf5ef2aSThomas Huth #define SPR_USPRG1 (0x101)
1785fcf5ef2aSThomas Huth #define SPR_USPRG2 (0x102)
1786fcf5ef2aSThomas Huth #define SPR_USPRG3 (0x103)
1787fcf5ef2aSThomas Huth #define SPR_USPRG4 (0x104)
1788fcf5ef2aSThomas Huth #define SPR_USPRG5 (0x105)
1789fcf5ef2aSThomas Huth #define SPR_USPRG6 (0x106)
1790fcf5ef2aSThomas Huth #define SPR_USPRG7 (0x107)
179180e28a41SNicholas Piggin #define SPR_TBL (0x10C)
179280e28a41SNicholas Piggin #define SPR_TBU (0x10D)
1793fcf5ef2aSThomas Huth #define SPR_SPRG0 (0x110)
1794fcf5ef2aSThomas Huth #define SPR_SPRG1 (0x111)
1795fcf5ef2aSThomas Huth #define SPR_SPRG2 (0x112)
1796fcf5ef2aSThomas Huth #define SPR_SPRG3 (0x113)
1797fcf5ef2aSThomas Huth #define SPR_SPRG4 (0x114)
17982736432fSNicholas Piggin #define SPR_POWER_SPRC (0x114)
1799fcf5ef2aSThomas Huth #define SPR_SPRG5 (0x115)
18002736432fSNicholas Piggin #define SPR_POWER_SPRD (0x115)
1801fcf5ef2aSThomas Huth #define SPR_SPRG6 (0x116)
1802fcf5ef2aSThomas Huth #define SPR_SPRG7 (0x117)
1803fcf5ef2aSThomas Huth #define SPR_ASR (0x118)
1804fcf5ef2aSThomas Huth #define SPR_EAR (0x11A)
180580e28a41SNicholas Piggin #define SPR_WR_TBL (0x11C)
180680e28a41SNicholas Piggin #define SPR_WR_TBU (0x11D)
1807fcf5ef2aSThomas Huth #define SPR_TBU40 (0x11E)
1808fcf5ef2aSThomas Huth #define SPR_SVR (0x11E)
1809fcf5ef2aSThomas Huth #define SPR_BOOKE_PIR (0x11E)
1810fcf5ef2aSThomas Huth #define SPR_PVR (0x11F)
1811fcf5ef2aSThomas Huth #define SPR_HSPRG0 (0x130)
1812fcf5ef2aSThomas Huth #define SPR_BOOKE_DBSR (0x130)
1813fcf5ef2aSThomas Huth #define SPR_HSPRG1 (0x131)
1814fcf5ef2aSThomas Huth #define SPR_HDSISR (0x132)
1815fcf5ef2aSThomas Huth #define SPR_HDAR (0x133)
1816fcf5ef2aSThomas Huth #define SPR_BOOKE_EPCR (0x133)
1817fcf5ef2aSThomas Huth #define SPR_SPURR (0x134)
1818fcf5ef2aSThomas Huth #define SPR_BOOKE_DBCR0 (0x134)
1819fcf5ef2aSThomas Huth #define SPR_IBCR (0x135)
1820fcf5ef2aSThomas Huth #define SPR_PURR (0x135)
1821fcf5ef2aSThomas Huth #define SPR_BOOKE_DBCR1 (0x135)
1822fcf5ef2aSThomas Huth #define SPR_DBCR (0x136)
1823fcf5ef2aSThomas Huth #define SPR_HDEC (0x136)
1824fcf5ef2aSThomas Huth #define SPR_BOOKE_DBCR2 (0x136)
1825fcf5ef2aSThomas Huth #define SPR_HIOR (0x137)
1826fcf5ef2aSThomas Huth #define SPR_MBAR (0x137)
1827fcf5ef2aSThomas Huth #define SPR_RMOR (0x138)
1828fcf5ef2aSThomas Huth #define SPR_BOOKE_IAC1 (0x138)
1829fcf5ef2aSThomas Huth #define SPR_HRMOR (0x139)
1830fcf5ef2aSThomas Huth #define SPR_BOOKE_IAC2 (0x139)
1831fcf5ef2aSThomas Huth #define SPR_HSRR0 (0x13A)
1832fcf5ef2aSThomas Huth #define SPR_BOOKE_IAC3 (0x13A)
1833fcf5ef2aSThomas Huth #define SPR_HSRR1 (0x13B)
1834fcf5ef2aSThomas Huth #define SPR_BOOKE_IAC4 (0x13B)
1835fcf5ef2aSThomas Huth #define SPR_BOOKE_DAC1 (0x13C)
1836fcf5ef2aSThomas Huth #define SPR_MMCRH (0x13C)
1837fcf5ef2aSThomas Huth #define SPR_DABR2 (0x13D)
1838fcf5ef2aSThomas Huth #define SPR_BOOKE_DAC2 (0x13D)
1839fcf5ef2aSThomas Huth #define SPR_TFMR (0x13D)
1840fcf5ef2aSThomas Huth #define SPR_BOOKE_DVC1 (0x13E)
1841fcf5ef2aSThomas Huth #define SPR_LPCR (0x13E)
1842fcf5ef2aSThomas Huth #define SPR_BOOKE_DVC2 (0x13F)
1843fcf5ef2aSThomas Huth #define SPR_LPIDR (0x13F)
1844fcf5ef2aSThomas Huth #define SPR_BOOKE_TSR (0x150)
1845fcf5ef2aSThomas Huth #define SPR_HMER (0x150)
1846fcf5ef2aSThomas Huth #define SPR_HMEER (0x151)
1847fcf5ef2aSThomas Huth #define SPR_PCR (0x152)
1848a3c020d8SNicholas Piggin #define SPR_HEIR (0x153)
1849fcf5ef2aSThomas Huth #define SPR_BOOKE_LPIDR (0x152)
1850fcf5ef2aSThomas Huth #define SPR_BOOKE_TCR (0x154)
1851fcf5ef2aSThomas Huth #define SPR_BOOKE_TLB0PS (0x158)
1852fcf5ef2aSThomas Huth #define SPR_BOOKE_TLB1PS (0x159)
1853fcf5ef2aSThomas Huth #define SPR_BOOKE_TLB2PS (0x15A)
1854fcf5ef2aSThomas Huth #define SPR_BOOKE_TLB3PS (0x15B)
1855fcf5ef2aSThomas Huth #define SPR_AMOR (0x15D)
1856fcf5ef2aSThomas Huth #define SPR_BOOKE_MAS7_MAS3 (0x174)
1857fcf5ef2aSThomas Huth #define SPR_BOOKE_IVOR0 (0x190)
1858fcf5ef2aSThomas Huth #define SPR_BOOKE_IVOR1 (0x191)
1859fcf5ef2aSThomas Huth #define SPR_BOOKE_IVOR2 (0x192)
1860fcf5ef2aSThomas Huth #define SPR_BOOKE_IVOR3 (0x193)
1861fcf5ef2aSThomas Huth #define SPR_BOOKE_IVOR4 (0x194)
1862fcf5ef2aSThomas Huth #define SPR_BOOKE_IVOR5 (0x195)
1863fcf5ef2aSThomas Huth #define SPR_BOOKE_IVOR6 (0x196)
1864fcf5ef2aSThomas Huth #define SPR_BOOKE_IVOR7 (0x197)
1865fcf5ef2aSThomas Huth #define SPR_BOOKE_IVOR8 (0x198)
1866fcf5ef2aSThomas Huth #define SPR_BOOKE_IVOR9 (0x199)
1867fcf5ef2aSThomas Huth #define SPR_BOOKE_IVOR10 (0x19A)
1868fcf5ef2aSThomas Huth #define SPR_BOOKE_IVOR11 (0x19B)
1869fcf5ef2aSThomas Huth #define SPR_BOOKE_IVOR12 (0x19C)
1870fcf5ef2aSThomas Huth #define SPR_BOOKE_IVOR13 (0x19D)
1871fcf5ef2aSThomas Huth #define SPR_BOOKE_IVOR14 (0x19E)
1872fcf5ef2aSThomas Huth #define SPR_BOOKE_IVOR15 (0x19F)
1873fcf5ef2aSThomas Huth #define SPR_BOOKE_IVOR38 (0x1B0)
1874fcf5ef2aSThomas Huth #define SPR_BOOKE_IVOR39 (0x1B1)
1875fcf5ef2aSThomas Huth #define SPR_BOOKE_IVOR40 (0x1B2)
1876fcf5ef2aSThomas Huth #define SPR_BOOKE_IVOR41 (0x1B3)
1877fcf5ef2aSThomas Huth #define SPR_BOOKE_IVOR42 (0x1B4)
1878fcf5ef2aSThomas Huth #define SPR_BOOKE_GIVOR2 (0x1B8)
1879fcf5ef2aSThomas Huth #define SPR_BOOKE_GIVOR3 (0x1B9)
1880fcf5ef2aSThomas Huth #define SPR_BOOKE_GIVOR4 (0x1BA)
1881fcf5ef2aSThomas Huth #define SPR_BOOKE_GIVOR8 (0x1BB)
1882fcf5ef2aSThomas Huth #define SPR_BOOKE_GIVOR13 (0x1BC)
1883fcf5ef2aSThomas Huth #define SPR_BOOKE_GIVOR14 (0x1BD)
1884fcf5ef2aSThomas Huth #define SPR_TIR (0x1BE)
1885395b5d5bSNicholas Miehlbradt #define SPR_UHDEXCR (0x1C7)
18864a7518e0SCédric Le Goater #define SPR_PTCR (0x1D0)
1887903f84ebSVíctor Colombo #define SPR_HASHKEYR (0x1D4)
1888903f84ebSVíctor Colombo #define SPR_HASHPKEYR (0x1D5)
1889395b5d5bSNicholas Miehlbradt #define SPR_HDEXCR (0x1D7)
1890fcf5ef2aSThomas Huth #define SPR_BOOKE_SPEFSCR (0x200)
1891fcf5ef2aSThomas Huth #define SPR_Exxx_BBEAR (0x201)
1892fcf5ef2aSThomas Huth #define SPR_Exxx_BBTAR (0x202)
1893fcf5ef2aSThomas Huth #define SPR_Exxx_L1CFG0 (0x203)
1894fcf5ef2aSThomas Huth #define SPR_Exxx_L1CFG1 (0x204)
1895fcf5ef2aSThomas Huth #define SPR_Exxx_NPIDR (0x205)
1896fcf5ef2aSThomas Huth #define SPR_ATBL (0x20E)
1897fcf5ef2aSThomas Huth #define SPR_ATBU (0x20F)
1898fcf5ef2aSThomas Huth #define SPR_IBAT0U (0x210)
1899fcf5ef2aSThomas Huth #define SPR_BOOKE_IVOR32 (0x210)
1900fcf5ef2aSThomas Huth #define SPR_RCPU_MI_GRA (0x210)
1901fcf5ef2aSThomas Huth #define SPR_IBAT0L (0x211)
1902fcf5ef2aSThomas Huth #define SPR_BOOKE_IVOR33 (0x211)
1903fcf5ef2aSThomas Huth #define SPR_IBAT1U (0x212)
1904fcf5ef2aSThomas Huth #define SPR_BOOKE_IVOR34 (0x212)
1905fcf5ef2aSThomas Huth #define SPR_IBAT1L (0x213)
1906fcf5ef2aSThomas Huth #define SPR_BOOKE_IVOR35 (0x213)
1907fcf5ef2aSThomas Huth #define SPR_IBAT2U (0x214)
1908fcf5ef2aSThomas Huth #define SPR_BOOKE_IVOR36 (0x214)
1909fcf5ef2aSThomas Huth #define SPR_IBAT2L (0x215)
1910fcf5ef2aSThomas Huth #define SPR_BOOKE_IVOR37 (0x215)
1911fcf5ef2aSThomas Huth #define SPR_IBAT3U (0x216)
1912fcf5ef2aSThomas Huth #define SPR_IBAT3L (0x217)
1913fcf5ef2aSThomas Huth #define SPR_DBAT0U (0x218)
1914fcf5ef2aSThomas Huth #define SPR_RCPU_L2U_GRA (0x218)
1915fcf5ef2aSThomas Huth #define SPR_DBAT0L (0x219)
1916fcf5ef2aSThomas Huth #define SPR_DBAT1U (0x21A)
1917fcf5ef2aSThomas Huth #define SPR_DBAT1L (0x21B)
1918fcf5ef2aSThomas Huth #define SPR_DBAT2U (0x21C)
1919fcf5ef2aSThomas Huth #define SPR_DBAT2L (0x21D)
1920fcf5ef2aSThomas Huth #define SPR_DBAT3U (0x21E)
1921fcf5ef2aSThomas Huth #define SPR_DBAT3L (0x21F)
1922fcf5ef2aSThomas Huth #define SPR_IBAT4U (0x230)
1923fcf5ef2aSThomas Huth #define SPR_RPCU_BBCMCR (0x230)
1924fcf5ef2aSThomas Huth #define SPR_MPC_IC_CST (0x230)
1925fcf5ef2aSThomas Huth #define SPR_Exxx_CTXCR (0x230)
1926fcf5ef2aSThomas Huth #define SPR_IBAT4L (0x231)
1927fcf5ef2aSThomas Huth #define SPR_MPC_IC_ADR (0x231)
1928fcf5ef2aSThomas Huth #define SPR_Exxx_DBCR3 (0x231)
1929fcf5ef2aSThomas Huth #define SPR_IBAT5U (0x232)
1930fcf5ef2aSThomas Huth #define SPR_MPC_IC_DAT (0x232)
1931fcf5ef2aSThomas Huth #define SPR_Exxx_DBCNT (0x232)
1932fcf5ef2aSThomas Huth #define SPR_IBAT5L (0x233)
1933fcf5ef2aSThomas Huth #define SPR_IBAT6U (0x234)
1934fcf5ef2aSThomas Huth #define SPR_IBAT6L (0x235)
1935fcf5ef2aSThomas Huth #define SPR_IBAT7U (0x236)
1936fcf5ef2aSThomas Huth #define SPR_IBAT7L (0x237)
1937fcf5ef2aSThomas Huth #define SPR_DBAT4U (0x238)
1938fcf5ef2aSThomas Huth #define SPR_RCPU_L2U_MCR (0x238)
1939fcf5ef2aSThomas Huth #define SPR_MPC_DC_CST (0x238)
1940fcf5ef2aSThomas Huth #define SPR_Exxx_ALTCTXCR (0x238)
1941fcf5ef2aSThomas Huth #define SPR_DBAT4L (0x239)
1942fcf5ef2aSThomas Huth #define SPR_MPC_DC_ADR (0x239)
1943fcf5ef2aSThomas Huth #define SPR_DBAT5U (0x23A)
1944fcf5ef2aSThomas Huth #define SPR_BOOKE_MCSRR0 (0x23A)
1945fcf5ef2aSThomas Huth #define SPR_MPC_DC_DAT (0x23A)
1946fcf5ef2aSThomas Huth #define SPR_DBAT5L (0x23B)
1947fcf5ef2aSThomas Huth #define SPR_BOOKE_MCSRR1 (0x23B)
1948fcf5ef2aSThomas Huth #define SPR_DBAT6U (0x23C)
1949fcf5ef2aSThomas Huth #define SPR_BOOKE_MCSR (0x23C)
1950fcf5ef2aSThomas Huth #define SPR_DBAT6L (0x23D)
1951fcf5ef2aSThomas Huth #define SPR_Exxx_MCAR (0x23D)
1952fcf5ef2aSThomas Huth #define SPR_DBAT7U (0x23E)
1953fcf5ef2aSThomas Huth #define SPR_BOOKE_DSRR0 (0x23E)
1954fcf5ef2aSThomas Huth #define SPR_DBAT7L (0x23F)
1955fcf5ef2aSThomas Huth #define SPR_BOOKE_DSRR1 (0x23F)
1956fcf5ef2aSThomas Huth #define SPR_BOOKE_SPRG8 (0x25C)
1957fcf5ef2aSThomas Huth #define SPR_BOOKE_SPRG9 (0x25D)
1958fcf5ef2aSThomas Huth #define SPR_BOOKE_MAS0 (0x270)
1959fcf5ef2aSThomas Huth #define SPR_BOOKE_MAS1 (0x271)
1960fcf5ef2aSThomas Huth #define SPR_BOOKE_MAS2 (0x272)
1961fcf5ef2aSThomas Huth #define SPR_BOOKE_MAS3 (0x273)
1962fcf5ef2aSThomas Huth #define SPR_BOOKE_MAS4 (0x274)
1963fcf5ef2aSThomas Huth #define SPR_BOOKE_MAS5 (0x275)
1964fcf5ef2aSThomas Huth #define SPR_BOOKE_MAS6 (0x276)
1965fcf5ef2aSThomas Huth #define SPR_BOOKE_PID1 (0x279)
1966fcf5ef2aSThomas Huth #define SPR_BOOKE_PID2 (0x27A)
1967fcf5ef2aSThomas Huth #define SPR_MPC_DPDR (0x280)
1968fcf5ef2aSThomas Huth #define SPR_MPC_IMMR (0x288)
1969fcf5ef2aSThomas Huth #define SPR_BOOKE_TLB0CFG (0x2B0)
1970fcf5ef2aSThomas Huth #define SPR_BOOKE_TLB1CFG (0x2B1)
1971fcf5ef2aSThomas Huth #define SPR_BOOKE_TLB2CFG (0x2B2)
1972fcf5ef2aSThomas Huth #define SPR_BOOKE_TLB3CFG (0x2B3)
1973fcf5ef2aSThomas Huth #define SPR_BOOKE_EPR (0x2BE)
19740b889323SMadhavan Srinivasan #define SPR_POWER_USIER2 (0x2E0)
19750b889323SMadhavan Srinivasan #define SPR_POWER_USIER3 (0x2E1)
19760b889323SMadhavan Srinivasan #define SPR_POWER_UMMCR3 (0x2E2)
19770b889323SMadhavan Srinivasan #define SPR_POWER_SIER2 (0x2F0)
19780b889323SMadhavan Srinivasan #define SPR_POWER_SIER3 (0x2F1)
19790b889323SMadhavan Srinivasan #define SPR_POWER_MMCR3 (0x2F2)
1980fcf5ef2aSThomas Huth #define SPR_PERF0 (0x300)
1981fcf5ef2aSThomas Huth #define SPR_RCPU_MI_RBA0 (0x300)
1982fcf5ef2aSThomas Huth #define SPR_MPC_MI_CTR (0x300)
1983fcf5ef2aSThomas Huth #define SPR_POWER_USIER (0x300)
1984fcf5ef2aSThomas Huth #define SPR_PERF1 (0x301)
1985fcf5ef2aSThomas Huth #define SPR_RCPU_MI_RBA1 (0x301)
1986fcf5ef2aSThomas Huth #define SPR_POWER_UMMCR2 (0x301)
1987fcf5ef2aSThomas Huth #define SPR_PERF2 (0x302)
1988fcf5ef2aSThomas Huth #define SPR_RCPU_MI_RBA2 (0x302)
1989fcf5ef2aSThomas Huth #define SPR_MPC_MI_AP (0x302)
1990fcf5ef2aSThomas Huth #define SPR_POWER_UMMCRA (0x302)
1991fcf5ef2aSThomas Huth #define SPR_PERF3 (0x303)
1992fcf5ef2aSThomas Huth #define SPR_RCPU_MI_RBA3 (0x303)
1993fcf5ef2aSThomas Huth #define SPR_MPC_MI_EPN (0x303)
1994fcf5ef2aSThomas Huth #define SPR_POWER_UPMC1 (0x303)
1995fcf5ef2aSThomas Huth #define SPR_PERF4 (0x304)
1996fcf5ef2aSThomas Huth #define SPR_POWER_UPMC2 (0x304)
1997fcf5ef2aSThomas Huth #define SPR_PERF5 (0x305)
1998fcf5ef2aSThomas Huth #define SPR_MPC_MI_TWC (0x305)
1999fcf5ef2aSThomas Huth #define SPR_POWER_UPMC3 (0x305)
2000fcf5ef2aSThomas Huth #define SPR_PERF6 (0x306)
2001fcf5ef2aSThomas Huth #define SPR_MPC_MI_RPN (0x306)
2002fcf5ef2aSThomas Huth #define SPR_POWER_UPMC4 (0x306)
2003fcf5ef2aSThomas Huth #define SPR_PERF7 (0x307)
2004fcf5ef2aSThomas Huth #define SPR_POWER_UPMC5 (0x307)
2005fcf5ef2aSThomas Huth #define SPR_PERF8 (0x308)
2006fcf5ef2aSThomas Huth #define SPR_RCPU_L2U_RBA0 (0x308)
2007fcf5ef2aSThomas Huth #define SPR_MPC_MD_CTR (0x308)
2008fcf5ef2aSThomas Huth #define SPR_POWER_UPMC6 (0x308)
2009fcf5ef2aSThomas Huth #define SPR_PERF9 (0x309)
2010fcf5ef2aSThomas Huth #define SPR_RCPU_L2U_RBA1 (0x309)
2011fcf5ef2aSThomas Huth #define SPR_MPC_MD_CASID (0x309)
2012fcf5ef2aSThomas Huth #define SPR_970_UPMC7 (0X309)
2013fcf5ef2aSThomas Huth #define SPR_PERFA (0x30A)
2014fcf5ef2aSThomas Huth #define SPR_RCPU_L2U_RBA2 (0x30A)
2015fcf5ef2aSThomas Huth #define SPR_MPC_MD_AP (0x30A)
2016fcf5ef2aSThomas Huth #define SPR_970_UPMC8 (0X30A)
2017fcf5ef2aSThomas Huth #define SPR_PERFB (0x30B)
2018fcf5ef2aSThomas Huth #define SPR_RCPU_L2U_RBA3 (0x30B)
2019fcf5ef2aSThomas Huth #define SPR_MPC_MD_EPN (0x30B)
2020fcf5ef2aSThomas Huth #define SPR_POWER_UMMCR0 (0X30B)
2021fcf5ef2aSThomas Huth #define SPR_PERFC (0x30C)
2022fcf5ef2aSThomas Huth #define SPR_MPC_MD_TWB (0x30C)
2023fcf5ef2aSThomas Huth #define SPR_POWER_USIAR (0X30C)
2024fcf5ef2aSThomas Huth #define SPR_PERFD (0x30D)
2025fcf5ef2aSThomas Huth #define SPR_MPC_MD_TWC (0x30D)
2026fcf5ef2aSThomas Huth #define SPR_POWER_USDAR (0X30D)
2027fcf5ef2aSThomas Huth #define SPR_PERFE (0x30E)
2028fcf5ef2aSThomas Huth #define SPR_MPC_MD_RPN (0x30E)
2029fcf5ef2aSThomas Huth #define SPR_POWER_UMMCR1 (0X30E)
2030fcf5ef2aSThomas Huth #define SPR_PERFF (0x30F)
2031fcf5ef2aSThomas Huth #define SPR_MPC_MD_TW (0x30F)
2032fcf5ef2aSThomas Huth #define SPR_UPERF0 (0x310)
2033fcf5ef2aSThomas Huth #define SPR_POWER_SIER (0x310)
2034fcf5ef2aSThomas Huth #define SPR_UPERF1 (0x311)
2035fcf5ef2aSThomas Huth #define SPR_POWER_MMCR2 (0x311)
2036fcf5ef2aSThomas Huth #define SPR_UPERF2 (0x312)
2037fcf5ef2aSThomas Huth #define SPR_POWER_MMCRA (0X312)
2038fcf5ef2aSThomas Huth #define SPR_UPERF3 (0x313)
2039fcf5ef2aSThomas Huth #define SPR_POWER_PMC1 (0X313)
2040fcf5ef2aSThomas Huth #define SPR_UPERF4 (0x314)
2041fcf5ef2aSThomas Huth #define SPR_POWER_PMC2 (0X314)
2042fcf5ef2aSThomas Huth #define SPR_UPERF5 (0x315)
2043fcf5ef2aSThomas Huth #define SPR_POWER_PMC3 (0X315)
2044fcf5ef2aSThomas Huth #define SPR_UPERF6 (0x316)
2045fcf5ef2aSThomas Huth #define SPR_POWER_PMC4 (0X316)
2046fcf5ef2aSThomas Huth #define SPR_UPERF7 (0x317)
2047fcf5ef2aSThomas Huth #define SPR_POWER_PMC5 (0X317)
2048fcf5ef2aSThomas Huth #define SPR_UPERF8 (0x318)
2049fcf5ef2aSThomas Huth #define SPR_POWER_PMC6 (0X318)
2050fcf5ef2aSThomas Huth #define SPR_UPERF9 (0x319)
2051fcf5ef2aSThomas Huth #define SPR_970_PMC7 (0X319)
2052fcf5ef2aSThomas Huth #define SPR_UPERFA (0x31A)
2053fcf5ef2aSThomas Huth #define SPR_970_PMC8 (0X31A)
2054fcf5ef2aSThomas Huth #define SPR_UPERFB (0x31B)
2055fcf5ef2aSThomas Huth #define SPR_POWER_MMCR0 (0X31B)
2056fcf5ef2aSThomas Huth #define SPR_UPERFC (0x31C)
2057fcf5ef2aSThomas Huth #define SPR_POWER_SIAR (0X31C)
2058fcf5ef2aSThomas Huth #define SPR_UPERFD (0x31D)
2059fcf5ef2aSThomas Huth #define SPR_POWER_SDAR (0X31D)
2060fcf5ef2aSThomas Huth #define SPR_UPERFE (0x31E)
2061fcf5ef2aSThomas Huth #define SPR_POWER_MMCR1 (0X31E)
2062fcf5ef2aSThomas Huth #define SPR_UPERFF (0x31F)
2063fcf5ef2aSThomas Huth #define SPR_RCPU_MI_RA0 (0x320)
2064fcf5ef2aSThomas Huth #define SPR_MPC_MI_DBCAM (0x320)
2065fcf5ef2aSThomas Huth #define SPR_BESCRS (0x320)
2066fcf5ef2aSThomas Huth #define SPR_RCPU_MI_RA1 (0x321)
2067fcf5ef2aSThomas Huth #define SPR_MPC_MI_DBRAM0 (0x321)
2068fcf5ef2aSThomas Huth #define SPR_BESCRSU (0x321)
2069fcf5ef2aSThomas Huth #define SPR_RCPU_MI_RA2 (0x322)
2070fcf5ef2aSThomas Huth #define SPR_MPC_MI_DBRAM1 (0x322)
2071fcf5ef2aSThomas Huth #define SPR_BESCRR (0x322)
2072fcf5ef2aSThomas Huth #define SPR_RCPU_MI_RA3 (0x323)
2073fcf5ef2aSThomas Huth #define SPR_BESCRRU (0x323)
2074fcf5ef2aSThomas Huth #define SPR_EBBHR (0x324)
2075fcf5ef2aSThomas Huth #define SPR_EBBRR (0x325)
2076fcf5ef2aSThomas Huth #define SPR_BESCR (0x326)
2077fcf5ef2aSThomas Huth #define SPR_RCPU_L2U_RA0 (0x328)
2078fcf5ef2aSThomas Huth #define SPR_MPC_MD_DBCAM (0x328)
2079fcf5ef2aSThomas Huth #define SPR_RCPU_L2U_RA1 (0x329)
2080fcf5ef2aSThomas Huth #define SPR_MPC_MD_DBRAM0 (0x329)
2081fcf5ef2aSThomas Huth #define SPR_RCPU_L2U_RA2 (0x32A)
2082fcf5ef2aSThomas Huth #define SPR_MPC_MD_DBRAM1 (0x32A)
2083fcf5ef2aSThomas Huth #define SPR_RCPU_L2U_RA3 (0x32B)
2084395b5d5bSNicholas Miehlbradt #define SPR_UDEXCR (0x32C)
2085fcf5ef2aSThomas Huth #define SPR_TAR (0x32F)
208632d0f0d8SSuraj Jitindar Singh #define SPR_ASDR (0x330)
2087395b5d5bSNicholas Miehlbradt #define SPR_DEXCR (0x33C)
2088fcf5ef2aSThomas Huth #define SPR_IC (0x350)
2089fcf5ef2aSThomas Huth #define SPR_VTB (0x351)
2090c9d5aedfSNicholas Piggin #define SPR_LDBAR (0x352)
2091fcf5ef2aSThomas Huth #define SPR_MMCRC (0x353)
2092b8af5b2dSDavid Gibson #define SPR_PSSCR (0x357)
2093fcf5ef2aSThomas Huth #define SPR_440_INV0 (0x370)
2094fcf5ef2aSThomas Huth #define SPR_440_INV1 (0x371)
209599837aa8SJoel Stanley #define SPR_TRIG1 (0x371)
2096fcf5ef2aSThomas Huth #define SPR_440_INV2 (0x372)
209799837aa8SJoel Stanley #define SPR_TRIG2 (0x372)
2098fcf5ef2aSThomas Huth #define SPR_440_INV3 (0x373)
2099fcf5ef2aSThomas Huth #define SPR_440_ITV0 (0x374)
2100fcf5ef2aSThomas Huth #define SPR_440_ITV1 (0x375)
2101fcf5ef2aSThomas Huth #define SPR_440_ITV2 (0x376)
2102fcf5ef2aSThomas Huth #define SPR_440_ITV3 (0x377)
2103fcf5ef2aSThomas Huth #define SPR_440_CCR1 (0x378)
2104fcf5ef2aSThomas Huth #define SPR_TACR (0x378)
2105fcf5ef2aSThomas Huth #define SPR_TCSCR (0x379)
2106fcf5ef2aSThomas Huth #define SPR_CSIGR (0x37a)
2107fcf5ef2aSThomas Huth #define SPR_DCRIPR (0x37B)
2108fcf5ef2aSThomas Huth #define SPR_POWER_SPMC1 (0x37C)
2109fcf5ef2aSThomas Huth #define SPR_POWER_SPMC2 (0x37D)
2110fcf5ef2aSThomas Huth #define SPR_POWER_MMCRS (0x37E)
2111fcf5ef2aSThomas Huth #define SPR_WORT (0x37F)
2112fcf5ef2aSThomas Huth #define SPR_PPR (0x380)
21131cbcbcb8SNicholas Piggin #define SPR_PPR32 (0x382)
2114fcf5ef2aSThomas Huth #define SPR_750_GQR0 (0x390)
2115fcf5ef2aSThomas Huth #define SPR_440_DNV0 (0x390)
2116fcf5ef2aSThomas Huth #define SPR_750_GQR1 (0x391)
2117fcf5ef2aSThomas Huth #define SPR_440_DNV1 (0x391)
2118fcf5ef2aSThomas Huth #define SPR_750_GQR2 (0x392)
2119fcf5ef2aSThomas Huth #define SPR_440_DNV2 (0x392)
2120fcf5ef2aSThomas Huth #define SPR_750_GQR3 (0x393)
2121fcf5ef2aSThomas Huth #define SPR_440_DNV3 (0x393)
2122fcf5ef2aSThomas Huth #define SPR_750_GQR4 (0x394)
2123fcf5ef2aSThomas Huth #define SPR_440_DTV0 (0x394)
2124fcf5ef2aSThomas Huth #define SPR_750_GQR5 (0x395)
2125fcf5ef2aSThomas Huth #define SPR_440_DTV1 (0x395)
2126fcf5ef2aSThomas Huth #define SPR_750_GQR6 (0x396)
2127fcf5ef2aSThomas Huth #define SPR_440_DTV2 (0x396)
2128fcf5ef2aSThomas Huth #define SPR_750_GQR7 (0x397)
2129fcf5ef2aSThomas Huth #define SPR_440_DTV3 (0x397)
2130fcf5ef2aSThomas Huth #define SPR_750_THRM4 (0x398)
2131fcf5ef2aSThomas Huth #define SPR_750CL_HID2 (0x398)
2132fcf5ef2aSThomas Huth #define SPR_440_DVLIM (0x398)
2133fcf5ef2aSThomas Huth #define SPR_750_WPAR (0x399)
2134fcf5ef2aSThomas Huth #define SPR_440_IVLIM (0x399)
2135fcf5ef2aSThomas Huth #define SPR_TSCR (0x399)
2136fcf5ef2aSThomas Huth #define SPR_750_DMAU (0x39A)
2137c9d5aedfSNicholas Piggin #define SPR_POWER_TTR (0x39A)
2138fcf5ef2aSThomas Huth #define SPR_750_DMAL (0x39B)
2139fcf5ef2aSThomas Huth #define SPR_440_RSTCFG (0x39B)
2140fcf5ef2aSThomas Huth #define SPR_BOOKE_DCDBTRL (0x39C)
2141fcf5ef2aSThomas Huth #define SPR_BOOKE_DCDBTRH (0x39D)
2142fcf5ef2aSThomas Huth #define SPR_BOOKE_ICDBTRL (0x39E)
2143fcf5ef2aSThomas Huth #define SPR_BOOKE_ICDBTRH (0x39F)
2144fcf5ef2aSThomas Huth #define SPR_74XX_UMMCR2 (0x3A0)
2145fcf5ef2aSThomas Huth #define SPR_7XX_UPMC5 (0x3A1)
2146fcf5ef2aSThomas Huth #define SPR_7XX_UPMC6 (0x3A2)
2147fcf5ef2aSThomas Huth #define SPR_UBAMR (0x3A7)
2148fcf5ef2aSThomas Huth #define SPR_7XX_UMMCR0 (0x3A8)
2149fcf5ef2aSThomas Huth #define SPR_7XX_UPMC1 (0x3A9)
2150fcf5ef2aSThomas Huth #define SPR_7XX_UPMC2 (0x3AA)
2151fcf5ef2aSThomas Huth #define SPR_7XX_USIAR (0x3AB)
2152fcf5ef2aSThomas Huth #define SPR_7XX_UMMCR1 (0x3AC)
2153fcf5ef2aSThomas Huth #define SPR_7XX_UPMC3 (0x3AD)
2154fcf5ef2aSThomas Huth #define SPR_7XX_UPMC4 (0x3AE)
2155fcf5ef2aSThomas Huth #define SPR_USDA (0x3AF)
2156fcf5ef2aSThomas Huth #define SPR_40x_ZPR (0x3B0)
2157fcf5ef2aSThomas Huth #define SPR_BOOKE_MAS7 (0x3B0)
2158fcf5ef2aSThomas Huth #define SPR_74XX_MMCR2 (0x3B0)
2159fcf5ef2aSThomas Huth #define SPR_7XX_PMC5 (0x3B1)
2160fcf5ef2aSThomas Huth #define SPR_40x_PID (0x3B1)
2161fcf5ef2aSThomas Huth #define SPR_7XX_PMC6 (0x3B2)
2162fcf5ef2aSThomas Huth #define SPR_440_MMUCR (0x3B2)
2163fcf5ef2aSThomas Huth #define SPR_4xx_CCR0 (0x3B3)
2164fcf5ef2aSThomas Huth #define SPR_BOOKE_EPLC (0x3B3)
2165fcf5ef2aSThomas Huth #define SPR_405_IAC3 (0x3B4)
2166fcf5ef2aSThomas Huth #define SPR_BOOKE_EPSC (0x3B4)
2167fcf5ef2aSThomas Huth #define SPR_405_IAC4 (0x3B5)
2168fcf5ef2aSThomas Huth #define SPR_405_DVC1 (0x3B6)
2169fcf5ef2aSThomas Huth #define SPR_405_DVC2 (0x3B7)
2170fcf5ef2aSThomas Huth #define SPR_BAMR (0x3B7)
2171fcf5ef2aSThomas Huth #define SPR_7XX_MMCR0 (0x3B8)
2172fcf5ef2aSThomas Huth #define SPR_7XX_PMC1 (0x3B9)
2173fcf5ef2aSThomas Huth #define SPR_40x_SGR (0x3B9)
2174fcf5ef2aSThomas Huth #define SPR_7XX_PMC2 (0x3BA)
2175fcf5ef2aSThomas Huth #define SPR_40x_DCWR (0x3BA)
2176fcf5ef2aSThomas Huth #define SPR_7XX_SIAR (0x3BB)
2177fcf5ef2aSThomas Huth #define SPR_405_SLER (0x3BB)
2178fcf5ef2aSThomas Huth #define SPR_7XX_MMCR1 (0x3BC)
2179fcf5ef2aSThomas Huth #define SPR_405_SU0R (0x3BC)
2180fcf5ef2aSThomas Huth #define SPR_401_SKR (0x3BC)
2181fcf5ef2aSThomas Huth #define SPR_7XX_PMC3 (0x3BD)
2182fcf5ef2aSThomas Huth #define SPR_405_DBCR1 (0x3BD)
2183fcf5ef2aSThomas Huth #define SPR_7XX_PMC4 (0x3BE)
2184fcf5ef2aSThomas Huth #define SPR_SDA (0x3BF)
2185fcf5ef2aSThomas Huth #define SPR_403_VTBL (0x3CC)
2186fcf5ef2aSThomas Huth #define SPR_403_VTBU (0x3CD)
2187fcf5ef2aSThomas Huth #define SPR_DMISS (0x3D0)
2188fcf5ef2aSThomas Huth #define SPR_DCMP (0x3D1)
2189fcf5ef2aSThomas Huth #define SPR_HASH1 (0x3D2)
2190fcf5ef2aSThomas Huth #define SPR_HASH2 (0x3D3)
2191fcf5ef2aSThomas Huth #define SPR_BOOKE_ICDBDR (0x3D3)
2192fcf5ef2aSThomas Huth #define SPR_TLBMISS (0x3D4)
2193fcf5ef2aSThomas Huth #define SPR_IMISS (0x3D4)
2194fcf5ef2aSThomas Huth #define SPR_40x_ESR (0x3D4)
2195fcf5ef2aSThomas Huth #define SPR_PTEHI (0x3D5)
2196fcf5ef2aSThomas Huth #define SPR_ICMP (0x3D5)
2197fcf5ef2aSThomas Huth #define SPR_40x_DEAR (0x3D5)
2198fcf5ef2aSThomas Huth #define SPR_PTELO (0x3D6)
2199fcf5ef2aSThomas Huth #define SPR_RPA (0x3D6)
2200fcf5ef2aSThomas Huth #define SPR_40x_EVPR (0x3D6)
2201fcf5ef2aSThomas Huth #define SPR_L3PM (0x3D7)
2202fcf5ef2aSThomas Huth #define SPR_403_CDBCR (0x3D7)
2203fcf5ef2aSThomas Huth #define SPR_L3ITCR0 (0x3D8)
2204fcf5ef2aSThomas Huth #define SPR_TCR (0x3D8)
2205fcf5ef2aSThomas Huth #define SPR_40x_TSR (0x3D8)
2206fcf5ef2aSThomas Huth #define SPR_IBR (0x3DA)
2207fcf5ef2aSThomas Huth #define SPR_40x_TCR (0x3DA)
2208fcf5ef2aSThomas Huth #define SPR_ESASRR (0x3DB)
2209fcf5ef2aSThomas Huth #define SPR_40x_PIT (0x3DB)
2210fcf5ef2aSThomas Huth #define SPR_403_TBL (0x3DC)
2211fcf5ef2aSThomas Huth #define SPR_403_TBU (0x3DD)
2212fcf5ef2aSThomas Huth #define SPR_SEBR (0x3DE)
2213fcf5ef2aSThomas Huth #define SPR_40x_SRR2 (0x3DE)
2214fcf5ef2aSThomas Huth #define SPR_SER (0x3DF)
2215fcf5ef2aSThomas Huth #define SPR_40x_SRR3 (0x3DF)
2216fcf5ef2aSThomas Huth #define SPR_L3OHCR (0x3E8)
2217fcf5ef2aSThomas Huth #define SPR_L3ITCR1 (0x3E9)
2218fcf5ef2aSThomas Huth #define SPR_L3ITCR2 (0x3EA)
2219fcf5ef2aSThomas Huth #define SPR_L3ITCR3 (0x3EB)
2220fcf5ef2aSThomas Huth #define SPR_HID0 (0x3F0)
2221fcf5ef2aSThomas Huth #define SPR_40x_DBSR (0x3F0)
2222fcf5ef2aSThomas Huth #define SPR_HID1 (0x3F1)
2223fcf5ef2aSThomas Huth #define SPR_IABR (0x3F2)
2224fcf5ef2aSThomas Huth #define SPR_40x_DBCR0 (0x3F2)
2225fcf5ef2aSThomas Huth #define SPR_Exxx_L1CSR0 (0x3F2)
2226fcf5ef2aSThomas Huth #define SPR_ICTRL (0x3F3)
2227fcf5ef2aSThomas Huth #define SPR_HID2 (0x3F3)
2228fcf5ef2aSThomas Huth #define SPR_750CL_HID4 (0x3F3)
2229fcf5ef2aSThomas Huth #define SPR_Exxx_L1CSR1 (0x3F3)
2230fcf5ef2aSThomas Huth #define SPR_440_DBDR (0x3F3)
2231fcf5ef2aSThomas Huth #define SPR_LDSTDB (0x3F4)
2232fcf5ef2aSThomas Huth #define SPR_750_TDCL (0x3F4)
2233fcf5ef2aSThomas Huth #define SPR_40x_IAC1 (0x3F4)
2234fcf5ef2aSThomas Huth #define SPR_MMUCSR0 (0x3F4)
2235fcf5ef2aSThomas Huth #define SPR_970_HID4 (0x3F4)
2236fcf5ef2aSThomas Huth #define SPR_DABR (0x3F5)
2237fcf5ef2aSThomas Huth #define DABR_MASK (~(target_ulong)0x7)
2238fcf5ef2aSThomas Huth #define SPR_Exxx_BUCSR (0x3F5)
2239fcf5ef2aSThomas Huth #define SPR_40x_IAC2 (0x3F5)
2240fcf5ef2aSThomas Huth #define SPR_40x_DAC1 (0x3F6)
2241fcf5ef2aSThomas Huth #define SPR_MSSCR0 (0x3F6)
2242fcf5ef2aSThomas Huth #define SPR_970_HID5 (0x3F6)
2243fcf5ef2aSThomas Huth #define SPR_MSSSR0 (0x3F7)
2244fcf5ef2aSThomas Huth #define SPR_MSSCR1 (0x3F7)
2245fcf5ef2aSThomas Huth #define SPR_DABRX (0x3F7)
2246fcf5ef2aSThomas Huth #define SPR_40x_DAC2 (0x3F7)
2247fcf5ef2aSThomas Huth #define SPR_MMUCFG (0x3F7)
2248fcf5ef2aSThomas Huth #define SPR_LDSTCR (0x3F8)
2249fcf5ef2aSThomas Huth #define SPR_L2PMCR (0x3F8)
2250fcf5ef2aSThomas Huth #define SPR_750FX_HID2 (0x3F8)
2251fcf5ef2aSThomas Huth #define SPR_Exxx_L1FINV0 (0x3F8)
2252fcf5ef2aSThomas Huth #define SPR_L2CR (0x3F9)
2253298091f8SBin Meng #define SPR_Exxx_L2CSR0 (0x3F9)
2254fcf5ef2aSThomas Huth #define SPR_L3CR (0x3FA)
2255fcf5ef2aSThomas Huth #define SPR_750_TDCH (0x3FA)
2256fcf5ef2aSThomas Huth #define SPR_IABR2 (0x3FA)
2257fcf5ef2aSThomas Huth #define SPR_40x_DCCR (0x3FA)
2258fcf5ef2aSThomas Huth #define SPR_ICTC (0x3FB)
2259fcf5ef2aSThomas Huth #define SPR_40x_ICCR (0x3FB)
2260fcf5ef2aSThomas Huth #define SPR_THRM1 (0x3FC)
2261fcf5ef2aSThomas Huth #define SPR_403_PBL1 (0x3FC)
2262fcf5ef2aSThomas Huth #define SPR_SP (0x3FD)
2263fcf5ef2aSThomas Huth #define SPR_THRM2 (0x3FD)
2264fcf5ef2aSThomas Huth #define SPR_403_PBU1 (0x3FD)
2265fcf5ef2aSThomas Huth #define SPR_604_HID13 (0x3FD)
2266fcf5ef2aSThomas Huth #define SPR_LT (0x3FE)
2267fcf5ef2aSThomas Huth #define SPR_THRM3 (0x3FE)
2268fcf5ef2aSThomas Huth #define SPR_RCPU_FPECR (0x3FE)
2269fcf5ef2aSThomas Huth #define SPR_403_PBL2 (0x3FE)
2270fcf5ef2aSThomas Huth #define SPR_PIR (0x3FF)
2271fcf5ef2aSThomas Huth #define SPR_403_PBU2 (0x3FF)
2272fcf5ef2aSThomas Huth #define SPR_604_HID15 (0x3FF)
2273fcf5ef2aSThomas Huth #define SPR_E500_SVR (0x3FF)
2274fcf5ef2aSThomas Huth
2275fcf5ef2aSThomas Huth /* Disable MAS Interrupt Updates for Hypervisor */
2276fcf5ef2aSThomas Huth #define EPCR_DMIUH (1 << 22)
2277fcf5ef2aSThomas Huth /* Disable Guest TLB Management Instructions */
2278fcf5ef2aSThomas Huth #define EPCR_DGTMI (1 << 23)
2279fcf5ef2aSThomas Huth /* Guest Interrupt Computation Mode */
2280fcf5ef2aSThomas Huth #define EPCR_GICM (1 << 24)
2281fcf5ef2aSThomas Huth /* Interrupt Computation Mode */
2282fcf5ef2aSThomas Huth #define EPCR_ICM (1 << 25)
2283fcf5ef2aSThomas Huth /* Disable Embedded Hypervisor Debug */
2284fcf5ef2aSThomas Huth #define EPCR_DUVD (1 << 26)
2285fcf5ef2aSThomas Huth /* Instruction Storage Interrupt Directed to Guest State */
2286fcf5ef2aSThomas Huth #define EPCR_ISIGS (1 << 27)
2287fcf5ef2aSThomas Huth /* Data Storage Interrupt Directed to Guest State */
2288fcf5ef2aSThomas Huth #define EPCR_DSIGS (1 << 28)
2289fcf5ef2aSThomas Huth /* Instruction TLB Error Interrupt Directed to Guest State */
2290fcf5ef2aSThomas Huth #define EPCR_ITLBGS (1 << 29)
2291fcf5ef2aSThomas Huth /* Data TLB Error Interrupt Directed to Guest State */
2292fcf5ef2aSThomas Huth #define EPCR_DTLBGS (1 << 30)
2293fcf5ef2aSThomas Huth /* External Input Interrupt Directed to Guest State */
2294fcf5ef2aSThomas Huth #define EPCR_EXTGS (1 << 31)
2295fcf5ef2aSThomas Huth
2296fcf5ef2aSThomas Huth #define L1CSR0_CPE 0x00010000 /* Data Cache Parity Enable */
2297fcf5ef2aSThomas Huth #define L1CSR0_CUL 0x00000400 /* (D-)Cache Unable to Lock */
2298fcf5ef2aSThomas Huth #define L1CSR0_DCLFR 0x00000100 /* D-Cache Lock Flash Reset */
2299fcf5ef2aSThomas Huth #define L1CSR0_DCFI 0x00000002 /* Data Cache Flash Invalidate */
2300fcf5ef2aSThomas Huth #define L1CSR0_DCE 0x00000001 /* Data Cache Enable */
2301fcf5ef2aSThomas Huth
2302fcf5ef2aSThomas Huth #define L1CSR1_CPE 0x00010000 /* Instruction Cache Parity Enable */
2303fcf5ef2aSThomas Huth #define L1CSR1_ICUL 0x00000400 /* I-Cache Unable to Lock */
2304fcf5ef2aSThomas Huth #define L1CSR1_ICLFR 0x00000100 /* I-Cache Lock Flash Reset */
2305fcf5ef2aSThomas Huth #define L1CSR1_ICFI 0x00000002 /* Instruction Cache Flash Invalidate */
2306fcf5ef2aSThomas Huth #define L1CSR1_ICE 0x00000001 /* Instruction Cache Enable */
2307fcf5ef2aSThomas Huth
2308298091f8SBin Meng /* E500 L2CSR0 */
2309298091f8SBin Meng #define E500_L2CSR0_L2FI (1 << 21) /* L2 cache flash invalidate */
2310298091f8SBin Meng #define E500_L2CSR0_L2FL (1 << 11) /* L2 cache flush */
2311298091f8SBin Meng #define E500_L2CSR0_L2LFC (1 << 10) /* L2 cache lock flash clear */
2312298091f8SBin Meng
2313fcf5ef2aSThomas Huth /* HID0 bits */
2314fcf5ef2aSThomas Huth #define HID0_DEEPNAP (1 << 24) /* pre-2.06 */
2315fcf5ef2aSThomas Huth #define HID0_DOZE (1 << 23) /* pre-2.06 */
2316fcf5ef2aSThomas Huth #define HID0_NAP (1 << 22) /* pre-2.06 */
23172a83f997SCédric Le Goater #define HID0_HILE PPC_BIT(19) /* POWER8 */
23180bfc0cf0SCédric Le Goater #define HID0_POWER9_HILE PPC_BIT(4)
231945693f94SNicholas Piggin #define HID0_ENABLE_ATTN PPC_BIT(31) /* POWER8 */
232045693f94SNicholas Piggin #define HID0_POWER9_ENABLE_ATTN PPC_BIT(3)
2321fcf5ef2aSThomas Huth
2322fcf5ef2aSThomas Huth /*****************************************************************************/
2323fcf5ef2aSThomas Huth /* PowerPC Instructions types definitions */
2324fcf5ef2aSThomas Huth enum {
2325fcf5ef2aSThomas Huth PPC_NONE = 0x0000000000000000ULL,
2326fcf5ef2aSThomas Huth /* PowerPC base instructions set */
2327fcf5ef2aSThomas Huth PPC_INSNS_BASE = 0x0000000000000001ULL,
2328fcf5ef2aSThomas Huth /* integer operations instructions */
2329fcf5ef2aSThomas Huth #define PPC_INTEGER PPC_INSNS_BASE
2330fcf5ef2aSThomas Huth /* flow control instructions */
2331fcf5ef2aSThomas Huth #define PPC_FLOW PPC_INSNS_BASE
2332fcf5ef2aSThomas Huth /* virtual memory instructions */
2333fcf5ef2aSThomas Huth #define PPC_MEM PPC_INSNS_BASE
2334fcf5ef2aSThomas Huth /* ld/st with reservation instructions */
2335fcf5ef2aSThomas Huth #define PPC_RES PPC_INSNS_BASE
2336fcf5ef2aSThomas Huth /* spr/msr access instructions */
2337fcf5ef2aSThomas Huth #define PPC_MISC PPC_INSNS_BASE
2338fcf5ef2aSThomas Huth /* 64 bits PowerPC instruction set */
2339fcf5ef2aSThomas Huth PPC_64B = 0x0000000000000020ULL,
2340fcf5ef2aSThomas Huth /* New 64 bits extensions (PowerPC 2.0x) */
2341fcf5ef2aSThomas Huth PPC_64BX = 0x0000000000000040ULL,
2342fcf5ef2aSThomas Huth /* 64 bits hypervisor extensions */
2343fcf5ef2aSThomas Huth PPC_64H = 0x0000000000000080ULL,
2344fcf5ef2aSThomas Huth /* New wait instruction (PowerPC 2.0x) */
2345fcf5ef2aSThomas Huth PPC_WAIT = 0x0000000000000100ULL,
2346fcf5ef2aSThomas Huth /* Time base mftb instruction */
2347fcf5ef2aSThomas Huth PPC_MFTB = 0x0000000000000200ULL,
2348fcf5ef2aSThomas Huth
2349fcf5ef2aSThomas Huth /* Fixed-point unit extensions */
2350fcf5ef2aSThomas Huth /* isel instruction */
2351fcf5ef2aSThomas Huth PPC_ISEL = 0x0000000000000800ULL,
2352fcf5ef2aSThomas Huth /* popcntb instruction */
2353fcf5ef2aSThomas Huth PPC_POPCNTB = 0x0000000000001000ULL,
2354fcf5ef2aSThomas Huth /* string load / store */
2355fcf5ef2aSThomas Huth PPC_STRING = 0x0000000000002000ULL,
2356fcf5ef2aSThomas Huth /* real mode cache inhibited load / store */
2357fcf5ef2aSThomas Huth PPC_CILDST = 0x0000000000004000ULL,
2358fcf5ef2aSThomas Huth
2359fcf5ef2aSThomas Huth /* Floating-point unit extensions */
2360fcf5ef2aSThomas Huth /* Optional floating point instructions */
2361fcf5ef2aSThomas Huth PPC_FLOAT = 0x0000000000010000ULL,
2362fcf5ef2aSThomas Huth /* New floating-point extensions (PowerPC 2.0x) */
2363fcf5ef2aSThomas Huth PPC_FLOAT_EXT = 0x0000000000020000ULL,
2364fcf5ef2aSThomas Huth PPC_FLOAT_FSQRT = 0x0000000000040000ULL,
2365fcf5ef2aSThomas Huth PPC_FLOAT_FRES = 0x0000000000080000ULL,
2366fcf5ef2aSThomas Huth PPC_FLOAT_FRSQRTE = 0x0000000000100000ULL,
2367fcf5ef2aSThomas Huth PPC_FLOAT_FRSQRTES = 0x0000000000200000ULL,
2368fcf5ef2aSThomas Huth PPC_FLOAT_FSEL = 0x0000000000400000ULL,
2369fcf5ef2aSThomas Huth PPC_FLOAT_STFIWX = 0x0000000000800000ULL,
2370fcf5ef2aSThomas Huth
2371fcf5ef2aSThomas Huth /* Vector/SIMD extensions */
2372fcf5ef2aSThomas Huth /* Altivec support */
2373fcf5ef2aSThomas Huth PPC_ALTIVEC = 0x0000000001000000ULL,
2374fcf5ef2aSThomas Huth /* PowerPC 2.03 SPE extension */
2375fcf5ef2aSThomas Huth PPC_SPE = 0x0000000002000000ULL,
2376fcf5ef2aSThomas Huth /* PowerPC 2.03 SPE single-precision floating-point extension */
2377fcf5ef2aSThomas Huth PPC_SPE_SINGLE = 0x0000000004000000ULL,
2378fcf5ef2aSThomas Huth /* PowerPC 2.03 SPE double-precision floating-point extension */
2379fcf5ef2aSThomas Huth PPC_SPE_DOUBLE = 0x0000000008000000ULL,
2380fcf5ef2aSThomas Huth
2381fcf5ef2aSThomas Huth /* Optional memory control instructions */
2382fcf5ef2aSThomas Huth PPC_MEM_TLBIA = 0x0000000010000000ULL,
2383fcf5ef2aSThomas Huth PPC_MEM_TLBIE = 0x0000000020000000ULL,
2384fcf5ef2aSThomas Huth PPC_MEM_TLBSYNC = 0x0000000040000000ULL,
2385fcf5ef2aSThomas Huth /* sync instruction */
2386fcf5ef2aSThomas Huth PPC_MEM_SYNC = 0x0000000080000000ULL,
2387fcf5ef2aSThomas Huth /* eieio instruction */
2388fcf5ef2aSThomas Huth PPC_MEM_EIEIO = 0x0000000100000000ULL,
2389fcf5ef2aSThomas Huth
2390fcf5ef2aSThomas Huth /* Cache control instructions */
2391fcf5ef2aSThomas Huth PPC_CACHE = 0x0000000200000000ULL,
2392fcf5ef2aSThomas Huth /* icbi instruction */
2393fcf5ef2aSThomas Huth PPC_CACHE_ICBI = 0x0000000400000000ULL,
2394fcf5ef2aSThomas Huth /* dcbz instruction */
2395fcf5ef2aSThomas Huth PPC_CACHE_DCBZ = 0x0000000800000000ULL,
2396fcf5ef2aSThomas Huth /* dcba instruction */
2397fcf5ef2aSThomas Huth PPC_CACHE_DCBA = 0x0000002000000000ULL,
2398fcf5ef2aSThomas Huth /* Freescale cache locking instructions */
2399fcf5ef2aSThomas Huth PPC_CACHE_LOCK = 0x0000004000000000ULL,
2400fcf5ef2aSThomas Huth
2401fcf5ef2aSThomas Huth /* MMU related extensions */
2402fcf5ef2aSThomas Huth /* external control instructions */
2403fcf5ef2aSThomas Huth PPC_EXTERN = 0x0000010000000000ULL,
2404fcf5ef2aSThomas Huth /* segment register access instructions */
2405fcf5ef2aSThomas Huth PPC_SEGMENT = 0x0000020000000000ULL,
2406fcf5ef2aSThomas Huth /* PowerPC 6xx TLB management instructions */
2407fcf5ef2aSThomas Huth PPC_6xx_TLB = 0x0000040000000000ULL,
2408fcf5ef2aSThomas Huth /* PowerPC 40x TLB management instructions */
2409fcf5ef2aSThomas Huth PPC_40x_TLB = 0x0000100000000000ULL,
2410fcf5ef2aSThomas Huth /* segment register access instructions for PowerPC 64 "bridge" */
2411fcf5ef2aSThomas Huth PPC_SEGMENT_64B = 0x0000200000000000ULL,
2412fcf5ef2aSThomas Huth /* SLB management */
2413fcf5ef2aSThomas Huth PPC_SLBI = 0x0000400000000000ULL,
2414fcf5ef2aSThomas Huth
2415fcf5ef2aSThomas Huth /* Embedded PowerPC dedicated instructions */
2416fcf5ef2aSThomas Huth PPC_WRTEE = 0x0001000000000000ULL,
2417fcf5ef2aSThomas Huth /* PowerPC 40x exception model */
2418fcf5ef2aSThomas Huth PPC_40x_EXCP = 0x0002000000000000ULL,
2419fcf5ef2aSThomas Huth /* PowerPC 405 Mac instructions */
2420fcf5ef2aSThomas Huth PPC_405_MAC = 0x0004000000000000ULL,
2421fcf5ef2aSThomas Huth /* PowerPC 440 specific instructions */
2422fcf5ef2aSThomas Huth PPC_440_SPEC = 0x0008000000000000ULL,
2423fcf5ef2aSThomas Huth /* BookE (embedded) PowerPC specification */
2424fcf5ef2aSThomas Huth PPC_BOOKE = 0x0010000000000000ULL,
2425fcf5ef2aSThomas Huth /* mfapidi instruction */
2426fcf5ef2aSThomas Huth PPC_MFAPIDI = 0x0020000000000000ULL,
2427fcf5ef2aSThomas Huth /* tlbiva instruction */
2428fcf5ef2aSThomas Huth PPC_TLBIVA = 0x0040000000000000ULL,
2429fcf5ef2aSThomas Huth /* tlbivax instruction */
2430fcf5ef2aSThomas Huth PPC_TLBIVAX = 0x0080000000000000ULL,
2431fcf5ef2aSThomas Huth /* PowerPC 4xx dedicated instructions */
2432fcf5ef2aSThomas Huth PPC_4xx_COMMON = 0x0100000000000000ULL,
2433fcf5ef2aSThomas Huth /* PowerPC 40x ibct instructions */
2434fcf5ef2aSThomas Huth PPC_40x_ICBT = 0x0200000000000000ULL,
2435fcf5ef2aSThomas Huth /* rfmci is not implemented in all BookE PowerPC */
2436fcf5ef2aSThomas Huth PPC_RFMCI = 0x0400000000000000ULL,
2437fcf5ef2aSThomas Huth /* rfdi instruction */
2438fcf5ef2aSThomas Huth PPC_RFDI = 0x0800000000000000ULL,
2439fcf5ef2aSThomas Huth /* DCR accesses */
2440fcf5ef2aSThomas Huth PPC_DCR = 0x1000000000000000ULL,
2441fcf5ef2aSThomas Huth /* DCR extended accesse */
2442fcf5ef2aSThomas Huth PPC_DCRX = 0x2000000000000000ULL,
2443fcf5ef2aSThomas Huth /* popcntw and popcntd instructions */
2444fcf5ef2aSThomas Huth PPC_POPCNTWD = 0x8000000000000000ULL,
2445fcf5ef2aSThomas Huth
2446005b69fdSCédric Le Goater #define PPC_TCG_INSNS (PPC_INSNS_BASE | PPC_64B \
2447fcf5ef2aSThomas Huth | PPC_64BX | PPC_64H | PPC_WAIT | PPC_MFTB \
24484537d62dSCédric Le Goater | PPC_ISEL | PPC_POPCNTB \
2449fcf5ef2aSThomas Huth | PPC_STRING | PPC_FLOAT | PPC_FLOAT_EXT \
2450fcf5ef2aSThomas Huth | PPC_FLOAT_FSQRT | PPC_FLOAT_FRES \
2451fcf5ef2aSThomas Huth | PPC_FLOAT_FRSQRTE | PPC_FLOAT_FRSQRTES \
2452fcf5ef2aSThomas Huth | PPC_FLOAT_FSEL | PPC_FLOAT_STFIWX \
2453fcf5ef2aSThomas Huth | PPC_ALTIVEC | PPC_SPE | PPC_SPE_SINGLE \
2454fcf5ef2aSThomas Huth | PPC_SPE_DOUBLE | PPC_MEM_TLBIA \
2455fcf5ef2aSThomas Huth | PPC_MEM_TLBIE | PPC_MEM_TLBSYNC \
2456fcf5ef2aSThomas Huth | PPC_MEM_SYNC | PPC_MEM_EIEIO \
2457fcf5ef2aSThomas Huth | PPC_CACHE | PPC_CACHE_ICBI \
2458fcf5ef2aSThomas Huth | PPC_CACHE_DCBZ \
2459fcf5ef2aSThomas Huth | PPC_CACHE_DCBA | PPC_CACHE_LOCK \
2460fcf5ef2aSThomas Huth | PPC_EXTERN | PPC_SEGMENT | PPC_6xx_TLB \
2461a09410edSFabiano Rosas | PPC_40x_TLB | PPC_SEGMENT_64B \
2462fcf5ef2aSThomas Huth | PPC_SLBI | PPC_WRTEE | PPC_40x_EXCP \
2463fcf5ef2aSThomas Huth | PPC_405_MAC | PPC_440_SPEC | PPC_BOOKE \
2464fcf5ef2aSThomas Huth | PPC_MFAPIDI | PPC_TLBIVA | PPC_TLBIVAX \
2465fcf5ef2aSThomas Huth | PPC_4xx_COMMON | PPC_40x_ICBT | PPC_RFMCI \
2466b63fa8b9SMatheus Ferst | PPC_RFDI | PPC_DCR | PPC_DCRX | PPC_POPCNTWD \
2467b63fa8b9SMatheus Ferst | PPC_CILDST)
2468fcf5ef2aSThomas Huth
2469fcf5ef2aSThomas Huth /* extended type values */
2470fcf5ef2aSThomas Huth
2471fcf5ef2aSThomas Huth /* BookE 2.06 PowerPC specification */
2472fcf5ef2aSThomas Huth PPC2_BOOKE206 = 0x0000000000000001ULL,
2473fcf5ef2aSThomas Huth /* VSX (extensions to Altivec / VMX) */
2474fcf5ef2aSThomas Huth PPC2_VSX = 0x0000000000000002ULL,
2475fcf5ef2aSThomas Huth /* Decimal Floating Point (DFP) */
2476fcf5ef2aSThomas Huth PPC2_DFP = 0x0000000000000004ULL,
2477fcf5ef2aSThomas Huth /* Embedded.Processor Control */
2478fcf5ef2aSThomas Huth PPC2_PRCNTL = 0x0000000000000008ULL,
2479fcf5ef2aSThomas Huth /* Byte-reversed, indexed, double-word load and store */
2480fcf5ef2aSThomas Huth PPC2_DBRX = 0x0000000000000010ULL,
2481fcf5ef2aSThomas Huth /* Book I 2.05 PowerPC specification */
2482fcf5ef2aSThomas Huth PPC2_ISA205 = 0x0000000000000020ULL,
2483fcf5ef2aSThomas Huth /* VSX additions in ISA 2.07 */
2484fcf5ef2aSThomas Huth PPC2_VSX207 = 0x0000000000000040ULL,
2485fcf5ef2aSThomas Huth /* ISA 2.06B bpermd */
2486fcf5ef2aSThomas Huth PPC2_PERM_ISA206 = 0x0000000000000080ULL,
2487fcf5ef2aSThomas Huth /* ISA 2.06B divide extended variants */
2488fcf5ef2aSThomas Huth PPC2_DIVE_ISA206 = 0x0000000000000100ULL,
2489fcf5ef2aSThomas Huth /* ISA 2.06B larx/stcx. instructions */
2490fcf5ef2aSThomas Huth PPC2_ATOMIC_ISA206 = 0x0000000000000200ULL,
2491fcf5ef2aSThomas Huth /* ISA 2.06B floating point integer conversion */
2492fcf5ef2aSThomas Huth PPC2_FP_CVT_ISA206 = 0x0000000000000400ULL,
2493fcf5ef2aSThomas Huth /* ISA 2.06B floating point test instructions */
2494fcf5ef2aSThomas Huth PPC2_FP_TST_ISA206 = 0x0000000000000800ULL,
2495fcf5ef2aSThomas Huth /* ISA 2.07 bctar instruction */
2496fcf5ef2aSThomas Huth PPC2_BCTAR_ISA207 = 0x0000000000001000ULL,
2497fcf5ef2aSThomas Huth /* ISA 2.07 load/store quadword */
2498fcf5ef2aSThomas Huth PPC2_LSQ_ISA207 = 0x0000000000002000ULL,
2499fcf5ef2aSThomas Huth /* ISA 2.07 Altivec */
2500fcf5ef2aSThomas Huth PPC2_ALTIVEC_207 = 0x0000000000004000ULL,
2501fcf5ef2aSThomas Huth /* PowerISA 2.07 Book3s specification */
2502fcf5ef2aSThomas Huth PPC2_ISA207S = 0x0000000000008000ULL,
2503fcf5ef2aSThomas Huth /* Double precision floating point conversion for signed integer 64 */
2504fcf5ef2aSThomas Huth PPC2_FP_CVT_S64 = 0x0000000000010000ULL,
2505fcf5ef2aSThomas Huth /* Transactional Memory (ISA 2.07, Book II) */
2506fcf5ef2aSThomas Huth PPC2_TM = 0x0000000000020000ULL,
2507fcf5ef2aSThomas Huth /* Server PM instructgions (ISA 2.06, Book III) */
2508fcf5ef2aSThomas Huth PPC2_PM_ISA206 = 0x0000000000040000ULL,
2509fcf5ef2aSThomas Huth /* POWER ISA 3.0 */
2510fcf5ef2aSThomas Huth PPC2_ISA300 = 0x0000000000080000ULL,
2511ca7a2fdaSLijun Pan /* POWER ISA 3.1 */
2512ca7a2fdaSLijun Pan PPC2_ISA310 = 0x0000000000100000ULL,
251303abfd90SNicholas Piggin /* lwsync instruction */
251403abfd90SNicholas Piggin PPC2_MEM_LWSYNC = 0x0000000000200000ULL,
25154dc5f8abSMatheus Ferst /* ISA 2.06 BCD assist instructions */
25164dc5f8abSMatheus Ferst PPC2_BCDA_ISA206 = 0x0000000000400000ULL,
2517fcf5ef2aSThomas Huth
2518fcf5ef2aSThomas Huth #define PPC_TCG_INSNS2 (PPC2_BOOKE206 | PPC2_VSX | PPC2_PRCNTL | PPC2_DBRX | \
2519fcf5ef2aSThomas Huth PPC2_ISA205 | PPC2_VSX207 | PPC2_PERM_ISA206 | \
2520fcf5ef2aSThomas Huth PPC2_DIVE_ISA206 | PPC2_ATOMIC_ISA206 | \
2521fcf5ef2aSThomas Huth PPC2_FP_CVT_ISA206 | PPC2_FP_TST_ISA206 | \
2522fcf5ef2aSThomas Huth PPC2_BCTAR_ISA207 | PPC2_LSQ_ISA207 | \
2523fcf5ef2aSThomas Huth PPC2_ALTIVEC_207 | PPC2_ISA207S | PPC2_DFP | \
2524fcf5ef2aSThomas Huth PPC2_FP_CVT_S64 | PPC2_TM | PPC2_PM_ISA206 | \
25254dc5f8abSMatheus Ferst PPC2_ISA300 | PPC2_ISA310 | PPC2_MEM_LWSYNC | \
25264dc5f8abSMatheus Ferst PPC2_BCDA_ISA206)
2527fcf5ef2aSThomas Huth };
2528fcf5ef2aSThomas Huth
2529fcf5ef2aSThomas Huth /*****************************************************************************/
2530c647e3feSDavid Gibson /*
2531c647e3feSDavid Gibson * Memory access type :
2532fcf5ef2aSThomas Huth * may be needed for precise access rights control and precise exceptions.
2533fcf5ef2aSThomas Huth */
2534fcf5ef2aSThomas Huth enum {
2535fcf5ef2aSThomas Huth /* Type of instruction that generated the access */
2536fcf5ef2aSThomas Huth ACCESS_CODE = 0x10, /* Code fetch access */
2537fcf5ef2aSThomas Huth ACCESS_INT = 0x20, /* Integer load/store access */
2538fcf5ef2aSThomas Huth ACCESS_FLOAT = 0x30, /* floating point load/store access */
2539fcf5ef2aSThomas Huth ACCESS_RES = 0x40, /* load/store with reservation */
2540fcf5ef2aSThomas Huth ACCESS_EXT = 0x50, /* external access */
2541fcf5ef2aSThomas Huth ACCESS_CACHE = 0x60, /* Cache manipulation */
2542fcf5ef2aSThomas Huth };
2543fcf5ef2aSThomas Huth
2544c647e3feSDavid Gibson /*
2545c647e3feSDavid Gibson * Hardware interrupt sources:
2546fcf5ef2aSThomas Huth * all those exception can be raised simulteaneously
2547fcf5ef2aSThomas Huth */
2548fcf5ef2aSThomas Huth /* Input pins definitions */
2549fcf5ef2aSThomas Huth enum {
2550fcf5ef2aSThomas Huth /* 6xx bus input pins */
2551fcf5ef2aSThomas Huth PPC6xx_INPUT_HRESET = 0,
2552fcf5ef2aSThomas Huth PPC6xx_INPUT_SRESET = 1,
2553fcf5ef2aSThomas Huth PPC6xx_INPUT_CKSTP_IN = 2,
2554fcf5ef2aSThomas Huth PPC6xx_INPUT_MCP = 3,
2555fcf5ef2aSThomas Huth PPC6xx_INPUT_SMI = 4,
2556fcf5ef2aSThomas Huth PPC6xx_INPUT_INT = 5,
2557fcf5ef2aSThomas Huth PPC6xx_INPUT_TBEN = 6,
2558fcf5ef2aSThomas Huth PPC6xx_INPUT_WAKEUP = 7,
2559fcf5ef2aSThomas Huth PPC6xx_INPUT_NB,
2560fcf5ef2aSThomas Huth };
2561fcf5ef2aSThomas Huth
2562fcf5ef2aSThomas Huth enum {
2563fcf5ef2aSThomas Huth /* Embedded PowerPC input pins */
2564fcf5ef2aSThomas Huth PPCBookE_INPUT_HRESET = 0,
2565fcf5ef2aSThomas Huth PPCBookE_INPUT_SRESET = 1,
2566fcf5ef2aSThomas Huth PPCBookE_INPUT_CKSTP_IN = 2,
2567fcf5ef2aSThomas Huth PPCBookE_INPUT_MCP = 3,
2568fcf5ef2aSThomas Huth PPCBookE_INPUT_SMI = 4,
2569fcf5ef2aSThomas Huth PPCBookE_INPUT_INT = 5,
2570fcf5ef2aSThomas Huth PPCBookE_INPUT_CINT = 6,
2571fcf5ef2aSThomas Huth PPCBookE_INPUT_NB,
2572fcf5ef2aSThomas Huth };
2573fcf5ef2aSThomas Huth
2574fcf5ef2aSThomas Huth enum {
2575fcf5ef2aSThomas Huth /* PowerPC E500 input pins */
2576fcf5ef2aSThomas Huth PPCE500_INPUT_RESET_CORE = 0,
2577fcf5ef2aSThomas Huth PPCE500_INPUT_MCK = 1,
2578fcf5ef2aSThomas Huth PPCE500_INPUT_CINT = 3,
2579fcf5ef2aSThomas Huth PPCE500_INPUT_INT = 4,
2580fcf5ef2aSThomas Huth PPCE500_INPUT_DEBUG = 6,
2581fcf5ef2aSThomas Huth PPCE500_INPUT_NB,
2582fcf5ef2aSThomas Huth };
2583fcf5ef2aSThomas Huth
2584fcf5ef2aSThomas Huth enum {
2585fcf5ef2aSThomas Huth /* PowerPC 40x input pins */
2586fcf5ef2aSThomas Huth PPC40x_INPUT_RESET_CORE = 0,
2587fcf5ef2aSThomas Huth PPC40x_INPUT_RESET_CHIP = 1,
2588fcf5ef2aSThomas Huth PPC40x_INPUT_RESET_SYS = 2,
2589fcf5ef2aSThomas Huth PPC40x_INPUT_CINT = 3,
2590fcf5ef2aSThomas Huth PPC40x_INPUT_INT = 4,
2591fcf5ef2aSThomas Huth PPC40x_INPUT_HALT = 5,
2592fcf5ef2aSThomas Huth PPC40x_INPUT_DEBUG = 6,
2593fcf5ef2aSThomas Huth PPC40x_INPUT_NB,
2594fcf5ef2aSThomas Huth };
2595fcf5ef2aSThomas Huth
2596fcf5ef2aSThomas Huth enum {
2597fcf5ef2aSThomas Huth /* RCPU input pins */
2598fcf5ef2aSThomas Huth PPCRCPU_INPUT_PORESET = 0,
2599fcf5ef2aSThomas Huth PPCRCPU_INPUT_HRESET = 1,
2600fcf5ef2aSThomas Huth PPCRCPU_INPUT_SRESET = 2,
2601fcf5ef2aSThomas Huth PPCRCPU_INPUT_IRQ0 = 3,
2602fcf5ef2aSThomas Huth PPCRCPU_INPUT_IRQ1 = 4,
2603fcf5ef2aSThomas Huth PPCRCPU_INPUT_IRQ2 = 5,
2604fcf5ef2aSThomas Huth PPCRCPU_INPUT_IRQ3 = 6,
2605fcf5ef2aSThomas Huth PPCRCPU_INPUT_IRQ4 = 7,
2606fcf5ef2aSThomas Huth PPCRCPU_INPUT_IRQ5 = 8,
2607fcf5ef2aSThomas Huth PPCRCPU_INPUT_IRQ6 = 9,
2608fcf5ef2aSThomas Huth PPCRCPU_INPUT_IRQ7 = 10,
2609fcf5ef2aSThomas Huth PPCRCPU_INPUT_NB,
2610fcf5ef2aSThomas Huth };
2611fcf5ef2aSThomas Huth
2612fcf5ef2aSThomas Huth #if defined(TARGET_PPC64)
2613fcf5ef2aSThomas Huth enum {
2614fcf5ef2aSThomas Huth /* PowerPC 970 input pins */
2615fcf5ef2aSThomas Huth PPC970_INPUT_HRESET = 0,
2616fcf5ef2aSThomas Huth PPC970_INPUT_SRESET = 1,
2617fcf5ef2aSThomas Huth PPC970_INPUT_CKSTP = 2,
2618fcf5ef2aSThomas Huth PPC970_INPUT_TBEN = 3,
2619fcf5ef2aSThomas Huth PPC970_INPUT_MCP = 4,
2620fcf5ef2aSThomas Huth PPC970_INPUT_INT = 5,
2621fcf5ef2aSThomas Huth PPC970_INPUT_THINT = 6,
2622fcf5ef2aSThomas Huth PPC970_INPUT_NB,
2623fcf5ef2aSThomas Huth };
2624fcf5ef2aSThomas Huth
2625fcf5ef2aSThomas Huth enum {
2626fcf5ef2aSThomas Huth /* POWER7 input pins */
2627fcf5ef2aSThomas Huth POWER7_INPUT_INT = 0,
2628c647e3feSDavid Gibson /*
2629c647e3feSDavid Gibson * POWER7 probably has other inputs, but we don't care about them
2630fcf5ef2aSThomas Huth * for any existing machine. We can wire these up when we need
2631c647e3feSDavid Gibson * them
2632c647e3feSDavid Gibson */
2633fcf5ef2aSThomas Huth POWER7_INPUT_NB,
2634fcf5ef2aSThomas Huth };
263567afe775SBenjamin Herrenschmidt
263667afe775SBenjamin Herrenschmidt enum {
263767afe775SBenjamin Herrenschmidt /* POWER9 input pins */
263867afe775SBenjamin Herrenschmidt POWER9_INPUT_INT = 0,
263967afe775SBenjamin Herrenschmidt POWER9_INPUT_HINT = 1,
264067afe775SBenjamin Herrenschmidt POWER9_INPUT_NB,
264167afe775SBenjamin Herrenschmidt };
2642fcf5ef2aSThomas Huth #endif
2643fcf5ef2aSThomas Huth
2644fcf5ef2aSThomas Huth /* Hardware exceptions definitions */
2645fcf5ef2aSThomas Huth enum {
2646fcf5ef2aSThomas Huth /* External hardware exception sources */
2647f003109fSMatheus Ferst PPC_INTERRUPT_RESET = 0x00001, /* Reset exception */
2648f003109fSMatheus Ferst PPC_INTERRUPT_WAKEUP = 0x00002, /* Wakeup exception */
2649f003109fSMatheus Ferst PPC_INTERRUPT_MCK = 0x00004, /* Machine check exception */
2650f003109fSMatheus Ferst PPC_INTERRUPT_EXT = 0x00008, /* External interrupt */
2651f003109fSMatheus Ferst PPC_INTERRUPT_SMI = 0x00010, /* System management interrupt */
2652f003109fSMatheus Ferst PPC_INTERRUPT_CEXT = 0x00020, /* Critical external interrupt */
2653f003109fSMatheus Ferst PPC_INTERRUPT_DEBUG = 0x00040, /* External debug exception */
2654f003109fSMatheus Ferst PPC_INTERRUPT_THERM = 0x00080, /* Thermal exception */
2655fcf5ef2aSThomas Huth /* Internal hardware exception sources */
2656f003109fSMatheus Ferst PPC_INTERRUPT_DECR = 0x00100, /* Decrementer exception */
2657f003109fSMatheus Ferst PPC_INTERRUPT_HDECR = 0x00200, /* Hypervisor decrementer exception */
2658f003109fSMatheus Ferst PPC_INTERRUPT_PIT = 0x00400, /* Programmable interval timer int. */
2659f003109fSMatheus Ferst PPC_INTERRUPT_FIT = 0x00800, /* Fixed interval timer interrupt */
2660f003109fSMatheus Ferst PPC_INTERRUPT_WDT = 0x01000, /* Watchdog timer interrupt */
2661f003109fSMatheus Ferst PPC_INTERRUPT_CDOORBELL = 0x02000, /* Critical doorbell interrupt */
2662f003109fSMatheus Ferst PPC_INTERRUPT_DOORBELL = 0x04000, /* Doorbell interrupt */
2663f003109fSMatheus Ferst PPC_INTERRUPT_PERFM = 0x08000, /* Performance monitor interrupt */
2664f003109fSMatheus Ferst PPC_INTERRUPT_HMI = 0x10000, /* Hypervisor Maintenance interrupt */
2665f003109fSMatheus Ferst PPC_INTERRUPT_HDOORBELL = 0x20000, /* Hypervisor Doorbell interrupt */
2666f003109fSMatheus Ferst PPC_INTERRUPT_HVIRT = 0x40000, /* Hypervisor virtualization interrupt */
2667f003109fSMatheus Ferst PPC_INTERRUPT_EBB = 0x80000, /* Event-based Branch exception */
2668fcf5ef2aSThomas Huth };
2669fcf5ef2aSThomas Huth
2670fcf5ef2aSThomas Huth /* Processor Compatibility mask (PCR) */
2671fcf5ef2aSThomas Huth enum {
2672a6a444a8SCédric Le Goater PCR_COMPAT_2_05 = PPC_BIT(62),
2673a6a444a8SCédric Le Goater PCR_COMPAT_2_06 = PPC_BIT(61),
2674a6a444a8SCédric Le Goater PCR_COMPAT_2_07 = PPC_BIT(60),
2675a6a444a8SCédric Le Goater PCR_COMPAT_3_00 = PPC_BIT(59),
26767d37b274SCédric Le Goater PCR_COMPAT_3_10 = PPC_BIT(58),
2677a6a444a8SCédric Le Goater PCR_VEC_DIS = PPC_BIT(0), /* Vec. disable (bit NA since POWER8) */
2678a6a444a8SCédric Le Goater PCR_VSX_DIS = PPC_BIT(1), /* VSX disable (bit NA since POWER8) */
2679a6a444a8SCédric Le Goater PCR_TM_DIS = PPC_BIT(2), /* Trans. memory disable (POWER8) */
2680fcf5ef2aSThomas Huth };
2681fcf5ef2aSThomas Huth
2682fcf5ef2aSThomas Huth /* HMER/HMEER */
2683fcf5ef2aSThomas Huth enum {
2684a6a444a8SCédric Le Goater HMER_MALFUNCTION_ALERT = PPC_BIT(0),
2685a6a444a8SCédric Le Goater HMER_PROC_RECV_DONE = PPC_BIT(2),
2686a6a444a8SCédric Le Goater HMER_PROC_RECV_ERROR_MASKED = PPC_BIT(3),
2687a6a444a8SCédric Le Goater HMER_TFAC_ERROR = PPC_BIT(4),
2688a6a444a8SCédric Le Goater HMER_TFMR_PARITY_ERROR = PPC_BIT(5),
2689a6a444a8SCédric Le Goater HMER_XSCOM_FAIL = PPC_BIT(8),
2690a6a444a8SCédric Le Goater HMER_XSCOM_DONE = PPC_BIT(9),
2691a6a444a8SCédric Le Goater HMER_PROC_RECV_AGAIN = PPC_BIT(11),
2692a6a444a8SCédric Le Goater HMER_WARN_RISE = PPC_BIT(14),
2693a6a444a8SCédric Le Goater HMER_WARN_FALL = PPC_BIT(15),
2694a6a444a8SCédric Le Goater HMER_SCOM_FIR_HMI = PPC_BIT(16),
2695a6a444a8SCédric Le Goater HMER_TRIG_FIR_HMI = PPC_BIT(17),
2696a6a444a8SCédric Le Goater HMER_HYP_RESOURCE_ERR = PPC_BIT(20),
2697a6a444a8SCédric Le Goater HMER_XSCOM_STATUS_MASK = PPC_BITMASK(21, 23),
2698fcf5ef2aSThomas Huth };
2699fcf5ef2aSThomas Huth
2700d8c14411SNicholas Piggin /* TFMR */
2701d8c14411SNicholas Piggin enum {
2702d8c14411SNicholas Piggin TFMR_CONTROL_MASK = PPC_BITMASK(0, 24),
2703d8c14411SNicholas Piggin TFMR_MASK_HMI = PPC_BIT(10),
2704d8c14411SNicholas Piggin TFMR_TB_ECLIPZ = PPC_BIT(14),
2705d8c14411SNicholas Piggin TFMR_LOAD_TOD_MOD = PPC_BIT(16),
2706d8c14411SNicholas Piggin TFMR_MOVE_CHIP_TOD_TO_TB = PPC_BIT(18),
2707d8c14411SNicholas Piggin TFMR_CLEAR_TB_ERRORS = PPC_BIT(24),
2708d8c14411SNicholas Piggin TFMR_STATUS_MASK = PPC_BITMASK(25, 63),
2709d8c14411SNicholas Piggin TFMR_TBST_ENCODED = PPC_BITMASK(28, 31), /* TBST = TB State */
2710d8c14411SNicholas Piggin TFMR_TBST_LAST = PPC_BITMASK(32, 35), /* Previous TBST */
2711d8c14411SNicholas Piggin TFMR_TB_ENABLED = PPC_BIT(40),
2712d8c14411SNicholas Piggin TFMR_TB_VALID = PPC_BIT(41),
2713d8c14411SNicholas Piggin TFMR_TB_SYNC_OCCURED = PPC_BIT(42),
2714d8c14411SNicholas Piggin TFMR_FIRMWARE_CONTROL_ERROR = PPC_BIT(46),
2715d8c14411SNicholas Piggin };
2716d8c14411SNicholas Piggin
2717d8c14411SNicholas Piggin /* TFMR TBST (Time Base State Machine). */
2718d8c14411SNicholas Piggin enum {
2719d8c14411SNicholas Piggin TBST_RESET = 0x0,
2720d8c14411SNicholas Piggin TBST_SEND_TOD_MOD = 0x1,
2721d8c14411SNicholas Piggin TBST_NOT_SET = 0x2,
2722d8c14411SNicholas Piggin TBST_SYNC_WAIT = 0x6,
2723d8c14411SNicholas Piggin TBST_GET_TOD = 0x7,
2724d8c14411SNicholas Piggin TBST_TB_RUNNING = 0x8,
2725d8c14411SNicholas Piggin TBST_TB_ERROR = 0x9,
2726d8c14411SNicholas Piggin };
2727d8c14411SNicholas Piggin
2728fcf5ef2aSThomas Huth /*****************************************************************************/
2729fcf5ef2aSThomas Huth
2730dd09c361SNikunj A Dadhania #define is_isa300(ctx) (!!(ctx->insns_flags2 & PPC2_ISA300))
273110de0521SMatheus Ferst target_ulong cpu_read_xer(const CPUPPCState *env);
273200b70788SNikunj A Dadhania void cpu_write_xer(CPUPPCState *env, target_ulong xer);
2733fcf5ef2aSThomas Huth
2734d0db7cadSGreg Kurz /*
2735d0db7cadSGreg Kurz * All 64-bit server processors compliant with arch 2.x, ie. 970 and newer,
2736d0db7cadSGreg Kurz * have PPC_SEGMENT_64B.
2737d0db7cadSGreg Kurz */
2738d0db7cadSGreg Kurz #define is_book3s_arch2x(ctx) (!!((ctx)->insns_flags & PPC_SEGMENT_64B))
2739d0db7cadSGreg Kurz
27402da8a6bcSRichard Henderson #ifdef CONFIG_DEBUG_TCG
2741bb5de525SAnton Johansson void cpu_get_tb_cpu_state(CPUPPCState *env, vaddr *pc,
2742bb5de525SAnton Johansson uint64_t *cs_base, uint32_t *flags);
27432da8a6bcSRichard Henderson #else
cpu_get_tb_cpu_state(CPUPPCState * env,vaddr * pc,uint64_t * cs_base,uint32_t * flags)2744bb5de525SAnton Johansson static inline void cpu_get_tb_cpu_state(CPUPPCState *env, vaddr *pc,
2745bb5de525SAnton Johansson uint64_t *cs_base, uint32_t *flags)
2746fcf5ef2aSThomas Huth {
2747fcf5ef2aSThomas Huth *pc = env->nip;
2748fcf5ef2aSThomas Huth *cs_base = 0;
2749fcf5ef2aSThomas Huth *flags = env->hflags;
2750fcf5ef2aSThomas Huth }
27512da8a6bcSRichard Henderson #endif
2752fcf5ef2aSThomas Huth
27538905770bSMarc-André Lureau G_NORETURN void raise_exception(CPUPPCState *env, uint32_t exception);
27548905770bSMarc-André Lureau G_NORETURN void raise_exception_ra(CPUPPCState *env, uint32_t exception,
2755fcf5ef2aSThomas Huth uintptr_t raddr);
27568905770bSMarc-André Lureau G_NORETURN void raise_exception_err(CPUPPCState *env, uint32_t exception,
2757fcf5ef2aSThomas Huth uint32_t error_code);
27588905770bSMarc-André Lureau G_NORETURN void raise_exception_err_ra(CPUPPCState *env, uint32_t exception,
2759fcf5ef2aSThomas Huth uint32_t error_code, uintptr_t raddr);
2760fcf5ef2aSThomas Huth
2761d3412df2SDaniel Henrique Barboza /* PERFM EBB helper*/
2762d3412df2SDaniel Henrique Barboza #if defined(TARGET_PPC64) && !defined(CONFIG_USER_ONLY)
2763d3412df2SDaniel Henrique Barboza void raise_ebb_perfm_exception(CPUPPCState *env);
2764d3412df2SDaniel Henrique Barboza #endif
2765d3412df2SDaniel Henrique Barboza
2766fcf5ef2aSThomas Huth #if !defined(CONFIG_USER_ONLY)
booke206_tlbm_id(CPUPPCState * env,ppcmas_tlb_t * tlbm)2767fcf5ef2aSThomas Huth static inline int booke206_tlbm_id(CPUPPCState *env, ppcmas_tlb_t *tlbm)
2768fcf5ef2aSThomas Huth {
2769fcf5ef2aSThomas Huth uintptr_t tlbml = (uintptr_t)tlbm;
2770fcf5ef2aSThomas Huth uintptr_t tlbl = (uintptr_t)env->tlb.tlbm;
2771fcf5ef2aSThomas Huth
2772fcf5ef2aSThomas Huth return (tlbml - tlbl) / sizeof(env->tlb.tlbm[0]);
2773fcf5ef2aSThomas Huth }
2774fcf5ef2aSThomas Huth
booke206_tlb_size(CPUPPCState * env,int tlbn)2775fcf5ef2aSThomas Huth static inline int booke206_tlb_size(CPUPPCState *env, int tlbn)
2776fcf5ef2aSThomas Huth {
2777fcf5ef2aSThomas Huth uint32_t tlbncfg = env->spr[SPR_BOOKE_TLB0CFG + tlbn];
2778fcf5ef2aSThomas Huth int r = tlbncfg & TLBnCFG_N_ENTRY;
2779fcf5ef2aSThomas Huth return r;
2780fcf5ef2aSThomas Huth }
2781fcf5ef2aSThomas Huth
booke206_tlb_ways(CPUPPCState * env,int tlbn)2782fcf5ef2aSThomas Huth static inline int booke206_tlb_ways(CPUPPCState *env, int tlbn)
2783fcf5ef2aSThomas Huth {
2784fcf5ef2aSThomas Huth uint32_t tlbncfg = env->spr[SPR_BOOKE_TLB0CFG + tlbn];
2785fcf5ef2aSThomas Huth int r = tlbncfg >> TLBnCFG_ASSOC_SHIFT;
2786fcf5ef2aSThomas Huth return r;
2787fcf5ef2aSThomas Huth }
2788fcf5ef2aSThomas Huth
booke206_tlbm_to_tlbn(CPUPPCState * env,ppcmas_tlb_t * tlbm)2789fcf5ef2aSThomas Huth static inline int booke206_tlbm_to_tlbn(CPUPPCState *env, ppcmas_tlb_t *tlbm)
2790fcf5ef2aSThomas Huth {
2791fcf5ef2aSThomas Huth int id = booke206_tlbm_id(env, tlbm);
2792fcf5ef2aSThomas Huth int end = 0;
2793fcf5ef2aSThomas Huth int i;
2794fcf5ef2aSThomas Huth
2795fcf5ef2aSThomas Huth for (i = 0; i < BOOKE206_MAX_TLBN; i++) {
2796fcf5ef2aSThomas Huth end += booke206_tlb_size(env, i);
2797fcf5ef2aSThomas Huth if (id < end) {
2798fcf5ef2aSThomas Huth return i;
2799fcf5ef2aSThomas Huth }
2800fcf5ef2aSThomas Huth }
2801fcf5ef2aSThomas Huth
2802db70b311SRichard Henderson cpu_abort(env_cpu(env), "Unknown TLBe: %d\n", id);
2803fcf5ef2aSThomas Huth return 0;
2804fcf5ef2aSThomas Huth }
2805fcf5ef2aSThomas Huth
booke206_tlbm_to_way(CPUPPCState * env,ppcmas_tlb_t * tlb)2806fcf5ef2aSThomas Huth static inline int booke206_tlbm_to_way(CPUPPCState *env, ppcmas_tlb_t *tlb)
2807fcf5ef2aSThomas Huth {
2808fcf5ef2aSThomas Huth int tlbn = booke206_tlbm_to_tlbn(env, tlb);
2809fcf5ef2aSThomas Huth int tlbid = booke206_tlbm_id(env, tlb);
2810fcf5ef2aSThomas Huth return tlbid & (booke206_tlb_ways(env, tlbn) - 1);
2811fcf5ef2aSThomas Huth }
2812fcf5ef2aSThomas Huth
booke206_get_tlbm(CPUPPCState * env,const int tlbn,target_ulong ea,int way)2813fcf5ef2aSThomas Huth static inline ppcmas_tlb_t *booke206_get_tlbm(CPUPPCState *env, const int tlbn,
2814fcf5ef2aSThomas Huth target_ulong ea, int way)
2815fcf5ef2aSThomas Huth {
2816fcf5ef2aSThomas Huth int r;
2817fcf5ef2aSThomas Huth uint32_t ways = booke206_tlb_ways(env, tlbn);
2818fcf5ef2aSThomas Huth int ways_bits = ctz32(ways);
2819fcf5ef2aSThomas Huth int tlb_bits = ctz32(booke206_tlb_size(env, tlbn));
2820fcf5ef2aSThomas Huth int i;
2821fcf5ef2aSThomas Huth
2822fcf5ef2aSThomas Huth way &= ways - 1;
2823fcf5ef2aSThomas Huth ea >>= MAS2_EPN_SHIFT;
2824fcf5ef2aSThomas Huth ea &= (1 << (tlb_bits - ways_bits)) - 1;
2825fcf5ef2aSThomas Huth r = (ea << ways_bits) | way;
2826fcf5ef2aSThomas Huth
2827fcf5ef2aSThomas Huth if (r >= booke206_tlb_size(env, tlbn)) {
2828fcf5ef2aSThomas Huth return NULL;
2829fcf5ef2aSThomas Huth }
2830fcf5ef2aSThomas Huth
2831fcf5ef2aSThomas Huth /* bump up to tlbn index */
2832fcf5ef2aSThomas Huth for (i = 0; i < tlbn; i++) {
2833fcf5ef2aSThomas Huth r += booke206_tlb_size(env, i);
2834fcf5ef2aSThomas Huth }
2835fcf5ef2aSThomas Huth
2836fcf5ef2aSThomas Huth return &env->tlb.tlbm[r];
2837fcf5ef2aSThomas Huth }
2838fcf5ef2aSThomas Huth
2839fcf5ef2aSThomas Huth /* returns bitmap of supported page sizes for a given TLB */
booke206_tlbnps(CPUPPCState * env,const int tlbn)2840fcf5ef2aSThomas Huth static inline uint32_t booke206_tlbnps(CPUPPCState *env, const int tlbn)
2841fcf5ef2aSThomas Huth {
2842fcf5ef2aSThomas Huth uint32_t ret = 0;
2843fcf5ef2aSThomas Huth
28443f330293SKONRAD Frederic if ((env->spr[SPR_MMUCFG] & MMUCFG_MAVN) == MMUCFG_MAVN_V2) {
28453f330293SKONRAD Frederic /* MAV2 */
2846fcf5ef2aSThomas Huth ret = env->spr[SPR_BOOKE_TLB0PS + tlbn];
2847fcf5ef2aSThomas Huth } else {
2848fcf5ef2aSThomas Huth uint32_t tlbncfg = env->spr[SPR_BOOKE_TLB0CFG + tlbn];
2849fcf5ef2aSThomas Huth uint32_t min = (tlbncfg & TLBnCFG_MINSIZE) >> TLBnCFG_MINSIZE_SHIFT;
2850fcf5ef2aSThomas Huth uint32_t max = (tlbncfg & TLBnCFG_MAXSIZE) >> TLBnCFG_MAXSIZE_SHIFT;
2851fcf5ef2aSThomas Huth int i;
2852fcf5ef2aSThomas Huth for (i = min; i <= max; i++) {
2853fcf5ef2aSThomas Huth ret |= (1 << (i << 1));
2854fcf5ef2aSThomas Huth }
2855fcf5ef2aSThomas Huth }
2856fcf5ef2aSThomas Huth
2857fcf5ef2aSThomas Huth return ret;
2858fcf5ef2aSThomas Huth }
2859fcf5ef2aSThomas Huth
booke206_fixed_size_tlbn(CPUPPCState * env,const int tlbn,ppcmas_tlb_t * tlb)2860c449d8baSKONRAD Frederic static inline void booke206_fixed_size_tlbn(CPUPPCState *env, const int tlbn,
2861c449d8baSKONRAD Frederic ppcmas_tlb_t *tlb)
2862c449d8baSKONRAD Frederic {
2863c449d8baSKONRAD Frederic uint8_t i;
2864c449d8baSKONRAD Frederic int32_t tsize = -1;
2865c449d8baSKONRAD Frederic
2866c449d8baSKONRAD Frederic for (i = 0; i < 32; i++) {
2867c449d8baSKONRAD Frederic if ((env->spr[SPR_BOOKE_TLB0PS + tlbn]) & (1ULL << i)) {
2868c449d8baSKONRAD Frederic if (tsize == -1) {
2869c449d8baSKONRAD Frederic tsize = i;
2870c449d8baSKONRAD Frederic } else {
2871c449d8baSKONRAD Frederic return;
2872c449d8baSKONRAD Frederic }
2873c449d8baSKONRAD Frederic }
2874c449d8baSKONRAD Frederic }
2875c449d8baSKONRAD Frederic
2876c449d8baSKONRAD Frederic /* TLBnPS unimplemented? Odd.. */
2877c449d8baSKONRAD Frederic assert(tsize != -1);
2878c449d8baSKONRAD Frederic tlb->mas1 &= ~MAS1_TSIZE_MASK;
2879c449d8baSKONRAD Frederic tlb->mas1 |= ((uint32_t)tsize) << MAS1_TSIZE_SHIFT;
2880c449d8baSKONRAD Frederic }
2881c449d8baSKONRAD Frederic
ppc_is_split_tlb(PowerPCCPU * cpu)28825fd257f5SBALATON Zoltan static inline bool ppc_is_split_tlb(PowerPCCPU *cpu)
28835fd257f5SBALATON Zoltan {
28845fd257f5SBALATON Zoltan return cpu->env.tlb_type == TLB_6XX;
28855fd257f5SBALATON Zoltan }
2886fcf5ef2aSThomas Huth #endif
2887fcf5ef2aSThomas Huth
msr_is_64bit(CPUPPCState * env,target_ulong msr)2888fcf5ef2aSThomas Huth static inline bool msr_is_64bit(CPUPPCState *env, target_ulong msr)
2889fcf5ef2aSThomas Huth {
2890fcf5ef2aSThomas Huth if (env->mmu_model == POWERPC_MMU_BOOKE206) {
2891fcf5ef2aSThomas Huth return msr & (1ULL << MSR_CM);
2892fcf5ef2aSThomas Huth }
2893fcf5ef2aSThomas Huth
2894fcf5ef2aSThomas Huth return msr & (1ULL << MSR_SF);
2895fcf5ef2aSThomas Huth }
2896fcf5ef2aSThomas Huth
2897fcf5ef2aSThomas Huth /**
2898fcf5ef2aSThomas Huth * Check whether register rx is in the range between start and
2899fcf5ef2aSThomas Huth * start + nregs (as needed by the LSWX and LSWI instructions)
2900fcf5ef2aSThomas Huth */
lsw_reg_in_range(int start,int nregs,int rx)2901fcf5ef2aSThomas Huth static inline bool lsw_reg_in_range(int start, int nregs, int rx)
2902fcf5ef2aSThomas Huth {
2903fcf5ef2aSThomas Huth return (start + nregs <= 32 && rx >= start && rx < start + nregs) ||
2904fcf5ef2aSThomas Huth (start + nregs > 32 && (rx >= start || rx < start + nregs - 32));
2905fcf5ef2aSThomas Huth }
2906fcf5ef2aSThomas Huth
2907ef96e3aeSMark Cave-Ayland /* Accessors for FP, VMX and VSX registers */
2908e03b5686SMarc-André Lureau #if HOST_BIG_ENDIAN
2909da7815efSMark Cave-Ayland #define VsrB(i) u8[i]
2910da7815efSMark Cave-Ayland #define VsrSB(i) s8[i]
2911da7815efSMark Cave-Ayland #define VsrH(i) u16[i]
2912da7815efSMark Cave-Ayland #define VsrSH(i) s16[i]
2913da7815efSMark Cave-Ayland #define VsrW(i) u32[i]
2914da7815efSMark Cave-Ayland #define VsrSW(i) s32[i]
2915da7815efSMark Cave-Ayland #define VsrD(i) u64[i]
2916da7815efSMark Cave-Ayland #define VsrSD(i) s64[i]
29172d9cba74SLucas Mateus Castro (alqotel) #define VsrHF(i) f16[i]
2918c29018ccSLucas Mateus Castro (alqotel) #define VsrSF(i) f32[i]
2919c29018ccSLucas Mateus Castro (alqotel) #define VsrDF(i) f64[i]
2920da7815efSMark Cave-Ayland #else
2921da7815efSMark Cave-Ayland #define VsrB(i) u8[15 - (i)]
2922da7815efSMark Cave-Ayland #define VsrSB(i) s8[15 - (i)]
2923da7815efSMark Cave-Ayland #define VsrH(i) u16[7 - (i)]
2924da7815efSMark Cave-Ayland #define VsrSH(i) s16[7 - (i)]
2925da7815efSMark Cave-Ayland #define VsrW(i) u32[3 - (i)]
2926da7815efSMark Cave-Ayland #define VsrSW(i) s32[3 - (i)]
2927da7815efSMark Cave-Ayland #define VsrD(i) u64[1 - (i)]
2928da7815efSMark Cave-Ayland #define VsrSD(i) s64[1 - (i)]
29292d9cba74SLucas Mateus Castro (alqotel) #define VsrHF(i) f16[7 - (i)]
2930c29018ccSLucas Mateus Castro (alqotel) #define VsrSF(i) f32[3 - (i)]
2931c29018ccSLucas Mateus Castro (alqotel) #define VsrDF(i) f64[1 - (i)]
2932da7815efSMark Cave-Ayland #endif
2933da7815efSMark Cave-Ayland
vsr64_offset(int i,bool high)2934d59d1182SMark Cave-Ayland static inline int vsr64_offset(int i, bool high)
2935e7d3b272SMark Cave-Ayland {
2936d59d1182SMark Cave-Ayland return offsetof(CPUPPCState, vsr[i].VsrD(high ? 0 : 1));
293745141dfdSMark Cave-Ayland }
293845141dfdSMark Cave-Ayland
vsr_full_offset(int i)2939c82a8a85SMark Cave-Ayland static inline int vsr_full_offset(int i)
2940c82a8a85SMark Cave-Ayland {
2941c82a8a85SMark Cave-Ayland return offsetof(CPUPPCState, vsr[i].u64[0]);
2942c82a8a85SMark Cave-Ayland }
2943c82a8a85SMark Cave-Ayland
acc_full_offset(int i)2944a702c533SLucas Mateus Castro (alqotel) static inline int acc_full_offset(int i)
2945a702c533SLucas Mateus Castro (alqotel) {
2946a702c533SLucas Mateus Castro (alqotel) return vsr_full_offset(i * 4);
2947a702c533SLucas Mateus Castro (alqotel) }
2948a702c533SLucas Mateus Castro (alqotel)
fpr_offset(int i)2949d59d1182SMark Cave-Ayland static inline int fpr_offset(int i)
2950d59d1182SMark Cave-Ayland {
2951d59d1182SMark Cave-Ayland return vsr64_offset(i, true);
2952d59d1182SMark Cave-Ayland }
2953d59d1182SMark Cave-Ayland
cpu_fpr_ptr(CPUPPCState * env,int i)2954d59d1182SMark Cave-Ayland static inline uint64_t *cpu_fpr_ptr(CPUPPCState *env, int i)
2955d59d1182SMark Cave-Ayland {
2956d59d1182SMark Cave-Ayland return (uint64_t *)((uintptr_t)env + fpr_offset(i));
2957d59d1182SMark Cave-Ayland }
2958d59d1182SMark Cave-Ayland
cpu_vsrl_ptr(CPUPPCState * env,int i)2959ef96e3aeSMark Cave-Ayland static inline uint64_t *cpu_vsrl_ptr(CPUPPCState *env, int i)
2960ef96e3aeSMark Cave-Ayland {
2961d59d1182SMark Cave-Ayland return (uint64_t *)((uintptr_t)env + vsr64_offset(i, false));
2962ef96e3aeSMark Cave-Ayland }
2963ef96e3aeSMark Cave-Ayland
avr64_offset(int i,bool high)296437da91f1SMark Cave-Ayland static inline long avr64_offset(int i, bool high)
296537da91f1SMark Cave-Ayland {
2966d59d1182SMark Cave-Ayland return vsr64_offset(i + 32, high);
296737da91f1SMark Cave-Ayland }
296837da91f1SMark Cave-Ayland
avr_full_offset(int i)2969c82a8a85SMark Cave-Ayland static inline int avr_full_offset(int i)
2970c82a8a85SMark Cave-Ayland {
2971c82a8a85SMark Cave-Ayland return vsr_full_offset(i + 32);
2972c82a8a85SMark Cave-Ayland }
2973c82a8a85SMark Cave-Ayland
cpu_avr_ptr(CPUPPCState * env,int i)2974ef96e3aeSMark Cave-Ayland static inline ppc_avr_t *cpu_avr_ptr(CPUPPCState *env, int i)
2975ef96e3aeSMark Cave-Ayland {
2976c82a8a85SMark Cave-Ayland return (ppc_avr_t *)((uintptr_t)env + avr_full_offset(i));
2977ef96e3aeSMark Cave-Ayland }
2978ef96e3aeSMark Cave-Ayland
ppc_has_spr(PowerPCCPU * cpu,int spr)297903282a3aSLucas Mateus Castro (alqotel) static inline bool ppc_has_spr(PowerPCCPU *cpu, int spr)
298003282a3aSLucas Mateus Castro (alqotel) {
298103282a3aSLucas Mateus Castro (alqotel) /* We can test whether the SPR is defined by checking for a valid name */
298203282a3aSLucas Mateus Castro (alqotel) return cpu->env.spr_cb[spr].name != NULL;
298303282a3aSLucas Mateus Castro (alqotel) }
298403282a3aSLucas Mateus Castro (alqotel)
2985516fc103SFabiano Rosas #if !defined(CONFIG_USER_ONLY)
2986ab452503SBALATON Zoltan /* Sort out endianness of interrupt. Depends on the CPU, HV mode, etc. */
ppc_interrupts_little_endian(PowerPCCPU * cpu,bool hv)2987516fc103SFabiano Rosas static inline bool ppc_interrupts_little_endian(PowerPCCPU *cpu, bool hv)
2988c11dc15dSGreg Kurz {
2989c11dc15dSGreg Kurz PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
2990516fc103SFabiano Rosas CPUPPCState *env = &cpu->env;
29912e894848SFabiano Rosas bool ile;
2992c11dc15dSGreg Kurz
2993516fc103SFabiano Rosas if (hv && env->has_hv_mode) {
2994516fc103SFabiano Rosas if (is_isa300(pcc)) {
2995516fc103SFabiano Rosas ile = !!(env->spr[SPR_HID0] & HID0_POWER9_HILE);
2996516fc103SFabiano Rosas } else {
2997516fc103SFabiano Rosas ile = !!(env->spr[SPR_HID0] & HID0_HILE);
2998c11dc15dSGreg Kurz }
2999c11dc15dSGreg Kurz
3000516fc103SFabiano Rosas } else if (pcc->lpcr_mask & LPCR_ILE) {
3001516fc103SFabiano Rosas ile = !!(env->spr[SPR_LPCR] & LPCR_ILE);
30022e894848SFabiano Rosas } else {
30033868540fSVíctor Colombo ile = FIELD_EX64(env->msr, MSR, ILE);
3004c11dc15dSGreg Kurz }
3005c11dc15dSGreg Kurz
3006516fc103SFabiano Rosas return ile;
3007516fc103SFabiano Rosas }
3008516fc103SFabiano Rosas #endif
3009516fc103SFabiano Rosas
3010fad866daSMarkus Armbruster void dump_mmu(CPUPPCState *env);
3011fcf5ef2aSThomas Huth
3012fcf5ef2aSThomas Huth void ppc_maybe_bswap_register(CPUPPCState *env, uint8_t *mem_buf, int len);
3013c19940dbSBruno Larsen (billionai) void ppc_store_vscr(CPUPPCState *env, uint32_t vscr);
3014c19940dbSBruno Larsen (billionai) uint32_t ppc_get_vscr(CPUPPCState *env);
30152060436aSHarsh Prateek Bora void ppc_set_cr(CPUPPCState *env, uint64_t cr);
30162060436aSHarsh Prateek Bora uint64_t ppc_get_cr(const CPUPPCState *env);
3017b58fd0c3SFabiano Rosas
3018b58fd0c3SFabiano Rosas /*****************************************************************************/
3019b58fd0c3SFabiano Rosas /* Power management enable checks */
check_pow_none(CPUPPCState * env)3020b58fd0c3SFabiano Rosas static inline int check_pow_none(CPUPPCState *env)
3021b58fd0c3SFabiano Rosas {
3022b58fd0c3SFabiano Rosas return 0;
3023b58fd0c3SFabiano Rosas }
3024b58fd0c3SFabiano Rosas
check_pow_nocheck(CPUPPCState * env)3025b58fd0c3SFabiano Rosas static inline int check_pow_nocheck(CPUPPCState *env)
3026b58fd0c3SFabiano Rosas {
3027b58fd0c3SFabiano Rosas return 1;
3028b58fd0c3SFabiano Rosas }
3029b58fd0c3SFabiano Rosas
303045693f94SNicholas Piggin /* attn enable check */
check_attn_none(CPUPPCState * env)303145693f94SNicholas Piggin static inline int check_attn_none(CPUPPCState *env)
303245693f94SNicholas Piggin {
303345693f94SNicholas Piggin return 0;
303445693f94SNicholas Piggin }
303545693f94SNicholas Piggin
3036b58fd0c3SFabiano Rosas /*****************************************************************************/
3037b58fd0c3SFabiano Rosas /* PowerPC implementations definitions */
3038b58fd0c3SFabiano Rosas
3039b58fd0c3SFabiano Rosas #define POWERPC_FAMILY(_name) \
3040b58fd0c3SFabiano Rosas static void \
3041b58fd0c3SFabiano Rosas glue(glue(ppc_, _name), _cpu_family_class_init)(ObjectClass *, void *); \
3042b58fd0c3SFabiano Rosas \
3043b58fd0c3SFabiano Rosas static const TypeInfo \
3044b58fd0c3SFabiano Rosas glue(glue(ppc_, _name), _cpu_family_type_info) = { \
3045b58fd0c3SFabiano Rosas .name = stringify(_name) "-family-" TYPE_POWERPC_CPU, \
3046b58fd0c3SFabiano Rosas .parent = TYPE_POWERPC_CPU, \
3047b58fd0c3SFabiano Rosas .abstract = true, \
3048b58fd0c3SFabiano Rosas .class_init = glue(glue(ppc_, _name), _cpu_family_class_init), \
3049b58fd0c3SFabiano Rosas }; \
3050b58fd0c3SFabiano Rosas \
3051b58fd0c3SFabiano Rosas static void glue(glue(ppc_, _name), _cpu_family_register_types)(void) \
3052b58fd0c3SFabiano Rosas { \
3053b58fd0c3SFabiano Rosas type_register_static( \
3054b58fd0c3SFabiano Rosas &glue(glue(ppc_, _name), _cpu_family_type_info)); \
3055b58fd0c3SFabiano Rosas } \
3056b58fd0c3SFabiano Rosas \
3057b58fd0c3SFabiano Rosas type_init(glue(glue(ppc_, _name), _cpu_family_register_types)) \
3058b58fd0c3SFabiano Rosas \
3059b58fd0c3SFabiano Rosas static void glue(glue(ppc_, _name), _cpu_family_class_init)
3060b58fd0c3SFabiano Rosas
3061b58fd0c3SFabiano Rosas
3062fcf5ef2aSThomas Huth #endif /* PPC_CPU_H */
3063