pcibus.c revision 00d0963faf2e861a4aef6b1bf28f99a5b2b20755
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <alloca.h>
#include <libdevinfo.h>
#include <libnvpair.h>
#include <fm/topo_mod.h>
#include "hostbridge.h"
#include "pcibus.h"
#include "did.h"
#include "did_props.h"
#include "util.h"
extern txprop_t Bus_common_props[];
extern txprop_t Dev_common_props[];
extern txprop_t Fn_common_props[];
extern int Bus_propcnt;
extern int Dev_propcnt;
extern int Fn_propcnt;
topo_instance_t, void *);
nvlist_t **);
nvlist_t **);
nvlist_t **);
const topo_modinfo_t Pci_info =
const topo_method_t Pci_methods[] = {
{ NULL }
};
static did_hash_t *Didhash;
void
{
/*
* Turn on module debugging output
*/
"Pcibus enumerator: di_prom_handle_init failed.\n");
return;
}
}
void
{
}
/*ARGSUSED*/
static int
{
return (0);
}
/*ARGSUSED*/
static int
{
return (0);
}
static int
{
if (version > TOPO_METH_LABEL_VERSION)
}
static tnode_t *
{
return (NULL);
return (NULL);
}
return (ntn);
}
/*ARGSUSED*/
static int
{
return (-1);
return (-1);
return (0);
}
tnode_t *
{
return (NULL);
return (NULL);
return (NULL);
}
/*
* We may find pci-express buses or plain-pci buses beneath a function
*/
return (NULL);
}
return (NULL);
}
return (ntn);
}
tnode_t *
{
return (NULL);
return (NULL);
return (NULL);
}
/*
* We can expect to find pci-express functions beneath the device
*/
if (child_range_add(PciHdl,
return (NULL);
}
return (ntn);
}
tnode_t *
{
return (NULL);
return (NULL);
return (NULL);
}
/*
* We can expect to find pci-express devices beneath the bus
*/
if (child_range_add(PciHdl,
return (NULL);
}
return (ntn);
}
tnode_t *
{
return (NULL);
return (NULL);
return (NULL);
}
/*
* We may find pci buses beneath a function
*/
return (NULL);
}
return (ntn);
}
tnode_t *
{
return (NULL);
return (NULL);
/*
* If our devinfo node is lacking certain information of its
* from our parent node's private data.
*/
return (NULL);
}
/*
* We can expect to find pci functions beneath the device
*/
return (NULL);
}
return (ntn);
}
tnode_t *
{
int hbchild = 0;
return (NULL);
return (NULL);
/*
* If our devinfo node is lacking certain information of its
* own, and our parent topology node is a hostbridge, we may
* hostbridge node's private data.
*/
hbchild = 1;
return (NULL);
}
/*
* We can expect to find pci devices beneath the bus
*/
return (NULL);
}
/*
* On each bus child of the hostbridge, we represent the
* hostbridge as a device outside the range of legal device
* numbers.
*/
if (hbchild == 1) {
if (hostbridge_asdevice(ntn) < 0) {
return (NULL);
}
}
return (ntn);
}
static int
{
int err;
if (rc >= 0)
else
return (-1);
}
if (rc >= 0)
else
return (-1);
return (-1);
if (excap <= 0 ||
else
if (err < 0)
return (-1);
}
return (0);
}
int
{
int pb = -1;
int b, d, f;
for (d = 0; d < MAX_PCIBUS_DEVS; d++)
for (f = 0; f < MAX_PCIDEV_FNS; f++)
/* start at the parent's first sibling */
while (sib != DI_NODE_NIL) {
return (-1);
if (pb < 0)
}
return (0);
if (rc >= 0)
else
return (-1);
if (pb < 0)
return (0);
for (d = 0; d < MAX_PCIBUS_DEVS; d++) {
for (f = 0; f < MAX_PCIDEV_FNS; f++) {
continue;
if ((declare_dev_and_fn(bn,
return (-1);
}
}
return (0);
}
/*ARGSUSED*/
static int
{
char *pname;
"Currently only know how to enumerate %s or %s not %s.\n",
return (0);
}
"Currently can only enumerate a %s or %s directly\n",
"descended from a %s or %s node.\n",
return (0);
}
"Parent %s node missing private data.\n"
"Unable to proceed with %s enumeration.\n",
return (0);
}
/*
* If we're looking for a specific bus-instance, find the right
* did_t in the chain, otherwise, there should be only one did_t.
* Cache the did_t of interest in *this* enumerator's cache.
*/
int b;
if (b == min)
break;
}
"Parent %s node missing private data related\n"
return (0);
}
} else {
}
}
/*ARGSUSED*/
static void
{
/*
* node private data (did_t) for this node is destroyed in
* did_hash_destroy()
*/
}