summaryrefslogtreecommitdiffstats
path: root/sys/dev/pccbb
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2006-05-24 17:27:55 +0000
committerimp <imp@FreeBSD.org>2006-05-24 17:27:55 +0000
commitcd7126b4158bcddab1cb24ee015a918a31f3088a (patch)
tree224b9835e6ffd469f5773748c64f4026f367329a /sys/dev/pccbb
parent1dda0904e8c9e36a1b08f487cd6ff70705d5f6e2 (diff)
downloadFreeBSD-src-cd7126b4158bcddab1cb24ee015a918a31f3088a.zip
FreeBSD-src-cd7126b4158bcddab1cb24ee015a918a31f3088a.tar.gz
Export the pribus, secbus and subbus as sysctls for information
purposes only. Additional information may be exported in the future.
Diffstat (limited to 'sys/dev/pccbb')
-rw-r--r--sys/dev/pccbb/pccbb_pci.c46
-rw-r--r--sys/dev/pccbb/pccbbvar.h5
2 files changed, 31 insertions, 20 deletions
diff --git a/sys/dev/pccbb/pccbb_pci.c b/sys/dev/pccbb/pccbb_pci.c
index ceed784..fc9435d 100644
--- a/sys/dev/pccbb/pccbb_pci.c
+++ b/sys/dev/pccbb/pccbb_pci.c
@@ -301,8 +301,10 @@ cbb_pci_attach(device_t brdev)
{
static int curr_bus_number = 2; /* XXX EVILE BAD (see below) */
struct cbb_softc *sc = (struct cbb_softc *)device_get_softc(brdev);
- int rid, bus, pribus;
+ int rid;
device_t parent;
+ struct sysctl_ctx_list *sctx;
+ struct sysctl_oid *soid;
parent = device_get_parent(brdev);
mtx_init(&sc->mtx, device_get_nameunit(brdev), "cbb", MTX_DEF);
@@ -314,6 +316,7 @@ cbb_pci_attach(device_t brdev)
sc->exca[0].pccarddev = NULL;
sc->secbus = pci_read_config(brdev, PCIR_SECBUS_2, 1);
sc->subbus = pci_read_config(brdev, PCIR_SUBBUS_2, 1);
+ sc->pribus = pci_read_config(brdev, PCIR_PRIBUS_2, 1);
SLIST_INIT(&sc->rl);
cbb_powerstate_d0(brdev);
@@ -338,30 +341,37 @@ cbb_pci_attach(device_t brdev)
sc->chipinit = cbb_chipinit;
sc->chipinit(sc);
+ /*Sysctls*/
+ sctx = device_get_sysctl_ctx(brdev);
+ soid = device_get_sysctl_tree(brdev);
+ SYSCTL_ADD_UINT(sctx, SYSCTL_CHILDREN(soid), OID_AUTO, "pribus",
+ CTLFLAG_RD, &sc->pribus, 0, "Primary bus number");
+ SYSCTL_ADD_UINT(sctx, SYSCTL_CHILDREN(soid), OID_AUTO, "secbus",
+ CTLFLAG_RD, &sc->secbus, 0, "Secondary bus number");
+ SYSCTL_ADD_UINT(sctx, SYSCTL_CHILDREN(soid), OID_AUTO, "subbus",
+ CTLFLAG_RD, &sc->subbus, 0, "Subordinate bus number");
+
/*
* This is a gross hack. We should be scanning the entire pci
* tree, assigning bus numbers in a way such that we (1) can
* reserve 1 extra bus just in case and (2) all sub busses
* are in an appropriate range.
*/
- bus = pci_read_config(brdev, PCIR_SECBUS_2, 1);
- pribus = pcib_get_bus(parent);
- DEVPRINTF((brdev, "Secondary bus is %d\n", bus));
- if (bus == 0) {
- if (curr_bus_number <= pribus)
- curr_bus_number = pribus + 1;
- if (pci_read_config(brdev, PCIR_PRIBUS_2, 1) != pribus) {
- DEVPRINTF((brdev, "Setting primary bus to %d\n", pribus));
- pci_write_config(brdev, PCIR_PRIBUS_2, pribus, 1);
+ DEVPRINTF((brdev, "Secondary bus is %d\n", sc->secbus));
+ if (sc->secbus == 0) {
+ if (curr_bus_number <= sc->pribus)
+ curr_bus_number = sc->pribus + 1;
+ if (pci_read_config(brdev, PCIR_PRIBUS_2, 1) != sc->pribus) {
+ DEVPRINTF((brdev, "Setting primary bus to %d\n",
+ sc->pribus));
+ pci_write_config(brdev, PCIR_PRIBUS_2, sc->pribus, 1);
}
- bus = curr_bus_number;
- DEVPRINTF((brdev, "Secondary bus set to %d subbus %d\n", bus,
- bus + 1));
- sc->secbus = bus;
- sc->subbus = bus + 1;
- pci_write_config(brdev, PCIR_SECBUS_2, bus, 1);
- pci_write_config(brdev, PCIR_SUBBUS_2, bus + 1, 1);
- curr_bus_number += 2;
+ sc->secbus = curr_bus_number++;
+ sc->subbus = curr_bus_number++;
+ DEVPRINTF((brdev, "Secondary bus set to %d subbus %d\n",
+ sc->secbus, sc->subbus));
+ pci_write_config(brdev, PCIR_SECBUS_2, sc->secbus, 1);
+ pci_write_config(brdev, PCIR_SUBBUS_2, sc->subbus, 1);
}
/* attach children */
diff --git a/sys/dev/pccbb/pccbbvar.h b/sys/dev/pccbb/pccbbvar.h
index c87de9a..8e98c77 100644
--- a/sys/dev/pccbb/pccbbvar.h
+++ b/sys/dev/pccbb/pccbbvar.h
@@ -61,8 +61,9 @@ struct cbb_softc {
void *intrhand;
bus_space_tag_t bst;
bus_space_handle_t bsh;
- u_int8_t secbus;
- u_int8_t subbus;
+ unsigned int pribus;
+ unsigned int secbus;
+ unsigned int subbus;
struct mtx mtx;
struct cv cv;
struct cv powercv;
OpenPOWER on IntegriCloud