10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 51961Scth * Common Development and Distribution License (the "License"). 61961Scth * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*12825SJimmy.Vetayases@oracle.com * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. 230Sstevel@tonic-gate */ 240Sstevel@tonic-gate 250Sstevel@tonic-gate #ifndef _SYS_SUNNDI_H 260Sstevel@tonic-gate #define _SYS_SUNNDI_H 270Sstevel@tonic-gate 280Sstevel@tonic-gate /* 290Sstevel@tonic-gate * Sun Specific NDI definitions 300Sstevel@tonic-gate */ 310Sstevel@tonic-gate 320Sstevel@tonic-gate #include <sys/esunddi.h> 330Sstevel@tonic-gate #include <sys/sunddi.h> 340Sstevel@tonic-gate #include <sys/obpdefs.h> 350Sstevel@tonic-gate 360Sstevel@tonic-gate #ifdef __cplusplus 370Sstevel@tonic-gate extern "C" { 380Sstevel@tonic-gate #endif 390Sstevel@tonic-gate 400Sstevel@tonic-gate #ifdef _KERNEL 410Sstevel@tonic-gate 420Sstevel@tonic-gate #define NDI_SUCCESS DDI_SUCCESS /* successful return */ 430Sstevel@tonic-gate #define NDI_FAILURE DDI_FAILURE /* unsuccessful return */ 4410923SEvan.Yan@Sun.COM #define NDI_NOMEM -2 /* failed to allocate resources */ 4510923SEvan.Yan@Sun.COM #define NDI_BADHANDLE -3 /* bad handle passed to in function */ 4610923SEvan.Yan@Sun.COM #define NDI_FAULT -4 /* fault during copyin/copyout */ 4710923SEvan.Yan@Sun.COM #define NDI_BUSY -5 /* device busy - could not offline */ 4810923SEvan.Yan@Sun.COM #define NDI_UNBOUND -6 /* device not bound to a driver */ 4910923SEvan.Yan@Sun.COM #define NDI_EINVAL -7 /* invalid request or arguments */ 5010923SEvan.Yan@Sun.COM #define NDI_ENOTSUP -8 /* operation or event not supported */ 5110923SEvan.Yan@Sun.COM #define NDI_CLAIMED NDI_SUCCESS /* event is claimed */ 5210923SEvan.Yan@Sun.COM #define NDI_UNCLAIMED -9 /* event is not claimed */ 530Sstevel@tonic-gate 540Sstevel@tonic-gate /* 550Sstevel@tonic-gate * Property functions: See also, ddipropdefs.h. 560Sstevel@tonic-gate * In general, the underlying driver MUST be held 570Sstevel@tonic-gate * to call it's property functions. 580Sstevel@tonic-gate */ 590Sstevel@tonic-gate 600Sstevel@tonic-gate /* 610Sstevel@tonic-gate * Used to create boolean properties 620Sstevel@tonic-gate */ 630Sstevel@tonic-gate int 640Sstevel@tonic-gate ndi_prop_create_boolean(dev_t match_dev, dev_info_t *dip, char *name); 650Sstevel@tonic-gate 660Sstevel@tonic-gate /* 670Sstevel@tonic-gate * Used to create, modify, and lookup integer properties 680Sstevel@tonic-gate */ 690Sstevel@tonic-gate int 700Sstevel@tonic-gate ndi_prop_update_int(dev_t match_dev, dev_info_t *dip, char *name, int data); 710Sstevel@tonic-gate 720Sstevel@tonic-gate int 730Sstevel@tonic-gate ndi_prop_update_int_array(dev_t match_dev, dev_info_t *dip, char *name, 740Sstevel@tonic-gate int *data, uint_t nelements); 750Sstevel@tonic-gate 760Sstevel@tonic-gate int 770Sstevel@tonic-gate ndi_prop_update_int64(dev_t match_dev, dev_info_t *dip, char *name, 780Sstevel@tonic-gate int64_t data); 790Sstevel@tonic-gate 800Sstevel@tonic-gate int 810Sstevel@tonic-gate ndi_prop_update_int64_array(dev_t match_dev, dev_info_t *dip, char *name, 820Sstevel@tonic-gate int64_t *data, uint_t nelements); 830Sstevel@tonic-gate 840Sstevel@tonic-gate /* 850Sstevel@tonic-gate * Used to create, modify, and lookup string properties 860Sstevel@tonic-gate */ 870Sstevel@tonic-gate int 880Sstevel@tonic-gate ndi_prop_update_string(dev_t match_dev, dev_info_t *dip, char *name, 890Sstevel@tonic-gate char *data); 900Sstevel@tonic-gate 910Sstevel@tonic-gate int 920Sstevel@tonic-gate ndi_prop_update_string_array(dev_t match_dev, dev_info_t *dip, 930Sstevel@tonic-gate char *name, char **data, uint_t nelements); 940Sstevel@tonic-gate 950Sstevel@tonic-gate /* 960Sstevel@tonic-gate * Used to create, modify, and lookup byte properties 970Sstevel@tonic-gate */ 980Sstevel@tonic-gate int 990Sstevel@tonic-gate ndi_prop_update_byte_array(dev_t match_dev, dev_info_t *dip, 1000Sstevel@tonic-gate char *name, uchar_t *data, uint_t nelements); 1010Sstevel@tonic-gate 1020Sstevel@tonic-gate /* 1030Sstevel@tonic-gate * Used to remove properties 1040Sstevel@tonic-gate */ 1050Sstevel@tonic-gate int 1060Sstevel@tonic-gate ndi_prop_remove(dev_t dev, dev_info_t *dip, char *name); 1070Sstevel@tonic-gate 1080Sstevel@tonic-gate void 1090Sstevel@tonic-gate ndi_prop_remove_all(dev_info_t *dip); 1100Sstevel@tonic-gate 1110Sstevel@tonic-gate /* 1120Sstevel@tonic-gate * Nexus Driver Functions 1130Sstevel@tonic-gate */ 1140Sstevel@tonic-gate /* 1150Sstevel@tonic-gate * Allocate and initialize a new dev_info structure. 1160Sstevel@tonic-gate * This routine will often be called at interrupt time by a nexus in 1170Sstevel@tonic-gate * response to a hotplug event, therefore memory allocations are 1180Sstevel@tonic-gate * not allowed to sleep. 1190Sstevel@tonic-gate */ 1200Sstevel@tonic-gate int 121789Sahrens ndi_devi_alloc(dev_info_t *parent, char *node_name, pnode_t nodeid, 1220Sstevel@tonic-gate dev_info_t **ret_dip); 1230Sstevel@tonic-gate 1240Sstevel@tonic-gate void 125789Sahrens ndi_devi_alloc_sleep(dev_info_t *parent, char *node_name, pnode_t nodeid, 1260Sstevel@tonic-gate dev_info_t **ret_dip); 1270Sstevel@tonic-gate 1280Sstevel@tonic-gate /* 1290Sstevel@tonic-gate * Remove an initialized (but not yet attached) dev_info 1300Sstevel@tonic-gate * node from it's parent. 1310Sstevel@tonic-gate */ 1320Sstevel@tonic-gate int 1330Sstevel@tonic-gate ndi_devi_free(dev_info_t *dip); 1340Sstevel@tonic-gate 1350Sstevel@tonic-gate /* devinfo locking: use DEVI_BUSY_OWNED in ASSERTs to verify */ 1360Sstevel@tonic-gate void ndi_devi_enter(dev_info_t *dip, int *circ); 1370Sstevel@tonic-gate void ndi_devi_exit(dev_info_t *dip, int circ); 1380Sstevel@tonic-gate int ndi_devi_tryenter(dev_info_t *dip, int *circ); 1390Sstevel@tonic-gate 1400Sstevel@tonic-gate /* devinfo ref counting */ 1410Sstevel@tonic-gate void ndi_hold_devi(dev_info_t *dip); 1420Sstevel@tonic-gate void ndi_rele_devi(dev_info_t *dip); 1430Sstevel@tonic-gate 1440Sstevel@tonic-gate /* driver ref counting */ 1450Sstevel@tonic-gate struct dev_ops *ndi_hold_driver(dev_info_t *dip); 1460Sstevel@tonic-gate void ndi_rele_driver(dev_info_t *dip); 1470Sstevel@tonic-gate 1480Sstevel@tonic-gate /* 1490Sstevel@tonic-gate * Change the node name 1500Sstevel@tonic-gate */ 1510Sstevel@tonic-gate int 1520Sstevel@tonic-gate ndi_devi_set_nodename(dev_info_t *dip, char *name, int flags); 1530Sstevel@tonic-gate 1540Sstevel@tonic-gate /* 1550Sstevel@tonic-gate * Place the devinfo in the DS_BOUND state, 1560Sstevel@tonic-gate * binding a driver to the device 1570Sstevel@tonic-gate * 1580Sstevel@tonic-gate * Flags: 1590Sstevel@tonic-gate * all flags are ignored. 1600Sstevel@tonic-gate */ 1610Sstevel@tonic-gate int 1620Sstevel@tonic-gate ndi_devi_bind_driver(dev_info_t *dip, uint_t flags); 1630Sstevel@tonic-gate 1640Sstevel@tonic-gate /* 1650Sstevel@tonic-gate * Asynchronous version of ndi_devi_bind_driver, callable from 1660Sstevel@tonic-gate * interrupt context. The dip must be a persistent node. 1670Sstevel@tonic-gate */ 1680Sstevel@tonic-gate int 1690Sstevel@tonic-gate ndi_devi_bind_driver_async(dev_info_t *dip, uint_t flags); 1700Sstevel@tonic-gate 1710Sstevel@tonic-gate /* 1720Sstevel@tonic-gate * Return devctl state of the child addressed by "name@addr". 1730Sstevel@tonic-gate * For use by a driver's DEVCTL_DEVICE_GETSTATE handler. 1740Sstevel@tonic-gate */ 1750Sstevel@tonic-gate int 1760Sstevel@tonic-gate ndi_devctl_device_getstate(dev_info_t *parent, struct devctl_iocdata *dcp, 1770Sstevel@tonic-gate uint_t *state); 1780Sstevel@tonic-gate 1790Sstevel@tonic-gate /* 1800Sstevel@tonic-gate * Transition the child addressed by "name@addr" to the online state. 1810Sstevel@tonic-gate * For use by a driver's DEVCTL_DEVICE_ONLINE handler. 1820Sstevel@tonic-gate */ 1830Sstevel@tonic-gate int 1840Sstevel@tonic-gate ndi_devctl_device_online(dev_info_t *dip, struct devctl_iocdata *dcp, 1850Sstevel@tonic-gate uint_t flags); 1860Sstevel@tonic-gate 1870Sstevel@tonic-gate /* 1880Sstevel@tonic-gate * Transition the child addressed by "name@addr" to the offline state. 1890Sstevel@tonic-gate * For use by a driver's DEVCTL_DEVICE_OFFLINE handler. 1900Sstevel@tonic-gate */ 1910Sstevel@tonic-gate int 1920Sstevel@tonic-gate ndi_devctl_device_offline(dev_info_t *dip, struct devctl_iocdata *dcp, 1930Sstevel@tonic-gate uint_t flags); 1940Sstevel@tonic-gate 1950Sstevel@tonic-gate /* 1960Sstevel@tonic-gate * Remove the child addressed by name@addr. 1970Sstevel@tonic-gate * For use by a driver's DEVCTL_DEVICE_REMOVE handler. 1980Sstevel@tonic-gate */ 1990Sstevel@tonic-gate int 2000Sstevel@tonic-gate ndi_devctl_device_remove(dev_info_t *dip, struct devctl_iocdata *dcp, 2010Sstevel@tonic-gate uint_t flags); 2020Sstevel@tonic-gate 2030Sstevel@tonic-gate /* 2040Sstevel@tonic-gate * Bus get state 2050Sstevel@tonic-gate * For use by a driver's DEVCTL_BUS_GETSTATE handler. 2060Sstevel@tonic-gate */ 2070Sstevel@tonic-gate int 2080Sstevel@tonic-gate ndi_devctl_bus_getstate(dev_info_t *dip, struct devctl_iocdata *dcp, 2090Sstevel@tonic-gate uint_t *state); 2100Sstevel@tonic-gate 2110Sstevel@tonic-gate /* 2120Sstevel@tonic-gate * Place the devinfo in the ONLINE state 2130Sstevel@tonic-gate */ 2140Sstevel@tonic-gate int 2150Sstevel@tonic-gate ndi_devi_online(dev_info_t *dip, uint_t flags); 2160Sstevel@tonic-gate 2170Sstevel@tonic-gate /* 2180Sstevel@tonic-gate * Generic devctl ioctl handler 2190Sstevel@tonic-gate */ 2200Sstevel@tonic-gate int 2210Sstevel@tonic-gate ndi_devctl_ioctl(dev_info_t *dip, int cmd, intptr_t arg, int mode, 2220Sstevel@tonic-gate uint_t flags); 2230Sstevel@tonic-gate 2240Sstevel@tonic-gate /* 2250Sstevel@tonic-gate * Asynchronous version of ndi_devi_online, callable from interrupt 2260Sstevel@tonic-gate * context. The dip must be a persistent node. 2270Sstevel@tonic-gate */ 2280Sstevel@tonic-gate int 2290Sstevel@tonic-gate ndi_devi_online_async(dev_info_t *dip, uint_t flags); 2300Sstevel@tonic-gate 2310Sstevel@tonic-gate 2320Sstevel@tonic-gate /* 2330Sstevel@tonic-gate * Configure children of a nexus node. 2340Sstevel@tonic-gate * 2350Sstevel@tonic-gate * Flags: 2360Sstevel@tonic-gate * NDI_ONLINE_ATTACH - Attach driver to devinfo node when placing 2370Sstevel@tonic-gate * the device Online. 2380Sstevel@tonic-gate * NDI_CONFIG - Recursively configure children if child is nexus node 2390Sstevel@tonic-gate */ 2400Sstevel@tonic-gate int 2410Sstevel@tonic-gate ndi_devi_config(dev_info_t *dip, int flags); 2420Sstevel@tonic-gate 2430Sstevel@tonic-gate int 2440Sstevel@tonic-gate ndi_devi_config_driver(dev_info_t *dip, int flags, major_t major); 2450Sstevel@tonic-gate 2460Sstevel@tonic-gate int 2470Sstevel@tonic-gate ndi_devi_config_one(dev_info_t *dip, char *devnm, dev_info_t **dipp, int flags); 2480Sstevel@tonic-gate 2490Sstevel@tonic-gate /* 2500Sstevel@tonic-gate * Unconfigure children of a nexus node. 2510Sstevel@tonic-gate * 2520Sstevel@tonic-gate * Flags: 2530Sstevel@tonic-gate * NDI_DEVI_REMOVE - Remove child devinfo nodes 2540Sstevel@tonic-gate * 2550Sstevel@tonic-gate * NDI_UNCONFIG - Put child devinfo nodes to uninitialized state, 2560Sstevel@tonic-gate * release resources held by child nodes. 2570Sstevel@tonic-gate */ 2580Sstevel@tonic-gate int 2590Sstevel@tonic-gate ndi_devi_unconfig(dev_info_t *dip, int flags); 2600Sstevel@tonic-gate 2610Sstevel@tonic-gate int 2620Sstevel@tonic-gate e_ddi_devi_unconfig(dev_info_t *dip, dev_info_t **dipp, int flags); 2630Sstevel@tonic-gate 2640Sstevel@tonic-gate int 2650Sstevel@tonic-gate ndi_devi_unconfig_one(dev_info_t *dip, char *devnm, dev_info_t **dipp, 2660Sstevel@tonic-gate int flags); 2670Sstevel@tonic-gate 2680Sstevel@tonic-gate int 2690Sstevel@tonic-gate ndi_devi_unconfig_driver(dev_info_t *dip, int flags, major_t major); 2700Sstevel@tonic-gate 2716313Skrishnae void 2726313Skrishnae ndi_set_bus_private(dev_info_t *dip, boolean_t up, uint32_t port_type, 2736313Skrishnae void *data); 2746313Skrishnae 2756313Skrishnae void * 2766313Skrishnae ndi_get_bus_private(dev_info_t *dip, boolean_t up); 2776313Skrishnae 2786313Skrishnae boolean_t 2796313Skrishnae ndi_port_type(dev_info_t *dip, boolean_t up, uint32_t port_type); 2806313Skrishnae 2810Sstevel@tonic-gate /* 28212683SJimmy.Vetayases@oracle.com * Interrupt Resource Management (IRM) Pools. 2838561SScott.Carter@Sun.COM */ 2848561SScott.Carter@Sun.COM int 2858561SScott.Carter@Sun.COM ndi_irm_create(dev_info_t *dip, ddi_irm_params_t *paramsp, 2868561SScott.Carter@Sun.COM ddi_irm_pool_t **pool_retp); 2878561SScott.Carter@Sun.COM 2888561SScott.Carter@Sun.COM int 2898561SScott.Carter@Sun.COM ndi_irm_destroy(ddi_irm_pool_t *poolp); 2908561SScott.Carter@Sun.COM 29112683SJimmy.Vetayases@oracle.com int 29212683SJimmy.Vetayases@oracle.com ndi_irm_resize_pool(ddi_irm_pool_t *poolp, uint_t newsize); 29312683SJimmy.Vetayases@oracle.com 2948561SScott.Carter@Sun.COM /* 2950Sstevel@tonic-gate * Take a device node "Offline". 2960Sstevel@tonic-gate * 2970Sstevel@tonic-gate * Offline means to detach the device instance from the bound 2980Sstevel@tonic-gate * driver and setting the devinfo state to prevent deferred attach 2990Sstevel@tonic-gate * from re-attaching the device instance. 3000Sstevel@tonic-gate * 3010Sstevel@tonic-gate * Flags: 3020Sstevel@tonic-gate * NDI_DEVI_REMOVE - Remove the node from the devinfo tree after 3030Sstevel@tonic-gate * first taking it Offline. 3040Sstevel@tonic-gate */ 3050Sstevel@tonic-gate 3062155Scth #define NDI_DEVI_REMOVE 0x00000001 /* remove after unconfig */ 3072155Scth #define NDI_ONLINE_ATTACH 0x00000002 /* online/attach after config */ 3082155Scth #define NDI_MDI_FALLBACK 0x00000004 /* Leadville to fallback to phci */ 3092155Scth #define NDI_CONFIG 0x00000008 /* recursively config descendants */ 3102155Scth #define NDI_UNCONFIG 0x00000010 /* unconfig to uninitialized state */ 3112155Scth #define NDI_DEVI_BIND 0x00000020 /* transition to DS_BOUND state */ 3122155Scth #define NDI_DEVI_PERSIST 0x00000040 /* do not config offlined nodes */ 3132155Scth #define NDI_PROMNAME 0x00000080 /* name comes from prom */ 3142155Scth #define NDI_DEVFS_CLEAN 0x00001000 /* clean dv_nodes only, no detach */ 3152155Scth #define NDI_AUTODETACH 0x00002000 /* moduninstall daemon */ 3162155Scth #define NDI_NO_EVENT 0x00004000 /* don't devfs add/remove events */ 3172155Scth #define NDI_DEVI_DEBUG 0x00008000 /* turn on observability */ 3182155Scth #define NDI_CONFIG_REPROBE 0x00010000 /* force reprobe (deferred attach) */ 3192155Scth #define NDI_DEVI_ONLINE 0x00020000 /* force offlined device to online */ 3202155Scth #define NDI_DEVI_OFFLINE 0x00040000 /* set detached device to offline */ 3212155Scth #define NDI_POST_EVENT 0x00080000 /* Post NDI events before remove */ 3222155Scth #define NDI_BRANCH_EVENT_OP 0x01000000 /* branch op needs branch event */ 3232155Scth #define NDI_NO_EVENT_STATE_CHNG 0x02000000 /* don't change the event state */ 3242155Scth #define NDI_DRV_CONF_REPROBE 0x04000000 /* reprobe conf-enum'd nodes only */ 3252155Scth #define NDI_DETACH_DRIVER 0x08000000 /* performing driver_detach */ 3262155Scth #define NDI_MTC_OFF 0x10000000 /* disable multi-threading */ 32710696SDavid.Hollister@Sun.COM #define NDI_USER_REQ 0x20000000 /* user requested operation */ 3280Sstevel@tonic-gate 3290Sstevel@tonic-gate /* ndi interface flag values */ 3300Sstevel@tonic-gate #define NDI_SLEEP 0x000000 3310Sstevel@tonic-gate #define NDI_NOSLEEP 0x100000 3320Sstevel@tonic-gate #define NDI_EVENT_NOPASS 0x200000 /* do not pass event req up the tree */ 3330Sstevel@tonic-gate 3340Sstevel@tonic-gate int 3350Sstevel@tonic-gate ndi_devi_offline(dev_info_t *dip, uint_t flags); 3360Sstevel@tonic-gate 3370Sstevel@tonic-gate /* 3380Sstevel@tonic-gate * Find the child dev_info node of parent nexus 'p' whose name 3390Sstevel@tonic-gate * matches "cname"@"caddr". Use ndi_devi_findchild() instead. 3400Sstevel@tonic-gate */ 3410Sstevel@tonic-gate dev_info_t * 3420Sstevel@tonic-gate ndi_devi_find(dev_info_t *p, char *cname, char *caddr); 3430Sstevel@tonic-gate 3440Sstevel@tonic-gate /* 3450Sstevel@tonic-gate * Find the child dev_info node of parent nexus 'p' whose name 3460Sstevel@tonic-gate * matches device name "name"@"addr". 3470Sstevel@tonic-gate */ 3480Sstevel@tonic-gate dev_info_t * 3490Sstevel@tonic-gate ndi_devi_findchild(dev_info_t *p, char *devname); 3500Sstevel@tonic-gate 3510Sstevel@tonic-gate /* 35210696SDavid.Hollister@Sun.COM * Find the child dev_info node of parent nexus 'p' whose name 35310696SDavid.Hollister@Sun.COM * matches "dname"@"ua". If a child doesn't have a "ua" 35410696SDavid.Hollister@Sun.COM * value, it calls the function "make_ua" to create it. 35510696SDavid.Hollister@Sun.COM */ 35610696SDavid.Hollister@Sun.COM dev_info_t * 35710696SDavid.Hollister@Sun.COM ndi_devi_findchild_by_callback(dev_info_t *p, char *dname, char *ua, 35810696SDavid.Hollister@Sun.COM int (*make_ua)(dev_info_t *, char *, int)); 35910696SDavid.Hollister@Sun.COM 36010696SDavid.Hollister@Sun.COM /* 36110696SDavid.Hollister@Sun.COM * Maintain DEVI_DEVICE_REMOVED hotplug devi_state for remove/reinsert hotplug 36210696SDavid.Hollister@Sun.COM * of open devices. 36310696SDavid.Hollister@Sun.COM */ 36410696SDavid.Hollister@Sun.COM int 36510696SDavid.Hollister@Sun.COM ndi_devi_device_isremoved(dev_info_t *dip); 36610696SDavid.Hollister@Sun.COM int 36710696SDavid.Hollister@Sun.COM ndi_devi_device_remove(dev_info_t *dip); 36810696SDavid.Hollister@Sun.COM int 36910696SDavid.Hollister@Sun.COM ndi_devi_device_insert(dev_info_t *dip); 37010696SDavid.Hollister@Sun.COM 37110696SDavid.Hollister@Sun.COM /* 3720Sstevel@tonic-gate * generate debug msg via NDI_DEVI_DEBUG flag 3730Sstevel@tonic-gate */ 3740Sstevel@tonic-gate #define NDI_DEBUG(flags, args) \ 3750Sstevel@tonic-gate if (flags & NDI_DEVI_DEBUG) cmn_err args 3760Sstevel@tonic-gate 3770Sstevel@tonic-gate /* 3780Sstevel@tonic-gate * Copy in the devctl IOCTL data structure and the strings referenced 3790Sstevel@tonic-gate * by the structure. 3800Sstevel@tonic-gate * 3810Sstevel@tonic-gate * Convenience functions for use by nexus drivers as part of the 3820Sstevel@tonic-gate * implementation of devctl IOCTL handling. 3830Sstevel@tonic-gate */ 3840Sstevel@tonic-gate int 3850Sstevel@tonic-gate ndi_dc_allochdl(void *iocarg, struct devctl_iocdata **rdcp); 3860Sstevel@tonic-gate 3870Sstevel@tonic-gate void 3880Sstevel@tonic-gate ndi_dc_freehdl(struct devctl_iocdata *dcp); 3890Sstevel@tonic-gate 3900Sstevel@tonic-gate char * 3910Sstevel@tonic-gate ndi_dc_getpath(struct devctl_iocdata *dcp); 3920Sstevel@tonic-gate 3930Sstevel@tonic-gate char * 3940Sstevel@tonic-gate ndi_dc_getname(struct devctl_iocdata *dcp); 3950Sstevel@tonic-gate 3960Sstevel@tonic-gate char * 3970Sstevel@tonic-gate ndi_dc_getaddr(struct devctl_iocdata *dcp); 3980Sstevel@tonic-gate 3990Sstevel@tonic-gate nvlist_t * 4000Sstevel@tonic-gate ndi_dc_get_ap_data(struct devctl_iocdata *dcp); 4010Sstevel@tonic-gate 4020Sstevel@tonic-gate char * 4030Sstevel@tonic-gate ndi_dc_getminorname(struct devctl_iocdata *dcp); 4040Sstevel@tonic-gate 4050Sstevel@tonic-gate int 4060Sstevel@tonic-gate ndi_dc_return_dev_state(dev_info_t *dip, struct devctl_iocdata *dcp); 4070Sstevel@tonic-gate 4080Sstevel@tonic-gate int 4090Sstevel@tonic-gate ndi_dc_return_ap_state(devctl_ap_state_t *ap, struct devctl_iocdata *dcp); 4100Sstevel@tonic-gate 4110Sstevel@tonic-gate int 4120Sstevel@tonic-gate ndi_dc_return_bus_state(dev_info_t *dip, struct devctl_iocdata *dcp); 4130Sstevel@tonic-gate 4140Sstevel@tonic-gate int 4150Sstevel@tonic-gate ndi_dc_devi_create(struct devctl_iocdata *dcp, dev_info_t *pdip, int flags, 4160Sstevel@tonic-gate dev_info_t **rdip); 4170Sstevel@tonic-gate 4180Sstevel@tonic-gate int 4190Sstevel@tonic-gate ndi_get_bus_state(dev_info_t *dip, uint_t *rstate); 4200Sstevel@tonic-gate 4210Sstevel@tonic-gate int 4220Sstevel@tonic-gate ndi_set_bus_state(dev_info_t *dip, uint_t state); 4230Sstevel@tonic-gate 4240Sstevel@tonic-gate /* 4250Sstevel@tonic-gate * Post an event notification up the device tree hierarchy to the 4260Sstevel@tonic-gate * parent nexus, until claimed by a bus nexus driver or the top 4270Sstevel@tonic-gate * of the dev_info tree is reached. 4280Sstevel@tonic-gate */ 4290Sstevel@tonic-gate int 4300Sstevel@tonic-gate ndi_post_event(dev_info_t *dip, dev_info_t *rdip, ddi_eventcookie_t eventhdl, 4310Sstevel@tonic-gate void *impl_data); 4320Sstevel@tonic-gate 4330Sstevel@tonic-gate /* 4340Sstevel@tonic-gate * Called by the NDI Event Framework to deliver a registration request to the 4350Sstevel@tonic-gate * appropriate bus nexus driver. 4360Sstevel@tonic-gate */ 4370Sstevel@tonic-gate int 4380Sstevel@tonic-gate ndi_busop_add_eventcall(dev_info_t *dip, dev_info_t *rdip, 4390Sstevel@tonic-gate ddi_eventcookie_t eventhdl, void (*callback)(), void *arg, 4400Sstevel@tonic-gate ddi_callback_id_t *cb_id); 4410Sstevel@tonic-gate 4420Sstevel@tonic-gate /* 4430Sstevel@tonic-gate * Called by the NDI Event Framework to deliver an unregister request to the 4440Sstevel@tonic-gate * appropriate bus nexus driver. 4450Sstevel@tonic-gate */ 4460Sstevel@tonic-gate int 4470Sstevel@tonic-gate ndi_busop_remove_eventcall(dev_info_t *ddip, ddi_callback_id_t id); 4480Sstevel@tonic-gate 4490Sstevel@tonic-gate /* 4500Sstevel@tonic-gate * Called by the NDI Event Framework and/or a bus nexus driver's 4510Sstevel@tonic-gate * implementation of the (*bus_get_eventcookie)() interface up the device tree 4520Sstevel@tonic-gate * hierarchy, until claimed by a bus nexus driver or the top of the dev_info 4530Sstevel@tonic-gate * tree is reached. The NDI Event Framework will skip nexus drivers which are 4540Sstevel@tonic-gate * not configured to handle NDI events. 4550Sstevel@tonic-gate */ 4560Sstevel@tonic-gate int 4570Sstevel@tonic-gate ndi_busop_get_eventcookie(dev_info_t *dip, dev_info_t *rdip, char *name, 4580Sstevel@tonic-gate ddi_eventcookie_t *event_cookiep); 4590Sstevel@tonic-gate 4600Sstevel@tonic-gate /* 4610Sstevel@tonic-gate * ndi event callback support routines: 4620Sstevel@tonic-gate * 4630Sstevel@tonic-gate * these functions require an opaque ndi event handle 4640Sstevel@tonic-gate */ 4650Sstevel@tonic-gate typedef struct ndi_event_hdl *ndi_event_hdl_t; 4660Sstevel@tonic-gate 4670Sstevel@tonic-gate /* 4680Sstevel@tonic-gate * structure for maintaining each registered callback 4690Sstevel@tonic-gate */ 4700Sstevel@tonic-gate typedef struct ndi_event_callbacks { 4710Sstevel@tonic-gate struct ndi_event_callbacks *ndi_evtcb_next; 4720Sstevel@tonic-gate struct ndi_event_callbacks *ndi_evtcb_prev; 4730Sstevel@tonic-gate dev_info_t *ndi_evtcb_dip; 4740Sstevel@tonic-gate char *devname; /* name of device defining this callback */ 4750Sstevel@tonic-gate void (*ndi_evtcb_callback)(); 4760Sstevel@tonic-gate void *ndi_evtcb_arg; 4770Sstevel@tonic-gate ddi_eventcookie_t ndi_evtcb_cookie; 4780Sstevel@tonic-gate } ndi_event_callbacks_t; 4790Sstevel@tonic-gate 4800Sstevel@tonic-gate /* 4810Sstevel@tonic-gate * a nexus driver defines events that it can support using the 4820Sstevel@tonic-gate * following structure 4830Sstevel@tonic-gate */ 4840Sstevel@tonic-gate typedef struct ndi_event_definition { 4850Sstevel@tonic-gate int ndi_event_tag; 4860Sstevel@tonic-gate char *ndi_event_name; 4870Sstevel@tonic-gate ddi_plevel_t ndi_event_plevel; 4880Sstevel@tonic-gate uint_t ndi_event_attributes; 4890Sstevel@tonic-gate } ndi_event_definition_t; 4900Sstevel@tonic-gate 4910Sstevel@tonic-gate typedef struct ndi_event_cookie { 49210696SDavid.Hollister@Sun.COM ndi_event_definition_t *definition; /* Event Description */ 4930Sstevel@tonic-gate dev_info_t *ddip; /* Devi defining this event */ 4940Sstevel@tonic-gate ndi_event_callbacks_t *callback_list; /* Cb's reg'd to w/ this evt */ 49510696SDavid.Hollister@Sun.COM struct ndi_event_cookie *next_cookie; /* Next cookie def'd in hdl */ 4960Sstevel@tonic-gate } ndi_event_cookie_t; 4970Sstevel@tonic-gate 4980Sstevel@tonic-gate 4990Sstevel@tonic-gate #define NDI_EVENT(cookie) ((struct ndi_event_cookie *)(void *)(cookie)) 5000Sstevel@tonic-gate #define NDI_EVENT_NAME(cookie) (NDI_EVENT(cookie)->definition->ndi_event_name) 5010Sstevel@tonic-gate #define NDI_EVENT_TAG(cookie) (NDI_EVENT(cookie)->definition->ndi_event_tag) 5020Sstevel@tonic-gate #define NDI_EVENT_ATTRIBUTES(cookie) \ 5030Sstevel@tonic-gate (NDI_EVENT(cookie)->definition->ndi_event_attributes) 5040Sstevel@tonic-gate #define NDI_EVENT_PLEVEL(cookie) \ 5050Sstevel@tonic-gate (NDI_EVENT(cookie)->definition->ndi_event_plevel) 5060Sstevel@tonic-gate #define NDI_EVENT_DDIP(cookie) (NDI_EVENT(cookie)->ddip) 5070Sstevel@tonic-gate 5080Sstevel@tonic-gate /* ndi_event_attributes */ 5090Sstevel@tonic-gate #define NDI_EVENT_POST_TO_ALL 0x0 /* broadcast: post to all handlers */ 5100Sstevel@tonic-gate #define NDI_EVENT_POST_TO_TGT 0x1 /* call only specific child's hdlr */ 5110Sstevel@tonic-gate 5120Sstevel@tonic-gate typedef struct ndi_event_set { 5130Sstevel@tonic-gate ushort_t ndi_events_version; 5140Sstevel@tonic-gate ushort_t ndi_n_events; 5150Sstevel@tonic-gate ndi_event_definition_t *ndi_event_defs; 5160Sstevel@tonic-gate } ndi_event_set_t; 5170Sstevel@tonic-gate 5180Sstevel@tonic-gate 5190Sstevel@tonic-gate #define NDI_EVENTS_REV0 0 5200Sstevel@tonic-gate #define NDI_EVENTS_REV1 1 5210Sstevel@tonic-gate 5220Sstevel@tonic-gate /* 5230Sstevel@tonic-gate * allocate an ndi event handle 5240Sstevel@tonic-gate */ 5250Sstevel@tonic-gate int 5260Sstevel@tonic-gate ndi_event_alloc_hdl(dev_info_t *dip, ddi_iblock_cookie_t cookie, 5270Sstevel@tonic-gate ndi_event_hdl_t *ndi_event_hdl, uint_t flag); 5280Sstevel@tonic-gate 5290Sstevel@tonic-gate /* 5300Sstevel@tonic-gate * free the ndi event handle 5310Sstevel@tonic-gate */ 5320Sstevel@tonic-gate int 5330Sstevel@tonic-gate ndi_event_free_hdl(ndi_event_hdl_t handle); 5340Sstevel@tonic-gate 5350Sstevel@tonic-gate /* 5360Sstevel@tonic-gate * bind or unbind a set of events to/from the event handle 5370Sstevel@tonic-gate */ 5380Sstevel@tonic-gate int 5390Sstevel@tonic-gate ndi_event_bind_set(ndi_event_hdl_t handle, 5400Sstevel@tonic-gate ndi_event_set_t *ndi_event_set, 5410Sstevel@tonic-gate uint_t flag); 5420Sstevel@tonic-gate 5430Sstevel@tonic-gate int 5440Sstevel@tonic-gate ndi_event_unbind_set(ndi_event_hdl_t handle, 5450Sstevel@tonic-gate ndi_event_set_t *ndi_event_set, 5460Sstevel@tonic-gate uint_t flag); 5470Sstevel@tonic-gate 5480Sstevel@tonic-gate /* 5490Sstevel@tonic-gate * get an event cookie 5500Sstevel@tonic-gate */ 5510Sstevel@tonic-gate int 55210696SDavid.Hollister@Sun.COM ndi_event_retrieve_cookie(ndi_event_hdl_t handle, 5530Sstevel@tonic-gate dev_info_t *child_dip, 5540Sstevel@tonic-gate char *eventname, 5550Sstevel@tonic-gate ddi_eventcookie_t *cookiep, 5560Sstevel@tonic-gate uint_t flag); 5570Sstevel@tonic-gate 5580Sstevel@tonic-gate /* 5590Sstevel@tonic-gate * add an event callback info to the ndi event handle 5600Sstevel@tonic-gate */ 5610Sstevel@tonic-gate int 56210696SDavid.Hollister@Sun.COM ndi_event_add_callback(ndi_event_hdl_t handle, 5630Sstevel@tonic-gate dev_info_t *child_dip, 5640Sstevel@tonic-gate ddi_eventcookie_t cookie, 5650Sstevel@tonic-gate void (*event_callback) 5660Sstevel@tonic-gate (dev_info_t *, 5670Sstevel@tonic-gate ddi_eventcookie_t, 5680Sstevel@tonic-gate void *arg, 5690Sstevel@tonic-gate void *impldata), 5700Sstevel@tonic-gate void *arg, 5710Sstevel@tonic-gate uint_t flag, 5720Sstevel@tonic-gate ddi_callback_id_t *cb_id); 5730Sstevel@tonic-gate 5740Sstevel@tonic-gate /* 5750Sstevel@tonic-gate * remove an event callback registration from the ndi event handle 5760Sstevel@tonic-gate */ 5770Sstevel@tonic-gate int 5780Sstevel@tonic-gate ndi_event_remove_callback(ndi_event_hdl_t handle, ddi_callback_id_t id); 5790Sstevel@tonic-gate 5800Sstevel@tonic-gate /* 5810Sstevel@tonic-gate * perform callbacks for a specified cookie 5820Sstevel@tonic-gate */ 5830Sstevel@tonic-gate int 5840Sstevel@tonic-gate ndi_event_run_callbacks(ndi_event_hdl_t handle, dev_info_t *child_dip, 5850Sstevel@tonic-gate ddi_eventcookie_t cookie, void *bus_impldata); 5860Sstevel@tonic-gate 5870Sstevel@tonic-gate /* 5880Sstevel@tonic-gate * do callback for just one child_dip, regardless of attributes 5890Sstevel@tonic-gate */ 5900Sstevel@tonic-gate int ndi_event_do_callback(ndi_event_hdl_t handle, dev_info_t *child_dip, 5910Sstevel@tonic-gate ddi_eventcookie_t cookie, void *bus_impldata); 5920Sstevel@tonic-gate 5930Sstevel@tonic-gate /* 5940Sstevel@tonic-gate * ndi_event_tag_to_cookie: utility function to find an event cookie 5950Sstevel@tonic-gate * given an event tag 5960Sstevel@tonic-gate */ 5970Sstevel@tonic-gate ddi_eventcookie_t 5980Sstevel@tonic-gate ndi_event_tag_to_cookie(ndi_event_hdl_t handle, int event_tag); 5990Sstevel@tonic-gate 6000Sstevel@tonic-gate /* 6010Sstevel@tonic-gate * ndi_event_cookie_to_tag: utility function to find an event tag 6020Sstevel@tonic-gate * given an event_cookie 6030Sstevel@tonic-gate */ 6040Sstevel@tonic-gate int 6050Sstevel@tonic-gate ndi_event_cookie_to_tag(ndi_event_hdl_t handle, 6060Sstevel@tonic-gate ddi_eventcookie_t cookie); 6070Sstevel@tonic-gate 6080Sstevel@tonic-gate /* 6090Sstevel@tonic-gate * ndi_event_cookie_to_name: utility function to find an event 6100Sstevel@tonic-gate * name given an event_cookie 6110Sstevel@tonic-gate */ 6120Sstevel@tonic-gate char * 6130Sstevel@tonic-gate ndi_event_cookie_to_name(ndi_event_hdl_t handle, 6140Sstevel@tonic-gate ddi_eventcookie_t cookie); 6150Sstevel@tonic-gate 6160Sstevel@tonic-gate /* 6170Sstevel@tonic-gate * ndi_event_tag_to_name: utility function to find an event 6180Sstevel@tonic-gate * name given an event_tag 6190Sstevel@tonic-gate */ 6200Sstevel@tonic-gate char * 62110696SDavid.Hollister@Sun.COM ndi_event_tag_to_name(ndi_event_hdl_t handle, int event_tag); 6220Sstevel@tonic-gate 6230Sstevel@tonic-gate dev_info_t * 6240Sstevel@tonic-gate ndi_devi_config_vhci(char *, int); 6250Sstevel@tonic-gate 6260Sstevel@tonic-gate #ifdef DEBUG 6270Sstevel@tonic-gate /* 6280Sstevel@tonic-gate * ndi_event_dump_hdl: debug functionality used to display event handle 6290Sstevel@tonic-gate */ 6300Sstevel@tonic-gate void 6310Sstevel@tonic-gate ndi_event_dump_hdl(struct ndi_event_hdl *hdl, char *location); 6320Sstevel@tonic-gate #endif 6330Sstevel@tonic-gate 6340Sstevel@tonic-gate /* 6350Sstevel@tonic-gate * Default busop bus_config helper functions 6360Sstevel@tonic-gate */ 6370Sstevel@tonic-gate int 6380Sstevel@tonic-gate ndi_busop_bus_config(dev_info_t *pdip, uint_t flags, ddi_bus_config_op_t op, 6390Sstevel@tonic-gate void *arg, dev_info_t **child, clock_t reset_delay); 6400Sstevel@tonic-gate 6410Sstevel@tonic-gate int 6420Sstevel@tonic-gate ndi_busop_bus_unconfig(dev_info_t *dip, uint_t flags, ddi_bus_config_op_t op, 6430Sstevel@tonic-gate void *arg); 6440Sstevel@tonic-gate 64510923SEvan.Yan@Sun.COM /* 64610923SEvan.Yan@Sun.COM * Called by the Nexus/HPC drivers to register, unregister and interact 64710923SEvan.Yan@Sun.COM * with the hotplug framework for the specified hotplug connection. 64810923SEvan.Yan@Sun.COM */ 64910923SEvan.Yan@Sun.COM int 65010923SEvan.Yan@Sun.COM ndi_hp_register(dev_info_t *dip, ddi_hp_cn_info_t *info_p); 65110923SEvan.Yan@Sun.COM 65210923SEvan.Yan@Sun.COM int 65310923SEvan.Yan@Sun.COM ndi_hp_unregister(dev_info_t *dip, char *cn_name); 65410923SEvan.Yan@Sun.COM 65510923SEvan.Yan@Sun.COM int 65610923SEvan.Yan@Sun.COM ndi_hp_state_change_req(dev_info_t *dip, char *cn_name, 65710923SEvan.Yan@Sun.COM ddi_hp_cn_state_t state, uint_t flag); 65810923SEvan.Yan@Sun.COM 65910923SEvan.Yan@Sun.COM void 66010923SEvan.Yan@Sun.COM ndi_hp_walk_cn(dev_info_t *dip, int (*f)(ddi_hp_cn_info_t *, void *), 66110923SEvan.Yan@Sun.COM void *arg); 6620Sstevel@tonic-gate 6630Sstevel@tonic-gate /* 6640Sstevel@tonic-gate * Bus Resource allocation structures and function prototypes exported 6650Sstevel@tonic-gate * by busra module 6660Sstevel@tonic-gate */ 6670Sstevel@tonic-gate 6680Sstevel@tonic-gate /* structure for specifying a request */ 6690Sstevel@tonic-gate typedef struct ndi_ra_request { 6700Sstevel@tonic-gate uint_t ra_flags; /* General flags */ 6710Sstevel@tonic-gate /* see bit definitions below */ 6720Sstevel@tonic-gate 6730Sstevel@tonic-gate uint64_t ra_len; /* Requested allocation length */ 6740Sstevel@tonic-gate 6750Sstevel@tonic-gate uint64_t ra_addr; /* Specific base address requested */ 6760Sstevel@tonic-gate 6770Sstevel@tonic-gate uint64_t ra_boundbase; /* Base address of the area for */ 6780Sstevel@tonic-gate /* the allocated resource to be */ 6790Sstevel@tonic-gate /* restricted to */ 6800Sstevel@tonic-gate 6810Sstevel@tonic-gate uint64_t ra_boundlen; /* Length of the area, starting */ 68210696SDavid.Hollister@Sun.COM /* from ra_boundbase, for the */ 6830Sstevel@tonic-gate /* allocated resource to be */ 68410696SDavid.Hollister@Sun.COM /* restricted to. */ 6850Sstevel@tonic-gate 6860Sstevel@tonic-gate uint64_t ra_align_mask; /* Alignment mask used for */ 6870Sstevel@tonic-gate /* allocated base address */ 6880Sstevel@tonic-gate } ndi_ra_request_t; 6890Sstevel@tonic-gate 6900Sstevel@tonic-gate 6910Sstevel@tonic-gate /* ra_flags bit definitions */ 6920Sstevel@tonic-gate #define NDI_RA_ALIGN_SIZE 0x0001 /* Set the alignment of the */ 6930Sstevel@tonic-gate /* allocated resource address */ 6940Sstevel@tonic-gate /* according to the ra_len */ 6950Sstevel@tonic-gate /* value (alignment mask will */ 6960Sstevel@tonic-gate /* be (ra_len - 1)). Value of */ 6970Sstevel@tonic-gate /* ra_len has to be power of 2. */ 6980Sstevel@tonic-gate /* If this flag is set, value of */ 6990Sstevel@tonic-gate /* ra_align_mask will be ignored. */ 7000Sstevel@tonic-gate 7010Sstevel@tonic-gate 7020Sstevel@tonic-gate #define NDI_RA_ALLOC_BOUNDED 0x0002 /* Indicates that the resource */ 7030Sstevel@tonic-gate /* should be restricted to the */ 7040Sstevel@tonic-gate /* area specified by ra_boundbase */ 7050Sstevel@tonic-gate /* and ra_boundlen */ 7060Sstevel@tonic-gate 7070Sstevel@tonic-gate #define NDI_RA_ALLOC_SPECIFIED 0x0004 /* Indicates that a specific */ 7080Sstevel@tonic-gate /* address (ra_addr value) is */ 7090Sstevel@tonic-gate /* requested. */ 7100Sstevel@tonic-gate 7110Sstevel@tonic-gate #define NDI_RA_ALLOC_PARTIAL_OK 0x0008 /* Indicates if requested size */ 7120Sstevel@tonic-gate /* (ra_len) chunk is not available */ 7130Sstevel@tonic-gate /* then allocate as big chunk as */ 7140Sstevel@tonic-gate /* possible which is less than or */ 7150Sstevel@tonic-gate /* equal to ra_len size. */ 7160Sstevel@tonic-gate 7170Sstevel@tonic-gate 7180Sstevel@tonic-gate /* return values specific to bus resource allocator */ 7190Sstevel@tonic-gate #define NDI_RA_PARTIAL_REQ -7 7200Sstevel@tonic-gate 7210Sstevel@tonic-gate 7220Sstevel@tonic-gate 7230Sstevel@tonic-gate 7240Sstevel@tonic-gate /* Predefined types for generic type of resources */ 7250Sstevel@tonic-gate #define NDI_RA_TYPE_MEM "memory" 7260Sstevel@tonic-gate #define NDI_RA_TYPE_IO "io" 7270Sstevel@tonic-gate #define NDI_RA_TYPE_PCI_BUSNUM "pci_bus_number" 7280Sstevel@tonic-gate #define NDI_RA_TYPE_PCI_PREFETCH_MEM "pci_prefetchable_memory" 7290Sstevel@tonic-gate #define NDI_RA_TYPE_INTR "interrupt" 7300Sstevel@tonic-gate 7310Sstevel@tonic-gate /* flag bit definition */ 7320Sstevel@tonic-gate #define NDI_RA_PASS 0x0001 /* pass request up the dev tree */ 7330Sstevel@tonic-gate 7340Sstevel@tonic-gate /* 7350Sstevel@tonic-gate * Prototype definitions for functions exported 7360Sstevel@tonic-gate */ 7370Sstevel@tonic-gate 7380Sstevel@tonic-gate int 7390Sstevel@tonic-gate ndi_ra_map_setup(dev_info_t *dip, char *type); 7400Sstevel@tonic-gate 7410Sstevel@tonic-gate int 7420Sstevel@tonic-gate ndi_ra_map_destroy(dev_info_t *dip, char *type); 7430Sstevel@tonic-gate 7440Sstevel@tonic-gate int 7450Sstevel@tonic-gate ndi_ra_alloc(dev_info_t *dip, ndi_ra_request_t *req, uint64_t *basep, 7460Sstevel@tonic-gate uint64_t *lenp, char *type, uint_t flag); 7470Sstevel@tonic-gate 7480Sstevel@tonic-gate int 7490Sstevel@tonic-gate ndi_ra_free(dev_info_t *dip, uint64_t base, uint64_t len, char *type, 7500Sstevel@tonic-gate uint_t flag); 7510Sstevel@tonic-gate 7520Sstevel@tonic-gate /* 7530Sstevel@tonic-gate * ndi_dev_is_prom_node: Return non-zero if the node is a prom node 7540Sstevel@tonic-gate */ 7550Sstevel@tonic-gate int ndi_dev_is_prom_node(dev_info_t *); 7560Sstevel@tonic-gate 7570Sstevel@tonic-gate /* 7580Sstevel@tonic-gate * ndi_dev_is_pseudo_node: Return non-zero if the node is a pseudo node. 7590Sstevel@tonic-gate * NB: all non-prom nodes are pseudo nodes. 7600Sstevel@tonic-gate * c.f. ndi_dev_is_persistent_node 7610Sstevel@tonic-gate */ 7620Sstevel@tonic-gate int ndi_dev_is_pseudo_node(dev_info_t *); 7630Sstevel@tonic-gate 7640Sstevel@tonic-gate /* 7650Sstevel@tonic-gate * ndi_dev_is_persistent_node: Return non-zero if the node has the 7660Sstevel@tonic-gate * property of persistence. 7670Sstevel@tonic-gate */ 7680Sstevel@tonic-gate int ndi_dev_is_persistent_node(dev_info_t *); 7690Sstevel@tonic-gate 7700Sstevel@tonic-gate /* 77110696SDavid.Hollister@Sun.COM * ndi_dev_is_hotplug_node: Return non-zero if the node was created by hotplug. 77210696SDavid.Hollister@Sun.COM */ 77310696SDavid.Hollister@Sun.COM int ndi_dev_is_hotplug_node(dev_info_t *); 77410696SDavid.Hollister@Sun.COM 77510696SDavid.Hollister@Sun.COM /* 7768912SChris.Horne@Sun.COM * ndi_dev_is_hidden_node: Return non-zero if the node is hidden. 7778912SChris.Horne@Sun.COM */ 7788912SChris.Horne@Sun.COM int ndi_dev_is_hidden_node(dev_info_t *); 7798912SChris.Horne@Sun.COM 7808912SChris.Horne@Sun.COM /* 7818912SChris.Horne@Sun.COM * ndi_devi_set_hidden: mark a node as hidden 7828912SChris.Horne@Sun.COM * ndi_devi_clr_hidden: mark a node as visible 7838912SChris.Horne@Sun.COM */ 7848912SChris.Horne@Sun.COM void ndi_devi_set_hidden(dev_info_t *); 7858912SChris.Horne@Sun.COM void ndi_devi_clr_hidden(dev_info_t *); 7868912SChris.Horne@Sun.COM 7878912SChris.Horne@Sun.COM /* 7880Sstevel@tonic-gate * Event posted when a fault is reported 7890Sstevel@tonic-gate */ 7900Sstevel@tonic-gate #define DDI_DEVI_FAULT_EVENT "DDI:DEVI_FAULT" 7910Sstevel@tonic-gate 7920Sstevel@tonic-gate struct ddi_fault_event_data { 7930Sstevel@tonic-gate dev_info_t *f_dip; 7940Sstevel@tonic-gate ddi_fault_impact_t f_impact; 7950Sstevel@tonic-gate ddi_fault_location_t f_location; 7960Sstevel@tonic-gate const char *f_message; 7970Sstevel@tonic-gate ddi_devstate_t f_oldstate; 7980Sstevel@tonic-gate }; 7990Sstevel@tonic-gate 8000Sstevel@tonic-gate /* 8010Sstevel@tonic-gate * Access handle/DMA handle fault flag setting/clearing functions for nexi 8020Sstevel@tonic-gate */ 8030Sstevel@tonic-gate void ndi_set_acc_fault(ddi_acc_handle_t ah); 8040Sstevel@tonic-gate void ndi_clr_acc_fault(ddi_acc_handle_t ah); 8050Sstevel@tonic-gate void ndi_set_dma_fault(ddi_dma_handle_t dh); 8060Sstevel@tonic-gate void ndi_clr_dma_fault(ddi_dma_handle_t dh); 8070Sstevel@tonic-gate 8080Sstevel@tonic-gate /* Driver.conf property merging */ 80910696SDavid.Hollister@Sun.COM int ndi_merge_node(dev_info_t *, int (*)(dev_info_t *, char *, int)); 81010696SDavid.Hollister@Sun.COM void ndi_merge_wildcard_node(dev_info_t *); 8110Sstevel@tonic-gate 8128860SMatthew.Jacob@Sun.COM /* 8138860SMatthew.Jacob@Sun.COM * Ndi 'flavor' support: These interfaces are to support a nexus driver 8148860SMatthew.Jacob@Sun.COM * with multiple 'flavors' of children (devi_flavor of child), coupled 8158860SMatthew.Jacob@Sun.COM * with a child flavor-specifc private data mechanism (via devi_flavor_v 8168860SMatthew.Jacob@Sun.COM * of parent). This is provided as an extension to ddi_[sg]et_driver_private, 8178860SMatthew.Jacob@Sun.COM * where the vanilla 'flavor' is what is stored or retrieved via 8188860SMatthew.Jacob@Sun.COM * ddi_[sg]et_driver_private. 8198860SMatthew.Jacob@Sun.COM * 8208860SMatthew.Jacob@Sun.COM * Flavors are indexed with a small integer. The first flavor, flavor 8218860SMatthew.Jacob@Sun.COM * zero, is always present and reserved as the 'vanilla' flavor. 8228860SMatthew.Jacob@Sun.COM * Space for extra flavors can be allocated and private pointers 8238860SMatthew.Jacob@Sun.COM * with respect to each flavor set and retrieved. 8248860SMatthew.Jacob@Sun.COM * 8258860SMatthew.Jacob@Sun.COM * NOTE:For a nexus driver, if the need to support multiple flavors of 8268860SMatthew.Jacob@Sun.COM * children is understood from the begining, then a private 'flavor' 8278860SMatthew.Jacob@Sun.COM * mechanism can be implemented via ddi_[sg]et_driver_private. 8288860SMatthew.Jacob@Sun.COM * 8298860SMatthew.Jacob@Sun.COM * With SCSA, the need to support multiple flavors of children was not 8308860SMatthew.Jacob@Sun.COM * anticipated, and ddi_get_driver_private(9F) of an initiator port 8318860SMatthew.Jacob@Sun.COM * devinfo node was publicly defined in the DDI to return a 8328860SMatthew.Jacob@Sun.COM * scsi_device(9S) child-flavor specific value: a pointer to 8338860SMatthew.Jacob@Sun.COM * scsi_hba_tran(9S). Over the years, each time the need to support 8348860SMatthew.Jacob@Sun.COM * a new flavor of child has occurred, a new form of overload/kludge 8358860SMatthew.Jacob@Sun.COM * has been devised. The ndi 'flavors' interfaces provide a simple way 8368860SMatthew.Jacob@Sun.COM * to address this issue that can be used by both SCSA nexus support, 8378860SMatthew.Jacob@Sun.COM * and by other nexus drivers. 8388860SMatthew.Jacob@Sun.COM */ 8398860SMatthew.Jacob@Sun.COM 8408860SMatthew.Jacob@Sun.COM /* 8418860SMatthew.Jacob@Sun.COM * Interfaces to maintain flavor-specific private data for children of self 8428860SMatthew.Jacob@Sun.COM */ 8438860SMatthew.Jacob@Sun.COM #define NDI_FLAVOR_VANILLA 0 8448860SMatthew.Jacob@Sun.COM 8458860SMatthew.Jacob@Sun.COM void ndi_flavorv_alloc(dev_info_t *self, int nflavors); 8468860SMatthew.Jacob@Sun.COM void ndi_flavorv_set(dev_info_t *self, ndi_flavor_t child_flavor, void *); 8478860SMatthew.Jacob@Sun.COM void *ndi_flavorv_get(dev_info_t *self, ndi_flavor_t child_flavor); 8488860SMatthew.Jacob@Sun.COM 8498860SMatthew.Jacob@Sun.COM /* Interfaces for 'self' nexus driver to get/set flavor of child */ 8508860SMatthew.Jacob@Sun.COM void ndi_flavor_set(dev_info_t *child, ndi_flavor_t child_flavor); 8518860SMatthew.Jacob@Sun.COM ndi_flavor_t ndi_flavor_get(dev_info_t *child); 8528860SMatthew.Jacob@Sun.COM 8530Sstevel@tonic-gate #endif /* _KERNEL */ 8540Sstevel@tonic-gate 8550Sstevel@tonic-gate #ifdef __cplusplus 8560Sstevel@tonic-gate } 8570Sstevel@tonic-gate #endif 8580Sstevel@tonic-gate 8590Sstevel@tonic-gate #endif /* _SYS_SUNNDI_H */ 860