1/*-
2 * Copyright (C) 2009 Nathan Whitehorn
3 * All rights reserved.
4 *
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
--- 11 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>
28__FBSDID("$FreeBSD: head/sys/dev/ofw/ofw_cpu.c 275815 2014-12-15 22:20:14Z emaste $");
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>
--- 129 unchanged lines hidden (view full) ---
166
167DRIVER_MODULE(ofw_cpu, cpulist, ofw_cpu_driver, ofw_cpu_devclass, 0, 0);
168
169static int
170ofw_cpu_probe(device_t dev)
171{
172 const char *type = ofw_bus_get_type(dev);
173
174 if (strcmp(type, "cpu") != 0)
175 return (ENXIO);
176
177 device_set_desc(dev, "Open Firmware CPU");
178 return (0);
179}
180
181static int
182ofw_cpu_attach(device_t dev)
183{
184 struct ofw_cpu_softc *sc;
185 uint32_t cell;
186
187 sc = device_get_softc(dev);
188 OF_getprop(ofw_bus_get_node(dev), "reg", &cell, sizeof(cell));
189 sc->sc_cpu_pcpu = pcpu_find(cell);
190 OF_getprop(ofw_bus_get_node(dev), "clock-frequency", &cell, sizeof(cell));
191 sc->sc_nominal_mhz = cell / 1000000; /* convert to MHz */
192
193 bus_generic_probe(dev);
194 return (bus_generic_attach(dev));
195}
196
197static int
198ofw_cpu_read_ivar(device_t dev, device_t child, int index, uintptr_t *result)
--- 17 unchanged lines hidden ---
2 * Copyright (C) 2009 Nathan Whitehorn
3 * All rights reserved.
4 *
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
--- 11 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>
28__FBSDID("$FreeBSD: head/sys/dev/ofw/ofw_cpu.c 275815 2014-12-15 22:20:14Z emaste $");
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>
--- 129 unchanged lines hidden (view full) ---
166
167DRIVER_MODULE(ofw_cpu, cpulist, ofw_cpu_driver, ofw_cpu_devclass, 0, 0);
168
169static int
170ofw_cpu_probe(device_t dev)
171{
172 const char *type = ofw_bus_get_type(dev);
173
174 if (strcmp(type, "cpu") != 0)
175 return (ENXIO);
176
177 device_set_desc(dev, "Open Firmware CPU");
178 return (0);
179}
180
181static int
182ofw_cpu_attach(device_t dev)
183{
184 struct ofw_cpu_softc *sc;
185 uint32_t cell;
186
187 sc = device_get_softc(dev);
188 OF_getprop(ofw_bus_get_node(dev), "reg", &cell, sizeof(cell));
189 sc->sc_cpu_pcpu = pcpu_find(cell);
190 OF_getprop(ofw_bus_get_node(dev), "clock-frequency", &cell, sizeof(cell));
191 sc->sc_nominal_mhz = cell / 1000000; /* convert to MHz */
192
193 bus_generic_probe(dev);
194 return (bus_generic_attach(dev));
195}
196
197static int
198ofw_cpu_read_ivar(device_t dev, device_t child, int index, uintptr_t *result)
--- 17 unchanged lines hidden ---