did.c revision 0b6016e6ff70af39f99c9cc28e0c2207c8f5413c
/*
* 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"
/*
* did.c
* The acronym did means "Dev-Info-Data". Many properties and
* characteristics of topology nodes are, with a bit of coaxing
* derived from devinfo nodes. These routines do some of the
* derivation and also encapsulate the discoveries in did_t
* structures that get associated with topology nodes as their
* "private" data.
*/
#include <alloca.h>
#include <assert.h>
#include <string.h>
#include <strings.h>
#include <libtopo.h>
#include <libnvpair.h>
#include <libdevinfo.h>
#include "topo_mod.h"
#include "hostbridge.h"
#include "pcibus.h"
#include "did_impl.h"
#include "did_props.h"
static void slotnm_destroy(slotnm_t *);
static slotnm_t *
{
slotnm_t *p;
return (NULL);
slotnm_destroy(p);
return (NULL);
}
return (p);
}
static void
{
if (p == NULL)
return;
slotnm_destroy(p->snm_next);
}
static int
{
*nslots = 0;
*nslots = 0;
return (-1);
}
} else {
}
(*nslots)++;
}
if (*nslots > 0)
"%p inherits %d slot label(s) from %p.\n",
return (0);
}
static int
{
char *slotbuf;
int sz;
*slotnum = -1;
/*
* If no physical slot number property was found, then the
* capabilities register may indicate the pci-express device
* implements a slot, and we should record which slot.
*/
int e;
if (e == 0)
}
if (*slotnum == -1)
return (0);
/*
* For PCI-Express, there is only one downstream device, so check for
* a slot-names property, and if it exists, ignore the slotmask value
* and use the string as the label.
*/
} else {
/*
* Make generic description string "SLOT <num>", allow up to
* 10 digits for number
*/
}
return (-1);
return (0);
}
static int
{
char *slotname;
int andbit;
int sz = -1;
*nslots = 0;
return (0);
return (0);
if (slotmap == 0)
return (0);
char *s = slotname;
*nslots = 0;
return (-1);
}
else {
}
(*nslots)++;
}
}
return (0);
}
int
{
return (did->dp_physlot);
}
{
}
did_t *
{
topo_mod_t *mp;
return (pd);
}
return (NULL);
/*
* We must have a reg prop and from it we extract the bus #,
* device #, and function #.
*/
return (NULL);
}
else
/*
* There *may* be a class code we can capture. If there wasn't
* one, capture that fact by setting the class value to -1.
*/
} else {
}
/*
* There *may* be a PCI-express capabilities register we can capture.
* If there wasn't one, the capabilities will be the out-of-bounds
* value of zero.
*/
/*
* There *may* be a physical slot number property we can capture.
*/
if (di_physlotinfo_get(mp,
return (NULL);
}
/*
* There *may* be PCI slot info we can capture
*/
return (NULL);
}
return (np);
}
did_t *
{
}
did_t *
{
}
void
{
}
void
{
}
void
{
}
void
{
/*
* did_destroy() is called only from did_hash_destroy() when
* all references to the did_t have been released. We can
* safely destroy the did_t. If at some later time, more
* fine-grained reference count control is desired, this
* code will need to change
*/
}
void
{
}
void
{
}
{
}
{
}
void
{
}
void
{
}
int
{
}
int
{
}
int
{
}
static int
{
}
int
{
}
int
{
}
const char *
{
return (dp->dp_physlot_label);
break;
return (NULL);
}
did_t *
{
}
int
{
return (-1);
return (0);
}
int
{
return (-1);
return (-1);
}
return (0);
}
int
{
return (-1);
}
int
{
/*
* If the child already has a label, we're done.
*/
if (did_numlabels(dp) > 0)
return (0);
/*
* If the child and parent are the same, we're done.
*/
return (0);
return (-1);
}
return (-1);
return (0);
}