summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2000-08-31 23:11:35 +0000
committerpeter <peter@FreeBSD.org>2000-08-31 23:11:35 +0000
commiteff5d582a01ba40ed735f77e3f58fec8f42d6604 (patch)
tree548c1d86f729edd11b788279a7df503e5c653b47 /sys
parentbfbd66dc36e695d7ff6dc73bc53b36eba1d4101b (diff)
downloadFreeBSD-src-eff5d582a01ba40ed735f77e3f58fec8f42d6604.zip
FreeBSD-src-eff5d582a01ba40ed735f77e3f58fec8f42d6604.tar.gz
Take a shot at fixing multiple pci busses on i386.
pcib_set_bus() cannot be used on the new child because it is meant to be used on the *pci* device (it looks at the parent internally) not the pcib being added. Bite the bullet and use ivars for the bus number to avoid any doubts about whether the softc is consistant between probe and attach. This should not break the Alpha code.
Diffstat (limited to 'sys')
-rw-r--r--sys/amd64/pci/pci_bus.c60
-rw-r--r--sys/amd64/pci/pci_cfgreg.c60
-rw-r--r--sys/i386/isa/pcibus.c60
-rw-r--r--sys/i386/pci/pci_bus.c60
-rw-r--r--sys/i386/pci/pci_cfgreg.c60
-rw-r--r--sys/i386/pci/pci_pir.c60
-rw-r--r--sys/pci/pcisupport.c17
7 files changed, 311 insertions, 66 deletions
diff --git a/sys/amd64/pci/pci_bus.c b/sys/amd64/pci/pci_bus.c
index ceff6a5..41e2226 100644
--- a/sys/amd64/pci/pci_bus.c
+++ b/sys/amd64/pci/pci_bus.c
@@ -32,6 +32,7 @@
#include <sys/bus.h>
#include <sys/kernel.h>
#include <sys/module.h>
+#include <sys/malloc.h>
#include <pci/pcivar.h>
#include <pci/pcireg.h>
@@ -107,7 +108,7 @@ pcibios_cfgread(int bus, int slot, int func, int reg, int bytes)
{
struct bios_regs args;
u_int mask;
-
+
switch(bytes) {
case 1:
args.eax = PCIBIOS_READ_CONFIG_BYTE;
@@ -135,7 +136,7 @@ static void
pcibios_cfgwrite(int bus, int slot, int func, int reg, int data, int bytes)
{
struct bios_regs args;
-
+
switch(bytes) {
case 1:
args.eax = PCIBIOS_WRITE_CONFIG_BYTE;
@@ -572,6 +573,8 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
int found = 0;
int pcifunchigh;
int found824xx = 0;
+ device_t child;
+ int *ivar;
if (pci_cfgopen() == 0)
return;
@@ -591,7 +594,6 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
*/
u_int32_t id;
u_int8_t class, subclass, busnum;
- device_t child;
const char *s;
id = nexus_pcib_read_config(0, bus, slot, func,
@@ -614,6 +616,14 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
child = BUS_ADD_CHILD(parent, 100,
"pcib", busnum);
device_set_desc(child, s);
+
+ ivar = malloc(sizeof ivar[0], M_DEVBUF,
+ M_NOWAIT);
+ if (ivar == NULL)
+ panic("out of memory");
+ device_set_ivars(child, ivar);
+ ivar[0] = busnum;
+
found = 1;
if (id == 0x12258086)
found824xx = 1;
@@ -634,36 +644,65 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
if (bootverbose)
printf(
"nexus_pcib_identify: no bridge found, adding pcib0 anyway\n");
- BUS_ADD_CHILD(parent, 100, "pcib", 0);
+ child = BUS_ADD_CHILD(parent, 100, "pcib", 0);
+ ivar = malloc(sizeof ivar[0], M_DEVBUF, M_NOWAIT);
+ if (ivar == NULL)
+ panic("out of memory");
+ device_set_ivars(child, ivar);
+ ivar[0] = 0;
}
}
static int
nexus_pcib_probe(device_t dev)
{
- if (pci_cfgopen() != 0) {
- device_add_child(dev, "pci", device_get_unit(dev));
+
+ if (pci_cfgopen() != 0)
return 0;
- }
+
return ENXIO;
}
static int
-nexus_pcib_read_ivar(device_t dev, device_t child, int which, u_long *result)
+nexus_pcib_attach(device_t dev)
+{
+ device_t child;
+
+ child = device_add_child(dev, "pci", device_get_unit(dev));
+
+ return bus_generic_attach(dev);
+}
+
+static int
+nexus_pcib_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
{
+
+ switch (which) {
+ case PCIB_IVAR_BUS:
+ *result = *(int*) device_get_ivars(dev);
+ return 0;
+ }
+ return ENOENT;
+}
+
+static int
+nexus_pcib_write_ivar(device_t dev, device_t child, int which, uintptr_t value)
+{
+
switch (which) {
case PCIB_IVAR_BUS:
- *result = 0;
+ *(int*) device_get_ivars(dev) = value;
return 0;
}
return ENOENT;
}
+
static device_method_t nexus_pcib_methods[] = {
/* Device interface */
DEVMETHOD(device_identify, nexus_pcib_identify),
DEVMETHOD(device_probe, nexus_pcib_probe),
- DEVMETHOD(device_attach, bus_generic_attach),
+ DEVMETHOD(device_attach, nexus_pcib_attach),
DEVMETHOD(device_shutdown, bus_generic_shutdown),
DEVMETHOD(device_suspend, bus_generic_suspend),
DEVMETHOD(device_resume, bus_generic_resume),
@@ -671,6 +710,7 @@ static device_method_t nexus_pcib_methods[] = {
/* Bus interface */
DEVMETHOD(bus_print_child, bus_generic_print_child),
DEVMETHOD(bus_read_ivar, nexus_pcib_read_ivar),
+ DEVMETHOD(bus_write_ivar, nexus_pcib_write_ivar),
DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
DEVMETHOD(bus_release_resource, bus_generic_release_resource),
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
diff --git a/sys/amd64/pci/pci_cfgreg.c b/sys/amd64/pci/pci_cfgreg.c
index ceff6a5..41e2226 100644
--- a/sys/amd64/pci/pci_cfgreg.c
+++ b/sys/amd64/pci/pci_cfgreg.c
@@ -32,6 +32,7 @@
#include <sys/bus.h>
#include <sys/kernel.h>
#include <sys/module.h>
+#include <sys/malloc.h>
#include <pci/pcivar.h>
#include <pci/pcireg.h>
@@ -107,7 +108,7 @@ pcibios_cfgread(int bus, int slot, int func, int reg, int bytes)
{
struct bios_regs args;
u_int mask;
-
+
switch(bytes) {
case 1:
args.eax = PCIBIOS_READ_CONFIG_BYTE;
@@ -135,7 +136,7 @@ static void
pcibios_cfgwrite(int bus, int slot, int func, int reg, int data, int bytes)
{
struct bios_regs args;
-
+
switch(bytes) {
case 1:
args.eax = PCIBIOS_WRITE_CONFIG_BYTE;
@@ -572,6 +573,8 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
int found = 0;
int pcifunchigh;
int found824xx = 0;
+ device_t child;
+ int *ivar;
if (pci_cfgopen() == 0)
return;
@@ -591,7 +594,6 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
*/
u_int32_t id;
u_int8_t class, subclass, busnum;
- device_t child;
const char *s;
id = nexus_pcib_read_config(0, bus, slot, func,
@@ -614,6 +616,14 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
child = BUS_ADD_CHILD(parent, 100,
"pcib", busnum);
device_set_desc(child, s);
+
+ ivar = malloc(sizeof ivar[0], M_DEVBUF,
+ M_NOWAIT);
+ if (ivar == NULL)
+ panic("out of memory");
+ device_set_ivars(child, ivar);
+ ivar[0] = busnum;
+
found = 1;
if (id == 0x12258086)
found824xx = 1;
@@ -634,36 +644,65 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
if (bootverbose)
printf(
"nexus_pcib_identify: no bridge found, adding pcib0 anyway\n");
- BUS_ADD_CHILD(parent, 100, "pcib", 0);
+ child = BUS_ADD_CHILD(parent, 100, "pcib", 0);
+ ivar = malloc(sizeof ivar[0], M_DEVBUF, M_NOWAIT);
+ if (ivar == NULL)
+ panic("out of memory");
+ device_set_ivars(child, ivar);
+ ivar[0] = 0;
}
}
static int
nexus_pcib_probe(device_t dev)
{
- if (pci_cfgopen() != 0) {
- device_add_child(dev, "pci", device_get_unit(dev));
+
+ if (pci_cfgopen() != 0)
return 0;
- }
+
return ENXIO;
}
static int
-nexus_pcib_read_ivar(device_t dev, device_t child, int which, u_long *result)
+nexus_pcib_attach(device_t dev)
+{
+ device_t child;
+
+ child = device_add_child(dev, "pci", device_get_unit(dev));
+
+ return bus_generic_attach(dev);
+}
+
+static int
+nexus_pcib_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
{
+
+ switch (which) {
+ case PCIB_IVAR_BUS:
+ *result = *(int*) device_get_ivars(dev);
+ return 0;
+ }
+ return ENOENT;
+}
+
+static int
+nexus_pcib_write_ivar(device_t dev, device_t child, int which, uintptr_t value)
+{
+
switch (which) {
case PCIB_IVAR_BUS:
- *result = 0;
+ *(int*) device_get_ivars(dev) = value;
return 0;
}
return ENOENT;
}
+
static device_method_t nexus_pcib_methods[] = {
/* Device interface */
DEVMETHOD(device_identify, nexus_pcib_identify),
DEVMETHOD(device_probe, nexus_pcib_probe),
- DEVMETHOD(device_attach, bus_generic_attach),
+ DEVMETHOD(device_attach, nexus_pcib_attach),
DEVMETHOD(device_shutdown, bus_generic_shutdown),
DEVMETHOD(device_suspend, bus_generic_suspend),
DEVMETHOD(device_resume, bus_generic_resume),
@@ -671,6 +710,7 @@ static device_method_t nexus_pcib_methods[] = {
/* Bus interface */
DEVMETHOD(bus_print_child, bus_generic_print_child),
DEVMETHOD(bus_read_ivar, nexus_pcib_read_ivar),
+ DEVMETHOD(bus_write_ivar, nexus_pcib_write_ivar),
DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
DEVMETHOD(bus_release_resource, bus_generic_release_resource),
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
diff --git a/sys/i386/isa/pcibus.c b/sys/i386/isa/pcibus.c
index ceff6a5..41e2226 100644
--- a/sys/i386/isa/pcibus.c
+++ b/sys/i386/isa/pcibus.c
@@ -32,6 +32,7 @@
#include <sys/bus.h>
#include <sys/kernel.h>
#include <sys/module.h>
+#include <sys/malloc.h>
#include <pci/pcivar.h>
#include <pci/pcireg.h>
@@ -107,7 +108,7 @@ pcibios_cfgread(int bus, int slot, int func, int reg, int bytes)
{
struct bios_regs args;
u_int mask;
-
+
switch(bytes) {
case 1:
args.eax = PCIBIOS_READ_CONFIG_BYTE;
@@ -135,7 +136,7 @@ static void
pcibios_cfgwrite(int bus, int slot, int func, int reg, int data, int bytes)
{
struct bios_regs args;
-
+
switch(bytes) {
case 1:
args.eax = PCIBIOS_WRITE_CONFIG_BYTE;
@@ -572,6 +573,8 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
int found = 0;
int pcifunchigh;
int found824xx = 0;
+ device_t child;
+ int *ivar;
if (pci_cfgopen() == 0)
return;
@@ -591,7 +594,6 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
*/
u_int32_t id;
u_int8_t class, subclass, busnum;
- device_t child;
const char *s;
id = nexus_pcib_read_config(0, bus, slot, func,
@@ -614,6 +616,14 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
child = BUS_ADD_CHILD(parent, 100,
"pcib", busnum);
device_set_desc(child, s);
+
+ ivar = malloc(sizeof ivar[0], M_DEVBUF,
+ M_NOWAIT);
+ if (ivar == NULL)
+ panic("out of memory");
+ device_set_ivars(child, ivar);
+ ivar[0] = busnum;
+
found = 1;
if (id == 0x12258086)
found824xx = 1;
@@ -634,36 +644,65 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
if (bootverbose)
printf(
"nexus_pcib_identify: no bridge found, adding pcib0 anyway\n");
- BUS_ADD_CHILD(parent, 100, "pcib", 0);
+ child = BUS_ADD_CHILD(parent, 100, "pcib", 0);
+ ivar = malloc(sizeof ivar[0], M_DEVBUF, M_NOWAIT);
+ if (ivar == NULL)
+ panic("out of memory");
+ device_set_ivars(child, ivar);
+ ivar[0] = 0;
}
}
static int
nexus_pcib_probe(device_t dev)
{
- if (pci_cfgopen() != 0) {
- device_add_child(dev, "pci", device_get_unit(dev));
+
+ if (pci_cfgopen() != 0)
return 0;
- }
+
return ENXIO;
}
static int
-nexus_pcib_read_ivar(device_t dev, device_t child, int which, u_long *result)
+nexus_pcib_attach(device_t dev)
+{
+ device_t child;
+
+ child = device_add_child(dev, "pci", device_get_unit(dev));
+
+ return bus_generic_attach(dev);
+}
+
+static int
+nexus_pcib_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
{
+
+ switch (which) {
+ case PCIB_IVAR_BUS:
+ *result = *(int*) device_get_ivars(dev);
+ return 0;
+ }
+ return ENOENT;
+}
+
+static int
+nexus_pcib_write_ivar(device_t dev, device_t child, int which, uintptr_t value)
+{
+
switch (which) {
case PCIB_IVAR_BUS:
- *result = 0;
+ *(int*) device_get_ivars(dev) = value;
return 0;
}
return ENOENT;
}
+
static device_method_t nexus_pcib_methods[] = {
/* Device interface */
DEVMETHOD(device_identify, nexus_pcib_identify),
DEVMETHOD(device_probe, nexus_pcib_probe),
- DEVMETHOD(device_attach, bus_generic_attach),
+ DEVMETHOD(device_attach, nexus_pcib_attach),
DEVMETHOD(device_shutdown, bus_generic_shutdown),
DEVMETHOD(device_suspend, bus_generic_suspend),
DEVMETHOD(device_resume, bus_generic_resume),
@@ -671,6 +710,7 @@ static device_method_t nexus_pcib_methods[] = {
/* Bus interface */
DEVMETHOD(bus_print_child, bus_generic_print_child),
DEVMETHOD(bus_read_ivar, nexus_pcib_read_ivar),
+ DEVMETHOD(bus_write_ivar, nexus_pcib_write_ivar),
DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
DEVMETHOD(bus_release_resource, bus_generic_release_resource),
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
diff --git a/sys/i386/pci/pci_bus.c b/sys/i386/pci/pci_bus.c
index ceff6a5..41e2226 100644
--- a/sys/i386/pci/pci_bus.c
+++ b/sys/i386/pci/pci_bus.c
@@ -32,6 +32,7 @@
#include <sys/bus.h>
#include <sys/kernel.h>
#include <sys/module.h>
+#include <sys/malloc.h>
#include <pci/pcivar.h>
#include <pci/pcireg.h>
@@ -107,7 +108,7 @@ pcibios_cfgread(int bus, int slot, int func, int reg, int bytes)
{
struct bios_regs args;
u_int mask;
-
+
switch(bytes) {
case 1:
args.eax = PCIBIOS_READ_CONFIG_BYTE;
@@ -135,7 +136,7 @@ static void
pcibios_cfgwrite(int bus, int slot, int func, int reg, int data, int bytes)
{
struct bios_regs args;
-
+
switch(bytes) {
case 1:
args.eax = PCIBIOS_WRITE_CONFIG_BYTE;
@@ -572,6 +573,8 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
int found = 0;
int pcifunchigh;
int found824xx = 0;
+ device_t child;
+ int *ivar;
if (pci_cfgopen() == 0)
return;
@@ -591,7 +594,6 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
*/
u_int32_t id;
u_int8_t class, subclass, busnum;
- device_t child;
const char *s;
id = nexus_pcib_read_config(0, bus, slot, func,
@@ -614,6 +616,14 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
child = BUS_ADD_CHILD(parent, 100,
"pcib", busnum);
device_set_desc(child, s);
+
+ ivar = malloc(sizeof ivar[0], M_DEVBUF,
+ M_NOWAIT);
+ if (ivar == NULL)
+ panic("out of memory");
+ device_set_ivars(child, ivar);
+ ivar[0] = busnum;
+
found = 1;
if (id == 0x12258086)
found824xx = 1;
@@ -634,36 +644,65 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
if (bootverbose)
printf(
"nexus_pcib_identify: no bridge found, adding pcib0 anyway\n");
- BUS_ADD_CHILD(parent, 100, "pcib", 0);
+ child = BUS_ADD_CHILD(parent, 100, "pcib", 0);
+ ivar = malloc(sizeof ivar[0], M_DEVBUF, M_NOWAIT);
+ if (ivar == NULL)
+ panic("out of memory");
+ device_set_ivars(child, ivar);
+ ivar[0] = 0;
}
}
static int
nexus_pcib_probe(device_t dev)
{
- if (pci_cfgopen() != 0) {
- device_add_child(dev, "pci", device_get_unit(dev));
+
+ if (pci_cfgopen() != 0)
return 0;
- }
+
return ENXIO;
}
static int
-nexus_pcib_read_ivar(device_t dev, device_t child, int which, u_long *result)
+nexus_pcib_attach(device_t dev)
+{
+ device_t child;
+
+ child = device_add_child(dev, "pci", device_get_unit(dev));
+
+ return bus_generic_attach(dev);
+}
+
+static int
+nexus_pcib_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
{
+
+ switch (which) {
+ case PCIB_IVAR_BUS:
+ *result = *(int*) device_get_ivars(dev);
+ return 0;
+ }
+ return ENOENT;
+}
+
+static int
+nexus_pcib_write_ivar(device_t dev, device_t child, int which, uintptr_t value)
+{
+
switch (which) {
case PCIB_IVAR_BUS:
- *result = 0;
+ *(int*) device_get_ivars(dev) = value;
return 0;
}
return ENOENT;
}
+
static device_method_t nexus_pcib_methods[] = {
/* Device interface */
DEVMETHOD(device_identify, nexus_pcib_identify),
DEVMETHOD(device_probe, nexus_pcib_probe),
- DEVMETHOD(device_attach, bus_generic_attach),
+ DEVMETHOD(device_attach, nexus_pcib_attach),
DEVMETHOD(device_shutdown, bus_generic_shutdown),
DEVMETHOD(device_suspend, bus_generic_suspend),
DEVMETHOD(device_resume, bus_generic_resume),
@@ -671,6 +710,7 @@ static device_method_t nexus_pcib_methods[] = {
/* Bus interface */
DEVMETHOD(bus_print_child, bus_generic_print_child),
DEVMETHOD(bus_read_ivar, nexus_pcib_read_ivar),
+ DEVMETHOD(bus_write_ivar, nexus_pcib_write_ivar),
DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
DEVMETHOD(bus_release_resource, bus_generic_release_resource),
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
diff --git a/sys/i386/pci/pci_cfgreg.c b/sys/i386/pci/pci_cfgreg.c
index ceff6a5..41e2226 100644
--- a/sys/i386/pci/pci_cfgreg.c
+++ b/sys/i386/pci/pci_cfgreg.c
@@ -32,6 +32,7 @@
#include <sys/bus.h>
#include <sys/kernel.h>
#include <sys/module.h>
+#include <sys/malloc.h>
#include <pci/pcivar.h>
#include <pci/pcireg.h>
@@ -107,7 +108,7 @@ pcibios_cfgread(int bus, int slot, int func, int reg, int bytes)
{
struct bios_regs args;
u_int mask;
-
+
switch(bytes) {
case 1:
args.eax = PCIBIOS_READ_CONFIG_BYTE;
@@ -135,7 +136,7 @@ static void
pcibios_cfgwrite(int bus, int slot, int func, int reg, int data, int bytes)
{
struct bios_regs args;
-
+
switch(bytes) {
case 1:
args.eax = PCIBIOS_WRITE_CONFIG_BYTE;
@@ -572,6 +573,8 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
int found = 0;
int pcifunchigh;
int found824xx = 0;
+ device_t child;
+ int *ivar;
if (pci_cfgopen() == 0)
return;
@@ -591,7 +594,6 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
*/
u_int32_t id;
u_int8_t class, subclass, busnum;
- device_t child;
const char *s;
id = nexus_pcib_read_config(0, bus, slot, func,
@@ -614,6 +616,14 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
child = BUS_ADD_CHILD(parent, 100,
"pcib", busnum);
device_set_desc(child, s);
+
+ ivar = malloc(sizeof ivar[0], M_DEVBUF,
+ M_NOWAIT);
+ if (ivar == NULL)
+ panic("out of memory");
+ device_set_ivars(child, ivar);
+ ivar[0] = busnum;
+
found = 1;
if (id == 0x12258086)
found824xx = 1;
@@ -634,36 +644,65 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
if (bootverbose)
printf(
"nexus_pcib_identify: no bridge found, adding pcib0 anyway\n");
- BUS_ADD_CHILD(parent, 100, "pcib", 0);
+ child = BUS_ADD_CHILD(parent, 100, "pcib", 0);
+ ivar = malloc(sizeof ivar[0], M_DEVBUF, M_NOWAIT);
+ if (ivar == NULL)
+ panic("out of memory");
+ device_set_ivars(child, ivar);
+ ivar[0] = 0;
}
}
static int
nexus_pcib_probe(device_t dev)
{
- if (pci_cfgopen() != 0) {
- device_add_child(dev, "pci", device_get_unit(dev));
+
+ if (pci_cfgopen() != 0)
return 0;
- }
+
return ENXIO;
}
static int
-nexus_pcib_read_ivar(device_t dev, device_t child, int which, u_long *result)
+nexus_pcib_attach(device_t dev)
+{
+ device_t child;
+
+ child = device_add_child(dev, "pci", device_get_unit(dev));
+
+ return bus_generic_attach(dev);
+}
+
+static int
+nexus_pcib_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
{
+
+ switch (which) {
+ case PCIB_IVAR_BUS:
+ *result = *(int*) device_get_ivars(dev);
+ return 0;
+ }
+ return ENOENT;
+}
+
+static int
+nexus_pcib_write_ivar(device_t dev, device_t child, int which, uintptr_t value)
+{
+
switch (which) {
case PCIB_IVAR_BUS:
- *result = 0;
+ *(int*) device_get_ivars(dev) = value;
return 0;
}
return ENOENT;
}
+
static device_method_t nexus_pcib_methods[] = {
/* Device interface */
DEVMETHOD(device_identify, nexus_pcib_identify),
DEVMETHOD(device_probe, nexus_pcib_probe),
- DEVMETHOD(device_attach, bus_generic_attach),
+ DEVMETHOD(device_attach, nexus_pcib_attach),
DEVMETHOD(device_shutdown, bus_generic_shutdown),
DEVMETHOD(device_suspend, bus_generic_suspend),
DEVMETHOD(device_resume, bus_generic_resume),
@@ -671,6 +710,7 @@ static device_method_t nexus_pcib_methods[] = {
/* Bus interface */
DEVMETHOD(bus_print_child, bus_generic_print_child),
DEVMETHOD(bus_read_ivar, nexus_pcib_read_ivar),
+ DEVMETHOD(bus_write_ivar, nexus_pcib_write_ivar),
DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
DEVMETHOD(bus_release_resource, bus_generic_release_resource),
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
diff --git a/sys/i386/pci/pci_pir.c b/sys/i386/pci/pci_pir.c
index ceff6a5..41e2226 100644
--- a/sys/i386/pci/pci_pir.c
+++ b/sys/i386/pci/pci_pir.c
@@ -32,6 +32,7 @@
#include <sys/bus.h>
#include <sys/kernel.h>
#include <sys/module.h>
+#include <sys/malloc.h>
#include <pci/pcivar.h>
#include <pci/pcireg.h>
@@ -107,7 +108,7 @@ pcibios_cfgread(int bus, int slot, int func, int reg, int bytes)
{
struct bios_regs args;
u_int mask;
-
+
switch(bytes) {
case 1:
args.eax = PCIBIOS_READ_CONFIG_BYTE;
@@ -135,7 +136,7 @@ static void
pcibios_cfgwrite(int bus, int slot, int func, int reg, int data, int bytes)
{
struct bios_regs args;
-
+
switch(bytes) {
case 1:
args.eax = PCIBIOS_WRITE_CONFIG_BYTE;
@@ -572,6 +573,8 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
int found = 0;
int pcifunchigh;
int found824xx = 0;
+ device_t child;
+ int *ivar;
if (pci_cfgopen() == 0)
return;
@@ -591,7 +594,6 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
*/
u_int32_t id;
u_int8_t class, subclass, busnum;
- device_t child;
const char *s;
id = nexus_pcib_read_config(0, bus, slot, func,
@@ -614,6 +616,14 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
child = BUS_ADD_CHILD(parent, 100,
"pcib", busnum);
device_set_desc(child, s);
+
+ ivar = malloc(sizeof ivar[0], M_DEVBUF,
+ M_NOWAIT);
+ if (ivar == NULL)
+ panic("out of memory");
+ device_set_ivars(child, ivar);
+ ivar[0] = busnum;
+
found = 1;
if (id == 0x12258086)
found824xx = 1;
@@ -634,36 +644,65 @@ nexus_pcib_identify(driver_t *driver, device_t parent)
if (bootverbose)
printf(
"nexus_pcib_identify: no bridge found, adding pcib0 anyway\n");
- BUS_ADD_CHILD(parent, 100, "pcib", 0);
+ child = BUS_ADD_CHILD(parent, 100, "pcib", 0);
+ ivar = malloc(sizeof ivar[0], M_DEVBUF, M_NOWAIT);
+ if (ivar == NULL)
+ panic("out of memory");
+ device_set_ivars(child, ivar);
+ ivar[0] = 0;
}
}
static int
nexus_pcib_probe(device_t dev)
{
- if (pci_cfgopen() != 0) {
- device_add_child(dev, "pci", device_get_unit(dev));
+
+ if (pci_cfgopen() != 0)
return 0;
- }
+
return ENXIO;
}
static int
-nexus_pcib_read_ivar(device_t dev, device_t child, int which, u_long *result)
+nexus_pcib_attach(device_t dev)
+{
+ device_t child;
+
+ child = device_add_child(dev, "pci", device_get_unit(dev));
+
+ return bus_generic_attach(dev);
+}
+
+static int
+nexus_pcib_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
{
+
+ switch (which) {
+ case PCIB_IVAR_BUS:
+ *result = *(int*) device_get_ivars(dev);
+ return 0;
+ }
+ return ENOENT;
+}
+
+static int
+nexus_pcib_write_ivar(device_t dev, device_t child, int which, uintptr_t value)
+{
+
switch (which) {
case PCIB_IVAR_BUS:
- *result = 0;
+ *(int*) device_get_ivars(dev) = value;
return 0;
}
return ENOENT;
}
+
static device_method_t nexus_pcib_methods[] = {
/* Device interface */
DEVMETHOD(device_identify, nexus_pcib_identify),
DEVMETHOD(device_probe, nexus_pcib_probe),
- DEVMETHOD(device_attach, bus_generic_attach),
+ DEVMETHOD(device_attach, nexus_pcib_attach),
DEVMETHOD(device_shutdown, bus_generic_shutdown),
DEVMETHOD(device_suspend, bus_generic_suspend),
DEVMETHOD(device_resume, bus_generic_resume),
@@ -671,6 +710,7 @@ static device_method_t nexus_pcib_methods[] = {
/* Bus interface */
DEVMETHOD(bus_print_child, bus_generic_print_child),
DEVMETHOD(bus_read_ivar, nexus_pcib_read_ivar),
+ DEVMETHOD(bus_write_ivar, nexus_pcib_write_ivar),
DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
DEVMETHOD(bus_release_resource, bus_generic_release_resource),
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
diff --git a/sys/pci/pcisupport.c b/sys/pci/pcisupport.c
index 374a168..0595dce 100644
--- a/sys/pci/pcisupport.c
+++ b/sys/pci/pcisupport.c
@@ -750,7 +750,7 @@ static int pcib_probe(device_t dev)
desc = pcib_match(dev);
if (desc) {
device_set_desc_copy(dev, desc);
- return 0;
+ return -10000;
}
return ENXIO;
@@ -759,14 +759,19 @@ static int pcib_probe(device_t dev)
static int pcib_attach(device_t dev)
{
u_int8_t secondary;
+ device_t child;
+ int *ivar;
chipset_attach(dev, device_get_unit(dev));
secondary = pci_get_secondarybus(dev);
if (secondary) {
- device_t child;
child = device_add_child(dev, "pci", -1);
- pcib_set_bus(child, secondary);
+ ivar = malloc(sizeof ivar[0], M_DEVBUF /* XXX */, M_NOWAIT);
+ if (ivar == NULL)
+ panic("out of memory");
+ device_set_ivars(child, ivar);
+ ivar[0] = secondary;
return bus_generic_attach(dev);
} else
return 0;
@@ -777,7 +782,7 @@ pcib_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
{
switch (which) {
case PCIB_IVAR_BUS:
- *result = *(int*) device_get_softc(dev);
+ *result = *(int*) device_get_ivars(dev);
return 0;
}
return ENOENT;
@@ -788,7 +793,7 @@ pcib_write_ivar(device_t dev, device_t child, int which, uintptr_t value)
{
switch (which) {
case PCIB_IVAR_BUS:
- *(int*) device_get_softc(dev) = value;
+ *(int*) device_get_ivars(dev) = value;
return 0;
}
return ENOENT;
@@ -854,7 +859,7 @@ static device_method_t pcib_methods[] = {
static driver_t pcib_driver = {
"pcib",
pcib_methods,
- sizeof(int),
+ 1,
};
static devclass_t pcib_devclass;
OpenPOWER on IntegriCloud