/*
* 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
*/
/*
*/
/*
* Create a topology node for a PRI node of type 'pciexrc'
*/
#include <strings.h>
#include <fm/topo_mod.h>
#include <libdevinfo.h>
#include "pi_impl.h"
tnode_t *);
/*
* Create a pciexrc topo by calling the pciexrc enumerator for this instance.
*/
int
{
int result;
/*
* Create the root complex topo node. Use the generic enumerator to
* do this, and then we will add more attributes below.
*/
"%s node_0x%llx failed to create topo node: %s\n",
return (result);
}
/* Update the topo node with more specific information */
hc_name);
if (result != 0) {
"%s node_0x%llx failed to create node properites: %s\n",
return (result);
}
if (result == 0) {
/*
* The node exists in this domain. We will call the PCIBUS
* enumerator after the entire PRI graph has been walked so
* that all the possible FRU nodes are available for bus's
* that span multiple FRU boundaries.
*/
if (result != 0) {
/* We cannot defer the call, so we need to do it now */
}
} else {
/*
* It is OK if the node does not exist for further PCIBUS
* enumeration. We can return success having created the
* root complex node itself.
*/
result = 0;
}
return (result);
}
/* ARGSUSED */
static int
{
int result;
"%s node_0x%llx deferred enumeration starting\n", _ENUM_NAME,
/* Make sure our dependent modules are loaded */
return (-1);
}
/* Create a node range for children of this bus */
min = 0;
if (result != 0) {
"%s node_0x%llx failed to create node range: %s\n",
return (-1);
}
/*
* Invoke the pcibus enumerator for this node.
*/
if (result != 0) {
"%s node_0x%llx enumeration failed: %s\n", _ENUM_NAME,
}
return (result);
}
/*
* Update PCIEXRC/HOSTBRIDGE topo node with node-specific information
*
* The following is mostly a duplicate of code contained in:
* cpuboard_hostbridge.c:cpuboard_rc_node_create
*/
int
{
int result;
int err;
int is_hbridge = 0;
int is_pciexrc = 0;
char *_enum_name;
/*
* Determine if decorating a PCIE root complex or a hostbridge
* node.
*/
is_pciexrc = 1;
_enum_name = "enum_pciexrc";
is_hbridge = 1;
_enum_name = "enum_hostbridge";
} else {
"pi_enum_update node_0x%llx unknown hc name %s\n",
return (-1);
}
return (-1);
}
/*
* Calculate the device path for this root complex node.
*/
if (is_hbridge == 1) {
/* "path" not required for hostbridge */
return (0);
}
return (-1);
}
/*
* Set the ASRU for this node using the dev scheme
*/
result = -1;
goto out;
}
if (result != 0) {
goto out;
}
/*
* Create property groups.
*/
if (result < 0) {
"topo_pgroup_create for io pgroup failed\n",
goto out;
}
if (is_pciexrc == 1) {
if (result < 0) {
"topo_pgroup_create for pci pgroup failed\n",
goto out;
}
}
if (result != 0) {
"%s node_0x%llx failed to set DEV property\n",
goto out;
}
/* device type is always "pciex" */
if (result < 0) {
"%s node_0x%llx failed to set DEVTYPE property\n",
goto out;
}
/*
* Derived the driver name from the device path.
*/
if (dnode == DI_NODE_NIL) {
result = -1;
goto out;
}
result = -1;
goto out;
}
if (is_pciexrc == 1) {
/*
* Derived the BDF property from the devinfo node.
*/
result = -1;
goto out;
}
}
if (result < 0) {
"%s node_0x%llx failed to set DRIVER property\n",
goto out;
}
"%s node_0x%llx failed to create module fmri\n",
result = -1;
goto out;
}
if (result < 0) {
"%s node_0x%llx failed to set MODULE property\n",
goto out;
}
if (is_pciexrc == 1) {
/* This is a PCIEX root complex */
if (result < 0) {
"%s node_0x%llx failed to set EXCAP property\n",
goto out;
}
/* Set BDF for root complex */
if (result < 0) {
"%s node_0x%llx failed to set BDF property\n",
goto out;
}
/* Create a node range for the children of this root complex */
if (result != 0) {
"%s node_0x%llx failed to create %s range\n",
result = -1;
}
}
out:
}
}
return (result);
}
static int
{
char *path;
/* Initialize the device information structure for this module */
if (devtree == DI_NODE_NIL) {
return (-1);
}
/*
* Find the PRI node path property. This will be used to associate
* the PRI node with the device node.
*/
return (-1);
}
/*
* Scan the device node list and find the node associated with
* the given PRI node. Equality is defined when the PRI path
* is the same as the device node path.
*/
while (dnode != DI_NODE_NIL) {
char *devfs_path;
if (devfs_path != NULL) {
/* We have found the matching dnode */
break;
}
}
/* We have not found the matching dnode yet */
}
if (dnode != DI_NODE_NIL) {
/*
* Associate this dnode with the topo node. The PCI
* enumerator requires this information.
*/
}
return (0);
}
/*
* Find the BDF property and return as a string.
*
* The string must be freed with topo_mod_strfree()
*/
static char *
{
unsigned char *buf;
/*
* Look for the "reg" property from the devinfo node.
*/
di_prop != DI_PROP_NIL;
sizeof (reg)) == 0) {
continue;
}
break;
}
}
/*
* If the "reg" property is not found in the di_node; look for it in
* OBP prom data.
*/
if (di_prop == DI_PROP_NIL) {
"%s failed to get prom handle\n", _ENUM_NAME);
return (NULL);
}
for (di_prom_prop =
sizeof (reg)) == 0) {
sizeof (uint_t)) {
continue;
}
break;
}
}
if (di_prom_prop == DI_PROP_NIL) {
"%s failed to get reg property\n", _ENUM_NAME);
return (NULL);
}
}
/*
* Caculate BDF
*
* The reg property is divided like this:
* -----------------------------------------------------
* | 23 Bus 16 | 15 Dev 11 | 10 Fn 8 | 7 Reg 0 |
* -----------------------------------------------------
*
* PCI_REG_* macros strip off Reg and shift to get individual
*/
/* Pass BDF back as a string */
}