xref: /titanic_52/usr/src/cmd/prtconf/prt_xxx.c (revision 1ac69ea687cc5094a956b1eb0a67df515029be6f)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
237c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #include <stdio.h>
307c478bd9Sstevel@tonic-gate #include <stddef.h>
317c478bd9Sstevel@tonic-gate #include <fcntl.h>
327c478bd9Sstevel@tonic-gate #include <string.h>
337c478bd9Sstevel@tonic-gate #include <libdevinfo.h>
347c478bd9Sstevel@tonic-gate #include <sys/pctypes.h>
357c478bd9Sstevel@tonic-gate #include <sys/pcmcia.h>
367c478bd9Sstevel@tonic-gate #include <sys/utsname.h>
377c478bd9Sstevel@tonic-gate #include <sys/avintr.h>
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate #include "prtconf.h"
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate struct priv_data {
427c478bd9Sstevel@tonic-gate 	char *drv_name;		/* parent name */
437c478bd9Sstevel@tonic-gate 	void (*pd_print)(uintptr_t, int);	/* print function */
447c478bd9Sstevel@tonic-gate };
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate extern void indent_to_level();
477c478bd9Sstevel@tonic-gate static void obio_printregs(struct regspec *, int);
487c478bd9Sstevel@tonic-gate static void obio_printranges(struct rangespec *, int);
497c478bd9Sstevel@tonic-gate static void obio_printintr(struct intrspec *, int);
507c478bd9Sstevel@tonic-gate static void obio_print(uintptr_t, int);
517c478bd9Sstevel@tonic-gate static void pcmcia_printregs(struct pcm_regs *, int);
527c478bd9Sstevel@tonic-gate static void pcmcia_printintr(struct intrspec *, int);
537c478bd9Sstevel@tonic-gate static void pcmcia_print(uintptr_t, int);
547c478bd9Sstevel@tonic-gate static void sbus_print(uintptr_t, int);
557c478bd9Sstevel@tonic-gate static struct priv_data *match_priv_data(di_node_t);
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate /*
587c478bd9Sstevel@tonic-gate  * This is a hardcoded list of drivers we print parent private
597c478bd9Sstevel@tonic-gate  * data as of Solaris 7.
607c478bd9Sstevel@tonic-gate  */
617c478bd9Sstevel@tonic-gate static struct di_priv_format ppd_format[] = {
627c478bd9Sstevel@tonic-gate 	{
637c478bd9Sstevel@tonic-gate 		/*
647c478bd9Sstevel@tonic-gate 		 * obio format: applies the following list
657c478bd9Sstevel@tonic-gate 		 * of nexus drivers. Note that obio driver
667c478bd9Sstevel@tonic-gate 		 * went away with sun4m.
677c478bd9Sstevel@tonic-gate 		 */
68*1ac69ea6Scth 		"central dma ebus fhc isa pci pci_pci rootnex",
697c478bd9Sstevel@tonic-gate 		sizeof (struct ddi_parent_private_data),
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate 		sizeof (struct regspec),		/* first pointer */
727c478bd9Sstevel@tonic-gate 		offsetof(struct ddi_parent_private_data, par_reg),
737c478bd9Sstevel@tonic-gate 		offsetof(struct ddi_parent_private_data, par_nreg),
747c478bd9Sstevel@tonic-gate 
757c478bd9Sstevel@tonic-gate 		sizeof (struct intrspec),		/* second pointer */
767c478bd9Sstevel@tonic-gate 		offsetof(struct ddi_parent_private_data, par_intr),
777c478bd9Sstevel@tonic-gate 		offsetof(struct ddi_parent_private_data, par_nintr),
787c478bd9Sstevel@tonic-gate 
797c478bd9Sstevel@tonic-gate 		sizeof (struct rangespec),		/* third pointer */
807c478bd9Sstevel@tonic-gate 		offsetof(struct ddi_parent_private_data, par_rng),
817c478bd9Sstevel@tonic-gate 		offsetof(struct ddi_parent_private_data, par_nrng),
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate 		0, 0, 0,	/* no more pointers */
847c478bd9Sstevel@tonic-gate 		0, 0, 0
857c478bd9Sstevel@tonic-gate 	},
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate 	{	/* pcmcia format */
887c478bd9Sstevel@tonic-gate 		"pcic stp4020",
897c478bd9Sstevel@tonic-gate 		sizeof (struct pcmcia_parent_private),
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate 		sizeof (struct pcm_regs),		/* first pointer */
927c478bd9Sstevel@tonic-gate 		offsetof(struct pcmcia_parent_private, ppd_reg),
937c478bd9Sstevel@tonic-gate 		offsetof(struct pcmcia_parent_private, ppd_nreg),
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate 		sizeof (struct intrspec),		/* second pointer */
967c478bd9Sstevel@tonic-gate 		offsetof(struct pcmcia_parent_private, ppd_intrspec),
977c478bd9Sstevel@tonic-gate 		offsetof(struct pcmcia_parent_private, ppd_intr),
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate 		0, 0, 0,	/* no more pointers */
1007c478bd9Sstevel@tonic-gate 		0, 0, 0,
1017c478bd9Sstevel@tonic-gate 		0, 0, 0
1027c478bd9Sstevel@tonic-gate 	},
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate 	{	/* sbus format--it's different on sun4u!! */
1057c478bd9Sstevel@tonic-gate 		"sbus",
1067c478bd9Sstevel@tonic-gate 		sizeof (struct ddi_parent_private_data),
1077c478bd9Sstevel@tonic-gate 
1087c478bd9Sstevel@tonic-gate 		sizeof (struct regspec),		/* first pointer */
1097c478bd9Sstevel@tonic-gate 		offsetof(struct ddi_parent_private_data, par_reg),
1107c478bd9Sstevel@tonic-gate 		offsetof(struct ddi_parent_private_data, par_nreg),
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate 		sizeof (struct intrspec),		/* second pointer */
1137c478bd9Sstevel@tonic-gate 		offsetof(struct ddi_parent_private_data, par_intr),
1147c478bd9Sstevel@tonic-gate 		offsetof(struct ddi_parent_private_data, par_nintr),
1157c478bd9Sstevel@tonic-gate 
1167c478bd9Sstevel@tonic-gate 		sizeof (struct rangespec),		/* third pointer */
1177c478bd9Sstevel@tonic-gate 		offsetof(struct ddi_parent_private_data, par_rng),
1187c478bd9Sstevel@tonic-gate 		offsetof(struct ddi_parent_private_data, par_nrng),
1197c478bd9Sstevel@tonic-gate 
1207c478bd9Sstevel@tonic-gate 		0, 0, 0,	/* no more pointers */
1217c478bd9Sstevel@tonic-gate 		0, 0, 0
1227c478bd9Sstevel@tonic-gate 	}
1237c478bd9Sstevel@tonic-gate };
1247c478bd9Sstevel@tonic-gate 
1257c478bd9Sstevel@tonic-gate static struct priv_data prt_priv_data[] = {
1267c478bd9Sstevel@tonic-gate 	{ ppd_format[0].drv_name, obio_print},
1277c478bd9Sstevel@tonic-gate 	{ ppd_format[1].drv_name, pcmcia_print},
1287c478bd9Sstevel@tonic-gate 	{ ppd_format[2].drv_name, sbus_print}
1297c478bd9Sstevel@tonic-gate };
1307c478bd9Sstevel@tonic-gate 
1317c478bd9Sstevel@tonic-gate static int nprt_priv_data = sizeof (prt_priv_data)/sizeof (struct priv_data);
1327c478bd9Sstevel@tonic-gate 
1337c478bd9Sstevel@tonic-gate void
1347c478bd9Sstevel@tonic-gate init_priv_data(struct di_priv_data *fetch)
1357c478bd9Sstevel@tonic-gate {
1367c478bd9Sstevel@tonic-gate 	/* no driver private data */
1377c478bd9Sstevel@tonic-gate 	fetch->version = DI_PRIVDATA_VERSION_0;
1387c478bd9Sstevel@tonic-gate 	fetch->n_driver = 0;
1397c478bd9Sstevel@tonic-gate 	fetch->driver = NULL;
1407c478bd9Sstevel@tonic-gate 
1417c478bd9Sstevel@tonic-gate 	fetch->n_parent = nprt_priv_data;
1427c478bd9Sstevel@tonic-gate 	fetch->parent = ppd_format;
1437c478bd9Sstevel@tonic-gate }
1447c478bd9Sstevel@tonic-gate 
1457c478bd9Sstevel@tonic-gate static void
1467c478bd9Sstevel@tonic-gate obio_printregs(struct regspec *rp, int ilev)
1477c478bd9Sstevel@tonic-gate {
1487c478bd9Sstevel@tonic-gate 	indent_to_level(ilev);
1497c478bd9Sstevel@tonic-gate 	(void) printf("    Bus Type=0x%x, Address=0x%x, Size=0x%x\n",
1507c478bd9Sstevel@tonic-gate 	    rp->regspec_bustype, rp->regspec_addr, rp->regspec_size);
1517c478bd9Sstevel@tonic-gate }
1527c478bd9Sstevel@tonic-gate 
1537c478bd9Sstevel@tonic-gate static void
1547c478bd9Sstevel@tonic-gate obio_printranges(struct rangespec *rp, int ilev)
1557c478bd9Sstevel@tonic-gate {
1567c478bd9Sstevel@tonic-gate 	indent_to_level(ilev);
1577c478bd9Sstevel@tonic-gate 	(void) printf("    Ch: %.2x,%.8x Pa: %.2x,%.8x, Sz: %x\n",
1587c478bd9Sstevel@tonic-gate 	    rp->rng_cbustype, rp->rng_coffset,
1597c478bd9Sstevel@tonic-gate 	    rp->rng_bustype, rp->rng_offset,
1607c478bd9Sstevel@tonic-gate 	    rp->rng_size);
1617c478bd9Sstevel@tonic-gate }
1627c478bd9Sstevel@tonic-gate 
1637c478bd9Sstevel@tonic-gate static void
1647c478bd9Sstevel@tonic-gate obio_printintr(struct intrspec *ip, int ilev)
1657c478bd9Sstevel@tonic-gate {
1667c478bd9Sstevel@tonic-gate 	indent_to_level(ilev);
1677c478bd9Sstevel@tonic-gate 	(void) printf("    Interrupt Priority=0x%x (ipl %d)",
1687c478bd9Sstevel@tonic-gate 	    ip->intrspec_pri, INT_IPL(ip->intrspec_pri));
1697c478bd9Sstevel@tonic-gate 	if (ip->intrspec_vec)
1707c478bd9Sstevel@tonic-gate 		(void) printf(", vector=0x%x (%d)",
1717c478bd9Sstevel@tonic-gate 		    ip->intrspec_vec, ip->intrspec_vec);
1727c478bd9Sstevel@tonic-gate 	(void) printf("\n");
1737c478bd9Sstevel@tonic-gate }
1747c478bd9Sstevel@tonic-gate 
1757c478bd9Sstevel@tonic-gate static void
1767c478bd9Sstevel@tonic-gate obio_print(uintptr_t data, int ilev)
1777c478bd9Sstevel@tonic-gate {
1787c478bd9Sstevel@tonic-gate 	int i, nreg, nrng, nintr;
1797c478bd9Sstevel@tonic-gate 	struct ddi_parent_private_data *dp;
1807c478bd9Sstevel@tonic-gate 	struct regspec *reg;
1817c478bd9Sstevel@tonic-gate 	struct intrspec *intr;
1827c478bd9Sstevel@tonic-gate 	struct rangespec *rng;
1837c478bd9Sstevel@tonic-gate 
1847c478bd9Sstevel@tonic-gate 	dp = (struct ddi_parent_private_data *)data;
1857c478bd9Sstevel@tonic-gate #ifdef DEBUG
1867c478bd9Sstevel@tonic-gate 	dprintf("obio parent private data: nreg = 0x%x offset = 0x%x"
1877c478bd9Sstevel@tonic-gate 	    " nintr = 0x%x offset = 0x%x nrng = 0x%x offset = %x\n",
1887c478bd9Sstevel@tonic-gate 	    dp->par_nreg, *((di_off_t *)(&dp->par_reg)),
1897c478bd9Sstevel@tonic-gate 	    dp->par_nintr, *((di_off_t *)(&dp->par_intr)),
1907c478bd9Sstevel@tonic-gate 	    dp->par_nrng, *((di_off_t *)(&dp->par_rng)));
1917c478bd9Sstevel@tonic-gate #endif /* DEBUG */
1927c478bd9Sstevel@tonic-gate 	nreg = dp->par_nreg;
1937c478bd9Sstevel@tonic-gate 	nintr = dp->par_nintr;
1947c478bd9Sstevel@tonic-gate 	nrng = dp->par_nrng;
1957c478bd9Sstevel@tonic-gate 
1967c478bd9Sstevel@tonic-gate 	/*
1977c478bd9Sstevel@tonic-gate 	 * All pointers are translated to di_off_t by the devinfo driver.
1987c478bd9Sstevel@tonic-gate 	 * This is a private agreement between libdevinfo and prtconf.
1997c478bd9Sstevel@tonic-gate 	 */
2007c478bd9Sstevel@tonic-gate 	if (nreg != 0) {
2017c478bd9Sstevel@tonic-gate 		indent_to_level(ilev);
2027c478bd9Sstevel@tonic-gate 		(void) printf("Register Specifications:\n");
2037c478bd9Sstevel@tonic-gate 
2047c478bd9Sstevel@tonic-gate 		reg = (struct regspec *)(data + *(di_off_t *)(&dp->par_reg));
2057c478bd9Sstevel@tonic-gate 		for (i = 0; i < nreg; ++i)
2067c478bd9Sstevel@tonic-gate 			obio_printregs(reg + i, ilev);
2077c478bd9Sstevel@tonic-gate 	}
2087c478bd9Sstevel@tonic-gate 
2097c478bd9Sstevel@tonic-gate 	if (nrng != 0) {
2107c478bd9Sstevel@tonic-gate 		indent_to_level(ilev);
2117c478bd9Sstevel@tonic-gate 		(void) printf("Range Specifications:\n");
2127c478bd9Sstevel@tonic-gate 
2137c478bd9Sstevel@tonic-gate 		rng = (struct rangespec *)(data + *(di_off_t *)(&dp->par_rng));
2147c478bd9Sstevel@tonic-gate 		for (i = 0; i < nrng; ++i)
2157c478bd9Sstevel@tonic-gate 			obio_printranges(rng + i, ilev);
2167c478bd9Sstevel@tonic-gate 	}
2177c478bd9Sstevel@tonic-gate 
2187c478bd9Sstevel@tonic-gate 	if (nintr != 0) {
2197c478bd9Sstevel@tonic-gate 		indent_to_level(ilev);
2207c478bd9Sstevel@tonic-gate 		(void) printf("Interrupt Specifications:\n");
2217c478bd9Sstevel@tonic-gate 
2227c478bd9Sstevel@tonic-gate 		intr = (struct intrspec *)(data + *(di_off_t *)(&dp->par_intr));
2237c478bd9Sstevel@tonic-gate 		for (i = 0; i < nintr; ++i)
2247c478bd9Sstevel@tonic-gate 			obio_printintr(intr + i, ilev);
2257c478bd9Sstevel@tonic-gate 	}
2267c478bd9Sstevel@tonic-gate }
2277c478bd9Sstevel@tonic-gate 
2287c478bd9Sstevel@tonic-gate static void
2297c478bd9Sstevel@tonic-gate pcmcia_printregs(struct pcm_regs *rp, int ilev)
2307c478bd9Sstevel@tonic-gate {
2317c478bd9Sstevel@tonic-gate 	indent_to_level(ilev);
2327c478bd9Sstevel@tonic-gate 	(void) printf("    Phys hi=0x%x, Phys lo=0x%x, Phys len=%x\n",
2337c478bd9Sstevel@tonic-gate 	    rp->phys_hi, rp->phys_lo, rp->phys_len);
2347c478bd9Sstevel@tonic-gate }
2357c478bd9Sstevel@tonic-gate 
2367c478bd9Sstevel@tonic-gate static void
2377c478bd9Sstevel@tonic-gate pcmcia_printintr(struct intrspec *ip, int ilev)
2387c478bd9Sstevel@tonic-gate {
2397c478bd9Sstevel@tonic-gate 	obio_printintr(ip, ilev);
2407c478bd9Sstevel@tonic-gate }
2417c478bd9Sstevel@tonic-gate 
2427c478bd9Sstevel@tonic-gate static void
2437c478bd9Sstevel@tonic-gate pcmcia_print(uintptr_t data, int ilev)
2447c478bd9Sstevel@tonic-gate {
2457c478bd9Sstevel@tonic-gate 	int i, nreg, nintr;
2467c478bd9Sstevel@tonic-gate 	struct pcmcia_parent_private *dp;
2477c478bd9Sstevel@tonic-gate 	struct pcm_regs *reg;
2487c478bd9Sstevel@tonic-gate 	struct intrspec *intr;
2497c478bd9Sstevel@tonic-gate 
2507c478bd9Sstevel@tonic-gate 	dp = (struct pcmcia_parent_private *)data;
2517c478bd9Sstevel@tonic-gate #ifdef DEBUG
2527c478bd9Sstevel@tonic-gate 	dprintf("pcmcia parent private data: nreg = 0x%x offset = 0x%x"
2537c478bd9Sstevel@tonic-gate 	    " intr = 0x%x offset = %x\n",
2547c478bd9Sstevel@tonic-gate 	    dp->ppd_nreg, *(di_off_t *)(&dp->ppd_reg),
2557c478bd9Sstevel@tonic-gate 	    dp->ppd_intr, *(di_off_t *)(&dp->ppd_intrspec));
2567c478bd9Sstevel@tonic-gate #endif /* DEBUG */
2577c478bd9Sstevel@tonic-gate 	nreg = dp->ppd_nreg;
2587c478bd9Sstevel@tonic-gate 	nintr = dp->ppd_intr;
2597c478bd9Sstevel@tonic-gate 
2607c478bd9Sstevel@tonic-gate 	/*
2617c478bd9Sstevel@tonic-gate 	 * All pointers are translated to di_off_t by the devinfo driver.
2627c478bd9Sstevel@tonic-gate 	 * This is a private agreement between libdevinfo and prtconf.
2637c478bd9Sstevel@tonic-gate 	 */
2647c478bd9Sstevel@tonic-gate 	if (nreg != 0)  {
2657c478bd9Sstevel@tonic-gate 		indent_to_level(ilev);
2667c478bd9Sstevel@tonic-gate 		(void) printf("Register Specifications:\n");
2677c478bd9Sstevel@tonic-gate 
2687c478bd9Sstevel@tonic-gate 		reg = (struct pcm_regs *)(data + *(di_off_t *)(&dp->ppd_reg));
2697c478bd9Sstevel@tonic-gate 		for (i = 0; i < nreg; ++i)
2707c478bd9Sstevel@tonic-gate 			pcmcia_printregs(reg + i, ilev);
2717c478bd9Sstevel@tonic-gate 	}
2727c478bd9Sstevel@tonic-gate 
2737c478bd9Sstevel@tonic-gate 	if (nintr != 0)  {
2747c478bd9Sstevel@tonic-gate 		indent_to_level(ilev);
2757c478bd9Sstevel@tonic-gate 		(void) printf("Interrupt Specifications:\n");
2767c478bd9Sstevel@tonic-gate 
2777c478bd9Sstevel@tonic-gate 		intr = (struct intrspec *)
2787c478bd9Sstevel@tonic-gate 		    (data + *(di_off_t *)(&dp->ppd_intrspec));
2797c478bd9Sstevel@tonic-gate 		for (i = 0; i < nintr; ++i)
2807c478bd9Sstevel@tonic-gate 			pcmcia_printintr(intr + i, ilev);
2817c478bd9Sstevel@tonic-gate 	}
2827c478bd9Sstevel@tonic-gate }
2837c478bd9Sstevel@tonic-gate 
2847c478bd9Sstevel@tonic-gate static void
2857c478bd9Sstevel@tonic-gate sbus_print(uintptr_t data, int ilev)
2867c478bd9Sstevel@tonic-gate {
2877c478bd9Sstevel@tonic-gate 	int i, nreg, nrng, nintr;
2887c478bd9Sstevel@tonic-gate 	struct ddi_parent_private_data *dp;
2897c478bd9Sstevel@tonic-gate 	struct regspec *reg;
2907c478bd9Sstevel@tonic-gate 	struct intrspec *intr;
2917c478bd9Sstevel@tonic-gate 	struct rangespec *rng;
2927c478bd9Sstevel@tonic-gate 
2937c478bd9Sstevel@tonic-gate 	dp = (struct ddi_parent_private_data *)data;
2947c478bd9Sstevel@tonic-gate #ifdef DEBUG
2957c478bd9Sstevel@tonic-gate 	dprintf("sbus parent private data: nreg = 0x%x offset = 0x%x"
2967c478bd9Sstevel@tonic-gate 	    " nintr = 0x%x offset = 0x%x nrng = 0x%x offset = %x\n",
2977c478bd9Sstevel@tonic-gate 	    dp->par_nreg, *((di_off_t *)(&dp->par_reg)),
2987c478bd9Sstevel@tonic-gate 	    dp->par_nintr, *((di_off_t *)(&dp->par_intr)),
2997c478bd9Sstevel@tonic-gate 	    dp->par_nrng, *((di_off_t *)(&dp->par_rng)));
3007c478bd9Sstevel@tonic-gate #endif /* DEBUG */
3017c478bd9Sstevel@tonic-gate 	nreg = dp->par_nreg;
3027c478bd9Sstevel@tonic-gate 	nintr = dp->par_nintr;
3037c478bd9Sstevel@tonic-gate 	nrng = dp->par_nrng;
3047c478bd9Sstevel@tonic-gate 
3057c478bd9Sstevel@tonic-gate 	/*
3067c478bd9Sstevel@tonic-gate 	 * All pointers are translated to di_off_t by the devinfo driver.
3077c478bd9Sstevel@tonic-gate 	 * This is a private agreement between libdevinfo and prtconf.
3087c478bd9Sstevel@tonic-gate 	 */
3097c478bd9Sstevel@tonic-gate 	if (nreg != 0) {
3107c478bd9Sstevel@tonic-gate 		indent_to_level(ilev);
3117c478bd9Sstevel@tonic-gate 		(void) printf("Register Specifications:\n");
3127c478bd9Sstevel@tonic-gate 
3137c478bd9Sstevel@tonic-gate 		reg = (struct regspec *)(data + *(di_off_t *)(&dp->par_reg));
3147c478bd9Sstevel@tonic-gate 		for (i = 0; i < nreg; ++i)
3157c478bd9Sstevel@tonic-gate 			obio_printregs(reg + i, ilev);
3167c478bd9Sstevel@tonic-gate 	}
3177c478bd9Sstevel@tonic-gate 
3187c478bd9Sstevel@tonic-gate 
3197c478bd9Sstevel@tonic-gate 	if (nrng != 0) {
3207c478bd9Sstevel@tonic-gate 		indent_to_level(ilev);
3217c478bd9Sstevel@tonic-gate 		(void) printf("Range Specifications:\n");
3227c478bd9Sstevel@tonic-gate 
3237c478bd9Sstevel@tonic-gate 		rng = (struct rangespec *)(data + *(di_off_t *)(&dp->par_rng));
3247c478bd9Sstevel@tonic-gate 		for (i = 0; i < nrng; ++i)
3257c478bd9Sstevel@tonic-gate 			obio_printranges(rng + i, ilev);
3267c478bd9Sstevel@tonic-gate 	}
3277c478bd9Sstevel@tonic-gate 
3287c478bd9Sstevel@tonic-gate 	/*
3297c478bd9Sstevel@tonic-gate 	 * To print interrupt property for children of sbus on sun4u requires
3307c478bd9Sstevel@tonic-gate 	 * definitions in sysiosbus.h.
3317c478bd9Sstevel@tonic-gate 	 *
3327c478bd9Sstevel@tonic-gate 	 * We can't #include <sys/sysiosbus.h> to have the build work on
3337c478bd9Sstevel@tonic-gate 	 * non sun4u machines. It's not right either to
3347c478bd9Sstevel@tonic-gate 	 *	#include "../../uts/sun4u/sys/sysiosbus.h"
3357c478bd9Sstevel@tonic-gate 	 * As a result, we will not print the information.
3367c478bd9Sstevel@tonic-gate 	 */
3377c478bd9Sstevel@tonic-gate 	if ((nintr != 0) && (strcmp(opts.o_uts.machine, "sun4u") != 0)) {
3387c478bd9Sstevel@tonic-gate 		indent_to_level(ilev);
3397c478bd9Sstevel@tonic-gate 		(void) printf("Interrupt Specifications:\n");
3407c478bd9Sstevel@tonic-gate 
3417c478bd9Sstevel@tonic-gate 		for (i = 0; i < nintr; ++i) {
3427c478bd9Sstevel@tonic-gate 			intr = (struct intrspec *)
3437c478bd9Sstevel@tonic-gate 			    (data + *(di_off_t *)(&dp->par_intr));
3447c478bd9Sstevel@tonic-gate 			obio_printintr(intr + i, ilev);
3457c478bd9Sstevel@tonic-gate 		}
3467c478bd9Sstevel@tonic-gate 	}
3477c478bd9Sstevel@tonic-gate }
3487c478bd9Sstevel@tonic-gate 
3497c478bd9Sstevel@tonic-gate static struct priv_data *
3507c478bd9Sstevel@tonic-gate match_priv_data(di_node_t node)
3517c478bd9Sstevel@tonic-gate {
3527c478bd9Sstevel@tonic-gate 	int i;
3537c478bd9Sstevel@tonic-gate 	size_t len;
3547c478bd9Sstevel@tonic-gate 	char *drv_name, *tmp;
3557c478bd9Sstevel@tonic-gate 	di_node_t parent;
3567c478bd9Sstevel@tonic-gate 	struct priv_data *pdp;
3577c478bd9Sstevel@tonic-gate 
3587c478bd9Sstevel@tonic-gate 	if ((parent = di_parent_node(node)) == DI_NODE_NIL)
3597c478bd9Sstevel@tonic-gate 		return (NULL);
3607c478bd9Sstevel@tonic-gate 
3617c478bd9Sstevel@tonic-gate 	if ((drv_name = di_driver_name(parent)) == NULL)
3627c478bd9Sstevel@tonic-gate 		return (NULL);
3637c478bd9Sstevel@tonic-gate 
3647c478bd9Sstevel@tonic-gate 	pdp = prt_priv_data;
3657c478bd9Sstevel@tonic-gate 	len = strlen(drv_name);
3667c478bd9Sstevel@tonic-gate 	for (i = 0; i < nprt_priv_data; ++i, ++pdp) {
3677c478bd9Sstevel@tonic-gate 		tmp = pdp->drv_name;
3687c478bd9Sstevel@tonic-gate 		while (tmp && (*tmp != '\0')) {
3697c478bd9Sstevel@tonic-gate 			if (strncmp(tmp, drv_name, len) == 0) {
3707c478bd9Sstevel@tonic-gate #ifdef	DEBUG
3717c478bd9Sstevel@tonic-gate 				dprintf("matched parent private data"
3727c478bd9Sstevel@tonic-gate 				    " at Node <%s> parent driver <%s>\n",
3737c478bd9Sstevel@tonic-gate 				    di_node_name(node), drv_name);
3747c478bd9Sstevel@tonic-gate #endif	/* DEBUG */
3757c478bd9Sstevel@tonic-gate 				return (pdp);
3767c478bd9Sstevel@tonic-gate 			}
3777c478bd9Sstevel@tonic-gate 			/*
3787c478bd9Sstevel@tonic-gate 			 * skip a white space
3797c478bd9Sstevel@tonic-gate 			 */
3807c478bd9Sstevel@tonic-gate 			if (tmp = strchr(tmp, ' '))
3817c478bd9Sstevel@tonic-gate 				tmp++;
3827c478bd9Sstevel@tonic-gate 		}
3837c478bd9Sstevel@tonic-gate 	}
3847c478bd9Sstevel@tonic-gate 
3857c478bd9Sstevel@tonic-gate 	return (NULL);
3867c478bd9Sstevel@tonic-gate }
3877c478bd9Sstevel@tonic-gate 
3887c478bd9Sstevel@tonic-gate void
3897c478bd9Sstevel@tonic-gate dump_priv_data(int ilev, di_node_t node)
3907c478bd9Sstevel@tonic-gate {
3917c478bd9Sstevel@tonic-gate 	uintptr_t priv;
3927c478bd9Sstevel@tonic-gate 	struct priv_data *pdp;
3937c478bd9Sstevel@tonic-gate 
3947c478bd9Sstevel@tonic-gate 	if ((priv = (uintptr_t)di_parent_private_data(node)) == NULL)
3957c478bd9Sstevel@tonic-gate 		return;
3967c478bd9Sstevel@tonic-gate 
3977c478bd9Sstevel@tonic-gate 	if ((pdp = match_priv_data(node)) == NULL) {
3987c478bd9Sstevel@tonic-gate #ifdef DEBUG
3997c478bd9Sstevel@tonic-gate 		dprintf("Error: parent private data format unknown\n");
4007c478bd9Sstevel@tonic-gate #endif /* DEBUG */
4017c478bd9Sstevel@tonic-gate 		return;
4027c478bd9Sstevel@tonic-gate 	}
4037c478bd9Sstevel@tonic-gate 
4047c478bd9Sstevel@tonic-gate 	pdp->pd_print(priv, ilev);
4057c478bd9Sstevel@tonic-gate 
4067c478bd9Sstevel@tonic-gate 	/* ignore driver private data for now */
4077c478bd9Sstevel@tonic-gate }
408