px_util.c revision 44bb982b3dceb1fe23d61ef29b896b40508e2a5a
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * CDDL HEADER START
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * The contents of this file are subject to the terms of the
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * Common Development and Distribution License (the "License").
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * You may not use this file except in compliance with the License.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * See the License for the specific language governing permissions
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * and limitations under the License.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * When distributing Covered Code, include this CDDL HEADER in each
a9478106a12424322498e53cf7cd75bd8a4d6004Yuri Pankov * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
a9478106a12424322498e53cf7cd75bd8a4d6004Yuri Pankov * If applicable, add the following below this CDDL HEADER, with the
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * fields enclosed by brackets "[]" replaced with your own identifying
a9478106a12424322498e53cf7cd75bd8a4d6004Yuri Pankov * information: Portions Copyright [yyyy] [name of copyright owner]
a9478106a12424322498e53cf7cd75bd8a4d6004Yuri Pankov * CDDL HEADER END
a9478106a12424322498e53cf7cd75bd8a4d6004Yuri Pankov * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * Use is subject to license terms.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#pragma ident "%Z%%M% %I% %E% SMI"
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * PCI nexus utility routines:
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * property and config routines for attach()
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * reg/intr/range/assigned-address property routines for bus_map()
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * init_child()
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * fault handling
52d2369a11f8e7fbf16d9fb72f92a154cf982013Robert Mustacchi/*LINTLIBRARY*/
52d2369a11f8e7fbf16d9fb72f92a154cf982013Robert Mustacchi * px_get_props
52d2369a11f8e7fbf16d9fb72f92a154cf982013Robert Mustacchi * This function is called from the attach routine to get the key
52d2369a11f8e7fbf16d9fb72f92a154cf982013Robert Mustacchi * properties of the pci nodes.
52d2369a11f8e7fbf16d9fb72f92a154cf982013Robert Mustacchi * used by: px_attach()
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * return value: DDI_FAILURE on failure
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * Get the bus-ranges property.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (ddi_getlongprop_buf(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe "bus-range", (caddr_t)&px_p->px_bus_range, &i) != DDI_SUCCESS) {
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe cmn_err(CE_WARN, "%s%d: no bus-range property\n",
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe DBG(DBG_ATTACH, dip, "get_px_properties: bus-range (%x,%x)\n",
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * Get the interrupts property.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe if (ddi_getlongprop(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS,
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe cmn_err(CE_WARN, "%s%d: no interrupts property\n",
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * figure out number of interrupts in the "interrupts" property
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * and convert them all into ino.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe i = ddi_getprop(DDI_DEV_T_ANY, dip, 0, "#interrupt-cells", 1);
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe for (i = 0; i < no_of_intrs; i++)
52d2369a11f8e7fbf16d9fb72f92a154cf982013Robert Mustacchi * Get the ranges property.
a9478106a12424322498e53cf7cd75bd8a4d6004Yuri Pankov if (ddi_getlongprop(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS, "ranges",
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe (caddr_t)&px_p->px_ranges_p, &px_p->px_ranges_length) !=
52d2369a11f8e7fbf16d9fb72f92a154cf982013Robert Mustacchi * px_free_props:
52d2369a11f8e7fbf16d9fb72f92a154cf982013Robert Mustacchi * This routine frees the memory used to cache the "interrupts"
a9478106a12424322498e53cf7cd75bd8a4d6004Yuri Pankov * and "ranges" properties of the pci bus device node.
a9478106a12424322498e53cf7cd75bd8a4d6004Yuri Pankov * used by: px_detach()
a9478106a12424322498e53cf7cd75bd8a4d6004Yuri Pankov * return value: none
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe kmem_free(px_p->px_ranges_p, px_p->px_ranges_length);
a9478106a12424322498e53cf7cd75bd8a4d6004Yuri Pankov * px_reloc_reg
a9478106a12424322498e53cf7cd75bd8a4d6004Yuri Pankov * If the "reg" entry (*px_rp) is relocatable, lookup "assigned-addresses"
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * property to fetch corresponding relocated address.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * used by: px_map()
a9478106a12424322498e53cf7cd75bd8a4d6004Yuri Pankov * return value:
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * DDI_SUCCESS - on success
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe * DDI_ME_INVAL - regspec is invalid
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowepx_reloc_reg(dev_info_t *dip, dev_info_t *rdip, px_t *px_p,
return (DDI_SUCCESS);
return (DDI_ME_INVAL);
return (DDI_ME_INVAL);
if (n >= rng_n)
return (DDI_ME_REGSPEC_RANGE);
return (DDI_SUCCESS);
int rval;
return (DDI_ME_INVAL);
return (rval);
return (DDI_FAILURE);
return (DDI_SUCCESS);
int reglen;
char **unit_addr;
uint_t n;
return (DDI_FAILURE);
return (DDI_SUCCESS);
return (DDI_FAILURE);
if (func != 0)
return (DDI_SUCCESS);
return (DDI_FAILURE);
return (DDI_SUCCESS);
int i, no_config;
sizeof (pci_pcimem_reg));
return (DDI_SUCCESS);
* node (possibly created by a driver.conf file).
extern int pci_allow_pseudo_children;
DDI_SUCCESS) {
return (DDI_NOT_WELL_FORMED);
return (DDI_FAILURE);
return (DDI_FAILURE);
return (DDI_SUCCESS);
return (DDI_NOT_WELL_FORMED);
return (DDI_FAILURE);
if (no_config != 0) {
return (DDI_SUCCESS);
return (DDI_FAILURE);
return (DDI_SUCCESS);
return (DDI_SUCCESS);
if (rnumber < 0)
goto done;
done:
return (size);
n = i / (int)sizeof (pci_regspec_t);
int *pci_ip;
n = i / (int)sizeof (uint_t);
if (i >= nrange)
px_p);
nerr = 0;
nerr++;
nerr++;
nerr++;
nerr++;
return (nerr);
return (B_TRUE);
return (B_FALSE);