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