fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro * CDDL HEADER START
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro * The contents of this file are subject to the terms of the
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro * Common Development and Distribution License (the "License").
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro * You may not use this file except in compliance with the License.
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro * See the License for the specific language governing permissions
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro * and limitations under the License.
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro * When distributing Covered Code, include this CDDL HEADER in each
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro * If applicable, add the following below this CDDL HEADER, with the
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro * fields enclosed by brackets "[]" replaced with your own identifying
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro * information: Portions Copyright [yyyy] [name of copyright owner]
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro * CDDL HEADER END
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro * Use is subject to license terms.
fc256490629fe68815f7e0f23cf9b3545720cfacJason Belorostatic int get_devinfo(uint8_t **mdpp, size_t *size);
fc256490629fe68815f7e0f23cf9b3545720cfacJason Belorostatic boolean_t is_root_complex(di_prom_handle_t ph, di_node_t di);
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro di_prom_handle_t ph, di_node_t di, md_node_t *node, char *path);
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro di_prom_handle_t ph, md_node_t *node, di_node_t parent);
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro di_prom_handle_t ph, md_node_t *node, di_node_t dev);
fc256490629fe68815f7e0f23cf9b3545720cfacJason Belorostatic int device_tree_to_md(mmd_t *mdp, md_node_t *top);
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro/* System Info version supported (only version 1.0) */
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro#define LDMA_DIO_NVERS (sizeof (ldma_dio_vers) / sizeof (ds_ver_t))
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro#define LDMA_DIO_NHANDLERS (sizeof (ldma_dio_handlers) / \
fc256490629fe68815f7e0f23cf9b3545720cfacJason Belorostatic ldm_msg_func_t ldma_dio_pcidev_info_handler;
fc256490629fe68815f7e0f23cf9b3545720cfacJason Belorostatic ldma_msg_handler_t ldma_dio_handlers[] = {
82629e3015252bf18319ba3815c773df23e21436Mike Christensen {MSGDIO_PCIDEV_INFO, LDMA_MSGFLG_ACCESS_CONTROL,
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro/* ARGSUSED */
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloroldma_dio_pcidev_info_handler(ds_ver_t *ver, ldma_message_header_t *request,
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro size_t request_dlen, ldma_message_header_t **replyp, size_t *reply_dlenp)
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro LDMA_DBG("%s: PCI device info request", __func__);
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro reply = ldma_alloc_result_msg(request, md_size);
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro LDMA_DBG("%s: sending PCI device info", __func__);
fc256490629fe68815f7e0f23cf9b3545720cfacJason Belorois_root_complex(di_prom_handle_t ph, di_node_t di)
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro len = di_prom_prop_lookup_strings(ph, di, "device_type", &type);
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro * A root complex node is directly under the root node. So, if
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro * 'di' is not the root node, and its parent has no parent,
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro * then 'di' represents a root complex node.
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro (di_parent_node(di_parent_node(di)) == DI_NODE_NIL));
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro * String properties in the prom can contain multiple null-terminated
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro * strings which are concatenated together. We must represent them in
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro * an MD as a data property. This function retrieves such a property
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro * and adds it to the MD. If the 'alt_name' PROM property exists then
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro * the MD property is created with the value of the PROM 'alt_name'
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro * property, otherwise it is created with the value of the PROM 'name'
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro mmd_t *mdp, md_node_t *np, di_node_t di, char *name, char *alt_name)
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro count = di_prom_prop_lookup_strings(ph, di, alt_name, &pp_data);
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro count = di_prom_prop_lookup_strings(ph, di, name, &pp_data);
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro for (str = pp_data; count > 0; str += strlen(str) + 1)
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro * Add an int property 'name' to an MD from an existing PROM property. If
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro * the 'alt_name' PROM property exists then the MD property is created with
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro * the value of the PROM 'alt_name' property, otherwise it is created with
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro * the value of the PROM 'name' property.
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro mmd_t *mdp, md_node_t *np, di_node_t di, char *name, char *alt_name)
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro count = di_prom_prop_lookup_ints(ph, di, alt_name, &pp_data);
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro count = di_prom_prop_lookup_ints(ph, di, name, &pp_data);
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro * Note: We know that the properties of interest contain a
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro * a single int.
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro rv = md_add_value_property(mdp, np, name, *pp_data);
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro di_prom_handle_t ph, di_node_t di, md_node_t *node, char *path)
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro np = md_link_new_node(mdp, "iodevice", node, "fwd", "back");
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro /* Add the properties from the devinfo node. */
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro if (md_add_string_property(mdp, np, "dev_path", path) != 0)
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro /* Add the required properties for this node. */
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro if (add_prom_string_prop(ph, mdp, np, di, "device_type", NULL) != 0)
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro if (add_prom_string_prop(ph, mdp, np, di, "compatible", NULL) != 0)
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro mdp, np, di, "device-id", "real-device-id") != 0)
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro mdp, np, di, "vendor-id", "real-vendor-id") != 0)
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro mdp, np, di, "class-code", "real-class-code") != 0)
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro di_prom_handle_t ph, md_node_t *md_parent, di_node_t di_parent)
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro md_node = link_device_node(mdp, ph, di_parent, md_parent, path);
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro while ((di_child = di_child_node(di_parent)) != DI_NODE_NIL) {
fc256490629fe68815f7e0f23cf9b3545720cfacJason Belorocreate_peers(mmd_t *mdp, di_prom_handle_t ph, md_node_t *node, di_node_t dev)
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro while ((di_peer = di_sibling_node(dev)) != DI_NODE_NIL) {
fc256490629fe68815f7e0f23cf9b3545720cfacJason Beloro LDMA_ERR("di_init cannot find device tree root node.");