1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-11 14:10:34 +00:00

Move the CPU newbus attachment to i386 legacy. The acpi_cpu device will

become just "cpu" and provide attachments in the !legacy case.

Tested by:	des
This commit is contained in:
Nate Lawson 2004-05-06 15:54:02 +00:00
parent 7f98247de2
commit 88d2c61ee8
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=129012
2 changed files with 71 additions and 71 deletions

View File

@ -41,7 +41,9 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <machine/bus.h>
#include <sys/pcpu.h>
#include <sys/rman.h>
#include <sys/smp.h>
#include "opt_mca.h"
#ifdef DEV_MCA
@ -143,7 +145,9 @@ legacy_probe(device_t dev)
static int
legacy_attach(device_t dev)
{
device_t child;
device_t child;
int i;
struct pcpu *pc;
/*
* First, let our child driver's identify any child devices that
@ -153,6 +157,21 @@ legacy_attach(device_t dev)
bus_generic_probe(dev);
bus_generic_attach(dev);
/* Attach CPU pseudo-driver. */
if (!devclass_get_device(devclass_find("cpu"), 0)) {
for (i = 0; i <= mp_maxid; i++)
if (!CPU_ABSENT(i)) {
pc = pcpu_find(i);
KASSERT(pc != NULL, ("pcpu_find failed"));
child = BUS_ADD_CHILD(dev, 0, "cpu", i);
if (child == NULL)
panic("legacy_attach cpu");
device_probe_and_attach(child);
pc->pc_device = child;
device_set_ivars(child, pc);
}
}
/*
* If we didn't see EISA or ISA on a pci bridge, create some
* connection points now so they show up "on motherboard".
@ -324,3 +343,54 @@ legacy_delete_resource(device_t dev, device_t child, int type, int rid)
resource_list_delete(rl, type, rid);
}
/*
* Legacy CPU attachment when ACPI is not available. Drivers like
* cpufreq(4) hang off this.
*/
static int cpu_read_ivar(device_t dev, device_t child, int index,
uintptr_t *result);
static device_method_t cpu_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, bus_generic_probe),
DEVMETHOD(device_attach, bus_generic_attach),
DEVMETHOD(device_detach, bus_generic_detach),
DEVMETHOD(device_shutdown, bus_generic_shutdown),
DEVMETHOD(device_suspend, bus_generic_suspend),
DEVMETHOD(device_resume, bus_generic_resume),
/* Bus interface */
DEVMETHOD(bus_read_ivar, cpu_read_ivar),
DEVMETHOD(bus_print_child, bus_generic_print_child),
DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
DEVMETHOD(bus_release_resource, bus_generic_release_resource),
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
{ 0, 0 }
};
static driver_t cpu_driver = {
"cpu",
cpu_methods,
1, /* no softc */
};
static devclass_t cpu_devclass;
DRIVER_MODULE(cpu, legacy, cpu_driver, cpu_devclass, 0, 0);
static int
cpu_read_ivar(device_t dev, device_t child, int index, uintptr_t *result)
{
struct pcpu *pc;
if (index != 0)
return (ENOENT);
pc = device_get_ivars(child);
if (pc == NULL)
return (ENOENT);
*result = (uintptr_t)pc;
return (0);
}

View File

@ -83,48 +83,6 @@ int smp_cpus = 1; /* how many cpu's running */
SYSCTL_INT(_kern_smp, OID_AUTO, cpus, CTLFLAG_RD, &smp_cpus, 0,
"Number of CPUs online");
#if !__sparc64__ && !__powerpc__
static void cpu_identify(driver_t *driver, device_t parent);
static device_t cpu_add_child(device_t bus, int order, const char *name,
int unit);
static device_method_t cpu_methods[] = {
/* Device interface */
DEVMETHOD(device_identify, cpu_identify),
DEVMETHOD(device_probe, bus_generic_probe),
DEVMETHOD(device_attach, bus_generic_attach),
DEVMETHOD(device_detach, bus_generic_detach),
DEVMETHOD(device_shutdown, bus_generic_shutdown),
DEVMETHOD(device_suspend, bus_generic_suspend),
DEVMETHOD(device_resume, bus_generic_resume),
/* Bus interface */
DEVMETHOD(bus_print_child, bus_generic_print_child),
DEVMETHOD(bus_add_child, cpu_add_child),
DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
DEVMETHOD(bus_release_resource, bus_generic_release_resource),
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
#ifdef notyet
DEVMETHOD(bus_set_resource, bus_generic_set_resource),
DEVMETHOD(bus_get_resource, bus_generic_get_resource),
DEVMETHOD(bus_delete_resource, bus_generic_delete_resource),
#endif
{ 0, 0 }
};
static driver_t cpu_driver = {
"cpu",
cpu_methods,
1, /* no softc */
};
static devclass_t cpu_devclass;
DRIVER_MODULE(cpu, nexus, cpu_driver, cpu_devclass, 0, 0);
#endif
#ifdef SMP
/* Enable forwarding of a signal to a process running on a different CPU */
static int forward_signal_enabled = 1;
@ -416,31 +374,3 @@ smp_rendezvous(void (* setup_func)(void *),
teardown_func(arg);
}
#endif /* SMP */
#if !__sparc64__ && !__powerpc__
static void
cpu_identify(driver_t *driver, device_t parent)
{
struct pcpu *pc;
int i;
/* Protect against multiple scans of the bus. */
if (!cold || device_find_child(parent, "cpu", 0) != NULL)
return;
for (i = 0; i <= mp_maxid; i++)
if (!CPU_ABSENT(i)) {
pc = pcpu_find(i);
KASSERT(pc != NULL, ("pcpu_find failed"));
pc->pc_device = BUS_ADD_CHILD(parent, 0, "cpu", i);
if (pc->pc_device == NULL)
panic("failed adding cpu child");
}
}
static device_t
cpu_add_child(device_t bus, int order, const char *name, int unit)
{
return (device_add_child_ordered(bus, order, name, unit));
}
#endif