ofw_cpu.c (276162) | ofw_cpu.c (277378) |
---|---|
1/*- 2 * Copyright (C) 2009 Nathan Whitehorn | 1/*- 2 * Copyright (C) 2009 Nathan Whitehorn |
3 * Copyright (C) 2015 The FreeBSD Foundation |
|
3 * All rights reserved. 4 * | 4 * All rights reserved. 5 * |
6 * Portions of this software were developed by Andrew Turner 7 * under sponsorship from the FreeBSD Foundation. 8 * |
|
5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. --- 7 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. --- 7 unchanged lines hidden (view full) --- 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 */ 30 31#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/dev/ofw/ofw_cpu.c 276162 2014-12-24 01:19:11Z ian $"); | 32__FBSDID("$FreeBSD: head/sys/dev/ofw/ofw_cpu.c 277378 2015-01-19 11:06:56Z andrew $"); |
29 30#include <sys/param.h> 31#include <sys/systm.h> 32#include <sys/kernel.h> 33#include <sys/module.h> 34#include <sys/malloc.h> 35#include <sys/bus.h> 36#include <sys/cpu.h> --- 151 unchanged lines hidden (view full) --- 188 sc = device_get_softc(dev); 189 node = ofw_bus_get_node(dev); 190 if (OF_getencprop(node, "reg", &cell, sizeof(cell)) < 0) { 191 cell = device_get_unit(dev); 192 device_printf(dev, "missing 'reg' property, using %u\n", cell); 193 } 194 sc->sc_cpu_pcpu = pcpu_find(cell); 195 if (OF_getencprop(node, "clock-frequency", &cell, sizeof(cell)) < 0) { | 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/kernel.h> 37#include <sys/module.h> 38#include <sys/malloc.h> 39#include <sys/bus.h> 40#include <sys/cpu.h> --- 151 unchanged lines hidden (view full) --- 192 sc = device_get_softc(dev); 193 node = ofw_bus_get_node(dev); 194 if (OF_getencprop(node, "reg", &cell, sizeof(cell)) < 0) { 195 cell = device_get_unit(dev); 196 device_printf(dev, "missing 'reg' property, using %u\n", cell); 197 } 198 sc->sc_cpu_pcpu = pcpu_find(cell); 199 if (OF_getencprop(node, "clock-frequency", &cell, sizeof(cell)) < 0) { |
196 device_printf(dev, "missing 'clock-frequency' property\n"); 197 return (ENXIO); 198 } 199 sc->sc_nominal_mhz = cell / 1000000; /* convert to MHz */ | 200 if (bootverbose) 201 device_printf(dev, 202 "missing 'clock-frequency' property\n"); 203 } else 204 sc->sc_nominal_mhz = cell / 1000000; /* convert to MHz */ |
200 201 bus_generic_probe(dev); 202 return (bus_generic_attach(dev)); 203} 204 205static int 206ofw_cpu_read_ivar(device_t dev, device_t child, int index, uintptr_t *result) 207{ 208 struct ofw_cpu_softc *sc; 209 210 sc = device_get_softc(dev); 211 212 switch (index) { 213 case CPU_IVAR_PCPU: 214 *result = (uintptr_t)sc->sc_cpu_pcpu; 215 return (0); 216 case CPU_IVAR_NOMINAL_MHZ: | 205 206 bus_generic_probe(dev); 207 return (bus_generic_attach(dev)); 208} 209 210static int 211ofw_cpu_read_ivar(device_t dev, device_t child, int index, uintptr_t *result) 212{ 213 struct ofw_cpu_softc *sc; 214 215 sc = device_get_softc(dev); 216 217 switch (index) { 218 case CPU_IVAR_PCPU: 219 *result = (uintptr_t)sc->sc_cpu_pcpu; 220 return (0); 221 case CPU_IVAR_NOMINAL_MHZ: |
217 *result = (uintptr_t)sc->sc_nominal_mhz; 218 return (0); | 222 if (sc->sc_nominal_mhz > 0) { 223 *result = (uintptr_t)sc->sc_nominal_mhz; 224 return (0); 225 } 226 break; |
219 } 220 221 return (ENOENT); 222} 223 | 227 } 228 229 return (ENOENT); 230} 231 |