summaryrefslogtreecommitdiffstats
path: root/sys/i386
diff options
context:
space:
mode:
authornjl <njl@FreeBSD.org>2005-02-04 05:36:40 +0000
committernjl <njl@FreeBSD.org>2005-02-04 05:36:40 +0000
commit8834727d3ed650002e8cc9e60d07ed1b9ad34d28 (patch)
tree3db2826220d228fdf8ec50446fb653a0e844641f /sys/i386
parent54a88fdbee07d09c2baebe29116e17810f21fb52 (diff)
downloadFreeBSD-src-8834727d3ed650002e8cc9e60d07ed1b9ad34d28.zip
FreeBSD-src-8834727d3ed650002e8cc9e60d07ed1b9ad34d28.tar.gz
Update the CPU attachments to return CPU_IVAR_PCPU as well as pass on
appropriate requests to any children.
Diffstat (limited to 'sys/i386')
-rw-r--r--sys/i386/i386/legacy.c92
1 files changed, 65 insertions, 27 deletions
diff --git a/sys/i386/i386/legacy.c b/sys/i386/i386/legacy.c
index af7f157..2112d77 100644
--- a/sys/i386/i386/legacy.c
+++ b/sys/i386/i386/legacy.c
@@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
+#include <sys/cpu.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/module.h>
@@ -137,32 +138,25 @@ legacy_attach(device_t dev)
{
device_t child;
int i;
- struct pcpu *pc;
+ /* First, attach the CPU pseudo-driver. */
+ for (i = 0; i <= mp_maxid; i++)
+ if (!CPU_ABSENT(i)) {
+ child = BUS_ADD_CHILD(dev, 0, "cpu", i);
+ if (child == NULL)
+ panic("legacy_attach cpu");
+ device_probe_and_attach(child);
+ }
+
+#ifndef PC98
/*
- * First, let our child driver's identify any child devices that
+ * Second, let our child driver's identify any child devices that
* they can find. Once that is done attach any devices that we
* found.
*/
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);
- }
- }
-
-#ifndef PC98
/*
* If we didn't see EISA or ISA on a pci bridge, create some
* connection points now so they show up "on motherboard".
@@ -265,6 +259,14 @@ legacy_write_ivar(device_t dev, device_t child, int which, uintptr_t value)
*/
static int cpu_read_ivar(device_t dev, device_t child, int index,
uintptr_t *result);
+static device_t cpu_add_child(device_t bus, int order, const char *name,
+ int unit);
+static struct resource_list *cpu_get_rlist(device_t dev, device_t child);
+
+struct cpu_device {
+ struct resource_list cd_rl;
+ struct pcpu *cd_pcpu;
+};
static device_method_t cpu_methods[] = {
/* Device interface */
@@ -276,10 +278,15 @@ static device_method_t cpu_methods[] = {
DEVMETHOD(device_resume, bus_generic_resume),
/* Bus interface */
+ DEVMETHOD(bus_add_child, cpu_add_child),
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_get_resource_list, cpu_get_rlist),
+ DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource),
+ DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource),
+ DEVMETHOD(bus_alloc_resource, bus_generic_rl_alloc_resource),
+ DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource),
+ DEVMETHOD(bus_driver_added, bus_generic_driver_added),
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
@@ -293,19 +300,50 @@ static driver_t cpu_driver = {
cpu_methods,
1, /* no softc */
};
-static devclass_t cpu_devclass;
+devclass_t cpu_devclass;
DRIVER_MODULE(cpu, legacy, cpu_driver, cpu_devclass, 0, 0);
+static device_t
+cpu_add_child(device_t bus, int order, const char *name, int unit)
+{
+ struct cpu_device *cd;
+ device_t child;
+ struct pcpu *pc;
+
+ if ((cd = malloc(sizeof(*cd), M_DEVBUF, M_NOWAIT | M_ZERO)) == NULL)
+ return (NULL);
+
+ resource_list_init(&cd->cd_rl);
+ pc = pcpu_find(unit);
+ KASSERT(pc != NULL, ("pcpu_find failed"));
+ cd->cd_pcpu = pc;
+
+ child = device_add_child_ordered(bus, order, name, unit);
+ if (child != NULL) {
+ pc->pc_device = child;
+ device_set_ivars(child, cd);
+ } else
+ free(cd, M_DEVBUF);
+ return (child);
+}
+
+static struct resource_list *
+cpu_get_rlist(device_t dev, device_t child)
+{
+ struct cpu_device *cpdev;
+
+ cpdev = device_get_ivars(child);
+ return (&cpdev->cd_rl);
+}
+
static int
cpu_read_ivar(device_t dev, device_t child, int index, uintptr_t *result)
{
- struct pcpu *pc;
+ struct cpu_device *cpdev;
- if (index != 0)
- return (ENOENT);
- pc = device_get_ivars(child);
- if (pc == NULL)
+ if (index != CPU_IVAR_PCPU)
return (ENOENT);
- *result = (uintptr_t)pc;
+ cpdev = device_get_ivars(dev);
+ *result = (uintptr_t)cpdev->cd_pcpu;
return (0);
}
OpenPOWER on IntegriCloud