Add field encoders for TLB count, PID count, PID width, real address
width and LPID width for the MMUCFG register. Compose the e6500
configuration from these encoders. The value remains 0x06510b45.

Signed-off-by: Bin Meng <[email protected]>

---

Changes in v3:
- New

 target/ppc/cpu.h      | 24 +++++++++++++++---------
 target/ppc/cpu_init.c |  4 +++-
 2 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
index 7fe02887de..451b794a21 100644
--- a/target/ppc/cpu.h
+++ b/target/ppc/cpu.h
@@ -1120,15 +1120,21 @@ FIELD(FPSCR, FI, FPSCR_FI, 1)
 #define MAS8_TLBPID             0x00000fff
 
 /* Bit definitions for MMUCFG */
-#define MMUCFG_MAVN     0x00000003      /* MMU Architecture Version Number */
-#define MMUCFG_MAVN_V1  0x00000000      /* v1.0 */
-#define MMUCFG_MAVN_V2  0x00000001      /* v2.0 */
-#define MMUCFG_NTLBS    0x0000000c      /* Number of TLBs */
-#define MMUCFG_PIDSIZE  0x000007c0      /* PID Reg Size */
-#define MMUCFG_TWC      0x00008000      /* TLB Write Conditional (v2.0) */
-#define MMUCFG_LRAT     0x00010000      /* LRAT Supported (v2.0) */
-#define MMUCFG_RASIZE   0x00fe0000      /* Real Addr Size */
-#define MMUCFG_LPIDSIZE 0x0f000000      /* LPID Reg Size */
+#define MMUCFG_MAVN            0x00000003 /* MMU Architecture Version Number */
+#define MMUCFG_MAVN_V1         0x00000000 /* v1.0 */
+#define MMUCFG_MAVN_V2         0x00000001 /* v2.0 */
+#define MMUCFG_NTLBS_MASK      0x0000000c /* Number of TLBs minus one */
+#define MMUCFG_NTLBS(n)        (((n) - 1U) << 2)
+#define MMUCFG_PIDSIZE_MASK    0x000007c0 /* PID width minus one */
+#define MMUCFG_PIDSIZE(n)      (((n) - 1U) << 6)
+#define MMUCFG_NPIDS_MASK      0x00007800 /* Number of PID registers */
+#define MMUCFG_NPIDS(n)        ((n) << 11)
+#define MMUCFG_TWC             0x00008000 /* TLB Write Conditional (v2.0) */
+#define MMUCFG_LRAT            0x00010000 /* LRAT Supported (v2.0) */
+#define MMUCFG_RASIZE_MASK     0x00fe0000 /* Real address width */
+#define MMUCFG_RASIZE(n)       ((n) << 17)
+#define MMUCFG_LPIDSIZE_MASK   0x0f000000 /* LPID width */
+#define MMUCFG_LPIDSIZE(n)     ((n) << 24)
 
 /* Bit definitions for MMUCSR0 */
 #define MMUCSR0_TLB1FI  0x00000002      /* TLB1 Flash invalidate */
diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
index 52340bb84c..945754e9a4 100644
--- a/target/ppc/cpu_init.c
+++ b/target/ppc/cpu_init.c
@@ -2865,7 +2865,9 @@ static void init_proc_e500(CPUPPCState *env, int version)
         tlbncfg[1] = register_tlbncfg(64, 1, 12, TLBnCFG_AVAIL | 
TLBnCFG_IPROT, 64);
         break;
     case fsl_e6500:
-        mmucfg = 0x6510B45;
+        mmucfg = MMUCFG_MAVN_V2 | MMUCFG_NTLBS(2) |
+                 MMUCFG_NPIDS(1) | MMUCFG_PIDSIZE(14) | MMUCFG_LRAT |
+                 MMUCFG_RASIZE(40) | MMUCFG_LPIDSIZE(6);
         env->nb_pids = 1;
         tlbncfg[0] = 0x08052400;
         tlbncfg[1] = 0x40028040;
-- 
2.53.0


Reply via email to