aboutsummaryrefslogtreecommitdiff
path: root/sys/powerpc/ofw/ofw_cpu.c
diff options
context:
space:
mode:
authorJustin Hibbits <jhibbits@FreeBSD.org>2013-06-23 14:20:54 +0000
committerJustin Hibbits <jhibbits@FreeBSD.org>2013-06-23 14:20:54 +0000
commit53c13dd1ab411600b292ee1db7472d0704c2ef06 (patch)
treebb387863e612b96a7520dcc222386eed8a8316fa /sys/powerpc/ofw/ofw_cpu.c
parentedc9198c33a5a42229cd8f9b97d6373065e78516 (diff)
downloadsrc-53c13dd1ab411600b292ee1db7472d0704c2ef06.tar.gz
src-53c13dd1ab411600b292ee1db7472d0704c2ef06.zip
Cache the Open Firmware CPU properties at attach time, so we don't always
enter it at runtime to get static data.
Notes
Notes: svn path=/head/; revision=252115
Diffstat (limited to 'sys/powerpc/ofw/ofw_cpu.c')
-rw-r--r--sys/powerpc/ofw/ofw_cpu.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/sys/powerpc/ofw/ofw_cpu.c b/sys/powerpc/ofw/ofw_cpu.c
index b50e3141eca1..6fb1126ae3cc 100644
--- a/sys/powerpc/ofw/ofw_cpu.c
+++ b/sys/powerpc/ofw/ofw_cpu.c
@@ -133,6 +133,11 @@ static int ofw_cpu_attach(device_t);
static int ofw_cpu_read_ivar(device_t dev, device_t child, int index,
uintptr_t *result);
+struct ofw_cpu_softc {
+ struct pcpu *sc_cpu_pcpu;
+ uint32_t sc_nominal_mhz;
+};
+
static device_method_t ofw_cpu_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, ofw_cpu_probe),
@@ -175,6 +180,15 @@ ofw_cpu_probe(device_t dev)
static int
ofw_cpu_attach(device_t dev)
{
+ struct ofw_cpu_softc *sc;
+ uint32_t cell;
+
+ sc = device_get_softc(dev);
+ OF_getprop(ofw_bus_get_node(dev), "reg", &cell, sizeof(cell));
+ sc->sc_cpu_pcpu = pcpu_find(cell);
+ OF_getprop(ofw_bus_get_node(dev), "clock-frequency", &cell, sizeof(cell));
+ sc->sc_nominal_mhz = cell / 1000000; /* convert to MHz */
+
bus_generic_probe(dev);
return (bus_generic_attach(dev));
}
@@ -182,19 +196,16 @@ ofw_cpu_attach(device_t dev)
static int
ofw_cpu_read_ivar(device_t dev, device_t child, int index, uintptr_t *result)
{
- uint32_t cell;
+ struct ofw_cpu_softc *sc;
+
+ sc = device_get_softc(dev);
switch (index) {
case CPU_IVAR_PCPU:
- OF_getprop(ofw_bus_get_node(dev), "reg", &cell, sizeof(cell));
- *result = (uintptr_t)(pcpu_find(cell));
+ *result = (uintptr_t)sc->sc_cpu_pcpu;
return (0);
case CPU_IVAR_NOMINAL_MHZ:
- cell = 0;
- OF_getprop(ofw_bus_get_node(dev), "clock-frequency",
- &cell, sizeof(cell));
- cell /= 1000000; /* convert to MHz */
- *result = (uintptr_t)(cell);
+ *result = (uintptr_t)sc->sc_nominal_mhz;
return (0);
}