/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Implementation to interact with libdevinfo to find port nodes,
* and information regarding each node (fru, port, location).
*/
#include <stdio.h>
#include <libdevinfo.h>
#include <picl.h>
#include <picltree.h>
#include <strings.h>
#include <stdlib.h>
#include <config_admin.h>
#include <picldefs.h>
#include "piclfrutree.h"
#include <syslog.h>
extern int frutree_debug;
typedef struct {
void *arg;
typedef struct p_info {
int geo_addr;
int instance;
typedef struct {
int n_serial;
int n_parallel;
int n_network;
} plist_t;
static void
{
return;
}
}
/* (callback function for qsort) compare the bus_addr */
static int
compare(const void *a, const void *b)
{
ptr2pinfo1 = (port_info_t **)a;
ptr2pinfo2 = (port_info_t **)b;
}
/*
* assigns GeoAddr property for ports based on bus-addr
*/
static picl_errno_t
{
int i = 0;
int num_ports = 0;
return (PICL_FAILURE);
}
return (PICL_SUCCESS);
}
switch (type) {
case SERIAL_PORT:
return (PICL_SUCCESS);
}
break;
case PARALLEL_PORT:
if (list->n_parallel == 0) {
return (PICL_SUCCESS);
}
break;
case NETWORK_PORT:
return (PICL_SUCCESS);
}
break;
}
sizeof (port_info_t *) * num_ports);
return (PICL_NOSPACE);
}
/* traverse thru list and look for ports of given type */
continue;
}
i++;
}
/* sort the nodes to assign geo_address */
sizeof (port_info_t *), compare);
for (i = 0; i < num_ports; i++) {
}
}
return (PICL_SUCCESS);
}
static picl_errno_t
{
return (PICL_FAILURE);
}
return (PICL_NOSPACE);
}
case NETWORK_PORT:
sizeof (label));
sizeof (port_type));
break;
case PARALLEL_PORT:
sizeof (label));
sizeof (port_type));
break;
case SERIAL_PORT:
sizeof (label));
sizeof (port_type));
break;
default:
}
"\n%s %s%d %s\n"
"\t%s %s %s %s 0 \"%s %d\"\n"
"\t%s %s %s %s 0 \"%s\"\n"
"\t%s %s %s %s 1 %d\n"
"\t%s %s %s %s 0 \"%s\"\n"
"\t%s %s %s %s 0 \"%s\"\n"
"%s\n",
"r", port_type,
"ENDNODE");
/* add to the cache */
} else { /* 2nd node */
}
}
return (PICL_SUCCESS);
}
/*ARGSUSED*/
static int
{
return (DI_WALK_CONTINUE);
}
return (DI_WALK_CONTINUE);
}
return (DI_WALK_CONTINUE);
}
static picl_errno_t
{
return (PICL_INVALIDARG);
}
if (rnode == DI_NODE_NIL) {
return (PICL_FAILURE);
}
return (PICL_FAILURE);
}
return (PICL_SUCCESS);
}
/*
* probe for port nodes
*/
static int
{
return (DI_WALK_TERMINATE);
}
continue;
}
} else {
continue;
}
/* found port node */
if (devfs_path == NULL) {
continue;
}
continue;
}
return (PICL_NOSPACE);
}
sizeof (port_info->devfs_path));
switch (port_type) {
case NETWORK_PORT:
break;
case SERIAL_PORT:
break;
case PARALLEL_PORT:
listptr->n_parallel++;
break;
}
/* add to the list */
} else { /* 2nd node */
}
return (DI_WALK_CONTINUE);
}
return (DI_WALK_CONTINUE);
}
/* This routine probes libdevinfo for port nodes */
{
return (PICL_FAILURE);
}
return (rc);
}
}
if (rnode == DI_NODE_NIL) {
return (PICL_FAILURE);
}
list.n_parallel = 0;
return (PICL_FAILURE);
}
return (rc);
}
return (rc);
}
if (list.n_parallel > 0)
return (rc);
}
return (rc);
}
return (PICL_SUCCESS);
}
static int
{
®) < 0) {
return (-1);
}
return (PCI_REG_DEV_G(reg[0]));
}
return (PCI_REG_DEV_G(reg[0]));
}
static int
{
int busaddr = 0;
int di_busaddr = 0;
return (DI_WALK_TERMINATE);
}
return (DI_WALK_CONTINUE);
}
if (char_di_bus_addr == NULL) {
/*
* look for reg property
* This applies to only cPCI devices
*/
/* bus addr is of type 1,0 */
/* we dont handle this case yet */
return (DI_WALK_PRUNECHILD);
}
if (di_busaddr == -1) {
/* reg prop not found */
return (DI_WALK_PRUNECHILD);
}
/* check if the bus addresses are same */
errno = 0;
if (errno != 0) {
return (DI_WALK_TERMINATE);
}
if (di_busaddr != busaddr) {
return (DI_WALK_PRUNECHILD);
}
/* build the fru path name */
/* parent_path/nodename@bus_addr */
return (DI_WALK_TERMINATE);
}
return (DI_WALK_TERMINATE);
}
return (DI_WALK_PRUNECHILD);
}
} else { /* bus addr is of type 0x */
/* check if the values are same */
errno = 0;
if (errno != 0) {
return (DI_WALK_TERMINATE);
}
errno = 0;
if (errno != 0) {
return (DI_WALK_TERMINATE);
}
if (di_busaddr != busaddr) {
return (DI_WALK_PRUNECHILD);
}
}
/* node found */
return (DI_WALK_TERMINATE);
}
{
return (rc);
}
return (rc);
}
return (rc);
}
return (PICL_SUCCESS);
}
prom_handle = di_prom_init();
if (rnode == DI_NODE_NIL) {
return (PICL_FAILURE);
}
return (PICL_NOSPACE);
}
return (rc);
}
return (PICL_FAILURE);
}
return (PICL_SUCCESS);
} else {
return (PICL_NODENOTFOUND);
}
}
static int
{
int busaddr = 0;
int di_busaddr = 0;
return (DI_WALK_CONTINUE);
}
if (char_di_bus_addr == NULL) {
return (DI_WALK_PRUNECHILD);
}
return (DI_WALK_PRUNECHILD);
}
/* bus addr is of type 1,0 */
return (DI_WALK_TERMINATE);
} else {
return (DI_WALK_PRUNECHILD);
}
} else { /* bus addr is of type 0x */
/* check if the values are same */
errno = 0;
if (errno != 0) {
return (DI_WALK_PRUNECHILD);
}
errno = 0;
if (errno != 0) {
return (DI_WALK_PRUNECHILD);
}
if (di_busaddr == busaddr) {
return (DI_WALK_TERMINATE);
} else {
return (DI_WALK_PRUNECHILD);
}
}
}
/*
* checks if a fru is present under location using pdev-path and busaddr
*/
{
return (B_FALSE);
}
sizeof (probe_path)) != PICL_SUCCESS) {
return (B_FALSE);
}
}
if (rnode == DI_NODE_NIL) {
return (B_FALSE);
}
return (B_FALSE);
}
find_fru_node) != 0) {
return (B_FALSE);
}
return (B_TRUE);
} else {
return (B_FALSE);
}
}
/*
* initializes the port driver and instance fields based on libdevinfo
*/
{
sizeof (devfs_path))) != PICL_SUCCESS) {
return (rc);
}
return (rc);
}
if (rnode == DI_NODE_NIL) {
return (PICL_FAILURE);
}
while (peer != DI_NODE_NIL) {
if (di_busaddr == NULL) {
continue;
}
/* compare the bus_addr */
/* bus addr is of type 1,0 */
continue;
}
} else { /* bus addr is of type 0x */
errno = 0;
if (errno != 0) {
continue;
}
errno = 0;
if (errno != 0) {
continue;
}
if (di_int_busaddr != int_busaddr) {
continue;
}
}
return (PICL_FAILURE);
}
/* initialize the driver name and instance number */
return (PICL_SUCCESS);
}
return (PICL_NODENOTFOUND);
}