Module Name: src Committed By: thorpej Date: Fri Feb 26 21:15:20 UTC 2021
Modified Files: src/sys/arch/powerpc/include/oea: cpufeat.h src/sys/arch/powerpc/oea: cpu_subr.c Log Message: Split cpu_model_init() into cpu_features_probe() and cpu_features_enable() so that early bootstrap can do those two steps independently, if needed. Continue to provide a cpu_model_init() wrapper for now. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/powerpc/include/oea/cpufeat.h cvs rdiff -u -r1.106 -r1.107 src/sys/arch/powerpc/oea/cpu_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/powerpc/include/oea/cpufeat.h diff -u src/sys/arch/powerpc/include/oea/cpufeat.h:1.5 src/sys/arch/powerpc/include/oea/cpufeat.h:1.6 --- src/sys/arch/powerpc/include/oea/cpufeat.h:1.5 Thu Mar 22 21:26:27 2018 +++ src/sys/arch/powerpc/include/oea/cpufeat.h Fri Feb 26 21:15:20 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cpufeat.h,v 1.5 2018/03/22 21:26:27 macallan Exp $ */ +/* $NetBSD: cpufeat.h,v 1.6 2021/02/26 21:15:20 thorpej Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. * All rights reserved. @@ -30,7 +30,8 @@ #ifndef _POWERPC_OEA_OEAFEAT_H_ -/* Cpu features for OEA Cpus. +/* + * Cpu features for OEA Cpus. * These are only features that affect early bootstrap, and decisions * that need to be made very early on, like what pmap to use, if bats are * available, etc etc. More can be added later. Some are not yet utilized. @@ -48,7 +49,9 @@ #define OEACPU_XBSEN (1 << 7) /* BATS > 256MB */ #ifdef _KERNEL -void cpu_model_init(void); +void cpu_features_probe(void); +void cpu_features_enable(void); +void cpu_model_init(void); extern unsigned long oeacpufeat; #define oea_mapiodev(addr, size) ((oeacpufeat & OEACPU_NOBAT) ? \ Index: src/sys/arch/powerpc/oea/cpu_subr.c diff -u src/sys/arch/powerpc/oea/cpu_subr.c:1.106 src/sys/arch/powerpc/oea/cpu_subr.c:1.107 --- src/sys/arch/powerpc/oea/cpu_subr.c:1.106 Fri Feb 26 02:18:57 2021 +++ src/sys/arch/powerpc/oea/cpu_subr.c Fri Feb 26 21:15:20 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_subr.c,v 1.106 2021/02/26 02:18:57 thorpej Exp $ */ +/* $NetBSD: cpu_subr.c,v 1.107 2021/02/26 21:15:20 thorpej Exp $ */ /*- * Copyright (c) 2001 Matt Thomas. @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.106 2021/02/26 02:18:57 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.107 2021/02/26 21:15:20 thorpej Exp $"); #include "sysmon_envsys.h" @@ -267,20 +267,22 @@ register_t cpu_pslusermask = 0xffff; unsigned long oeacpufeat; -/* This is to be called from locore.S, and nowhere else. */ - void -cpu_model_init(void) +cpu_features_probe(void) { + static bool feature_probe_done; + u_int pvr, vers; + if (feature_probe_done) { + return; + } + pvr = mfpvr(); vers = pvr >> 16; - oeacpufeat = 0; - if ((vers >= IBMRS64II && vers <= IBM970GX) || vers == MPC620 || - vers == IBMCELL || vers == IBMPOWER6P5) { + vers == IBMCELL || vers == IBMPOWER6P5) { oeacpufeat |= OEACPU_64; oeacpufeat |= OEACPU_64_BRIDGE; oeacpufeat |= OEACPU_NOBAT; @@ -289,22 +291,53 @@ cpu_model_init(void) oeacpufeat |= OEACPU_601; } else if (MPC745X_P(vers)) { - register_t hid1 = mfspr(SPR_HID1); - if (vers != MPC7450) { - register_t hid0 = mfspr(SPR_HID0); - /* Enable more SPRG registers */ oeacpufeat |= OEACPU_HIGHSPRG; /* Enable more BAT registers */ oeacpufeat |= OEACPU_HIGHBAT; - hid0 |= HID0_HIGH_BAT_EN; /* Enable larger BAT registers */ oeacpufeat |= OEACPU_XBSEN; + } + + } else if (vers == IBM750FX || vers == IBM750GX) { + oeacpufeat |= OEACPU_HIGHBAT; + } + + feature_probe_done = true; +} + +void +cpu_features_enable(void) +{ + static bool feature_enable_done; + + if (feature_enable_done) { + return; + } + + u_int pvr, vers; + + pvr = mfpvr(); + vers = pvr >> 16; + + if (MPC745X_P(vers)) { + register_t hid0 = mfspr(SPR_HID0); + register_t hid1 = mfspr(SPR_HID1); + + const register_t ohid0 = hid0; + + if (oeacpufeat & OEACPU_HIGHBAT) { + hid0 |= HID0_HIGH_BAT_EN; + } + + if (oeacpufeat & OEACPU_XBSEN) { hid0 |= HID0_XBSEN; + } + if (hid0 != ohid0) { mtspr(SPR_HID0, hid0); __asm volatile("sync;isync"); } @@ -314,10 +347,22 @@ cpu_model_init(void) mtspr(SPR_HID1, hid1); __asm volatile("sync;isync"); - - } else if (vers == IBM750FX || vers == IBM750GX) { - oeacpufeat |= OEACPU_HIGHBAT; } + + feature_enable_done = true; +} + +/* This is to be called from locore.S, and nowhere else. */ + +void +cpu_model_init(void) +{ + /* + * This is just a wrapper for backwards-compatibility, and will + * probably be garbage-collected in the near future. + */ + cpu_features_probe(); + cpu_features_enable(); } void