Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/ofw/ofw_cpu.c
Show First 20 Lines • Show All 185 Lines • ▼ Show 20 Lines | |||||
static int | static int | ||||
ofw_cpu_probe(device_t dev) | ofw_cpu_probe(device_t dev) | ||||
{ | { | ||||
const char *type = ofw_bus_get_type(dev); | const char *type = ofw_bus_get_type(dev); | ||||
if (type == NULL || strcmp(type, "cpu") != 0) | if (type == NULL || strcmp(type, "cpu") != 0) | ||||
return (ENXIO); | return (ENXIO); | ||||
/* Skip SMT CPUs, which we can't reasonably represent with this code */ | |||||
if (OF_hasprop(ofw_bus_get_node(dev), "ibm,ppc-interrupt-server#s")) | |||||
return (ENXIO); | |||||
device_set_desc(dev, "Open Firmware CPU"); | device_set_desc(dev, "Open Firmware CPU"); | ||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
ofw_cpu_attach(device_t dev) | ofw_cpu_attach(device_t dev) | ||||
{ | { | ||||
struct ofw_cpulist_softc *psc; | struct ofw_cpulist_softc *psc; | ||||
Show All 22 Lines | else if ((rv % 4) != 0) { | ||||
if (bootverbose) | if (bootverbose) | ||||
device_printf(dev, "Malformed reg property\n"); | device_printf(dev, "Malformed reg property\n"); | ||||
} else if ((rv / 4) != psc->sc_addr_cells) { | } else if ((rv / 4) != psc->sc_addr_cells) { | ||||
if (bootverbose) | if (bootverbose) | ||||
device_printf(dev, "Invalid reg size %u\n", rv); | device_printf(dev, "Invalid reg size %u\n", rv); | ||||
} else | } else | ||||
sc->sc_reg_valid = true; | sc->sc_reg_valid = true; | ||||
#ifdef __powerpc__ | |||||
/* | |||||
* On powerpc, "interrupt-servers" denotes a SMT CPU. Look for any | |||||
* thread on this CPU, and assign that. | |||||
*/ | |||||
if (OF_hasprop(node, "ibm,ppc-interrupt-server#s")) { | |||||
struct cpuref cpuref; | |||||
cell_t *servers; | |||||
int i, nservers, rv; | |||||
if ((nservers = OF_getencprop_alloc(node, | |||||
"ibm,ppc-interrupt-server#s", (void **)&servers)) < 0) | |||||
return (ENXIO); | |||||
nservers /= sizeof(cell_t); | |||||
for (i = 0; i < nservers; i++) { | |||||
for (rv = platform_smp_first_cpu(&cpuref); rv == 0; | |||||
rv = platform_smp_next_cpu(&cpuref)) { | |||||
if (cpuref.cr_hwref == servers[i]) { | |||||
sc->sc_cpu_pcpu = | |||||
pcpu_find(cpuref.cr_cpuid); | |||||
if (sc->sc_cpu_pcpu == NULL) { | |||||
OF_prop_free(servers); | |||||
return (ENXIO); | |||||
} | |||||
break; | |||||
} | |||||
} | |||||
if (rv != ENOENT) | |||||
break; | |||||
} | |||||
OF_prop_free(servers); | |||||
if (sc->sc_cpu_pcpu == NULL) { | |||||
device_printf(dev, "No CPU found for this device.\n"); | |||||
return (ENXIO); | |||||
} | |||||
} else | |||||
#endif | |||||
sc->sc_cpu_pcpu = pcpu_find(device_get_unit(dev)); | sc->sc_cpu_pcpu = pcpu_find(device_get_unit(dev)); | ||||
if (OF_getencprop(node, "clock-frequency", &cell, sizeof(cell)) < 0) { | if (OF_getencprop(node, "clock-frequency", &cell, sizeof(cell)) < 0) { | ||||
if (bootverbose) | if (bootverbose) | ||||
device_printf(dev, | device_printf(dev, | ||||
"missing 'clock-frequency' property\n"); | "missing 'clock-frequency' property\n"); | ||||
} else | } else | ||||
sc->sc_nominal_mhz = cell / 1000000; /* convert to MHz */ | sc->sc_nominal_mhz = cell / 1000000; /* convert to MHz */ | ||||
▲ Show 20 Lines • Show All 104 Lines • Show Last 20 Lines |