Deleted Added
sdiff udiff text old ( 277378 ) new ( 277491 )
full compact
1/*-
2 * Copyright (C) 2009 Nathan Whitehorn
3 * Copyright (C) 2015 The FreeBSD Foundation
4 * All rights reserved.
5 *
6 * Portions of this software were developed by Andrew Turner
7 * under sponsorship from the FreeBSD Foundation.
8 *

--- 15 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>
32__FBSDID("$FreeBSD: head/sys/dev/ofw/ofw_cpu.c 277378 2015-01-19 11:06:56Z andrew $");
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>

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

46
47static int ofw_cpulist_probe(device_t);
48static int ofw_cpulist_attach(device_t);
49static const struct ofw_bus_devinfo *ofw_cpulist_get_devinfo(device_t dev,
50 device_t child);
51
52static MALLOC_DEFINE(M_OFWCPU, "ofwcpu", "OFW CPU device information");
53
54static device_method_t ofw_cpulist_methods[] = {
55 /* Device interface */
56 DEVMETHOD(device_probe, ofw_cpulist_probe),
57 DEVMETHOD(device_attach, ofw_cpulist_attach),
58
59 /* Bus interface */
60 DEVMETHOD(bus_add_child, bus_generic_add_child),
61 DEVMETHOD(bus_child_pnpinfo_str, ofw_bus_gen_child_pnpinfo_str),

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

69 DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type),
70
71 DEVMETHOD_END
72};
73
74static driver_t ofw_cpulist_driver = {
75 "cpulist",
76 ofw_cpulist_methods,
77 0
78};
79
80static devclass_t ofw_cpulist_devclass;
81
82DRIVER_MODULE(ofw_cpulist, ofwbus, ofw_cpulist_driver, ofw_cpulist_devclass,
83 0, 0);
84
85static int

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

95 device_set_desc(dev, "Open Firmware CPU Group");
96
97 return (0);
98}
99
100static int
101ofw_cpulist_attach(device_t dev)
102{
103 phandle_t root, child;
104 device_t cdev;
105 struct ofw_bus_devinfo *dinfo;
106
107 root = ofw_bus_get_node(dev);
108
109 for (child = OF_child(root); child != 0; child = OF_peer(child)) {
110 dinfo = malloc(sizeof(*dinfo), M_OFWCPU, M_WAITOK | M_ZERO);
111
112 if (ofw_bus_gen_setup_devinfo(dinfo, child) != 0) {
113 free(dinfo, M_OFWCPU);
114 continue;
115 }
116 cdev = device_add_child(dev, NULL, -1);

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

136static int ofw_cpu_probe(device_t);
137static int ofw_cpu_attach(device_t);
138static int ofw_cpu_read_ivar(device_t dev, device_t child, int index,
139 uintptr_t *result);
140
141struct ofw_cpu_softc {
142 struct pcpu *sc_cpu_pcpu;
143 uint32_t sc_nominal_mhz;
144};
145
146static device_method_t ofw_cpu_methods[] = {
147 /* Device interface */
148 DEVMETHOD(device_probe, ofw_cpu_probe),
149 DEVMETHOD(device_attach, ofw_cpu_attach),
150
151 /* Bus interface */

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

180
181 device_set_desc(dev, "Open Firmware CPU");
182 return (0);
183}
184
185static int
186ofw_cpu_attach(device_t dev)
187{
188 struct ofw_cpu_softc *sc;
189 phandle_t node;
190 uint32_t cell;
191
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) {
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 */
205
206 bus_generic_probe(dev);

--- 25 unchanged lines hidden ---