summary refs log tree commit diff stats
path: root/target-ppc/cpu.h
diff options
context:
space:
mode:
Diffstat (limited to 'target-ppc/cpu.h')
-rw-r--r--target-ppc/cpu.h163
1 files changed, 137 insertions, 26 deletions
diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h
index 75ed5fa636..74407ee209 100644
--- a/target-ppc/cpu.h
+++ b/target-ppc/cpu.h
@@ -238,6 +238,7 @@ enum {
     POWERPC_EXCP_DTLBE    = 93, /* Data TLB error                            */
     /* VSX Unavailable (Power ISA 2.06 and later)                            */
     POWERPC_EXCP_VSXU     = 94, /* VSX Unavailable                           */
+    POWERPC_EXCP_FU       = 95, /* Facility Unavailable                      */
     /* EOL                                                                   */
     POWERPC_EXCP_NB       = 96,
     /* QEMU exceptions: used internally during code translation              */
@@ -426,6 +427,9 @@ struct ppc_slb_t {
 #define MSR_TAG  62 /* Tag-active mode (POWERx ?)                            */
 #define MSR_ISF  61 /* Sixty-four-bit interrupt mode on 630                  */
 #define MSR_SHV  60 /* hypervisor state                               hflags */
+#define MSR_TS0  34 /* Transactional state, 2 bits (Book3s)                  */
+#define MSR_TS1  33
+#define MSR_TM   32 /* Transactional Memory Available (Book3s)               */
 #define MSR_CM   31 /* Computation mode for BookE                     hflags */
 #define MSR_ICM  30 /* Interrupt computation mode for BookE                  */
 #define MSR_THV  29 /* hypervisor state for 32 bits PowerPC           hflags */
@@ -463,6 +467,8 @@ struct ppc_slb_t {
 #define MSR_LE   0  /* Little-endian mode                           1 hflags */
 
 #define LPCR_ILE (1 << (63-38))
+#define LPCR_AIL_SHIFT (63-40)      /* Alternate interrupt location */
+#define LPCR_AIL (3 << LPCR_AIL_SHIFT)
 
 #define msr_sf   ((env->msr >> MSR_SF)   & 1)
 #define msr_isf  ((env->msr >> MSR_ISF)  & 1)
@@ -502,6 +508,9 @@ struct ppc_slb_t {
 #define msr_pmm  ((env->msr >> MSR_PMM)  & 1)
 #define msr_ri   ((env->msr >> MSR_RI)   & 1)
 #define msr_le   ((env->msr >> MSR_LE)   & 1)
+#define msr_ts   ((env->msr >> MSR_TS1)  & 3)
+#define msr_tm   ((env->msr >> MSR_TM)   & 1)
+
 /* Hypervisor bit is more specific */
 #if defined(TARGET_PPC64)
 #define MSR_HVB (1ULL << MSR_SHV)
@@ -516,6 +525,19 @@ struct ppc_slb_t {
 #endif
 #endif
 
+/* Facility Status and Control (FSCR) bits */
+#define FSCR_EBB        (63 - 56) /* Event-Based Branch Facility */
+#define FSCR_TAR        (63 - 55) /* Target Address Register */
+/* Interrupt cause mask and position in FSCR. HFSCR has the same format */
+#define FSCR_IC_MASK    (0xFFULL)
+#define FSCR_IC_POS     (63 - 7)
+#define FSCR_IC_DSCR_SPR3   2
+#define FSCR_IC_PMU         3
+#define FSCR_IC_BHRB        4
+#define FSCR_IC_TM          5
+#define FSCR_IC_EBB         7
+#define FSCR_IC_TAR         8
+
 /* Exception state register bits definition                                  */
 #define ESR_PIL   (1 << (63 - 36)) /* Illegal Instruction                    */
 #define ESR_PPR   (1 << (63 - 37)) /* Privileged Instruction                 */
@@ -908,10 +930,8 @@ struct CPUPPCState {
      */
     /* general purpose registers */
     target_ulong gpr[32];
-#if !defined(TARGET_PPC64)
     /* Storage for GPR MSB, used by the SPE extension */
     target_ulong gprh[32];
-#endif
     /* LR */
     target_ulong lr;
     /* CTR */
@@ -1081,6 +1101,20 @@ struct CPUPPCState {
      */
     uint8_t fit_period[4];
     uint8_t wdt_period[4];
+
+    /* Transactional memory state */
+    target_ulong tm_gpr[32];
+    ppc_avr_t tm_vsr[64];
+    uint64_t tm_cr;
+    uint64_t tm_lr;
+    uint64_t tm_ctr;
+    uint64_t tm_fpscr;
+    uint64_t tm_amr;
+    uint64_t tm_ppr;
+    uint64_t tm_vrsave;
+    uint32_t tm_vscr;
+    uint64_t tm_dscr;
+    uint64_t tm_tar;
 };
 
 #define SET_FIT_PERIOD(a_, b_, c_, d_)          \
@@ -1104,6 +1138,7 @@ do {                                            \
 /*****************************************************************************/
 PowerPCCPU *cpu_ppc_init(const char *cpu_model);
 void ppc_translate_init(void);
+void gen_update_current_nip(void *opaque);
 int cpu_ppc_exec (CPUPPCState *s);
 /* you can call this signal handler from your SIGBUS and SIGSEGV
    signal handlers to inform the virtual CPU of exceptions. non zero
@@ -1122,6 +1157,8 @@ void ppc_store_sdr1 (CPUPPCState *env, target_ulong value);
 void ppc_store_msr (CPUPPCState *env, target_ulong value);
 
 void ppc_cpu_list (FILE *f, fprintf_function cpu_fprintf);
+int ppc_get_compat_smt_threads(PowerPCCPU *cpu);
+int ppc_set_compat(PowerPCCPU *cpu, uint32_t cpu_version);
 
 /* Time-base and decrementer management */
 #ifndef NO_CPU_IO_DEFS
@@ -1162,7 +1199,6 @@ static inline uint64_t ppc_dump_gpr(CPUPPCState *env, int gprn)
     uint64_t gprv;
 
     gprv = env->gpr[gprn];
-#if !defined(TARGET_PPC64)
     if (env->flags & POWERPC_FLAG_SPE) {
         /* If the CPU implements the SPE extension, we have to get the
          * high bits of the GPR from the gprh storage area
@@ -1170,7 +1206,6 @@ static inline uint64_t ppc_dump_gpr(CPUPPCState *env, int gprn)
         gprv &= 0xFFFFFFFFULL;
         gprv |= (uint64_t)env->gprh[gprn] << 32;
     }
-#endif
 
     return gprv;
 }
@@ -1258,6 +1293,10 @@ static inline int cpu_mmu_index (CPUPPCState *env)
 #define SPR_MPC_EIE           (0x050)
 #define SPR_MPC_EID           (0x051)
 #define SPR_MPC_NRI           (0x052)
+#define SPR_TFHAR             (0x080)
+#define SPR_TFIAR             (0x081)
+#define SPR_TEXASR            (0x082)
+#define SPR_TEXASRU           (0x083)
 #define SPR_UCTRL             (0x088)
 #define SPR_MPC_CMPA          (0x090)
 #define SPR_MPC_CMPB          (0x091)
@@ -1270,6 +1309,7 @@ static inline int cpu_mmu_index (CPUPPCState *env)
 #define SPR_CTRL              (0x098)
 #define SPR_MPC_CMPE          (0x098)
 #define SPR_MPC_CMPF          (0x099)
+#define SPR_FSCR              (0x099)
 #define SPR_MPC_CMPG          (0x09A)
 #define SPR_MPC_CMPH          (0x09B)
 #define SPR_MPC_LCTRL1        (0x09C)
@@ -1338,6 +1378,7 @@ static inline int cpu_mmu_index (CPUPPCState *env)
 #define SPR_LPCR              (0x13E)
 #define SPR_BOOKE_DVC2        (0x13F)
 #define SPR_BOOKE_TSR         (0x150)
+#define SPR_PCR               (0x152)
 #define SPR_BOOKE_TCR         (0x154)
 #define SPR_BOOKE_TLB0PS      (0x158)
 #define SPR_BOOKE_TLB1PS      (0x159)
@@ -1365,10 +1406,18 @@ static inline int cpu_mmu_index (CPUPPCState *env)
 #define SPR_BOOKE_IVOR40      (0x1B2)
 #define SPR_BOOKE_IVOR41      (0x1B3)
 #define SPR_BOOKE_IVOR42      (0x1B4)
+#define SPR_BOOKE_GIVOR2      (0x1B8)
+#define SPR_BOOKE_GIVOR3      (0x1B9)
+#define SPR_BOOKE_GIVOR4      (0x1BA)
+#define SPR_BOOKE_GIVOR8      (0x1BB)
+#define SPR_BOOKE_GIVOR13     (0x1BC)
+#define SPR_BOOKE_GIVOR14     (0x1BD)
+#define SPR_TIR               (0x1BE)
 #define SPR_BOOKE_SPEFSCR     (0x200)
 #define SPR_Exxx_BBEAR        (0x201)
 #define SPR_Exxx_BBTAR        (0x202)
 #define SPR_Exxx_L1CFG0       (0x203)
+#define SPR_Exxx_L1CFG1       (0x204)
 #define SPR_Exxx_NPIDR        (0x205)
 #define SPR_ATBL              (0x20E)
 #define SPR_ATBU              (0x20F)
@@ -1453,62 +1502,96 @@ static inline int cpu_mmu_index (CPUPPCState *env)
 #define SPR_MPC_MI_CTR        (0x300)
 #define SPR_PERF1             (0x301)
 #define SPR_RCPU_MI_RBA1      (0x301)
+#define SPR_POWER_UMMCR2      (0x301)
 #define SPR_PERF2             (0x302)
 #define SPR_RCPU_MI_RBA2      (0x302)
 #define SPR_MPC_MI_AP         (0x302)
-#define SPR_MMCRA             (0x302)
+#define SPR_POWER_UMMCRA      (0x302)
 #define SPR_PERF3             (0x303)
 #define SPR_RCPU_MI_RBA3      (0x303)
 #define SPR_MPC_MI_EPN        (0x303)
+#define SPR_POWER_UPMC1       (0x303)
 #define SPR_PERF4             (0x304)
+#define SPR_POWER_UPMC2       (0x304)
 #define SPR_PERF5             (0x305)
 #define SPR_MPC_MI_TWC        (0x305)
+#define SPR_POWER_UPMC3       (0x305)
 #define SPR_PERF6             (0x306)
 #define SPR_MPC_MI_RPN        (0x306)
+#define SPR_POWER_UPMC4       (0x306)
 #define SPR_PERF7             (0x307)
+#define SPR_POWER_UPMC5       (0x307)
 #define SPR_PERF8             (0x308)
 #define SPR_RCPU_L2U_RBA0     (0x308)
 #define SPR_MPC_MD_CTR        (0x308)
+#define SPR_POWER_UPMC6       (0x308)
 #define SPR_PERF9             (0x309)
 #define SPR_RCPU_L2U_RBA1     (0x309)
 #define SPR_MPC_MD_CASID      (0x309)
+#define SPR_970_UPMC7         (0X309)
 #define SPR_PERFA             (0x30A)
 #define SPR_RCPU_L2U_RBA2     (0x30A)
 #define SPR_MPC_MD_AP         (0x30A)
+#define SPR_970_UPMC8         (0X30A)
 #define SPR_PERFB             (0x30B)
 #define SPR_RCPU_L2U_RBA3     (0x30B)
 #define SPR_MPC_MD_EPN        (0x30B)
+#define SPR_POWER_UMMCR0      (0X30B)
 #define SPR_PERFC             (0x30C)
 #define SPR_MPC_MD_TWB        (0x30C)
+#define SPR_POWER_USIAR       (0X30C)
 #define SPR_PERFD             (0x30D)
 #define SPR_MPC_MD_TWC        (0x30D)
+#define SPR_POWER_USDAR       (0X30D)
 #define SPR_PERFE             (0x30E)
 #define SPR_MPC_MD_RPN        (0x30E)
+#define SPR_POWER_UMMCR1      (0X30E)
 #define SPR_PERFF             (0x30F)
 #define SPR_MPC_MD_TW         (0x30F)
 #define SPR_UPERF0            (0x310)
 #define SPR_UPERF1            (0x311)
+#define SPR_POWER_MMCR2       (0x311)
 #define SPR_UPERF2            (0x312)
+#define SPR_POWER_MMCRA       (0X312)
 #define SPR_UPERF3            (0x313)
+#define SPR_POWER_PMC1        (0X313)
 #define SPR_UPERF4            (0x314)
+#define SPR_POWER_PMC2        (0X314)
 #define SPR_UPERF5            (0x315)
+#define SPR_POWER_PMC3        (0X315)
 #define SPR_UPERF6            (0x316)
+#define SPR_POWER_PMC4        (0X316)
 #define SPR_UPERF7            (0x317)
+#define SPR_POWER_PMC5        (0X317)
 #define SPR_UPERF8            (0x318)
+#define SPR_POWER_PMC6        (0X318)
 #define SPR_UPERF9            (0x319)
+#define SPR_970_PMC7          (0X319)
 #define SPR_UPERFA            (0x31A)
+#define SPR_970_PMC8          (0X31A)
 #define SPR_UPERFB            (0x31B)
+#define SPR_POWER_MMCR0       (0X31B)
 #define SPR_UPERFC            (0x31C)
+#define SPR_POWER_SIAR        (0X31C)
 #define SPR_UPERFD            (0x31D)
+#define SPR_POWER_SDAR        (0X31D)
 #define SPR_UPERFE            (0x31E)
+#define SPR_POWER_MMCR1       (0X31E)
 #define SPR_UPERFF            (0x31F)
 #define SPR_RCPU_MI_RA0       (0x320)
 #define SPR_MPC_MI_DBCAM      (0x320)
+#define SPR_BESCRS            (0x320)
 #define SPR_RCPU_MI_RA1       (0x321)
 #define SPR_MPC_MI_DBRAM0     (0x321)
+#define SPR_BESCRSU           (0x321)
 #define SPR_RCPU_MI_RA2       (0x322)
 #define SPR_MPC_MI_DBRAM1     (0x322)
+#define SPR_BESCRR            (0x322)
 #define SPR_RCPU_MI_RA3       (0x323)
+#define SPR_BESCRRU           (0x323)
+#define SPR_EBBHR             (0x324)
+#define SPR_EBBRR             (0x325)
+#define SPR_BESCR             (0x326)
 #define SPR_RCPU_L2U_RA0      (0x328)
 #define SPR_MPC_MD_DBCAM      (0x328)
 #define SPR_RCPU_L2U_RA1      (0x329)
@@ -1527,6 +1610,7 @@ static inline int cpu_mmu_index (CPUPPCState *env)
 #define SPR_440_ITV3          (0x377)
 #define SPR_440_CCR1          (0x378)
 #define SPR_DCRIPR            (0x37B)
+#define SPR_POWER_MMCRS       (0x37E)
 #define SPR_PPR               (0x380)
 #define SPR_750_GQR0          (0x390)
 #define SPR_440_DNV0          (0x390)
@@ -1556,24 +1640,24 @@ static inline int cpu_mmu_index (CPUPPCState *env)
 #define SPR_BOOKE_DCDBTRH     (0x39D)
 #define SPR_BOOKE_ICDBTRL     (0x39E)
 #define SPR_BOOKE_ICDBTRH     (0x39F)
-#define SPR_UMMCR2            (0x3A0)
-#define SPR_UPMC5             (0x3A1)
-#define SPR_UPMC6             (0x3A2)
+#define SPR_74XX_UMMCR2       (0x3A0)
+#define SPR_7XX_UPMC5         (0x3A1)
+#define SPR_7XX_UPMC6         (0x3A2)
 #define SPR_UBAMR             (0x3A7)
-#define SPR_UMMCR0            (0x3A8)
-#define SPR_UPMC1             (0x3A9)
-#define SPR_UPMC2             (0x3AA)
-#define SPR_USIAR             (0x3AB)
-#define SPR_UMMCR1            (0x3AC)
-#define SPR_UPMC3             (0x3AD)
-#define SPR_UPMC4             (0x3AE)
+#define SPR_7XX_UMMCR0        (0x3A8)
+#define SPR_7XX_UPMC1         (0x3A9)
+#define SPR_7XX_UPMC2         (0x3AA)
+#define SPR_7XX_USIAR         (0x3AB)
+#define SPR_7XX_UMMCR1        (0x3AC)
+#define SPR_7XX_UPMC3         (0x3AD)
+#define SPR_7XX_UPMC4         (0x3AE)
 #define SPR_USDA              (0x3AF)
 #define SPR_40x_ZPR           (0x3B0)
 #define SPR_BOOKE_MAS7        (0x3B0)
-#define SPR_MMCR2             (0x3B0)
-#define SPR_PMC5              (0x3B1)
+#define SPR_74XX_MMCR2        (0x3B0)
+#define SPR_7XX_PMC5          (0x3B1)
 #define SPR_40x_PID           (0x3B1)
-#define SPR_PMC6              (0x3B2)
+#define SPR_7XX_PMC6          (0x3B2)
 #define SPR_440_MMUCR         (0x3B2)
 #define SPR_4xx_CCR0          (0x3B3)
 #define SPR_BOOKE_EPLC        (0x3B3)
@@ -1583,19 +1667,19 @@ static inline int cpu_mmu_index (CPUPPCState *env)
 #define SPR_405_DVC1          (0x3B6)
 #define SPR_405_DVC2          (0x3B7)
 #define SPR_BAMR              (0x3B7)
-#define SPR_MMCR0             (0x3B8)
-#define SPR_PMC1              (0x3B9)
+#define SPR_7XX_MMCR0         (0x3B8)
+#define SPR_7XX_PMC1          (0x3B9)
 #define SPR_40x_SGR           (0x3B9)
-#define SPR_PMC2              (0x3BA)
+#define SPR_7XX_PMC2          (0x3BA)
 #define SPR_40x_DCWR          (0x3BA)
-#define SPR_SIAR              (0x3BB)
+#define SPR_7XX_SIAR          (0x3BB)
 #define SPR_405_SLER          (0x3BB)
-#define SPR_MMCR1             (0x3BC)
+#define SPR_7XX_MMCR1         (0x3BC)
 #define SPR_405_SU0R          (0x3BC)
 #define SPR_401_SKR           (0x3BC)
-#define SPR_PMC3              (0x3BD)
+#define SPR_7XX_PMC3          (0x3BD)
 #define SPR_405_DBCR1         (0x3BD)
-#define SPR_PMC4              (0x3BE)
+#define SPR_7XX_PMC4          (0x3BE)
 #define SPR_SDA               (0x3BF)
 #define SPR_403_VTBL          (0x3CC)
 #define SPR_403_VTBU          (0x3CD)
@@ -1648,6 +1732,7 @@ static inline int cpu_mmu_index (CPUPPCState *env)
 #define SPR_750_TDCL          (0x3F4)
 #define SPR_40x_IAC1          (0x3F4)
 #define SPR_MMUCSR0           (0x3F4)
+#define SPR_970_HID4          (0x3F4)
 #define SPR_DABR              (0x3F5)
 #define DABR_MASK (~(target_ulong)0x7)
 #define SPR_Exxx_BUCSR        (0x3F5)
@@ -1709,6 +1794,23 @@ static inline int cpu_mmu_index (CPUPPCState *env)
 /* External Input Interrupt Directed to Guest State */
 #define EPCR_EXTGS            (1 << 31)
 
+#define   L1CSR0_CPE		0x00010000	/* Data Cache Parity Enable */
+#define   L1CSR0_CUL		0x00000400	/* (D-)Cache Unable to Lock */
+#define   L1CSR0_DCLFR		0x00000100	/* D-Cache Lock Flash Reset */
+#define   L1CSR0_DCFI		0x00000002	/* Data Cache Flash Invalidate */
+#define   L1CSR0_DCE		0x00000001	/* Data Cache Enable */
+
+#define   L1CSR1_CPE		0x00010000	/* Instruction Cache Parity Enable */
+#define   L1CSR1_ICUL		0x00000400	/* I-Cache Unable to Lock */
+#define   L1CSR1_ICLFR		0x00000100	/* I-Cache Lock Flash Reset */
+#define   L1CSR1_ICFI		0x00000002	/* Instruction Cache Flash Invalidate */
+#define   L1CSR1_ICE		0x00000001	/* Instruction Cache Enable */
+
+/* HID0 bits */
+#define HID0_DEEPNAP        (1 << 24)
+#define HID0_DOZE           (1 << 23)
+#define HID0_NAP            (1 << 22)
+
 /*****************************************************************************/
 /* PowerPC Instructions types definitions                                    */
 enum {
@@ -1910,7 +2012,7 @@ enum {
                         PPC2_DIVE_ISA206 | PPC2_ATOMIC_ISA206 | \
                         PPC2_FP_CVT_ISA206 | PPC2_FP_TST_ISA206 | \
                         PPC2_BCTAR_ISA207 | PPC2_LSQ_ISA207 | \
-                        PPC2_ALTIVEC_207)
+                        PPC2_ALTIVEC_207 | PPC2_ISA207S)
 };
 
 /*****************************************************************************/
@@ -2042,6 +2144,15 @@ enum {
     PPC_INTERRUPT_PERFM,          /* Performance monitor interrupt        */
 };
 
+/* Processor Compatibility mask (PCR) */
+enum {
+    PCR_COMPAT_2_05     = 1ull << (63-62),
+    PCR_COMPAT_2_06     = 1ull << (63-61),
+    PCR_VEC_DIS         = 1ull << (63-0), /* Vec. disable (bit NA since POWER8) */
+    PCR_VSX_DIS         = 1ull << (63-1), /* VSX disable (bit NA since POWER8) */
+    PCR_TM_DIS          = 1ull << (63-2), /* Trans. memory disable (POWER8) */
+};
+
 /*****************************************************************************/
 
 static inline target_ulong cpu_read_xer(CPUPPCState *env)