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.
This commit is contained in:
parent
bfbd66dc36
commit
eff5d582a0
@ -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>
|
||||
@ -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 = 0;
|
||||
*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:
|
||||
*(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),
|
||||
|
@ -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>
|
||||
@ -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 = 0;
|
||||
*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:
|
||||
*(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),
|
||||
|
@ -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>
|
||||
@ -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 = 0;
|
||||
*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:
|
||||
*(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),
|
||||
|
@ -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>
|
||||
@ -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 = 0;
|
||||
*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:
|
||||
*(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),
|
||||
|
@ -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>
|
||||
@ -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 = 0;
|
||||
*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:
|
||||
*(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),
|
||||
|
@ -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>
|
||||
@ -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 = 0;
|
||||
*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:
|
||||
*(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),
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user