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