xref: /titanic_44/usr/src/uts/sun4/io/rootnex.c (revision a195726fa33097e56cf1c25c31feddb827e140f0)
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
502e56f3fSwesolows  * Common Development and Distribution License (the "License").
602e56f3fSwesolows  * 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  */
2102e56f3fSwesolows 
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 /*
307c478bd9Sstevel@tonic-gate  * sun4 root nexus driver
317c478bd9Sstevel@tonic-gate  */
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #include <sys/conf.h>
347c478bd9Sstevel@tonic-gate #include <sys/modctl.h>
357c478bd9Sstevel@tonic-gate #include <sys/ddi_subrdefs.h>
367c478bd9Sstevel@tonic-gate #include <sys/sunndi.h>
377c478bd9Sstevel@tonic-gate #include <sys/vmsystm.h>
387c478bd9Sstevel@tonic-gate #include <sys/async.h>
397c478bd9Sstevel@tonic-gate #include <sys/intr.h>
407c478bd9Sstevel@tonic-gate #include <sys/ndifm.h>
417c478bd9Sstevel@tonic-gate #include <vm/seg_dev.h>
427c478bd9Sstevel@tonic-gate #include <vm/seg_kmem.h>
437c478bd9Sstevel@tonic-gate #include <sys/ontrap.h>
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate /* Useful debugging Stuff */
467c478bd9Sstevel@tonic-gate #include <sys/nexusdebug.h>
477c478bd9Sstevel@tonic-gate #define	ROOTNEX_MAP_DEBUG		0x1
487c478bd9Sstevel@tonic-gate #define	ROOTNEX_INTR_DEBUG		0x2
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate /*
517c478bd9Sstevel@tonic-gate  * config information
527c478bd9Sstevel@tonic-gate  */
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate static int
557c478bd9Sstevel@tonic-gate rootnex_map(dev_info_t *dip, dev_info_t *rdip, ddi_map_req_t *mp,
567c478bd9Sstevel@tonic-gate     off_t offset, off_t len, caddr_t *vaddrp);
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate static int
597c478bd9Sstevel@tonic-gate rootnex_intr_ops(dev_info_t *, dev_info_t *, ddi_intr_op_t,
607c478bd9Sstevel@tonic-gate     ddi_intr_handle_impl_t *, void *);
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate static int
637c478bd9Sstevel@tonic-gate rootnex_map_fault(dev_info_t *dip, dev_info_t *rdip,
647c478bd9Sstevel@tonic-gate     struct hat *hat, struct seg *seg, caddr_t addr,
657c478bd9Sstevel@tonic-gate     struct devpage *dp, pfn_t pfn, uint_t prot, uint_t lock);
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate static int
687c478bd9Sstevel@tonic-gate rootnex_ctlops(dev_info_t *, dev_info_t *, ddi_ctl_enum_t, void *, void *);
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate static int
717c478bd9Sstevel@tonic-gate rootnex_busop_fminit(dev_info_t *dip, dev_info_t *tdip, int tcap,
727c478bd9Sstevel@tonic-gate     ddi_iblock_cookie_t *ibc);
737c478bd9Sstevel@tonic-gate 
747c478bd9Sstevel@tonic-gate static void
757c478bd9Sstevel@tonic-gate rootnex_fm_init(dev_info_t *);
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate static int
787c478bd9Sstevel@tonic-gate rootnex_ctlops_peekpoke(ddi_ctl_enum_t, peekpoke_ctlops_t *, void *result);
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate /*
817c478bd9Sstevel@tonic-gate  * Defined in $KARCH/io/mach_rootnex.c
827c478bd9Sstevel@tonic-gate  */
837c478bd9Sstevel@tonic-gate int rootnex_add_intr_impl(dev_info_t *dip, dev_info_t *rdip,
847c478bd9Sstevel@tonic-gate     ddi_intr_handle_impl_t *hdlp);
857c478bd9Sstevel@tonic-gate #pragma weak rootnex_add_intr_impl
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate int rootnex_remove_intr_impl(dev_info_t *dip, dev_info_t *rdip,
887c478bd9Sstevel@tonic-gate     ddi_intr_handle_impl_t *hdlp);
897c478bd9Sstevel@tonic-gate #pragma weak rootnex_remove_intr_impl
907c478bd9Sstevel@tonic-gate 
91*a195726fSgovinda int rootnex_get_intr_pri(dev_info_t *dip, dev_info_t *rdip,
927c478bd9Sstevel@tonic-gate     ddi_intr_handle_impl_t *hdlp);
937c478bd9Sstevel@tonic-gate #pragma weak rootnex_get_intr_pri
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate int rootnex_name_child_impl(dev_info_t *child, char *name, int namelen);
967c478bd9Sstevel@tonic-gate #pragma weak rootnex_name_child_impl
977c478bd9Sstevel@tonic-gate 
987c478bd9Sstevel@tonic-gate int rootnex_ctl_initchild_impl(dev_info_t *dip);
997c478bd9Sstevel@tonic-gate #pragma weak rootnex_initchild_impl
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate void rootnex_ctl_uninitchild_impl(dev_info_t *dip);
1027c478bd9Sstevel@tonic-gate #pragma weak rootnex_uninitchild_impl
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate int rootnex_ctl_reportdev_impl(dev_info_t *dev);
1057c478bd9Sstevel@tonic-gate #pragma weak rootnex_reportdev_impl
1067c478bd9Sstevel@tonic-gate 
1077c478bd9Sstevel@tonic-gate static struct cb_ops rootnex_cb_ops = {
1087c478bd9Sstevel@tonic-gate 	nodev,		/* open */
1097c478bd9Sstevel@tonic-gate 	nodev,		/* close */
1107c478bd9Sstevel@tonic-gate 	nodev,		/* strategy */
1117c478bd9Sstevel@tonic-gate 	nodev,		/* print */
1127c478bd9Sstevel@tonic-gate 	nodev,		/* dump */
1137c478bd9Sstevel@tonic-gate 	nodev,		/* read */
1147c478bd9Sstevel@tonic-gate 	nodev,		/* write */
1157c478bd9Sstevel@tonic-gate 	nodev,		/* ioctl */
1167c478bd9Sstevel@tonic-gate 	nodev,		/* devmap */
1177c478bd9Sstevel@tonic-gate 	nodev,		/* mmap */
1187c478bd9Sstevel@tonic-gate 	nodev,		/* segmap */
1197c478bd9Sstevel@tonic-gate 	nochpoll,	/* chpoll */
1207c478bd9Sstevel@tonic-gate 	ddi_prop_op,	/* cb_prop_op */
1217c478bd9Sstevel@tonic-gate 	NULL,		/* struct streamtab */
1227c478bd9Sstevel@tonic-gate 	D_NEW | D_MP | D_HOTPLUG,	/* compatibility flags */
1237c478bd9Sstevel@tonic-gate 	CB_REV,		/* Rev */
1247c478bd9Sstevel@tonic-gate 	nodev,		/* cb_aread */
1257c478bd9Sstevel@tonic-gate 	nodev		/* cb_awrite */
1267c478bd9Sstevel@tonic-gate };
1277c478bd9Sstevel@tonic-gate 
1287c478bd9Sstevel@tonic-gate static struct bus_ops rootnex_bus_ops = {
1297c478bd9Sstevel@tonic-gate 	BUSO_REV,
1307c478bd9Sstevel@tonic-gate 	rootnex_map,
1317c478bd9Sstevel@tonic-gate 	NULL,
1327c478bd9Sstevel@tonic-gate 	NULL,
1337c478bd9Sstevel@tonic-gate 	NULL,
1347c478bd9Sstevel@tonic-gate 	rootnex_map_fault,
1357c478bd9Sstevel@tonic-gate 	ddi_no_dma_map,		/* no rootnex_dma_map- now in sysio nexus */
1367c478bd9Sstevel@tonic-gate 	ddi_no_dma_allochdl,
1377c478bd9Sstevel@tonic-gate 	ddi_no_dma_freehdl,
1387c478bd9Sstevel@tonic-gate 	ddi_no_dma_bindhdl,
1397c478bd9Sstevel@tonic-gate 	ddi_no_dma_unbindhdl,
1407c478bd9Sstevel@tonic-gate 	ddi_no_dma_flush,
1417c478bd9Sstevel@tonic-gate 	ddi_no_dma_win,
1427c478bd9Sstevel@tonic-gate 	ddi_no_dma_mctl,	/* no rootnex_dma_mctl- now in sysio nexus */
1437c478bd9Sstevel@tonic-gate 	rootnex_ctlops,
1447c478bd9Sstevel@tonic-gate 	ddi_bus_prop_op,
1457c478bd9Sstevel@tonic-gate 	i_ddi_rootnex_get_eventcookie,
1467c478bd9Sstevel@tonic-gate 	i_ddi_rootnex_add_eventcall,
1477c478bd9Sstevel@tonic-gate 	i_ddi_rootnex_remove_eventcall,
1487c478bd9Sstevel@tonic-gate 	i_ddi_rootnex_post_event,
1497c478bd9Sstevel@tonic-gate 	NULL,			/* bus_intr_ctl */
1507c478bd9Sstevel@tonic-gate 	NULL,			/* bus_config */
1517c478bd9Sstevel@tonic-gate 	NULL,			/* bus_unconfig */
1527c478bd9Sstevel@tonic-gate 	rootnex_busop_fminit,	/* bus_fm_init */
1537c478bd9Sstevel@tonic-gate 	NULL,			/* bus_fm_fini */
1547c478bd9Sstevel@tonic-gate 	NULL,			/* bus_fm_access_enter */
1557c478bd9Sstevel@tonic-gate 	NULL,			/* bus_fm_access_fini */
1567c478bd9Sstevel@tonic-gate 	NULL,			/* bus_power */
1577c478bd9Sstevel@tonic-gate 	rootnex_intr_ops	/* bus_intr_op */
1587c478bd9Sstevel@tonic-gate };
1597c478bd9Sstevel@tonic-gate 
1607c478bd9Sstevel@tonic-gate static int rootnex_attach(dev_info_t *devi, ddi_attach_cmd_t cmd);
1617c478bd9Sstevel@tonic-gate static int rootnex_detach(dev_info_t *devi, ddi_detach_cmd_t cmd);
1627c478bd9Sstevel@tonic-gate 
1637c478bd9Sstevel@tonic-gate static struct dev_ops rootnex_ops = {
1647c478bd9Sstevel@tonic-gate 	DEVO_REV,
1657c478bd9Sstevel@tonic-gate 	0,		/* refcnt */
1667c478bd9Sstevel@tonic-gate 	ddi_no_info,	/* info */
1677c478bd9Sstevel@tonic-gate 	nulldev,
1687c478bd9Sstevel@tonic-gate 	nulldev,	/* probe */
1697c478bd9Sstevel@tonic-gate 	rootnex_attach,
1707c478bd9Sstevel@tonic-gate 	rootnex_detach,
1717c478bd9Sstevel@tonic-gate 	nodev,		/* reset */
1727c478bd9Sstevel@tonic-gate 	&rootnex_cb_ops,
1737c478bd9Sstevel@tonic-gate 	&rootnex_bus_ops
1747c478bd9Sstevel@tonic-gate };
1757c478bd9Sstevel@tonic-gate 
1767c478bd9Sstevel@tonic-gate 
1777c478bd9Sstevel@tonic-gate extern uint_t	root_phys_addr_lo_mask;
1787c478bd9Sstevel@tonic-gate extern uint_t	root_phys_addr_hi_mask;
1797c478bd9Sstevel@tonic-gate extern struct mod_ops mod_driverops;
1807c478bd9Sstevel@tonic-gate extern struct dev_ops rootnex_ops;
1817c478bd9Sstevel@tonic-gate extern struct cpu cpu0;
1827c478bd9Sstevel@tonic-gate extern ddi_iblock_cookie_t rootnex_err_ibc;
1837c478bd9Sstevel@tonic-gate 
1847c478bd9Sstevel@tonic-gate 
1857c478bd9Sstevel@tonic-gate /*
1867c478bd9Sstevel@tonic-gate  * Add statically defined root properties to this list...
1877c478bd9Sstevel@tonic-gate  */
1887c478bd9Sstevel@tonic-gate static const int pagesize = PAGESIZE;
1897c478bd9Sstevel@tonic-gate static const int mmu_pagesize = MMU_PAGESIZE;
1907c478bd9Sstevel@tonic-gate static const int mmu_pageoffset = MMU_PAGEOFFSET;
1917c478bd9Sstevel@tonic-gate 
1927c478bd9Sstevel@tonic-gate struct prop_def {
1937c478bd9Sstevel@tonic-gate 	char *prop_name;
1947c478bd9Sstevel@tonic-gate 	caddr_t prop_value;
1957c478bd9Sstevel@tonic-gate };
1967c478bd9Sstevel@tonic-gate 
1977c478bd9Sstevel@tonic-gate static struct prop_def root_props[] = {
1987c478bd9Sstevel@tonic-gate 	{ "PAGESIZE",		(caddr_t)&pagesize },
1997c478bd9Sstevel@tonic-gate 	{ "MMU_PAGESIZE",	(caddr_t)&mmu_pagesize},
2007c478bd9Sstevel@tonic-gate 	{ "MMU_PAGEOFFSET",	(caddr_t)&mmu_pageoffset},
2017c478bd9Sstevel@tonic-gate };
2027c478bd9Sstevel@tonic-gate 
2037c478bd9Sstevel@tonic-gate static vmem_t	*rootnex_regspec_arena;
2047c478bd9Sstevel@tonic-gate 
2057c478bd9Sstevel@tonic-gate #define	NROOT_PROPS	(sizeof (root_props) / sizeof (struct prop_def))
2067c478bd9Sstevel@tonic-gate 
2077c478bd9Sstevel@tonic-gate 
2087c478bd9Sstevel@tonic-gate 
2097c478bd9Sstevel@tonic-gate /*
2107c478bd9Sstevel@tonic-gate  * Module linkage information for the kernel.
2117c478bd9Sstevel@tonic-gate  */
2127c478bd9Sstevel@tonic-gate 
2137c478bd9Sstevel@tonic-gate static struct modldrv modldrv = {
2147c478bd9Sstevel@tonic-gate 	&mod_driverops,	/* Type of module.  This one is a nexus driver */
2157c478bd9Sstevel@tonic-gate 	"sun4 root nexus %I%",
2167c478bd9Sstevel@tonic-gate 	&rootnex_ops,	/* Driver ops */
2177c478bd9Sstevel@tonic-gate };
2187c478bd9Sstevel@tonic-gate 
2197c478bd9Sstevel@tonic-gate static struct modlinkage modlinkage = {
2207c478bd9Sstevel@tonic-gate 	MODREV_1, (void *)&modldrv, NULL
2217c478bd9Sstevel@tonic-gate };
2227c478bd9Sstevel@tonic-gate 
2237c478bd9Sstevel@tonic-gate int
2247c478bd9Sstevel@tonic-gate _init(void)
2257c478bd9Sstevel@tonic-gate {
2267c478bd9Sstevel@tonic-gate 	return (mod_install(&modlinkage));
2277c478bd9Sstevel@tonic-gate }
2287c478bd9Sstevel@tonic-gate 
2297c478bd9Sstevel@tonic-gate int
2307c478bd9Sstevel@tonic-gate _fini(void)
2317c478bd9Sstevel@tonic-gate {
2327c478bd9Sstevel@tonic-gate 	return (EBUSY);
2337c478bd9Sstevel@tonic-gate }
2347c478bd9Sstevel@tonic-gate 
2357c478bd9Sstevel@tonic-gate int
2367c478bd9Sstevel@tonic-gate _info(struct modinfo *modinfop)
2377c478bd9Sstevel@tonic-gate {
2387c478bd9Sstevel@tonic-gate 	return (mod_info(&modlinkage, modinfop));
2397c478bd9Sstevel@tonic-gate }
2407c478bd9Sstevel@tonic-gate 
2417c478bd9Sstevel@tonic-gate /*
2427c478bd9Sstevel@tonic-gate  * rootnex_attach:
2437c478bd9Sstevel@tonic-gate  *
2447c478bd9Sstevel@tonic-gate  *	attach the root nexus.
2457c478bd9Sstevel@tonic-gate  */
2467c478bd9Sstevel@tonic-gate static void add_root_props(dev_info_t *);
2477c478bd9Sstevel@tonic-gate 
2487c478bd9Sstevel@tonic-gate /*ARGSUSED*/
2497c478bd9Sstevel@tonic-gate static int
2507c478bd9Sstevel@tonic-gate rootnex_attach(dev_info_t *devi, ddi_attach_cmd_t cmd)
2517c478bd9Sstevel@tonic-gate {
2527c478bd9Sstevel@tonic-gate 	int length;
2537c478bd9Sstevel@tonic-gate 	char *valuep = NULL;
2547c478bd9Sstevel@tonic-gate 
2557c478bd9Sstevel@tonic-gate 	/*
2567c478bd9Sstevel@tonic-gate 	 * Only do these functions when the driver is acting as the
2577c478bd9Sstevel@tonic-gate 	 * root nexus, not when it is driving a memory controller.
2587c478bd9Sstevel@tonic-gate 	 */
2597c478bd9Sstevel@tonic-gate 	if (ddi_root_node() == devi) {
2607c478bd9Sstevel@tonic-gate 		rootnex_fm_init(devi);
2617c478bd9Sstevel@tonic-gate 		add_root_props(devi);
2627c478bd9Sstevel@tonic-gate 		i_ddi_rootnex_init_events(devi);
2637c478bd9Sstevel@tonic-gate 		rootnex_regspec_arena = vmem_create("regspec",
2647c478bd9Sstevel@tonic-gate 		    (void *)PIOMAPBASE, PIOMAPSIZE, MMU_PAGESIZE, NULL, NULL,
2657c478bd9Sstevel@tonic-gate 		    NULL, 0, VM_SLEEP);
2667c478bd9Sstevel@tonic-gate 	}
2677c478bd9Sstevel@tonic-gate 
2687c478bd9Sstevel@tonic-gate 	if (ddi_prop_op(DDI_DEV_T_ANY, devi, PROP_LEN_AND_VAL_ALLOC,
2697c478bd9Sstevel@tonic-gate 	    DDI_PROP_DONTPASS, "banner-name", (caddr_t)&valuep,
2707c478bd9Sstevel@tonic-gate 	    &length) == DDI_PROP_SUCCESS) {
2717c478bd9Sstevel@tonic-gate 		cmn_err(CE_CONT, "?root nexus = %s\n", valuep);
2727c478bd9Sstevel@tonic-gate 		kmem_free(valuep, length);
2737c478bd9Sstevel@tonic-gate 	}
2747c478bd9Sstevel@tonic-gate 	/*
2757c478bd9Sstevel@tonic-gate 	 * Add a no-suspend-resume property so that NDI
2767c478bd9Sstevel@tonic-gate 	 * does not attempt to suspend/resume the rootnex
2777c478bd9Sstevel@tonic-gate 	 * (or any of its aliases) node.
2787c478bd9Sstevel@tonic-gate 	 */
2797c478bd9Sstevel@tonic-gate 	(void) ddi_prop_update_string(DDI_DEV_T_NONE, devi,
2807c478bd9Sstevel@tonic-gate 	    "pm-hardware-state", "no-suspend-resume");
2817c478bd9Sstevel@tonic-gate 
2827c478bd9Sstevel@tonic-gate 	return (DDI_SUCCESS);
2837c478bd9Sstevel@tonic-gate }
2847c478bd9Sstevel@tonic-gate 
2857c478bd9Sstevel@tonic-gate /*ARGSUSED*/
2867c478bd9Sstevel@tonic-gate static int
2877c478bd9Sstevel@tonic-gate rootnex_detach(dev_info_t *devi, ddi_detach_cmd_t cmd)
2887c478bd9Sstevel@tonic-gate {
2897c478bd9Sstevel@tonic-gate 	return (DDI_SUCCESS);
2907c478bd9Sstevel@tonic-gate }
2917c478bd9Sstevel@tonic-gate 
2927c478bd9Sstevel@tonic-gate static void
2937c478bd9Sstevel@tonic-gate add_root_props(dev_info_t *devi)
2947c478bd9Sstevel@tonic-gate {
2957c478bd9Sstevel@tonic-gate 	int i;
2967c478bd9Sstevel@tonic-gate 	struct prop_def *rpp;
2977c478bd9Sstevel@tonic-gate 
2987c478bd9Sstevel@tonic-gate 	/*
2997c478bd9Sstevel@tonic-gate 	 * Note that this for loop works because all of the
3007c478bd9Sstevel@tonic-gate 	 * properties in root_prop are integers
3017c478bd9Sstevel@tonic-gate 	 */
3027c478bd9Sstevel@tonic-gate 	for (i = 0, rpp = root_props; i < NROOT_PROPS; ++i, ++rpp) {
3037c478bd9Sstevel@tonic-gate 		(void) e_ddi_prop_update_int(DDI_DEV_T_NONE, devi,
3047c478bd9Sstevel@tonic-gate 		    rpp->prop_name, *((int *)rpp->prop_value));
3057c478bd9Sstevel@tonic-gate 	}
3067c478bd9Sstevel@tonic-gate 
3077c478bd9Sstevel@tonic-gate 	/*
3087c478bd9Sstevel@tonic-gate 	 * Create the root node "boolean" property
3097c478bd9Sstevel@tonic-gate 	 * corresponding to addressing type supported in the root node:
3107c478bd9Sstevel@tonic-gate 	 *
3117c478bd9Sstevel@tonic-gate 	 * Choices are:
3127c478bd9Sstevel@tonic-gate 	 *	"relative-addressing" (OBP PROMS)
3137c478bd9Sstevel@tonic-gate 	 *	"generic-addressing"  (SunMon -- pseudo OBP/DDI)
3147c478bd9Sstevel@tonic-gate 	 */
3157c478bd9Sstevel@tonic-gate 
3167c478bd9Sstevel@tonic-gate 	(void) e_ddi_prop_update_int(DDI_DEV_T_NONE, devi,
3177c478bd9Sstevel@tonic-gate 	    DDI_RELATIVE_ADDRESSING, 1);
3187c478bd9Sstevel@tonic-gate 
3197c478bd9Sstevel@tonic-gate 	/*
3207c478bd9Sstevel@tonic-gate 	 * Create fault management capability property
3217c478bd9Sstevel@tonic-gate 	 */
3227c478bd9Sstevel@tonic-gate 	(void) e_ddi_prop_update_int(DDI_DEV_T_NONE, devi, "fm-capable",
3237c478bd9Sstevel@tonic-gate 	    ddi_fm_capable(devi));
3247c478bd9Sstevel@tonic-gate }
3257c478bd9Sstevel@tonic-gate 
3267c478bd9Sstevel@tonic-gate static int
3277c478bd9Sstevel@tonic-gate rootnex_map_regspec(ddi_map_req_t *mp, caddr_t *vaddrp, uint_t mapping_attr)
3287c478bd9Sstevel@tonic-gate {
3297c478bd9Sstevel@tonic-gate 	ulong_t base;
3307c478bd9Sstevel@tonic-gate 	caddr_t kaddr;
3317c478bd9Sstevel@tonic-gate 	pgcnt_t npages;
3327c478bd9Sstevel@tonic-gate 	pfn_t 	pfn;
3337c478bd9Sstevel@tonic-gate 	uint_t 	pgoffset;
3347c478bd9Sstevel@tonic-gate 	struct regspec *rp = mp->map_obj.rp;
3357c478bd9Sstevel@tonic-gate 	ddi_acc_hdl_t *hp;
3367c478bd9Sstevel@tonic-gate 
3377c478bd9Sstevel@tonic-gate 	base = (ulong_t)rp->regspec_addr & (~MMU_PAGEOFFSET); /* base addr */
3387c478bd9Sstevel@tonic-gate 
3397c478bd9Sstevel@tonic-gate 	/*
3407c478bd9Sstevel@tonic-gate 	 * Take the bustype and the physical page base within the
3417c478bd9Sstevel@tonic-gate 	 * bus space and turn it into a 28 bit page frame number.
3427c478bd9Sstevel@tonic-gate 	 */
3437c478bd9Sstevel@tonic-gate 
3447c478bd9Sstevel@tonic-gate 	pfn = BUSTYPE_TO_PFN(((rp->regspec_bustype) & root_phys_addr_hi_mask),
3457c478bd9Sstevel@tonic-gate 	    mmu_btop(base));
3467c478bd9Sstevel@tonic-gate 
3477c478bd9Sstevel@tonic-gate 
3487c478bd9Sstevel@tonic-gate 	/*
3497c478bd9Sstevel@tonic-gate 	 * Do a quick sanity check to make sure we are in I/O space.
3507c478bd9Sstevel@tonic-gate 	 */
3517c478bd9Sstevel@tonic-gate 	if (pf_is_memory(pfn))
3527c478bd9Sstevel@tonic-gate 		return (DDI_ME_INVAL);
3537c478bd9Sstevel@tonic-gate 
3547c478bd9Sstevel@tonic-gate 	if (rp->regspec_size == 0) {
3557c478bd9Sstevel@tonic-gate 		DPRINTF(ROOTNEX_MAP_DEBUG, ("rootnex_map_regspec: zero "
3567c478bd9Sstevel@tonic-gate 		    "regspec_size\n"));
3577c478bd9Sstevel@tonic-gate 		return (DDI_ME_INVAL);
3587c478bd9Sstevel@tonic-gate 	}
3597c478bd9Sstevel@tonic-gate 
3607c478bd9Sstevel@tonic-gate 	if (mp->map_flags & DDI_MF_DEVICE_MAPPING)
3617c478bd9Sstevel@tonic-gate 		*vaddrp = (caddr_t)pfn;
3627c478bd9Sstevel@tonic-gate 	else {
3637c478bd9Sstevel@tonic-gate 		pgoffset = (ulong_t)rp->regspec_addr & MMU_PAGEOFFSET;
3647c478bd9Sstevel@tonic-gate 		npages = mmu_btopr(rp->regspec_size + pgoffset);
3657c478bd9Sstevel@tonic-gate 
3667c478bd9Sstevel@tonic-gate 		DPRINTF(ROOTNEX_MAP_DEBUG, ("rootnex_map_regspec: Mapping "
3677c478bd9Sstevel@tonic-gate 		    "%lu pages physical %x.%lx ", npages, rp->regspec_bustype,
3687c478bd9Sstevel@tonic-gate 		    base));
3697c478bd9Sstevel@tonic-gate 
3707c478bd9Sstevel@tonic-gate 		if ((kaddr = vmem_alloc(rootnex_regspec_arena,
3717c478bd9Sstevel@tonic-gate 		    ptob(npages), VM_NOSLEEP)) == NULL)
3727c478bd9Sstevel@tonic-gate 			return (DDI_ME_NORESOURCES);
3737c478bd9Sstevel@tonic-gate 
3747c478bd9Sstevel@tonic-gate 		/*
3757c478bd9Sstevel@tonic-gate 		 * Now map in the pages we've allocated...
3767c478bd9Sstevel@tonic-gate 		 */
3777c478bd9Sstevel@tonic-gate 		hat_devload(kas.a_hat, kaddr, ptob(npages), pfn,
3787c478bd9Sstevel@tonic-gate 		    mp->map_prot | mapping_attr, HAT_LOAD_LOCK);
3797c478bd9Sstevel@tonic-gate 
3807c478bd9Sstevel@tonic-gate 		*vaddrp = kaddr + pgoffset;
3817c478bd9Sstevel@tonic-gate 
3827c478bd9Sstevel@tonic-gate 		hp = mp->map_handlep;
3837c478bd9Sstevel@tonic-gate 		if (hp) {
3847c478bd9Sstevel@tonic-gate 			hp->ah_pfn = pfn;
3857c478bd9Sstevel@tonic-gate 			hp->ah_pnum = npages;
3867c478bd9Sstevel@tonic-gate 		}
3877c478bd9Sstevel@tonic-gate 	}
3887c478bd9Sstevel@tonic-gate 
38902e56f3fSwesolows 	DPRINTF(ROOTNEX_MAP_DEBUG, ("at virtual 0x%p\n", *vaddrp));
3907c478bd9Sstevel@tonic-gate 	return (0);
3917c478bd9Sstevel@tonic-gate }
3927c478bd9Sstevel@tonic-gate 
3937c478bd9Sstevel@tonic-gate static int
3947c478bd9Sstevel@tonic-gate rootnex_unmap_regspec(ddi_map_req_t *mp, caddr_t *vaddrp)
3957c478bd9Sstevel@tonic-gate {
3967c478bd9Sstevel@tonic-gate 	caddr_t addr = *vaddrp;
3977c478bd9Sstevel@tonic-gate 	pgcnt_t npages;
3987c478bd9Sstevel@tonic-gate 	uint_t  pgoffset;
3997c478bd9Sstevel@tonic-gate 	caddr_t base;
4007c478bd9Sstevel@tonic-gate 	struct regspec *rp;
4017c478bd9Sstevel@tonic-gate 
4027c478bd9Sstevel@tonic-gate 	if (mp->map_flags & DDI_MF_DEVICE_MAPPING)
4037c478bd9Sstevel@tonic-gate 		return (0);
4047c478bd9Sstevel@tonic-gate 
4057c478bd9Sstevel@tonic-gate 	rp = mp->map_obj.rp;
4067c478bd9Sstevel@tonic-gate 	pgoffset = (uintptr_t)addr & MMU_PAGEOFFSET;
4077c478bd9Sstevel@tonic-gate 
4087c478bd9Sstevel@tonic-gate 	if (rp->regspec_size == 0) {
4097c478bd9Sstevel@tonic-gate 		DPRINTF(ROOTNEX_MAP_DEBUG, ("rootnex_unmap_regspec: "
4107c478bd9Sstevel@tonic-gate 		    "zero regspec_size\n"));
4117c478bd9Sstevel@tonic-gate 		return (DDI_ME_INVAL);
4127c478bd9Sstevel@tonic-gate 	}
4137c478bd9Sstevel@tonic-gate 
4147c478bd9Sstevel@tonic-gate 	base = addr - pgoffset;
4157c478bd9Sstevel@tonic-gate 	npages = mmu_btopr(rp->regspec_size + pgoffset);
4167c478bd9Sstevel@tonic-gate 	hat_unload(kas.a_hat, base, ptob(npages), HAT_UNLOAD_UNLOCK);
4177c478bd9Sstevel@tonic-gate 	vmem_free(rootnex_regspec_arena, base, ptob(npages));
4187c478bd9Sstevel@tonic-gate 
4197c478bd9Sstevel@tonic-gate 	/*
4207c478bd9Sstevel@tonic-gate 	 * Destroy the pointer - the mapping has logically gone
4217c478bd9Sstevel@tonic-gate 	 */
4227c478bd9Sstevel@tonic-gate 	*vaddrp = (caddr_t)0;
4237c478bd9Sstevel@tonic-gate 
4247c478bd9Sstevel@tonic-gate 	return (0);
4257c478bd9Sstevel@tonic-gate }
4267c478bd9Sstevel@tonic-gate 
4277c478bd9Sstevel@tonic-gate static int
4287c478bd9Sstevel@tonic-gate rootnex_map_handle(ddi_map_req_t *mp)
4297c478bd9Sstevel@tonic-gate {
4307c478bd9Sstevel@tonic-gate 	ddi_acc_hdl_t *hp;
4317c478bd9Sstevel@tonic-gate 	uint_t hat_flags;
4327c478bd9Sstevel@tonic-gate 	register struct regspec *rp;
4337c478bd9Sstevel@tonic-gate 
4347c478bd9Sstevel@tonic-gate 	/*
4357c478bd9Sstevel@tonic-gate 	 * Set up the hat_flags for the mapping.
4367c478bd9Sstevel@tonic-gate 	 */
4377c478bd9Sstevel@tonic-gate 	hp = mp->map_handlep;
4387c478bd9Sstevel@tonic-gate 
4397c478bd9Sstevel@tonic-gate 	switch (hp->ah_acc.devacc_attr_endian_flags) {
4407c478bd9Sstevel@tonic-gate 	case DDI_NEVERSWAP_ACC:
4417c478bd9Sstevel@tonic-gate 		hat_flags = HAT_NEVERSWAP | HAT_STRICTORDER;
4427c478bd9Sstevel@tonic-gate 		break;
4437c478bd9Sstevel@tonic-gate 	case DDI_STRUCTURE_BE_ACC:
4447c478bd9Sstevel@tonic-gate 		hat_flags = HAT_STRUCTURE_BE;
4457c478bd9Sstevel@tonic-gate 		break;
4467c478bd9Sstevel@tonic-gate 	case DDI_STRUCTURE_LE_ACC:
4477c478bd9Sstevel@tonic-gate 		hat_flags = HAT_STRUCTURE_LE;
4487c478bd9Sstevel@tonic-gate 		break;
4497c478bd9Sstevel@tonic-gate 	default:
4507c478bd9Sstevel@tonic-gate 		return (DDI_REGS_ACC_CONFLICT);
4517c478bd9Sstevel@tonic-gate 	}
4527c478bd9Sstevel@tonic-gate 
4537c478bd9Sstevel@tonic-gate 	switch (hp->ah_acc.devacc_attr_dataorder) {
4547c478bd9Sstevel@tonic-gate 	case DDI_STRICTORDER_ACC:
4557c478bd9Sstevel@tonic-gate 		break;
4567c478bd9Sstevel@tonic-gate 	case DDI_UNORDERED_OK_ACC:
4577c478bd9Sstevel@tonic-gate 		hat_flags |= HAT_UNORDERED_OK;
4587c478bd9Sstevel@tonic-gate 		break;
4597c478bd9Sstevel@tonic-gate 	case DDI_MERGING_OK_ACC:
4607c478bd9Sstevel@tonic-gate 		hat_flags |= HAT_MERGING_OK;
4617c478bd9Sstevel@tonic-gate 		break;
4627c478bd9Sstevel@tonic-gate 	case DDI_LOADCACHING_OK_ACC:
4637c478bd9Sstevel@tonic-gate 		hat_flags |= HAT_LOADCACHING_OK;
4647c478bd9Sstevel@tonic-gate 		break;
4657c478bd9Sstevel@tonic-gate 	case DDI_STORECACHING_OK_ACC:
4667c478bd9Sstevel@tonic-gate 		hat_flags |= HAT_STORECACHING_OK;
4677c478bd9Sstevel@tonic-gate 		break;
4687c478bd9Sstevel@tonic-gate 	default:
4697c478bd9Sstevel@tonic-gate 		return (DDI_FAILURE);
4707c478bd9Sstevel@tonic-gate 	}
4717c478bd9Sstevel@tonic-gate 
4727c478bd9Sstevel@tonic-gate 	rp = mp->map_obj.rp;
4737c478bd9Sstevel@tonic-gate 	if (rp->regspec_size == 0)
4747c478bd9Sstevel@tonic-gate 		return (DDI_ME_INVAL);
4757c478bd9Sstevel@tonic-gate 
4767c478bd9Sstevel@tonic-gate 	hp->ah_hat_flags = hat_flags;
4777c478bd9Sstevel@tonic-gate 	hp->ah_pfn = mmu_btop((ulong_t)rp->regspec_addr & (~MMU_PAGEOFFSET));
4787c478bd9Sstevel@tonic-gate 	hp->ah_pnum = mmu_btopr(rp->regspec_size +
4797c478bd9Sstevel@tonic-gate 	    (ulong_t)rp->regspec_addr & MMU_PAGEOFFSET);
4807c478bd9Sstevel@tonic-gate 	return (DDI_SUCCESS);
4817c478bd9Sstevel@tonic-gate }
4827c478bd9Sstevel@tonic-gate 
4837c478bd9Sstevel@tonic-gate static int
4847c478bd9Sstevel@tonic-gate rootnex_map(dev_info_t *dip, dev_info_t *rdip, ddi_map_req_t *mp,
4857c478bd9Sstevel@tonic-gate     off_t offset, off_t len, caddr_t *vaddrp)
4867c478bd9Sstevel@tonic-gate {
4877c478bd9Sstevel@tonic-gate 	struct regspec *rp, tmp_reg;
4887c478bd9Sstevel@tonic-gate 	ddi_map_req_t mr = *mp;		/* Get private copy of request */
4897c478bd9Sstevel@tonic-gate 	int error;
4907c478bd9Sstevel@tonic-gate 	uint_t mapping_attr;
4917c478bd9Sstevel@tonic-gate 	ddi_acc_hdl_t *hp = NULL;
4927c478bd9Sstevel@tonic-gate 
4937c478bd9Sstevel@tonic-gate 	mp = &mr;
4947c478bd9Sstevel@tonic-gate 
4957c478bd9Sstevel@tonic-gate 	switch (mp->map_op)  {
4967c478bd9Sstevel@tonic-gate 	case DDI_MO_MAP_LOCKED:
4977c478bd9Sstevel@tonic-gate 	case DDI_MO_UNMAP:
4987c478bd9Sstevel@tonic-gate 	case DDI_MO_MAP_HANDLE:
4997c478bd9Sstevel@tonic-gate 		break;
5007c478bd9Sstevel@tonic-gate 	default:
5017c478bd9Sstevel@tonic-gate 		DPRINTF(ROOTNEX_MAP_DEBUG, ("rootnex_map: unimplemented map "
5027c478bd9Sstevel@tonic-gate 		    "op %d.", mp->map_op));
5037c478bd9Sstevel@tonic-gate 		return (DDI_ME_UNIMPLEMENTED);
5047c478bd9Sstevel@tonic-gate 	}
5057c478bd9Sstevel@tonic-gate 
5067c478bd9Sstevel@tonic-gate 	if (mp->map_flags & DDI_MF_USER_MAPPING)  {
5077c478bd9Sstevel@tonic-gate 		DPRINTF(ROOTNEX_MAP_DEBUG, ("rootnex_map: unimplemented map "
5087c478bd9Sstevel@tonic-gate 		    "type: user."));
5097c478bd9Sstevel@tonic-gate 		return (DDI_ME_UNIMPLEMENTED);
5107c478bd9Sstevel@tonic-gate 	}
5117c478bd9Sstevel@tonic-gate 
5127c478bd9Sstevel@tonic-gate 	/*
5137c478bd9Sstevel@tonic-gate 	 * First, if given an rnumber, convert it to a regspec...
5147c478bd9Sstevel@tonic-gate 	 * (Presumably, this is on behalf of a child of the root node?)
5157c478bd9Sstevel@tonic-gate 	 */
5167c478bd9Sstevel@tonic-gate 
5177c478bd9Sstevel@tonic-gate 	if (mp->map_type == DDI_MT_RNUMBER)  {
5187c478bd9Sstevel@tonic-gate 
5197c478bd9Sstevel@tonic-gate 		int rnumber = mp->map_obj.rnumber;
5207c478bd9Sstevel@tonic-gate 
5217c478bd9Sstevel@tonic-gate 		rp = i_ddi_rnumber_to_regspec(rdip, rnumber);
5227c478bd9Sstevel@tonic-gate 		if (rp == (struct regspec *)0)  {
5237c478bd9Sstevel@tonic-gate 			DPRINTF(ROOTNEX_MAP_DEBUG, ("rootnex_map: Out of "
5247c478bd9Sstevel@tonic-gate 			    "range rnumber <%d>, device <%s>", rnumber,
5257c478bd9Sstevel@tonic-gate 			    ddi_get_name(rdip)));
5267c478bd9Sstevel@tonic-gate 			return (DDI_ME_RNUMBER_RANGE);
5277c478bd9Sstevel@tonic-gate 		}
5287c478bd9Sstevel@tonic-gate 
5297c478bd9Sstevel@tonic-gate 		/*
5307c478bd9Sstevel@tonic-gate 		 * Convert the given ddi_map_req_t from rnumber to regspec...
5317c478bd9Sstevel@tonic-gate 		 */
5327c478bd9Sstevel@tonic-gate 
5337c478bd9Sstevel@tonic-gate 		mp->map_type = DDI_MT_REGSPEC;
5347c478bd9Sstevel@tonic-gate 		mp->map_obj.rp = rp;
5357c478bd9Sstevel@tonic-gate 	}
5367c478bd9Sstevel@tonic-gate 
5377c478bd9Sstevel@tonic-gate 	/*
5387c478bd9Sstevel@tonic-gate 	 * Adjust offset and length corresponding to called values...
5397c478bd9Sstevel@tonic-gate 	 * XXX: A non-zero length means override the one in the regspec
5407c478bd9Sstevel@tonic-gate 	 * XXX: regardless of what's in the parent's range?.
5417c478bd9Sstevel@tonic-gate 	 */
5427c478bd9Sstevel@tonic-gate 
5437c478bd9Sstevel@tonic-gate 	tmp_reg = *(mp->map_obj.rp);		/* Preserve underlying data */
5447c478bd9Sstevel@tonic-gate 	rp = mp->map_obj.rp = &tmp_reg;		/* Use tmp_reg in request */
5457c478bd9Sstevel@tonic-gate 
5467c478bd9Sstevel@tonic-gate 	rp->regspec_addr += (uint_t)offset;
5477c478bd9Sstevel@tonic-gate 	if (len != 0)
5487c478bd9Sstevel@tonic-gate 		rp->regspec_size = (uint_t)len;
5497c478bd9Sstevel@tonic-gate 
5507c478bd9Sstevel@tonic-gate 	/*
5517c478bd9Sstevel@tonic-gate 	 * Apply any parent ranges at this level, if applicable.
5527c478bd9Sstevel@tonic-gate 	 * (This is where nexus specific regspec translation takes place.
5537c478bd9Sstevel@tonic-gate 	 * Use of this function is implicit agreement that translation is
5547c478bd9Sstevel@tonic-gate 	 * provided via ddi_apply_range.)
5557c478bd9Sstevel@tonic-gate 	 */
5567c478bd9Sstevel@tonic-gate 
5577c478bd9Sstevel@tonic-gate 	DPRINTF(ROOTNEX_MAP_DEBUG, ("rootnex_map: applying range of parent "
5587c478bd9Sstevel@tonic-gate 	    "<%s> to child <%s>...\n", ddi_get_name(dip), ddi_get_name(rdip)));
5597c478bd9Sstevel@tonic-gate 
5607c478bd9Sstevel@tonic-gate 	if ((error = i_ddi_apply_range(dip, rdip, mp->map_obj.rp)) != 0)
5617c478bd9Sstevel@tonic-gate 		return (error);
5627c478bd9Sstevel@tonic-gate 
5637c478bd9Sstevel@tonic-gate 	switch (mp->map_op)  {
5647c478bd9Sstevel@tonic-gate 	case DDI_MO_MAP_LOCKED:
5657c478bd9Sstevel@tonic-gate 
5667c478bd9Sstevel@tonic-gate 		/*
5677c478bd9Sstevel@tonic-gate 		 * Set up the locked down kernel mapping to the regspec...
5687c478bd9Sstevel@tonic-gate 		 */
5697c478bd9Sstevel@tonic-gate 
5707c478bd9Sstevel@tonic-gate 		/*
5717c478bd9Sstevel@tonic-gate 		 * If we were passed an access handle we need to determine
5727c478bd9Sstevel@tonic-gate 		 * the "endian-ness" of the mapping and fill in the handle.
5737c478bd9Sstevel@tonic-gate 		 */
5747c478bd9Sstevel@tonic-gate 		if (mp->map_handlep) {
5757c478bd9Sstevel@tonic-gate 			hp = mp->map_handlep;
5767c478bd9Sstevel@tonic-gate 			switch (hp->ah_acc.devacc_attr_endian_flags) {
5777c478bd9Sstevel@tonic-gate 			case DDI_NEVERSWAP_ACC:
5787c478bd9Sstevel@tonic-gate 				mapping_attr = HAT_NEVERSWAP | HAT_STRICTORDER;
5797c478bd9Sstevel@tonic-gate 				break;
5807c478bd9Sstevel@tonic-gate 			case DDI_STRUCTURE_BE_ACC:
5817c478bd9Sstevel@tonic-gate 				mapping_attr = HAT_STRUCTURE_BE;
5827c478bd9Sstevel@tonic-gate 				break;
5837c478bd9Sstevel@tonic-gate 			case DDI_STRUCTURE_LE_ACC:
5847c478bd9Sstevel@tonic-gate 				mapping_attr = HAT_STRUCTURE_LE;
5857c478bd9Sstevel@tonic-gate 				break;
5867c478bd9Sstevel@tonic-gate 			default:
5877c478bd9Sstevel@tonic-gate 				return (DDI_REGS_ACC_CONFLICT);
5887c478bd9Sstevel@tonic-gate 			}
5897c478bd9Sstevel@tonic-gate 
5907c478bd9Sstevel@tonic-gate 			switch (hp->ah_acc.devacc_attr_dataorder) {
5917c478bd9Sstevel@tonic-gate 			case DDI_STRICTORDER_ACC:
5927c478bd9Sstevel@tonic-gate 				break;
5937c478bd9Sstevel@tonic-gate 			case DDI_UNORDERED_OK_ACC:
5947c478bd9Sstevel@tonic-gate 				mapping_attr |= HAT_UNORDERED_OK;
5957c478bd9Sstevel@tonic-gate 				break;
5967c478bd9Sstevel@tonic-gate 			case DDI_MERGING_OK_ACC:
5977c478bd9Sstevel@tonic-gate 				mapping_attr |= HAT_MERGING_OK;
5987c478bd9Sstevel@tonic-gate 				break;
5997c478bd9Sstevel@tonic-gate 			case DDI_LOADCACHING_OK_ACC:
6007c478bd9Sstevel@tonic-gate 				mapping_attr |= HAT_LOADCACHING_OK;
6017c478bd9Sstevel@tonic-gate 				break;
6027c478bd9Sstevel@tonic-gate 			case DDI_STORECACHING_OK_ACC:
6037c478bd9Sstevel@tonic-gate 				mapping_attr |= HAT_STORECACHING_OK;
6047c478bd9Sstevel@tonic-gate 				break;
6057c478bd9Sstevel@tonic-gate 			default:
6067c478bd9Sstevel@tonic-gate 				return (DDI_REGS_ACC_CONFLICT);
6077c478bd9Sstevel@tonic-gate 			}
6087c478bd9Sstevel@tonic-gate 		} else {
6097c478bd9Sstevel@tonic-gate 			mapping_attr = HAT_NEVERSWAP | HAT_STRICTORDER;
6107c478bd9Sstevel@tonic-gate 		}
6117c478bd9Sstevel@tonic-gate 
6127c478bd9Sstevel@tonic-gate 		/*
6137c478bd9Sstevel@tonic-gate 		 * Set up the mapping.
6147c478bd9Sstevel@tonic-gate 		 */
6157c478bd9Sstevel@tonic-gate 		error = rootnex_map_regspec(mp, vaddrp, mapping_attr);
6167c478bd9Sstevel@tonic-gate 
6177c478bd9Sstevel@tonic-gate 		/*
6187c478bd9Sstevel@tonic-gate 		 * Fill in the access handle if needed.
6197c478bd9Sstevel@tonic-gate 		 */
6207c478bd9Sstevel@tonic-gate 		if (hp) {
6217c478bd9Sstevel@tonic-gate 			hp->ah_addr = *vaddrp;
6227c478bd9Sstevel@tonic-gate 			hp->ah_hat_flags = mapping_attr;
6237c478bd9Sstevel@tonic-gate 			if (error == 0)
6247c478bd9Sstevel@tonic-gate 				impl_acc_hdl_init(hp);
6257c478bd9Sstevel@tonic-gate 		}
6267c478bd9Sstevel@tonic-gate 		return (error);
6277c478bd9Sstevel@tonic-gate 
6287c478bd9Sstevel@tonic-gate 	case DDI_MO_UNMAP:
6297c478bd9Sstevel@tonic-gate 
6307c478bd9Sstevel@tonic-gate 		/*
6317c478bd9Sstevel@tonic-gate 		 * Release mapping...
6327c478bd9Sstevel@tonic-gate 		 */
6337c478bd9Sstevel@tonic-gate 
6347c478bd9Sstevel@tonic-gate 		return (rootnex_unmap_regspec(mp, vaddrp));
6357c478bd9Sstevel@tonic-gate 
6367c478bd9Sstevel@tonic-gate 	case DDI_MO_MAP_HANDLE:
6377c478bd9Sstevel@tonic-gate 		return (rootnex_map_handle(mp));
6387c478bd9Sstevel@tonic-gate 
6397c478bd9Sstevel@tonic-gate 	}
6407c478bd9Sstevel@tonic-gate 
6417c478bd9Sstevel@tonic-gate 	return (DDI_ME_UNIMPLEMENTED);
6427c478bd9Sstevel@tonic-gate }
6437c478bd9Sstevel@tonic-gate 
6447c478bd9Sstevel@tonic-gate static int
6457c478bd9Sstevel@tonic-gate rootnex_intr_ops(dev_info_t *dip, dev_info_t *rdip, ddi_intr_op_t intr_op,
6467c478bd9Sstevel@tonic-gate     ddi_intr_handle_impl_t *hdlp, void *result)
6477c478bd9Sstevel@tonic-gate {
6487c478bd9Sstevel@tonic-gate 	int	ret = DDI_SUCCESS;
6497c478bd9Sstevel@tonic-gate 
6507c478bd9Sstevel@tonic-gate 	DPRINTF(ROOTNEX_INTR_DEBUG, ("rootnex_intr_ops: rdip=%s%d "
6517c478bd9Sstevel@tonic-gate 	    "intr_op 0x%x hdlp 0x%p\n", ddi_driver_name(rdip),
6527c478bd9Sstevel@tonic-gate 	    ddi_get_instance(rdip), intr_op, hdlp));
6537c478bd9Sstevel@tonic-gate 
6547c478bd9Sstevel@tonic-gate 	switch (intr_op) {
6557c478bd9Sstevel@tonic-gate 	case DDI_INTROP_GETCAP:
656*a195726fSgovinda 		*(int *)result = DDI_INTR_FLAG_LEVEL;
6577c478bd9Sstevel@tonic-gate 		break;
6587c478bd9Sstevel@tonic-gate 	case DDI_INTROP_SETCAP:
6597c478bd9Sstevel@tonic-gate 		ret = DDI_ENOTSUP;
6607c478bd9Sstevel@tonic-gate 		break;
6617c478bd9Sstevel@tonic-gate 	case DDI_INTROP_ALLOC:
6627c478bd9Sstevel@tonic-gate 		*(int *)result = hdlp->ih_scratch1;
6637c478bd9Sstevel@tonic-gate 		break;
6647c478bd9Sstevel@tonic-gate 	case DDI_INTROP_FREE:
6657c478bd9Sstevel@tonic-gate 		break;
6667c478bd9Sstevel@tonic-gate 	case DDI_INTROP_GETPRI:
667*a195726fSgovinda 		*(int *)result = rootnex_get_intr_pri(dip, rdip, hdlp);
6687c478bd9Sstevel@tonic-gate 		break;
6697c478bd9Sstevel@tonic-gate 	case DDI_INTROP_SETPRI:
6707c478bd9Sstevel@tonic-gate 		break;
6717c478bd9Sstevel@tonic-gate 	case DDI_INTROP_ADDISR:
6727c478bd9Sstevel@tonic-gate 		ret = rootnex_add_intr_impl(dip, rdip, hdlp);
6737c478bd9Sstevel@tonic-gate 		break;
6747c478bd9Sstevel@tonic-gate 	case DDI_INTROP_REMISR:
6757c478bd9Sstevel@tonic-gate 		ret = rootnex_remove_intr_impl(dip, rdip, hdlp);
6767c478bd9Sstevel@tonic-gate 		break;
6777c478bd9Sstevel@tonic-gate 	case DDI_INTROP_ENABLE:
6787c478bd9Sstevel@tonic-gate 	case DDI_INTROP_DISABLE:
6797c478bd9Sstevel@tonic-gate 		break;
6807c478bd9Sstevel@tonic-gate 	case DDI_INTROP_NINTRS:
6817c478bd9Sstevel@tonic-gate 	case DDI_INTROP_NAVAIL:
6827c478bd9Sstevel@tonic-gate 		*(int *)result = i_ddi_get_nintrs(rdip);
6837c478bd9Sstevel@tonic-gate 		break;
6847c478bd9Sstevel@tonic-gate 	case DDI_INTROP_SUPPORTED_TYPES:
6857c478bd9Sstevel@tonic-gate 		/* Root nexus driver supports only fixed interrupts */
6867c478bd9Sstevel@tonic-gate 		*(int *)result = i_ddi_get_nintrs(rdip) ?
6877c478bd9Sstevel@tonic-gate 		    DDI_INTR_TYPE_FIXED : 0;
6887c478bd9Sstevel@tonic-gate 		break;
6897c478bd9Sstevel@tonic-gate 	default:
6907c478bd9Sstevel@tonic-gate 		ret = DDI_ENOTSUP;
6917c478bd9Sstevel@tonic-gate 		break;
6927c478bd9Sstevel@tonic-gate 	}
6937c478bd9Sstevel@tonic-gate 
6947c478bd9Sstevel@tonic-gate 	return (ret);
6957c478bd9Sstevel@tonic-gate }
6967c478bd9Sstevel@tonic-gate 
6977c478bd9Sstevel@tonic-gate 
6987c478bd9Sstevel@tonic-gate /*
6997c478bd9Sstevel@tonic-gate  * Shorthand defines
7007c478bd9Sstevel@tonic-gate  */
7017c478bd9Sstevel@tonic-gate 
7027c478bd9Sstevel@tonic-gate #define	DMAOBJ_PP_PP	dmao_obj.pp_obj.pp_pp
7037c478bd9Sstevel@tonic-gate #define	DMAOBJ_PP_OFF	dmao_ogj.pp_obj.pp_offset
7047c478bd9Sstevel@tonic-gate #define	ALO		dma_lim->dlim_addr_lo
7057c478bd9Sstevel@tonic-gate #define	AHI		dma_lim->dlim_addr_hi
7067c478bd9Sstevel@tonic-gate #define	OBJSIZE		dmareq->dmar_object.dmao_size
7077c478bd9Sstevel@tonic-gate #define	ORIGVADDR	dmareq->dmar_object.dmao_obj.virt_obj.v_addr
7087c478bd9Sstevel@tonic-gate #define	RED		((mp->dmai_rflags & DDI_DMA_REDZONE)? 1 : 0)
7097c478bd9Sstevel@tonic-gate #define	DIRECTION	(mp->dmai_rflags & DDI_DMA_RDWR)
7107c478bd9Sstevel@tonic-gate 
7117c478bd9Sstevel@tonic-gate /*
7127c478bd9Sstevel@tonic-gate  * rootnex_map_fault:
7137c478bd9Sstevel@tonic-gate  *
7147c478bd9Sstevel@tonic-gate  *	fault in mappings for requestors
7157c478bd9Sstevel@tonic-gate  */
7167c478bd9Sstevel@tonic-gate 
7177c478bd9Sstevel@tonic-gate /*ARGSUSED*/
7187c478bd9Sstevel@tonic-gate static int
7197c478bd9Sstevel@tonic-gate rootnex_map_fault(dev_info_t *dip, dev_info_t *rdip,
7207c478bd9Sstevel@tonic-gate     struct hat *hat, struct seg *seg, caddr_t addr,
7217c478bd9Sstevel@tonic-gate     struct devpage *dp, pfn_t pfn, uint_t prot, uint_t lock)
7227c478bd9Sstevel@tonic-gate {
7237c478bd9Sstevel@tonic-gate 	extern struct seg_ops segdev_ops;
7247c478bd9Sstevel@tonic-gate 
72502e56f3fSwesolows 	DPRINTF(ROOTNEX_MAP_DEBUG, ("rootnex_map_fault: address <%p> "
72602e56f3fSwesolows 	    "pfn <%lx>", addr, pfn));
7277c478bd9Sstevel@tonic-gate 	DPRINTF(ROOTNEX_MAP_DEBUG, (" Seg <%s>\n",
7287c478bd9Sstevel@tonic-gate 	    seg->s_ops == &segdev_ops ? "segdev" :
7297c478bd9Sstevel@tonic-gate 	    seg == &kvseg ? "segkmem" : "NONE!"));
7307c478bd9Sstevel@tonic-gate 
7317c478bd9Sstevel@tonic-gate 	/*
7327c478bd9Sstevel@tonic-gate 	 * This is all terribly broken, but it is a start
7337c478bd9Sstevel@tonic-gate 	 *
7347c478bd9Sstevel@tonic-gate 	 * XXX	Note that this test means that segdev_ops
7357c478bd9Sstevel@tonic-gate 	 *	must be exported from seg_dev.c.
7367c478bd9Sstevel@tonic-gate 	 * XXX	What about devices with their own segment drivers?
7377c478bd9Sstevel@tonic-gate 	 */
7387c478bd9Sstevel@tonic-gate 	if (seg->s_ops == &segdev_ops) {
7397c478bd9Sstevel@tonic-gate 		register struct segdev_data *sdp =
7407c478bd9Sstevel@tonic-gate 		    (struct segdev_data *)seg->s_data;
7417c478bd9Sstevel@tonic-gate 
7427c478bd9Sstevel@tonic-gate 		if (hat == NULL) {
7437c478bd9Sstevel@tonic-gate 			/*
7447c478bd9Sstevel@tonic-gate 			 * This is one plausible interpretation of
7457c478bd9Sstevel@tonic-gate 			 * a null hat i.e. use the first hat on the
7467c478bd9Sstevel@tonic-gate 			 * address space hat list which by convention is
7477c478bd9Sstevel@tonic-gate 			 * the hat of the system MMU.  At alternative
7487c478bd9Sstevel@tonic-gate 			 * would be to panic .. this might well be better ..
7497c478bd9Sstevel@tonic-gate 			 */
7507c478bd9Sstevel@tonic-gate 			ASSERT(AS_READ_HELD(seg->s_as, &seg->s_as->a_lock));
7517c478bd9Sstevel@tonic-gate 			hat = seg->s_as->a_hat;
7527c478bd9Sstevel@tonic-gate 			cmn_err(CE_NOTE, "rootnex_map_fault: nil hat");
7537c478bd9Sstevel@tonic-gate 		}
7547c478bd9Sstevel@tonic-gate 		hat_devload(hat, addr, MMU_PAGESIZE, pfn, prot | sdp->hat_attr,
7557c478bd9Sstevel@tonic-gate 		    (lock ? HAT_LOAD_LOCK : HAT_LOAD));
7567c478bd9Sstevel@tonic-gate 	} else if (seg == &kvseg && dp == (struct devpage *)0) {
7577c478bd9Sstevel@tonic-gate 		hat_devload(kas.a_hat, addr, MMU_PAGESIZE, pfn, prot,
7587c478bd9Sstevel@tonic-gate 		    HAT_LOAD_LOCK);
7597c478bd9Sstevel@tonic-gate 	} else
7607c478bd9Sstevel@tonic-gate 		return (DDI_FAILURE);
7617c478bd9Sstevel@tonic-gate 	return (DDI_SUCCESS);
7627c478bd9Sstevel@tonic-gate }
7637c478bd9Sstevel@tonic-gate 
7647c478bd9Sstevel@tonic-gate /*
7657c478bd9Sstevel@tonic-gate  * Name a child of rootnex
7667c478bd9Sstevel@tonic-gate  *
7677c478bd9Sstevel@tonic-gate  * This may be called multiple times, independent of initchild calls.
7687c478bd9Sstevel@tonic-gate  */
7697c478bd9Sstevel@tonic-gate int
7707c478bd9Sstevel@tonic-gate rootnex_name_child(dev_info_t *child, char *name, int namelen)
7717c478bd9Sstevel@tonic-gate {
7727c478bd9Sstevel@tonic-gate 	return (rootnex_name_child_impl(child, name, namelen));
7737c478bd9Sstevel@tonic-gate }
7747c478bd9Sstevel@tonic-gate 
7757c478bd9Sstevel@tonic-gate 
7767c478bd9Sstevel@tonic-gate static int
7777c478bd9Sstevel@tonic-gate rootnex_ctl_initchild(dev_info_t *dip)
7787c478bd9Sstevel@tonic-gate {
7797c478bd9Sstevel@tonic-gate 	return (rootnex_ctl_initchild_impl(dip));
7807c478bd9Sstevel@tonic-gate }
7817c478bd9Sstevel@tonic-gate 
7827c478bd9Sstevel@tonic-gate 
7837c478bd9Sstevel@tonic-gate int
7847c478bd9Sstevel@tonic-gate rootnex_ctl_uninitchild(dev_info_t *dip)
7857c478bd9Sstevel@tonic-gate {
7867c478bd9Sstevel@tonic-gate 	extern void impl_free_ddi_ppd(dev_info_t *);
7877c478bd9Sstevel@tonic-gate 
7887c478bd9Sstevel@tonic-gate 	rootnex_ctl_uninitchild_impl(dip);
7897c478bd9Sstevel@tonic-gate 
7907c478bd9Sstevel@tonic-gate 	/*
7917c478bd9Sstevel@tonic-gate 	 * strip properties and convert node to prototype form
7927c478bd9Sstevel@tonic-gate 	 */
7937c478bd9Sstevel@tonic-gate 	impl_free_ddi_ppd(dip);
7947c478bd9Sstevel@tonic-gate 	ddi_set_name_addr(dip, NULL);
7957c478bd9Sstevel@tonic-gate 	impl_rem_dev_props(dip);
7967c478bd9Sstevel@tonic-gate 	return (DDI_SUCCESS);
7977c478bd9Sstevel@tonic-gate }
7987c478bd9Sstevel@tonic-gate 
7997c478bd9Sstevel@tonic-gate 
8007c478bd9Sstevel@tonic-gate static int
8017c478bd9Sstevel@tonic-gate rootnex_ctl_reportdev(dev_info_t *dev)
8027c478bd9Sstevel@tonic-gate {
8037c478bd9Sstevel@tonic-gate 	return (rootnex_ctl_reportdev_impl(dev));
8047c478bd9Sstevel@tonic-gate }
8057c478bd9Sstevel@tonic-gate 
8067c478bd9Sstevel@tonic-gate 
8077c478bd9Sstevel@tonic-gate static int
8087c478bd9Sstevel@tonic-gate rootnex_ctlops_peekpoke(ddi_ctl_enum_t cmd, peekpoke_ctlops_t *in_args,
8097c478bd9Sstevel@tonic-gate     void *result)
8107c478bd9Sstevel@tonic-gate {
8117c478bd9Sstevel@tonic-gate 	int err = DDI_SUCCESS;
8127c478bd9Sstevel@tonic-gate 	on_trap_data_t otd;
8137c478bd9Sstevel@tonic-gate 
8147c478bd9Sstevel@tonic-gate 	/* No safe access except for peek/poke is supported. */
8157c478bd9Sstevel@tonic-gate 	if (in_args->handle != NULL)
8167c478bd9Sstevel@tonic-gate 		return (DDI_FAILURE);
8177c478bd9Sstevel@tonic-gate 
8187c478bd9Sstevel@tonic-gate 	/* Set up protected environment. */
8197c478bd9Sstevel@tonic-gate 	if (!on_trap(&otd, OT_DATA_ACCESS)) {
8207c478bd9Sstevel@tonic-gate 		uintptr_t tramp = otd.ot_trampoline;
8217c478bd9Sstevel@tonic-gate 
8227c478bd9Sstevel@tonic-gate 		if (cmd == DDI_CTLOPS_POKE) {
8237c478bd9Sstevel@tonic-gate 			otd.ot_trampoline = (uintptr_t)&poke_fault;
8247c478bd9Sstevel@tonic-gate 			err = do_poke(in_args->size, (void *)in_args->dev_addr,
8257c478bd9Sstevel@tonic-gate 			    (void *)in_args->host_addr);
8267c478bd9Sstevel@tonic-gate 		} else {
8277c478bd9Sstevel@tonic-gate 			otd.ot_trampoline = (uintptr_t)&peek_fault;
8287c478bd9Sstevel@tonic-gate 			err = do_peek(in_args->size, (void *)in_args->dev_addr,
8297c478bd9Sstevel@tonic-gate 			    (void *)in_args->host_addr);
8307c478bd9Sstevel@tonic-gate 			result = (void *)in_args->host_addr;
8317c478bd9Sstevel@tonic-gate 		}
8327c478bd9Sstevel@tonic-gate 		otd.ot_trampoline = tramp;
8337c478bd9Sstevel@tonic-gate 	} else
8347c478bd9Sstevel@tonic-gate 		err = DDI_FAILURE;
8357c478bd9Sstevel@tonic-gate 
8367c478bd9Sstevel@tonic-gate 	/* Take down protected environment. */
8377c478bd9Sstevel@tonic-gate 	no_trap();
8387c478bd9Sstevel@tonic-gate 
8397c478bd9Sstevel@tonic-gate 	return (err);
8407c478bd9Sstevel@tonic-gate }
8417c478bd9Sstevel@tonic-gate 
8427c478bd9Sstevel@tonic-gate /*ARGSUSED*/
8437c478bd9Sstevel@tonic-gate static int
8447c478bd9Sstevel@tonic-gate rootnex_ctlops(dev_info_t *dip, dev_info_t *rdip,
8457c478bd9Sstevel@tonic-gate     ddi_ctl_enum_t ctlop, void *arg, void *result)
8467c478bd9Sstevel@tonic-gate {
8477c478bd9Sstevel@tonic-gate 	register int n, *ptr;
8487c478bd9Sstevel@tonic-gate 	register struct ddi_parent_private_data *pdp;
8497c478bd9Sstevel@tonic-gate 
8507c478bd9Sstevel@tonic-gate 	static boolean_t reserved_msg_printed = B_FALSE;
8517c478bd9Sstevel@tonic-gate 
8527c478bd9Sstevel@tonic-gate 	switch (ctlop) {
8537c478bd9Sstevel@tonic-gate 	case DDI_CTLOPS_DMAPMAPC:
8547c478bd9Sstevel@tonic-gate 		return (DDI_FAILURE);
8557c478bd9Sstevel@tonic-gate 
8567c478bd9Sstevel@tonic-gate 	case DDI_CTLOPS_BTOP:
8577c478bd9Sstevel@tonic-gate 		/*
8587c478bd9Sstevel@tonic-gate 		 * Convert byte count input to physical page units.
8597c478bd9Sstevel@tonic-gate 		 * (byte counts that are not a page-size multiple
8607c478bd9Sstevel@tonic-gate 		 * are rounded down)
8617c478bd9Sstevel@tonic-gate 		 */
8627c478bd9Sstevel@tonic-gate 		*(ulong_t *)result = btop(*(ulong_t *)arg);
8637c478bd9Sstevel@tonic-gate 		return (DDI_SUCCESS);
8647c478bd9Sstevel@tonic-gate 
8657c478bd9Sstevel@tonic-gate 	case DDI_CTLOPS_PTOB:
8667c478bd9Sstevel@tonic-gate 		/*
8677c478bd9Sstevel@tonic-gate 		 * Convert size in physical pages to bytes
8687c478bd9Sstevel@tonic-gate 		 */
8697c478bd9Sstevel@tonic-gate 		*(ulong_t *)result = ptob(*(ulong_t *)arg);
8707c478bd9Sstevel@tonic-gate 		return (DDI_SUCCESS);
8717c478bd9Sstevel@tonic-gate 
8727c478bd9Sstevel@tonic-gate 	case DDI_CTLOPS_BTOPR:
8737c478bd9Sstevel@tonic-gate 		/*
8747c478bd9Sstevel@tonic-gate 		 * Convert byte count input to physical page units
8757c478bd9Sstevel@tonic-gate 		 * (byte counts that are not a page-size multiple
8767c478bd9Sstevel@tonic-gate 		 * are rounded up)
8777c478bd9Sstevel@tonic-gate 		 */
8787c478bd9Sstevel@tonic-gate 		*(ulong_t *)result = btopr(*(ulong_t *)arg);
8797c478bd9Sstevel@tonic-gate 		return (DDI_SUCCESS);
8807c478bd9Sstevel@tonic-gate 
8817c478bd9Sstevel@tonic-gate 	case DDI_CTLOPS_INITCHILD:
8827c478bd9Sstevel@tonic-gate 		return (rootnex_ctl_initchild((dev_info_t *)arg));
8837c478bd9Sstevel@tonic-gate 
8847c478bd9Sstevel@tonic-gate 	case DDI_CTLOPS_UNINITCHILD:
8857c478bd9Sstevel@tonic-gate 		return (rootnex_ctl_uninitchild((dev_info_t *)arg));
8867c478bd9Sstevel@tonic-gate 
8877c478bd9Sstevel@tonic-gate 	case DDI_CTLOPS_REPORTDEV:
8887c478bd9Sstevel@tonic-gate 		return (rootnex_ctl_reportdev(rdip));
8897c478bd9Sstevel@tonic-gate 
8907c478bd9Sstevel@tonic-gate 	case DDI_CTLOPS_IOMIN:
8917c478bd9Sstevel@tonic-gate 		/*
8927c478bd9Sstevel@tonic-gate 		 * Nothing to do here but reflect back..
8937c478bd9Sstevel@tonic-gate 		 */
8947c478bd9Sstevel@tonic-gate 		return (DDI_SUCCESS);
8957c478bd9Sstevel@tonic-gate 
8967c478bd9Sstevel@tonic-gate 	case DDI_CTLOPS_REGSIZE:
8977c478bd9Sstevel@tonic-gate 	case DDI_CTLOPS_NREGS:
8987c478bd9Sstevel@tonic-gate 		break;
8997c478bd9Sstevel@tonic-gate 
9007c478bd9Sstevel@tonic-gate 	case DDI_CTLOPS_SIDDEV:
9017c478bd9Sstevel@tonic-gate 		if (ndi_dev_is_prom_node(rdip))
9027c478bd9Sstevel@tonic-gate 			return (DDI_SUCCESS);
9037c478bd9Sstevel@tonic-gate 		if (ndi_dev_is_persistent_node(rdip))
9047c478bd9Sstevel@tonic-gate 			return (DDI_SUCCESS);
9057c478bd9Sstevel@tonic-gate 		return (DDI_FAILURE);
9067c478bd9Sstevel@tonic-gate 
9077c478bd9Sstevel@tonic-gate 	case DDI_CTLOPS_POWER: {
9087c478bd9Sstevel@tonic-gate 		return ((*pm_platform_power)((power_req_t *)arg));
9097c478bd9Sstevel@tonic-gate 	}
9107c478bd9Sstevel@tonic-gate 
911*a195726fSgovinda 	case DDI_CTLOPS_RESERVED0: /* Was DDI_CTLOPS_NINTRS, obsolete */
9127c478bd9Sstevel@tonic-gate 	case DDI_CTLOPS_RESERVED1: /* Was DDI_CTLOPS_POKE_INIT, obsolete */
9137c478bd9Sstevel@tonic-gate 	case DDI_CTLOPS_RESERVED2: /* Was DDI_CTLOPS_POKE_FLUSH, obsolete */
9147c478bd9Sstevel@tonic-gate 	case DDI_CTLOPS_RESERVED3: /* Was DDI_CTLOPS_POKE_FINI, obsolete */
915*a195726fSgovinda 	case DDI_CTLOPS_RESERVED4: /* Was DDI_CTLOPS_INTR_HILEVEL, obsolete */
916*a195726fSgovinda 	case DDI_CTLOPS_RESERVED5: /* Was DDI_CTLOPS_XLATE_INTRS, obsolete */
9177c478bd9Sstevel@tonic-gate 		if (!reserved_msg_printed) {
9187c478bd9Sstevel@tonic-gate 			reserved_msg_printed = B_TRUE;
9197c478bd9Sstevel@tonic-gate 			cmn_err(CE_WARN, "Failing ddi_ctlops call(s) for "
9207c478bd9Sstevel@tonic-gate 			    "1 or more reserved/obsolete operations.");
9217c478bd9Sstevel@tonic-gate 		}
9227c478bd9Sstevel@tonic-gate 		return (DDI_FAILURE);
9237c478bd9Sstevel@tonic-gate 
9247c478bd9Sstevel@tonic-gate 	case DDI_CTLOPS_POKE:
9257c478bd9Sstevel@tonic-gate 	case DDI_CTLOPS_PEEK:
9267c478bd9Sstevel@tonic-gate 		return (rootnex_ctlops_peekpoke(ctlop, (peekpoke_ctlops_t *)arg,
9277c478bd9Sstevel@tonic-gate 		    result));
9287c478bd9Sstevel@tonic-gate 
9297c478bd9Sstevel@tonic-gate 	default:
9307c478bd9Sstevel@tonic-gate 		return (DDI_FAILURE);
9317c478bd9Sstevel@tonic-gate 	}
9327c478bd9Sstevel@tonic-gate 
9337c478bd9Sstevel@tonic-gate 	/*
9347c478bd9Sstevel@tonic-gate 	 * The rest are for "hardware" properties
9357c478bd9Sstevel@tonic-gate 	 */
9367c478bd9Sstevel@tonic-gate 	if ((pdp = ddi_get_parent_data(rdip)) == NULL)
9377c478bd9Sstevel@tonic-gate 		return (DDI_FAILURE);
9387c478bd9Sstevel@tonic-gate 
9397c478bd9Sstevel@tonic-gate 	if (ctlop == DDI_CTLOPS_NREGS) {
9407c478bd9Sstevel@tonic-gate 		ptr = (int *)result;
9417c478bd9Sstevel@tonic-gate 		*ptr = pdp->par_nreg;
9427c478bd9Sstevel@tonic-gate 	} else {	/* ctlop == DDI_CTLOPS_REGSIZE */
9437c478bd9Sstevel@tonic-gate 		off_t *size = (off_t *)result;
9447c478bd9Sstevel@tonic-gate 
9457c478bd9Sstevel@tonic-gate 		ptr = (int *)arg;
9467c478bd9Sstevel@tonic-gate 		n = *ptr;
9477c478bd9Sstevel@tonic-gate 		if (n >= pdp->par_nreg) {
9487c478bd9Sstevel@tonic-gate 			return (DDI_FAILURE);
9497c478bd9Sstevel@tonic-gate 		}
9507c478bd9Sstevel@tonic-gate 		*size = (off_t)pdp->par_reg[n].regspec_size;
9517c478bd9Sstevel@tonic-gate 	}
9527c478bd9Sstevel@tonic-gate 	return (DDI_SUCCESS);
9537c478bd9Sstevel@tonic-gate }
9547c478bd9Sstevel@tonic-gate 
9557c478bd9Sstevel@tonic-gate /* ARGSUSED */
9567c478bd9Sstevel@tonic-gate int
9577c478bd9Sstevel@tonic-gate rootnex_busop_fminit(dev_info_t *dip, dev_info_t *tdip, int cap,
9587c478bd9Sstevel@tonic-gate     ddi_iblock_cookie_t *ibc)
9597c478bd9Sstevel@tonic-gate {
9607c478bd9Sstevel@tonic-gate 	*ibc = rootnex_err_ibc;
9617c478bd9Sstevel@tonic-gate 	return (ddi_system_fmcap | DDI_FM_ACCCHK_CAPABLE |
9627c478bd9Sstevel@tonic-gate 	    DDI_FM_DMACHK_CAPABLE);
9637c478bd9Sstevel@tonic-gate }
9647c478bd9Sstevel@tonic-gate 
9657c478bd9Sstevel@tonic-gate static void
9667c478bd9Sstevel@tonic-gate rootnex_fm_init(dev_info_t *dip)
9677c478bd9Sstevel@tonic-gate {
9687c478bd9Sstevel@tonic-gate 	int fmcap;
9697c478bd9Sstevel@tonic-gate 
9707c478bd9Sstevel@tonic-gate 	/* Minimum fm capability level for sun4u platforms */
9717c478bd9Sstevel@tonic-gate 	ddi_system_fmcap = DDI_FM_EREPORT_CAPABLE | DDI_FM_ERRCB_CAPABLE;
9727c478bd9Sstevel@tonic-gate 
9737c478bd9Sstevel@tonic-gate 	fmcap = ddi_system_fmcap;
9747c478bd9Sstevel@tonic-gate 
9757c478bd9Sstevel@tonic-gate 	/*
9767c478bd9Sstevel@tonic-gate 	 * Initialize ECC error handling
9777c478bd9Sstevel@tonic-gate 	 */
9787c478bd9Sstevel@tonic-gate 	rootnex_err_ibc = (ddi_iblock_cookie_t)PIL_15;
9797c478bd9Sstevel@tonic-gate 	ddi_fm_init(dip, &fmcap, &rootnex_err_ibc);
9807c478bd9Sstevel@tonic-gate }
981