ldma_dio.c revision fc256490629fe68815f7e0f23cf9b3545720cfac
/*
* 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 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <alloca.h>
#include <malloc.h>
#include <fcntl.h>
#include <syslog.h>
#include <string.h>
#include <errno.h>
#include <sys/mdesc_impl.h>
#include <libdevinfo.h>
#include "ldma.h"
#include "mdesc_mutable.h"
#define PCIEX "pciex"
#define LDMA_MODULE LDMA_NAME_DIO
/* System Info version supported (only version 1.0) */
#define LDMA_DIO_NHANDLERS (sizeof (ldma_dio_handlers) / \
sizeof (ldma_msg_handler_t))
static ldma_msg_handler_t ldma_dio_handlers[] = {
};
};
/* ARGSUSED */
static ldma_request_status_t
{
char *data;
int rv;
if (rv != 0) {
LDMA_ERR("Failed to generate devinfo MD");
return (LDMA_REQ_FAILED);
}
LDMA_ERR("Memory allocation failure");
return (LDMA_REQ_FAILED);
}
*reply_dlenp = md_size;
return (LDMA_REQ_COMPLETED);
}
static boolean_t
{
int len;
char *type;
return (B_FALSE);
return (B_FALSE);
/*
* A root complex node is directly under the root node. So, if
* 'di' is not the root node, and its parent has no parent,
* then 'di' represents a root complex node.
*/
}
/*
* String properties in the prom can contain multiple null-terminated
* strings which are concatenated together. We must represent them in
* an MD as a data property. This function retrieves such a property
* and adds it to the MD. If the 'alt_name' PROM property exists then
* the MD property is created with the value of the PROM 'alt_name'
* property, otherwise it is created with the value of the PROM 'name'
* property.
*/
static int
{
int count;
char *str;
int rv = 0;
}
}
count--;
}
return (rv);
}
/*
* Add an int property 'name' to an MD from an existing PROM property. If
* the 'alt_name' PROM property exists then the MD property is created with
* the value of the PROM 'alt_name' property, otherwise it is created with
* the value of the PROM 'name' property.
*/
static int
{
int count;
int rv = 0;
}
}
/*
* Note: We know that the properties of interest contain a
* a single int.
*/
}
return (rv);
}
static md_node_t *
{
return (NULL);
/* Add the properties from the devinfo node. */
goto fail;
/* Add the required properties for this node. */
goto fail;
goto fail;
if (add_prom_int_prop(ph,
goto fail;
if (add_prom_int_prop(ph,
goto fail;
if (add_prom_int_prop(ph,
goto fail;
return (np);
fail:
return (NULL);
}
static int
{
char *path;
int rv;
return (EIO);
return (ENOMEM);
}
return (ENOMEM);
}
}
if (rv != 0)
return (rv);
}
return (0);
}
static int
{
int rv;
if (rv != 0)
return (rv);
}
return (0);
}
static int
{
int rv = 0;
if (root == DI_NODE_NIL) {
LDMA_ERR("di_init cannot find device tree root node.");
return (errno);
}
ph = di_prom_init();
if (ph == DI_PROM_HANDLE_NIL) {
LDMA_ERR("di_prom_init failed.");
return (errno);
}
if (rv != 0)
break;
}
}
return (rv);
}
static int
{
return (ENOMEM);
}
return (ENOMEM);
}
return (ENOMEM);
}
if (md_size == 0) {
return (EIO);
}
return (0);
}