Author: jhibbits
Date: Sat May  5 15:48:39 2018
New Revision: 333272
URL: https://svnweb.freebsd.org/changeset/base/333272

Log:
  Break out the cpu_features setup to its own function, to be run earlier
  
  The new POWER9 MMU configuration is slightly different from current setups.
  Rather than special-casing on POWER9, move the initialization of cpu_features
  and cpu_features2 to as early as possible, so that platform and MMU
  configuration can be based upon CPU features instead of specific CPUs if at 
all
  possible.
  
  Reviewed by:  nwhitehorn

Modified:
  head/sys/powerpc/include/md_var.h
  head/sys/powerpc/powerpc/cpu.c
  head/sys/powerpc/powerpc/machdep.c

Modified: head/sys/powerpc/include/md_var.h
==============================================================================
--- head/sys/powerpc/include/md_var.h   Sat May  5 15:42:58 2018        
(r333271)
+++ head/sys/powerpc/include/md_var.h   Sat May  5 15:48:39 2018        
(r333272)
@@ -63,6 +63,7 @@ void  decr_init(void);
 void   decr_ap_init(void);
 void   decr_tc_init(void);
 
+void   cpu_feature_setup(void);
 void   cpu_setup(u_int);
 
 struct trapframe;

Modified: head/sys/powerpc/powerpc/cpu.c
==============================================================================
--- head/sys/powerpc/powerpc/cpu.c      Sat May  5 15:42:58 2018        
(r333271)
+++ head/sys/powerpc/powerpc/cpu.c      Sat May  5 15:48:39 2018        
(r333272)
@@ -231,6 +231,8 @@ static int  cpu_feature_bit(SYSCTL_HANDLER_ARGS);
 static char model[64];
 SYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD, model, 0, "");
 
+static const struct cputab     *cput;
+
 u_long cpu_features = PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU;
 u_long cpu_features2 = 0;
 SYSCTL_OPAQUE(_hw, OID_AUTO, cpu_features, CTLFLAG_RD,
@@ -245,14 +247,37 @@ SYSCTL_PROC(_hw, OID_AUTO, floatingpoint, CTLTYPE_INT 
 SYSCTL_PROC(_hw, OID_AUTO, altivec, CTLTYPE_INT | CTLFLAG_RD,
     0, PPC_FEATURE_HAS_ALTIVEC, cpu_feature_bit, "I", "CPU supports Altivec");
 
+/*
+ * Phase 1 (early) CPU setup.  Setup the cpu_features/cpu_features2 variables,
+ * so they can be used during platform and MMU bringup.
+ */
 void
+cpu_feature_setup()
+{
+       u_int           pvr;
+       uint16_t        vers;
+       const struct    cputab *cp;
+
+       pvr = mfpvr();
+       vers = pvr >> 16;
+       for (cp = models; cp->version != 0; cp++) {
+               if (cp->version == vers)
+                       break;
+       }
+
+       cput = cp;
+       cpu_features |= cp->features;
+       cpu_features2 |= cp->features2;
+}
+
+
+void
 cpu_setup(u_int cpuid)
 {
-       u_int           pvr, maj, min;
-       uint16_t        vers, rev, revfmt;
        uint64_t        cps;
-       const struct    cputab *cp;
        const char      *name;
+       u_int           maj, min, pvr;
+       uint16_t        rev, revfmt, vers;
 
        pvr = mfpvr();
        vers = pvr >> 16;
@@ -274,13 +299,8 @@ cpu_setup(u_int cpuid)
                        min = (pvr >>  0) & 0xf;
        }
 
-       for (cp = models; cp->version != 0; cp++) {
-               if (cp->version == vers)
-                       break;
-       }
-
-       revfmt = cp->revfmt;
-       name = cp->name;
+       revfmt = cput->revfmt;
+       name = cput->name;
        if (rev == MPC750 && pvr == 15) {
                name = "Motorola MPC755";
                revfmt = REVFMT_HEX;
@@ -305,8 +325,6 @@ cpu_setup(u_int cpuid)
                printf(", %jd.%02jd MHz", cps / 1000000, (cps / 10000) % 100);
        printf("\n");
 
-       cpu_features |= cp->features;
-       cpu_features2 |= cp->features2;
        printf("cpu%d: Features %b\n", cpuid, (int)cpu_features,
            PPC_FEATURE_BITMASK);
        if (cpu_features2 != 0)
@@ -316,8 +334,8 @@ cpu_setup(u_int cpuid)
        /*
         * Configure CPU
         */
-       if (cp->cpu_setup != NULL)
-               cp->cpu_setup(cpuid, vers);
+       if (cput->cpu_setup != NULL)
+               cput->cpu_setup(cpuid, vers);
 }
 
 /* Get current clock frequency for the given cpu id. */

Modified: head/sys/powerpc/powerpc/machdep.c
==============================================================================
--- head/sys/powerpc/powerpc/machdep.c  Sat May  5 15:42:58 2018        
(r333271)
+++ head/sys/powerpc/powerpc/machdep.c  Sat May  5 15:48:39 2018        
(r333272)
@@ -275,6 +275,8 @@ powerpc_init(vm_offset_t fdt, vm_offset_t toc, vm_offs
        bzero(__bss_start, _end - __bss_start);
 #endif
 
+       cpu_feature_setup();
+
 #ifdef AIM
        aim_early_init(fdt, toc, ofentry, mdp, mdp_cookie);
 #endif
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to