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
This commit is contained in:
Justin Hibbits 2018-05-05 15:48:39 +00:00
parent 4f4f92c58f
commit 55a12bbda2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=333272
3 changed files with 35 additions and 14 deletions

View File

@ -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;

View File

@ -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 | CTLFLAG_RD,
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. */

View File

@ -275,6 +275,8 @@ powerpc_init(vm_offset_t fdt, vm_offset_t toc, vm_offset_t ofentry, void *mdp,
bzero(__bss_start, _end - __bss_start);
#endif
cpu_feature_setup();
#ifdef AIM
aim_early_init(fdt, toc, ofentry, mdp, mdp_cookie);
#endif