Deleted Added
full compact
ofw_cpu.c (278608) ofw_cpu.c (278609)
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

--- 10 unchanged lines hidden (view full) ---

19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
21 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
22 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include <sys/cdefs.h>
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

--- 10 unchanged lines hidden (view full) ---

19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
21 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
22 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include <sys/cdefs.h>
27__FBSDID("$FreeBSD: stable/10/sys/dev/ofw/ofw_cpu.c 278608 2015-02-12 00:25:33Z ian $");
27__FBSDID("$FreeBSD: stable/10/sys/dev/ofw/ofw_cpu.c 278609 2015-02-12 00:35:58Z ian $");
28
29#include <sys/param.h>
30#include <sys/systm.h>
31#include <sys/kernel.h>
32#include <sys/module.h>
33#include <sys/malloc.h>
34#include <sys/bus.h>
35#include <sys/cpu.h>

--- 129 unchanged lines hidden (view full) ---

165
166DRIVER_MODULE(ofw_cpu, cpulist, ofw_cpu_driver, ofw_cpu_devclass, 0, 0);
167
168static int
169ofw_cpu_probe(device_t dev)
170{
171 const char *type = ofw_bus_get_type(dev);
172
28
29#include <sys/param.h>
30#include <sys/systm.h>
31#include <sys/kernel.h>
32#include <sys/module.h>
33#include <sys/malloc.h>
34#include <sys/bus.h>
35#include <sys/cpu.h>

--- 129 unchanged lines hidden (view full) ---

165
166DRIVER_MODULE(ofw_cpu, cpulist, ofw_cpu_driver, ofw_cpu_devclass, 0, 0);
167
168static int
169ofw_cpu_probe(device_t dev)
170{
171 const char *type = ofw_bus_get_type(dev);
172
173 if (strcmp(type, "cpu") != 0)
173 if (type == NULL || strcmp(type, "cpu") != 0)
174 return (ENXIO);
175
176 device_set_desc(dev, "Open Firmware CPU");
177 return (0);
178}
179
180static int
181ofw_cpu_attach(device_t dev)
182{
183 struct ofw_cpu_softc *sc;
174 return (ENXIO);
175
176 device_set_desc(dev, "Open Firmware CPU");
177 return (0);
178}
179
180static int
181ofw_cpu_attach(device_t dev)
182{
183 struct ofw_cpu_softc *sc;
184 phandle_t node;
184 uint32_t cell;
185
186 sc = device_get_softc(dev);
185 uint32_t cell;
186
187 sc = device_get_softc(dev);
187 OF_getprop(ofw_bus_get_node(dev), "reg", &cell, sizeof(cell));
188 node = ofw_bus_get_node(dev);
189 if (OF_getencprop(node, "reg", &cell, sizeof(cell)) < 0) {
190 cell = device_get_unit(dev);
191 device_printf(dev, "missing 'reg' property, using %u\n", cell);
192 }
188 sc->sc_cpu_pcpu = pcpu_find(cell);
193 sc->sc_cpu_pcpu = pcpu_find(cell);
189 OF_getprop(ofw_bus_get_node(dev), "clock-frequency", &cell, sizeof(cell));
194 if (OF_getencprop(node, "clock-frequency", &cell, sizeof(cell)) < 0) {
195 device_printf(dev, "missing 'clock-frequency' property\n");
196 return (ENXIO);
197 }
190 sc->sc_nominal_mhz = cell / 1000000; /* convert to MHz */
191
192 bus_generic_probe(dev);
193 return (bus_generic_attach(dev));
194}
195
196static int
197ofw_cpu_read_ivar(device_t dev, device_t child, int index, uintptr_t *result)

--- 17 unchanged lines hidden ---
198 sc->sc_nominal_mhz = cell / 1000000; /* convert to MHz */
199
200 bus_generic_probe(dev);
201 return (bus_generic_attach(dev));
202}
203
204static int
205ofw_cpu_read_ivar(device_t dev, device_t child, int index, uintptr_t *result)

--- 17 unchanged lines hidden ---